sim/configs/fb: Add a configuration for non-graphical testing of the frambuffer character driver using apps/example/fb

drivers/video/fb.c and include/nuttx/video.fb.h:  Some improvements and fixes from early testing sith the sim/fb cnofiguration.
This commit is contained in:
Gregory Nutt
2017-09-12 09:48:47 -06:00
parent 7846381e09
commit 107866c00e
7 changed files with 163 additions and 19 deletions
+36 -5
View File
@@ -1,5 +1,6 @@
/****************************************************************************
* graphis/fb/fb.c
* graphics/fb/fb.c
* Framebuffer character driver
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@@ -451,9 +452,18 @@ static int fb_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
* Name: fb_register
*
* Description:
* Register the framebuffer device at /dev/fbN-M where N is the display
* number and M is the display plane for displays with multiple color
* planes.
* Register the framebuffer character device at /dev/fbN where N is the
* display number if the devices supports only a single plane. If the
* hardware supports multile color planes, then the device will be
* registered at /dev/fbN-M where N is the again display number but M is
* the display plane.
*
* Input Parameters:
* display - The display number for the case of boards supporting multiple
* displays or for hardware that supports supports multile
* layers (each layer is consider a display). Typically zero.
* plane - Identifies the color plane on hardware that supports separate
* framebuffer "planes" for each color component.
*
* Returned Value:
* Zero (OK) is returned success; a negated errno value is returned on any
@@ -464,8 +474,10 @@ static int fb_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
int fb_register(int display, int plane)
{
FAR struct fb_chardev_s *fb;
struct fb_videoinfo_s vinfo;
struct fb_planeinfo_s pinfo;
char devname[16];
int nplanes;
int ret;
/* Allocate a framebuffer state instance */
@@ -497,6 +509,17 @@ int fb_register(int display, int plane)
/* Initialize the frame buffer instance. */
DEBUGASSERT(fb->vtable->getvideoinfo != NULL);
ret = fb->vtable->getvideoinfo(fb->vtable, &vinfo);
if (ret < 0)
{
gerr("ERROR: getvideoinfo() failed: %d\n", ret);
goto errout_with_fb;
}
nplanes = vinfo.nplanes;
DEBUGASSERT(vinfo.nplanes > 0 && (unsigned)plane < vinfo.nplanes);
DEBUGASSERT(fb->vtable->getplaneinfo != NULL);
ret = fb->vtable->getplaneinfo(fb->vtable, plane, &pinfo);
if (ret < 0)
@@ -511,7 +534,15 @@ int fb_register(int display, int plane)
/* Register the framebuffer device */
(void)snprintf(devname, 16, "/dev/fb%d-%d", display, plane);
if (nplanes < 2)
{
(void)snprintf(devname, 16, "/dev/fb%d", display);
}
else
{
(void)snprintf(devname, 16, "/dev/fb%d-%d", display, plane);
}
ret = register_driver(devname, &fb_fops, 0666, (FAR void *)fb);
if (ret < 0)
{