linux/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2021 MediaTek Inc.
 * Author: George Sun <[email protected]>
 */

#include <linux/module.h>
#include <linux/slab.h>
#include <media/videobuf2-dma-contig.h>
#include <media/v4l2-vp9.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"

/* reset_frame_context defined in VP9 spec */
#define VP9_RESET_FRAME_CONTEXT_NONE0
#define VP9_RESET_FRAME_CONTEXT_NONE1
#define VP9_RESET_FRAME_CONTEXT_SPEC
#define VP9_RESET_FRAME_CONTEXT_ALL

#define VP9_TILE_BUF_SIZE
#define VP9_PROB_BUF_SIZE
#define VP9_COUNTS_BUF_SIZE

#define HDR_FLAG(x)
#define LF_FLAG(x)
#define SEG_FLAG(x)
#define VP9_BAND_6(band)

/*
 * struct vdec_vp9_slice_frame_ctx - vp9 prob tables footprint
 */
struct vdec_vp9_slice_frame_ctx {};

/*
 * struct vdec_vp9_slice_frame_counts - vp9 counts tables footprint
 */
struct vdec_vp9_slice_frame_counts {};

/**
 * struct vdec_vp9_slice_counts_map - vp9 counts tables to map
 *                                    v4l2_vp9_frame_symbol_counts
 * @skip:	skip counts.
 * @y_mode:	Y prediction mode counts.
 * @filter:	interpolation filter counts.
 * @sign:	motion vector sign counts.
 * @classes:	motion vector class counts.
 * @class0:	motion vector class0 bit counts.
 * @bits:	motion vector bits counts.
 * @class0_fp:	motion vector class0 fractional bit counts.
 * @fp:	motion vector fractional bit counts.
 * @class0_hp:	motion vector class0 high precision fractional bit counts.
 * @hp:	motion vector high precision fractional bit counts.
 */
struct vdec_vp9_slice_counts_map {};

/*
 * struct vdec_vp9_slice_uncompressed_header - vp9 uncompressed header syntax
 *                                             used for decoding
 */
struct vdec_vp9_slice_uncompressed_header {};

/*
 * struct vdec_vp9_slice_compressed_header - vp9 compressed header syntax
 *                                           used for decoding.
 */
struct vdec_vp9_slice_compressed_header {};

/*
 * struct vdec_vp9_slice_tiles - vp9 tile syntax
 */
struct vdec_vp9_slice_tiles {};

/*
 * struct vdec_vp9_slice_reference - vp9 reference frame information
 */
struct vdec_vp9_slice_reference {};

/*
 * struct vdec_vp9_slice_frame - vp9 syntax used for decoding
 */
struct vdec_vp9_slice_frame {};

/*
 * struct vdec_vp9_slice_init_vsi - VSI used to initialize instance
 */
struct vdec_vp9_slice_init_vsi {};

/*
 * struct vdec_vp9_slice_mem - memory address and size
 */
struct vdec_vp9_slice_mem {};

/*
 * struct vdec_vp9_slice_bs - input buffer for decoding
 */
struct vdec_vp9_slice_bs {};

/*
 * struct vdec_vp9_slice_fb - frame buffer for decoding
 */
struct vdec_vp9_slice_fb {};

/*
 * struct vdec_vp9_slice_state - decoding state
 */
struct vdec_vp9_slice_state {};

/**
 * struct vdec_vp9_slice_vsi - exchange decoding information
 *                             between Main CPU and MicroP
 *
 * @bs:	input buffer
 * @fb:	output buffer
 * @ref:	3 reference buffers
 * @mv:	mv working buffer
 * @seg:	segmentation working buffer
 * @tile:	tile buffer
 * @prob:	prob table buffer, used to set/update prob table
 * @counts:	counts table buffer, used to update prob table
 * @ube:	general buffer
 * @trans:	trans buffer position in general buffer
 * @err_map:	error buffer
 * @row_info:	row info buffer
 * @frame:	decoding syntax
 * @state:	decoding state
 */
struct vdec_vp9_slice_vsi {};

/**
 * struct vdec_vp9_slice_pfc - per-frame context that contains a local vsi.
 *                             pass it from lat to core
 *
 * @vsi:	local vsi. copy to/from remote vsi before/after decoding
 * @ref_idx:	reference buffer index
 * @seq:	picture sequence
 * @state:	decoding state
 */
struct vdec_vp9_slice_pfc {};

/*
 * enum vdec_vp9_slice_resolution_level
 */
enum vdec_vp9_slice_resolution_level {};

/*
 * struct vdec_vp9_slice_ref - picture's width & height should kept
 *                             for later decoding as reference picture
 */
struct vdec_vp9_slice_ref {};

