2008-12-10 03:31:15     mmap in sport driver

Document created by Aaronwu Employee on Aug 9, 2013
Version 1Show Document
  • View in full screen mode

2008-12-10 03:31:15     mmap in sport driver

Daniele Pagani (ITALY)

Message: 66586   

 

Hi all,

 

I need to add mmap feature to the sport driver.

 

So, I start from:

 

http://docs.blackfin.uclinux.org/doku.php?id=mmap

 

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:

 

http://blackfin.uclinux.org/gf/project/uclinux-dist/forum/?action=ForumBrowse&forum_id=39&thread_id=3795&_forum_action=ForumMessageBrowse

 

but nobody has answered to it and I've the same problem.

 

When I run my application, I receive:

 

mmap device ok p = (nil)

 

Any suggestions?

 

Regards,

 

Daniele.

 

 

TranslateQuoteReplyEditDelete

 

 

2008-12-10 07:27:44     Re: mmap in sport driver

Daniele Pagani (ITALY)

Message: 66602   

 

Sorry,

 

I try to better explain the problem.

 

I take this page:

 

http://docs.blackfin.uclinux.org/doku.php?id=mmap

 

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:

 

data_rx=kmalloc(config->rx_data_len*word_bytes*2,__GFP_DMA)...

 

so, I don't understand what I need to use in order to reach this result.

 

So, I read from another thread:

 

http://blackfin.uclinux.org/gf/project/uclinux-dist/forum/?action=ForumBrowse&forum_id=39&thread_id=3795&_forum_action=ForumMessageBrowse

 

but it doesn't work.

 

So, where can I find an example of mmap with kernel 2.6 with allocated buffer?

 

Best regards,

 

Daniele.

 

 

TranslateQuoteReplyEditDelete

 

 

2008-12-22 11:26:24     Re: mmap in sport driver

Michael McTernan (UNITED KINGDOM)

Message: 67042   

 

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;

    void *p;

 

    /* Check if the device has been opened */

    if(fd == 0)

    {

        fd = open("/dev/dmamem0", O_RDWR);

        if(fd < 0)

        {          

            return NULL;

        }

    }

 

    /* 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)

    {

        return NULL;

    }

    else

    {

        return p;

    }

}

 

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!!).

 

devdmamem.c

QuoteReplyEditDelete

 

 

2008-12-22 23:12:39     Re: mmap in sport driver

Sonic Zhang (CHINA)

Message: 67054   

 

Please refer to function bfin_lq035q1_fb_mmap() in file linux-2.6.x/drivers/video/bfin-lq035q1-fb.c

Attachments

Outcomes