Tux
Communication
Mailing lists
Documentation
User Manual
Target board info.
Target chip info.
Support
Linux support
Bugzilla
Downloads
STLinux
Updates
Search
Google


The web
stlinux.com
Distribution Guide
STMicroelectronics DMA API
ST Logo
  Contents   Next
static int foo(void)
{
	const char * dmac_id =STM_DMAC_ID;
	const char * hb_cap_channel = STM_DMA_CAP_HIGH_BW;
	unsigned long xfer_bytes =4096;
	void * src_buff = (void*)kmalloc(xfer_bytes,GFP_KERNEL);
	void * dst_buff = (void*)kmalloc(xfer_bytes,GFP_KERNEL);
	struct stm_dma_params dmap0;
	int ch_num = request_dma_bycap(&dmac_id,&hb_cap_channel,__FUNCTION__);	
	if(ch_num == -ENODEV){
		printk(" No DMA channel or DMAC available\n");
		return -ENODEV;
	}
	printk("%s IN ch %d\n",__FUNCTION__,ch_num);
	
	
	
	declare_dma_parms(
				&dmap0,
				MODE_FREERUNNING,
				STM_DMA_LIST_OPEN,
				STM_DMA_SETUP_CONTEXT_TASK,
				STM_DMA_NOBLOCK_MODE,
				STM_DMAC_ID);

	if(src_buff && dst_buff){	
		memset(src_buff,0x4,xfer_bytes);
		flush_cache_all();
	}
	
	dma_parms_addrs(&dmap0,
		virt_to_phys(src_buff),
		virt_to_phys(dst_buff),
		(unsigned long)xfer_bytes);

	dma_parms_comp_cb(&dmap0,report_on_node_complete,NULL,0);
	
	dma_parms_DIM_1_x_1(&dmap0,xfer_bytes);
	dma_compile_list(&dmap0);
	dma_xfer_list(ch_num,&dmap0);
	dma_wait_for_completion(ch_num);
	printk(" RECIEVED WAKE UP FROM DMA_API modifying for next transfer\n");		
	
	
	kfree(src_buff);

	src_buff = (void*)kmalloc(xfer_bytes,GFP_KERNEL);

	memset(src_buff,0x1,xfer_bytes);

	dma_parms_addrs(&dmap0,
			virt_to_phys(src_buff),
			virt_to_phys(dst_buff),
			xfer_bytes);
	
	dma_parms_DIM_1_x_1(&dmap0,xfer_bytes);
	
	dma_parms_comp_cb(&dmap0,report_on_node_complete_alt,NULL,0);
	
	dma_compile_list(&dmap0);

	dma_xfer_list(ch_num,&dmap0);

	dma_wait_for_completion(ch_num);

	printk(" RECIEVED WAKE UP FROM DMA_API modified  transfer\n");		
	free_dma(ch_num);

	dma_free_descriptor(&dmap0);

	kfree(src_buff);

	kfree(dst_buff);

	return 0;

}

  Contents   Next
Valid HTML 4.01! Last updated: 2006/11/09 12:20:57
© Copyright STMicroelectronics Limited, 2005
Printer