Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions examples/fb/fb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ static int fb_init_mem2(FAR struct fb_state_s *state)
int ret;
uintptr_t buf_offset;
struct fb_planeinfo_s pinfo;
FAR void *fbmem;

memset(&pinfo, 0, sizeof(pinfo));
pinfo.display = state->pinfo.display + 1;
Expand All @@ -207,6 +208,17 @@ static int fb_init_mem2(FAR struct fb_state_s *state)
return EXIT_FAILURE;
}

fbmem = mmap(NULL, pinfo.fblen, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_FILE, state->fd, 0);

if (fbmem == MAP_FAILED)
{
int errcode = errno;
fprintf(stderr, "ERROR: ioctl(FBIOGET_PLANEINFO) failed: %d\n",
errcode);
return EXIT_FAILURE;
}

/* Check bpp */

if (pinfo.bpp != state->pinfo.bpp)
Expand All @@ -219,7 +231,7 @@ static int fb_init_mem2(FAR struct fb_state_s *state)
* It needs to be divisible by pinfo.stride
*/

buf_offset = pinfo.fbmem - state->fbmem;
buf_offset = fbmem - state->fbmem;

if ((buf_offset % state->pinfo.stride) != 0)
{
Expand All @@ -236,7 +248,7 @@ static int fb_init_mem2(FAR struct fb_state_s *state)
/* Use consecutive fbmem2. */

state->mem2_yoffset = state->vinfo.yres;
state->fbmem2 = pinfo.fbmem + state->mem2_yoffset * pinfo.stride;
state->fbmem2 = fbmem + state->mem2_yoffset * pinfo.stride;
printf("Use consecutive fbmem2 = %p, yoffset = %" PRIu32"\n",
state->fbmem2, state->mem2_yoffset);
}
Expand All @@ -245,7 +257,7 @@ static int fb_init_mem2(FAR struct fb_state_s *state)
/* Use non-consecutive fbmem2. */

state->mem2_yoffset = buf_offset / state->pinfo.stride;
state->fbmem2 = pinfo.fbmem;
state->fbmem2 = fbmem;
printf("Use non-consecutive fbmem2 = %p, yoffset = %" PRIu32"\n",
state->fbmem2, state->mem2_yoffset);
}
Expand Down
Loading