v4l: fixed the issue of timestamp with the first frame. [1/1]
authorNanxin Qin <nanxin.qin@amlogic.com>
Thu, 11 Jun 2020 09:23:17 +0000 (17:23 +0800)
committerHui Zhang <hui.zhang@amlogic.com>
Tue, 16 Jun 2020 12:15:04 +0000 (05:15 -0700)
PD#SWPL-27740

Problem:
wrong of timestamp with the first frame.

Solution:
the first frame timestamp has not taken into consideration before
therefore caused lost time information on the frame, so must be
pass the timestamp into decoder.

Android P,Q share CL.

Verify:
u212

Change-Id: I79e3f1fa5be6456af024806dd46cdb8dfd3eba42
Signed-off-by: Nanxin Qin <nanxin.qin@amlogic.com>
drivers/amvdec_ports/aml_vcodec_dec.c
drivers/amvdec_ports/aml_vcodec_util.h
drivers/amvdec_ports/decoder/vdec_h264_if.c
drivers/amvdec_ports/decoder/vdec_hevc_if.c
drivers/amvdec_ports/decoder/vdec_mjpeg_if.c
drivers/amvdec_ports/decoder/vdec_mpeg12_if.c
drivers/amvdec_ports/decoder/vdec_mpeg4_if.c
drivers/amvdec_ports/decoder/vdec_vp9_if.c
drivers/amvdec_ports/vdec_drv_base.h
drivers/amvdec_ports/vdec_drv_if.c
drivers/amvdec_ports/vdec_drv_if.h

index bf600ca23bdf56fb87c7ff0c5e6baf80a1529d5c..bb6eee455b4c3f8a072b5e83a0eca0390efa4b42 100644 (file)
@@ -824,6 +824,7 @@ static void aml_vdec_worker(struct work_struct *work)
        buf.addr        = vb2_dma_contig_plane_dma_addr(src_buf, 0);
        buf.size        = src_buf->planes[0].bytesused;
        buf.model       = src_buf->memory;
