summaryrefslogtreecommitdiff
path: root/nuttx/arch
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-10-06 16:31:13 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-10-06 16:31:13 +0000
commit25130d72c303524ed50e54fddbdf0bd1096f4149 (patch)
tree85d225a0e7776640d85a168d9e1213edda0261d2 /nuttx/arch
parentcd87146d9b80c85ad070dec888635c2ea6af0a9c (diff)
downloadpx4-nuttx-25130d72c303524ed50e54fddbdf0bd1096f4149.tar.gz
px4-nuttx-25130d72c303524ed50e54fddbdf0bd1096f4149.tar.bz2
px4-nuttx-25130d72c303524ed50e54fddbdf0bd1096f4149.zip
Add sim/nsh2 configuration
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4026 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch')
-rw-r--r--nuttx/arch/sim/src/up_idle.c23
-rw-r--r--nuttx/arch/sim/src/up_internal.h5
-rw-r--r--nuttx/arch/sim/src/up_x11framebuffer.c105
3 files changed, 77 insertions, 56 deletions
diff --git a/nuttx/arch/sim/src/up_idle.c b/nuttx/arch/sim/src/up_idle.c
index 70d25f1d6..d7397ba22 100644
--- a/nuttx/arch/sim/src/up_idle.c
+++ b/nuttx/arch/sim/src/up_idle.c
@@ -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
diff --git a/nuttx/arch/sim/src/up_internal.h b/nuttx/arch/sim/src/up_internal.h
index b0a365b4b..194191de0 100644
--- a/nuttx/arch/sim/src/up_internal.h
+++ b/nuttx/arch/sim/src/up_internal.h
@@ -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
diff --git a/nuttx/arch/sim/src/up_x11framebuffer.c b/nuttx/arch/sim/src/up_x11framebuffer.c
index 4d8c9b9a5..248156100 100644
--- a/nuttx/arch/sim/src/up_x11framebuffer.c
+++ b/nuttx/arch/sim/src/up_x11framebuffer.c
@@ -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");
-#ifndef CONFIG_SIM_X11NOSHM
- if (g_shmcheckpoint > 4)
+ if (g_x11initialized)
{
- XShmDetach(g_display, &g_xshminfo);
- }
+#ifndef CONFIG_SIM_X11NOSHM
+ 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,41 +369,47 @@ 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;
+ if (!g_x11initialized)
+ {
+ /* Save inputs */
- /* Create the X11 window */
+ g_fbpixelwidth = width;
+ g_fbpixelheight = height;
- ret = up_x11createframe();
- if (ret < 0)
- {
- return ret;
- }
+ /* Create the X11 window */
- /* Determine the supported pixel bpp of the current window */
+ ret = up_x11createframe();
+ if (ret < 0)
+ {
+ return ret;
+ }
- XGetWindowAttributes(g_display, DefaultRootWindow(g_display), &windowAttributes);
+ /* Determine the supported pixel bpp of the current window */
- /* Get the pixel depth. If the depth is 24-bits, use 32 because X expects
- * 32-bit aligment anyway.
- */
+ XGetWindowAttributes(g_display, DefaultRootWindow(g_display), &windowAttributes);
- depth = windowAttributes.depth;
- if (depth == 24)
- {
- depth = 32;
- }
- printf("Pixel bpp is %d bits (using %d)\n", windowAttributes.depth, depth);
+ /* Get the pixel depth. If the depth is 24-bits, use 32 because X expects
+ * 32-bit aligment anyway.
+ */
- *bpp = depth;
- *stride = (depth * width / 8);
- *fblen = (*stride * height);
+ depth = windowAttributes.depth;
+ if (depth == 24)
+ {
+ depth = 32;
+ }
+ printf("Pixel bpp is %d bits (using %d)\n", windowAttributes.depth, depth);
- /* Map the window to shared memory */
+ *bpp = depth;
+ *stride = (depth * width / 8);
+ *fblen = (*stride * height);
- up_x11mapsharedmem(windowAttributes.depth, *fblen);
+ /* Map the window to shared memory */
+
+ up_x11mapsharedmem(windowAttributes.depth, *fblen);
+ g_x11initialized = 1;
+ }
*fbmem = (void*)g_framebuffer;
return 0;