2008-12-10 03:31:15 mmap in sport driver
Daniele Pagani (ITALY)
I need to add mmap feature to the sport driver.
So, I start from:
I've read and read again the document.
Anyway, I need a third example, that is the example 2 without the bootargs, but with a buffer of BUFFER_SIZE byte.
I've seen this thread:
but nobody has answered to it and I've the same problem.
When I run my application, I receive:
mmap device ok p = (nil)
2008-12-10 07:27:44 Re: mmap in sport driver
Daniele Pagani (ITALY)
I try to better explain the problem.
I take this page:
I test example 1; of course it doesn't work, because I've not the "wrapper.h" file and I'm using uClinux-dist-2008R1.5-RC3 so I suppose that this example doesn't work with kernel2.6
Then, I test example 2; it works, and I use bootargs as max_mem=48M mem=32M so I have 16M for my test.
when I run the application, I see:
Simple VMA open, virt 2000000, phys 2000000
mmap device ok p=0x2000000
memory write/read succeed
Simple VMA close
That means that it works fine.
Now, I need to mmap a buffer that I allocate in sport driver for 2-d DMA buffer:
so, I don't understand what I need to use in order to reach this result.
So, I read from another thread:
but it doesn't work.
So, where can I find an example of mmap with kernel 2.6 with allocated buffer?
2008-12-22 11:26:24 Re: mmap in sport driver
Michael McTernan (UNITED KINGDOM)
Attached is an example that allows mmap() on the device to return regions of memory in the non-cached DMA hole. It's been used on the 2008R1.5 release and isn't particularly complete, and isn't in the kernel coding style, but may help you.
The user space code to grab pages looks something like the following:
static void *getPage(void)
static int fd = 0;
/* Check if the device has been opened */
if(fd == 0)
fd = open("/dev/dmamem0", O_RDWR);
if(fd < 0)
/* Attempt to map a page into our address space */
p = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if(p == MAP_FAILED)
Note this may not be perfect, so let me know if you find any bugs (other than dmamem_vma_close() not being correclty implemented - see the todo!!).
2008-12-22 23:12:39 Re: mmap in sport driver
Sonic Zhang (CHINA)
Please refer to function bfin_lq035q1_fb_mmap() in file linux-2.6.x/drivers/video/bfin-lq035q1-fb.c