[PATCH v5, 12/15] media: mtk-vcodec: Extract H264 common code
AngeloGioacchino Del Regno
angelogioacchino.delregno at collabora.com
Thu Jan 20 15:10:45 UTC 2022
Il 17/01/22 10:39, Yunfei Dong ha scritto:
> Mt8192 can use some of common code with mt8183. Moves them to
> a new file in order to reuse.
>
> Signed-off-by: Yunfei Dong <yunfei.dong at mediatek.com>
> ---
> drivers/media/platform/mtk-vcodec/Makefile | 1 +
> .../mtk-vcodec/vdec/vdec_h264_req_common.c | 307 ++++++++++++++
> .../mtk-vcodec/vdec/vdec_h264_req_common.h | 253 +++++++++++
> .../mtk-vcodec/vdec/vdec_h264_req_if.c | 395 +-----------------
> 4 files changed, 579 insertions(+), 377 deletions(-)
> create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_common.c
> create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_common.h
>
> diff --git a/drivers/media/platform/mtk-vcodec/Makefile b/drivers/media/platform/mtk-vcodec/Makefile
> index 359619653a0e..3f41d748eee5 100644
> --- a/drivers/media/platform/mtk-vcodec/Makefile
> +++ b/drivers/media/platform/mtk-vcodec/Makefile
> @@ -9,6 +9,7 @@ mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
> vdec/vdec_vp8_if.o \
> vdec/vdec_vp9_if.o \
> vdec/vdec_h264_req_if.o \
> + vdec/vdec_h264_req_common.o \
> mtk_vcodec_dec_drv.o \
> vdec_drv_if.o \
> vdec_vpu_if.o \
> diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_common.c b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_common.c
> new file mode 100644
> index 000000000000..90e8c4906e2a
> --- /dev/null
> +++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_common.c
> @@ -0,0 +1,307 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2021 MediaTek Inc.
> + * Author: Yunfei Dong <yunfei.dong at mediatek.com>
> + */
> +
> +#include "vdec_h264_req_common.h"
> +
> +/* get used parameters for sps/pps */
> +#define GET_MTK_VDEC_FLAG(cond, flag) \
> + { dst_param->cond = ((src_param->flags & flag) ? (1) : (0)); }
> +#define GET_MTK_VDEC_PARAM(param) \
> + { dst_param->param = src_param->param; }
> +
> +/*
> + * The firmware expects unused reflist entries to have the value 0x20.
> + */
> +void mtk_vdec_h264_fixup_ref_list(u8 *ref_list, size_t num_valid)
> +{
> + memset(&ref_list[num_valid], 0x20, 32 - num_valid);
> +}
> +
> +void *mtk_vdec_h264_get_ctrl_ptr(struct mtk_vcodec_ctx *ctx, int id)
> +{
> + struct v4l2_ctrl *ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl, id);
> +
Like written in the review for the VP8 driver, please perform a NULL check and
handle the error case properly in the caller...
> + return ctrl->p_cur.p;
> +}
> +
> +void mtk_vdec_h264_fill_dpb_info(struct mtk_vcodec_ctx *ctx,
> + struct slice_api_h264_decode_param *decode_params,
> + mtk_h264_dpb_info *h264_dpb_info)
struct mtk_h264_dpb_info *h264_dpb_info)
^^^^^^
Oops! This typo makes this code unable to be compiled.
> +{
> + struct vb2_queue *vq;
> + struct vb2_buffer *vb;
> + struct vb2_v4l2_buffer *vb2_v4l2;
> + int index;
> +
> + vq = v4l2_m2m_get_vq(ctx->m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
> +
> + for (index = 0; index < V4L2_H264_NUM_DPB_ENTRIES; index++) {
> + const struct slice_h264_dpb_entry *dpb;
> + int vb2_index;
> +
...snip...
> +void mtk_vdec_h264_copy_scaling_matrix(struct slice_api_h264_scaling_matrix *dst_matrix,
> + const struct v4l2_ctrl_h264_scaling_matrix *src_matrix)
> +{
> + memcpy(dst_matrix->scaling_list_4x4, src_matrix->scaling_list_4x4,
> + sizeof(dst_matrix->scaling_list_4x4));
> +
> + memcpy(dst_matrix->scaling_list_8x8, src_matrix->scaling_list_8x8,
> + sizeof(dst_matrix->scaling_list_8x8));
> +}
> +
> +void
> +mtk_vdec_h264_copy_decode_params(struct slice_api_h264_decode_param *dst_params,
> + const struct v4l2_ctrl_h264_decode_params *src_params,
> + const struct v4l2_h264_dpb_entry dpb[V4L2_H264_NUM_DPB_ENTRIES]);
There's another overlook here:
const struct v4l2_h264_dpb_entry *dpb)
> +{
> + int i;
Regards,
Angelo
More information about the dri-devel
mailing list