VNC: BPP as presented to application must match configuration; we will need to do conversions as necesasry for the BPP of the remote framebuffer

This commit is contained in:
Gregory Nutt 2016-04-16 18:11:17 -06:00
parent f154d7ea1b
commit 9bdc08e013
3 changed files with 18 additions and 6 deletions

View File

@ -159,9 +159,12 @@ static int up_getvideoinfo(FAR struct fb_vtable_s *vtable,
return -ENOTCONN; return -ENOTCONN;
} }
/* Return the requested video info */ /* Return the requested video info. We are committed to using the
* configured color format in the framebuffer, but performing color
* conversions on the fly for the remote framebuffer as necessary.
*/
vinfo->fmt = session->colorfmt; vinfo->fmt = RFB_COLORFMT;
vinfo->xres = session->screen.w; vinfo->xres = session->screen.w;
vinfo->yres = session->screen.h; vinfo->yres = session->screen.h;
vinfo->nplanes = 1; vinfo->nplanes = 1;
@ -197,10 +200,15 @@ static int up_getplaneinfo(FAR struct fb_vtable_s *vtable, int planeno,
DEBUGASSERT(session->fb != NULL); DEBUGASSERT(session->fb != NULL);
pinfo->fbmem = (FAR void *)&session->fb; /* Return the requested plane info. We are committed to using the
* configured bits-per-pixels in the framebuffer, but performing color
* conversions on the fly for the remote framebuffer as necessary.
*/
pinfo->fbmem = (FAR void *)session->fb;
pinfo->fblen = (uint32_t)session->stride * CONFIG_VNCSERVER_SCREENWIDTH; pinfo->fblen = (uint32_t)session->stride * CONFIG_VNCSERVER_SCREENWIDTH;
pinfo->stride = (fb_coord_t)session->stride; pinfo->stride = (fb_coord_t)session->stride;
pinfo->bpp = session->bpp; pinfo->bpp = RFB_BITSPERPIXEL;
return OK; return OK;
} }

View File

@ -275,14 +275,16 @@ int vnc_negotiate(FAR struct vnc_session_s *session)
session->screen.w = CONFIG_VNCSERVER_SCREENWIDTH; session->screen.w = CONFIG_VNCSERVER_SCREENWIDTH;
session->screen.h = CONFIG_VNCSERVER_SCREENHEIGHT; session->screen.h = CONFIG_VNCSERVER_SCREENHEIGHT;
/* Now allocate the framebuffer memory */ /* Now allocate the framebuffer memory. We rely on the fact that
* the KMM allocator will align memory to 32-bits or better.
*/
len = (session->bpp + 7) >> 3; len = (session->bpp + 7) >> 3;
session->stride = len * CONFIG_VNCSERVER_SCREENWIDTH; session->stride = len * CONFIG_VNCSERVER_SCREENWIDTH;
alloc = (size_t)session->stride * CONFIG_VNCSERVER_SCREENHEIGHT; alloc = (size_t)session->stride * CONFIG_VNCSERVER_SCREENHEIGHT;
session->fb = (FAR uint8_t *)kmm_zalloc(alloc); session->fb = (FAR uint8_t *)kmm_zalloc(alloc);
if (session->fb) if (session->fb == NULL)
{ {
gdbg("ERROR: Failed to allocate framebuffer memory: %lu\n", gdbg("ERROR: Failed to allocate framebuffer memory: %lu\n",
(unsigned long)alloc); (unsigned long)alloc);

View File

@ -68,6 +68,7 @@
#endif #endif
#if defined(CONFIG_VNCSERVER_COLORFMT_RGB16) #if defined(CONFIG_VNCSERVER_COLORFMT_RGB16)
# define RFB_COLORFMT FB_FMT_RGB16_565
# define RFB_BITSPERPIXEL 16 # define RFB_BITSPERPIXEL 16
# define RFB_PIXELDEPTH 16 # define RFB_PIXELDEPTH 16
# define RFB_TRUECOLOR 1 # define RFB_TRUECOLOR 1
@ -78,6 +79,7 @@
# define RFB_GSHIFT 5 # define RFB_GSHIFT 5
# define RFB_BSHIFT 0 # define RFB_BSHIFT 0
#elif defined(CONFIG_VNCSERVER_COLORFMT_RGB32) #elif defined(CONFIG_VNCSERVER_COLORFMT_RGB32)
# define RFB_COLORFMT FB_FMT_RGB32
# define RFB_BITSPERPIXEL 32 # define RFB_BITSPERPIXEL 32
# define RFB_PIXELDEPTH 24 # define RFB_PIXELDEPTH 24
# define RFB_TRUECOLOR 1 # define RFB_TRUECOLOR 1