videosync: expire driven by vsync [1/1]
authorjintao xu <jintao.xu@amlogic.com>
Fri, 18 Oct 2019 09:58:37 +0000 (17:58 +0800)
committerJintao Xu <jintao.xu@amlogic.com>
Tue, 22 Oct 2019 05:42:07 +0000 (22:42 -0700)
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 <jintao.xu@amlogic.com>
drivers/amlogic/media/video_processor/videosync/videosync.c
drivers/amlogic/media/video_processor/videosync/videosync.h
drivers/amlogic/media/video_sink/video.c
include/linux/amlogic/media/video_sink/video.h

index a990854..f73e6db 100644 (file)
@@ -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;
index e36f39e..861d955 100644 (file)
@@ -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;
 
index 5055546..5fd2a0e 100644 (file)
@@ -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)
index 06c4b31..a68eeea 100644 (file)
@@ -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 */