+       buf.timestamp   = src_buf->timestamp;
 
        if (!buf.vaddr && !buf.addr) {
                v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
@@ -842,7 +843,7 @@ static void aml_vdec_worker(struct work_struct *work)
        /*v4l_dbg(ctx, V4L_DEBUG_CODEC_EXINFO,
                "timestamp: 0x%llx\n", src_buf->timestamp);*/
 
-       ret = vdec_if_decode(ctx, &buf, src_buf->timestamp, &res_chg);
+       ret = vdec_if_decode(ctx, &buf, &res_chg);
        if (ret > 0) {
                /*
                 * we only return src buffer with VB2_BUF_STATE_DONE
@@ -2044,9 +2045,9 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb)
        buf = container_of(vb2_v4l2, struct aml_video_dec_buf, vb);
 
        v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT,
-               "%s, vb: %lx, type: %d, idx: %d, state: %d, used: %d\n",
+               "%s, vb: %lx, type: %d, idx: %d, state: %d, used: %d, ts: %llu\n",
                __func__, (ulong) vb, vb->vb2_queue->type,
-               vb->index, vb->state, buf->used);
+               vb->index, vb->state, buf->used, vb->timestamp);
        /*
         * check if this buffer is ready to be used after decode
         */
@@ -2112,6 +2113,7 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb)
        src_mem.addr    = vb2_dma_contig_plane_dma_addr(vb, 0);
        src_mem.size    = vb->planes[0].bytesused;
        src_mem.model   = vb->memory;
+       src_mem.timestamp = vb->timestamp;
 
        if (vdec_if_probe(ctx, &src_mem, NULL)) {
                v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
index 8e479a6e0a8af26ba99d0257147ec910c1a0f243..312ee406d986ad8628faabadc8a5725ac8b38ef5 100644 (file)
@@ -44,6 +44,7 @@ struct aml_vcodec_mem {
        void    *vaddr;
        u32     bytes_used;
        u32     offset;
+       u64     timestamp;
        dma_addr_t dma_addr;
        u32     model;
 };
index 40cbeb8578eada2eba4c932c647cf1a0c0297423..aaef30322f1fd944aac54f78225ccd6a92a03bdf 100644 (file)
@@ -561,12 +561,13 @@ static int vdec_search_startcode(u8 *buf, u32 range)
        return pos;
 }
 
-static int parse_stream_ucode(struct vdec_h264_inst *inst, u8 *buf, u32 size)
+static int parse_stream_ucode(struct vdec_h264_inst *inst,
+                             u8 *buf, u32 size, u64 timestamp)
 {
        int ret = 0;
        struct aml_vdec_adapt *vdec = &inst->vdec;
 
-       ret = vdec_vframe_write(vdec, buf, size, 0);
+       ret = vdec_vframe_write(vdec, buf, size, timestamp);
        if (ret < 0) {
                v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
                        "write frame data failed. err: %d\n", ret);
@@ -581,12 +582,12 @@ static int parse_stream_ucode(struct vdec_h264_inst *inst, u8 *buf, u32 size)
 }
 
 static int parse_stream_ucode_dma(struct vdec_h264_inst *inst,
-       ulong buf, u32 size, u32 handle)
+       ulong buf, u32 size, u64 timestamp, u32 handle)
 {
        int ret = 0;
        struct aml_vdec_adapt *vdec = &inst->vdec;
 
-       ret = vdec_vframe_write_with_dma(vdec, buf, size, 0, handle);
+       ret = vdec_vframe_write_with_dma(vdec, buf, size, timestamp, handle);
        if (ret < 0) {
                v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
                        "write frame data failed. err: %d\n", ret);
@@ -655,7 +656,8 @@ static int vdec_h264_probe(unsigned long h_vdec,
                                return -1;
 
                        if (inst->ctx->param_sets_from_ucode) {
-                               ret = parse_stream_ucode(inst, s->data, s->len);
+                               ret = parse_stream_ucode(inst, s->data,
+                                       s->len, bs->timestamp);
                        } else {
                                skip_aud_data((u8 **)&s->data, &s->len);
                                ret = parse_stream_cpu(inst, s->data, s->len);
@@ -663,11 +665,11 @@ static int vdec_h264_probe(unsigned long h_vdec,
                } else if (bs->model == VB2_MEMORY_DMABUF ||
                        bs->model == VB2_MEMORY_USERPTR) {
                        ret = parse_stream_ucode_dma(inst, bs->addr, size,
-                               BUFF_IDX(bs, bs->index));
+                               bs->timestamp, BUFF_IDX(bs, bs->index));
                }
        } else {
                if (inst->ctx->param_sets_from_ucode) {
-                       ret = parse_stream_ucode(inst, buf, size);
+                       ret = parse_stream_ucode(inst, buf, size, bs->timestamp);
                } else {
                        skip_aud_data(&buf, &size);
                        ret = parse_stream_cpu(inst, buf, size);
@@ -866,8 +868,8 @@ static bool monitor_res_change(struct vdec_h264_inst *inst, u8 *buf, u32 size)
        return false;
 }
 
-static int vdec_h264_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs,
-                        u64 timestamp, bool *res_chg)
+static int vdec_h264_decode(unsigned long h_vdec,
+                           struct aml_vcodec_mem *bs, bool *res_chg)
 {
        struct vdec_h264_inst *inst = (struct vdec_h264_inst *)h_vdec;
        struct aml_vdec_adapt *vdec = &inst->vdec;
@@ -899,11 +901,11 @@ static int vdec_h264_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs,
                        ret = vdec_vframe_write(vdec,
                                s->data,
                                s->len,
-                               timestamp);
+                               bs->timestamp);
                } else if (bs->model == VB2_MEMORY_DMABUF ||
                        bs->model == VB2_MEMORY_USERPTR) {
                        ret = vdec_vframe_write_with_dma(vdec,
-                               bs->addr, size, timestamp,
+                               bs->addr, size, bs->timestamp,
                                BUFF_IDX(bs, bs->index));
                }
        } else {
@@ -919,7 +921,7 @@ static int vdec_h264_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs,
                                return 0;
                        }
                }
