stream_input: wrong pts value is displayed in sys file [3/4]
authorzihaoling <zihao.ling@amlogic.com>
Thu, 23 Apr 2020 09:04:08 +0000 (17:04 +0800)
committerHui Zhang <hui.zhang@amlogic.com>
Fri, 22 May 2020 10:05:02 +0000 (03:05 -0700)
PD#SWPL-24755

Problem:
wrong video pts value is displayed in sys file

Solution:
1.amstream_ioctl_get add case
  AMSTREAM_GET_VPTS_U64/AMSTREAM_GET_APTS_U64
2.get the highest bit of videopts and checkin

Verify:
Ac211

Change-Id: I04e8beb823cd99e24a146ab676ad0aec11aae835
Signed-off-by: zihaoling <zihao.ling@amlogic.com>
drivers/stream_input/amports/amstream.c
drivers/stream_input/parser/hw_demux/aml_dvb.c
drivers/stream_input/parser/tsdemux.c

index c15c6a50f050b55ae08991235aa6b0b444a38c0b..fbf6517f2d7a772b9d42afa9b81fd75502ac1319 100644 (file)
@@ -1898,6 +1898,12 @@ static long amstream_ioctl_get(struct port_priv_s *priv, ulong arg)
        case AMSTREAM_GET_VPTS:
                parm.data_32 = timestamp_vpts_get();
                break;
+       case AMSTREAM_GET_VPTS_U64:
+               parm.data_64 = timestamp_vpts_get_u64();
+               break;
+       case AMSTREAM_GET_APTS_U64:
+               parm.data_64 = timestamp_apts_get_u64();
+               break;
        case AMSTREAM_GET_PCRSCR:
                parm.data_32 = timestamp_pcrscr_get();
                break;
index fd80a3e58972215e8b646e238173f88734e135ac..114d422851791bd4e07da6fb003532bea05a7682 100644 (file)
@@ -1708,6 +1708,43 @@ static ssize_t demux_show_audio_pts_bit32(struct class *class,
        return ret;
 }
 
+/*Show the 33bit Video PTS value*/
+static ssize_t demux_show_video_pts_u64(struct class *class,
+                               struct class_attribute *attr, char *buf)
+{
+       struct aml_dvb *dvb = &aml_dvb_device;
+       ssize_t ret = 0;
+
+       u64 pts_val = aml_dmx_get_video_pts(dvb);
+       pts_val &= 0x00000000FFFFFFFF;
+
+       if (aml_dmx_get_video_pts_bit32(dvb)) {
+               pts_val = pts_val | (1LL<<32);
+       }
+
+       ret = sprintf(buf, "%llu\n", pts_val);
+
+       return ret;
+}
+
+/*Show the 33bit Audio PTS value*/
+static ssize_t demux_show_audio_pts_u64(struct class *class,
+                               struct class_attribute *attr, char *buf)
+{
+       struct aml_dvb *dvb = &aml_dvb_device;
+       ssize_t ret = 0;
+
+       u64 pts_val = aml_dmx_get_audio_pts(dvb);
+       pts_val &= 0x00000000FFFFFFFF;
+
+       if (aml_dmx_get_audio_pts_bit32(dvb)) {
+               pts_val = pts_val | (1LL<<32);
+       }
+
+       ret = sprintf(buf, "%llu\n", pts_val);
+
+       return ret;
+}
 
 /*Show the First Video PTS value*/
 static ssize_t demux_show_first_video_pts(struct class *class,
@@ -2027,6 +2064,8 @@ static struct class_attribute aml_stb_class_attrs[] = {
               NULL),
        __ATTR(video_pts_bit32, 0644, demux_show_video_pts_bit32, NULL),
        __ATTR(audio_pts_bit32, 0644, demux_show_audio_pts_bit32, NULL),
+       __ATTR(video_pts_u64, 0644, demux_show_video_pts_u64, NULL),
+       __ATTR(audio_pts_u64, 0644, demux_show_audio_pts_u64, NULL),
        __ATTR(first_video_pts, 0644, demux_show_first_video_pts,
               NULL),
        __ATTR(first_audio_pts, 0644, demux_show_first_audio_pts,
index 0070724d44117b4e4d6d51e45fdfb86582f11b8b..ab2c79f8761a80b53d6692fb9ba40e30accee8f5 100644 (file)
@@ -224,6 +224,11 @@ static int tsdemux_config(void)
 
 static void tsdemux_pcr_set(unsigned int pcr);
 /*TODO irq*/
+/* bit 15 ---------------*/
+/* bit 12 --VIDEO_PTS[32]*/
+/* bit 0  ---------------*/
+/*Read the 13th bit of STB_PTS_DTS_STATUS register
+correspond to the highest bit of video pts*/
 static irqreturn_t tsdemux_isr(int irq, void *dev_id)
 {
        u32 int_status = 0;
@@ -243,11 +248,18 @@ static irqreturn_t tsdemux_isr(int irq, void *dev_id)
        if (int_status & (1 << NEW_PDTS_READY)) {
                if (!enable_demux_driver()) {
                        u32 pdts_status = READ_DEMUX_REG(STB_PTS_DTS_STATUS);
+                       u64 vpts;
+
+                       vpts = READ_MPEG_REG(VIDEO_PTS_DEMUX);
+                       vpts &= 0x00000000FFFFFFFF;
+                       if (pdts_status & 0x1000) {
+                               vpts = vpts | (1LL<<32);
+                       }
 
                        if (pdts_status & (1 << VIDEO_PTS_READY))
-                               pts_checkin_wrptr(PTS_TYPE_VIDEO,
+                               pts_checkin_wrptr_pts33(PTS_TYPE_VIDEO,
                                        READ_DEMUX_REG(VIDEO_PDTS_WR_PTR),
-                                       READ_DEMUX_REG(VIDEO_PTS_DEMUX));
+                                       vpts);
 
                        if (pdts_status & (1 << AUDIO_PTS_READY))
                                pts_checkin_wrptr(PTS_TYPE_AUDIO,
@@ -259,13 +271,18 @@ static irqreturn_t tsdemux_isr(int irq, void *dev_id)
 #define DMX_READ_REG(i, r)\
        ((i) ? ((i == 1) ? READ_DEMUX_REG(r##_2) : \
                READ_DEMUX_REG(r##_3)) : READ_DEMUX_REG(r))
-
+                       u64 vpts;
                        u32 pdts_status = DMX_READ_REG(id, STB_PTS_DTS_STATUS);
+                       vpts = DMX_READ_REG(id, VIDEO_PTS_DEMUX);
+                       vpts &= 0x00000000FFFFFFFF;
+                       if (pdts_status & 0x1000) {
+                               vpts = vpts | (1LL<<32);
+                       }
 
                        if (pdts_status & (1 << VIDEO_PTS_READY))
-                               pts_checkin_wrptr(PTS_TYPE_VIDEO,
+                               pts_checkin_wrptr_pts33(PTS_TYPE_VIDEO,
                                        DMX_READ_REG(id, VIDEO_PDTS_WR_PTR),
-                                       DMX_READ_REG(id, VIDEO_PTS_DEMUX));
+                                       vpts);
 
                        if (pdts_status & (1 << AUDIO_PTS_READY))
                                pts_checkin_wrptr(PTS_TYPE_AUDIO,