Merge tag 'media/v5.5-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
[sfrench/cifs-2.6.git] / drivers / media / platform / mtk-vcodec / vdec_vpu_if.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (c) 2016 MediaTek Inc.
4  * Author: PC Chen <pc.chen@mediatek.com>
5  */
6
7 #ifndef _VDEC_VPU_IF_H_
8 #define _VDEC_VPU_IF_H_
9
10 #include "mtk_vpu.h"
11
12 /**
13  * struct vdec_vpu_inst - VPU instance for video codec
14  * @ipi_id      : ipi id for each decoder
15  * @vsi         : driver structure allocated by VPU side and shared to AP side
16  *                for control and info share
17  * @failure     : VPU execution result status, 0: success, others: fail
18  * @inst_addr   : VPU decoder instance address
19  * @signaled    : 1 - Host has received ack message from VPU, 0 - not received
20  * @ctx         : context for v4l2 layer integration
21  * @dev         : platform device of VPU
22  * @wq          : wait queue to wait VPU message ack
23  * @handler     : ipi handler for each decoder
24  */
25 struct vdec_vpu_inst {
26         enum ipi_id id;
27         void *vsi;
28         int32_t failure;
29         uint32_t inst_addr;
30         unsigned int signaled;
31         struct mtk_vcodec_ctx *ctx;
32         struct platform_device *dev;
33         wait_queue_head_t wq;
34         ipi_handler_t handler;
35 };
36
37 /**
38  * vpu_dec_init - init decoder instance and allocate required resource in VPU.
39  *
40  * @vpu: instance for vdec_vpu_inst
41  */
42 int vpu_dec_init(struct vdec_vpu_inst *vpu);
43
44 /**
45  * vpu_dec_start - start decoding, basically the function will be invoked once
46  *                 every frame.
47  *
48  * @vpu : instance for vdec_vpu_inst
49  * @data: meta data to pass bitstream info to VPU decoder
50  * @len : meta data length
51  */
52 int vpu_dec_start(struct vdec_vpu_inst *vpu, uint32_t *data, unsigned int len);
53
54 /**
55  * vpu_dec_end - end decoding, basically the function will be invoked once
56  *               when HW decoding done interrupt received successfully. The
57  *               decoder in VPU will continue to do reference frame management
58  *               and check if there is a new decoded frame available to display.
59  *
60  * @vpu : instance for vdec_vpu_inst
61  */
62 int vpu_dec_end(struct vdec_vpu_inst *vpu);
63
64 /**
65  * vpu_dec_deinit - deinit decoder instance and resource freed in VPU.
66  *
67  * @vpu: instance for vdec_vpu_inst
68  */
69 int vpu_dec_deinit(struct vdec_vpu_inst *vpu);
70
71 /**
72  * vpu_dec_reset - reset decoder, use for flush decoder when end of stream or
73  *                 seek. Remainig non displayed frame will be pushed to display.
74  *
75  * @vpu: instance for vdec_vpu_inst
76  */
77 int vpu_dec_reset(struct vdec_vpu_inst *vpu);
78
79 #endif