-               ret = vdec_write_nalu(inst, buf, size, timestamp);
+               ret = vdec_write_nalu(inst, buf, size, bs->timestamp);
        }
 
        return ret;
index 10c6b48e1211aa74ad0a60064c3469e14faae87e..12c4ccff57c50bb8333f7ea43b69f3699c8b2126 100644 (file)
@@ -409,12 +409,13 @@ static void fill_vdec_params(struct vdec_hevc_inst *inst, struct h265_SPS_t *sps
                dec->dpb_sz - margin, margin);
 }
 
-static int parse_stream_ucode(struct vdec_hevc_inst *inst, u8 *buf, u32 size)
+static int parse_stream_ucode(struct vdec_hevc_inst *inst,
+                             u8 *buf, u32 size, u64 timestamp)
 {
        int ret = 0;
        struct aml_vdec_adapt *vdec = &inst->vdec;
 
-       ret = vdec_vframe_write(vdec, buf, size, 0);
+       ret = vdec_vframe_write(vdec, buf, size, timestamp);
        if (ret < 0) {
                v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
                        "write frame data failed. err: %d\n", ret);
@@ -429,12 +430,12 @@ static int parse_stream_ucode(struct vdec_hevc_inst *inst, u8 *buf, u32 size)
 }
 
 static int parse_stream_ucode_dma(struct vdec_hevc_inst *inst,
-       ulong buf, u32 size, u32 handle)
+       ulong buf, u32 size, u64 timestamp, u32 handle)
 {
        int ret = 0;
        struct aml_vdec_adapt *vdec = &inst->vdec;
 
-       ret = vdec_vframe_write_with_dma(vdec, buf, size, 0, handle);
+       ret = vdec_vframe_write_with_dma(vdec, buf, size, timestamp, handle);
        if (ret < 0) {
                v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
                        "write frame data failed. err: %d\n", ret);
@@ -493,18 +494,19 @@ static int vdec_hevc_probe(unsigned long h_vdec,
                                return -1;
 
                        if (inst->ctx->param_sets_from_ucode) {
-                               ret = parse_stream_ucode(inst, s->data, s->len);
+                               ret = parse_stream_ucode(inst, s->data,
+                                       s->len, bs->timestamp);
                        } else {
                                ret = parse_stream_cpu(inst, s->data, s->len);
                        }
                } else if (bs->model == VB2_MEMORY_DMABUF ||
                        bs->model == VB2_MEMORY_USERPTR) {
                        ret = parse_stream_ucode_dma(inst, bs->addr, size,
-                               BUFF_IDX(bs, bs->index));
+                               bs->timestamp, BUFF_IDX(bs, bs->index));
                }
        } else {
                if (inst->ctx->param_sets_from_ucode) {
-                       ret = parse_stream_ucode(inst, buf, size);
+                       ret = parse_stream_ucode(inst, buf, size, bs->timestamp);
                } else {
                        ret = parse_stream_cpu(inst, buf, size);
                }
@@ -630,8 +632,8 @@ static bool monitor_res_change(struct vdec_hevc_inst *inst, u8 *buf, u32 size)
        return false;
 }
 
