This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 1699f53 vncserver: Allow fb operation while no connection
1699f53 is described below
commit 1699f530a50bbc991b5d52185c0ac404ccb23a8b
Author: Huang Qi <[email protected]>
AuthorDate: Tue Feb 15 15:25:42 2022 +0800
vncserver: Allow fb operation while no connection
Signed-off-by: Huang Qi <[email protected]>
---
drivers/video/vnc/vnc_fbdev.c | 91 ++++--------------------------------------
drivers/video/vnc/vnc_server.c | 3 --
drivers/video/vnc/vnc_server.h | 1 -
3 files changed, 7 insertions(+), 88 deletions(-)
diff --git a/drivers/video/vnc/vnc_fbdev.c b/drivers/video/vnc/vnc_fbdev.c
index 6f41028..371b1db 100644
--- a/drivers/video/vnc/vnc_fbdev.c
+++ b/drivers/video/vnc/vnc_fbdev.c
@@ -169,7 +169,7 @@ static int up_getvideoinfo(FAR struct fb_vtable_s *vtable,
fbinfo->display < RFB_MAX_DISPLAYS);
session = g_vnc_sessions[fbinfo->display];
- if (session == NULL || session->state != VNCSERVER_RUNNING)
+ if (session == NULL)
{
gerr("ERROR: session is not connected\n");
return -ENOTCONN;
@@ -211,7 +211,7 @@ static int up_getplaneinfo(FAR struct fb_vtable_s *vtable,
int planeno,
fbinfo->display < RFB_MAX_DISPLAYS);
session = g_vnc_sessions[fbinfo->display];
- if (session == NULL || session->state != VNCSERVER_RUNNING)
+ if (session == NULL)
{
gerr("ERROR: session is not connected\n");
return -ENOTCONN;
@@ -508,7 +508,6 @@ static int vnc_start_server(int display)
g_fbstartup[display].result = -EBUSY;
nxsem_reset(&g_fbstartup[display].fbinit, 0);
- nxsem_reset(&g_fbstartup[display].fbconnect, 0);
/* Format the kernel thread arguments (ASCII.. yech) */
@@ -577,83 +576,6 @@ static inline int vnc_wait_start(int display)
}
/****************************************************************************
- * Name: vnc_wait_connect
- *
- * Description:
- * Wait for the server to be connected to the VNC client. We can do
- * nothing until that connection is established.
- *
- * 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_connect(int display)
-{
- int ret;
-
- /* 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 RUNNING state.
- * The RUNNING state indicates that the server has started, it has
- * established a connection with the VNC client, it is negotiated
- * encodings and framebuffer characteristics, and it has started the
- * updater thread. The server is now ready to receive Client-to-Server
- * messages and to perform remote framebuffer updates.
- */
-
- while (g_vnc_sessions[display] == NULL ||
- g_vnc_sessions[display]->state != VNCSERVER_RUNNING)
- {
- /* 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.
- */
-
- ret = nxsem_wait_uninterruptible(&g_fbstartup[display].fbconnect);
- if (ret < 0)
- {
- return ret;
- }
-
- /* We were awakened. A result of -EBUSY means that the negotiation
- * is not complete. Why would we be awakened in that case? Some
- * counting semaphore screw-up?
- */
-
- ret = g_fbstartup[display].result;
- if (ret != -EBUSY)
- {
-#ifdef CONFIG_DEBUG_FEATURES
- if (ret < 0)
- {
- DEBUGASSERT(g_vnc_sessions[display] == NULL);
- gerr("ERROR: VNC server startup failed: %d\n", ret);
- }
- else
- {
- DEBUGASSERT(g_vnc_sessions[display] != NULL &&
- g_vnc_sessions[display]->state ==
- VNCSERVER_RUNNING);
- }
-#endif
-
- return ret;
- }
- }
-
- return OK;
-}
-
-/****************************************************************************
* Public Functions
****************************************************************************/
@@ -688,12 +610,13 @@ int up_fbinitialize(int display)
return ret;
}
- /* Wait for the VNC client to connect and for the RFB to be ready */
+ /* Wait for the VNC server to be ready */
+
+ ret = vnc_wait_start(display);
- ret = vnc_wait_connect(display);
if (ret < 0)
{
- gerr("ERROR: vnc_wait_connect() failed: %d\n", ret);
+ gerr("ERROR: wait for vnc server start failed: %d\n", ret);
}
return ret;
@@ -817,7 +740,7 @@ FAR struct fb_vtable_s *up_fbgetvplane(int display, int
vplane)
/* Verify that the session is still valid */
- if (session == NULL || session->state != VNCSERVER_RUNNING)
+ if (session == NULL)
{
return NULL;
}
diff --git a/drivers/video/vnc/vnc_server.c b/drivers/video/vnc/vnc_server.c
index fc9de6b..ef0bbfc 100644
--- a/drivers/video/vnc/vnc_server.c
+++ b/drivers/video/vnc/vnc_server.c
@@ -301,7 +301,6 @@ int vnc_server(int argc, FAR char *argv[])
vnc_reset_session(session, fb, display);
g_fbstartup[display].result = -EBUSY;
- nxsem_reset(&g_fbstartup[display].fbconnect, 0);
/* Establish a connection with the VNC client */
@@ -339,7 +338,6 @@ int vnc_server(int argc, FAR char *argv[])
*/
g_fbstartup[display].result = OK;
- nxsem_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
@@ -366,7 +364,6 @@ errout_with_fb:
errout_with_post:
g_fbstartup[display].result = ret;
- nxsem_post(&g_fbstartup[display].fbconnect);
errout_with_hang:
return EXIT_FAILURE;
diff --git a/drivers/video/vnc/vnc_server.h b/drivers/video/vnc/vnc_server.h
index 0ba47d0..c40bafc 100644
--- a/drivers/video/vnc/vnc_server.h
+++ b/drivers/video/vnc/vnc_server.h
@@ -250,7 +250,6 @@ struct vnc_session_s
struct fb_startup_s
{
sem_t fbinit; /* Wait for session creation */
- sem_t fbconnect; /* Wait for client connection */
int16_t result; /* OK: successfully initialized */
};