media: platform: rename mtk-vcodec/ to mediatek/mtk-vcodec/
[linux-2.6-microblaze.git] / drivers / media / platform / mediatek / mtk-vcodec / vdec_drv_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  *                 Tiffany Lin <tiffany.lin@mediatek.com>
6  */
7
8 #ifndef _VDEC_DRV_IF_H_
9 #define _VDEC_DRV_IF_H_
10
11 #include "mtk_vcodec_drv.h"
12 #include "mtk_vcodec_dec.h"
13 #include "mtk_vcodec_util.h"
14
15
16 /**
17  * enum vdec_fb_status  - decoder frame buffer status
18  * @FB_ST_NORMAL: initial state
19  * @FB_ST_DISPLAY: frame buffer is ready to be displayed
20  * @FB_ST_FREE: frame buffer is not used by decoder any more
21  */
22 enum vdec_fb_status {
23         FB_ST_NORMAL            = 0,
24         FB_ST_DISPLAY           = (1 << 0),
25         FB_ST_FREE              = (1 << 1)
26 };
27
28 /* For GET_PARAM_DISP_FRAME_BUFFER and GET_PARAM_FREE_FRAME_BUFFER,
29  * the caller does not own the returned buffer. The buffer will not be
30  *                              released before vdec_if_deinit.
31  * GET_PARAM_DISP_FRAME_BUFFER  : get next displayable frame buffer,
32  *                              struct vdec_fb**
33  * GET_PARAM_FREE_FRAME_BUFFER  : get non-referenced framebuffer, vdec_fb**
34  * GET_PARAM_PIC_INFO           : get picture info, struct vdec_pic_info*
35  * GET_PARAM_CROP_INFO          : get crop info, struct v4l2_crop*
36  * GET_PARAM_DPB_SIZE           : get dpb size, unsigned int*
37  */
38 enum vdec_get_param_type {
39         GET_PARAM_DISP_FRAME_BUFFER,
40         GET_PARAM_FREE_FRAME_BUFFER,
41         GET_PARAM_PIC_INFO,
42         GET_PARAM_CROP_INFO,
43         GET_PARAM_DPB_SIZE
44 };
45
46 /**
47  * struct vdec_fb_node  - decoder frame buffer node
48  * @list        : list to hold this node
49  * @fb  : point to frame buffer (vdec_fb), fb could point to frame buffer and
50  *      working buffer this is for maintain buffers in different state
51  */
52 struct vdec_fb_node {
53         struct list_head list;
54         struct vdec_fb *fb;
55 };
56
57 extern const struct vdec_common_if vdec_h264_if;
58 extern const struct vdec_common_if vdec_h264_slice_if;
59 extern const struct vdec_common_if vdec_vp8_if;
60 extern const struct vdec_common_if vdec_vp9_if;
61
62 /**
63  * vdec_if_init() - initialize decode driver
64  * @ctx : [in] v4l2 context
65  * @fourcc      : [in] video format fourcc, V4L2_PIX_FMT_H264/VP8/VP9..
66  */
67 int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc);
68
69 /**
70  * vdec_if_deinit() - deinitialize decode driver
71  * @ctx : [in] v4l2 context
72  *
73  */
74 void vdec_if_deinit(struct mtk_vcodec_ctx *ctx);
75
76 /**
77  * vdec_if_decode() - trigger decode
78  * @ctx : [in] v4l2 context
79  * @bs  : [in] input bitstream
80  * @fb  : [in] frame buffer to store decoded frame, when null means parse
81  *      header only
82  * @res_chg     : [out] resolution change happens if current bs have different
83  *      picture width/height
84  * Note: To flush the decoder when reaching EOF, set input bitstream as NULL.
85  *
86  * Return: 0 on success. -EIO on unrecoverable error.
87  */
88 int vdec_if_decode(struct mtk_vcodec_ctx *ctx, struct mtk_vcodec_mem *bs,
89                    struct vdec_fb *fb, bool *res_chg);
90
91 /**
92  * vdec_if_get_param() - get driver's parameter
93  * @ctx : [in] v4l2 context
94  * @type        : [in] input parameter type
95  * @out : [out] buffer to store query result
96  */
97 int vdec_if_get_param(struct mtk_vcodec_ctx *ctx, enum vdec_get_param_type type,
98                       void *out);
99
100 #endif