Various graphics apps: If CONFIG_VNCSERVER=y, don't vnc_default_fbinitialize() directly. That is a violation of the portable POSIX interface. Instead, call boardctl(BOARDIOC_VNC_START);.

This commit is contained in:
Gregory Nutt 2019-04-02 07:06:06 -06:00
parent 84922406f7
commit 61eb262142
12 changed files with 173 additions and 140 deletions
examples
graphics
NxWidgets/nxwidgets/src
screenshot
traveler/src

View File

@ -1,7 +1,8 @@
/****************************************************************************
* examples/nx/nx_main.c
*
* Copyright (C) 2008-2011, 2015-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2008-2011, 2015-2016, 2019 Gregory Nutt. All rights
* reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -56,10 +57,6 @@
#include <nuttx/arch.h>
#include <nuttx/board.h>
#ifdef CONFIG_VNCSERVER
# include <nuttx/video/vnc.h>
#endif
#include <nuttx/nx/nx.h>
#include <nuttx/nx/nxtk.h>
#include <nuttx/nx/nxfonts.h>
@ -458,15 +455,21 @@ static int nxeg_initialize(void)
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
ret = vnc_default_fbinitialize(0, g_hnx);
if (ret < 0)
{
printf("vnc_default_fbinitialize failed: %d\n", ret);
nx_disconnect(g_hnx);
g_exitcode = NXEXIT_FBINITIALIZE;
return ERROR;
}
struct boardioc_vncstart_s vnc =
{
0, g_hnx
};
ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
if (ret < 0)
{
printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
nx_disconnect(g_hnx);
g_exitcode = NXEXIT_FBINITIALIZE;
return ERROR;
}
#endif
/* Start a separate thread to listen for server events. This is probably
* the least efficient way to do this, but it makes this example flow more
* smoothly.

View File

@ -1,7 +1,7 @@
/****************************************************************************
* examples/nxdemo/nxdemo_main.c
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Copyright (C) 2018-2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Cherciu Mihail <m_cherciu@yahoo.com>
*
@ -61,9 +61,6 @@
# include <nuttx/lcd/lcd.h>
#else
# include <nuttx/video/fb.h>
# ifdef CONFIG_VNCSERVER
# include <nuttx/video/vnc.h>
# endif
#endif
#include <nuttx/nx/nx.h>
@ -148,14 +145,20 @@ static inline int nxdemo_initialize(void)
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
ret = vnc_default_fbinitialize(0, g_nxdemo.hnx);
if (ret < 0)
{
printf("vnc_default_fbinitialize failed: %d\n", ret);
nx_disconnect(g_nxdemo.hnx);
return ERROR;
}
struct boardioc_vncstart_s vnc =
{
0, g_nxdemo.hnx
};
ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
if (ret < 0)
{
printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
nx_disconnect(g_nxdemo.hnx);
return ERROR;
}
#endif
/* Start a separate thread to listen for server events. This is probably
* the least efficient way to do this, but it makes this example flow more
* smoothly.

View File

@ -1,7 +1,7 @@
/****************************************************************************
* examples/nxhello/nxhello_main.c
*
* Copyright (C) 2011, 2015-2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2015-2017, 2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -56,10 +56,6 @@
#include <nuttx/arch.h>
#include <nuttx/board.h>
#ifdef CONFIG_VNCSERVER
# include <nuttx/video/vnc.h>
#endif
#include <nuttx/nx/nx.h>
#include <nuttx/nx/nxglib.h>
#include <nuttx/nx/nxfonts.h>
@ -126,14 +122,20 @@ static inline int nxhello_initialize(void)
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
ret = vnc_default_fbinitialize(0, g_nxhello.hnx);
if (ret < 0)
{
printf("vnc_default_fbinitialize failed: %d\n", ret);
nx_disconnect(g_nxhello.hnx);
return ERROR;
}
struct boardioc_vncstart_s vnc =
{
0, g_nxhello.hnx
};
ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
if (ret < 0)
{
printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
nx_disconnect(g_nxhello.hnx);
return ERROR;
}
#endif
/* Start a separate thread to listen for server events. This is probably
* the least efficient way to do this, but it makes this example flow more
* smoothly.

View File

@ -56,10 +56,6 @@
#include <nuttx/arch.h>
#include <nuttx/board.h>
#ifdef CONFIG_VNCSERVER
# include <nuttx/video/vnc.h>
#endif
#include <nuttx/nx/nx.h>
#include <nuttx/nx/nxglib.h>
#include <nuttx/nx/nxfonts.h>
@ -130,14 +126,20 @@ static inline int nximage_initialize(void)
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
ret = vnc_default_fbinitialize(0, g_nximage.hnx);
if (ret < 0)
{
printf("vnc_default_fbinitialize failed: %d\n", ret);
nx_disconnect(g_nximage.hnx);
return ERROR;
}
struct boardioc_vncstart_s vnc =
{
0, g_nximage.hnx
};
ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
if (ret < 0)
{
printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
nx_disconnect(g_nximage.hnx);
return ERROR;
}
#endif
/* Start a separate thread to listen for server events. This is probably
* the least efficient way to do this, but it makes this example flow more
* smoothly.

View File

@ -1,7 +1,8 @@
/****************************************************************************
* examples/nxlines/nxlines_main.c
*
* Copyright (C) 2011-2012, 2015-2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2011-2012, 2015-2017, 2019 Gregory Nutt. All rights
* reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -54,10 +55,6 @@
#include <nuttx/arch.h>
#include <nuttx/board.h>
#ifdef CONFIG_VNCSERVER
# include <nuttx/video/vnc.h>
#endif
#include <nuttx/nx/nx.h>
#include <nuttx/nx/nxglib.h>
@ -151,14 +148,20 @@ static inline int nxlines_initialize(void)
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
ret = vnc_default_fbinitialize(0, g_nxlines.hnx);
if (ret < 0)
{
printf("vnc_default_fbinitialize failed: %d\n", ret);
nx_disconnect(g_nxlines.hnx);
return ERROR;
}
struct boardioc_vncstart_s vnc =
{
0, g_nxlines.hnx
};
ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
if (ret < 0)
{
printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
nx_disconnect(g_nxlines.hnx);
return ERROR;
}
#endif
/* Start a separate thread to listen for server events. This is probably
* the least efficient way to do this, but it makes this example flow more
* smoothly.

View File

@ -56,9 +56,6 @@
# include <nuttx/lcd/lcd.h>
#else
# include <nuttx/video/fb.h>
# ifdef CONFIG_VNCSERVER
# include <nuttx/video/vnc.h>
# endif
#endif
#include <nuttx/nx/nx.h>
@ -142,15 +139,22 @@ static int nxterm_initialize(void)
pthread_attr_t attr;
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
/* Setup the VNC server to support keyboard/mouse inputs */
ret = vnc_default_fbinitialize(0, g_nxterm_vars.hnx);
if (ret < 0)
{
printf("vnc_default_fbinitialize failed: %d\n", ret);
return ERROR;
}
struct boardioc_vncstart_s vnc =
{
0, g_nxterm_vars.hnx
};
ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
if (ret < 0)
{
printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
nx_disconnect(g_nxterm_vars.hnx);
return ERROR;
}
#endif
/* Start a separate thread to listen for server events. This is probably
* the least efficient way to do this, but it makes this example flow more
* smoothly.

View File

@ -1,7 +1,8 @@
/****************************************************************************
* examples/nxtext/nxtext_main.c
*
* Copyright (C) 2011-2012, 2015-2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2011-2012, 2015-2017, 2019 Gregory Nutt. All rights
* reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -60,9 +61,6 @@
# include <nuttx/lcd/lcd.h>
#else
# include <nuttx/video/fb.h>
# ifdef CONFIG_VNCSERVER
# include <nuttx/video/vnc.h>
# endif
#endif
#include <nuttx/nx/nx.h>
@ -204,15 +202,21 @@ static int nxtext_initialize(void)
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
ret = vnc_default_fbinitialize(0, g_hnx);
if (ret < 0)
{
printf("vnc_default_fbinitialize failed: %d\n", ret);
struct boardioc_vncstart_s vnc =
{
0, g_hnx
};
g_exitcode = NXEXIT_FBINITIALIZE;
return ERROR;
}
ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
if (ret < 0)
{
printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
nx_disconnect(g_hnx);
g_exitcode = NXEXIT_FBINITIALIZE;
return ERROR;
}
#endif
/* Start a separate thread to listen for server events. This is probably
* the least efficient way to do this, but it makes this example flow more
* smoothly.

View File

@ -57,10 +57,6 @@
#include <nuttx/arch.h>
#include <nuttx/board.h>
#ifdef CONFIG_VNCSERVER
# include <nuttx/video/vnc.h>
#endif
#include <nuttx/nx/nx.h>
#include <nuttx/nx/nxtk.h>
#include <nuttx/nx/nxbe.h>
@ -120,15 +116,22 @@ static bool pwfb_server_initialize(FAR struct pwfb_state_s *st)
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
ret = vnc_default_fbinitialize(0, st->hnx);
if (ret < 0)
{
printf("pwfb_server_initialize: ERROR: "
"vnc_default_fbinitialize failed: %d\n",
ret);
nx_disconnect(st->hnx);
return false;
}
struct boardioc_vncstart_s vnc =
{
0, st->hnx
};
ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
if (ret < 0)
{
printf("pwfb_server_initialize: ERROR: "
"boardctl(BOARDIOC_VNC_START) failed: %d\n",
ret);
nx_disconnect(st->hnx);
g_exitcode = NXEXIT_FBINITIALIZE;
return ERROR;
}
#endif
}
else

View File

@ -57,10 +57,6 @@
#include <nuttx/arch.h>
#include <nuttx/board.h>
#ifdef CONFIG_VNCSERVER
# include <nuttx/video/vnc.h>
#endif
#include <nuttx/nx/nx.h>
#include <nuttx/nx/nxtk.h>
#include <nuttx/nx/nxbe.h>
@ -111,15 +107,21 @@ static bool pwlines_server_initialize(FAR struct pwlines_state_s *st)
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
ret = vnc_default_fbinitialize(0, st->hnx);
if (ret < 0)
{
printf("pwlines_server_initialize: ERROR: "
"vnc_default_fbinitialize failed: %d\n",
ret);
nx_disconnect(st->hnx);
return false;
}
struct boardioc_vncstart_s vnc =
{
0, st->hnx
};
ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
if (ret < 0)
{
printf("pwlines_server_initialize: ERROR: "
"boardctl(BOARDIOC_VNC_START) failed: %d\n",
ret);
nx_disconnect(st->hnx);
return false;
}
#endif
}
else

View File

@ -1,7 +1,8 @@
/****************************************************************************
* apps/graphics/NxWidgets/nxwidgets/src/cnxserver.cxx
*
* Copyright (C) 2012, 2013, 2015-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2012, 2013, 2015-2016, 2019 Gregory Nutt. All rights
* reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -54,10 +55,6 @@
#include <nuttx/board.h>
#ifdef CONFIG_VNCSERVER
# include <nuttx/video/vnc.h>
#endif
#include "graphics/nxwidgets/nxconfig.hxx"
#include "graphics/nxwidgets/singletons.hxx"
#include "graphics/nxwidgets/cnxserver.hxx"
@ -161,14 +158,19 @@ bool CNxServer::connect(void)
#ifdef CONFIG_VNCSERVER
// Setup the VNC server to support keyboard/mouse inputs
ret = vnc_default_fbinitialize(0, m_hNxServer);
if (ret < 0)
{
gerr("ERROR: CNxServer::connect: vnc_default_fbinitialize failed: %d\n", ret);
m_running = false;
disconnect();
return false;
}
struct boardioc_vncstart_s vnc =
{
0, m_hNxServer
};
ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
if (ret < 0)
{
gerr("ERROR: boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
m_running = false;
disconnect();
return false;
}
#endif
// Start a separate thread to listen for server events. This is probably

View File

@ -1,7 +1,7 @@
/****************************************************************************
* apps/examples/screenshot/screenshot_main.c
*
* Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2013, 2016, 2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Petteri Aimonen <jpa@kapsi.fi>
*
@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <sys/boardctl.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
@ -52,10 +53,6 @@
#include <nuttx/nx/nx.h>
#ifdef CONFIG_VNCSERVER
# include <nuttx/video/vnc.h>
#endif
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
@ -125,6 +122,9 @@ int save_screenshot(FAR const char *filename)
struct tiff_info_s info;
struct nx_callback_s cb = {};
struct nxgl_size_s size = {CONFIG_SCREENSHOT_WIDTH, CONFIG_SCREENSHOT_HEIGHT};
#ifdef CONFIG_VNCSERVER
struct boardioc_vncstart_s vnc;
#endif
FAR uint8_t *strip;
NXHANDLE server;
NXWINDOW window;
@ -146,15 +146,18 @@ int save_screenshot(FAR const char *filename)
}
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
/* Setup the VNC server to support keyboard/mouse inputs */
ret = vnc_default_fbinitialize(0, server);
if (ret < 0)
{
printf("vnc_default_fbinitialize failed: %d\n", ret);
nx_disconnect(server);
return 1;
}
vnc.display = 0;
vnc.handle = server;
ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
if (ret < 0)
{
printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
nx_disconnect(server);
return 1;
}
#endif
/* Wait for "connected" event */

View File

@ -58,9 +58,6 @@
#ifdef CONFIG_GRAPHICS_TRAVELER_FB
# include <nuttx/video/fb.h>
#endif
#ifdef CONFIG_VNCSERVER
# include <nuttx/video/vnc.h>
#endif
/****************************************************************************
* Public Data
@ -241,11 +238,16 @@ static inline int trv_nx_initialize(FAR struct trv_graphics_info_s *ginfo)
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
ret = vnc_default_fbinitialize(0, ginfo->hnx);
if (ret < 0)
{
trv_abort("vnc_default_fbinitialize failed: %d\n", ret);
}
struct boardioc_vncstart_s vnc =
{
0, ginfo->hnx
};
ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
if (ret < 0)
{
trv_abort("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
}
#endif
/* Start a separate thread to listen for server events. This is probably