diff --git a/graphics/vnc/server/vnc_fbdev.c b/graphics/vnc/server/vnc_fbdev.c index 7d427d7983..cb05686cda 100644 --- a/graphics/vnc/server/vnc_fbdev.c +++ b/graphics/vnc/server/vnc_fbdev.c @@ -159,9 +159,12 @@ static int up_getvideoinfo(FAR struct fb_vtable_s *vtable, 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->yres = session->screen.h; vinfo->nplanes = 1; @@ -197,10 +200,15 @@ static int up_getplaneinfo(FAR struct fb_vtable_s *vtable, int planeno, 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->stride = (fb_coord_t)session->stride; - pinfo->bpp = session->bpp; + pinfo->bpp = RFB_BITSPERPIXEL; return OK; } diff --git a/graphics/vnc/server/vnc_negotiate.c b/graphics/vnc/server/vnc_negotiate.c index dc87247210..f5f487873b 100644 --- a/graphics/vnc/server/vnc_negotiate.c +++ b/graphics/vnc/server/vnc_negotiate.c @@ -275,14 +275,16 @@ int vnc_negotiate(FAR struct vnc_session_s *session) session->screen.w = CONFIG_VNCSERVER_SCREENWIDTH; 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; session->stride = len * CONFIG_VNCSERVER_SCREENWIDTH; alloc = (size_t)session->stride * CONFIG_VNCSERVER_SCREENHEIGHT; session->fb = (FAR uint8_t *)kmm_zalloc(alloc); - if (session->fb) + if (session->fb == NULL) { gdbg("ERROR: Failed to allocate framebuffer memory: %lu\n", (unsigned long)alloc); diff --git a/graphics/vnc/server/vnc_server.h b/graphics/vnc/server/vnc_server.h index 17dee09406..fda657b1ab 100644 --- a/graphics/vnc/server/vnc_server.h +++ b/graphics/vnc/server/vnc_server.h @@ -68,6 +68,7 @@ #endif #if defined(CONFIG_VNCSERVER_COLORFMT_RGB16) +# define RFB_COLORFMT FB_FMT_RGB16_565 # define RFB_BITSPERPIXEL 16 # define RFB_PIXELDEPTH 16 # define RFB_TRUECOLOR 1 @@ -78,6 +79,7 @@ # define RFB_GSHIFT 5 # define RFB_BSHIFT 0 #elif defined(CONFIG_VNCSERVER_COLORFMT_RGB32) +# define RFB_COLORFMT FB_FMT_RGB32 # define RFB_BITSPERPIXEL 32 # define RFB_PIXELDEPTH 24 # define RFB_TRUECOLOR 1