From b76ec96bfbe3413a228cfe00cbd1ac7b73b29b1b 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 --- libnxwidgets/src/cnxserver.cxx | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/libnxwidgets/src/cnxserver.cxx b/libnxwidgets/src/cnxserver.cxx index 3ac00e7fb..19b87a043 100644 --- a/libnxwidgets/src/cnxserver.cxx +++ b/libnxwidgets/src/cnxserver.cxx @@ -127,15 +127,25 @@ CNxServer::~CNxServer(void) bool CNxServer::connect(void) { #if defined(CONFIG_NXWIDGETS_EXTERNINIT) + struct boardioc_graphics_s devinfo; + int ret; + // Use external graphics driver initialization - m_hDevice = boardctl(BOARDIOC_GRAPHICS_SETUP, CONFIG_NXWIDGETS_DEVNO); - if (!m_hDevice) + printf("nxtext_initialize: Initializing external graphics device\n"); + + devinfo.devno = CONFIG_NXWIDGETS_DEVNO; + devinfo.dev = NULL; + + ret = boardctl(BOARDIOC_GRAPHICS_SETUP, (uintptr_t)&devinfo); + if (ret < 0) { - gdbg("boardctl failed, devno=%d\n", CONFIG_NXWIDGETS_DEVNO); + gdbg("boardctl failed, devno=%d: %d\n", CONFIG_NXWIDGETS_DEVNO, errno); return false; } + m_hDevice = devinfo.dev; + #elif defined(CONFIG_NX_LCDDRIVER) int ret; @@ -359,15 +369,25 @@ int CNxServer::server(int argc, char *argv[]) int ret; #if defined(CONFIG_NXWIDGETS_EXTERNINIT) + struct boardioc_graphics_s devinfo; + int ret; + // Use external graphics driver initialization - dev = boardctl(BOARDIOC_GRAPHICS_SETUP, CONFIG_NXWIDGETS_DEVNO); - if (!dev) + printf("nxtext_initialize: Initializing external graphics device\n"); + + devinfo.devno = CONFIG_NXWIDGETS_DEVNO; + devinfo.dev = NULL; + + ret = boardctl(BOARDIOC_GRAPHICS_SETUP, (uintptr_t)&devinfo); + if (ret < 0) { - gdbg("boardctl failed, devno=%d\n", CONFIG_NXWIDGETS_DEVNO); + gdbg("boardctl failed, devno=%d: %d\n", CONFIG_NXWIDGETS_DEVNO, errno); return EXIT_FAILURE; } + dev = devinfo.dev; + #elif defined(CONFIG_NX_LCDDRIVER) // Initialize the LCD device