You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by si...@apache.org on 2026/04/10 08:47:15 UTC

(nuttx) 01/05: video/gc0308: report V4L2_PIX_FMT_RGB565X for 8-bit DVP output

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

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

commit e6ad9d25d7179495c7b93b9703648bc0284ade9f
Author: wangjianyu3 <wa...@xiaomi.com>
AuthorDate: Tue Apr 7 11:57:15 2026 +0800

    video/gc0308: report V4L2_PIX_FMT_RGB565X for 8-bit DVP output
    
    GC0308 register 0x24 bits[3:0] = 0x06 selects RGB565 output per
    datasheet.  On an 8-bit DVP bus the high byte is clocked out first,
    so the pixel data arrives in memory in big-endian order (RGB565X).
    
    Report V4L2_PIX_FMT_RGB565X so that userspace can detect this and
    byte-swap if needed for a little-endian display path.
    
    Signed-off-by: wangjianyu3 <wa...@xiaomi.com>
---
 drivers/video/gc0308.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/video/gc0308.c b/drivers/video/gc0308.c
index b1faab20692..768b21e46ca 100644
--- a/drivers/video/gc0308.c
+++ b/drivers/video/gc0308.c
@@ -461,8 +461,8 @@ static const struct v4l2_fmtdesc g_gc0308_fmtdescs[] =
     .description = "YUV 4:2:2 (YUYV)",
   },
   {
-    .pixelformat = V4L2_PIX_FMT_RGB565,
-    .description = "RGB565",
+    .pixelformat = V4L2_PIX_FMT_RGB565X,
+    .description = "RGB565X (BE)",
   },
 };
 
@@ -653,7 +653,10 @@ static int gc0308_init(struct imgsensor_s *sensor)
 
   up_mdelay(80);
 
-  /* Set default RGB565 output format: reg 0x24 bits[3:0] = 6 */
+  /* Set RGB565 output: reg 0x24 bits[3:0] = 0x06 per datasheet.
+   * On 8-bit DVP bus the high byte is clocked out first, so the
+   * resulting memory layout is big-endian (RGB565X).
+   */
 
   ret = gc0308_putreg(priv->i2c, GC0308_REG_RESET, 0x00);
   if (ret < 0)
@@ -662,7 +665,7 @@ static int gc0308_init(struct imgsensor_s *sensor)
     }
 
   ret = gc0308_modreg(priv->i2c, GC0308_REG_OUTPUT_FMT, 0x0f, 0x06);
-  priv->pixelformat = IMGSENSOR_PIX_FMT_RGB565;
+  priv->pixelformat = IMGSENSOR_PIX_FMT_RGB565X;
   if (ret < 0)
     {
       return ret;
@@ -760,7 +763,7 @@ static int gc0308_validate_frame_setting(struct imgsensor_s *sensor,
   if (datafmts[IMGSENSOR_FMT_MAIN].pixelformat !=
       IMGSENSOR_PIX_FMT_YUYV &&
       datafmts[IMGSENSOR_FMT_MAIN].pixelformat !=
-      IMGSENSOR_PIX_FMT_RGB565)
+      IMGSENSOR_PIX_FMT_RGB565X)
     {
       return -EINVAL;
     }
@@ -795,9 +798,9 @@ static int gc0308_start_capture(struct imgsensor_s *sensor,
 
   /* Configure output format register based on requested pixel format */
 
-  if (datafmts[IMGSENSOR_FMT_MAIN].pixelformat == IMGSENSOR_PIX_FMT_RGB565)
+  if (datafmts[IMGSENSOR_FMT_MAIN].pixelformat == IMGSENSOR_PIX_FMT_RGB565X)
     {
-      fmtval = 0x06;  /* RGB565 */
+      fmtval = 0x06;  /* Reg 0x24 = RGB565; BE in memory due to 8-bit DVP */
     }
   else
     {