/**
 * struct vdec_vp9_slice_instance - represent one vp9 instance
 *
 * @ctx:		pointer to codec's context
 * @vpu:		VPU instance
 * @seq:		global picture sequence
 * @level:		level of current resolution
 * @width:		width of last picture
 * @height:		height of last picture
 * @frame_type:	frame_type of last picture
 * @irq:		irq to Main CPU or MicroP
 * @show_frame:	show_frame of last picture
 * @dpb:		picture information (width/height) for reference
 * @mv:		mv working buffer
 * @seg:		segmentation working buffer
 * @tile:		tile buffer
 * @prob:		prob table buffer, used to set/update prob table
 * @counts:		counts table buffer, used to update prob table
 * @frame_ctx:		4 frame context according to VP9 Spec
 * @frame_ctx_helper:	4 frame context according to newest kernel spec
 * @dirty:		state of each frame context
 * @init_vsi:		vsi used for initialized VP9 instance
 * @vsi:		vsi used for decoding/flush ...
 * @core_vsi:		vsi used for Core stage
 *
 * @sc_pfc:		per frame context single core
 * @counts_map:	used map to counts_helper
 * @counts_helper:	counts table according to newest kernel spec
 */
struct vdec_vp9_slice_instance {};

/*
 * all VP9 instances could share this default frame context.
 */
static struct vdec_vp9_slice_frame_ctx *vdec_vp9_slice_default_frame_ctx;
static DEFINE_MUTEX(vdec_vp9_slice_frame_ctx_lock);

static int vdec_vp9_slice_core_decode(struct vdec_lat_buf *lat_buf);

static int vdec_vp9_slice_init_default_frame_ctx(struct vdec_vp9_slice_instance *instance)
{}

static int vdec_vp9_slice_alloc_working_buffer(struct vdec_vp9_slice_instance *instance,
					       struct vdec_vp9_slice_vsi *vsi)
{}

static void vdec_vp9_slice_free_working_buffer(struct vdec_vp9_slice_instance *instance)
{}

static void vdec_vp9_slice_vsi_from_remote(struct vdec_vp9_slice_vsi *vsi,
					   struct vdec_vp9_slice_vsi *remote_vsi,
					   int skip)
{}

static void vdec_vp9_slice_vsi_to_remote(struct vdec_vp9_slice_vsi *vsi,
					 struct vdec_vp9_slice_vsi *remote_vsi)
{}

static int vdec_vp9_slice_tile_offset(int idx, int mi_num, int tile_log2)
{}

static
int vdec_vp9_slice_setup_single_from_src_to_dst(struct vdec_vp9_slice_instance *instance)
{}

static int vdec_vp9_slice_setup_lat_from_src_buf(struct vdec_vp9_slice_instance *instance,
						 struct vdec_lat_buf *lat_buf)
{}

static void vdec_vp9_slice_setup_hdr(struct vdec_vp9_slice_instance *instance,
				     struct vdec_vp9_slice_uncompressed_header *uh,
				     struct v4l2_ctrl_vp9_frame *hdr)
{}

static void vdec_vp9_slice_setup_frame_ctx(struct vdec_vp9_slice_instance *instance,
					   struct vdec_vp9_slice_uncompressed_header *uh,
					   struct v4l2_ctrl_vp9_frame *hdr)
{}

static void vdec_vp9_slice_setup_loop_filter(struct vdec_vp9_slice_uncompressed_header *uh,
					     struct v4l2_vp9_loop_filter *lf)
{}

static void vdec_vp9_slice_setup_quantization(struct vdec_vp9_slice_uncompressed_header *uh,
					      struct v4l2_vp9_quantization *quant)
{}

static void vdec_vp9_slice_setup_segmentation(struct vdec_vp9_slice_uncompressed_header *uh,
					      struct v4l2_vp9_segmentation *seg)
{}

static int vdec_vp9_slice_setup_tile(struct vdec_vp9_slice_vsi *vsi,
				     struct v4l2_ctrl_vp9_frame *hdr)
{}

static void vdec_vp9_slice_setup_state(struct vdec_vp9_slice_vsi *vsi)
{}

static void vdec_vp9_slice_setup_ref_idx(struct vdec_vp9_slice_pfc *pfc,
					 struct v4l2_ctrl_vp9_frame *hdr)
{}

static int vdec_vp9_slice_setup_pfc(struct vdec_vp9_slice_instance *instance,
				    struct vdec_vp9_slice_pfc *pfc)
{}

static int vdec_vp9_slice_setup_lat_buffer(struct vdec_vp9_slice_instance *instance,
					   struct vdec_vp9_slice_vsi *vsi,
					   struct mtk_vcodec_mem *bs,
					   struct vdec_lat_buf *lat_buf)
{}

static int vdec_vp9_slice_setup_prob_buffer(struct vdec_vp9_slice_instance *instance,
					    struct vdec_vp9_slice_vsi *vsi)
{}

static void vdec_vp9_slice_setup_seg_buffer(struct vdec_vp9_slice_instance *instance,
					    struct vdec_vp9_slice_vsi *vsi,
					    struct mtk_vcodec_mem *buf)
{}

/*
 * parse tiles according to `6.4 Decode tiles syntax`
 * in "vp9-bitstream-specification"
 *
 * frame contains uncompress header, compressed header and several tiles.
 * this function parses tiles' position and size, stores them to tile buffer
 * for decoding.
 */
static int vdec_vp9_slice_setup_tile_buffer(struct vdec_vp9_slice_instance *instance,
					    struct vdec_vp9_slice_vsi *vsi,
					    struct mtk_vcodec_mem *bs)
{}

