MMAP fails in attempt to double buffer framebufer

牧云@^-^@ 提交于 2019-12-12 04:59:52

问题


I am trying to implement a double buffer using ioctl(fd, FBIOPAN_DISPLAY... my single buffer code works fine

screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;

fbp = (char*)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0);

when I try to increase the "length parameter" by using screensize*2, the mmap fails with EINVAL. I think it doesn't like my length parameter.

The screen size for a single buffer is 6,220,800 and for the double buffer is 12,441600. This is an embedded system but it has 1 Gig of RAM.

The length parameter is size_t which on this system is only 4 bytes which would make me think that the max size I could use would be 4 Meg, yet 6 Meg works fine so I think I am missing something really simple. Is there a way to mmap a buffer larger than size_t?


回答1:


The man page says that length (the 2nd parameter) is of type size_t, so I don't think you are safe to pass a larger type.

I would suggest you to just map the first part, and then remap the second part as shown in this SO Q&A.

Regarding the EINVAL: Following is stated in the man page:

EINVAL We don't like addr, length, or offset (e.g., they are too large, or not aligned on a page boundary).

EINVAL (since Linux 2.6.12) length was 0.

EINVAL flags contained neither MAP_PRIVATE or MAP_SHARED, or contained both of these values.

Are you sure you are page alligned?



来源:https://stackoverflow.com/questions/39969673/mmap-fails-in-attempt-to-double-buffer-framebufer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!