You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ag...@apache.org on 2020/02/11 20:15:17 UTC

[incubator-nuttx] branch master updated (28d7061 -> 2ff43fb)

This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


    from 28d7061  boards: stm32f4discovery: Modify a default path to a romfs image because the stm32f4discovery directory has been moved from configs/ to boards/arm/stm32/
     new 14a82f4  arch/sim: Make eventloop as an internal variable to simplify up_idle.
     new e6c67bd  arch/sim: Drive up_x11update by work to simplify up_idle.
     new d5ea46c  boards/sim: Update README.txt to inform about the xhost command.
     new 2ff43fb  Run files modified by PR239 through nxstyle.

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 arch/sim/Kconfig                     |   2 +
 arch/sim/src/sim/up_ajoystick.c      |  22 ++++--
 arch/sim/src/sim/up_framebuffer.c    |  90 ++++++++++++++++-------
 arch/sim/src/sim/up_idle.c           |  51 ++-----------
 arch/sim/src/sim/up_internal.h       |  18 +----
 arch/sim/src/sim/up_touchscreen.c    |  54 ++++++++------
 arch/sim/src/sim/up_x11eventloop.c   |   6 +-
 arch/sim/src/sim/up_x11framebuffer.c | 137 +++++++++++++++++------------------
 boards/sim/sim/sim/README.txt        |   4 +
 9 files changed, 196 insertions(+), 188 deletions(-)


[incubator-nuttx] 04/04: Run files modified by PR239 through nxstyle.

Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 2ff43fb8a85708e06dfa36655d55766a0638491c
Author: Ouss4 <ab...@gmail.com>
AuthorDate: Tue Feb 11 21:05:55 2020 +0000

    Run files modified by PR239 through nxstyle.
---
 arch/sim/src/sim/up_ajoystick.c      | 12 +++++---
 arch/sim/src/sim/up_framebuffer.c    | 54 ++++++++++++++++++++++++------------
 arch/sim/src/sim/up_touchscreen.c    | 39 ++++++++++++++------------
 arch/sim/src/sim/up_x11framebuffer.c | 44 +++++++++++++++++------------
 4 files changed, 91 insertions(+), 58 deletions(-)

diff --git a/arch/sim/src/sim/up_ajoystick.c b/arch/sim/src/sim/up_ajoystick.c
index d6adee5..3b15244 100644
--- a/arch/sim/src/sim/up_ajoystick.c
+++ b/arch/sim/src/sim/up_ajoystick.c
@@ -61,10 +61,12 @@
  * Private Function Prototypes
  ****************************************************************************/
 
-static ajoy_buttonset_t ajoy_supported(FAR const struct ajoy_lowerhalf_s *lower);
+static ajoy_buttonset_t ajoy_supported(
+  FAR const struct ajoy_lowerhalf_s *lower);
 static int ajoy_sample(FAR const struct ajoy_lowerhalf_s *lower,
                        FAR struct ajoy_sample_s *sample);
-static ajoy_buttonset_t ajoy_buttons(FAR const struct ajoy_lowerhalf_s *lower);
+static ajoy_buttonset_t ajoy_buttons(
+  FAR const struct ajoy_lowerhalf_s *lower);
 static void ajoy_enable(FAR const struct ajoy_lowerhalf_s *lower,
                          ajoy_buttonset_t press, ajoy_buttonset_t release,
                          ajoy_handler_t handler, FAR void *arg);
@@ -107,7 +109,8 @@ static ajoy_buttonset_t g_ajoy_rset;       /* Set of releases waited for */
  *
  ****************************************************************************/
 
-static ajoy_buttonset_t ajoy_supported(FAR const struct ajoy_lowerhalf_s *lower)
+static ajoy_buttonset_t ajoy_supported(
+  FAR const struct ajoy_lowerhalf_s *lower)
 {
   return (ajoy_buttonset_t)AJOY_SUPPORTED;
 }