static int vdec_vp9_slice_setup_lat(struct vdec_vp9_slice_instance *instance,
				    struct mtk_vcodec_mem *bs,
				    struct vdec_lat_buf *lat_buf,
				    struct vdec_vp9_slice_pfc *pfc)
{}

static
void vdec_vp9_slice_map_counts_eob_coef(unsigned int i, unsigned int j, unsigned int k,
					struct vdec_vp9_slice_frame_counts *counts,
					struct v4l2_vp9_frame_symbol_counts *counts_helper)
{}

static void vdec_vp9_slice_counts_map_helper(struct vdec_vp9_slice_counts_map *counts_map,
					     struct vdec_vp9_slice_frame_counts *counts,
					     struct v4l2_vp9_frame_symbol_counts *counts_helper)
{}

static void vdec_vp9_slice_map_to_coef(unsigned int i, unsigned int j, unsigned int k,
				       struct vdec_vp9_slice_frame_ctx *frame_ctx,
				       struct v4l2_vp9_frame_context *frame_ctx_helper)
{}

static void vdec_vp9_slice_map_from_coef(unsigned int i, unsigned int j, unsigned int k,
					 struct vdec_vp9_slice_frame_ctx *frame_ctx,
					 struct v4l2_vp9_frame_context *frame_ctx_helper)
{}

static
void vdec_vp9_slice_framectx_map_helper(bool frame_is_intra,
					struct vdec_vp9_slice_frame_ctx *pre_frame_ctx,
					struct vdec_vp9_slice_frame_ctx *frame_ctx,
					struct v4l2_vp9_frame_context *frame_ctx_helper)
{}

static void vdec_vp9_slice_helper_map_framectx(struct v4l2_vp9_frame_context *frame_ctx_helper,
					       struct vdec_vp9_slice_frame_ctx *frame_ctx)
{}

static int vdec_vp9_slice_update_prob(struct vdec_vp9_slice_instance *instance,
				      struct vdec_vp9_slice_vsi *vsi)
{}

static int vdec_vp9_slice_update_single(struct vdec_vp9_slice_instance *instance,
					struct vdec_vp9_slice_pfc *pfc)
{}

static int vdec_vp9_slice_update_lat(struct vdec_vp9_slice_instance *instance,
				     struct vdec_lat_buf *lat_buf,
				     struct vdec_vp9_slice_pfc *pfc)
{}

static int vdec_vp9_slice_setup_core_to_dst_buf(struct vdec_vp9_slice_instance *instance,
						struct vdec_lat_buf *lat_buf)
{}

static int vdec_vp9_slice_setup_core_buffer(struct vdec_vp9_slice_instance *instance,
					    struct vdec_vp9_slice_pfc *pfc,
					    struct vdec_vp9_slice_vsi *vsi,
					    struct vdec_fb *fb,
					    struct vdec_lat_buf *lat_buf)
{}

static void vdec_vp9_slice_setup_single_buffer(struct vdec_vp9_slice_instance *instance,
					       struct vdec_vp9_slice_pfc *pfc,
					       struct vdec_vp9_slice_vsi *vsi,
					       struct mtk_vcodec_mem *bs,
					       struct vdec_fb *fb)
{}

static int vdec_vp9_slice_setup_core(struct vdec_vp9_slice_instance *instance,
				     struct vdec_fb *fb,
				     struct vdec_lat_buf *lat_buf,
				     struct vdec_vp9_slice_pfc *pfc)
{}

static int vdec_vp9_slice_setup_single(struct vdec_vp9_slice_instance *instance,
				       struct mtk_vcodec_mem *bs,
				       struct vdec_fb *fb,
				       struct vdec_vp9_slice_pfc *pfc)
{}

static int vdec_vp9_slice_update_core(struct vdec_vp9_slice_instance *instance,
				      struct vdec_lat_buf *lat_buf,
				      struct vdec_vp9_slice_pfc *pfc)
{}

static int vdec_vp9_slice_init(struct mtk_vcodec_dec_ctx *ctx)
{}

static void vdec_vp9_slice_deinit(void *h_vdec)
{}

static int vdec_vp9_slice_flush(void *h_vdec, struct mtk_vcodec_mem *bs,
				struct vdec_fb *fb, bool *res_chg)
{}

static void vdec_vp9_slice_get_pic_info(struct vdec_vp9_slice_instance *instance)
{}

static void vdec_vp9_slice_get_dpb_size(struct vdec_vp9_slice_instance *instance,
					unsigned int *dpb_sz)
{}

static int vdec_vp9_slice_get_param(void *h_vdec, enum vdec_get_param_type type, void *out)
{}

static int vdec_vp9_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
					struct vdec_fb *fb, bool *res_chg)
{}

static int vdec_vp9_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
				     struct vdec_fb *fb, bool *res_chg)
{}

static int vdec_vp9_slice_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
				 struct vdec_fb *fb, bool *res_chg)
{}

static int vdec_vp9_slice_core_decode(struct vdec_lat_buf *lat_buf)
{}

const struct vdec_common_if vdec_vp9_slice_lat_if =;