diff --git a/graphics/vnc/server/Kconfig b/graphics/vnc/server/Kconfig index 74319591ef1..7af1dccf525 100644 --- a/graphics/vnc/server/Kconfig +++ b/graphics/vnc/server/Kconfig @@ -8,6 +8,7 @@ menuconfig VNCSERVER default n depends on NET_TCP && !NX_LCDDRIVER && EXPERIMENTAL select NET_TCP_READAHEAD + select NX_UPDATE ---help--- Enable support for a VNC Remote Frame Buffer (RFB) server. diff --git a/graphics/vnc/server/vnc_fbdev.c b/graphics/vnc/server/vnc_fbdev.c index 68ae32ef49b..2d67f980cab 100644 --- a/graphics/vnc/server/vnc_fbdev.c +++ b/graphics/vnc/server/vnc_fbdev.c @@ -406,7 +406,7 @@ int up_fbinitialize(int display) */ gvdbg("Starting the VNC server for display %d\n", display); - DEBUGASSERT(display >= 8 && display < RFB_MAX_DISPLAYS); + DEBUGASSERT(display >= 0 && display < RFB_MAX_DISPLAYS); (void)itoa(display, str, 10); argv[0] = str; @@ -513,3 +513,54 @@ void up_fbuninitialize(int display) UNUSED(fbinfo); } +/**************************************************************************** + * Name: nx_notify_rectangle + * + * Description: + * When CONFIG_NX_UPDATE=y, then the graphics system will callout to + * inform some external module that the display has been updated. This + * would be useful in a couple for cases. + * + * - When a serial LCD is used, but a framebuffer is used to access the + * LCD. In this case, the update callout can be used to refresh the + * affected region of the display. + * + * - When VNC is enabled. This is case, this callout is necessary to + * update the remote frame buffer to match the local framebuffer. + * + * When this feature is enabled, some external logic must provide this + * interface. This is the function that will handle the notification. It + * receives the rectangular region that was updated on the provided plane. + * + ****************************************************************************/ + +#ifdef CONFIG_NX_UPDATE +void nx_notify_rectangle(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *rect) +{ + FAR struct vnc_session_s *session; + int ret; + + DEBUGASSERT(pinfo != NULL && rect != NULL); + + /* Recover the session informatin from the display number in the planeinfo + * structure. + */ + + DEBUGASSERT(pinfo->display >= 0 && pinfo->display < RFB_MAX_DISPLAYS); + session = vnc_find_session(pinfo->display); + + /* Verify that the session is still valid */ + + if (session != NULL && session->state == VNCSERVER_RUNNING) + { + /* Queue the rectangular update */ + + ret = vnc_update_rectangle(session, rect); + if (ret < 0) + { + gdbg("ERROR: vnc_update_rectangle failed: %d\n", ret); + } + } +} +#endif diff --git a/graphics/vnc/server/vnc_server.h b/graphics/vnc/server/vnc_server.h index 4e0a2cf3eef..d839b34c61a 100644 --- a/graphics/vnc/server/vnc_server.h +++ b/graphics/vnc/server/vnc_server.h @@ -56,6 +56,14 @@ /* Configuration */ +#ifndef CONFIG_NET_TCP_READAHEAD +# error CONFIG_NET_TCP_READAHEAD must be set to use VNC +#endif + +#ifndef CONFIG_NX_UPDATE +# error CONFIG_NX_UPDATE must be set to use VNC +#endif + #if !defined(CONFIG_VNCSERVER_PROTO3p3) && !defined(CONFIG_VNCSERVER_PROTO3p8) # error No VNC protocol selected #endif @@ -268,6 +276,25 @@ int vnc_start_updater(FAR struct vnc_session_s *session); int vnc_stop_updater(FAR struct vnc_session_s *session); +/**************************************************************************** + * Name: vnc_update_rectangle + * + * Description: + * Queue an update of the specified rectangular region on the display. + * + * Input Parameters: + * session - An instance of the session structure. + * rect - The rectanglular region to be updated. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure. + * + ****************************************************************************/ + +int vnc_update_rectangle(FAR struct vnc_session_s *session, + FAR const struct nxgl_rect_s *rect); + /**************************************************************************** * Name: vnc_receiver * diff --git a/graphics/vnc/server/vnc_updater.c b/graphics/vnc/server/vnc_updater.c index f8a44a9341d..4db204c9b4d 100644 --- a/graphics/vnc/server/vnc_updater.c +++ b/graphics/vnc/server/vnc_updater.c @@ -42,6 +42,7 @@ #include #include #include +#include #include "vnc_server.h" @@ -75,7 +76,7 @@ static FAR void *vnc_updater(FAR void *arg) #warning Missing logic } - return NULL; + return NULL; } /**************************************************************************** @@ -169,3 +170,31 @@ int vnc_stop_updater(FAR struct vnc_session_s *session) return OK; } +/**************************************************************************** + * Name: vnc_update_rectangle + * + * Description: + * Queue an update of the specified rectangular region on the display. + * + * Input Parameters: + * session - An instance of the session structure. + * rect - The rectanglular region to be updated. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure. + * + ****************************************************************************/ + +int vnc_update_rectangle(FAR struct vnc_session_s *session, + FAR const struct nxgl_rect_s *rect) +{ + /* Make sure that the rectangle has a area */ + + if (!nxgl_nullrect(rect)) + { +#warning Missing logic + } + + return -ENOSYS; +}