Hi Nicolas, Thanks for your advice. On Mon, 2023-09-11 at 11:44 -0400, Nicolas Dufresne wrote: > Hi, > > Le lundi 11 septembre 2023 à 20:59 +0800, Yunfei Dong a écrit : > > The capture buffer has two planes for format MM21, but user space > > only > > allocate secure memory for plane[0], and the size is Y data + uv > > data. > > The driver need to support one plane decoder for svp mode. > > I'm sorry, but in current V4L2 status, you must introduce a new > format. Assuming > the second M means MPLANE, this format would be MT21 (though you > already used > that fourcc for MT21C) ? > Just using the first plane for format MM21 in order to support svp mode according google's suggestion. The plane[1] won't be used to allocate memory. Whether it's better to add one format to support one plane? Not using MM21. Best Regards, Yunfei Dong > Nicolas > > > > > Signed-off-by: Yunfei Dong <yunfei.dong@xxxxxxxxxxxx> > > --- > > .../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 24 ++++++++++++--- > > ---- > > .../vcodec/decoder/mtk_vcodec_dec_stateless.c | 13 ++++++---- > > .../decoder/vdec/vdec_h264_req_common.c | 16 +++++++------ > > .../mediatek/vcodec/decoder/vdec_drv_if.c | 4 ++-- > > 4 files changed, 34 insertions(+), 23 deletions(-) > > > > diff --git > > a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c > > b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c > > index 91ed576d6821..457c3e2979c9 100644 > > --- > > a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c > > +++ > > b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c > > @@ -541,14 +541,15 @@ static int vidioc_vdec_s_fmt(struct file > > *file, void *priv, > > ctx->q_data[MTK_Q_DATA_DST].bytesperline[0] = > > ctx->picinfo.buf_w; > > } else { > > - ctx->q_data[MTK_Q_DATA_DST].sizeimage[0] = > > - ctx->picinfo.fb_sz[0]; > > - ctx->q_data[MTK_Q_DATA_DST].bytesperline[0] = > > - ctx->picinfo.buf_w; > > - ctx->q_data[MTK_Q_DATA_DST].sizeimage[1] = > > - ctx->picinfo.fb_sz[1]; > > - ctx->q_data[MTK_Q_DATA_DST].bytesperline[1] = > > - ctx->picinfo.buf_w; > > + if (ctx->is_svp_mode) > > + ctx- > > >q_data[MTK_Q_DATA_DST].sizeimage[0] = > > + ctx->picinfo.fb_sz[0] + ctx- > > >picinfo.fb_sz[1]; > > + else > > + ctx- > > >q_data[MTK_Q_DATA_DST].sizeimage[0] = ctx->picinfo.fb_sz[0]; > > + > > + ctx->q_data[MTK_Q_DATA_DST].bytesperline[0] = > > ctx->picinfo.buf_w; > > + ctx->q_data[MTK_Q_DATA_DST].sizeimage[1] = ctx- > > >picinfo.fb_sz[1]; > > + ctx->q_data[MTK_Q_DATA_DST].bytesperline[1] = > > ctx->picinfo.buf_w; > > } > > > > ctx->q_data[MTK_Q_DATA_DST].coded_width = ctx- > > >picinfo.buf_w; > > @@ -673,7 +674,12 @@ static int vidioc_vdec_g_fmt(struct file > > *file, void *priv, > > * So we just return picinfo yet, and update picinfo in > > * stop_streaming hook function > > */ > > - q_data->sizeimage[0] = ctx->picinfo.fb_sz[0]; > > + > > + if (ctx->is_svp_mode) > > + q_data->sizeimage[0] = ctx->picinfo.fb_sz[0] + > > ctx->picinfo.fb_sz[1]; > > + else > > + q_data->sizeimage[0] = ctx->picinfo.fb_sz[0]; > > + > > q_data->sizeimage[1] = ctx->picinfo.fb_sz[1]; > > q_data->bytesperline[0] = ctx- > > >last_decoded_picinfo.buf_w; > > q_data->bytesperline[1] = ctx- > > >last_decoded_picinfo.buf_w; > > diff --git > > a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta > > teless.c > > b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta > > teless.c > > index e29c9c58f3da..2ea517883a86 100644 > > --- > > a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta > > teless.c > > +++ > > b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta > > teless.c > > @@ -256,11 +256,12 @@ static struct vdec_fb > > *vdec_get_cap_buffer(struct mtk_vcodec_dec_ctx *ctx) > > framebuf = container_of(vb2_v4l2, struct mtk_video_dec_buf, > > m2m_buf.vb); > > > > pfb = &framebuf->frame_buffer; > > - pfb->base_y.va = vb2_plane_vaddr(dst_buf, 0); > > + if (!ctx->is_svp_mode) > > + pfb->base_y.va = vb2_plane_vaddr(dst_buf, 0); > > pfb->base_y.dma_addr = vb2_dma_contig_plane_dma_addr(dst_buf, > > 0); > > pfb->base_y.size = ctx->q_data[MTK_Q_DATA_DST].sizeimage[0]; > > > > - if (ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes == 2) { > > + if (ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes == 2 && !ctx- > > >is_svp_mode) { > > pfb->base_c.va = vb2_plane_vaddr(dst_buf, 1); > > pfb->base_c.dma_addr = > > vb2_dma_contig_plane_dma_addr(dst_buf, 1); > > @@ -310,16 +311,18 @@ static void mtk_vdec_worker(struct > > work_struct *work) > > mtk_v4l2_vdec_dbg(3, ctx, "[%d] (%d) id=%d, vb=%p", ctx->id, > > vb2_src->vb2_queue->type, vb2_src->index, > > vb2_src); > > > > - bs_src->va = vb2_plane_vaddr(vb2_src, 0); > > - bs_src->dma_addr = vb2_dma_contig_plane_dma_addr(vb2_src, 0); > > - bs_src->size = (size_t)vb2_src->planes[0].bytesused; > > + if (!ctx->is_svp_mode) { > > + bs_src->va = vb2_plane_vaddr(vb2_src, 0); > > if (!bs_src->va) { > > v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx); > > mtk_v4l2_vdec_err(ctx, "[%d] id=%d source buffer is > > NULL", ctx->id, > > vb2_src->index); > > return; > > + } > > } > > > > + bs_src->dma_addr = vb2_dma_contig_plane_dma_addr(vb2_src, 0); > > + bs_src->size = (size_t)vb2_src->planes[0].bytesused; > > mtk_v4l2_vdec_dbg(3, ctx, "[%d] Bitstream VA=%p DMA=%pad > > Size=%zx vb=%p", > > ctx->id, bs_src->va, &bs_src->dma_addr, > > bs_src->size, vb2_src); > > /* Apply request controls. */ > > diff --git > > a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req > > _common.c > > b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req > > _common.c > > index 5ca20d75dc8e..838f0eeea6e2 100644 > > --- > > a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req > > _common.c > > +++ > > b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req > > _common.c > > @@ -81,13 +81,15 @@ void mtk_vdec_h264_fill_dpb_info(struct > > mtk_vcodec_dec_ctx *ctx, > > > > h264_dpb_info[index].y_dma_addr = > > vb2_dma_contig_plane_dma_addr(vb, 0); > > - if (ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes == 2) > > - h264_dpb_info[index].c_dma_addr = > > - vb2_dma_contig_plane_dma_addr(vb, 1); > > - else > > - h264_dpb_info[index].c_dma_addr = > > - h264_dpb_info[index].y_dma_addr + > > - ctx->picinfo.fb_sz[0]; > > + if (!ctx->is_svp_mode) { > > + if (ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes > > == 2) > > + h264_dpb_info[index].c_dma_addr = > > + vb2_dma_contig_plane_dma_addr(v > > b, 1); > > + else > > + h264_dpb_info[index].c_dma_addr = > > + h264_dpb_info[index].y_dma_addr > > + > > + ctx->picinfo.fb_sz[0]; > > + } > > } > > } > > > > diff --git > > a/drivers/media/platform/mediatek/vcodec/decoder/vdec_drv_if.c > > b/drivers/media/platform/mediatek/vcodec/decoder/vdec_drv_if.c > > index d0b459b1603f..c7d33e540a13 100644 > > --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec_drv_if.c > > +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec_drv_if.c > > @@ -73,14 +73,14 @@ int vdec_if_decode(struct mtk_vcodec_dec_ctx > > *ctx, struct mtk_vcodec_mem *bs, > > { > > int ret = 0; > > > > - if (bs) { > > + if (bs && !ctx->is_svp_mode) { > > if ((bs->dma_addr & 63) != 0) { > > mtk_v4l2_vdec_err(ctx, "bs dma_addr should 64 > > byte align"); > > return -EINVAL; > > } > > } > > > > - if (fb) { > > + if (fb && !ctx->is_svp_mode) { > > if (((fb->base_y.dma_addr & 511) != 0) || > > ((fb->base_c.dma_addr & 511) != 0)) { > > mtk_v4l2_vdec_err(ctx, "frame buffer dma_addr > > should 512 byte align"); > >