You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2023/01/29 20:34:42 UTC

[nuttx] branch master updated (e02a5a70eb -> 0443889124)

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

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


    from e02a5a70eb fs/partiton: add sanity check
     new 9e39600c83 arch: fix sim_x11events calls but sim_x11initialize() hasn't ready
     new 0443889124 sim_framebuffer: fix fb_pollnotify not called

The 2 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/src/sim/posix/sim_x11framebuffer.c | 86 ++++++++++++++++++-----------
 arch/sim/src/sim/sim_framebuffer.c          | 14 ++---
 arch/sim/src/sim/sim_internal.h             |  2 +-
 arch/sim/src/sim/sim_lcd.c                  | 15 ++---
 4 files changed, 67 insertions(+), 50 deletions(-)


[nuttx] 02/02: sim_framebuffer: fix fb_pollnotify not called

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

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

commit 04438891246900af0593a9f80699dd73f54b0ac7
Author: pengyiqiang <pe...@xiaomi.com>
AuthorDate: Thu Dec 22 12:36:36 2022 +0800

    sim_framebuffer: fix fb_pollnotify not called
    
    Signed-off-by: pengyiqiang <pe...@xiaomi.com>
---
 arch/sim/src/sim/sim_framebuffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sim/src/sim/sim_framebuffer.c b/arch/sim/src/sim/sim_framebuffer.c
