drivers/video: add fb_vsync_pollnotify

when the vsync comes, fb drivers should call fb_vsync_pollnotify to notify POLLPRI, so that users can catch the synchronization time of vsync and do something.

Signed-off-by: jianglianfang <jianglianfang@xiaomi.com>
This commit is contained in:
jianglianfang 2023-11-21 15:26:49 +08:00 committed by Xiang Xiao
parent a2662bd369
commit 8122cbd5d2
3 changed files with 58 additions and 8 deletions

View File

@ -426,6 +426,7 @@ void sim_x11loop(void)
if (now - last >= MSEC2TICK(16))
{
last = now;
fb_notify_vsync(&g_fbobject, FB_NO_OVERLAY);
if (fb_paninfo_count(&g_fbobject, FB_NO_OVERLAY) > 1)
{
fb_remove_paninfo(&g_fbobject, FB_NO_OVERLAY);
@ -463,7 +464,8 @@ int up_fbinitialize(int display)
#ifdef CONFIG_SIM_X11FB
g_planeinfo.xres_virtual = CONFIG_SIM_FBWIDTH;
g_planeinfo.yres_virtual = CONFIG_SIM_FBHEIGHT * CONFIG_SIM_FRAMEBUFFER_COUNT;
g_planeinfo.yres_virtual = CONFIG_SIM_FBHEIGHT *
CONFIG_SIM_FRAMEBUFFER_COUNT;
ret = sim_x11initialize(CONFIG_SIM_FBWIDTH, CONFIG_SIM_FBHEIGHT,
&g_planeinfo.fbmem, &g_planeinfo.fblen,
&g_planeinfo.bpp, &g_planeinfo.stride,

View File

@ -1223,17 +1223,14 @@ static int fb_get_planeinfo(FAR struct fb_chardev_s *fb,
}
/****************************************************************************
* Name: fb_do_pollnotify
* Name: fb_notify_paninfo
****************************************************************************/
static void fb_do_pollnotify(wdparm_t arg)
static void fb_notify_paninfo(FAR struct fb_paninfo_s *paninfo,
pollevent_t events, int overlay)
{
FAR struct fb_paninfo_s *paninfo = (FAR struct fb_paninfo_s *)arg;
FAR struct fb_priv_s * priv;
irqstate_t flags;
int overlay;
overlay = paninfo - paninfo->dev->paninfo - 1;
flags = enter_critical_section();
for (priv = paninfo->dev->head; priv; priv = priv->flink)
@ -1245,12 +1242,26 @@ static void fb_do_pollnotify(wdparm_t arg)
/* Notify framebuffer is writable. */
poll_notify(priv->fds, CONFIG_VIDEO_FB_NPOLLWAITERS, POLLOUT);
poll_notify(priv->fds, CONFIG_VIDEO_FB_NPOLLWAITERS, events);
}
leave_critical_section(flags);
}
/****************************************************************************
* Name: fb_do_pollnotify
****************************************************************************/
static void fb_do_pollnotify(wdparm_t arg)
{
FAR struct fb_paninfo_s *paninfo = (FAR struct fb_paninfo_s *)arg;
int overlay;
overlay = paninfo - paninfo->dev->paninfo - 1;
fb_notify_paninfo(paninfo, POLLOUT, overlay);
}
#ifdef CONFIG_FB_SYNC
/****************************************************************************
* Name: fb_sem_wait
@ -1355,6 +1366,30 @@ static void fb_pollnotify(FAR struct fb_chardev_s *fb, int overlay)
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: fb_notify_vsync
* Description:
* notify that the vsync comes.
*
* Input Parameters:
* vtable - Pointer to framebuffer's virtual table.
* overlay - Overlay index.
*
****************************************************************************/
void fb_notify_vsync(FAR struct fb_vtable_s *vtable, int overlay)
{
FAR struct fb_chardev_s *fb;
FAR struct fb_paninfo_s *paninfo;
fb = vtable->priv;
if (fb != NULL)
{
paninfo = &fb->paninfo[overlay + 1];
fb_notify_paninfo(paninfo, POLLPRI, overlay);
}
}
/****************************************************************************
* Name: fb_peek_paninfo
* Description:

View File

@ -1008,6 +1008,19 @@ FAR struct fb_vtable_s *up_fbgetvplane(int display, int vplane);
void up_fbuninitialize(int display);
/****************************************************************************
* Name: fb_notify_vsync
* Description:
* notify that the vsync comes.
*
* Input Parameters:
* vtable - Pointer to framebuffer's virtual table.
* overlay - Overlay index.
*
****************************************************************************/
void fb_notify_vsync(FAR struct fb_vtable_s *vtable, int overlay);
/****************************************************************************
* Name: fb_peek_paninfo
* Description: