Graphics: Remove all NX server taks. Instead, call boardctl() to the the NX server kernel thread.
This commit is contained in:
parent
7288a8d7c0
commit
38e3619e21
@ -14,6 +14,7 @@ if EXAMPLES_NX
|
||||
config EXAMPLES_NX_VPLANE
|
||||
int "Video Plane"
|
||||
default 0
|
||||
depends on !NX_MULTIUSER
|
||||
---help---
|
||||
The plane to select from the framebuffer driver for use in the test.
|
||||
Default: 0
|
||||
@ -21,6 +22,7 @@ config EXAMPLES_NX_VPLANE
|
||||
config EXAMPLES_NX_DEVNO
|
||||
int "Video Device Number"
|
||||
default 0
|
||||
depends on !NX_MULTIUSER
|
||||
---help---
|
||||
The LCD device to select from the LCD driver for use in the test:
|
||||
Default: 0
|
||||
@ -94,6 +96,7 @@ config EXAMPLES_NX_EXTERNINIT
|
||||
default n
|
||||
depends on LIB_BOARDCTL
|
||||
select BOARDCTL_GRAPHICS
|
||||
select NXSTART_EXTERNINIT if NX_MULTIUSER
|
||||
---help---
|
||||
The driver for the graphics device on this platform requires some
|
||||
unusual initialization. This is the for, for example, SPI LCD/OLED
|
||||
|
@ -39,9 +39,6 @@
|
||||
|
||||
ASRCS =
|
||||
CSRCS = nx_events.c nx_kbdin.c
|
||||
ifeq ($(CONFIG_NX_MULTIUSER),y)
|
||||
CSRCS += nx_server.c
|
||||
endif
|
||||
MAINSRC = nx_main.c
|
||||
|
||||
CONFIG_XYZ_PROGNAME ?= nx$(EXEEXT)
|
||||
|
@ -277,7 +277,6 @@ extern nxgl_mxpixel_t g_tbcolor[CONFIG_NX_NPLANES];
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NX) && defined(CONFIG_NX_MULTIUSER)
|
||||
int nx_servertask(int argc, char *argv[]);
|
||||
FAR void *nx_listenerthread(FAR void *arg);
|
||||
#endif
|
||||
|
||||
|
@ -88,14 +88,6 @@
|
||||
# define CONFIG_EXAMPLES_NX_DEVNO 0
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -542,7 +534,6 @@ static inline int nxeg_muinitialize(void)
|
||||
{
|
||||
struct sched_param param;
|
||||
pthread_t thread;
|
||||
pid_t servrid;
|
||||
int ret;
|
||||
|
||||
/* Set the client task priority */
|
||||
@ -556,22 +547,16 @@ static inline int nxeg_muinitialize(void)
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/* Start the server task */
|
||||
/* Start the NX server kernel thread */
|
||||
|
||||
printf("nxeg_initialize: Starting nx_servertask task\n");
|
||||
servrid = task_create("NX Server", CONFIG_EXAMPLES_NX_SERVERPRIO,
|
||||
CONFIG_EXAMPLES_NX_STACKSIZE, nx_servertask, NULL);
|
||||
if (servrid < 0)
|
||||
ret = boardctl(BOARDIOC_NX_START, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("nxeg_initialize: Failed to create nx_servertask task: %d\n", errno);
|
||||
printf("nxeg_initialize: Failed to start the NX server: %d\n", errno);
|
||||
g_exitcode = NXEXIT_TASKCREATE;
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/* Wait a bit to let the server get started */
|
||||
|
||||
sleep(1);
|
||||
|
||||
/* Connect to the server */
|
||||
|
||||
g_hnx = nx_connect();
|
||||
@ -942,7 +927,7 @@ errout_with_nx:
|
||||
printf("nx_main: Disconnect from the server\n");
|
||||
nx_disconnect(g_hnx);
|
||||
#else
|
||||
/* Close the server */
|
||||
/* Close the window */
|
||||
|
||||
printf("nx_main: Close NX\n");
|
||||
nx_close(g_hnx);
|
||||
|
@ -1,168 +0,0 @@
|
||||
/****************************************************************************
|
||||
* examples/nx/nx_server.c
|
||||
*
|
||||
* Copyright (C) 2008-2009, 2015-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/boardctl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sched.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/nx/nx.h>
|
||||
|
||||
#ifdef CONFIG_NX_LCDDRIVER
|
||||
# include <nuttx/lcd/lcd.h>
|
||||
#else
|
||||
# include <nuttx/video/fb.h>
|
||||
#endif
|
||||
|
||||
#include "nx_internal.h"
|
||||
|
||||
#ifdef CONFIG_NX_MULTIUSER
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nx_servertask
|
||||
****************************************************************************/
|
||||
|
||||
int nx_servertask(int argc, char *argv[])
|
||||
{
|
||||
FAR NX_DRIVERTYPE *dev;
|
||||
int ret;
|
||||
|
||||
#if defined(CONFIG_EXAMPLES_NX_EXTERNINIT)
|
||||
struct boardioc_graphics_s devinfo;
|
||||
int ret;
|
||||
|
||||
/* Use external graphics driver initialization */
|
||||
|
||||
printf("nx_servertask: Initializing external graphics device\n");
|
||||
|
||||
devinfo.devno = CONFIG_EXAMPLES_NX_DEVNO;
|
||||
devinfo.dev = NULL;
|
||||
|
||||
ret = boardctl(BOARDIOC_GRAPHICS_SETUP, (uintptr_t)&devinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("nx_servertask: boardctl failed, devno=%d: %d\n",
|
||||
CONFIG_EXAMPLES_NX_DEVNO, errno);
|
||||
g_exitcode = NXEXIT_EXTINITIALIZE;
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
dev = devinfo.dev;
|
||||
|
||||
#elif defined(CONFIG_NX_LCDDRIVER)
|
||||
/* Initialize the LCD device */
|
||||
|
||||
printf("nx_servertask: Initializing LCD\n");
|
||||
ret = board_lcd_initialize();
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("nx_servertask: board_lcd_initialize failed: %d\n", -ret);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Get the device instance */
|
||||
|
||||
dev = board_lcd_getdev(CONFIG_EXAMPLES_NX_DEVNO);
|
||||
if (!dev)
|
||||
{
|
||||
printf("nx_servertask: board_lcd_getdev failed, devno=%d\n",
|
||||
CONFIG_EXAMPLES_NX_DEVNO);
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* Turn the LCD on at 75% power */
|
||||
|
||||
(void)dev->setpower(dev, ((3*CONFIG_LCD_MAXPOWER + 3)/4));
|
||||
#else
|
||||
/* Initialize the frame buffer device */
|
||||
|
||||
printf("nx_servertask: Initializing framebuffer\n");
|
||||
|
||||
ret = up_fbinitialize(0);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("nx_servertask: up_fbinitialize failed: %d\n", -ret);
|
||||
return 1;
|
||||
}
|
||||
|
||||
dev = up_fbgetvplane(0, CONFIG_EXAMPLES_NX_VPLANE);
|
||||
if (!dev)
|
||||
{
|
||||
printf("nx_servertask: up_fbgetvplane failed, vplane=%d\n",
|
||||
CONFIG_EXAMPLES_NX_VPLANE);
|
||||
return 2;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Then start the server */
|
||||
|
||||
ret = nx_run(dev);
|
||||
printf("nx_servertask: nx_run returned: %d\n", errno);
|
||||
return 3;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NX_MULTIUSER */
|
@ -38,7 +38,7 @@
|
||||
# NuttX NX Console Example.
|
||||
|
||||
ASRCS =
|
||||
CSRCS = nxterm_toolbar.c nxterm_wndo.c nxterm_server.c
|
||||
CSRCS = nxterm_toolbar.c nxterm_wndo.c nxterm_listener.c
|
||||
MAINSRC = nxterm_main.c
|
||||
|
||||
CONFIG_XYZ_PROGNAME ?= nxterm$(EXEEXT)
|
||||
|
@ -279,7 +279,6 @@ extern const struct nx_callback_s g_nxtoolcb;
|
||||
|
||||
/* Server thread support */
|
||||
|
||||
int nxterm_server(int argc, char *argv[]);
|
||||
FAR void *nxterm_listener(FAR void *arg);
|
||||
|
||||
#endif /* __EXAMPLES_NXTERM_NXTERM_INTERNAL_H */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* examples/nxterm/nxterm_server.c
|
||||
* examples/nxterm/nxterm_listener.c
|
||||
*
|
||||
* Copyright (C) 2012, 2015-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
@ -39,128 +39,18 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/boardctl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sched.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/nx/nx.h>
|
||||
|
||||
#ifdef CONFIG_NX_LCDDRIVER
|
||||
# include <nuttx/lcd/lcd.h>
|
||||
#else
|
||||
# include <nuttx/video/fb.h>
|
||||
#endif
|
||||
|
||||
#include "nxterm_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxterm_server
|
||||
****************************************************************************/
|
||||
|
||||
int nxterm_server(int argc, char *argv[])
|
||||
{
|
||||
FAR NX_DRIVERTYPE *dev;
|
||||
int ret;
|
||||
|
||||
#if defined(CONFIG_EXAMPLES_NXTERM_EXTERNINIT)
|
||||
struct boardioc_graphics_s devinfo;
|
||||
int ret;
|
||||
|
||||
/* Use external graphics driver initialization */
|
||||
|
||||
printf("nxterm_server: Initializing external graphics device\n");
|
||||
|
||||
devinfo.devno = CONFIG_EXAMPLES_NXTERM_DEVNO;
|
||||
devinfo.dev = NULL;
|
||||
|
||||
ret = boardctl(BOARDIOC_GRAPHICS_SETUP, (uintptr_t)&devinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("nxterm_server: boardctl failed, devno=%d: %d\n",
|
||||
CONFIG_EXAMPLES_NXTERM_DEVNO, errno);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
dev = devinfo.dev;
|
||||
|
||||
#elif defined(CONFIG_NX_LCDDRIVER)
|
||||
/* Initialize the LCD device */
|
||||
|
||||
printf("nxterm_server: Initializing LCD\n");
|
||||
ret = board_lcd_initialize();
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("nxterm_server: board_lcd_initialize failed: %d\n", -ret);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Get the device instance */
|
||||
|
||||
dev = board_lcd_getdev(CONFIG_EXAMPLES_NXTERM_DEVNO);
|
||||
if (!dev)
|
||||
{
|
||||
printf("nxterm_server: board_lcd_getdev failed, devno=%d\n",
|
||||
CONFIG_EXAMPLES_NXTERM_DEVNO);
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* Turn the LCD on at 75% power */
|
||||
|
||||
(void)dev->setpower(dev, ((3*CONFIG_LCD_MAXPOWER + 3)/4));
|
||||
#else
|
||||
/* Initialize the frame buffer device */
|
||||
|
||||
printf("nxterm_server: Initializing framebuffer\n");
|
||||
|
||||
ret = up_fbinitialize(0);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("nxterm_server: up_fbinitialize failed: %d\n", -ret);
|
||||
return 1;
|
||||
}
|
||||
|
||||
dev = up_fbgetvplane(0, CONFIG_EXAMPLES_NXTERM_VPLANE);
|
||||
if (!dev)
|
||||
{
|
||||
printf("nxterm_server: up_fbgetvplane failed, vplane=%d\n",
|
||||
CONFIG_EXAMPLES_NXTERM_VPLANE);
|
||||
return 2;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Then start the server */
|
||||
|
||||
ret = nx_run(dev);
|
||||
ginfo("nx_run returned: %d\n", errno);
|
||||
return 3;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxterm_listener
|
||||
****************************************************************************/
|
@ -40,6 +40,7 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/boardctl.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
@ -70,22 +71,6 @@
|
||||
|
||||
#include "nxterm_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
@ -108,7 +93,6 @@ static int nxterm_initialize(void)
|
||||
{
|
||||
struct sched_param param;
|
||||
pthread_t thread;
|
||||
pid_t servrid;
|
||||
int ret;
|
||||
|
||||
/* Set the client task priority */
|
||||
@ -121,21 +105,15 @@ static int nxterm_initialize(void)
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/* Start the server task */
|
||||
/* Start the NX server kernel thread */
|
||||
|
||||
printf("nxterm_initialize: Starting nxterm_server task\n");
|
||||
servrid = task_create("NX Server", CONFIG_EXAMPLES_NXTERM_SERVERPRIO,
|
||||
CONFIG_EXAMPLES_NXTERM_STACKSIZE, nxterm_server, NULL);
|
||||
if (servrid < 0)
|
||||
ret = boardctl(BOARDIOC_NX_START, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("nxterm_initialize: Failed to create nxterm_server task: %d\n", errno);
|
||||
printf("nxterm_initialize: Failed to start the NX server: %d\n", errno);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/* Wait a bit to let the server get started */
|
||||
|
||||
sleep(1);
|
||||
|
||||
/* Connect to the server */
|
||||
|
||||
g_nxterm_vars.hnx = nx_connect();
|
||||
|
@ -134,22 +134,10 @@ if NX_MULTIUSER
|
||||
comment "Multi-User Configuration Options"
|
||||
|
||||
config EXAMPLES_NXTEXT_STACKSIZE
|
||||
int "NX Server Stack Size"
|
||||
int "Listener Stack Size"
|
||||
default 2048
|
||||
---help---
|
||||
The stacksize to use when creating the NX server. Default 2048
|
||||
|
||||
config EXAMPLES_NXTEXT_CLIENTPRIO
|
||||
int "Client Priority"
|
||||
default 100
|
||||
---help---
|
||||
The client priority. Default: 100
|
||||
|
||||
config EXAMPLES_NXTEXT_SERVERPRIO
|
||||
int "Server Priority"
|
||||
default 120
|
||||
---help---
|
||||
The server priority. Default: 120
|
||||
The stacksize to use when starting the NX listener. Default 2048
|
||||
|
||||
config EXAMPLES_NXTEXT_LISTENERPRIO
|
||||
int "Listener Priority"
|
||||
@ -157,11 +145,5 @@ config EXAMPLES_NXTEXT_LISTENERPRIO
|
||||
---help---
|
||||
The priority of the event listener thread. Default 100.
|
||||
|
||||
config EXAMPLES_NXTEXT_NOTIFYSIGNO
|
||||
int "Notify Signal Number"
|
||||
default 4
|
||||
---help---
|
||||
The signal number to use with nx_eventnotify(). Default: 4
|
||||
|
||||
endif # NX_MULTIUSER
|
||||
endif # EXAMPLES_NXTEXT
|
||||
|
@ -42,7 +42,7 @@ CSRCS = nxtext_bkgd.c nxtext_popup.c nxtext_putc.c
|
||||
MAINSRC = nxtext_main.c
|
||||
|
||||
ifeq ($(CONFIG_NX_MULTIUSER),y)
|
||||
CSRCS += nxtext_server.c
|
||||
CSRCS += nxtext_listener.c
|
||||
endif
|
||||
|
||||
CONFIG_XYZ_PROGNAME ?= nxtext$(EXEEXT)
|
||||
|
@ -178,15 +178,6 @@
|
||||
# ifndef CONFIG_EXAMPLES_NXTEXT_LISTENERPRIO
|
||||
# define CONFIG_EXAMPLES_NXTEXT_LISTENERPRIO 100
|
||||
# endif
|
||||
# ifndef CONFIG_EXAMPLES_NXTEXT_CLIENTPRIO
|
||||
# define CONFIG_EXAMPLES_NXTEXT_CLIENTPRIO 100
|
||||
# endif
|
||||
# ifndef CONFIG_EXAMPLES_NXTEXT_SERVERPRIO
|
||||
# define CONFIG_EXAMPLES_NXTEXT_SERVERPRIO 120
|
||||
# endif
|
||||
# ifndef CONFIG_EXAMPLES_NXTEXT_NOTIFYSIGNO
|
||||
# define CONFIG_EXAMPLES_NXTEXT_NOTIFYSIGNO 4
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Bitmap flags */
|
||||
@ -208,7 +199,7 @@ enum exitcode_e
|
||||
{
|
||||
NXEXIT_SUCCESS = 0,
|
||||
NXEXIT_SCHEDSETPARAM,
|
||||
NXEXIT_TASKCREATE,
|
||||
NXEXIT_SERVERSTART,
|
||||
NXEXIT_PTHREADCREATE,
|
||||
NXEXIT_EXTINITIALIZE,
|
||||
NXEXIT_FBINITIALIZE,
|
||||
@ -315,7 +306,6 @@ extern int g_exitcode;
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NX) && defined(CONFIG_NX_MULTIUSER)
|
||||
int nxtext_server(int argc, char *argv[]);
|
||||
FAR void *nxtext_listener(FAR void *arg);
|
||||
#endif
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* examples/nxtext/nxtext_server.c
|
||||
* examples/nxtext/nxtext_listener.c
|
||||
*
|
||||
* Copyright (C) 2011-2012, 2015-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
@ -39,131 +39,20 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/boardctl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sched.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/nx/nx.h>
|
||||
|
||||
#ifdef CONFIG_NX_LCDDRIVER
|
||||
# include <nuttx/lcd/lcd.h>
|
||||
#else
|
||||
# include <nuttx/video/fb.h>
|
||||
#endif
|
||||
|
||||
#include "nxtext_internal.h"
|
||||
|
||||
#ifdef CONFIG_NX_MULTIUSER
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtext_server
|
||||
****************************************************************************/
|
||||
|
||||
int nxtext_server(int argc, char *argv[])
|
||||
{
|
||||
FAR NX_DRIVERTYPE *dev;
|
||||
int ret;
|
||||
|
||||
#if defined(CONFIG_EXAMPLES_NXTEXT_EXTERNINIT)
|
||||
struct boardioc_graphics_s devinfo;
|
||||
int ret;
|
||||
|
||||
/* Use external graphics driver initialization */
|
||||
|
||||
printf("nxtext_server: Initializing external graphics device\n");
|
||||
|
||||
devinfo.devno = CONFIG_EXAMPLES_NXTEXT_DEVNO;
|
||||
devinfo.dev = NULL;
|
||||
|
||||
ret = boardctl(BOARDIOC_GRAPHICS_SETUP, (uintptr_t)&devinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("nxtext_server: boardctl failed, devno=%d: %d\n",
|
||||
CONFIG_EXAMPLES_NXTEXT_DEVNO, errno);
|
||||
g_exitcode = NXEXIT_EXTINITIALIZE;
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
dev = devinfo.dev;
|
||||
|
||||
#elif defined(CONFIG_NX_LCDDRIVER)
|
||||
/* Initialize the LCD device */
|
||||
|
||||
printf("nxtext_server: Initializing LCD\n");
|
||||
ret = board_lcd_initialize();
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("nxtext_server: board_lcd_initialize failed: %d\n", -ret);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Get the device instance */
|
||||
|
||||
dev = board_lcd_getdev(CONFIG_EXAMPLES_NXTEXT_DEVNO);
|
||||
if (!dev)
|
||||
{
|
||||
printf("nxtext_server: board_lcd_getdev failed, devno=%d\n",
|
||||
CONFIG_EXAMPLES_NXTEXT_DEVNO);
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* Turn the LCD on at 75% power */
|
||||
|
||||
(void)dev->setpower(dev, ((3*CONFIG_LCD_MAXPOWER + 3)/4));
|
||||
#else
|
||||
/* Initialize the frame buffer device */
|
||||
|
||||
printf("nxtext_server: Initializing framebuffer\n");
|
||||
|
||||
ret = up_fbinitialize(0);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("nxtext_server: up_fbinitialize failed: %d\n", -ret);
|
||||
return 1;
|
||||
}
|
||||
|
||||
dev = up_fbgetvplane(0, CONFIG_EXAMPLES_NXTEXT_VPLANE);
|
||||
if (!dev)
|
||||
{
|
||||
printf("nxtext_server: up_fbgetvplane failed, vplane=%d\n",
|
||||
CONFIG_EXAMPLES_NXTEXT_VPLANE);
|
||||
return 2;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Then start the server */
|
||||
|
||||
ret = nx_run(dev);
|
||||
ginfo("nx_run returned: %d\n", errno);
|
||||
return 3;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtext_listener
|
||||
****************************************************************************/
|
@ -40,8 +40,8 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <sys/boardctl.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
@ -284,36 +284,19 @@ static inline int nxtext_muinitialize(void)
|
||||
{
|
||||
struct sched_param param;
|
||||
pthread_t thread;
|
||||
pid_t servrid;
|
||||
int ret;
|
||||
|
||||
/* Set the client task priority */
|
||||
/* Start the NX server kernel thread */
|
||||
|
||||
param.sched_priority = CONFIG_EXAMPLES_NXTEXT_CLIENTPRIO;
|
||||
ret = sched_setparam(0, ¶m);
|
||||
printf("nxtext_initialize: Starting NX server\n");
|
||||
ret = boardctl(BOARDIOC_NX_START, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("nxtext_initialize: sched_setparam failed: %d\n" , ret);
|
||||
g_exitcode = NXEXIT_SCHEDSETPARAM;
|
||||
printf("nxtext_initialize: Failed to start the NX server: %d\n", errno);
|
||||
g_exitcode = NXEXIT_SERVERSTART;
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/* Start the server task */
|
||||
|
||||
printf("nxtext_initialize: Starting nxtext_server task\n");
|
||||
servrid = task_create("NX Server", CONFIG_EXAMPLES_NXTEXT_SERVERPRIO,
|
||||
CONFIG_EXAMPLES_NXTEXT_STACKSIZE, nxtext_server, NULL);
|
||||
if (servrid < 0)
|
||||
{
|
||||
printf("nxtext_initialize: Failed to create nxtext_server task: %d\n", errno);
|
||||
g_exitcode = NXEXIT_TASKCREATE;
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/* Wait a bit to let the server get started */
|
||||
|
||||
sleep(1);
|
||||
|
||||
/* Connect to the server */
|
||||
|
||||
g_hnx = nx_connect();
|
||||
|
@ -69,8 +69,8 @@ MAINSRC = trv_main.c
|
||||
|
||||
ifeq ($(CONFIG_NX),y)
|
||||
CSRCS += trv_nxbkgd.c
|
||||
ifeq ($(CONFIG_NX),y)
|
||||
CSRCS += trv_nxserver.c
|
||||
ifeq ($(CONFIG_NX_MULTIUSER),y)
|
||||
CSRCS += trv_nxlistener.c
|
||||
endif
|
||||
endif
|
||||
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#ifdef CONFIG_NX_MULTIUSER
|
||||
# include <sys/boardctl.h>
|
||||
# include <semaphore.h>
|
||||
#endif
|
||||
|
||||
@ -224,27 +225,6 @@ static inline int trv_nxsu_initialize(FAR struct trv_graphics_info_s *ginfo)
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: trv_servertask
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NX_MULTIUSER
|
||||
int trv_servertask(int argc, char *argv[])
|
||||
{
|
||||
FAR struct fb_vtable_s *fbdev;
|
||||
int ret;
|
||||
|
||||
/* Get the framebuffer device */
|
||||
|
||||
fbdev = trv_get_fbdev();
|
||||
|
||||
/* Then start the server */
|
||||
|
||||
ret = nx_run(dev);
|
||||
trv_abort("nx_run returned: %d\n", errno);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: trv_nxmu_initialize
|
||||
****************************************************************************/
|
||||
@ -254,7 +234,6 @@ static inline int trv_nxmu_initialize(FAR struct trv_graphics_info_s *ginfo)
|
||||
{
|
||||
struct sched_param param;
|
||||
pthread_t thread;
|
||||
pid_t servrid;
|
||||
int ret;
|
||||
|
||||
/* Set the client task priority */
|
||||
@ -263,17 +242,16 @@ static inline int trv_nxmu_initialize(FAR struct trv_graphics_info_s *ginfo)
|
||||
ret = sched_setparam(0, ¶m);
|
||||
if (ret < 0)
|
||||
{
|
||||
trv_abort("nxeg_initialize: sched_setparam failed: %d\n" , ret);
|
||||
trv_abort("trv_nxmu_initialize: sched_setparam failed: %d\n" , ret);
|
||||
}
|
||||
|
||||
/* Start the server task */
|
||||
/* Start the NX server kernel thread */
|
||||
|
||||
printf("nxeg_initialize: Starting trv_servertask task\n");
|
||||
servrid = task_create("NX Server", CONFIG_EXAMPLES_NX_SERVERPRIO,
|
||||
CONFIG_EXAMPLES_NX_STACKSIZE, trv_servertask, NULL);
|
||||
if (servrid < 0)
|
||||
printf("trv_nxmu_initialize: Starting NX server\n");
|
||||
ret = boardctl(BOARDIOC_NX_START, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
trv_abort("nxeg_initialize: Failed to create trv_servertask task: %d\n",
|
||||
trv_abort("trv_nxmu_initialize: Failed to start the NX server: %d\n",
|
||||
errno);
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
/****************************************************************************
|
||||
* apps/graphics/traveler/trv_nxserver.c
|
||||
* NX server logic
|
||||
* apps/graphics/traveler/trv_nxlistener.c
|
||||
* NX listener logic
|
||||
*
|
||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -40,33 +40,14 @@
|
||||
|
||||
#include "trv_types.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sched.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/video/fb.h>
|
||||
|
||||
#ifdef CONFIG_NX_MULTIUSER
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
Loading…
Reference in New Issue
Block a user