From d508390213deafec07301a42e3e61077c33672ae Mon Sep 17 00:00:00 2001 From: jintao xu Date: Fri, 18 Oct 2019 17:58:37 +0800 Subject: [PATCH] videosync: expire driven by vsync [1/1] PD#SWPL-14542 Problem: pipvideo drop frame when play 60fps Solution: expire driven by vsync Verify: U212 Change-Id: Ie54fb6c62b1e3db04157a98fd075c126b5b304d1 Signed-off-by: jintao xu --- .../video_processor/videosync/videosync.c | 21 ++++++++++++++----- .../video_processor/videosync/videosync.h | 2 ++ drivers/amlogic/media/video_sink/video.c | 1 + .../linux/amlogic/media/video_sink/video.h | 1 + 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/amlogic/media/video_processor/videosync/videosync.c b/drivers/amlogic/media/video_processor/videosync/videosync.c index a990854ca40c..f73e6db284bd 100644 --- a/drivers/amlogic/media/video_processor/videosync/videosync.c +++ b/drivers/amlogic/media/video_processor/videosync/videosync.c @@ -203,6 +203,14 @@ static void videosync_vf_put(struct vframe_s *vf, void *op_arg) } } +void vsync_notify_videosync(void) +{ + if (videosync_inited) { + vp_dev->wakeup = 1; + wake_up_interruptible(&vp_dev->videosync_wait); + } +} + static int videosync_event_cb(int type, void *data, void *private_data) { return 0; @@ -923,7 +931,7 @@ static void prepare_queued_queue(struct videosync_dev *dev) continue; } - if (vf_peek(dev_s->vf_receiver_name)) { + while (vf_peek(dev_s->vf_receiver_name)) { vf = vf_get(dev_s->vf_receiver_name); if (vf) { vfq_push(&dev_s->queued_q, vf); @@ -935,9 +943,6 @@ static void prepare_queued_queue(struct videosync_dev *dev) vf->index, vfq_level(&dev_s->queued_q)); } - } else { - vp_print(dev_s->vf_receiver_name, PRINT_OTHER, - "peek failed %d\n"); } } @@ -1006,6 +1011,8 @@ static int videosync_receiver_event_fun(int type, void *data, if (dev_s->active_state == VIDEOSYNC_ACTIVE) { dev_s->active_state = VIDEOSYNC_INACTIVE_REQ; + dev->wakeup = 1; + wake_up_interruptible(&dev->videosync_wait); time_left = wait_for_completion_timeout( &dev_s->inactive_done, msecs_to_jiffies(100)); @@ -1149,6 +1156,9 @@ static void videosync_thread_tick(struct videosync_dev *dev) if (!dev) return; + wait_event_interruptible(dev->videosync_wait, dev->wakeup); + dev->wakeup = 0; + for (i = 0; i < VIDEOSYNC_S_COUNT; i++) { dev_s = &dev->video_prov[i]; if (dev_s->active_state == VIDEOSYNC_INACTIVE_REQ) { @@ -1165,7 +1175,6 @@ static void videosync_thread_tick(struct videosync_dev *dev) spin_unlock_irqrestore(&dev->dev_s_num_slock, flags); prepare_queued_queue(dev); prepare_ready_queue(dev); - usleep_range(7000, 8000); } else { spin_unlock_irqrestore(&dev->dev_s_num_slock, flags); vp_print(RECEIVER_NAME, PRINT_OTHER, @@ -1248,6 +1257,8 @@ static int __init videosync_init(void) } init_completion(&vp_dev->thread_active); + vp_dev->wakeup = 0; + init_waitqueue_head(&vp_dev->videosync_wait); vp_dev->kthread = kthread_run(videosync_thread, vp_dev, "videosync"); videosync_inited = true; return ret; diff --git a/drivers/amlogic/media/video_processor/videosync/videosync.h b/drivers/amlogic/media/video_processor/videosync/videosync.h index e36f39e23d93..861d95540bec 100644 --- a/drivers/amlogic/media/video_processor/videosync/videosync.h +++ b/drivers/amlogic/media/video_processor/videosync/videosync.h @@ -57,6 +57,8 @@ struct videosync_dev { struct mutex vp_mutex; spinlock_t dev_s_num_slock; u32 active_dev_s_num; + wait_queue_head_t videosync_wait; + int wakeup; }; extern bool omx_secret_mode; diff --git a/drivers/amlogic/media/video_sink/video.c b/drivers/amlogic/media/video_sink/video.c index 50555466858e..5fd2a0e514cf 100644 --- a/drivers/amlogic/media/video_sink/video.c +++ b/drivers/amlogic/media/video_sink/video.c @@ -7656,6 +7656,7 @@ SET_FILTER: } vf = pip_vf_peek(); } + vsync_notify_videosync(); if (videopip_get_vf_cnt >= 2) { videopip_drop_vf_cnt += (videopip_get_vf_cnt - 1); if (debug_flag & DEBUG_FLAG_PRINT_DROP_FRAME) diff --git a/include/linux/amlogic/media/video_sink/video.h b/include/linux/amlogic/media/video_sink/video.h index 06c4b31569a1..a68eeead1b5e 100644 --- a/include/linux/amlogic/media/video_sink/video.h +++ b/include/linux/amlogic/media/video_sink/video.h @@ -263,4 +263,5 @@ extern int DI_POST_WR_REG_BITS(u32 adr, u32 val, u32 start, u32 len); void DI_POST_UPDATE_MC(void); extern void videosync_pcrscr_update(s32 inc, u32 base); +void vsync_notify_videosync(void); #endif /* VIDEO_H */