[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4ff89457cbcc0582d312c8af919dab7a16b1943b.camel@collabora.com>
Date: Mon, 11 Sep 2023 11:44:37 -0400
From: Nicolas Dufresne <nicolas.dufresne@...labora.com>
To: Yunfei Dong <yunfei.dong@...iatek.com>,
Nícolas "F . R . A . Prado"
<nfraprado@...labora.com>, Hans Verkuil <hverkuil-cisco@...all.nl>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>,
Benjamin Gaignard <benjamin.gaignard@...labora.com>,
Nathan Hebert <nhebert@...omium.org>
Cc: Chen-Yu Tsai <wenst@...omium.org>,
Hsin-Yi Wang <hsinyi@...omium.org>,
Fritz Koenig <frkoenig@...omium.org>,
Daniel Vetter <daniel@...ll.ch>,
Steve Cho <stevecho@...omium.org>, linux-media@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org,
Project_Global_Chrome_Upstream_Group@...iatek.com
Subject: Re: [PATCH 08/14] media: medkatek: vcodec: support one plane
capture buffer
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) ?
Nicolas
>
> Signed-off-by: Yunfei Dong <yunfei.dong@...iatek.com>
> ---
> .../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_stateless.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c
> index e29c9c58f3da..2ea517883a86 100644
> --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c
> +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.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(vb, 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");
Powered by blists - more mailing lists