@@ -137,7 +140,8 @@ static int ajoy_sample(FAR const struct ajoy_lowerhalf_s *lower,
  *
  ****************************************************************************/
 
-static ajoy_buttonset_t ajoy_buttons(FAR const struct ajoy_lowerhalf_s *lower)
+static ajoy_buttonset_t ajoy_buttons(
+  FAR const struct ajoy_lowerhalf_s *lower)
 {
   g_ajoy_valid   = false;
   g_ajoy_buttons = g_ajoy_sample.as_buttons;
diff --git a/arch/sim/src/sim/up_framebuffer.c b/arch/sim/src/sim/up_framebuffer.c
index ab0ffac..b81185b 100644
--- a/arch/sim/src/sim/up_framebuffer.c
+++ b/arch/sim/src/sim/up_framebuffer.c
@@ -94,24 +94,34 @@
  * Private Function Prototypes
  ****************************************************************************/
 
-  /* Get information about the video controller configuration and the configuration
-   * of each color plane.
-   */
+/* Get information about the video controller configuration and the
+ * configuration of each color plane.
+ */
 
-static int up_getvideoinfo(FAR struct fb_vtable_s *vtable, FAR struct fb_videoinfo_s *vinfo);
-static int up_getplaneinfo(FAR struct fb_vtable_s *vtable, int planeno, FAR struct fb_planeinfo_s *pinfo);
+static int up_getvideoinfo(FAR struct fb_vtable_s *vtable,
+                           FAR struct fb_videoinfo_s *vinfo);
+static int up_getplaneinfo(FAR struct fb_vtable_s *vtable, int planeno,
+                           FAR struct fb_planeinfo_s *pinfo);
 
-  /* The following is provided only if the video hardware supports RGB color mapping */
+/* The following is provided only if the video hardware supports
+ * RGB color mapping.
+ */
 
 #ifdef CONFIG_FB_CMAP
-static int up_getcmap(FAR struct fb_vtable_s *vtable, FAR struct fb_cmap_s *cmap);
-static int up_putcmap(FAR struct fb_vtable_s *vtable, FAR const struct fb_cmap_s *cmap);
+static int up_getcmap(FAR struct fb_vtable_s *vtable,
+                      FAR struct fb_cmap_s *cmap);
+static int up_putcmap(FAR struct fb_vtable_s *vtable,
+                      FAR const struct fb_cmap_s *cmap);
 #endif
-  /* The following is provided only if the video hardware supports a hardware cursor */
+  /* The following is provided only if the video hardware supports
+   * a hardware cursor
+   */
 
 #ifdef CONFIG_FB_HWCURSOR
-static int up_getcursor(FAR struct fb_vtable_s *vtable, FAR struct fb_cursorattrib_s *attrib);
-static int up_setcursor(FAR struct fb_vtable_s *vtable, FAR struct fb_setcursor_s *setttings);
+static int up_getcursor(FAR struct fb_vtable_s *vtable,
+                        FAR struct fb_cursorattrib_s *attrib);
+static int up_setcursor(FAR struct fb_vtable_s *vtable,
+                        FAR struct fb_setcursor_s *setttings);
 #endif
 
 /****************************************************************************
@@ -165,8 +175,8 @@ static struct fb_cursorsize_s g_csize;
 #endif
 #endif
 
-/* The framebuffer object -- There is no private state information in this simple
- * framebuffer simulation.
+/* The framebuffer object -- There is no private state information
+ * in this simple framebuffer simulation.
  */
 
 struct fb_vtable_s g_fbobject =
@@ -228,7 +238,8 @@ static int up_getplaneinfo(FAR struct fb_vtable_s *vtable, int planeno,
  ****************************************************************************/
 
 #ifdef CONFIG_FB_CMAP
-static int up_getcmap(FAR struct fb_vtable_s *vtable, FAR struct fb_cmap_s *cmap)
+static int up_getcmap(FAR struct fb_vtable_s *vtable,
+                      FAR struct fb_cmap_s *cmap)
 {
   int len;
   int i;
@@ -260,10 +271,12 @@ static int up_getcmap(FAR struct fb_vtable_s *vtable, FAR struct fb_cmap_s *cmap
  ****************************************************************************/
 
 #ifdef CONFIG_FB_CMAP
-static int up_putcmap(FAR struct fb_vtable_s *vtable, FAR const struct fb_cmap_s *cmap)
+static int up_putcmap(FAR struct fb_vtable_s *vtable,
+                      FAR const struct fb_cmap_s *cmap)
 {
 #ifdef CONFIG_SIM_X11FB
-  return up_x11cmap(cmap->first, cmap->len, cmap->red, cmap->green, cmap->blue, NULL);
+  return up_x11cmap(cmap->first, cmap->len, cmap->red, cmap->green,
+                    cmap->blue, NULL);
 #else
   ginfo("vtable=%p cmap=%p len=%d\n", vtable, cmap, cmap->len);
   if (vtable && cmap)
@@ -324,6 +337,7 @@ static int up_setcursor(FAR struct fb_vtable_s *vtable,
           g_cpos = settings->pos;
           ginfo("pos:     (h:%d, w:%d)\n", g_cpos.x, g_cpos.y);
         }
+
 #ifdef CONFIG_FB_HWCURSORSIZE
       if ((flags & FB_CUR_SETSIZE) != 0)
         {
@@ -331,12 +345,15 @@ static int up_setcursor(FAR struct fb_vtable_s *vtable,
           ginfo("size:    (h:%d, w:%d)\n", g_csize.h, g_csize.w);
         }
 #endif
+
 #ifdef CONFIG_FB_HWCURSORIMAGE
       if ((flags & FB_CUR_SETIMAGE) != 0)
         {
           ginfo("image:   (h:%d, w:%d) @ %p\n",
-               settings->img.height, settings->img.width, settings->img.image);
+               settings->img.height, settings->img.width,
+               settings->img.image);
         }
+
 #endif
       return OK;
     }
@@ -400,7 +417,8 @@ int up_fbinitialize(int display)
  *
  * Description:
  *   Return a a reference to the framebuffer object for the specified video
- *   plane of the specified plane.  Many OSDs support multiple planes of video.
+ *   plane of the specified plane.  Many OSDs support multiple planes of
+ *   video.
  *
  * Input Parameters:
  *   display - In the case of hardware with multiple displays, this
diff --git a/arch/sim/src/sim/up_touchscreen.c b/arch/sim/src/sim/up_touchscreen.c
index f5703b4..39e1050 100644
--- a/arch/sim/src/sim/up_touchscreen.c
+++ b/arch/sim/src/sim/up_touchscreen.c
@@ -186,17 +186,17 @@ static void up_notify(FAR struct up_dev_s *priv)
   iinfo("contact=%d nwaiters=%d\n", priv->sample.contact, priv->nwaiters);
   if (priv->nwaiters > 0)
     {
-      /* After posting this semaphore, we need to exit because the touchscreen
-       * is no longer avaialable.
+      /* After posting this semaphore, we need to exit because
+       * the touchscreen is no longer avaialable.
        */
 
       nxsem_post(&priv->waitsem);
     }
 
-  /* If there are threads waiting on poll() for touchscreen data to become available,
-   * then wake them up now.  NOTE: we wake up all waiting threads because we
-   * do not know what they are going to do.  If they all try to read the data,
-   * then some make end up blocking after all.
+  /* If there are threads waiting on poll() for touchscreen data to become
+   * available, then wake them up now.  NOTE: we wake up all waiting threads
+   * because we do not know what they are going to do.  If they all try to
+   * read the data then some make end up blocking after all.
    */
 
   for (i = 0; i < CONFIG_SIM_TCNWAITERS; i++)
@@ -243,11 +243,11 @@ static int up_sample(FAR struct up_dev_s *priv,
           priv->id++;
         }
       else if (sample->contact == CONTACT_DOWN)
-       {
+        {
           /* First report -- next report will be a movement */
 
-         priv->sample.contact = CONTACT_MOVE;
-       }
+          priv->sample.contact = CONTACT_MOVE;
+        }
 
       priv->penchange = false;
       iinfo("penchange=%d contact=%d id=%d\n",
@@ -307,8 +307,8 @@ static int up_waitsample(FAR struct up_dev_s *priv,
         }
     }
 
-  /* Re-acquire the semaphore that manages mutually exclusive access to
-   * the device structure.  We may have to wait here.  But we have our sample.
+  /* Re-acquire the semaphore that manages mutually exclusive access to the
+   * device structure.  We may have to wait here.  But we have our sample.
    * Interrupts and pre-emption will be re-enabled while we wait.
    */
 
@@ -407,7 +407,7 @@ static ssize_t up_read(FAR struct file *filep, FAR char *buffer, size_t len)
         {
           ret = -EAGAIN;
           goto errout;
-       }
+        }
 
       /* Wait for sample data */
 
@@ -446,13 +446,15 @@ static ssize_t up_read(FAR struct file *filep, FAR char *buffer, size_t len)
     {
       /* First contact */
 
-      report->point[0].flags  = TOUCH_DOWN | TOUCH_ID_VALID | TOUCH_POS_VALID | TOUCH_PRESSURE_VALID;
+      report->point[0].flags  = TOUCH_DOWN | TOUCH_ID_VALID |
+                                TOUCH_POS_VALID | TOUCH_PRESSURE_VALID;
     }
   else /* if (sample->contact == CONTACT_MOVE) */
     {
       /* Movement of the same contact */
 
-      report->point[0].flags  = TOUCH_MOVE | TOUCH_ID_VALID | TOUCH_POS_VALID | TOUCH_PRESSURE_VALID;
+      report->point[0].flags  = TOUCH_MOVE | TOUCH_ID_VALID |
+                                TOUCH_POS_VALID | TOUCH_PRESSURE_VALID;
     }
 
   ret = SIZEOF_TOUCH_SAMPLE_S(1);
@@ -736,8 +738,9 @@ void up_buttonevent(int x, int y, int buttons)
 
   if (!pendown)
     {
-      /* Ignore the pend up if the pen was already up (CONTACT_NONE == pen up and
-       * already reported.  CONTACT_UP == pen up, but not reported)
+      /* Ignore the pend up if the pen was already up
+       * (CONTACT_NONE == pen up and  already reported.
+       *  CONTACT_UP == pen up, but not reported)
        */
 
       if (priv->sample.contact == CONTACT_NONE)
@@ -756,8 +759,8 @@ void up_buttonevent(int x, int y, int buttons)
       priv->sample.x = x;
       priv->sample.y = y;
 
-      /* Note the availability of new measurements */
-      /* If this is the first (acknowledged) pen down report, then report
+      /* Note the availability of new measurements:
+       * If this is the first (acknowledged) pen down report, then report
        * this as the first contact.  If contact == CONTACT_DOWN, it will be
        * set to set to CONTACT_MOVE after the contact is first sampled.
        */
diff --git a/arch/sim/src/sim/up_x11framebuffer.c b/arch/sim/src/sim/up_x11framebuffer.c
index 2cd767b..28f4c26 100644
--- a/arch/sim/src/sim/up_x11framebuffer.c
+++ b/arch/sim/src/sim/up_x11framebuffer.c
@@ -266,7 +266,8 @@ static inline int up_x11mapsharedmem(int depth, unsigned int fblen)
       printf("Using shared memory.\n");
 
       up_x11traperrors();
-      g_image = XShmCreateImage(g_display, DefaultVisual(g_display, g_screen),
+      g_image = XShmCreateImage(g_display,
+                                DefaultVisual(g_display, g_screen),
                                 depth, ZPixmap, NULL, &g_xshminfo,
                                 g_fbpixelwidth, g_fbpixelheight);
       if (up_x11untraperrors())
@@ -274,11 +275,13 @@ static inline int up_x11mapsharedmem(int depth, unsigned int fblen)
           up_x11uninitialize();
           goto shmerror;
         }
+
       if (!g_image)
         {
           fprintf(stderr, "Unable to create g_image.");
           return -1;
         }
+
       g_shmcheckpoint++;
 
       g_xshminfo.shmid = shmget(IPC_PRIVATE,
@@ -289,6 +292,7 @@ static inline int up_x11mapsharedmem(int depth, unsigned int fblen)
           up_x11uninitialize();
           goto shmerror;
         }
+
       g_shmcheckpoint++;
 
       g_image->data = (char *) shmat(g_xshminfo.shmid, 0, 0);
@@ -297,6 +301,7 @@ static inline int up_x11mapsharedmem(int depth, unsigned int fblen)
           up_x11uninitialize();
           goto shmerror;
         }
+
       g_shmcheckpoint++;
 
       g_xshminfo.shmaddr = g_image->data;
@@ -324,18 +329,20 @@ shmerror:
 
       g_framebuffer = (unsigned char *)malloc(fblen);
 
-      g_image = XCreateImage(g_display, DefaultVisual(g_display, g_screen), depth,
-                             ZPixmap, 0, (char *)g_framebuffer, g_fbpixelwidth, g_fbpixelheight,
+      g_image = XCreateImage(g_display, DefaultVisual(g_display, g_screen),
+                             depth, ZPixmap, 0, (char *)g_framebuffer,
+                             g_fbpixelwidth, g_fbpixelheight,
                              8, 0);
 
       if (g_image == NULL)
-         {
-            fprintf(stderr, "Unable to create g_image\n");
-            return -1;
-         }
+        {
+          fprintf(stderr, "Unable to create g_image\n");
+          return -1;
+        }
 
       g_shmcheckpoint++;
     }
+
   return 0;
 }
 
@@ -374,7 +381,8 @@ int up_x11initialize(unsigned short width, unsigned short height,
 
   /* Determine the supported pixel bpp of the current window */
 
-  XGetWindowAttributes(g_display, DefaultRootWindow(g_display), &windowAttributes);
+  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.
@@ -422,18 +430,18 @@ int up_x11cmap(unsigned short first, unsigned short len,
        * ranges from 0-255; for X11 the range is 0-65536
        */
 
-     color.red   = (short)(*red++) << 8;
-     color.green = (short)(*green++) << 8;
-     color.blue  = (short)(*blue++) << 8;
-     color.flags = DoRed | DoGreen | DoBlue;
+      color.red   = (short)(*red++) << 8;
+      color.green = (short)(*green++) << 8;
+      color.blue  = (short)(*blue++) << 8;
+      color.flags = DoRed | DoGreen | DoBlue;
 
-     /* Then allocate a color for this selection */
+      /* Then allocate a color for this selection */
 
-     if (!XAllocColor(g_display, cMap, &color))
-       {
-         fprintf(stderr, "Failed to allocate color%d\n", ndx);
-         return -1;
-       }
+      if (!XAllocColor(g_display, cMap, &color))
+        {
+          fprintf(stderr, "Failed to allocate color%d\n", ndx);
+          return -1;
+        }
     }
 
   return 0;


[incubator-nuttx] 01/04: arch/sim: Make eventloop as an internal variable to simplify up_idle.

Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 14a82f40d25e58e9d1ee7fbebdd5a9f4026779c9
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Feb 10 01:30:43 2020 +0800

    arch/sim: Make eventloop as an internal variable to simplify up_idle.
---
 arch/sim/src/sim/up_ajoystick.c    | 10 +++++++---
 arch/sim/src/sim/up_idle.c         | 15 ++++++---------
 arch/sim/src/sim/up_internal.h     | 13 +++----------
 arch/sim/src/sim/up_touchscreen.c  | 15 ++++++++++-----
 arch/sim/src/sim/up_x11eventloop.c |  6 ++----
 5 files changed, 28 insertions(+), 31 deletions(-)

diff --git a/arch/sim/src/sim/up_ajoystick.c b/arch/sim/src/sim/up_ajoystick.c
index cbbe74b..d6adee5 100644
--- a/arch/sim/src/sim/up_ajoystick.c
+++ b/arch/sim/src/sim/up_ajoystick.c
@@ -85,6 +85,7 @@ static const struct ajoy_lowerhalf_s g_ajoylower =
 
 /* Driver state data */
 
+static int g_eventloop;
 static bool g_ajoy_valid;                  /* True: Sample data is valid */
 static struct ajoy_sample_s g_ajoy_sample; /* Last sample data */
 static ajoy_buttonset_t g_ajoy_buttons;    /* Last buttons set */
@@ -196,12 +197,17 @@ int sim_ajoy_initialize(void)
  * Name: up_buttonevent
  ****************************************************************************/
 
-int up_buttonevent(int x, int y, int buttons)
+void up_buttonevent(int x, int y, int buttons)
 {
   ajoy_buttonset_t changed;
   ajoy_buttonset_t pressed;
   ajoy_buttonset_t released;
 
+  if (g_eventloop == 0)
+    {
+      return;
+    }
+
   /* Same the positional data */
 
   g_ajoy_sample.as_x = x;
@@ -248,6 +254,4 @@ int up_buttonevent(int x, int y, int buttons)
             }
         }
     }
-
-  return OK;
 }
diff --git a/arch/sim/src/sim/up_idle.c b/arch/sim/src/sim/up_idle.c
index 2b53cbf..a8d3862 100644
--- a/arch/sim/src/sim/up_idle.c
+++ b/arch/sim/src/sim/up_idle.c
@@ -107,6 +107,12 @@ void up_idle(void)
   up_devconloop();
 #endif
 
+#if defined(CONFIG_SIM_TOUCHSCREEN) || defined(CONFIG_SIM_AJOYSTICK)
+  /* Drive the X11 event loop */
+
+  up_x11events();
+#endif
+
 #if defined(CONFIG_NET_ETHERNET) && defined(CONFIG_SIM_NETDEV)
   /* Run the network if enabled */
 
@@ -148,15 +154,6 @@ void up_idle(void)
 #ifdef CONFIG_SIM_X11FB
   if (g_x11initialized)
     {
-#if defined(CONFIG_SIM_TOUCHSCREEN) || defined(CONFIG_SIM_AJOYSTICK)
-      /* Drive the X11 event loop */
-
-      if (g_eventloop)
-        {
-          up_x11events();
-        }
-#endif
-
       /* Update the display periodically */
 
       g_x11refresh += 1000000 / CLK_TCK;
diff --git a/arch/sim/src/sim/up_internal.h b/arch/sim/src/sim/up_internal.h
index 67b906a..b536c78 100644
--- a/arch/sim/src/sim/up_internal.h
+++ b/arch/sim/src/sim/up_internal.h
@@ -199,9 +199,6 @@
 
 #ifdef CONFIG_SIM_X11FB
 extern int g_x11initialized;
-#if defined(CONFIG_SIM_TOUCHSCREEN) || defined(CONFIG_SIM_AJOYSTICK)
-extern volatile int g_eventloop;
-#endif
 #endif
 
 #ifdef CONFIG_SMP
@@ -300,21 +297,17 @@ int up_x11cmap(unsigned short first, unsigned short len,
 
 /* up_touchscreen.c *********************************************************/
 
+#ifdef CONFIG_SIM_TOUCHSCREEN
 int  sim_tsc_initialize(int minor);
 void sim_tsc_uninitialize(void);
-
-/* up_eventloop.c ***********************************************************/
-
-#if defined(CONFIG_SIM_X11FB) && \
-   (defined(CONFIG_SIM_TOUCHSCREEN) || defined(CONFIG_SIM_AJOYSTICK))
-void up_x11events(void);
 #endif
 
 /* up_eventloop.c ***********************************************************/
 
 #if defined(CONFIG_SIM_X11FB) && \
    (defined(CONFIG_SIM_TOUCHSCREEN) || defined(CONFIG_SIM_AJOYSTICK))
-int up_buttonevent(int x, int y, int buttons);
+void up_x11events(void);
+void up_buttonevent(int x, int y, int buttons);
 #endif
 
 /* up_ajoystick.c ***********************************************************/
diff --git a/arch/sim/src/sim/up_touchscreen.c b/arch/sim/src/sim/up_touchscreen.c
index 7bf2628..f5703b4 100644
--- a/arch/sim/src/sim/up_touchscreen.c
+++ b/arch/sim/src/sim/up_touchscreen.c
@@ -108,6 +108,7 @@ struct up_sample_s
 
 struct up_dev_s
 {
+  int eventloop;
   volatile uint8_t nwaiters;           /* Number of threads waiting for touchscreen data */
   uint8_t id;                          /* Current touch point ID */
   uint8_t minor;                       /* Minor device number */
@@ -650,7 +651,7 @@ int sim_tsc_initialize(int minor)
 
   /* Enable X11 event processing from the IDLE loop */
 
-  g_eventloop = 1;
+  priv->eventloop = 1;
 
   /* And return success */
 
@@ -691,7 +692,7 @@ void sim_tsc_uninitialize(void)
    * done in close() using a reference count).
    */
 
-  g_eventloop = 0;
+  priv->eventloop = 0;
 
   /* Un-register the device */
 
@@ -714,11 +715,16 @@ void sim_tsc_uninitialize(void)
  * Name: up_buttonevent
  ****************************************************************************/
 
-int up_buttonevent(int x, int y, int buttons)
+void up_buttonevent(int x, int y, int buttons)
 {
   FAR struct up_dev_s *priv = (FAR struct up_dev_s *)&g_simtouchscreen;
   bool                 pendown;  /* true: pen is down */
 
+  if (priv->eventloop == 0)
+    {
+      return;
+    }
+
   iinfo("x=%d y=%d buttons=%02x\n", x, y, buttons);
   iinfo("contact=%d nwaiters=%d\n", priv->sample.contact, priv->nwaiters);
 
@@ -736,7 +742,7 @@ int up_buttonevent(int x, int y, int buttons)
 
       if (priv->sample.contact == CONTACT_NONE)
         {
-          return OK;
+          return;
         }
 
       /* Not yet reported */
@@ -772,5 +778,4 @@ int up_buttonevent(int x, int y, int buttons)
   /* Notify any waiters that new touchscreen data is available */
 
   up_notify(priv);
-  return OK;
 }
diff --git a/arch/sim/src/sim/up_x11eventloop.c b/arch/sim/src/sim/up_x11eventloop.c
index fea5b10..35d01ef 100644
--- a/arch/sim/src/sim/up_x11eventloop.c
+++ b/arch/sim/src/sim/up_x11eventloop.c
@@ -45,7 +45,7 @@
  * Public Function Prototypes
  ****************************************************************************/
 
-extern int up_buttonevent(int x, int y, int buttons);
+extern void up_buttonevent(int x, int y, int buttons);
 
 /****************************************************************************
  * Public Data
@@ -55,8 +55,6 @@ extern int up_buttonevent(int x, int y, int buttons);
 
 extern Display *g_display;
 
-volatile int g_eventloop;
-
 /****************************************************************************
  * Private Functions
  ****************************************************************************/
@@ -107,7 +105,7 @@ void up_x11events(void)
 
   /* Check if there are any pending, queue X11 events. */
 
-  if (XPending(g_display) > 0)
+  if (g_display && XPending(g_display) > 0)
     {
       /* Yes, get the event (this should not block since we know there are
        * pending events)


[incubator-nuttx] 03/04: boards/sim: Update README.txt to inform about the xhost command.

Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit d5ea46c6109fce9e1f8ed35d88a0092e717c8298
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Tue Feb 11 11:49:33 2020 +0800

    boards/sim: Update README.txt to inform about the xhost command.
---
 boards/sim/sim/sim/README.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/boards/sim/sim/sim/README.txt b/boards/sim/sim/sim/README.txt
index b2d45c8..cc0c287 100644
--- a/boards/sim/sim/sim/README.txt
+++ b/boards/sim/sim/sim/README.txt
@@ -220,6 +220,10 @@ it, XOpenDisplay() aborted the program.  UPDATE:  This was caused by the small
 stack size and can be fixed by increasing the size of the NuttX stack that
 calls into X11.  See the discussion "Stack Size Issues" above.
 
+Update: You may need issue this command with the latest Ubuntu before launch:
+
+  sudo xhost +
+
 Cygwin64 Issues
 ---------------
 There are some additional issues using the simulator with Cygwin64.  Below is


[incubator-nuttx] 02/04: arch/sim: Drive up_x11update by work to simplify up_idle.

Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit e6c67bdd788406da1da315607fe0e3a1c837ca84
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Feb 10 01:38:45 2020 +0800

    arch/sim: Drive up_x11update by work to simplify up_idle.
---
 arch/sim/Kconfig                     |  2 +
 arch/sim/src/sim/up_framebuffer.c    | 36 ++++++++++----
 arch/sim/src/sim/up_idle.c           | 36 +-------------
 arch/sim/src/sim/up_internal.h       |  5 +-
 arch/sim/src/sim/up_x11framebuffer.c | 95 ++++++++++++++++--------------------
 5 files changed, 74 insertions(+), 100 deletions(-)

diff --git a/arch/sim/Kconfig b/arch/sim/Kconfig
index 62c977a..f85c460 100644
--- a/arch/sim/Kconfig
+++ b/arch/sim/Kconfig
@@ -177,6 +177,8 @@ if SIM_FRAMEBUFFER
 config SIM_X11FB
 	bool "Use X11 window"
 	default n
+	select SCHED_LPWORK
+	select SIM_WALLTIME
 	---help---
 		Use an X11 graphics window to simulate the graphics device"
 
diff --git a/arch/sim/src/sim/up_framebuffer.c b/arch/sim/src/sim/up_framebuffer.c
index fbccf3f..ab0ffac 100644
--- a/arch/sim/src/sim/up_framebuffer.c
+++ b/arch/sim/src/sim/up_framebuffer.c
@@ -44,6 +44,8 @@
 #include <errno.h>
 #include <debug.h>
 
+#include <nuttx/clock.h>
+#include <nuttx/wqueue.h>
 #include <nuttx/nx/nx.h>
 #include <nuttx/nx/nxglib.h>
 #include <nuttx/video/fb.h>
@@ -144,6 +146,8 @@ static const struct fb_planeinfo_s g_planeinfo =
   .bpp      = CONFIG_SIM_FBBPP,
 };
 #else
+static struct work_s g_updatework;
+
 /* This structure describes the single, X11 color plane */
 
 static struct fb_planeinfo_s g_planeinfo;
@@ -180,10 +184,6 @@ struct fb_vtable_s g_fbobject =
 };
 
 /****************************************************************************
- * Public Data
- ****************************************************************************/
-
-/****************************************************************************
  * Private Functions
  ****************************************************************************/
 
@@ -347,6 +347,18 @@ static int up_setcursor(FAR struct fb_vtable_s *vtable,
 #endif
 
 /****************************************************************************
+ * Name: up_updatework
+ ****************************************************************************/
+
+#ifdef CONFIG_SIM_X11FB
+static void up_updatework(FAR void *arg)
+{
+  work_queue(LPWORK, &g_updatework, up_updatework, NULL, MSEC2TICK(33));
+  up_x11update();
+}
+#endif
+
+/****************************************************************************
  * Public Functions
  ****************************************************************************/
 
@@ -368,13 +380,19 @@ static int up_setcursor(FAR struct fb_vtable_s *vtable,
 
 int up_fbinitialize(int display)
 {
+  int ret = OK;
+
 #ifdef CONFIG_SIM_X11FB
-  return up_x11initialize(CONFIG_SIM_FBWIDTH, CONFIG_SIM_FBHEIGHT,
-                          &g_planeinfo.fbmem, &g_planeinfo.fblen,
-                          &g_planeinfo.bpp, &g_planeinfo.stride);
-#else
-  return OK;
+  ret = up_x11initialize(CONFIG_SIM_FBWIDTH, CONFIG_SIM_FBHEIGHT,
+                         &g_planeinfo.fbmem, &g_planeinfo.fblen,
+                         &g_planeinfo.bpp, &g_planeinfo.stride);
+  if (ret == OK)
+    {
+      work_queue(LPWORK, &g_updatework, up_updatework, NULL, MSEC2TICK(33));
+    }
 #endif
+
+  return ret;
 }
 
 /****************************************************************************
diff --git a/arch/sim/src/sim/up_idle.c b/arch/sim/src/sim/up_idle.c
index a8d3862..0aae79b 100644
--- a/arch/sim/src/sim/up_idle.c
+++ b/arch/sim/src/sim/up_idle.c
@@ -40,9 +40,8 @@
 
 #include <nuttx/config.h>
 
-#include <time.h>
-
 #include <nuttx/arch.h>
+#include <nuttx/power/pm.h>
 
 #include "up_internal.h"
 
@@ -53,22 +52,6 @@
 #define PM_IDLE_DOMAIN 0 /* Revisit */
 
 /****************************************************************************
- * Private Data
- ****************************************************************************/
-
-#ifdef CONFIG_SIM_X11FB
-static int g_x11refresh = 0;
-#endif
-
-/****************************************************************************
- * Public Function Prototypes
- ****************************************************************************/
-
-#ifdef CONFIG_SIM_X11FB
-extern void up_x11update(void);
-#endif
-
-/****************************************************************************
  * Public Functions
  ****************************************************************************/
 
@@ -142,26 +125,11 @@ void up_idle(void)
   }
 #endif
 
-#if defined(CONFIG_SIM_WALLTIME) || defined(CONFIG_SIM_X11FB)
+#ifdef CONFIG_SIM_WALLTIME
   /* Wait a bit so that the nxsched_process_timer() is called close to the
    * correct rate.
    */
 
   up_hostusleep(1000000 / CLK_TCK);
-
-  /* Handle X11-related events */
-
-#ifdef CONFIG_SIM_X11FB
-  if (g_x11initialized)
-    {
-      /* Update the display periodically */
-
-      g_x11refresh += 1000000 / CLK_TCK;
-      if (g_x11refresh > 500000)
-        {
-          up_x11update();
-        }
-    }
-#endif
 #endif
 }
diff --git a/arch/sim/src/sim/up_internal.h b/arch/sim/src/sim/up_internal.h
index b536c78..e0b2f91 100644
--- a/arch/sim/src/sim/up_internal.h
+++ b/arch/sim/src/sim/up_internal.h
@@ -197,10 +197,6 @@
 
 #ifndef __ASSEMBLY__
 
-#ifdef CONFIG_SIM_X11FB
-extern int g_x11initialized;
-#endif
-
 #ifdef CONFIG_SMP
 /* These spinlocks are used in the SMP configuration in order to implement
  * up_cpu_pause().  The protocol for CPUn to pause CPUm is as follows
@@ -288,6 +284,7 @@ unsigned long up_getwalltime(void);
 int up_x11initialize(unsigned short width, unsigned short height,
                      void **fbmem, size_t *fblen, unsigned char *bpp,
                      unsigned short *stride);
+void up_x11update(void);
 #ifdef CONFIG_FB_CMAP
 int up_x11cmap(unsigned short first, unsigned short len,
                unsigned char *red, unsigned char *green,
diff --git a/arch/sim/src/sim/up_x11framebuffer.c b/arch/sim/src/sim/up_x11framebuffer.c
index 8704a85..2cd767b 100644
--- a/arch/sim/src/sim/up_x11framebuffer.c
+++ b/arch/sim/src/sim/up_x11framebuffer.c
@@ -56,7 +56,6 @@
 /* Also used in up_x11eventloop */
 
 Display *g_display;
-int g_x11initialized;
 
 /****************************************************************************
  * Private Data
@@ -191,37 +190,33 @@ static int up_x11untraperrors(void)
 
 static void up_x11uninitX(void)
 {
-  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 */
 
 #if defined(CONFIG_SIM_TOUCHSCREEN) || defined(CONFIG_SIM_AJOYSTICK)
-      XUngrabButton(g_display, Button1, AnyModifier, g_window);
+  XUngrabButton(g_display, Button1, AnyModifier, g_window);
 #endif
-      g_x11initialized = 0;
-    }
 
   XCloseDisplay(g_display);
 }
@@ -364,46 +359,40 @@ int up_x11initialize(unsigned short width, unsigned short height,
   int depth;
   int ret;
 
-  /* Check if we are already initialized */
-
-  if (!g_x11initialized)
-    {
-      /* Save inputs */
+  /* Save inputs */
 
-      g_fbpixelwidth  = width;
-      g_fbpixelheight = height;
+  g_fbpixelwidth  = width;
+  g_fbpixelheight = height;
 
-      /* Create the X11 window */
+  /* Create the X11 window */
 
-      ret = up_x11createframe();
-      if (ret < 0)
-        {
-          return ret;
-        }
+  ret = up_x11createframe();
+  if (ret < 0)
+    {
+      return ret;
+    }
 
-      /* Determine the supported pixel bpp of the current window */
+  /* Determine the supported pixel bpp of the current window */
 
-      XGetWindowAttributes(g_display, DefaultRootWindow(g_display), &windowAttributes);
+  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.
-       */
+  /* 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;
-        }
+  depth = windowAttributes.depth;
+  if (depth == 24)
+    {
+      depth = 32;
+    }
 
-      *bpp    = depth;
-      *stride = (depth * width / 8);
-      *fblen  = (*stride * height);
+  *bpp    = depth;
+  *stride = (depth * width / 8);
+  *fblen  = (*stride * height);
 
-      /* Map the window to shared memory */
+  /* Map the window to shared memory */
 
-      up_x11mapsharedmem(windowAttributes.depth, *fblen);
-      g_x11initialized = 1;
-    }
+  up_x11mapsharedmem(windowAttributes.depth, *fblen);
 
   *fbmem  = (void *)g_framebuffer;
   return 0;