1*0934d375SYunfei Dong /* SPDX-License-Identifier: GPL-2.0 */
2*0934d375SYunfei Dong /*
3*0934d375SYunfei Dong  * Copyright (c) 2016 MediaTek Inc.
4*0934d375SYunfei Dong  * Author: PC Chen <pc.chen@mediatek.com>
5*0934d375SYunfei Dong  */
6*0934d375SYunfei Dong 
7*0934d375SYunfei Dong #ifndef _VDEC_VPU_IF_H_
8*0934d375SYunfei Dong #define _VDEC_VPU_IF_H_
9*0934d375SYunfei Dong 
10*0934d375SYunfei Dong struct mtk_vcodec_dec_ctx;
11*0934d375SYunfei Dong 
12*0934d375SYunfei Dong /**
13*0934d375SYunfei Dong  * struct vdec_vpu_inst - VPU instance for video codec
14*0934d375SYunfei Dong  * @id          : ipi msg id for each decoder
15*0934d375SYunfei Dong  * @core_id     : core id used to separate different hardware
16*0934d375SYunfei Dong  * @vsi         : driver structure allocated by VPU side and shared to AP side
17*0934d375SYunfei Dong  *                for control and info share
18*0934d375SYunfei Dong  * @failure     : VPU execution result status, 0: success, others: fail
19*0934d375SYunfei Dong  * @inst_addr	: VPU decoder instance address
20*0934d375SYunfei Dong  * @fw_abi_version : ABI version of the firmware.
21*0934d375SYunfei Dong  * @inst_id	: if fw_abi_version >= 2, contains the instance ID to be given
22*0934d375SYunfei Dong  *                in place of inst_addr in messages.
23*0934d375SYunfei Dong  * @signaled    : 1 - Host has received ack message from VPU, 0 - not received
24*0934d375SYunfei Dong  * @ctx         : context for v4l2 layer integration
25*0934d375SYunfei Dong  * @dev		: platform device of VPU
26*0934d375SYunfei Dong  * @wq          : wait queue to wait VPU message ack
27*0934d375SYunfei Dong  * @handler     : ipi handler for each decoder
28*0934d375SYunfei Dong  * @codec_type     : use codec type to separate different codecs
29*0934d375SYunfei Dong  * @capture_type:	used capture type to separate different capture format
30*0934d375SYunfei Dong  * @fb_sz  : frame buffer size of each plane
31*0934d375SYunfei Dong  */
32*0934d375SYunfei Dong struct vdec_vpu_inst {
33*0934d375SYunfei Dong 	int id;
34*0934d375SYunfei Dong 	int core_id;
35*0934d375SYunfei Dong 	void *vsi;
36*0934d375SYunfei Dong 	int32_t failure;
37*0934d375SYunfei Dong 	uint32_t inst_addr;
38*0934d375SYunfei Dong 	uint32_t fw_abi_version;
39*0934d375SYunfei Dong 	uint32_t inst_id;
40*0934d375SYunfei Dong 	unsigned int signaled;
41*0934d375SYunfei Dong 	struct mtk_vcodec_dec_ctx *ctx;
42*0934d375SYunfei Dong 	wait_queue_head_t wq;
43*0934d375SYunfei Dong 	mtk_vcodec_ipi_handler handler;
44*0934d375SYunfei Dong 	unsigned int codec_type;
45*0934d375SYunfei Dong 	unsigned int capture_type;
46*0934d375SYunfei Dong 	unsigned int fb_sz[2];
47*0934d375SYunfei Dong };
48*0934d375SYunfei Dong 
49*0934d375SYunfei Dong /**
50*0934d375SYunfei Dong  * vpu_dec_init - init decoder instance and allocate required resource in VPU.
51*0934d375SYunfei Dong  *
52*0934d375SYunfei Dong  * @vpu: instance for vdec_vpu_inst
53*0934d375SYunfei Dong  */
54*0934d375SYunfei Dong int vpu_dec_init(struct vdec_vpu_inst *vpu);
55*0934d375SYunfei Dong 
56*0934d375SYunfei Dong /**
57*0934d375SYunfei Dong  * vpu_dec_start - start decoding, basically the function will be invoked once
58*0934d375SYunfei Dong  *                 every frame.
59*0934d375SYunfei Dong  *
60*0934d375SYunfei Dong  * @vpu : instance for vdec_vpu_inst
61*0934d375SYunfei Dong  * @data: meta data to pass bitstream info to VPU decoder
62*0934d375SYunfei Dong  * @len : meta data length
63*0934d375SYunfei Dong  */
64*0934d375SYunfei Dong int vpu_dec_start(struct vdec_vpu_inst *vpu, uint32_t *data, unsigned int len);
65*0934d375SYunfei Dong 
66*0934d375SYunfei Dong /**
67*0934d375SYunfei Dong  * vpu_dec_end - end decoding, basically the function will be invoked once
68*0934d375SYunfei Dong  *               when HW decoding done interrupt received successfully. The
69*0934d375SYunfei Dong  *               decoder in VPU will continue to do reference frame management
70*0934d375SYunfei Dong  *               and check if there is a new decoded frame available to display.
71*0934d375SYunfei Dong  *
72*0934d375SYunfei Dong  * @vpu : instance for vdec_vpu_inst
73*0934d375SYunfei Dong  */
74*0934d375SYunfei Dong int vpu_dec_end(struct vdec_vpu_inst *vpu);
75*0934d375SYunfei Dong 
76*0934d375SYunfei Dong /**
77*0934d375SYunfei Dong  * vpu_dec_deinit - deinit decoder instance and resource freed in VPU.
78*0934d375SYunfei Dong  *
79*0934d375SYunfei Dong  * @vpu: instance for vdec_vpu_inst
80*0934d375SYunfei Dong  */
81*0934d375SYunfei Dong int vpu_dec_deinit(struct vdec_vpu_inst *vpu);
82*0934d375SYunfei Dong 
83*0934d375SYunfei Dong /**
84*0934d375SYunfei Dong  * vpu_dec_reset - reset decoder, use for flush decoder when end of stream or
85*0934d375SYunfei Dong  *                 seek. Remainig non displayed frame will be pushed to display.
86*0934d375SYunfei Dong  *
87*0934d375SYunfei Dong  * @vpu: instance for vdec_vpu_inst
88*0934d375SYunfei Dong  */
89*0934d375SYunfei Dong int vpu_dec_reset(struct vdec_vpu_inst *vpu);
90*0934d375SYunfei Dong 
91*0934d375SYunfei Dong /**
92*0934d375SYunfei Dong  * vpu_dec_core - core start decoding, basically the function will be invoked once
93*0934d375SYunfei Dong  *                 every frame.
94*0934d375SYunfei Dong  *
95*0934d375SYunfei Dong  * @vpu : instance for vdec_vpu_inst
96*0934d375SYunfei Dong  */
97*0934d375SYunfei Dong int vpu_dec_core(struct vdec_vpu_inst *vpu);
98*0934d375SYunfei Dong 
99*0934d375SYunfei Dong /**
100*0934d375SYunfei Dong  * vpu_dec_core_end - core end decoding, basically the function will be invoked once
101*0934d375SYunfei Dong  *               when core HW decoding done and receive interrupt successfully. The
102*0934d375SYunfei Dong  *               decoder in VPU will updata hardware information and deinit hardware
103*0934d375SYunfei Dong  *               and check if there is a new decoded frame available to display.
104*0934d375SYunfei Dong  *
105*0934d375SYunfei Dong  * @vpu : instance for vdec_vpu_inst
106*0934d375SYunfei Dong  */
107*0934d375SYunfei Dong int vpu_dec_core_end(struct vdec_vpu_inst *vpu);
108*0934d375SYunfei Dong 
109*0934d375SYunfei Dong /**
110*0934d375SYunfei Dong  * vpu_dec_get_param - get param from scp
111*0934d375SYunfei Dong  *
112*0934d375SYunfei Dong  * @vpu : instance for vdec_vpu_inst
113*0934d375SYunfei Dong  * @data: meta data to pass bitstream info to VPU decoder
114*0934d375SYunfei Dong  * @len : meta data length
115*0934d375SYunfei Dong  * @param_type : get param type
116*0934d375SYunfei Dong  */
117*0934d375SYunfei Dong int vpu_dec_get_param(struct vdec_vpu_inst *vpu, uint32_t *data,
118*0934d375SYunfei Dong 		      unsigned int len, unsigned int param_type);
119*0934d375SYunfei Dong 
120*0934d375SYunfei Dong #endif
121