-static int vdec_hevc_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs,
-                        u64 timestamp, bool *res_chg)
+static int vdec_hevc_decode(unsigned long h_vdec,
+                           struct aml_vcodec_mem *bs, bool *res_chg)
 {
        struct vdec_hevc_inst *inst = (struct vdec_hevc_inst *)h_vdec;
        struct aml_vdec_adapt *vdec = &inst->vdec;
@@ -663,11 +665,11 @@ static int vdec_hevc_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs,
                        ret = vdec_vframe_write(vdec,
                                s->data,
                                s->len,
-                               timestamp);
+                               bs->timestamp);
                } else if (bs->model == VB2_MEMORY_DMABUF ||
                        bs->model == VB2_MEMORY_USERPTR) {
                        ret = vdec_vframe_write_with_dma(vdec,
-                               bs->addr, size, timestamp,
+                               bs->addr, size, bs->timestamp,
                                BUFF_IDX(bs, bs->index));
                }
        } else {
@@ -676,7 +678,7 @@ static int vdec_hevc_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs,
                        if ((*res_chg = monitor_res_change(inst, buf, size)))
                                return 0;
                }
-               ret = vdec_write_nalu(inst, buf, size, timestamp);
+               ret = vdec_write_nalu(inst, buf, size, bs->timestamp);
        }
 
        return ret;
index 4e1082809d492e5f83db06b88849a11e4c893566..4ede6b5ebcc320f6233b5cbc455913dc04848b4b 100644 (file)
@@ -277,12 +277,13 @@ static void fill_vdec_params(struct vdec_mjpeg_inst *inst,
                pic->visible_width, pic->visible_height, dec->dpb_sz);
 }
 
-static int parse_stream_ucode(struct vdec_mjpeg_inst *inst, u8 *buf, u32 size)
+static int parse_stream_ucode(struct vdec_mjpeg_inst *inst,
+                             u8 *buf, u32 size, u64 timestamp)
 {
        int ret = 0;
        struct aml_vdec_adapt *vdec = &inst->vdec;
 
-       ret = vdec_vframe_write(vdec, buf, size, 0);
+       ret = vdec_vframe_write(vdec, buf, size, timestamp);
        if (ret < 0) {
                v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
                        "write frame data failed. err: %d\n", ret);
@@ -297,12 +298,12 @@ static int parse_stream_ucode(struct vdec_mjpeg_inst *inst, u8 *buf, u32 size)
 }
 
 static int parse_stream_ucode_dma(struct vdec_mjpeg_inst *inst,
-       ulong buf, u32 size, u32 handle)
+       ulong buf, u32 size, u64 timestamp, u32 handle)
 {
        int ret = 0;
        struct aml_vdec_adapt *vdec = &inst->vdec;
 
-       ret = vdec_vframe_write_with_dma(vdec, buf, size, 0, handle);
+       ret = vdec_vframe_write_with_dma(vdec, buf, size, timestamp, handle);
        if (ret < 0) {
                v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
                        "write frame data failed. err: %d\n", ret);
@@ -361,18 +362,19 @@ static int vdec_mjpeg_probe(unsigned long h_vdec,
                                return -1;
 
                        if (inst->ctx->param_sets_from_ucode) {
-                               ret = parse_stream_ucode(inst, s->data, s->len);
+                               ret = parse_stream_ucode(inst, s->data,
+                                       s->len, bs->timestamp);
                        } else {
                                ret = parse_stream_cpu(inst, s->data, s->len);
                        }
                } else if (bs->model == VB2_MEMORY_DMABUF ||
                        bs->model == VB2_MEMORY_USERPTR) {
                        ret = parse_stream_ucode_dma(inst, bs->addr, size,
-                               BUFF_IDX(bs, bs->index));
+                               bs->timestamp, BUFF_IDX(bs, bs->index));
                }
        } else {
                if (inst->ctx->param_sets_from_ucode) {
-                       ret = parse_stream_ucode(inst, buf, size);
+                       ret = parse_stream_ucode(inst, buf, size, bs->timestamp);
                } else {
                        ret = parse_stream_cpu(inst, buf, size);
                }
@@ -458,8 +460,8 @@ static int vdec_write_nalu(struct vdec_mjpeg_inst *inst,
        return ret;
 }
 
-static int vdec_mjpeg_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs,
-                        u64 timestamp, bool *res_chg)
+static int vdec_mjpeg_decode(unsigned long h_vdec,
+                            struct aml_vcodec_mem *bs, bool *res_chg)
 {
        struct vdec_mjpeg_inst *inst = (struct vdec_mjpeg_inst *)h_vdec;
        struct aml_vdec_adapt *vdec = &inst->vdec;
@@ -481,15 +483,15 @@ static int vdec_mjpeg_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs,
                        ret = vdec_vframe_write(vdec,
                                s->data,
                                s->len,
-                               timestamp);
+                               bs->timestamp);
                } else if (bs->model == VB2_MEMORY_DMABUF ||
                        bs->model == VB2_MEMORY_USERPTR) {
                        ret = vdec_vframe_write_with_dma(vdec,
-                               bs->addr, size, timestamp,
+                               bs->addr, size, bs->timestamp,
                                BUFF_IDX(bs, bs->index));
                }
        } else {
-               ret = vdec_write_nalu(inst, buf, size, timestamp);
+               ret = vdec_write_nalu(inst, buf, size, bs->timestamp);
        }
 
        return ret;
