// SPDX-License-Identifier: GPL-2.0 #include <linux/module.h> #include <linux/slab.h> #include <media/v4l2-mem2mem.h> #include <media/v4l2-h264.h> #include <media/videobuf2-dma-contig.h> #include "../mtk_vcodec_dec.h" #include "../../common/mtk_vcodec_intr.h" #include "../vdec_drv_base.h" #include "../vdec_drv_if.h" #include "../vdec_vpu_if.h" #include "vdec_h264_req_common.h" /* * struct mtk_h264_dec_slice_param - parameters for decode current frame */ struct mtk_h264_dec_slice_param { … }; /** * struct vdec_h264_dec_info - decode information * @dpb_sz : decoding picture buffer size * @resolution_changed : flag to notify that a resolution change happened * @realloc_mv_buf : flag to notify driver to re-allocate mv buffer * @cap_num_planes : number planes of capture buffer * @bs_dma : Input bit-stream buffer dma address * @y_fb_dma : Y frame buffer dma address * @c_fb_dma : C frame buffer dma address * @vdec_fb_va : VDEC frame buffer struct virtual address */ struct vdec_h264_dec_info { … }; /** * struct vdec_h264_vsi - shared memory for decode information exchange * between VPU and Host. * The memory is allocated by VPU then mapping to Host * in vpu_dec_init() and freed in vpu_dec_deinit() * by VPU. * AP-W/R : AP is writer/reader on this item * VPU-W/R: VPU is write/reader on this item * @pred_buf_dma : HW working prediction buffer dma address (AP-W, VPU-R) * @mv_buf_dma : HW working motion vector buffer dma address (AP-W, VPU-R) * @dec : decode information (AP-R, VPU-W) * @pic : picture information (AP-R, VPU-W) * @crop : crop information (AP-R, VPU-W) * @h264_slice_params : the parameters that hardware use to decode */ struct vdec_h264_vsi { … }; /** * struct vdec_h264_slice_inst - h264 decoder instance * @num_nalu : how many nalus be decoded * @ctx : point to mtk_vcodec_dec_ctx * @pred_buf : HW working prediction buffer * @mv_buf : HW working motion vector buffer * @vpu : VPU instance * @vsi_ctx : Local VSI data for this decoding context * @h264_slice_param : the parameters that hardware use to decode * @dpb : decoded picture buffer used to store reference buffer information */ struct vdec_h264_slice_inst { … }; static int get_vdec_decode_parameters(struct vdec_h264_slice_inst *inst) { … } static int allocate_prediction_buf(struct vdec_h264_slice_inst *inst) { … } static void free_prediction_buf(struct vdec_h264_slice_inst *inst) { … } static int alloc_mv_buf(struct vdec_h264_slice_inst *inst, struct vdec_pic_info *pic) { … } static void free_mv_buf(struct vdec_h264_slice_inst *inst) { … } static void get_pic_info(struct vdec_h264_slice_inst *inst, struct vdec_pic_info *pic) { … } static void get_crop_info(struct vdec_h264_slice_inst *inst, struct v4l2_rect *cr) { … } static void get_dpb_size(struct vdec_h264_slice_inst *inst, unsigned int *dpb_sz) { … } static int vdec_h264_slice_init(struct mtk_vcodec_dec_ctx *ctx) { … } static void vdec_h264_slice_deinit(void *h_vdec) { … } static int vdec_h264_slice_decode(void *h_vdec, struct mtk_vcodec_mem *bs, struct vdec_fb *unused, bool *res_chg) { … } static int vdec_h264_slice_get_param(void *h_vdec, enum vdec_get_param_type type, void *out) { … } const struct vdec_common_if vdec_h264_slice_if = …;