From 804061abdcb93cabe6f138bb321a41ab2cebe872 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 16 Apr 2015 07:39:00 -0600 Subject: [PATCH] Correct use of the BOARDIOC_GRAPHICS_SETUP boardctl() call --- examples/nx/nx_main.c | 16 +++++++++++++--- examples/nx/nx_server.c | 21 +++++++++++++++------ examples/nxhello/nxhello_main.c | 17 +++++++++++++---- examples/nximage/nximage_main.c | 17 +++++++++++++---- examples/nxlines/nxlines_main.c | 17 +++++++++++++---- examples/nxterm/nxterm_server.c | 19 ++++++++++++++----- examples/nxtext/nxtext_main.c | 18 ++++++++++++++---- examples/nxtext/nxtext_server.c | 18 ++++++++++++++---- 8 files changed, 109 insertions(+), 34 deletions(-) diff --git a/examples/nx/nx_main.c b/examples/nx/nx_main.c index e9d3eaa92..dbdd608fa 100644 --- a/examples/nx/nx_main.c +++ b/examples/nx/nx_main.c @@ -427,17 +427,27 @@ static inline int nxeg_suinitialize(void) FAR NX_DRIVERTYPE *dev; #if defined(CONFIG_EXAMPLES_NX_EXTERNINIT) + struct boardioc_graphics_s devinfo; + int ret; + /* Use external graphics driver initialization */ printf("nxeg_initialize: Initializing external graphics device\n"); - dev = boardctl(BOARDIOC_GRAPHICS_SETUP, CONFIG_EXAMPLES_NX_DEVNO); - if (!dev) + + devinfo.devno = CONFIG_EXAMPLES_NX_DEVNO; + devinfo.dev = NULL; + + ret = boardctl(BOARDIOC_GRAPHICS_SETUP, (uintptr_t)&devinfo); + if (ret < 0) { - printf("nxeg_initialize: boardctl failed, devno=%d\n", CONFIG_EXAMPLES_NX_DEVNO); + printf("nxeg_initialize: 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) int ret; diff --git a/examples/nx/nx_server.c b/examples/nx/nx_server.c index fbb9a1b92..b13eb6d54 100644 --- a/examples/nx/nx_server.c +++ b/examples/nx/nx_server.c @@ -63,7 +63,7 @@ #ifdef CONFIG_NX_MULTIUSER /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -92,18 +92,27 @@ int nx_servertask(int argc, char *argv[]) int ret; #if defined(CONFIG_EXAMPLES_NX_EXTERNINIT) + struct boardioc_graphics_s devinfo; + int ret; + /* Use external graphics driver initialization */ - printf("nxeg_initialize: Initializing external graphics device\n"); - dev = boardctl(BOARDIOC_GRAPHICS_SETUP, CONFIG_EXAMPLES_NX_DEVNO); - if (!dev) + 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("nxeg_initialize: boardctl failed, devno=%d\n", - CONFIG_EXAMPLES_NX_DEVNO); + 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 */ diff --git a/examples/nxhello/nxhello_main.c b/examples/nxhello/nxhello_main.c index 61b2b5393..2082d71b0 100644 --- a/examples/nxhello/nxhello_main.c +++ b/examples/nxhello/nxhello_main.c @@ -126,18 +126,27 @@ static inline int nxhello_initialize(void) FAR NX_DRIVERTYPE *dev; #if defined(CONFIG_EXAMPLES_NXHELLO_EXTERNINIT) + struct boardioc_graphics_s devinfo; + int ret; + /* Use external graphics driver initialization */ printf("nxhello_initialize: Initializing external graphics device\n"); - dev = boardctl(BOARDIOC_GRAPHICS_SETUP, CONFIG_EXAMPLES_NXHELLO_DEVNO); - if (!dev) + + devinfo.devno = CONFIG_EXAMPLES_NXHELLO_DEVNO; + devinfo.dev = NULL; + + ret = boardctl(BOARDIOC_GRAPHICS_SETUP, (uintptr_t)&devinfo); + if (ret < 0) { - printf("nxhello_initialize: boardctl failed, devno=%d\n", - CONFIG_EXAMPLES_NXHELLO_DEVNO); + printf("nxhello_initialize: boardctl failed, devno=%d: %d\n", + CONFIG_EXAMPLES_NXHELLO_DEVNO, errno); g_nxhello.code = NXEXIT_EXTINITIALIZE; return ERROR; } + dev = devinfo.dev; + #elif defined(CONFIG_NX_LCDDRIVER) int ret; diff --git a/examples/nximage/nximage_main.c b/examples/nximage/nximage_main.c index 9bf6112b8..9d84b64ba 100644 --- a/examples/nximage/nximage_main.c +++ b/examples/nximage/nximage_main.c @@ -130,18 +130,27 @@ static inline int nximage_initialize(void) FAR NX_DRIVERTYPE *dev; #if defined(CONFIG_EXAMPLES_NXIMAGE_EXTERNINIT) + struct boardioc_graphics_s devinfo; + int ret; + /* Use external graphics driver initialization */ printf("nximage_initialize: Initializing external graphics device\n"); - dev = boardctl(BOARDIOC_GRAPHICS_SETUP, CONFIG_EXAMPLES_NXIMAGE_DEVNO); - if (!dev) + + devinfo.devno = CONFIG_EXAMPLES_NXIMAGE_DEVNO; + devinfo.dev = NULL; + + ret = boardctl(BOARDIOC_GRAPHICS_SETUP, (uintptr_t)&devinfo); + if (ret < 0) { - printf("nximage_initialize: boardctl failed, devno=%d\n", - CONFIG_EXAMPLES_NXIMAGE_DEVNO); + printf("nximage_initialize: boardctl failed, devno=%d: %d\n", + CONFIG_EXAMPLES_NXIMAGE_DEVNO, errno); g_nximage.code = NXEXIT_EXTINITIALIZE; return ERROR; } + dev = devinfo.dev; + #elif defined(CONFIG_NX_LCDDRIVER) int ret; diff --git a/examples/nxlines/nxlines_main.c b/examples/nxlines/nxlines_main.c index 08d2573e8..eb4a26b13 100644 --- a/examples/nxlines/nxlines_main.c +++ b/examples/nxlines/nxlines_main.c @@ -122,18 +122,27 @@ static inline int nxlines_initialize(void) FAR NX_DRIVERTYPE *dev; #if defined(CONFIG_EXAMPLES_NXLINES_EXTERNINIT) + struct boardioc_graphics_s devinfo; + int ret; + /* Use external graphics driver initialization */ printf("nxlines_initialize: Initializing external graphics device\n"); - dev = boardctl(BOARDIOC_GRAPHICS_SETUP, CONFIG_EXAMPLES_NXLINES_DEVNO); - if (!dev) + + devinfo.devno = CONFIG_EXAMPLES_NXLINES_DEVNO; + devinfo.dev = NULL; + + ret = boardctl(BOARDIOC_GRAPHICS_SETUP, (uintptr_t)&devinfo); + if (ret < 0) { - printf("nxlines_initialize: boardctl failed, devno=%d\n", - CONFIG_EXAMPLES_NXLINES_DEVNO); + printf("nxlines_initialize: boardctl failed, devno=%d: %d\n", + CONFIG_EXAMPLES_NXLINES_DEVNO, errno); g_nxlines.code = NXEXIT_EXTINITIALIZE; return ERROR; } + dev = devinfo.dev; + #elif defined(CONFIG_NX_LCDDRIVER) int ret; diff --git a/examples/nxterm/nxterm_server.c b/examples/nxterm/nxterm_server.c index c52f73c79..1be10e17b 100644 --- a/examples/nxterm/nxterm_server.c +++ b/examples/nxterm/nxterm_server.c @@ -60,7 +60,7 @@ #include "nxterm_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -89,17 +89,26 @@ int nxterm_server(int argc, char *argv[]) int ret; #if defined(CONFIG_EXAMPLES_NXCON_EXTERNINIT) + struct boardioc_graphics_s devinfo; + int ret; + /* Use external graphics driver initialization */ printf("nxterm_server: Initializing external graphics device\n"); - dev = boardctl(BOARDIOC_GRAPHICS_SETUP, CONFIG_EXAMPLES_NXCON_DEVNO); - if (!dev) + + devinfo.devno = CONFIG_EXAMPLES_NXCON_DEVNO; + devinfo.dev = NULL; + + ret = boardctl(BOARDIOC_GRAPHICS_SETUP, (uintptr_t)&devinfo); + if (ret < 0) { - printf("nxterm_server: boardctl failed, devno=%d\n", - CONFIG_EXAMPLES_NXCON_DEVNO); + printf("nxterm_server: boardctl failed, devno=%d: %d\n", + CONFIG_EXAMPLES_NXCON_DEVNO, errno); return ERROR; } + dev = devinfo.dev; + #elif defined(CONFIG_NX_LCDDRIVER) /* Initialize the LCD device */ diff --git a/examples/nxtext/nxtext_main.c b/examples/nxtext/nxtext_main.c index ed00fc04d..209941fd3 100644 --- a/examples/nxtext/nxtext_main.c +++ b/examples/nxtext/nxtext_main.c @@ -41,6 +41,7 @@ #include +#include #include #include #include @@ -167,18 +168,27 @@ static inline int nxtext_suinitialize(void) FAR NX_DRIVERTYPE *dev; #if defined(CONFIG_EXAMPLES_NXTEXT_EXTERNINIT) + struct boardioc_graphics_s devinfo; + int ret; + /* Use external graphics driver initialization */ printf("nxtext_initialize: Initializing external graphics device\n"); - dev = boardctl(BOARDIOC_GRAPHICS_SETUP, CONFIG_EXAMPLES_NXTEXT_DEVNO); - if (!dev) + + devinfo.devno = CONFIG_EXAMPLES_NXTEXT_DEVNO; + devinfo.dev = NULL; + + ret = boardctl(BOARDIOC_GRAPHICS_SETUP, (uintptr_t)&devinfo); + if (ret < 0) { - printf("nxtext_initialize: boardctl failed, devno=%d\n", - CONFIG_EXAMPLES_NXTEXT_DEVNO); + printf("nxtext_initialize: 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) int ret; diff --git a/examples/nxtext/nxtext_server.c b/examples/nxtext/nxtext_server.c index 844c800bf..813d56ed1 100644 --- a/examples/nxtext/nxtext_server.c +++ b/examples/nxtext/nxtext_server.c @@ -39,6 +39,7 @@ #include +#include #include #include #include @@ -90,18 +91,27 @@ int nxtext_server(int argc, char *argv[]) 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"); - dev = boardctl(BOARDIOC_GRAPHICS_SETUP, CONFIG_EXAMPLES_NXTEXT_DEVNO); - if (!dev) + + 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\n", - CONFIG_EXAMPLES_NXTEXT_DEVNO); + 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 */