Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf
[sfrench/cifs-2.6.git] / drivers / media / platform / mtk-vcodec / vdec_vpu_if.h
1 /*
2  * Copyright (c) 2016 MediaTek Inc.
3  * Author: PC Chen <pc.chen@mediatek.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  */
14
15 #ifndef _VDEC_VPU_IF_H_
16 #define _VDEC_VPU_IF_H_
17
18 #include "mtk_vpu.h"
19
20 /**
21  * struct vdec_vpu_inst - VPU instance for video codec
22  * @ipi_id      : ipi id for each decoder
23  * @vsi         : driver structure allocated by VPU side and shared to AP side
24  *                for control and info share
25  * @failure     : VPU execution result status, 0: success, others: fail
26  * @inst_addr   : VPU decoder instance address
27  * @signaled    : 1 - Host has received ack message from VPU, 0 - not received
28  * @ctx         : context for v4l2 layer integration
29  * @dev         : platform device of VPU
30  * @wq          : wait queue to wait VPU message ack
31  * @handler     : ipi handler for each decoder
32  */
33 struct vdec_vpu_inst {
34         enum ipi_id id;
35         void *vsi;
36         int32_t failure;
37         uint32_t inst_addr;
38         unsigned int signaled;
39         struct mtk_vcodec_ctx *ctx;
40         struct platform_device *dev;
41         wait_queue_head_t wq;
42         ipi_handler_t handler;
43 };
44
45 /**
46  * vpu_dec_init - init decoder instance and allocate required resource in VPU.
47  *
48  * @vpu: instance for vdec_vpu_inst
49  */
50 int vpu_dec_init(struct vdec_vpu_inst *vpu);
51
52 /**
53  * vpu_dec_start - start decoding, basically the function will be invoked once
54  *                 every frame.
55  *
56  * @vpu : instance for vdec_vpu_inst
57  * @data: meta data to pass bitstream info to VPU decoder
58  * @len : meta data length
59  */
60 int vpu_dec_start(struct vdec_vpu_inst *vpu, uint32_t *data, unsigned int len);
61
62 /**
63  * vpu_dec_end - end decoding, basically the function will be invoked once
64  *               when HW decoding done interrupt received successfully. The
65  *               decoder in VPU will continute to do referene frame management
66  *               and check if there is a new decoded frame available to display.
67  *
68  * @vpu : instance for vdec_vpu_inst
69  */
70 int vpu_dec_end(struct vdec_vpu_inst *vpu);
71
72 /**
73  * vpu_dec_deinit - deinit decoder instance and resource freed in VPU.
74  *
75  * @vpu: instance for vdec_vpu_inst
76  */
77 int vpu_dec_deinit(struct vdec_vpu_inst *vpu);
78
79 /**
80  * vpu_dec_reset - reset decoder, use for flush decoder when end of stream or
81  *                 seek. Remainig non displayed frame will be pushed to display.
82  *
83  * @vpu: instance for vdec_vpu_inst
84  */
85 int vpu_dec_reset(struct vdec_vpu_inst *vpu);
86
87 /**
88  * vpu_dec_ipi_handler - Handler for VPU ipi message.
89  *
90  * @data: ipi message
91  * @len : length of ipi message
92  * @priv: callback private data which is passed by decoder when register.
93  */
94 void vpu_dec_ipi_handler(void *data, unsigned int len, void *priv);
95
96 #endif