diff --git a/graphics/vnc/server/Kconfig b/graphics/vnc/server/Kconfig index 17a5e3d8ab..3f14b38bc2 100644 --- a/graphics/vnc/server/Kconfig +++ b/graphics/vnc/server/Kconfig @@ -118,7 +118,7 @@ config VNCSERVER_UPDATE_BUFSIZE config VNCSERVER_KBDENCODE bool "Encode keyboard input" default n - depends on NXTERM_NXKBDIN + depends on LIB_KBDCODEC ---help--- Use a special encoding of keyboard characters as defined in include/nuttx/input/kbd_coded.h. diff --git a/graphics/vnc/server/vnc_fbdev.c b/graphics/vnc/server/vnc_fbdev.c index 87fb91b84d..2f98fab21b 100644 --- a/graphics/vnc/server/vnc_fbdev.c +++ b/graphics/vnc/server/vnc_fbdev.c @@ -48,6 +48,7 @@ #include #include #include +#include #include "vnc_server.h" @@ -158,7 +159,9 @@ static int up_getvideoinfo(FAR struct fb_vtable_s *vtable, DEBUGASSERT(fbinfo != NULL && vinfo != NULL); if (fbinfo != NULL && vinfo != NULL) { - session = vnc_find_session(fbinfo->display); + DEBUGASSERT(fbinfo->display >= 0 && fbinfo->display < RFB_MAX_DISPLAYS); + session = g_vnc_sessions[fbinfo->display]; + if (session == NULL || session->state != VNCSERVER_RUNNING) { gdbg("ERROR: session is not connected\n"); @@ -197,7 +200,9 @@ static int up_getplaneinfo(FAR struct fb_vtable_s *vtable, int planeno, DEBUGASSERT(fbinfo != NULL && pinfo != NULL && planeno == 0); if (fbinfo != NULL && pinfo != NULL && planeno == 0) { - session = vnc_find_session(fbinfo->display); + DEBUGASSERT(fbinfo->display >= 0 && fbinfo->display < RFB_MAX_DISPLAYS); + session = g_vnc_sessions[fbinfo->display]; + if (session == NULL || session->state != VNCSERVER_RUNNING) { gdbg("ERROR: session is not connected\n"); @@ -242,7 +247,9 @@ static int up_getcmap(FAR struct fb_vtable_s *vtable, if (fbinfo != NULL && cmap != NULL) { - session = vnc_find_session(fbinfo->display); + DEBUGASSERT(fbinfo->display >= 0 && fbinfo->display < RFB_MAX_DISPLAYS); + session = g_vnc_sessions[fbinfo->display]; + if (session == NULL || session->state != VNCSERVER_RUNNING) { gdbg("ERROR: session is not connected\n"); @@ -277,7 +284,9 @@ static int up_putcmap(FAR struct fb_vtable_s *vtable, FAR const struct fb_cmap_s if (fbinfo != NULL && cmap != NULL) { - session = vnc_find_session(fbinfo->display); + DEBUGASSERT(fbinfo->display >= 0 && fbinfo->display < RFB_MAX_DISPLAYS); + session = g_vnc_sessions[fbinfo->display]; + if (session == NULL || session->state != VNCSERVER_RUNNING) { gdbg("ERROR: session is not connected\n"); @@ -313,7 +322,9 @@ static int up_getcursor(FAR struct fb_vtable_s *vtable, if (fbinfo != NULL && attrib != NULL) { - session = vnc_find_session(fbinfo->display); + DEBUGASSERT(fbinfo->display >= 0 && fbinfo->display < RFB_MAX_DISPLAYS); + session = g_vnc_sessions[fbinfo->display]; + if (session == NULL || session->state != VNCSERVER_RUNNING) { gdbg("ERROR: session is not connected\n"); @@ -347,7 +358,9 @@ static int up_setcursor(FAR struct fb_vtable_s *vtable, if (fbinfo != NULL && settings != NULL) { - session = vnc_find_session(fbinfo->display); + DEBUGASSERT(fbinfo->display >= 0 && fbinfo->display < RFB_MAX_DISPLAYS); + session = g_vnc_sessions[fbinfo->display]; + if (session == NULL || session->state != VNCSERVER_RUNNING) { gdbg("ERROR: session is not connected\n"); @@ -381,7 +394,121 @@ static int up_setcursor(FAR struct fb_vtable_s *vtable, #endif /**************************************************************************** - * Name: vnc_wait_server + * Name: vnc_start_server + * + * Description: + * Start the VNC server. + * + * Input parameters: + * display - In the case of hardware with multiple displays, this + * specifies the display. Normally this is zero. + * + * Returned Value: + * Zero is returned on success; a negated errno value is returned on any + * failure. + * + ****************************************************************************/ + +static int vnc_start_server(int display) +{ + FAR char *argv[2]; + char str[8]; + pid_t pid; + + DEBUGASSERT(display >= 0 && display < RFB_MAX_DISPLAYS); + + /* Check if the server is already running */ + + if (g_vnc_sessions[display] != NULL) + { + DEBUGASSERT(g_vnc_sessions[display]->state >= VNCSERVER_INITIALIZED); + return OK; + } + + /* Start the VNC server kernel thread. */ + + gvdbg("Starting the VNC server for display %d\n", display); + + g_fbstartup[display].result = -EBUSY; + sem_reset(&g_fbstartup[display].fbinit, 0); + sem_reset(&g_fbstartup[display].fbconnect, 0); + + /* Format the kernel thread arguments (ASCII.. yech) */ + + (void)itoa(display, str, 10); + argv[0] = str; + argv[1] = NULL; + + pid = kernel_thread("vnc_server", CONFIG_VNCSERVER_PRIO, + CONFIG_VNCSERVER_STACKSIZE, + (main_t)vnc_server, argv); + if (pid < 0) + { + gdbg("ERROR: Failed to start the VNC server: %d\n", (int)pid); + return (int)pid; + } + + return OK; +} + +/**************************************************************************** + * Name: vnc_wait_start + * + * Description: + * Wait for the server to be started. + * + * Input parameters: + * display - In the case of hardware with multiple displays, this + * specifies the display. Normally this is zero. + * + * Returned Value: + * Zero is returned on success; a negated errno value is returned on any + * failure. + * + ****************************************************************************/ + +static inline int vnc_wait_start(int display) +{ + int errcode; + + /* Check if there has been a session allocated yet. This is one of the + * first things that the VNC server will do with the kernel thread is + * started. But we might be here before the thread has gotten that far. + * + * If it has been allocated, then wait until it is in the INIITIALIZED + * state. The INITIAILIZED states indicates tht the session structure + * has been allocated and fully initialized. + */ + + while (g_vnc_sessions[display] == NULL || + g_vnc_sessions[display]->state != VNCSERVER_UNINITIALIZED) + { + /* The server is not yet running. Wait for the server to post the FB + * semaphore. In certain error situations, the server may post the + * semaphore, then reset it to zero. There are are certainly race + * conditions here, but I think none that are fatal. + */ + + while (sem_wait(&g_fbstartup[display].fbinit) < 0) + { + errcode = get_errno(); + + /* sem_wait() should fail only if it is interrupt by a signal. */ + + DEBUGASSERT(errcode == EINTR); + if (errcode != EINTR) + { + DEBUGASSERT(errcode > 0); + return -errcode; + } + } + } + + return OK; +} + +/**************************************************************************** + * Name: vnc_wait_connect * * Description: * Wait for the server to be connected to the VNC client. We can do @@ -397,7 +524,7 @@ static int up_setcursor(FAR struct fb_vtable_s *vtable, * ****************************************************************************/ -static inline int vnc_wait_server(int display) +static inline int vnc_wait_connect(int display) { int errcode; int result; @@ -423,7 +550,7 @@ static inline int vnc_wait_server(int display) * conditions here, but I think none that are fatal. */ - while (sem_wait(&g_fbstartup[display].fbsem) < 0) + while (sem_wait(&g_fbstartup[display].fbconnect) < 0) { errcode = get_errno(); @@ -486,48 +613,119 @@ static inline int vnc_wait_server(int display) int up_fbinitialize(int display) { - FAR char *argv[2]; - char str[8]; - pid_t pid; + int ret; - /* Start the VNC server kernel thread. - * REVISIT: There is no protection for the case where this function is - * called more that once. - */ - - gvdbg("Starting the VNC server for display %d\n", display); DEBUGASSERT(display >= 0 && display < RFB_MAX_DISPLAYS); - /* Check if the server is already running */ + /* Start the VNC server kernel thread. */ - g_fbstartup[display].result = -EBUSY; - sem_reset(&g_fbstartup[display].fbsem, 0); - - if (g_vnc_sessions[display] != NULL) + ret = vnc_start_server(display); + if (ret < 0) { - DEBUGASSERT(g_vnc_sessions[display]->state >= VNCSERVER_INITIALIZED); - } - else - { - /* Format the kernel thread arguments (ASCII.. yech) */ - - (void)itoa(display, str, 10); - argv[0] = str; - argv[1] = NULL; - - pid = kernel_thread("vnc_server", CONFIG_VNCSERVER_PRIO, - CONFIG_VNCSERVER_STACKSIZE, - (main_t)vnc_server, argv); - if (pid < 0) - { - gdbg("ERROR: Failed to start the VNC server: %d\n", (int)pid); - return (int)pid; - } + gvdbg("ERROR: vnc_start_server() failed: %d\n", ret); + return ret; } /* Wait for the VNC client to connect and for the RFB to be ready */ - return vnc_wait_server(display); + ret = vnc_wait_connect(display); + if (ret < 0) + { + gvdbg("ERROR: vnc_wait_connect() failed: %d\n", ret); + } + + return ret; +} + +/**************************************************************************** + * Function: vnc_fbinitialize + * + * Description: + * Initialize the VNC frame buffer driver. The VNC frame buffer driver + * supports two initialization interfaces: The standard up_fbinitialize() + * that will be called from the graphics layer and this speical + * initialization function that can be used only by VNC aware OS logic. + * + * The two initialization functions may be called separated or together in + * either order. The difference is that standard up_fbinitialize(), if + * used by itself, will not have any remote mouse or keyboard inputs that + * are reported to the VNC framebuffer driver from the remote VNC client. + * + * In the standard graphics architecture, the keyboard/mouse inputs are + * received by some appliation/board specific logic at the highest level + * in the architecture via input drivers. The received keyboard/mouse + * input data must then be "injected" into NX where it can they can be + * assigned to the window that has focus. They will eventually be + * received by the Window instances via NX callback methods. + * + * NX is a middleware layer in the architecture, below the + * application/board specific logic but above the driver level logic. The + * frame buffer driver, on the other hand lies at the very lowest level in + * the graphics architecture. It cannot call upward into the application + * nor can it call upward into NX. So, some other logic. + * + * vnc_fbinitialize() provides an optional, alternative initialization + * function. It is optional becuase it need not be called. If it is not + * called, however, keyboard/mouse inputs from the remote VNC client will + * be lost. By calling vnc_fbinitialize(), you can provide callout + * functions that can be received by logic higher in the architure. This + * higher level level callouts can then call nx_kbdin() or nx_mousein() on + * behalf of the VNC server. + * + * Parameters: + * display - In the case of hardware with multiple displays, this + * specifies the display. Normally this is zero. + * kbdout - If non-NULL, then the pointed-to function will be called to + * handle all keyboard input as it is received. This may be either raw, + * ASCII keypress input or encoded keyboard input as determined by + * CONFIG_VNCSERVER_KBDENCODE. See include/nuttx/input/kbd_codec.h. + * mouseout - If non-NULL, then the pointed-to function will be called to + * handle all mouse input as it is received. + * arg - An opaque user provided argument that will be provided when the + * callouts are performed. + * + * Returned Value: + * Zero (OK) is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +int vnc_fbinitialize(int display, vnc_kbdout_t kbdout, + vnc_mouseout_t mouseout, FAR void *arg) +{ + FAR struct vnc_session_s *session; + int ret; + + DEBUGASSERT(display >= 0 && display < RFB_MAX_DISPLAYS); + + /* Start the VNC server kernel thread. */ + + ret = vnc_start_server(display); + if (ret < 0) + { + gvdbg("ERROR: vnc_start_server() failed: %d\n", ret); + return ret; + } + + /* Wait for the VNC server to start and complete initialization. */ + + ret = vnc_wait_start(display); + if (ret < 0) + { + gvdbg("ERROR: vnc_wait_start() failed: %d\n", ret); + return ret; + } + + /* Save the input callout function information in the session structure. */ + + session = g_vnc_sessions[display]; + DEBUGASSERT(session != NULL); + + session->kbdout = kbdout; + session->mouseout = mouseout; + session->arg = arg; + + return OK; } /**************************************************************************** @@ -550,12 +748,15 @@ int up_fbinitialize(int display) FAR struct fb_vtable_s *up_fbgetvplane(int display, int vplane) { - FAR struct vnc_session_s *session = vnc_find_session(display); + FAR struct vnc_session_s *session; FAR struct vnc_fbinfo_s *fbinfo; + DEBUGASSERT(display >= 0 && display < RFB_MAX_DISPLAYS); + session = g_vnc_sessions[display]; + /* Verify that the session is still valid */ - if (session->state != VNCSERVER_RUNNING) + if (session == NULL || session->state != VNCSERVER_RUNNING) { return NULL; } @@ -607,14 +808,21 @@ FAR struct fb_vtable_s *up_fbgetvplane(int display, int vplane) void up_fbuninitialize(int display) { #if 0 /* Do nothing */ - FAR struct vnc_session_s *session = vnc_find_session(display); + FAR struct vnc_session_s *session; FAR struct vnc_fbinfo_s *fbinfo; - DEBUGASSERT(session != NULL); - fbinfo = &g_fbinfo[display]; + DEBUGASSERT(display >= 0 && display < RFB_MAX_DISPLAYS); + session = g_vnc_sessions[display]; + + /* Verify that the session is still valid */ + + if (session != NULL) + { + fbinfo = &g_fbinfo[display]; #warning Missing logic - UNUSED(session); - UNUSED(fbinfo); + UNUSED(session); + UNUSED(fbinfo); + } #endif } @@ -653,7 +861,7 @@ void nx_notify_rectangle(FAR NX_PLANEINFOTYPE *pinfo, */ DEBUGASSERT(pinfo->display >= 0 && pinfo->display < RFB_MAX_DISPLAYS); - session = vnc_find_session(pinfo->display); + session = g_vnc_sessions[pinfo->display]; /* Verify that the session is still valid */ diff --git a/graphics/vnc/server/vnc_keymap.c b/graphics/vnc/server/vnc_keymap.c index 57690183f4..bb5fe3f623 100644 --- a/graphics/vnc/server/vnc_keymap.c +++ b/graphics/vnc/server/vnc_keymap.c @@ -481,9 +481,10 @@ void vnc_key_map(FAR struct vnc_session_s *session, uint16_t keysym, #ifdef CONFIG_VNCSERVER_KBDENCODE uint8_t buffer[4] int nch; +#else + uint8_t buffer; #endif int16_t keych; - int ret; /* Check for modifier keys */ @@ -505,6 +506,14 @@ void vnc_key_map(FAR struct vnc_session_s *session, uint16_t keysym, } #endif + /* If no external keyboard input handler has been provided, then we have to drop the keyboard input. + */ + + if (session->kbdout == NULL) + { + return; + } + /* Try to convert the keycode to an ASCII value */ keych = vnc_kbd_ascii((char)(keysym & 255)); @@ -580,19 +589,12 @@ void vnc_key_map(FAR struct vnc_session_s *session, uint16_t keysym, /* Inject the normal character sequence into NX */ - ret = nx_kbdin(session->handle, nch, buffer); - if (ret < 0) - { - gdbg("ERROR: nx_kbdin() failed: %d\n", ret); - } + session->kbdout(session->arg, nch, buffer); #else /* Inject the single key press into NX */ - ret = nx_kbdchin(session->handle,(uint8_t)keych); - if (ret < 0) - { - gdbg("ERROR: nx_kbdchin() failed: %d\n", ret); - } + buffer = (uint8_t)keych; + session->kbdout(session->arg, 1, &buffer); #endif } @@ -619,11 +621,7 @@ void vnc_key_map(FAR struct vnc_session_s *session, uint16_t keysym, /* Inject the special character sequence into NX */ - ret = nx_kbdin(session->handle, nch, buffer); - if (ret < 0) - { - gdbg("ERROR: nx_kbdin() failed: %d\n", ret) - } + session->kbdout(session->arg, nch, buffer); } } #endif diff --git a/graphics/vnc/server/vnc_receiver.c b/graphics/vnc/server/vnc_receiver.c index 1df8df72d2..862b39362a 100644 --- a/graphics/vnc/server/vnc_receiver.c +++ b/graphics/vnc/server/vnc_receiver.c @@ -337,7 +337,7 @@ int vnc_receiver(FAR struct vnc_session_s *session) #ifdef CONFIG_NX_XYINPUT /* REVISIT: How will be get the NX handle? */ - else if (session->handle != NULL) + else if (session->mouseout != NULL) { event = (FAR struct rfb_pointerevent_s *)session->inbuf; @@ -362,14 +362,10 @@ int vnc_receiver(FAR struct vnc_session_s *session) buttons |= NX_MOUSE_RIGHTBUTTON; } - ret = nx_mousein(session->handle, - (nxgl_coord_t)rfb_getbe16(event->xpos), - (nxgl_coord_t)rfb_getbe16(event->ypos), - buttons); - if (ret < 0) - { - gdbg("ERROR: nx_mousein failed: %d\n", ret); - } + session->mouseout(session->arg, + (nxgl_coord_t)rfb_getbe16(event->xpos), + (nxgl_coord_t)rfb_getbe16(event->ypos), + buttons); } #endif } diff --git a/graphics/vnc/server/vnc_server.c b/graphics/vnc/server/vnc_server.c index 742a97fa01..c33050f303 100644 --- a/graphics/vnc/server/vnc_server.c +++ b/graphics/vnc/server/vnc_server.c @@ -271,6 +271,11 @@ int vnc_server(int argc, FAR char *argv[]) sem_init(&session->freesem, 0, CONFIG_VNCSERVER_NUPDATES); sem_init(&session->queuesem, 0, 0); + /* Inform any waiter that we have started */ + + vnc_reset_session(session, fb, display); + sem_post(&g_fbstartup[display].fbinit); + /* Loop... handling each each VNC client connection to this display. Only * a single client is allowed for each display. */ @@ -283,7 +288,7 @@ int vnc_server(int argc, FAR char *argv[]) vnc_reset_session(session, fb, display); g_fbstartup[display].result = -EBUSY; - sem_reset(&g_fbstartup[display].fbsem, 0); + sem_reset(&g_fbstartup[display].fbconnect, 0); /* Establish a connection with the VNC client */ @@ -321,7 +326,7 @@ int vnc_server(int argc, FAR char *argv[]) */ g_fbstartup[display].result = OK; - sem_post(&g_fbstartup[display].fbsem); + sem_post(&g_fbstartup[display].fbconnect); /* Run the VNC receiver on this trhead. The VNC receiver handles * all Client-to-Server messages. The VNC receiver function does @@ -347,36 +352,6 @@ errout_with_fb: errout_with_post: g_fbstartup[display].result = ret; - sem_post(&g_fbstartup[display].fbsem); + sem_post(&g_fbstartup[display].fbconnect); return EXIT_FAILURE; } - -/**************************************************************************** - * Name: vnc_find_session - * - * Description: - * Return the session structure associated with this display. - * - * Input Parameters: - * display - The display number of interest. - * - * Returned Value: - * Returns the instance of the session structure for this display. NULL - * will be returned if the server has not yet been started or if the - * display number is out of range. - * - ****************************************************************************/ - -FAR struct vnc_session_s *vnc_find_session(int display) -{ - FAR struct vnc_session_s *session = NULL; - - DEBUGASSERT(display >= 0 && display < RFB_MAX_DISPLAYS); - - if (display >= 0 && display < RFB_MAX_DISPLAYS) - { - session = g_vnc_sessions[display]; - } - - return session; -} diff --git a/graphics/vnc/server/vnc_server.h b/graphics/vnc/server/vnc_server.h index 4929cc35aa..077bc0d6b4 100644 --- a/graphics/vnc/server/vnc_server.h +++ b/graphics/vnc/server/vnc_server.h @@ -49,6 +49,7 @@ #include #include +#include #include #include #include @@ -239,10 +240,6 @@ struct vnc_fbupdate_s struct vnc_session_s { - /* NX graphics system */ - - NXHANDLE handle; /* NX graphics handle */ - /* Connection data */ struct socket listen; /* Listen socket */ @@ -259,6 +256,12 @@ struct vnc_session_s volatile bool rre; /* Remote supports RRE encoding */ FAR uint8_t *fb; /* Allocated local frame buffer */ + /* VNC client input support */ + + vnc_kbdout_t kbdout; /* Callout when keyboard input is received */ + vnc_mouseout_t mouseout; /* Callout when keyboard input is received */ + FAR void *arg; /* Argument that accompanies the callouts */ + /* Updater information */ pthread_t updater; /* Updater thread ID */ @@ -283,7 +286,8 @@ struct vnc_session_s struct fb_startup_s { - sem_t fbsem; /* Framebuffer driver will wait on this */ + sem_t fbinit; /* Wait for session creation */ + sem_t fbconnect; /* Wait for client connection */ int16_t result; /* OK: successfully initialized */ }; @@ -537,24 +541,6 @@ void vnc_key_map(FAR struct vnc_session_s *session, uint16_t keysym, bool keydown); #endif -/**************************************************************************** - * Name: vnc_find_session - * - * Description: - * Return the session structure associated with this display. - * - * Input Parameters: - * display - The display number of interest. - * - * Returned Value: - * Returns the instance of the session structure for this display. NULL - * will be returned if the server has not yet been started or if the - * display number is out of range. - * - ****************************************************************************/ - -FAR struct vnc_session_s *vnc_find_session(int display); - /**************************************************************************** * Name: vnc_convert_rgbNN * diff --git a/include/nuttx/video/vnc.h b/include/nuttx/video/vnc.h new file mode 100644 index 0000000000..a3b9f9e675 --- /dev/null +++ b/include/nuttx/video/vnc.h @@ -0,0 +1,137 @@ +/**************************************************************************** + * include/nuttx/video/vnc.h + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_VIDEO_VNC_H +#define __INCLUDE_NUTTX_VIDEO_VNC_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/* These are the types of the function pointers used to support callouts when + * mouse or keyboard inputs are received by the local VNC server from the + * remove VNC client. Notice that these callouts have arguments that match + * the inputs to nx_kbdin() and nx_mousein(). + */ + +typedef CODE void (*vnc_mouseout_t)(FAR void *arg, nxgl_coord_t x, + nxgl_coord_t y, uint8_t buttons); +typedef CODE void (*vnc_kbdout_t)(FAR void *arg, uint8_t nch, + FAR const uint8_t *ch); + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Function: vnc_fbinitialize + * + * Description: + * Initialize the VNC frame buffer driver. The VNC frame buffer driver + * supports two initialization interfaces: The standard up_fbinitialize() + * that will be called from the graphics layer and this speical + * initialization function that can be used only by VNC aware OS logic. + * + * The two initialization functions may be called separated or together in + * either order. The difference is that standard up_fbinitialize(), if + * used by itself, will not have any remote mouse or keyboard inputs that + * are reported to the VNC framebuffer driver from the remote VNC client. + * + * In the standard graphics architecture, the keyboard/mouse inputs are + * received by some appliation/board specific logic at the highest level + * in the architecture via input drivers. The received keyboard/mouse + * input data must then be "injected" into NX where it can they can be + * assigned to the window that has focus. They will eventually be + * received by the Window instances via NX callback methods. + * + * NX is a middleware layer in the architecture, below the + * application/board specific logic but above the driver level logic. The + * frame buffer driver, on the other hand lies at the very lowest level in + * the graphics architecture. It cannot call upward into the application + * nor can it call upward into NX. So, some other logic. + * + * vnc_fbinitialize() provides an optional, alternative initialization + * function. It is optional becuase it need not be called. If it is not + * called, however, keyboard/mouse inputs from the remote VNC client will + * be lost. By calling vnc_fbinitialize(), you can provide callout + * functions that can be received by logic higher in the architure. This + * higher level level callouts can then call nx_kbdin() or nx_mousein() on + * behalf of the VNC server. + * + * Parameters: + * display - In the case of hardware with multiple displays, this + * specifies the display. Normally this is zero. + * kbdout - If non-NULL, then the pointed-to function will be called to + * handle all keyboard input as it is received. This may be either raw, + * ASCII keypress input or encoded keyboard input as determined by + * CONFIG_VNCSERVER_KBDENCODE. See include/nuttx/input/kbd_codec.h. + * mouseout - If non-NULL, then the pointed-to function will be called to + * handle all mouse input as it is received. + * arg - An opaque user provided argument that will be provided when the + * callouts are performed. + * + * Returned Value: + * Zero (OK) is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +int vnc_fbinitialize(int display, vnc_kbdout_t kbdout, + vnc_mouseout_t mouseout, FAR void *arg); + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* __INCLUDE_NUTTX_VIDEO_VNC_H */