linguini1 commented on code in PR #19911:
URL: https://github.com/apache/nuttx/pull/19911#discussion_r3830437240


##########
drivers/video/vfb.c:
##########
@@ -0,0 +1,226 @@
+/****************************************************************************
+ * drivers/video/vfb.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/* A framebuffer with no display behind it:  memory, registered as
+ * /dev/fbN, with the geometry the configuration asks for.
+ *
+ * Applications draw into it exactly as they would into a panel, and
+ * whatever wants the pixels, a VNC server, a screen recorder, a test
+ * harness comparing renders, reads the same memory and learns what
+ * changed through the framebuffer's dirty-area reporting.  That makes a
+ * board with no display, or one whose display is the wrong size for what
+ * is being developed, run the same graphics stack as one with a panel.
+ *
+ * There is deliberately nothing here about who consumes it.
+ */
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <debug.h>
+#include <errno.h>
+#include <string.h>
+
+#include <nuttx/kmalloc.h>
+#include <nuttx/video/fb.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define VFB_WIDTH   CONFIG_VIDEO_VFB_WIDTH
+#define VFB_HEIGHT  CONFIG_VIDEO_VFB_HEIGHT
+
+#ifdef CONFIG_VIDEO_VFB_FMT_RGB32
+#  define VFB_FMT   FB_FMT_RGB32
+#  define VFB_BPP   32
+#else
+#  define VFB_FMT   FB_FMT_RGB16_565
+#  define VFB_BPP   16
+#endif
+
+#define VFB_STRIDE  (VFB_WIDTH * ((VFB_BPP + 7) >> 3))
+#define VFB_SIZE    (VFB_STRIDE * VFB_HEIGHT)
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static int vfb_getvideoinfo(FAR struct fb_vtable_s *vtable,
+                            FAR struct fb_videoinfo_s *vinfo);
+static int vfb_getplaneinfo(FAR struct fb_vtable_s *vtable, int planeno,
+                            FAR struct fb_planeinfo_s *pinfo);
+#ifdef CONFIG_FB_UPDATE
+static int vfb_updatearea(FAR struct fb_vtable_s *vtable,
+                          FAR const struct fb_area_s *area);
+#endif
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct fb_vtable_s g_vfb_vtable =
+{
+  .getvideoinfo = vfb_getvideoinfo,
+  .getplaneinfo = vfb_getplaneinfo,
+#ifdef CONFIG_FB_UPDATE
+  .updatearea   = vfb_updatearea,
+#endif
+};
+
+static FAR uint8_t *g_vfb_buffer;
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: vfb_getvideoinfo
+ ****************************************************************************/
+
+static int vfb_getvideoinfo(FAR struct fb_vtable_s *vtable,
+                            FAR struct fb_videoinfo_s *vinfo)
+{
+  if (vtable == NULL || vinfo == NULL)
+    {
+      return -EINVAL;
+    }
+
+  memset(vinfo, 0, sizeof(*vinfo));
+  vinfo->fmt     = VFB_FMT;
+  vinfo->xres    = VFB_WIDTH;
+  vinfo->yres    = VFB_HEIGHT;
+  vinfo->nplanes = 1;
+
+  return OK;
+}
+
+/****************************************************************************
+ * Name: vfb_getplaneinfo
+ ****************************************************************************/
+
+static int vfb_getplaneinfo(FAR struct fb_vtable_s *vtable, int planeno,
+                            FAR struct fb_planeinfo_s *pinfo)
+{
+  if (vtable == NULL || pinfo == NULL || planeno != 0)
+    {
+      return -EINVAL;
+    }
+
+  memset(pinfo, 0, sizeof(*pinfo));
+  pinfo->fbmem   = g_vfb_buffer;
+  pinfo->fblen   = VFB_SIZE;
+  pinfo->stride  = VFB_STRIDE;
+  pinfo->display = 0;
+  pinfo->bpp     = VFB_BPP;
+
+  return OK;
+}
+
+/****************************************************************************
+ * Name: vfb_updatearea
+ *
+ * Description:
+ *   There is no panel to push anything to.  The call exists so that the
+ *   framebuffer core sees a driver that supports updates and passes the
+ *   areas on to whoever is watching.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_FB_UPDATE
+static int vfb_updatearea(FAR struct fb_vtable_s *vtable,
+                          FAR const struct fb_area_s *area)
+{
+  UNUSED(vtable);
+  UNUSED(area);
+  return OK;
+}
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: up_fbinitialize
+ *
+ * Description:
+ *   Allocate the framebuffer.  Boards with no display of their own get
+ *   this implementation of the framebuffer interface;  one that has a
+ *   panel provides its own, and the two cannot both be built.
+ *
+ ****************************************************************************/
+
+int up_fbinitialize(int display)

Review Comment:
   We should use the other interface instead of the up_ one for this driver.



-- 
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