graphics/nxmu/nxmu_start.c: Extend nxmu_start so that receives a display number as an argument. This makes it possible to have multiple instances of the NX server running on boards that support multiple displays. Also includes updates to boardctl() to accept display number paramters.

This commit is contained in:
Gregory Nutt 2019-03-10 13:50:05 -06:00
parent f6b9fe5b14
commit aa4f7c9ba7
7 changed files with 67 additions and 37 deletions

View File

@ -12,7 +12,7 @@
<h1><big><font color="#3c34ec">
<i>NX Graphics Subsystem</i>
</font></big></h1>
<p>Last Updated: April 15, 2018</p>
<p>Last Updated: March 10, 2019</p>
</td>
</tr>
</table>
@ -956,7 +956,7 @@ struct nx_callback_s
<ul><pre>
#include &lt;nuttx/nx/nx.h&gt;
int nxmu_start(void);
int nxmu_start(int display, int plane);
</pre></ul>
<p>
<b>Description:</b>
@ -964,7 +964,12 @@ int nxmu_start(void);
</p>
<p>
<b>Input Parameters:</b>
None
<ul><dl>
<dt><code>display</code>
<dd>The display number to be served by this new NXMU instance.
<dt><code>plane</code>
<dd>The plane number to use to get information about the display geometry and color format.
</dl></ul>
</p>
<p>
<b>Returned Value:</b>

View File

@ -412,14 +412,20 @@ int boardctl(unsigned int cmd, uintptr_t arg)
#ifdef CONFIG_NX
/* CMD: BOARDIOC_NX_START
* DESCRIPTION: Start the NX servier
* ARG: None
* ARG: Integer display number to be served by this NXMU
( instance.
* CONFIGURATION: CONFIG_NX
* DEPENDENCIES: Base graphics logic provides nxmu_start()
*/
case BOARDIOC_NX_START:
{
ret = nxmu_start();
/* REVISIT: Plane number is forced to zero. On multiplanar
* displays there may be multiple planes. Only one is supported
* here.
*/
ret = nxmu_start((int)arg, 0);
}
break;
#endif

View File

