xiaoxiang781216 commented on code in PR #17294:
URL: https://github.com/apache/nuttx/pull/17294#discussion_r2506993750


##########
arch/arm64/src/bcm2711/bcm2711_mailbox.c:
##########
@@ -746,3 +746,440 @@ int bcm2711_mbox_setclkrate(uint8_t id, uint32_t *rate, 
bool turbo)
   *rate = buf[6];
   return err;
 }
+
+/****************************************************************************
+ * Name: bcm2711_mbox_getfb
+ *
+ * Description:
+ *   Allocates a frame buffer and returns it.
+ *
+ * Input parameters:
+ *   fb - A place to store the frame buffer address
+ *   size - The frame buffer size in bytes
+ *
+ * Returned Value:
+ *   0 on success, negated error code on failure.
+ ****************************************************************************/
+
+int bcm2711_mbox_getfb(void **fb, uint32_t *size)
+{
+  int err;
+  uint32_t buf[BUF_FIELDS + TAG_FIELDS + 2] ALIGNED_MBOX;
+
+  DEBUGASSERT(fb != NULL);
+
+  buf[0] = 16; /* Alignment in bytes TODO: should this be variable? */
+  buf[1] = 0;
+
+  bcm2711_mbox_makereq(MBOX_TAG_FALLOC, buf, 2 * sizeof(uint32_t),
+                       sizeof(buf));
+  err = bcm2711_mbox_sendreq(buf, sizeof(buf));
+
+  *fb = (void *)(unsigned long)VCADDR_TO_ARM(buf[5]);
+  *size = buf[6];
+
+  /* Docs say that if size is returned as 0, the alignment was
+   * invalid because the frame buffer wasn't allocated.
+   */
+
+  if (buf[6] == 0 && !err)
+    {
+      ipcerr("Frame buffer alignment of 16 bytes invalid.");
+      return -EINVAL; /* Invalid alignment */
+    }
+
+  /* Frame buffer address needs to be modified since the address is what's
+   * seen from the VideoCore memory.
+   */
+
+  return err;
+}
+
+/****************************************************************************
+ * Name: bcm2711_mbox_releasefb
+ *
+ * Description:
+ *   Releases the previously allocated frame buffer.
+ *
+ * Returned Value:
+ *   0 on success, negated error code on failure.
+ ****************************************************************************/
+
+int bcm2711_mbox_releasefb(void)
+{
+  uint32_t buf[BUF_FIELDS + TAG_FIELDS] ALIGNED_MBOX;
+  bcm2711_mbox_makereq(MBOX_TAG_FREL, buf, 0, sizeof(buf));
+  return bcm2711_mbox_sendreq(buf, sizeof(buf));
+}
+
+/****************************************************************************
+ * Name: bcm2711_mbox_getdisp
+ *
+ * Description:
+ *   Get physical display width and height.
+ *
+ * Input parameters:
+ *   x - Width in pixels
+ *   y - Height in pixels
+ *
+ * Returned Value:
+ *   0 on success, negated error code on failure.
+ ****************************************************************************/
+
+int bcm2711_mbox_getdisp(uint32_t *x, uint32_t *y)
+{
+  int err;
+  uint32_t buf[BUF_FIELDS + TAG_FIELDS + 2] ALIGNED_MBOX;
+
+  DEBUGASSERT(x != NULL);
+  DEBUGASSERT(y != NULL);
+
+  bcm2711_mbox_makereq(MBOX_TAG_GETDISP, buf, 2 * sizeof(uint32_t),
+                       sizeof(buf));
+  err = bcm2711_mbox_sendreq(buf, sizeof(buf));
+
+  *x = buf[5];
+  *y = buf[6];
+  return err;
+}
+
+/****************************************************************************
+ * Name: bcm2711_mbox_getdepth
+ *
+ * Description:
+ *   Get the bits per pixel used for the display.
+ *
+ * Input parameters:
+ *   bpp - Bits per pixel
+ *
+ * Returned Value:
+ *   0 on success, negated error code on failure.
+ ****************************************************************************/
+
+int bcm2711_mbox_getdepth(uint32_t *bpp)
+{
+  int err;
+  uint32_t buf[BUF_FIELDS + TAG_FIELDS + 1] ALIGNED_MBOX;
+
+  DEBUGASSERT(bpp != NULL);
+
+  bcm2711_mbox_makereq(MBOX_TAG_GETDEPTH, buf, sizeof(uint32_t),
+                       sizeof(buf));
+  err = bcm2711_mbox_sendreq(buf, sizeof(buf));
+  *bpp = buf[5];
+  return err;
+}
+
+/****************************************************************************
+ * Name: bcm2711_mbox_getalpha
+ *
+ * Description:
+ *   Get the alpha mode.
+ *
+ * Input parameters:
+ *   alpha - Returned alpha state: 0 enabled, 1 reversed, 2 ignored
+ *
+ * Returned Value:
+ *   0 on success, negated error code on failure.
+ ****************************************************************************/
+
+int bcm2711_mbox_getalpha(uint32_t *alpha)
+{
+  int err;
+  uint32_t buf[BUF_FIELDS + TAG_FIELDS + 1] ALIGNED_MBOX;
+
+  DEBUGASSERT(alpha != NULL);
+
+  bcm2711_mbox_makereq(MBOX_TAG_GETALPHA, buf, sizeof(uint32_t),
+                       sizeof(buf));
+  err = bcm2711_mbox_sendreq(buf, sizeof(buf));
+  *alpha = buf[5];
+  return err;
+}
+
+/****************************************************************************
+ * Name: bcm2711_mbox_getpitch
+ *
+ * Description:
+ *   Get the number of bytes per line.
+ *
+ * Input parameters:
+ *   bpl - Bytes per line
+ *
+ * Returned Value:
+ *   0 on success, negated error code on failure.
+ ****************************************************************************/
+
+int bcm2711_mbox_getpitch(uint32_t *bpl)
+{
+  int err;
+  uint32_t buf[BUF_FIELDS + TAG_FIELDS + 1] ALIGNED_MBOX;
+
+  DEBUGASSERT(bpl != NULL);
+
+  bcm2711_mbox_makereq(MBOX_TAG_GETPITCH, buf, sizeof(uint32_t),
+                       sizeof(buf));
+  err = bcm2711_mbox_sendreq(buf, sizeof(buf));
+  *bpl = buf[5];
+  return err;
+}
+
+/****************************************************************************
+ * Name: bcm2711_mbox_getvirtres
+ *
+ * Description:
+ *   Get the virtual resolution of the display.
+ *
+ * Input parameters:
+ *   x - Width in pixels
+ *   y - Height in pixels
+ *
+ * Returned Value:
+ *   0 on success, negated error code on failure.
+ ****************************************************************************/
+
+int bcm2711_mbox_getvirtres(uint32_t *x, uint32_t *y)
+{
+  int err;
+  uint32_t buf[BUF_FIELDS + TAG_FIELDS + 2] ALIGNED_MBOX;
+
+  DEBUGASSERT(x != NULL);
+  DEBUGASSERT(y != NULL);
+
+  bcm2711_mbox_makereq(MBOX_TAG_GETVBUF, buf, 2 * sizeof(uint32_t),
+                       sizeof(buf));
+  err = bcm2711_mbox_sendreq(buf, sizeof(buf));
+  *x = buf[5];
+  *y = buf[6];
+  return err;
+}
+
+/****************************************************************************
+ * Name: bcm2711_mbox_setvirtres
+ *
+ * Description:
+ *   Set the virtual resolution of the display. The new virtual resolution is
+ *   returned in the input parameters.
+ *
+ * Input parameters:
+ *   x - Width in pixels
+ *   y - Height in pixels
+ *
+ * Returned Value:
+ *   0 on success, negated error code on failure.
+ ****************************************************************************/
+
+int bcm2711_mbox_setvirtres(uint32_t *x, uint32_t *y)
+{
+  int err;
+  uint32_t buf[BUF_FIELDS + TAG_FIELDS + 2] ALIGNED_MBOX;
+
+  DEBUGASSERT(x != NULL);
+  DEBUGASSERT(y != NULL);
+
+  buf[0] = *x;
+  buf[1] = *y;
+
+  bcm2711_mbox_makereq(MBOX_TAG_SETVBUF, buf, 2 * sizeof(uint32_t),
+                       sizeof(buf));
+  err = bcm2711_mbox_sendreq(buf, sizeof(buf));
+  *x = buf[5];
+  *y = buf[6];
+  return err;
+}
+
+/****************************************************************************
+ * Name: bcm2711_mbox_getvirtoff
+ *
+ * Description:
+ *   Get the virtual buffer offset in pixels
+ *
+ * Input parameters:
+ *   x - X in pixels
+ *   y - Y in pixels
+ *
+ * Returned Value:
+ *   0 on success, negated error code on failure.
+ ****************************************************************************/
+
+int bcm2711_mbox_getvirtoff(uint32_t *x, uint32_t *y)
+{
+  int err;
+  uint32_t buf[BUF_FIELDS + TAG_FIELDS + 2] ALIGNED_MBOX;
+
+  DEBUGASSERT(x != NULL);
+  DEBUGASSERT(y != NULL);
+
+  bcm2711_mbox_makereq(MBOX_TAG_GETVIRTOFF, buf, 2 * sizeof(uint32_t),
+                       sizeof(buf));
+  err = bcm2711_mbox_sendreq(buf, sizeof(buf));
+  *x = buf[5];
+  *y = buf[6];
+  return err;
+}
+
+/****************************************************************************
+ * Name: bcm2711_mbox_getpixord
+ *
+ * Description:
+ *   Get the pixel order of the frame buffer.
+ *
+ * Input parameters:
+ *   rgb - True if RGB order, false for BGR order
+ *
+ * Returned Value:
+ *   0 on success, negated error code on failure.
+ ****************************************************************************/
+
+int bcm2711_mbox_getpixord(bool *rgb)
+{
+  int err;
+  uint32_t buf[BUF_FIELDS + TAG_FIELDS + 1] ALIGNED_MBOX;
+
+  DEBUGASSERT(rgb != NULL);
+
+  bcm2711_mbox_makereq(MBOX_TAG_GETPIXORD, buf, sizeof(uint32_t),
+                       sizeof(buf));
+  err = bcm2711_mbox_sendreq(buf, sizeof(buf));
+  *rgb = buf[5] ? true : false;
+  return err;
+}
+
+/****************************************************************************
+ * Name: bcm2711_mbox_setpixord
+ *
+ * Description:
+ *   Set the pixel order of the frame buffer.
+ *
+ * Input parameters:
+ *   rgb - True if RGB order, false for BGR order
+ *
+ * Returned Value:
+ *   0 on success, negated error code on failure.
+ ****************************************************************************/
+
+int bcm2711_mbox_setpixord(bool rgb)
+{
+  int err;
+  uint32_t buf[BUF_FIELDS + TAG_FIELDS + 1] ALIGNED_MBOX;
+
+  buf[0] = rgb ? 1 : 0;
+
+  bcm2711_mbox_makereq(MBOX_TAG_GETPIXORD, buf, sizeof(uint32_t),

Review Comment:
   MBOX_TAG_GETPIXORD->MBOX_TAG_SETPIXORD



##########
boards/arm64/bcm2711/raspberrypi-4b/Kconfig:
##########
@@ -53,4 +53,12 @@ config RPI4B_MOUNT_BOOT
                Mounts the boot partition of the micro SD card to NuttX as a 
read/write
                file system.
 
+config RPI4B_FRAMEBUFFER
+       bool "Register frame buffer driver"
+       depends on BCM2711_FRAMEBUFFER
+       depends on VIDEO_FB

Review Comment:
   move VIDEO_FB dependence to arch/arm64/src/bcm2711/Kconfig



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to