video: compensation omxpts for pcr check [1/1]
authorshuanglong.wang <shuanglong.wang@amlogic.com>
Fri, 12 Apr 2019 05:55:06 +0000 (13:55 +0800)
committerNick Xie <nick@khadas.com>
Mon, 5 Aug 2019 06:12:19 +0000 (14:12 +0800)
PD#SWPL-5664

Problem:
pcr is probably adjust when test AL1 eyepatch test case

Solution:
the time is not accurate when check pcr and omx_pts differ, because
omx_pts is used the value that be set, but pcr is current. Here add
compensation for omx_pts

Verify:
verify by nts

Change-Id: I3e0f6f006fd79cf7cac4148fd18da72111a333c7
Signed-off-by: shuanglong.wang <shuanglong.wang@amlogic.com>
 Conflicts:
drivers/amlogic/media/video_sink/video.c

drivers/amlogic/media/video_sink/video.c

index fc1d900..7f0cc29 100644 (file)
@@ -153,6 +153,11 @@ static bool video_start_post;
 static bool videopeek;
 static bool nopostvideostart;
 static struct video_frame_detect_s video_frame_detect;
+static struct timeval time_setomxpts = {
+       .tv_sec = 0,
+       .tv_usec = 0,
+};
+
 
 /*----omx_info  bit0: keep_last_frame, bit1~31: unused----*/
 static u32 omx_info = 0x1;
@@ -6300,10 +6305,22 @@ static irqreturn_t vsync_isr_in(int irq, void *dev_id)
        }
        if (omx_secret_mode == true) {
                u32 system_time = timestamp_pcrscr_get();
-               int diff = system_time - omx_pts;
+               int diff = 0;
+               unsigned long delta1 = 0;
                video_notify_flag |= VIDEO_NOTIFY_TRICK_WAIT;
                atomic_set(&trickmode_framedone, 1);
 
+               diff = system_time - omx_pts;
+               if (time_setomxpts.tv_sec > 0) {
+                       struct timeval now;
+
+                       do_gettimeofday(&now);
+                       delta1 = (now.tv_sec - time_setomxpts.tv_sec)
+                               * 1000000LL
+                               + (now.tv_usec - time_setomxpts.tv_usec);
+                       diff -=  delta1 * 90 / 1000;
+               }
+
                if ((diff - omx_pts_interval_upper) > 0
                        || (diff - omx_pts_interval_lower) < 0
                        || (omx_pts_set_from_hwc_count <
@@ -8140,6 +8157,9 @@ static void video_vf_unreg_provider(void)
        show_first_picture = false;
        show_first_frame_nosync = false;
 
+       time_setomxpts.tv_sec = 0;
+       time_setomxpts.tv_usec = 0;
+
 #ifdef PTS_LOGGING
        {
                int pattern;
@@ -8676,8 +8696,11 @@ static void set_omx_pts(u32 *p)
                pr_info("[set_omx_pts]tmp_pts:%d, set_from_hwc:%d,frame_num=%d, not_reset=%d\n",
                        tmp_pts, set_from_hwc, frame_num, not_reset);
 
-       if (not_reset == 0)
+       if (not_reset == 0) {
                omx_pts = tmp_pts;
+               ATRACE_COUNTER("omxpts", omx_pts);
+               do_gettimeofday(&time_setomxpts);
+       }
        /* kodi may render first frame, then drop dozens of frames */
        if (set_from_hwc == 0 && omx_run == true && frame_num <= 2
                        && not_reset == 0) {