From 8bb1632e6ab25288e2b7b0f28066bcd6d79263bc Mon Sep 17 00:00:00 2001 From: zihaoling Date: Thu, 23 Apr 2020 17:04:08 +0800 Subject: [PATCH] stream_input: wrong pts value is displayed in sys file [3/4] 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 --- drivers/stream_input/amports/amstream.c | 6 +++ .../stream_input/parser/hw_demux/aml_dvb.c | 39 +++++++++++++++++++ drivers/stream_input/parser/tsdemux.c | 27 ++++++++++--- 3 files changed, 67 insertions(+), 5 deletions(-) diff --git a/drivers/stream_input/amports/amstream.c b/drivers/stream_input/amports/amstream.c index c15c6a5..fbf6517 100644 --- a/drivers/stream_input/amports/amstream.c +++ b/drivers/stream_input/amports/amstream.c @@ -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; diff --git a/drivers/stream_input/parser/hw_demux/aml_dvb.c b/drivers/stream_input/parser/hw_demux/aml_dvb.c index fd80a3e..114d422 100644 --- a/drivers/stream_input/parser/hw_demux/aml_dvb.c +++ b/drivers/stream_input/parser/hw_demux/aml_dvb.c @@ -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, diff --git a/drivers/stream_input/parser/tsdemux.c b/drivers/stream_input/parser/tsdemux.c index 0070724..ab2c79f 100644 --- a/drivers/stream_input/parser/tsdemux.c +++ b/drivers/stream_input/parser/tsdemux.c @@ -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, -- 2.20.1