Add sim/nsh2 configuration

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4026 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2011-10-06 16:31:13 +00:00
parent d6cfe71a23
commit 4f1e0c062d
3 changed files with 84 additions and 63 deletions

View File

@ -134,19 +134,24 @@ void up_idle(void)
/* Handle X11-related events */
#ifdef CONFIG_SIM_X11FB
#ifdef CONFIG_SIM_TOUCHSCREEN
if (g_eventloop)
if (g_x11initialized)
{
up_x11events();
}
/* Driver the X11 event loop */
#ifdef CONFIG_SIM_TOUCHSCREEN
if (g_eventloop)
{
up_x11events();
}
#endif
/* Update the display periodically */
/* Update the display periodically */
g_x11refresh += 1000000 / CLK_TCK;
if (g_x11refresh > 500000)
{
up_x11update();
g_x11refresh += 1000000 / CLK_TCK;
if (g_x11refresh > 500000)
{
up_x11update();
}
}
#endif
#endif

View File

@ -116,9 +116,12 @@
#ifndef __ASSEMBLY__
#if defined(CONFIG_SIM_X11FB) && defined(CONFIG_SIM_TOUCHSCREEN)
#ifdef CONFIG_SIM_X11FB
extern int g_x11initialized;
#ifdef CONFIG_SIM_TOUCHSCREEN
extern volatile int g_eventloop;
#endif
#endif
/**************************************************************************
* Public Function Prototypes

View File

@ -70,6 +70,7 @@
/* Also used in up_x11eventloop */
Display *g_display;
int g_x11initialized;
/****************************************************************************
* Private Variables
@ -112,9 +113,9 @@ static inline int up_x11createframe(void)
g_screen = DefaultScreen(g_display);
g_window = XCreateSimpleWindow(g_display, DefaultRootWindow(g_display),
0, 0, g_fbpixelwidth, g_fbpixelheight, 2,
BlackPixel(g_display, g_screen),
BlackPixel(g_display, g_screen));
0, 0, g_fbpixelwidth, g_fbpixelheight, 2,
BlackPixel(g_display, g_screen),
BlackPixel(g_display, g_screen));
XStringListToTextProperty(&winName, 1, &winprop);
XStringListToTextProperty(&iconName, 1, &iconprop);
@ -147,6 +148,7 @@ static inline int up_x11createframe(void)
gcval.graphics_exposures = 0;
g_gc = XCreateGC(g_display, g_window, GCGraphicsExposures, &gcval);
return 0;
}
@ -194,33 +196,38 @@ static int up_x11untraperrors(void)
static void up_x11uninitX(void)
{
fprintf(stderr, "Uninitalizing X\n");
if (g_x11initialized)
{
#ifndef CONFIG_SIM_X11NOSHM
if (g_shmcheckpoint > 4)
{
XShmDetach(g_display, &g_xshminfo);
}
if (g_shmcheckpoint > 4)
{
XShmDetach(g_display, &g_xshminfo);
}
if (g_shmcheckpoint > 3)
{
shmdt(g_xshminfo.shmaddr);
}
if (g_shmcheckpoint > 3)
{
shmdt(g_xshminfo.shmaddr);
}
if (g_shmcheckpoint > 2)
{
shmctl(g_xshminfo.shmid, IPC_RMID, 0);
}
if (g_shmcheckpoint > 2)
{
shmctl(g_xshminfo.shmid, IPC_RMID, 0);
}
#endif
if (g_shmcheckpoint > 1)
{
XDestroyImage(g_image);
}
if (g_shmcheckpoint > 1)
{
XDestroyImage(g_image);
}
/* Un-grab the mouse buttons */
/* Un-grab the mouse buttons */
#ifdef CONFIG_SIM_TOUCHSCREEN
XUngrabButton(g_display, Button1, AnyModifier, g_window);
XUngrabButton(g_display, Button1, AnyModifier, g_window);
#endif
g_x11initialized = 0;
}
XCloseDisplay(g_display);
}
@ -362,42 +369,48 @@ int up_x11initialize(unsigned short width, unsigned short height,
int depth;
int ret;
/* Save inputs */
/* Check if we are already initialized */
g_fbpixelwidth = width;
g_fbpixelheight = height;
/* Create the X11 window */
ret = up_x11createframe();
if (ret < 0)
if (!g_x11initialized)
{
return ret;
/* Save inputs */
g_fbpixelwidth = width;
g_fbpixelheight = height;
/* Create the X11 window */
ret = up_x11createframe();
if (ret < 0)
{
return ret;
}
/* Determine the supported pixel bpp of the current window */
XGetWindowAttributes(g_display, DefaultRootWindow(g_display), &windowAttributes);
/* Get the pixel depth. If the depth is 24-bits, use 32 because X expects
* 32-bit aligment anyway.
*/
depth = windowAttributes.depth;
if (depth == 24)
{
depth = 32;
}
printf("Pixel bpp is %d bits (using %d)\n", windowAttributes.depth, depth);
*bpp = depth;
*stride = (depth * width / 8);
*fblen = (*stride * height);
/* Map the window to shared memory */
up_x11mapsharedmem(windowAttributes.depth, *fblen);
g_x11initialized = 1;
}
/* Determine the supported pixel bpp of the current window */
XGetWindowAttributes(g_display, DefaultRootWindow(g_display), &windowAttributes);
/* Get the pixel depth. If the depth is 24-bits, use 32 because X expects
* 32-bit aligment anyway.
*/
depth = windowAttributes.depth;
if (depth == 24)
{
depth = 32;
}
printf("Pixel bpp is %d bits (using %d)\n", windowAttributes.depth, depth);
*bpp = depth;
*stride = (depth * width / 8);
*fblen = (*stride * height);
/* Map the window to shared memory */
up_x11mapsharedmem(windowAttributes.depth, *fblen);
*fbmem = (void*)g_framebuffer;
return 0;
}