index 8de52036a8..b0609acc4e 100644
--- a/arch/sim/src/sim/sim_framebuffer.c
+++ b/arch/sim/src/sim/sim_framebuffer.c
@@ -348,7 +348,7 @@ void sim_x11loop(void)
 
   if (now - last >= MSEC2TICK(16))
     {
-      if (sim_x11update() > 0)
+      if (sim_x11update() >= 0)
         {
           fb_pollnotify(&g_fbobject);
         }


[nuttx] 01/02: arch: fix sim_x11events calls but sim_x11initialize() hasn't ready

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

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

commit 9e39600c8301af8b6fdb2fe5ee49faa353e88fca
Author: ligd <li...@xiaomi.com>
AuthorDate: Wed Dec 21 17:55:48 2022 +0800

    arch: fix sim_x11events calls but sim_x11initialize() hasn't ready
    
    Signed-off-by: ligd <li...@xiaomi.com>
---
 arch/sim/src/sim/posix/sim_x11framebuffer.c | 86 ++++++++++++++++++-----------
 arch/sim/src/sim/sim_framebuffer.c          | 14 ++---
 arch/sim/src/sim/sim_internal.h             |  2 +-
 arch/sim/src/sim/sim_lcd.c                  | 15 ++---
 4 files changed, 67 insertions(+), 50 deletions(-)

diff --git a/arch/sim/src/sim/posix/sim_x11framebuffer.c b/arch/sim/src/sim/posix/sim_x11framebuffer.c
index 47d6290f31..dd63e10d0b 100644
--- a/arch/sim/src/sim/posix/sim_x11framebuffer.c
+++ b/arch/sim/src/sim/posix/sim_x11framebuffer.c
@@ -68,8 +68,9 @@ static int b_useshm;
  * Name: sim_x11createframe
  ****************************************************************************/
 
-static inline int sim_x11createframe(void)
+static inline Display *sim_x11createframe(void)
 {
+  Display *display;
   XGCValues gcval;
   char *argv[2] =
     {
@@ -82,18 +83,18 @@ static inline int sim_x11createframe(void)
   XTextProperty iconprop;
   XSizeHints hints;
 
-  g_display = XOpenDisplay(NULL);
-  if (g_display == NULL)
+  display = XOpenDisplay(NULL);
+  if (display == NULL)
     {
       syslog(LOG_ERR, "Unable to open display.\n");
-      return -1;
+      return NULL;
     }
 
-  g_screen = DefaultScreen(g_display);
-  g_window = XCreateSimpleWindow(g_display, DefaultRootWindow(g_display),
+  g_screen = DefaultScreen(display);
+  g_window = XCreateSimpleWindow(display, DefaultRootWindow(display),
                                  0, 0, g_fbpixelwidth, g_fbpixelheight, 2,
-                                 BlackPixel(g_display, g_screen),
-                                 BlackPixel(g_display, g_screen));
+                                 BlackPixel(display, g_screen),
+                                 BlackPixel(display, g_screen));
 
   XStringListToTextProperty(&winname, 1, &winprop);
   XStringListToTextProperty(&iconname, 1, &iconprop);
@@ -102,18 +103,18 @@ static inline int sim_x11createframe(void)
   hints.width  = hints.min_width  = hints.max_width  = g_fbpixelwidth;
   hints.height = hints.min_height = hints.max_height = g_fbpixelheight;
 
-  XSetWMProperties(g_display, g_window, &winprop, &iconprop, argv, 1,
+  XSetWMProperties(display, g_window, &winprop, &iconprop, argv, 1,
                    &hints, NULL, NULL);
 
-  XMapWindow(g_display, g_window);
+  XMapWindow(display, g_window);
 
   /* Select window input events */
 
 #if defined(CONFIG_SIM_AJOYSTICK)
-  XSelectInput(g_display, g_window,
+  XSelectInput(display, g_window,
                ButtonPressMask | ButtonReleaseMask | PointerMotionMask);
 #else
-  XSelectInput(g_display, g_window,
+  XSelectInput(display, g_window,
                ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
                KeyPressMask | KeyReleaseMask);
 #endif
@@ -122,19 +123,19 @@ static inline int sim_x11createframe(void)
 
 #if defined(CONFIG_SIM_TOUCHSCREEN) || defined(CONFIG_SIM_AJOYSTICK) || \
     defined(CONFIG_SIM_BUTTONS)
-  XAllowEvents(g_display, AsyncBoth, CurrentTime);
+  XAllowEvents(display, AsyncBoth, CurrentTime);
 
   /* Grab mouse button 1, enabling mouse-related events */
 
-  XGrabButton(g_display, Button1, AnyModifier, g_window, 1,
+  XGrabButton(display, Button1, AnyModifier, g_window, 1,
               ButtonPressMask | ButtonReleaseMask | ButtonMotionMask,
               GrabModeAsync, GrabModeAsync, None, None);
 #endif
 
   gcval.graphics_exposures = 0;
-  g_gc = XCreateGC(g_display, g_window, GCGraphicsExposures, &gcval);
+  g_gc = XCreateGC(display, g_window, GCGraphicsExposures, &gcval);
 
-  return 0;
+  return display;
 }
 
 /****************************************************************************
@@ -166,9 +167,9 @@ static void sim_x11traperrors(void)
  ****************************************************************************/
 
 #ifndef CONFIG_SIM_X11NOSHM
-static int sim_x11untraperrors(void)
+static int sim_x11untraperrors(Display *display)
 {
-  XSync(g_display, 0);
+  XSync(display, 0);
   XSetErrorHandler(NULL);
   return g_xerror;
 }
@@ -180,6 +181,11 @@ static int sim_x11untraperrors(void)
 
 static void sim_x11uninit(void)
 {
+  if (g_display == NULL)
+    {
+      return;
+    }
+
 #ifndef CONFIG_SIM_X11NOSHM
   if (g_shmcheckpoint > 4)
     {
@@ -239,7 +245,8 @@ static void sim_x11uninitialize(void)
  * Name: sim_x11mapsharedmem
  ****************************************************************************/
 
-static inline int sim_x11mapsharedmem(int depth, unsigned int fblen)
+static inline int sim_x11mapsharedmem(Display *display,
+                                      int depth, unsigned int fblen)
 {
 #ifndef CONFIG_SIM_X11NOSHM
   Status result;
@@ -250,16 +257,16 @@ static inline int sim_x11mapsharedmem(int depth, unsigned int fblen)
   b_useshm = 0;
 
 #ifndef CONFIG_SIM_X11NOSHM
-  if (XShmQueryExtension(g_display))
+  if (XShmQueryExtension(display))
     {
       b_useshm = 1;
 
       sim_x11traperrors();
-      g_image = XShmCreateImage(g_display,
-                                DefaultVisual(g_display, g_screen),
+      g_image = XShmCreateImage(display,
+                                DefaultVisual(display, g_screen),
                                 depth, ZPixmap, NULL, &g_xshminfo,
                                 g_fbpixelwidth, g_fbpixelheight);
-      if (sim_x11untraperrors())
+      if (sim_x11untraperrors(display))
         {
           sim_x11uninitialize();
           goto shmerror;
@@ -297,8 +304,8 @@ static inline int sim_x11mapsharedmem(int depth, unsigned int fblen)
       g_xshminfo.readOnly = 0;
 
       sim_x11traperrors();
-      result = XShmAttach(g_display, &g_xshminfo);
-      if (sim_x11untraperrors() || !result)
+      result = XShmAttach(display, &g_xshminfo);
+      if (sim_x11untraperrors(display) || !result)
         {
           sim_x11uninitialize();
           goto shmerror;
@@ -318,7 +325,7 @@ shmerror:
 
       g_framebuffer = (unsigned char *)malloc(fblen);
 
-      g_image = XCreateImage(g_display, DefaultVisual(g_display, g_screen),
+      g_image = XCreateImage(display, DefaultVisual(display, g_screen),
                              depth, ZPixmap, 0, (char *)g_framebuffer,
                              g_fbpixelwidth, g_fbpixelheight,
                              8, 0);
@@ -352,8 +359,8 @@ int sim_x11initialize(unsigned short width, unsigned short height,
                      unsigned short *stride)
 {
   XWindowAttributes windowattributes;
+  Display *display;
   int depth;
-  int ret;
 
   /* Save inputs */
 
@@ -362,15 +369,15 @@ int sim_x11initialize(unsigned short width, unsigned short height,
 
   /* Create the X11 window */
 
-  ret = sim_x11createframe();
-  if (ret < 0)
+  display = sim_x11createframe();
+  if (display == NULL)
     {
-      return ret;
+      return -1;
     }
 
   /* Determine the supported pixel bpp of the current window */
 
-  XGetWindowAttributes(g_display, DefaultRootWindow(g_display),
+  XGetWindowAttributes(display, DefaultRootWindow(display),
                        &windowattributes);
 
   /* Get the pixel depth.  If the depth is 24-bits, use 32 because X expects
@@ -389,9 +396,10 @@ int sim_x11initialize(unsigned short width, unsigned short height,
 
   /* Map the window to shared memory */
 
-  sim_x11mapsharedmem(windowattributes.depth, *fblen);
+  sim_x11mapsharedmem(display, windowattributes.depth, *fblen);
 
   *fbmem  = (void *)g_framebuffer;
+  g_display = display;
   return 0;
 }
 
@@ -406,6 +414,11 @@ int sim_x11cmap(unsigned short first, unsigned short len,
   Colormap cmap;
   int ndx;
 
+  if (g_display == NULL)
+    {
+      return -1;
+    }
+
   /* Convert each color to X11 scaling */
 
   cmap = DefaultColormap(g_display, g_screen);
@@ -438,8 +451,13 @@ int sim_x11cmap(unsigned short first, unsigned short len,
  * Name: sim_x11update
  ****************************************************************************/
 
-void sim_x11update(void)
+int sim_x11update(void)
 {
+  if (g_display == NULL)
+    {
+      return -1;
+    }
+
 #ifndef CONFIG_SIM_X11NOSHM
   if (b_useshm)
     {
@@ -454,4 +472,6 @@ void sim_x11update(void)
     }
 
   XSync(g_display, 0);
+
+  return 0;
 }
diff --git a/arch/sim/src/sim/sim_framebuffer.c b/arch/sim/src/sim/sim_framebuffer.c
index 276c0a0e6b..8de52036a8 100644
--- a/arch/sim/src/sim/sim_framebuffer.c
+++ b/arch/sim/src/sim/sim_framebuffer.c
@@ -343,17 +343,17 @@ static int sim_setcursor(struct fb_vtable_s *vtable,
 void sim_x11loop(void)
 {
 #ifdef CONFIG_SIM_X11FB
-  if (g_planeinfo.fbmem != NULL)
-    {
-      static clock_t last;
-      clock_t now = clock_systime_ticks();
+  static clock_t last;
+  clock_t now = clock_systime_ticks();
 
-      if (now - last >= MSEC2TICK(16))
+  if (now - last >= MSEC2TICK(16))
+    {
+      if (sim_x11update() > 0)
         {
-          sim_x11update();
           fb_pollnotify(&g_fbobject);
-          last = now;
         }
+
+      last = now;
     }
 #endif
 }
diff --git a/arch/sim/src/sim/sim_internal.h b/arch/sim/src/sim/sim_internal.h
index 13d7ec07a4..e676e8f1eb 100644
--- a/arch/sim/src/sim/sim_internal.h
+++ b/arch/sim/src/sim/sim_internal.h
@@ -232,7 +232,7 @@ void sim_registerblockdevice(void);
 int sim_x11initialize(unsigned short width, unsigned short height,
                       void **fbmem, size_t *fblen, unsigned char *bpp,
                       unsigned short *stride);
-void sim_x11update(void);
+int sim_x11update(void);
 #ifdef CONFIG_FB_CMAP
 int sim_x11cmap(unsigned short first, unsigned short len,
                 unsigned char *red, unsigned char *green,
diff --git a/arch/sim/src/sim/sim_lcd.c b/arch/sim/src/sim/sim_lcd.c
index b20193f44f..81bddbed3b 100644
--- a/arch/sim/src/sim/sim_lcd.c
+++ b/arch/sim/src/sim/sim_lcd.c
@@ -433,16 +433,13 @@ static int sim_setcontrast(struct lcd_dev_s *dev, unsigned int contrast)
 void sim_x11loop(void)
 {
 #ifdef CONFIG_SIM_X11FB
-  if (g_planeinfo.buffer != NULL)
-    {
-      static clock_t last;
-      clock_t now = clock_systime_ticks();
+  static clock_t last;
+  clock_t now = clock_systime_ticks();
 
-      if (now - last >= MSEC2TICK(16))
-        {
-          sim_x11update();
-          last = now;
-        }
+  if (now - last >= MSEC2TICK(16))
+    {
+      sim_x11update();
+      last = now;
     }
 #endif
 }