index b5b128bc1191ca023fac5c6337aade8b210e1807..7401be420b2313ccc43811fb89aef4d08c28205b 100644 (file)
@@ -296,12 +296,13 @@ static void fill_vdec_params(struct vdec_mpeg12_inst *inst,
                pic->visible_width, pic->visible_height, dec->dpb_sz);
 }
 
-static int parse_stream_ucode(struct vdec_mpeg12_inst *inst, u8 *buf, u32 size)
+static int parse_stream_ucode(struct vdec_mpeg12_inst *inst,
+                             u8 *buf, u32 size, u64 timestamp)
 {
        int ret = 0;
        struct aml_vdec_adapt *vdec = &inst->vdec;
 
-       ret = vdec_vframe_write(vdec, buf, size, 0);
+       ret = vdec_vframe_write(vdec, buf, size, timestamp);
        if (ret < 0) {
                v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
                        "write frame data failed. err: %d\n", ret);
@@ -316,12 +317,12 @@ static int parse_stream_ucode(struct vdec_mpeg12_inst *inst, u8 *buf, u32 size)
 }
 
 static int parse_stream_ucode_dma(struct vdec_mpeg12_inst *inst,
-       ulong buf, u32 size, u32 handle)
+       ulong buf, u32 size, u64 timestamp, u32 handle)
 {
        int ret = 0;
        struct aml_vdec_adapt *vdec = &inst->vdec;
 
-       ret = vdec_vframe_write_with_dma(vdec, buf, size, 0, handle);
+       ret = vdec_vframe_write_with_dma(vdec, buf, size, timestamp, handle);
        if (ret < 0) {
                v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
                        "write frame data failed. err: %d\n", ret);
@@ -380,18 +381,19 @@ static int vdec_mpeg12_probe(unsigned long h_vdec,
                                return -1;
 
                        if (inst->ctx->param_sets_from_ucode) {
-                               ret = parse_stream_ucode(inst, s->data, s->len);
+                               ret = parse_stream_ucode(inst, s->data,
+                                       s->len, bs->timestamp);
                        } else {
                                ret = parse_stream_cpu(inst, s->data, s->len);
                        }
                } else if (bs->model == VB2_MEMORY_DMABUF ||
                        bs->model == VB2_MEMORY_USERPTR) {
                        ret = parse_stream_ucode_dma(inst, bs->addr, size,
-                               BUFF_IDX(bs, bs->index));
+                               bs->timestamp, BUFF_IDX(bs, bs->index));
                }
        } else {
                if (inst->ctx->param_sets_from_ucode) {
-                       ret = parse_stream_ucode(inst, buf, size);
+                       ret = parse_stream_ucode(inst, buf, size, bs->timestamp);
                } else {
                        ret = parse_stream_cpu(inst, buf, size);
                }
@@ -477,8 +479,8 @@ static int vdec_write_nalu(struct vdec_mpeg12_inst *inst,
        return ret;
 }
 
-static int vdec_mpeg12_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs,
-                        u64 timestamp, bool *res_chg)
+static int vdec_mpeg12_decode(unsigned long h_vdec,
+                             struct aml_vcodec_mem *bs, bool *res_chg)
 {
        struct vdec_mpeg12_inst *inst = (struct vdec_mpeg12_inst *)h_vdec;
        struct aml_vdec_adapt *vdec = &inst->vdec;
@@ -500,15 +502,15 @@ static int vdec_mpeg12_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs,
                        ret = vdec_vframe_write(vdec,
                                s->data,
                                s->len,
-                               timestamp);
+                               bs->timestamp);
                } else if (bs->model == VB2_MEMORY_DMABUF ||
                        bs->model == VB2_MEMORY_USERPTR) {
                        ret = vdec_vframe_write_with_dma(vdec,
-                               bs->addr, size, timestamp,
+                               bs->addr, size, bs->timestamp,
                                BUFF_IDX(bs, bs->index));
                }
        } else {
-               ret = vdec_write_nalu(inst, buf, size, timestamp);
+               ret = vdec_write_nalu(inst, buf, size, bs->timestamp);
        }
 
        return ret;