@ -23,9 +23,19 @@ config NX_LCDDRIVER
this this option is provide to select, instead, the LCD driver interface
defined in include/nuttx/lcd/lcd.h.
config NX_NDISPLAYS
int "Maximum number of displays supported"
default 1
range 1 9
---help---
The maximum number of displays that can be supported by the NX server.
Normally this takes the value one but may be increased to support systems
with multiple displays.
config NX_NPLANES
int "Number of Color Planes"
default 1
range 1 8
---help---
Some YUV color formats requires support for multiple planes, one for
each color component. Unless you have such special hardware (and
@ -422,22 +432,6 @@ config NXSTART_DEVNO
---help---
LCD device number (in case there are more than one LCDs connected).
Default: 0
config NXSTART_DISPLAYNO
int "Display Number"
default 0
depends on !NX_LCDDRIVER && !NXSTART_EXTERNINIT
---help---
Framebuffer display number (in case there are more than one framebuffers).
Default: 0
config NXSTART_VPLANE
int "Plane Number"
default 0
depends on !NX_LCDDRIVER && !NXSTART_EXTERNINIT
---help---
Only a single video plane is supported. Default: 0
source "graphics/vnc/Kconfig"
endif # NX

View File

@ -42,6 +42,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <sched.h>
#include <errno.h>
#include <debug.h>
@ -58,7 +59,7 @@
* Private Data
****************************************************************************/
static bool g_nxserver_started;
static bool g_nxserver_started[CONFIG_NX_NDISPLAYS];
/****************************************************************************
* Private Functions
@ -83,15 +84,23 @@ static bool g_nxserver_started;
static int nx_server(int argc, char *argv[])
{
FAR NX_DRIVERTYPE *dev;
int display;
int plane;
int ret;
/* Get display parameters from the command line */
display = atoi(argv[1]);
plane = atoi(argv[2]);
#if defined(CONFIG_NXSTART_EXTERNINIT)
/* Use external graphics driver initialization */
dev = board_graphics_setup(CONFIG_NXSTART_DEVNO);
if (!dev)
{
gerr("ERROR: board_graphics_setup failed, devno=%d\n", CONFIG_NXSTART_DEVNO);
gerr("ERROR: board_graphics_setup failed, devno=%d\n",
CONFIG_NXSTART_DEVNO);
return EXIT_FAILURE;
}
@ -117,24 +126,24 @@ static int nx_server(int argc, char *argv[])
/* Turn the LCD on at 75% power */
(void)dev->setpower(dev, ((3*CONFIG_LCD_MAXPOWER + 3)/4));
(void)dev->setpower(dev, ((3 * CONFIG_LCD_MAXPOWER + 3) / 4));
#else /* CONFIG_NX_LCDDRIVER */
/* Initialize the frame buffer device.
* REVISIT: display == 0 is assumed.
*/
ret = up_fbinitialize(CONFIG_NXSTART_DISPLAYNO);
ret = up_fbinitialize(display);
if (ret < 0)
{
gerr("ERROR: up_fbinitialize failed: %d\n", ret);
return EXIT_FAILURE;
}
dev = up_fbgetvplane(CONFIG_NXSTART_DISPLAYNO, CONFIG_NXSTART_VPLANE);
dev = up_fbgetvplane(display, plane);
if (!dev)
{
gerr("ERROR: up_fbgetvplane failed, vplane=%d\n", CONFIG_NXSTART_VPLANE);
gerr("ERROR: up_fbgetvplane failed, vplane=%d\n", plane);
return EXIT_FAILURE;
}
@ -164,7 +173,8 @@ static int nx_server(int argc, char *argv[])
* boardctl() interface with the BOARDIOC_NX_START command.
*
* Input Parameters:
* None
* display - Display number served by this NXMU instance.
* plane - Plane number to use for display info
*
* Returned Value:
* Zero (OK) is returned on success. This indicates that the NX server
@ -176,19 +186,33 @@ static int nx_server(int argc, char *argv[])
*
****************************************************************************/
int nxmu_start(void)
int nxmu_start(int display, int plane)
{
DEBUGASSERT((unsigned)display < CONFIG_NX_NDISPLAYS &&
(unsigned)plane < CONFIG_NX_NPLANES);
/* Do nothing is the server has already been started */
if (!g_nxserver_started)
if (!g_nxserver_started[display])
{
FAR char display_str[8];
FAR char plane_str[8];
FAR char * const argv[3] =
{
(FAR char * const)display_str,
(FAR char * const)plane_str,
NULL
};
pid_t server;
/* Start the server kernel thread */
snprintf(display_str, 8, "%d", display);
snprintf(plane_str, 8, "%d", plane);
ginfo("Starting server task\n");
server = kthread_create("NX Server", CONFIG_NXSTART_SERVERPRIO,
CONFIG_NXSTART_SERVERSTACK, nx_server, NULL);
CONFIG_NXSTART_SERVERSTACK, nx_server, argv);
if (server < 0)
{
gerr("ERROR: Failed to create nx_server kernel thread: %d\n",
@ -196,7 +220,7 @@ int nxmu_start(void)
return (int)server;
}
g_nxserver_started = true;
g_nxserver_started[display] = true;
/* Wait a bit to make sure that the server get started. NOTE that
* this operation cannot be done from the IDLE thread!

View File

@ -480,7 +480,8 @@ extern "C"
* boardctl() interface with the BOARDIOC_NX_START command.
*
* Input Parameters:
* None
* display - Display number served by this NXMU instance.
* plane - Plane number to use for display info
*
* Returned Value:
* Zero (OK) is returned on success. This indicates that the NX server
@ -492,7 +493,7 @@ extern "C"
*
****************************************************************************/
int nxmu_start(void);
int nxmu_start(int display, int plane);
/****************************************************************************
* Name: nxfe_constructwindow

View File

@ -115,7 +115,7 @@
*
* CMD: BOARDIOC_NX_START
* DESCRIPTION: Start the NX server
* ARG: None
* ARG: Integer display number to be served by this NXMU instance.
* CONFIGURATION: CONFIG_NX
* DEPENDENCIES: Base graphics logic provides nxmu_start()
*

View File

@ -250,7 +250,7 @@ int main(int argc, char **argv, char **envp)
if (line[n] != '}' /* && line[n] != '#' */)
{
fprintf(stderr,
"Missing blank line after comment line. Found at line %d\n",
"Missing blank line after comment found at line %d\n",
comment_lineno);
}
}
@ -691,7 +691,7 @@ int main(int argc, char **argv, char **envp)
else if (line[n + 1] == '/')
{
fprintf(stderr, "C++ style comment on at %d:%d\n",
fprintf(stderr, "C++ style comment at %d:%d\n",
lineno, n);
n++;
continue;