diff --git a/drivers/video/fb.c b/drivers/video/fb.c index 739bff0e28..200093808e 100644 --- a/drivers/video/fb.c +++ b/drivers/video/fb.c @@ -110,6 +110,8 @@ static FAR struct circbuf_s *fb_get_panbuf(FAR struct fb_chardev_s *fb, static int fb_add_paninfo(FAR struct fb_chardev_s *fb, FAR const union fb_paninfo_u *info, int overlay); +static int fb_clear_paninfo(FAR struct fb_chardev_s *fb, + int overlay); static int fb_open(FAR struct file *filep); static int fb_close(FAR struct file *filep); static ssize_t fb_read(FAR struct file *filep, FAR char *buffer, @@ -217,6 +219,39 @@ static int fb_add_paninfo(FAR struct fb_chardev_s *fb, return ret <= 0 ? -ENOSPC : OK; } +/**************************************************************************** + * Name: fb_clear_paninfo + ****************************************************************************/ + +static int fb_clear_paninfo(FAR struct fb_chardev_s *fb, + int overlay) +{ + FAR struct circbuf_s *panbuf; + irqstate_t flags; + + DEBUGASSERT(fb != NULL); + + panbuf = fb_get_panbuf(fb, overlay); + if (panbuf == NULL) + { + return -EINVAL; + } + + /* Disable the interrupt when writing to the queue to + * prevent it from being modified by the interrupted + * thread during the writing process. + */ + + flags = enter_critical_section(); + + circbuf_reset(panbuf); + + /* Re-enable interrupts */ + + leave_critical_section(flags); + return OK; +} + /**************************************************************************** * Name: fb_open ****************************************************************************/ @@ -861,6 +896,12 @@ static int fb_ioctl(FAR struct file *filep, int cmd, unsigned long arg) } break; + case FBIOPAN_CLEAR: + { + ret = fb_clear_paninfo(fb, (int)arg); + } + break; + case FBIOSET_VSYNCOFFSET: { fb->vsyncoffset = USEC2TICK(arg); diff --git a/include/nuttx/video/fb.h b/include/nuttx/video/fb.h index 054d001d12..c582ee2307 100644 --- a/include/nuttx/video/fb.h +++ b/include/nuttx/video/fb.h @@ -301,15 +301,19 @@ * Argument: read-only struct * fb_planeinfo_s* */ -#define FBIOSET_VSYNCOFFSET _FBIOC(0x0019) /* Set VSync offset in usec +#define FBIOPAN_CLEAR _FBIOC(0x0019) /* Pan clear */ + /* Argument: read-only + * unsigned long */ + +#define FBIOSET_VSYNCOFFSET _FBIOC(0x001a) /* Set VSync offset in usec * Argument: int */ /* Linux Support ************************************************************/ -#define FBIOGET_VSCREENINFO _FBIOC(0x001a) /* Get video variable info */ +#define FBIOGET_VSCREENINFO _FBIOC(0x001b) /* Get video variable info */ /* Argument: writable struct * fb_var_screeninfo */ -#define FBIOGET_FSCREENINFO _FBIOC(0x001b) /* Get video fix info */ +#define FBIOGET_FSCREENINFO _FBIOC(0x001c) /* Get video fix info */ /* Argument: writable struct * fb_fix_screeninfo */