index 4bc945ef009a601efa98ac7181e86b88dc34898a..b0f9d6c1fa64e2eafad66c278be020365cc8b911 100644 (file)
@@ -306,12 +306,13 @@ static void fill_vdec_params(struct vdec_mpeg4_inst *inst,
                pic->visible_width, pic->visible_height, dec->dpb_sz);
 }
 
-static int parse_stream_ucode(struct vdec_mpeg4_inst *inst, u8 *buf, u32 size)
+static int parse_stream_ucode(struct vdec_mpeg4_inst *inst,
+                            u8 *buf, u32 size, u64 timestamp)
 {
        int ret = 0;
        struct aml_vdec_adapt *vdec = &inst->vdec;
 
-       ret = vdec_vframe_write(vdec, buf, size, 0);
+       ret = vdec_vframe_write(vdec, buf, size, timestamp);
        if (ret < 0) {
                v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
                        "write frame data failed. err: %d\n", ret);
@@ -326,12 +327,12 @@ static int parse_stream_ucode(struct vdec_mpeg4_inst *inst, u8 *buf, u32 size)
 }
 
 static int parse_stream_ucode_dma(struct vdec_mpeg4_inst *inst,
-       ulong buf, u32 size, u32 handle)
+       ulong buf, u32 size, u64 timestamp, u32 handle)
 {
        int ret = 0;
        struct aml_vdec_adapt *vdec = &inst->vdec;
 
-       ret = vdec_vframe_write_with_dma(vdec, buf, size, 0, handle);
+       ret = vdec_vframe_write_with_dma(vdec, buf, size, timestamp, handle);
        if (ret < 0) {
                v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
                        "write frame data failed. err: %d\n", ret);
@@ -390,18 +391,19 @@ static int vdec_mpeg4_probe(unsigned long h_vdec,
                                return -1;
 
                        if (inst->ctx->param_sets_from_ucode) {
-                               ret = parse_stream_ucode(inst, s->data, s->len);
+                               ret = parse_stream_ucode(inst, s->data,
+                                       s->len, bs->timestamp);
                        } else {
                                ret = parse_stream_cpu(inst, s->data, s->len);
                        }
                } else if (bs->model == VB2_MEMORY_DMABUF ||
                        bs->model == VB2_MEMORY_USERPTR) {
                        ret = parse_stream_ucode_dma(inst, bs->addr, size,
-                               BUFF_IDX(bs, bs->index));
+                               bs->timestamp, BUFF_IDX(bs, bs->index));
                }
        } else {
                if (inst->ctx->param_sets_from_ucode) {
-                       ret = parse_stream_ucode(inst, buf, size);
+                       ret = parse_stream_ucode(inst, buf, size, bs->timestamp);
                } else {
                        ret = parse_stream_cpu(inst, buf, size);
                }
@@ -487,8 +489,8 @@ static int vdec_write_nalu(struct vdec_mpeg4_inst *inst,
        return ret;
 }
 
-static int vdec_mpeg4_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs,
-                        u64 timestamp, bool *res_chg)
+static int vdec_mpeg4_decode(unsigned long h_vdec,
+                            struct aml_vcodec_mem *bs, bool *res_chg)
 {
        struct vdec_mpeg4_inst *inst = (struct vdec_mpeg4_inst *)h_vdec;
        struct aml_vdec_adapt *vdec = &inst->vdec;
@@ -510,15 +512,15 @@ static int vdec_mpeg4_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs,
                        ret = vdec_vframe_write(vdec,
                                s->data,
                                s->len,
-                               timestamp);
+                               bs->timestamp);
                } else if (bs->model == VB2_MEMORY_DMABUF ||
                        bs->model == VB2_MEMORY_USERPTR) {
                        ret = vdec_vframe_write_with_dma(vdec,
-                               bs->addr, size, timestamp,
+                               bs->addr, size, bs->timestamp,
                                BUFF_IDX(bs, bs->index));
                }
        } else {
-               ret = vdec_write_nalu(inst, buf, size, timestamp);
+               ret = vdec_write_nalu(inst, buf, size, bs->timestamp);
        }
 
        return ret;
