You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "liamHowatt (via GitHub)" <gi...@apache.org> on 2024/11/08 12:17:01 UTC

[PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

liamHowatt opened a new pull request, #14701:
URL: https://github.com/apache/nuttx/pull/14701

   cc @XuNeo @FASTSHIFT
   
   ## Summary
   
   Make the esp32s3 LCD FB device support double buffering. Leverage the FB `pandisplay` callback for users to achieve [double buffering in applications such as LVGL](https://github.com/lvgl/lvgl/blob/f89ac3677e6666449835d765d182f5515770c984/src/drivers/nuttx/lv_nuttx_fbdev.c#L275-L288). Use DMA interrupt to facilitate vsync.
   
   ## Impact
   
   I would like feedback on how this change should be managed. I made it so that the feature will be active if there is 1 LCD layer. The impact is that double the memory will be allocated compared to before this change, which could cause users to have insufficient memory after upgrading. Should it be a Kconfig option?
   
   ## Testing
   
   Mainboard: ESP32-S3-LCD-EV-Board-MB_V1.5
   LCD Subboard: ESP32-S3-LCD-EV-Board-SUB2_V1.5
   
   config: `esp32s3-lcd-ev:lvgl`
   
   For the specific board model:
   ```
   kconfig-tweak --set-val CONFIG_ESP32S3_I2C0_SCLPIN 48
   kconfig-tweak --set-val CONFIG_ESP32S3_I2C0_SDAPIN 47
   kconfig-tweak --set-val CONFIG_ESP32S3_LCD_DATA6_PIN 8
   kconfig-tweak --set-val CONFIG_ESP32S3_LCD_DATA7_PIN 18
   yes '' | make oldconfig
   ```
   
   LVGL will [detect the effect of the changes](https://github.com/lvgl/lvgl/blob/f89ac3677e6666449835d765d182f5515770c984/src/drivers/nuttx/lv_nuttx_fbdev.c#L145-L154) in the PR and double buffering will take effect without any other changes.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "liamHowatt (via GitHub)" <gi...@apache.org>.
liamHowatt commented on code in PR #14701:
URL: https://github.com/apache/nuttx/pull/14701#discussion_r1845492088


##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -548,7 +564,31 @@ static int esp32s3_lcd_base_updatearea(struct fb_vtable_s *vtable,
   struct esp32s3_lcd_s *priv = &g_lcd_priv;
 
   cache_writeback_addr(CURRENT_LAYER(priv)->framebuffer,
-                       ESP32S3_LCD_FB_SIZE);
+                       ESP32S3_LCD_FB_ALLOC_SIZE);
+
+  return 0;
+}
+#endif
+
+#if ESP32S3_LCD_DBLBUFFERED
+static int esp32s3_lcd_base_pandisplay(FAR struct fb_vtable_s *vtable,
+                                       FAR struct fb_planeinfo_s *pinfo)
+{
+  struct esp32s3_lcd_s *priv = &g_lcd_priv;
+  struct esp32s3_layer_s *layer = &priv->layer[0];
+  uint8_t *fb_panned = &layer->framebuffer[pinfo->yoffset * ESP32S3_LCD_STRIDE];

Review Comment:
   > It is recommended to add an access out of bounds judgment to `pinfo->yoffset`, and print a reminder when the user passes an error parameter.
   
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "liamHowatt (via GitHub)" <gi...@apache.org>.
liamHowatt commented on code in PR #14701:
URL: https://github.com/apache/nuttx/pull/14701#discussion_r1845487848


##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -623,6 +663,8 @@ static int IRAM_ATTR lcd_interrupt(int irq, void *context, void *arg)
       regval  = esp32s3_lcd_getreg(LCD_CAM_LCD_USER_REG);
       regval |= LCD_CAM_LCD_START_M;
       esp32s3_lcd_putreg(LCD_CAM_LCD_USER_REG, regval);
+
+      fb_remove_paninfo(&g_base_vtable, FB_NO_OVERLAY);

Review Comment:
   Take a look what I did in my latest changes. It's similar to the other users of this function.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #14701:
URL: https://github.com/apache/nuttx/pull/14701#discussion_r1836618030


##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -300,13 +310,16 @@ static const struct fb_videoinfo_s g_base_videoinfo =
 
 /* This structure provides the base layer interface */
 
-static const struct fb_vtable_s g_base_vtable =
+static struct fb_vtable_s g_base_vtable =

Review Comment:
   Ok, let's keep as it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "liamHowatt (via GitHub)" <gi...@apache.org>.
liamHowatt commented on code in PR #14701:
URL: https://github.com/apache/nuttx/pull/14701#discussion_r1847618176


##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -545,10 +569,66 @@ static int esp32s3_lcd_base_getplaneinfo(struct fb_vtable_s *vtable,
 static int esp32s3_lcd_base_updatearea(struct fb_vtable_s *vtable,
                                        const struct fb_area_s *area)
 {
+  if (area->w == 0 || area->h == 0)
+    {
+      return 0;
+    }
+
+  if (area->x + area->w > ESP32S3_LCD_HRES_VIRTUAL ||
+      area->y + area->h > ESP32S3_LCD_VRES_VIRTUAL)
+    {
+      gerr("ERROR: updatearea area is out of bounds. "
+           "x: %" PRIu16 ", y: %" PRIu16 ", w: %" PRIu16 ", h: %" PRIu16 ", "
+           "virtual hres: %d, virtual vres: %d\n",
+           area->x, area->y, area->w, area->h,
+           ESP32S3_LCD_HRES_VIRTUAL, ESP32S3_LCD_VRES_VIRTUAL);
+      return -EINVAL;
+    }
+
   struct esp32s3_lcd_s *priv = &g_lcd_priv;
 
-  cache_writeback_addr(CURRENT_LAYER(priv)->framebuffer,
-                       ESP32S3_LCD_FB_SIZE);
+  uint8_t *first_pixel = CURRENT_LAYER(priv)->framebuffer +
+                         (area->y * ESP32S3_LCD_STRIDE +
+                          area->x * ESP32S3_LCD_DATA_WIDTH);
+
+  uint32_t size = (area->h - 1) * ESP32S3_LCD_STRIDE +

Review Comment:
   Thanks. Is there anything else I can improve to make it conform to c89 spec?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "FASTSHIFT (via GitHub)" <gi...@apache.org>.
FASTSHIFT commented on code in PR #14701:
URL: https://github.com/apache/nuttx/pull/14701#discussion_r1845815662


##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -545,10 +569,59 @@ static int esp32s3_lcd_base_getplaneinfo(struct fb_vtable_s *vtable,
 static int esp32s3_lcd_base_updatearea(struct fb_vtable_s *vtable,
                                        const struct fb_area_s *area)
 {
+  if (area->w == 0 || area->h == 0)
+    {
+      return 0;
+    }
+
+  if (area->x + area->w > ESP32S3_LCD_HRES_VIRTUAL ||
+      area->y + area->h > ESP32S3_LCD_VRES_VIRTUAL)
+    {
+      gerr("ERROR: updatearea area is out of bounds\n");
+      return -EINVAL;
+    }
+
   struct esp32s3_lcd_s *priv = &g_lcd_priv;
 
-  cache_writeback_addr(CURRENT_LAYER(priv)->framebuffer,
-                       ESP32S3_LCD_FB_SIZE);
+  uint8_t *first_pixel = CURRENT_LAYER(priv)->framebuffer +
+                         (area->y * ESP32S3_LCD_STRIDE +
+                          area->x * ESP32S3_LCD_DATA_WIDTH);
+
+  uint32_t size = (area->h - 1) * ESP32S3_LCD_STRIDE +
+                  area->w       * ESP32S3_LCD_DATA_WIDTH;
+
+  cache_writeback_addr(first_pixel, size);
+
+  return 0;
+}
+#endif
+
+/****************************************************************************
+ * Name: esp32s3_lcd_base_pandisplay
+ *
+ * Description:
+ *   Validate the pan info. The pan info is queued by the framebuffer
+ *   subsystem.
+ *
+ * Input Parameters:
+ *   vtable - The framebuffer driver object
+ *   pinfo  - the planeinfo object
+ *
+ * Returned Value:
+ *   Zero is returned on success; a negated errno value is returned on any
+ *   failure.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ESP32S3_LCD_DOUBLE_BUFFERED
+static int esp32s3_lcd_base_pandisplay(FAR struct fb_vtable_s *vtable,
+                                       FAR struct fb_planeinfo_s *pinfo)
+{
+  if (pinfo->yoffset > ESP32S3_LCD_VRES_VIRTUAL - CONFIG_ESP32S3_LCD_VRES)
+    {
+      gerr("ERROR: pandisplay yoffset out of bounds\n");

Review Comment:
   print `pinfo->yoffset` value



##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -545,10 +569,59 @@ static int esp32s3_lcd_base_getplaneinfo(struct fb_vtable_s *vtable,
 static int esp32s3_lcd_base_updatearea(struct fb_vtable_s *vtable,
                                        const struct fb_area_s *area)
 {
+  if (area->w == 0 || area->h == 0)
+    {
+      return 0;
+    }
+
+  if (area->x + area->w > ESP32S3_LCD_HRES_VIRTUAL ||
+      area->y + area->h > ESP32S3_LCD_VRES_VIRTUAL)
+    {
+      gerr("ERROR: updatearea area is out of bounds\n");

Review Comment:
   print area info



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #14701:
URL: https://github.com/apache/nuttx/pull/14701#discussion_r1845931261


##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -545,10 +569,66 @@ static int esp32s3_lcd_base_getplaneinfo(struct fb_vtable_s *vtable,
 static int esp32s3_lcd_base_updatearea(struct fb_vtable_s *vtable,
                                        const struct fb_area_s *area)
 {
+  if (area->w == 0 || area->h == 0)
+    {
+      return 0;
+    }
+
+  if (area->x + area->w > ESP32S3_LCD_HRES_VIRTUAL ||
+      area->y + area->h > ESP32S3_LCD_VRES_VIRTUAL)
+    {
+      gerr("ERROR: updatearea area is out of bounds. "
+           "x: %" PRIu16 ", y: %" PRIu16 ", w: %" PRIu16 ", h: %" PRIu16 ", "
+           "virtual hres: %d, virtual vres: %d\n",
+           area->x, area->y, area->w, area->h,
+           ESP32S3_LCD_HRES_VIRTUAL, ESP32S3_LCD_VRES_VIRTUAL);
+      return -EINVAL;
+    }
+
   struct esp32s3_lcd_s *priv = &g_lcd_priv;
 
-  cache_writeback_addr(CURRENT_LAYER(priv)->framebuffer,
-                       ESP32S3_LCD_FB_SIZE);
+  uint8_t *first_pixel = CURRENT_LAYER(priv)->framebuffer +
+                         (area->y * ESP32S3_LCD_STRIDE +
+                          area->x * ESP32S3_LCD_DATA_WIDTH);
+
+  uint32_t size = (area->h - 1) * ESP32S3_LCD_STRIDE +

Review Comment:
   size and first_pixel need at the begin of function too to confirm c89 spec



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "FASTSHIFT (via GitHub)" <gi...@apache.org>.
FASTSHIFT commented on code in PR #14701:
URL: https://github.com/apache/nuttx/pull/14701#discussion_r1834531099


##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -548,7 +564,31 @@ static int esp32s3_lcd_base_updatearea(struct fb_vtable_s *vtable,
   struct esp32s3_lcd_s *priv = &g_lcd_priv;
 
   cache_writeback_addr(CURRENT_LAYER(priv)->framebuffer,
-                       ESP32S3_LCD_FB_SIZE);
+                       ESP32S3_LCD_FB_ALLOC_SIZE);
+
+  return 0;
+}
+#endif
+
+#if ESP32S3_LCD_DBLBUFFERED
+static int esp32s3_lcd_base_pandisplay(FAR struct fb_vtable_s *vtable,
+                                       FAR struct fb_planeinfo_s *pinfo)
+{
+  struct esp32s3_lcd_s *priv = &g_lcd_priv;
+  struct esp32s3_layer_s *layer = &priv->layer[0];
+  uint8_t *fb_panned = &layer->framebuffer[pinfo->yoffset * ESP32S3_LCD_STRIDE];
+
+  up_disable_irq(ESP32S3_IRQ_LCD_CAM);
+
+  esp32s3_dma_wait_idle(priv->dma_channel, true);
+
+  esp32s3_dma_setup(layer->dmadesc,

Review Comment:
   Does `esp32s3_dma_setup` have a buffer length limit with a single transfer?



##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -548,7 +564,31 @@ static int esp32s3_lcd_base_updatearea(struct fb_vtable_s *vtable,
   struct esp32s3_lcd_s *priv = &g_lcd_priv;
 
   cache_writeback_addr(CURRENT_LAYER(priv)->framebuffer,
-                       ESP32S3_LCD_FB_SIZE);
+                       ESP32S3_LCD_FB_ALLOC_SIZE);
+
+  return 0;
+}
+#endif
+
+#if ESP32S3_LCD_DBLBUFFERED
+static int esp32s3_lcd_base_pandisplay(FAR struct fb_vtable_s *vtable,
+                                       FAR struct fb_planeinfo_s *pinfo)
+{
+  struct esp32s3_lcd_s *priv = &g_lcd_priv;
+  struct esp32s3_layer_s *layer = &priv->layer[0];
+  uint8_t *fb_panned = &layer->framebuffer[pinfo->yoffset * ESP32S3_LCD_STRIDE];

Review Comment:
   Use script `nuttx/tools/checkpatch.sh -f <FILE>` to check the format of the code.



##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -548,7 +564,31 @@ static int esp32s3_lcd_base_updatearea(struct fb_vtable_s *vtable,
   struct esp32s3_lcd_s *priv = &g_lcd_priv;
 
   cache_writeback_addr(CURRENT_LAYER(priv)->framebuffer,
-                       ESP32S3_LCD_FB_SIZE);
+                       ESP32S3_LCD_FB_ALLOC_SIZE);
+
+  return 0;
+}
+#endif
+
+#if ESP32S3_LCD_DBLBUFFERED
+static int esp32s3_lcd_base_pandisplay(FAR struct fb_vtable_s *vtable,
+                                       FAR struct fb_planeinfo_s *pinfo)
+{
+  struct esp32s3_lcd_s *priv = &g_lcd_priv;
+  struct esp32s3_layer_s *layer = &priv->layer[0];
+  uint8_t *fb_panned = &layer->framebuffer[pinfo->yoffset * ESP32S3_LCD_STRIDE];
+
+  up_disable_irq(ESP32S3_IRQ_LCD_CAM);
+
+  esp32s3_dma_wait_idle(priv->dma_channel, true);
+
+  esp32s3_dma_setup(layer->dmadesc,

Review Comment:
   Added a return value check that the transmission failed to return an error code.



##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -548,7 +564,31 @@ static int esp32s3_lcd_base_updatearea(struct fb_vtable_s *vtable,
   struct esp32s3_lcd_s *priv = &g_lcd_priv;
 
   cache_writeback_addr(CURRENT_LAYER(priv)->framebuffer,
-                       ESP32S3_LCD_FB_SIZE);
+                       ESP32S3_LCD_FB_ALLOC_SIZE);
+
+  return 0;
+}
+#endif
+
+#if ESP32S3_LCD_DBLBUFFERED
+static int esp32s3_lcd_base_pandisplay(FAR struct fb_vtable_s *vtable,
+                                       FAR struct fb_planeinfo_s *pinfo)
+{
+  struct esp32s3_lcd_s *priv = &g_lcd_priv;
+  struct esp32s3_layer_s *layer = &priv->layer[0];
+  uint8_t *fb_panned = &layer->framebuffer[pinfo->yoffset * ESP32S3_LCD_STRIDE];

Review Comment:
   It is recommended to add an access offset judgment to `pinfo->yoffset`, and print a reminder when the user passes an error parameter.



##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -623,6 +663,8 @@ static int IRAM_ATTR lcd_interrupt(int irq, void *context, void *arg)
       regval  = esp32s3_lcd_getreg(LCD_CAM_LCD_USER_REG);
       regval |= LCD_CAM_LCD_START_M;
       esp32s3_lcd_putreg(LCD_CAM_LCD_USER_REG, regval);
+
+      fb_remove_paninfo(&g_base_vtable, FB_NO_OVERLAY);

Review Comment:
   Add a return value check.



##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -548,7 +564,31 @@ static int esp32s3_lcd_base_updatearea(struct fb_vtable_s *vtable,
   struct esp32s3_lcd_s *priv = &g_lcd_priv;
 
   cache_writeback_addr(CURRENT_LAYER(priv)->framebuffer,
-                       ESP32S3_LCD_FB_SIZE);
+                       ESP32S3_LCD_FB_ALLOC_SIZE);
+
+  return 0;
+}
+#endif
+
+#if ESP32S3_LCD_DBLBUFFERED
+static int esp32s3_lcd_base_pandisplay(FAR struct fb_vtable_s *vtable,
+                                       FAR struct fb_planeinfo_s *pinfo)
+{
+  struct esp32s3_lcd_s *priv = &g_lcd_priv;

Review Comment:
   For pointer types, you need to add the `FAR` keyword:
   ```c
   FAR struct esp32s3_lcd_s *priv = &g_lcd_priv;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "liamHowatt (via GitHub)" <gi...@apache.org>.
liamHowatt commented on code in PR #14701:
URL: https://github.com/apache/nuttx/pull/14701#discussion_r1847618176


##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -545,10 +569,66 @@ static int esp32s3_lcd_base_getplaneinfo(struct fb_vtable_s *vtable,
 static int esp32s3_lcd_base_updatearea(struct fb_vtable_s *vtable,
                                        const struct fb_area_s *area)
 {
+  if (area->w == 0 || area->h == 0)
+    {
+      return 0;
+    }
+
+  if (area->x + area->w > ESP32S3_LCD_HRES_VIRTUAL ||
+      area->y + area->h > ESP32S3_LCD_VRES_VIRTUAL)
+    {
+      gerr("ERROR: updatearea area is out of bounds. "
+           "x: %" PRIu16 ", y: %" PRIu16 ", w: %" PRIu16 ", h: %" PRIu16 ", "
+           "virtual hres: %d, virtual vres: %d\n",
+           area->x, area->y, area->w, area->h,
+           ESP32S3_LCD_HRES_VIRTUAL, ESP32S3_LCD_VRES_VIRTUAL);
+      return -EINVAL;
+    }
+
   struct esp32s3_lcd_s *priv = &g_lcd_priv;
 
-  cache_writeback_addr(CURRENT_LAYER(priv)->framebuffer,
-                       ESP32S3_LCD_FB_SIZE);
+  uint8_t *first_pixel = CURRENT_LAYER(priv)->framebuffer +
+                         (area->y * ESP32S3_LCD_STRIDE +
+                          area->x * ESP32S3_LCD_DATA_WIDTH);
+
+  uint32_t size = (area->h - 1) * ESP32S3_LCD_STRIDE +

Review Comment:
   Thanks. Is there anything else I can improve to make it conform to the c89 spec?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "FASTSHIFT (via GitHub)" <gi...@apache.org>.
FASTSHIFT commented on code in PR #14701:
URL: https://github.com/apache/nuttx/pull/14701#discussion_r1845816244


##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -545,10 +569,59 @@ static int esp32s3_lcd_base_getplaneinfo(struct fb_vtable_s *vtable,
 static int esp32s3_lcd_base_updatearea(struct fb_vtable_s *vtable,
                                        const struct fb_area_s *area)
 {
+  if (area->w == 0 || area->h == 0)
+    {
+      return 0;
+    }
+
+  if (area->x + area->w > ESP32S3_LCD_HRES_VIRTUAL ||
+      area->y + area->h > ESP32S3_LCD_VRES_VIRTUAL)
+    {
+      gerr("ERROR: updatearea area is out of bounds\n");

Review Comment:
   print `area` info



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "liamHowatt (via GitHub)" <gi...@apache.org>.
liamHowatt commented on code in PR #14701:
URL: https://github.com/apache/nuttx/pull/14701#discussion_r1836548619


##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -300,13 +310,16 @@ static const struct fb_videoinfo_s g_base_videoinfo =
 
 /* This structure provides the base layer interface */
 
-static const struct fb_vtable_s g_base_vtable =
+static struct fb_vtable_s g_base_vtable =

Review Comment:
   The `fb_remove_paninfo(&g_base_vtable, FB_NO_OVERLAY);` I added takes a `FAR struct fb_vtable_s *vtable`. Looks like `fb_remove_paninfo` does not modify it, though. Maybe the parameter could be made const? See https://github.com/apache/nuttx/blob/52b0df1ce6cdcc99b44700b20a2bc3351285eee0/drivers/video/fb.c#L1607
   
   Otherwise, should I keep the vtable const in esp32s3_lcd.c and cast to non-`const`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "nuttxpr (via GitHub)" <gi...@apache.org>.
nuttxpr commented on PR #14701:
URL: https://github.com/apache/nuttx/pull/14701#issuecomment-2464618190

   [**\[Experimental Bot, please feedback here\]**](https://github.com/search?q=repo%3Aapache%2Fnuttx+13552&type=issues)
   
   
   
   This PR appears to mostly meet the NuttX requirements, but has some gaps that need addressing before it's ready. Here's a breakdown:
   
   **Strengths:**
   
   * **Clear Summary:** The summary explains the "why," "what," and "how" of the change effectively.  The link to the LVGL code showing the usage is helpful.
   * **Impact Acknowledged:** The impact section correctly identifies the potential memory issue and seeks feedback on how to handle it. This proactive approach is good.
   * **Testing Information Provided:**  The testing section specifies the hardware and software environment used for verification. The instructions for configuring the board are clear.  Referencing how LVGL detects the changes is also good.
   
   
   **Weaknesses:**
   
   * **Missing Issue References:**  The summary should link to a related NuttX or NuttX Apps issue if one exists. If not, consider creating one to track the feature request/bug this PR addresses.
   * **Impact Needs More Detail:** While the memory impact is mentioned, other impacts need to be addressed more thoroughly.  Even if the answer is "NO", a brief explanation is helpful for reviewers.  For example:
       * **Impact on user:**  Even if LVGL adapts automatically, will *other* users of the framebuffer device need to change their code?
       * **Impact on build:**  Does adding double buffering change any build dependencies or configurations?
       * **Impact on hardware:** Is this change specific to the ESP32-S3, or could it be applied to other LCD drivers?
       * **Impact on documentation:** Does this change require updating any documentation (e.g., the framebuffer driver documentation, board configuration documentation)?  If so, has the documentation been updated in the PR?
       * **Impact on security:** While unlikely, it's good practice to consider security implications of any change.  Explicitly stating "NO" with a brief justification is sufficient.
       * **Impact on compatibility:**  Does this change break compatibility with any existing applications or configurations?
   * **Missing Testing Logs:** The testing section *describes* the testing but doesn't include any actual logs.  Include relevant log output before and after the change to demonstrate the functionality and the absence of regressions.  Demonstrate both single buffering and double buffering behavior.  Show what happens if the system has insufficient memory.
   * **Kconfig Decision:** The PR raises the question about a Kconfig option but doesn't propose a solution.  Suggest a concrete Kconfig option (name, description, default value) in the PR description.  This allows reviewers to discuss the specific proposal.
   
   
   **Recommendations:**
   
   1. **Create a related issue:** File an issue in the appropriate repository (NuttX or NuttX-Apps) and link it in the PR summary.
   2. **Complete the Impact section:** Address all impact points with specific details, even if the answer is "NO."
   3. **Provide testing logs:** Include actual log output demonstrating the behavior before and after the change, covering both positive and negative cases (sufficient and insufficient memory).
   4. **Propose a Kconfig option:**  Suggest a specific Kconfig option (name, description, default value) to control double buffering. Justify your choice (e.g., why enabled by default or disabled by default).
   
   
   By addressing these points, the PR will be much stronger and easier for reviewers to evaluate.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "liamHowatt (via GitHub)" <gi...@apache.org>.
liamHowatt commented on code in PR #14701:
URL: https://github.com/apache/nuttx/pull/14701#discussion_r1845487848


##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -623,6 +663,8 @@ static int IRAM_ATTR lcd_interrupt(int irq, void *context, void *arg)
       regval  = esp32s3_lcd_getreg(LCD_CAM_LCD_USER_REG);
       regval |= LCD_CAM_LCD_START_M;
       esp32s3_lcd_putreg(LCD_CAM_LCD_USER_REG, regval);
+
+      fb_remove_paninfo(&g_base_vtable, FB_NO_OVERLAY);

Review Comment:
   Take a look what I did in my latest changes. It's similar to [the way other FB drivers use this function](https://github.com/apache/nuttx/blob/a88652fe531fc79c922c26e7f96ce602317c661d/arch/sim/src/sim/sim_framebuffer.c#L444-L452).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #14701:
URL: https://github.com/apache/nuttx/pull/14701#discussion_r1835474942


##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -300,13 +310,16 @@ static const struct fb_videoinfo_s g_base_videoinfo =
 
 /* This structure provides the base layer interface */
 
-static const struct fb_vtable_s g_base_vtable =
+static struct fb_vtable_s g_base_vtable =

Review Comment:
   why remove const



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #14701:
URL: https://github.com/apache/nuttx/pull/14701


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "liamHowatt (via GitHub)" <gi...@apache.org>.
liamHowatt commented on code in PR #14701:
URL: https://github.com/apache/nuttx/pull/14701#discussion_r1845487682


##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -300,13 +310,16 @@ static const struct fb_videoinfo_s g_base_videoinfo =
 
 /* This structure provides the base layer interface */
 
-static const struct fb_vtable_s g_base_vtable =
+static struct fb_vtable_s g_base_vtable =

Review Comment:
   I understand why it has to be non-`const` now. There's a member `priv` at the end of the struct that gets assigned by fb.c. In `master` the `const` region is being written to.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "liamHowatt (via GitHub)" <gi...@apache.org>.
liamHowatt commented on PR #14701:
URL: https://github.com/apache/nuttx/pull/14701#issuecomment-2471009537

   I'm going to make some changes I think.
   
   I did this some time ago and wanted to remember why I made it work for 1 layer only. I don't think there was a reason, after analyzing. However, I think the >1 layer support is incomplete. If there are two layers, `lcd_interrupt` alternates between layers, DMAing their framebuffers out. When the `getvideoinfo` or `getplaneinfo` ioctl is called, a random layer's info is returned. The layer which was last alternated to is the current layer and its info is returned. I'm going to update this PR to continue using the random `CURRENT_LAYER` getter pattern until it's properly addressed in another PR or even this PR if you wish.
   
   The new `esp32s3_lcd_base_pandisplay` is blocking due to `esp32s3_dma_wait_idle`. I think I could/should use a critical section to set a flag which `lcd_interrupt` checks to know if the buffer should be panned and that's where `esp32s3_dma_setup` would be called.
   
   Are force-pushes preferred? Squash merging isn't normally done?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "liamHowatt (via GitHub)" <gi...@apache.org>.
liamHowatt commented on code in PR #14701:
URL: https://github.com/apache/nuttx/pull/14701#discussion_r1845488537


##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -548,7 +564,31 @@ static int esp32s3_lcd_base_updatearea(struct fb_vtable_s *vtable,
   struct esp32s3_lcd_s *priv = &g_lcd_priv;
 
   cache_writeback_addr(CURRENT_LAYER(priv)->framebuffer,
-                       ESP32S3_LCD_FB_SIZE);
+                       ESP32S3_LCD_FB_ALLOC_SIZE);
+
+  return 0;
+}
+#endif
+
+#if ESP32S3_LCD_DBLBUFFERED
+static int esp32s3_lcd_base_pandisplay(FAR struct fb_vtable_s *vtable,
+                                       FAR struct fb_planeinfo_s *pinfo)
+{
+  struct esp32s3_lcd_s *priv = &g_lcd_priv;
+  struct esp32s3_layer_s *layer = &priv->layer[0];
+  uint8_t *fb_panned = &layer->framebuffer[pinfo->yoffset * ESP32S3_LCD_STRIDE];
+
+  up_disable_irq(ESP32S3_IRQ_LCD_CAM);
+
+  esp32s3_dma_wait_idle(priv->dma_channel, true);
+
+  esp32s3_dma_setup(layer->dmadesc,

Review Comment:
   It chains transfers together using a linked list of DMA descriptors. In this PR, the transfer size is not increasing, just the starting offset changes now. There's another place `esp32s3_dma_setup` is used in this file.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #14701:
URL: https://github.com/apache/nuttx/pull/14701#issuecomment-2471286728

   Please update the patch inplace.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #14701:
URL: https://github.com/apache/nuttx/pull/14701#discussion_r1835474832


##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -548,7 +564,31 @@ static int esp32s3_lcd_base_updatearea(struct fb_vtable_s *vtable,
   struct esp32s3_lcd_s *priv = &g_lcd_priv;
 
   cache_writeback_addr(CURRENT_LAYER(priv)->framebuffer,
-                       ESP32S3_LCD_FB_SIZE);
+                       ESP32S3_LCD_FB_ALLOC_SIZE);
+
+  return 0;
+}
+#endif
+
+#if ESP32S3_LCD_DBLBUFFERED
+static int esp32s3_lcd_base_pandisplay(FAR struct fb_vtable_s *vtable,
+                                       FAR struct fb_planeinfo_s *pinfo)
+{
+  struct esp32s3_lcd_s *priv = &g_lcd_priv;

Review Comment:
   arch/board code could drop FAR, only the common code need it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "liamHowatt (via GitHub)" <gi...@apache.org>.
liamHowatt commented on code in PR #14701:
URL: https://github.com/apache/nuttx/pull/14701#discussion_r1845487977


##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -548,7 +564,31 @@ static int esp32s3_lcd_base_updatearea(struct fb_vtable_s *vtable,
   struct esp32s3_lcd_s *priv = &g_lcd_priv;
 
   cache_writeback_addr(CURRENT_LAYER(priv)->framebuffer,
-                       ESP32S3_LCD_FB_SIZE);
+                       ESP32S3_LCD_FB_ALLOC_SIZE);
+
+  return 0;
+}
+#endif
+
+#if ESP32S3_LCD_DBLBUFFERED
+static int esp32s3_lcd_base_pandisplay(FAR struct fb_vtable_s *vtable,
+                                       FAR struct fb_planeinfo_s *pinfo)
+{
+  struct esp32s3_lcd_s *priv = &g_lcd_priv;
+  struct esp32s3_layer_s *layer = &priv->layer[0];
+  uint8_t *fb_panned = &layer->framebuffer[pinfo->yoffset * ESP32S3_LCD_STRIDE];
+
+  up_disable_irq(ESP32S3_IRQ_LCD_CAM);
+
+  esp32s3_dma_wait_idle(priv->dma_channel, true);
+
+  esp32s3_dma_setup(layer->dmadesc,

Review Comment:
   Now it's in an ISR. Any advice for how to manage an error, considering the latest changes?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "liamHowatt (via GitHub)" <gi...@apache.org>.
liamHowatt commented on PR #14701:
URL: https://github.com/apache/nuttx/pull/14701#issuecomment-2481313508

   I've updated and validated it. It's much more correct now, despite the previous iteration technically working.
   
   > can be enabled/disabled by the user (default to `y`, I think).
   
   Okay, if you think it can be default. I've done it. I made it independent of layers, as mentioned in my previous comment.
   
   @FASTSHIFT I added some checks. Please see my responses to your review.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #14701:
URL: https://github.com/apache/nuttx/pull/14701#discussion_r1845716570


##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -603,10 +677,43 @@ static int IRAM_ATTR lcd_interrupt(int irq, void *context, void *arg)
                        true);
 #endif
 
+#ifdef CONFIG_ESP32S3_LCD_DOUBLE_BUFFERED
+      /* Pan the display to a new buffer offset if one was queued */
+
+      if (fb_paninfo_count(&g_base_vtable, FB_NO_OVERLAY) > 1)
+        {
+          fb_remove_paninfo(&g_base_vtable, FB_NO_OVERLAY);
+        }
+
+      union fb_paninfo_u info;

Review Comment:
   need move to the begin of function/block



##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -244,6 +258,11 @@ static int esp32s3_lcd_base_updatearea(struct fb_vtable_s *vtable,
                                        const struct fb_area_s *area);
 #endif
 
+#ifdef CONFIG_ESP32S3_LCD_DOUBLE_BUFFERED
+static int esp32s3_lcd_base_pandisplay(FAR struct fb_vtable_s *vtable,

Review Comment:
   remove all FAR



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on PR #14701:
URL: https://github.com/apache/nuttx/pull/14701#issuecomment-2464922749

   > I would like feedback on how this change should be managed. I made it so that the feature will be active if there is 1 LCD layer. The impact is that double the memory will be allocated compared to before this change, which could cause users to have insufficient memory after upgrading. Should it be a Kconfig option?
   
   Yes, I think so. You can turn `ESP32S3_LCD_DBLBUFFERED` a Kconfig option that depends on CONFIG_ESP32S3_LCD_BUFFER_LAYERS being `= 1` (just like [here](https://github.com/apache/incubator-nuttx/blob/b6d2dc6c5487ffa957eaa524e02e9699b1f6dacc/drivers/lcd/Kconfig#L1279)) and can be enabled/disabled by the user (default to `y`, I think). You can insert in `help` the warning about the memory usage.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/esp32s3: lcd add fb pandisplay [nuttx]

Posted by "FASTSHIFT (via GitHub)" <gi...@apache.org>.
FASTSHIFT commented on code in PR #14701:
URL: https://github.com/apache/nuttx/pull/14701#discussion_r1834528910


##########
arch/xtensa/src/esp32s3/esp32s3_lcd.c:
##########
@@ -548,7 +564,31 @@ static int esp32s3_lcd_base_updatearea(struct fb_vtable_s *vtable,
   struct esp32s3_lcd_s *priv = &g_lcd_priv;
 
   cache_writeback_addr(CURRENT_LAYER(priv)->framebuffer,
-                       ESP32S3_LCD_FB_SIZE);
+                       ESP32S3_LCD_FB_ALLOC_SIZE);
+
+  return 0;
+}
+#endif
+
+#if ESP32S3_LCD_DBLBUFFERED
+static int esp32s3_lcd_base_pandisplay(FAR struct fb_vtable_s *vtable,
+                                       FAR struct fb_planeinfo_s *pinfo)
+{
+  struct esp32s3_lcd_s *priv = &g_lcd_priv;
+  struct esp32s3_layer_s *layer = &priv->layer[0];
+  uint8_t *fb_panned = &layer->framebuffer[pinfo->yoffset * ESP32S3_LCD_STRIDE];

Review Comment:
   It is recommended to add an access out of bounds judgment to `pinfo->yoffset`, and print a reminder when the user passes an error parameter.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org