map the DMA memory

I wrote my own capture driver (using the IPU) and used the folling code to map the DMA memory (from IPU) to user space: Normally because of DMA memory is mapped uncached, but due to size and usage, it's no problem to map it cached.

/* function to map DMA memory to user space */

static int capture_mmap(struct file *file, struct vm_area_struct *vm)

{

struct capture_device *dev = file->private_data;

size_t rsize = vm->vm_end - vm->vm_start;

int map;

int idx;

if ((vm->vm_pgoff * PAGE_SIZE) != (unsigned long)dev->dma)

  return -ENOMEM;           /\* wrong base address \*/

if \(down\_interruptible\(&dev->busy\_lock\)\)

  return -EINTR;

vm->vm_page_prot = phys_mem_access_prot(file, vm->vm_pgoff, rsize, vm->vm_page_prot);

/* map DMA memory to user process (allow cacheable, since data much larger than cache) */

if (remap_pfn_range(vm, vm->vm_start, vm->vm_pgoff, rsize, vm->vm_page_prot))

  map = EAGAIN;

else

  map = 0;

up(&dev->busy_lock);

return map;

}

If you use some driver from FreeScale/NXP, you may have to change the driver.

results for ""

    No results matching ""