index 9882b4765fe2440f162f75a7e68d3fa0acf0a959..ec9ce64ce4b5e5f765f7e6549caa095622a3bb43 100644 (file)
@@ -439,11 +439,12 @@ static void fill_vdec_params(struct vdec_vp9_inst *inst,
                dec->dpb_sz - margin, margin);
 }
 
-static int parse_stream_ucode(struct vdec_vp9_inst *inst, u8 *buf, u32 size)
+static int parse_stream_ucode(struct vdec_vp9_inst *inst,
+                             u8 *buf, u32 size, u64 timestamp)
 {
        int ret = 0;
 
-       ret = vdec_write_nalu(inst, buf, size, 0);
+       ret = vdec_write_nalu(inst, buf, size, timestamp);
        if (ret < 0) {
                v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
                        "write frame data failed. err: %d\n", ret);
@@ -458,12 +459,12 @@ static int parse_stream_ucode(struct vdec_vp9_inst *inst, u8 *buf, u32 size)
 }
 
 static int parse_stream_ucode_dma(struct vdec_vp9_inst *inst,
-       ulong buf, u32 size, u32 handle)
+       ulong buf, u32 size, u64 timestamp, u32 handle)
 {
        int ret = 0;
        struct aml_vdec_adapt *vdec = &inst->vdec;
 
-       ret = vdec_vframe_write_with_dma(vdec, buf, size, 0, handle);
+       ret = vdec_vframe_write_with_dma(vdec, buf, size, timestamp, handle);
        if (ret < 0) {
                v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
                        "write frame data failed. err: %d\n", ret);
@@ -522,18 +523,19 @@ static int vdec_vp9_probe(unsigned long h_vdec,
                                return -1;
 
                        if (inst->ctx->param_sets_from_ucode) {
-                               ret = parse_stream_ucode(inst, s->data, s->len);
+                               ret = parse_stream_ucode(inst, s->data,
+                                       s->len, bs->timestamp);
                        } else {
                                ret = parse_stream_cpu(inst, s->data, s->len);
                        }
                } else if (bs->model == VB2_MEMORY_DMABUF ||
                        bs->model == VB2_MEMORY_USERPTR) {
                        ret = parse_stream_ucode_dma(inst, bs->addr, size,
-                               BUFF_IDX(bs, bs->index));
+                               bs->timestamp, BUFF_IDX(bs, bs->index));
                }
        } else {
                if (inst->ctx->param_sets_from_ucode) {
-                       ret = parse_stream_ucode(inst, buf, size);
+                       ret = parse_stream_ucode(inst, buf, size, bs->timestamp);
                } else {
                        ret = parse_stream_cpu(inst, buf, size);
                }
@@ -746,8 +748,8 @@ static bool monitor_res_change(struct vdec_vp9_inst *inst, u8 *buf, u32 size)
        return false;
 }
 
