From 6c374fc06c9da5bf2f00930a2174ee65bf6535e2 Mon Sep 17 00:00:00 2001 From: liushuai25 Date: Thu, 30 Sep 2021 13:47:00 +0800 Subject: [PATCH] feat: driver: support double buffer for display add pan display for fb driver. reference links: https://github.com/torvalds/linux/blob/master/drivers/video/fbdev/core/fbmem.c https://github.com/torvalds/linux/blob/master/drivers/video/fbdev/goldfishfb.c Signed-off-by: liushuai25 Update include/nuttx/video/fb.h Co-authored-by: Gustavo Henrique Nihei <38959758+gustavonihei@users.noreply.github.com> Update include/nuttx/video/fb.h Co-authored-by: Gustavo Henrique Nihei <38959758+gustavonihei@users.noreply.github.com> --- drivers/video/fb.c | 11 +++++++++++ include/nuttx/video/fb.h | 23 ++++++++++++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/drivers/video/fb.c b/drivers/video/fb.c index 3e294dd73a..9da1474e54 100644 --- a/drivers/video/fb.c +++ b/drivers/video/fb.c @@ -554,6 +554,17 @@ static int fb_ioctl(FAR struct file *filep, int cmd, unsigned long arg) } break; + case FBIOPAN_DISPLAY: + { + FAR struct fb_planeinfo_s *pinfo = + (FAR struct fb_planeinfo_s *)((uintptr_t)arg); + + DEBUGASSERT(pinfo != NULL && fb->vtable != NULL && + fb->vtable->pandisplay != NULL); + ret = fb->vtable->pandisplay(fb->vtable, pinfo); + } + break; + default: gerr("ERROR: Unsupported IOCTL command: %d\n", cmd); ret = -ENOTTY; diff --git a/include/nuttx/video/fb.h b/include/nuttx/video/fb.h index 0291fd81cb..e120b8d5b8 100644 --- a/include/nuttx/video/fb.h +++ b/include/nuttx/video/fb.h @@ -283,6 +283,10 @@ #define FBIOGET_FRAMERATE _FBIOC(0x0015) /* Get frame rate * Argument: int* */ +#define FBIOPAN_DISPLAY _FBIOC(0x0016) /* Pan display + * Argument: read-only struct + * fb_planeinfo_s* */ + /**************************************************************************** * Public Types ****************************************************************************/ @@ -315,11 +319,15 @@ struct fb_videoinfo_s struct fb_planeinfo_s { - FAR void *fbmem; /* Start of frame buffer memory */ - size_t fblen; /* Length of frame buffer memory in bytes */ - fb_coord_t stride; /* Length of a line in bytes */ - uint8_t display; /* Display number */ - uint8_t bpp; /* Bits per pixel */ + FAR void *fbmem; /* Start of frame buffer memory */ + size_t fblen; /* Length of frame buffer memory in bytes */ + fb_coord_t stride; /* Length of a line in bytes */ + uint8_t display; /* Display number */ + uint8_t bpp; /* Bits per pixel */ + uint32_t xres_virtual; /* Virtual Horizontal resolution in pixel columns */ + uint32_t yres_virtual; /* Virtual Vertical resolution in pixel rows */ + uint32_t xoffset; /* Offset from virtual to visible resolution */ + uint32_t yoffset; /* Offset from virtual to visible resolution */ }; /* This structure describes an area. */ @@ -584,6 +592,11 @@ struct fb_vtable_s # endif #endif + /* Pan display for multiple buffers. */ + + int (*pandisplay)(FAR struct fb_vtable_s *vtable, + FAR struct fb_planeinfo_s *pinfo); + /* Specific Controls ******************************************************/ /* Set the frequency of the framebuffer update panel (0: disable refresh) */