VNC: Add support for (1) an 8-bit local frame buffer format and (2) a configurable server name
This commit is contained in:
parent
f8604d11a9
commit
79e577eae1
4 changed files with 128 additions and 36 deletions
|
@ -35,6 +35,10 @@ config VNCSERVER_NDISPLAYS
|
|||
Specifies the number of RFB displays supported by the server.
|
||||
Normally this should be one.
|
||||
|
||||
config VNCSERVER_NAME
|
||||
string "VNC display name"
|
||||
default "NuttX"
|
||||
|
||||
config VNCSERVER_PRIO
|
||||
int "VNC server task priority"
|
||||
default 100
|
||||
|
@ -55,11 +59,14 @@ choice
|
|||
prompt "VNC color format"
|
||||
default VNCSERVER_COLORFMT_RGB16
|
||||
|
||||
config VNCSERVER_COLORFMT_RGB8
|
||||
bool "RGB8 3:3:2"
|
||||
|
||||
config VNCSERVER_COLORFMT_RGB16
|
||||
bool "RGB16 5:6:5"
|
||||
|
||||
config VNCSERVER_COLORFMT_RGB32
|
||||
bool "RGB24 (32-bit) or RGB32 (w/tranparency)"
|
||||
bool "RGB32 8:8:8"
|
||||
|
||||
endchoice # VNC color format
|
||||
|
||||
|
|
|
@ -53,9 +53,10 @@
|
|||
* Name: vnc_convert_rgbNN
|
||||
*
|
||||
* Description:
|
||||
* Convert the native framebuffer color format (either RGB16 5:6:5 or RGB32
|
||||
* 8:8:8) to the remote framebuffer color format (either RGB16 5:6:5,
|
||||
* RGB16 5:5:5, or RGB32 8:8:)
|
||||
* Convert the native framebuffer color format (either RGB8 3:3:2,
|
||||
* RGB16 5:6:5, or RGB32 8:8:8) to the remote framebuffer color format
|
||||
* (either RGB8 2:2:2, RGB8 3:3:2, RGB16 5:5:5, RGB16 5:6:5, or RGB32
|
||||
* 8:8:8)
|
||||
*
|
||||
* Input Parameters:
|
||||
* pixel - The src color in local framebuffer format.
|
||||
|
@ -65,7 +66,71 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_VNCSERVER_COLORFMT_RGB16)
|
||||
#if defined(CONFIG_VNCSERVER_COLORFMT_RGB8)
|
||||
|
||||
uint8_t vnc_convert_rgb8_222(lfb_color_t rgb)
|
||||
{
|
||||
/* 76543210
|
||||
* --------
|
||||
* RRRGGGBB
|
||||
* ..RRGGBB
|
||||
*/
|
||||
|
||||
return (uint8_t)(((rgb >> 2) & 0x30) |
|
||||
((rgb >> 1) & 0x0c) |
|
||||
( rgb & 0x03));
|
||||
}
|
||||
|
||||
uint8_t vnc_convert_rgb8_332(lfb_color_t rgb)
|
||||
{
|
||||
/* Identity mapping */
|
||||
|
||||
return (uint8_t)rgb;
|
||||
}
|
||||
|
||||
uint16_t vnc_convert_rgb16_555(lfb_color_t rgb)
|
||||
{
|
||||
/* 111111
|
||||
* 54321098 76543210
|
||||
* -----------------
|
||||
* RRRGGGBB
|
||||
* .RRR..GG G..BB...
|
||||
*/
|
||||
|
||||
return (uint8_t)((((uint16_t)rgb << 8) & 0x7000) |
|
||||
(((uint16_t)rgb << 5) & 0x0380) |
|
||||
(((uint16_t)rgb << 3) & 0x0018));
|
||||
}
|
||||
|
||||
uint16_t vnc_convert_rgb16_565(lfb_color_t rgb)
|
||||
{
|
||||
/* 111111
|
||||
* 54321098 76543210
|
||||
* -----------------
|
||||
* RRRGGGBB
|
||||
* RRR..GGG ...BB...
|
||||
*/
|
||||
|
||||
return (uint8_t)((((uint16_t)rgb << 8) & 0xe000) |
|
||||
(((uint16_t)rgb << 6) & 0x0700) |
|
||||
(((uint16_t)rgb << 3) & 0x0018));
|
||||
}
|
||||
|
||||
uint32_t vnc_convert_rgb32_888(lfb_color_t rgb)
|
||||
{
|
||||
/* 33222222 22221111 111111
|
||||
* 10987654 32109876 54321098 76543210
|
||||
* ----------------------------------
|
||||
* RRRGGGBB
|
||||
* RRR..... GGG..... BB......
|
||||
*/
|
||||
|
||||
return (((uint32_t)rgb << 16) & 0x00e00000) |
|
||||
(((uint32_t)rgb << 11) & 0x0000e000) |
|
||||
(((uint32_t)rgb << 6) & 0x000000c0);
|
||||
}
|
||||
|
||||
#elif defined(CONFIG_VNCSERVER_COLORFMT_RGB16)
|
||||
|
||||
uint8_t vnc_convert_rgb8_222(lfb_color_t rgb)
|
||||
{
|
||||
|
@ -104,14 +169,14 @@ uint16_t vnc_convert_rgb16_555(lfb_color_t rgb)
|
|||
* .RRRRRGG GGGBBBBB
|
||||
*/
|
||||
|
||||
return (((rgb >> 1) & ~0x1f) | (rgb & 0x1f));
|
||||
return (((rgb >> 1) & ~0x001f) | (rgb & 0x001f));
|
||||
}
|
||||
|
||||
uint16_t vnc_convert_rgb16_565(lfb_color_t rgb)
|
||||
{
|
||||
/* Identity mapping */
|
||||
|
||||
return rgb;
|
||||
return (uint32_t)rgb;
|
||||
}
|
||||
|
||||
uint32_t vnc_convert_rgb32_888(lfb_color_t rgb)
|
||||
|
@ -139,9 +204,9 @@ uint8_t vnc_convert_rgb8_222(lfb_color_t rgb)
|
|||
* ..RRGGBB
|
||||
*/
|
||||
|
||||
return (uint8_t)(((rgb >> 18) & 0x0030) |
|
||||
((rgb >> 12) & 0x000c) |
|
||||
(rgb >> 6) & 0x0003));
|
||||
return (uint8_t)(((rgb >> 18) & 0x00000030) |
|
||||
((rgb >> 12) & 0x0000000c) |
|
||||
(rgb >> 6) & 0x00000003));
|
||||
}
|
||||
|
||||
uint8_t vnc_convert_rgb8_332(lfb_color_t rgb)
|
||||
|
@ -153,9 +218,9 @@ uint8_t vnc_convert_rgb8_332(lfb_color_t rgb)
|
|||
* RRRGGGBB
|
||||
*/
|
||||
|
||||
return (uint8_t)(((rgb >> 16) & 0x0070) |
|
||||
((rgb >> 11) & 0x001c) |
|
||||
(rgb >> 6) & 0x0003));
|
||||
return (uint8_t)(((rgb >> 16) & 0x00000070) |
|
||||
((rgb >> 11) & 0x0000001c) |
|
||||
(rgb >> 6) & 0x00000003));
|
||||
}
|
||||
|
||||
uint16_t vnc_convert_rgb16_555(lfb_color_t rgb)
|
||||
|
@ -167,10 +232,9 @@ uint16_t vnc_convert_rgb16_555(lfb_color_t rgb)
|
|||
* .RRRRRGG GGGBBBBB
|
||||
*/
|
||||
|
||||
return (uint16_t)
|
||||
(((rgb >> 9) & 0x00007c00) |
|
||||
((rgb >> 6) & 0x000003e0) |
|
||||
((rgb >> 3) & 0x0000001f));
|
||||
return (uint16_t)(((rgb >> 9) & 0x00007c00) |
|
||||
((rgb >> 6) & 0x000003e0) |
|
||||
((rgb >> 3) & 0x0000001f));
|
||||
}
|
||||
|
||||
uint16_t vnc_convert_rgb16_565(lfb_color_t rgb)
|
||||
|
@ -182,10 +246,9 @@ uint16_t vnc_convert_rgb16_565(lfb_color_t rgb)
|
|||
* RRRRRGGG GGGBBBBB
|
||||
*/
|
||||
|
||||
return (uint16_t)
|
||||
(((rgb >> 8) & 0x0000f800) |
|
||||
((rgb >> 5) & 0x000007e0) |
|
||||
((rgb >> 3) & 0x0000001f));
|
||||
return (uint16_t)(((rgb >> 8) & 0x0000f800) |
|
||||
((rgb >> 5) & 0x000007e0) |
|
||||
((rgb >> 3) & 0x0000001f));
|
||||
}
|
||||
|
||||
uint32_t vnc_convert_rgb32_888(lfb_color_t rgb)
|
||||
|
|
|
@ -64,6 +64,7 @@ static const char g_vncproto[] = RFB_PROTOCOL_VERSION_3p3;
|
|||
static const char g_vncproto[] = RFB_PROTOCOL_VERSION_3p8;
|
||||
static const char g_nosecurity[] = "No security types are supported";
|
||||
#endif
|
||||
static const char g_vncname[] = CONFIG_VNCSERVER_NAME;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
@ -326,7 +327,6 @@ int vnc_negotiate(FAR struct vnc_session_s *session)
|
|||
|
||||
rfb_putbe16(serverinit->width, CONFIG_VNCSERVER_SCREENWIDTH);
|
||||
rfb_putbe16(serverinit->height, CONFIG_VNCSERVER_SCREENHEIGHT);
|
||||
rfb_putbe32(serverinit->namelen, 0);
|
||||
|
||||
pixelfmt = &serverinit->format;
|
||||
|
||||
|
@ -343,8 +343,12 @@ int vnc_negotiate(FAR struct vnc_session_s *session)
|
|||
pixelfmt->gshift = RFB_GSHIFT;
|
||||
pixelfmt->bshift = RFB_BSHIFT;
|
||||
|
||||
len = strlen(g_vncname);
|
||||
rfb_putbe32(serverinit->namelen, len);
|
||||
memcpy(serverinit->name, g_vncname, len);
|
||||
|
||||
nsent = psock_send(&session->connect, serverinit,
|
||||
SIZEOF_RFB_SERVERINIT_S(0), 0);
|
||||
SIZEOF_RFB_SERVERINIT_S(len), 0);
|
||||
if (nsent < 0)
|
||||
{
|
||||
errcode = get_errno();
|
||||
|
@ -352,7 +356,7 @@ int vnc_negotiate(FAR struct vnc_session_s *session)
|
|||
return -errcode;
|
||||
}
|
||||
|
||||
DEBUGASSERT(nsent == SIZEOF_RFB_SERVERINIT_S(0));
|
||||
DEBUGASSERT(nsent == SIZEOF_RFB_SERVERINIT_S(len));
|
||||
|
||||
/* We now expect to receive the SetPixelFormat message from the client.
|
||||
* This may override some of our framebuffer settings.
|
||||
|
|
|
@ -79,14 +79,25 @@
|
|||
# define CONFIG_VNCSERVER_NDISPLAYS 1
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_VNCSERVER_COLORFMT_RGB16)
|
||||
#if defined(CONFIG_VNCSERVER_COLORFMT_RGB8)
|
||||
# define RFB_COLORFMT FB_FMT_RGB8_332
|
||||
# define RFB_BITSPERPIXEL 8
|
||||
# define RFB_PIXELDEPTH 8
|
||||
# define RFB_TRUECOLOR 1
|
||||
# define RFB_RMAX 0x07
|
||||
# define RFB_GMAX 0x07
|
||||
# define RFB_BMAX 0x03
|
||||
# define RFB_RSHIFT 5
|
||||
# define RFB_GSHIFT 2
|
||||
# define RFB_BSHIFT 0
|
||||
#elif defined(CONFIG_VNCSERVER_COLORFMT_RGB16)
|
||||
# define RFB_COLORFMT FB_FMT_RGB16_565
|
||||
# define RFB_BITSPERPIXEL 16
|
||||
# define RFB_PIXELDEPTH 16
|
||||
# define RFB_TRUECOLOR 1
|
||||
# define RFB_RMAX 0x1f
|
||||
# define RFB_GMAX 0x3f
|
||||
# define RFB_BMAX 0x1f
|
||||
# define RFB_RMAX 0x001f
|
||||
# define RFB_GMAX 0x003f
|
||||
# define RFB_BMAX 0x001f
|
||||
# define RFB_RSHIFT 11
|
||||
# define RFB_GSHIFT 5
|
||||
# define RFB_BSHIFT 0
|
||||
|
@ -95,9 +106,9 @@
|
|||
# define RFB_BITSPERPIXEL 32
|
||||
# define RFB_PIXELDEPTH 24
|
||||
# define RFB_TRUECOLOR 1
|
||||
# define RFB_RMAX 0xff
|
||||
# define RFB_GMAX 0xff
|
||||
# define RFB_BMAX 0xff
|
||||
# define RFB_RMAX 0x000000ff
|
||||
# define RFB_GMAX 0x000000ff
|
||||
# define RFB_BMAX 0x000000ff
|
||||
# define RFB_RSHIFT 16
|
||||
# define RFB_GSHIFT 8
|
||||
# define RFB_BSHIFT 0
|
||||
|
@ -113,6 +124,10 @@
|
|||
# define CONFIG_VNCSERVER_SCREENHEIGHT 240
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_VNCSERVER_NAME
|
||||
# define CONFIG_VNCSERVER_NAME "NuttX"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_VNCSERVER_PRIO
|
||||
# define CONFIG_VNCSERVER_PRIO 100
|
||||
#endif
|
||||
|
@ -243,7 +258,9 @@ struct fb_startup_s
|
|||
|
||||
/* The size of the color type in the local framebuffer */
|
||||
|
||||
#if defined(CONFIG_VNCSERVER_COLORFMT_RGB16)
|
||||
#if defined(CONFIG_VNCSERVER_COLORFMT_RGB8)
|
||||
typedef uint8_t lfb_color_t;
|
||||
#elif defined(CONFIG_VNCSERVER_COLORFMT_RGB16)
|
||||
typedef uint16_t lfb_color_t;
|
||||
#elif defined(CONFIG_VNCSERVER_COLORFMT_RGB32)
|
||||
typedef uint32_t lfb_color_t;
|
||||
|
@ -512,12 +529,13 @@ FAR struct vnc_session_s *vnc_find_session(int display);
|
|||
* Name: vnc_convert_rgbNN
|
||||
*
|
||||
* Description:
|
||||
* Convert the native framebuffer color format (either RGB16 5:6:5 or RGB32
|
||||
* 8:8:8) to the remote framebuffer color format (either RGB16 5:6:5,
|
||||
* RGB16 5:5:5, or RGB32 8:8:)
|
||||
* Convert the native framebuffer color format (either RGB8 3:3:2,
|
||||
* RGB16 5:6:5, or RGB32 8:8:8) to the remote framebuffer color format
|
||||
* (either RGB8 2:2:2, RGB8 3:3:2, RGB16 5:5:5, RGB16 5:6:5, or RGB32
|
||||
* 8:8:8)
|
||||
*
|
||||
* Input Parameters:
|
||||
* rgb - The RGB src color in local framebuffer color format.
|
||||
* pixel - The src color in local framebuffer format.
|
||||
*
|
||||
* Returned Value:
|
||||
* The pixel in the remote framebuffer color format.
|
||||
|
|
Loading…
Reference in a new issue