-static int vdec_vp9_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs,
-                        u64 timestamp, bool *res_chg)
+static int vdec_vp9_decode(unsigned long h_vdec,
+                          struct aml_vcodec_mem *bs, bool *res_chg)
 {
        struct vdec_vp9_inst *inst = (struct vdec_vp9_inst *)h_vdec;
        struct aml_vdec_adapt *vdec = &inst->vdec;
@@ -781,11 +783,11 @@ static int vdec_vp9_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs,
                        ret = vdec_vframe_write(vdec,
                                s->data,
                                s->len,
-                               timestamp);
+                               bs->timestamp);
                } else if (bs->model == VB2_MEMORY_DMABUF ||
                        bs->model == VB2_MEMORY_USERPTR) {
                        ret = vdec_vframe_write_with_dma(vdec,
-                               bs->addr, size, timestamp,
+                               bs->addr, size, bs->timestamp,
                                BUFF_IDX(bs, bs->index));
                }
        } else {
@@ -794,7 +796,7 @@ static int vdec_vp9_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs,
                        (*res_chg = monitor_res_change(inst, buf, size)))
                        return 0;
 
-               ret = vdec_write_nalu(inst, buf, size, timestamp);
+               ret = vdec_write_nalu(inst, buf, size, bs->timestamp);
        }
        ATRACE_COUNTER("v4l2_decode_write", ret);
 
index e192b203a6f22b302d2dea4eb8775fd545f92dec..990d4060a61966de075d61dc0a2be994a4ae261c 100644 (file)
@@ -43,7 +43,7 @@ struct vdec_common_if {
         * @res_chg : [out] resolution change happen
         */
        int (*decode)(unsigned long h_vdec, struct aml_vcodec_mem *bs,
-               u64 pts, bool *res_chg);
+               bool *res_chg);
 
        /**
         * (*get_param)() - get driver's parameter
index e870da44dd848c325ec1fb06c9646813ba63c372..3be48b9783e9fa66ac25bca647bfe9610ee26de3 100644 (file)
@@ -76,8 +76,8 @@ int vdec_if_probe(struct aml_vcodec_ctx *ctx,
        return ret;
 }
 
-int vdec_if_decode(struct aml_vcodec_ctx *ctx, struct aml_vcodec_mem *bs,
-       u64 timestamp, bool *res_chg)
+int vdec_if_decode(struct aml_vcodec_ctx *ctx,
+                  struct aml_vcodec_mem *bs, bool *res_chg)
 {
        int ret = 0;
 
@@ -93,7 +93,7 @@ int vdec_if_decode(struct aml_vcodec_ctx *ctx, struct aml_vcodec_mem *bs,
                return -EIO;
 
        aml_vcodec_set_curr_ctx(ctx->dev, ctx);
-       ret = ctx->dec_if->decode(ctx->drv_handle, bs, timestamp, res_chg);
+       ret = ctx->dec_if->decode(ctx->drv_handle, bs, res_chg);
        aml_vcodec_set_curr_ctx(ctx->dev, NULL);
 
        return ret;
index 579e499cdcfa6a42c791fb8df93f812f690c5c1c..a04d832795241b9c5f3201cd3c045a7637531bd7 100644 (file)
@@ -129,8 +129,8 @@ void vdec_if_deinit(struct aml_vcodec_ctx *ctx);
  *
  * Return: 0 on success. -EIO on unrecoverable error.
  */
-int vdec_if_decode(struct aml_vcodec_ctx *ctx, struct aml_vcodec_mem *bs,
-                       u64 timestamp, bool *res_chg);
+int vdec_if_decode(struct aml_vcodec_ctx *ctx,
+                  struct aml_vcodec_mem *bs, bool *res_chg);
 
 /**
  * vdec_if_get_param() - get driver's parameter