blob: d3ccef21fa72182c47105fb000ed8852e7fe8d12
1 | /* |
2 | * Copyright (C) 2017 Amlogic, Inc. All rights reserved. |
3 | * |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by |
6 | * the Free Software Foundation; either version 2 of the License, or |
7 | * (at your option) any later version. |
8 | * |
9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
12 | * more details. |
13 | * |
14 | * You should have received a copy of the GNU General Public License along |
15 | * with this program; if not, write to the Free Software Foundation, Inc., |
16 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | * |
18 | * Description: |
19 | */ |
20 | #ifndef _VDEC_DRV_IF_H_ |
21 | #define _VDEC_DRV_IF_H_ |
22 | |
23 | #include "aml_vcodec_drv.h" |
24 | #include "aml_vcodec_dec.h" |
25 | #include "aml_vcodec_util.h" |
26 | #include "../stream_input/parser/streambuf.h" |
27 | |
28 | #define NORe CODEC_MODE('N', 'O', 'R', 'e') // normal es |
29 | #define NORn CODEC_MODE('N', 'O', 'R', 'n') // normal nalu |
30 | #define DRMe CODEC_MODE('D', 'R', 'M', 'e') // drm es |
31 | #define DRMn CODEC_MODE('D', 'R', 'M', 'n') // drm nalu |
32 | |
33 | struct stream_info { |
34 | u32 magic; |
35 | u32 type; |
36 | union { |
37 | struct drm_info drm; |
38 | u8 buf[128]; |
39 | } m; |
40 | u32 length; |
41 | u8 data[0]; |
42 | }; |
43 | |
44 | /** |
45 | * struct vdec_fb_status - decoder frame buffer status |
46 | * @FB_ST_NORMAL : initial state |
47 | * @FB_ST_DISPLAY : frmae buffer is ready to be displayed |
48 | * @FB_ST_FREE : frame buffer is not used by decoder any more |
49 | */ |
50 | enum vdec_fb_status { |
51 | FB_ST_NORMAL, |
52 | FB_ST_DISPLAY, |
53 | FB_ST_FREE |
54 | }; |
55 | |
56 | /* For GET_PARAM_DISP_FRAME_BUFFER and GET_PARAM_FREE_FRAME_BUFFER, |
57 | * the caller does not own the returned buffer. The buffer will not be |
58 | * released before vdec_if_deinit. |
59 | * GET_PARAM_DISP_FRAME_BUFFER : get next displayable frame buffer, |
60 | * struct vdec_fb** |
61 | * GET_PARAM_FREE_FRAME_BUFFER : get non-referenced framebuffer, vdec_fb** |
62 | * GET_PARAM_PIC_INFO : get picture info, struct vdec_pic_info* |
63 | * GET_PARAM_CROP_INFO : get crop info, struct v4l2_crop* |
64 | * GET_PARAM_DPB_SIZE : get dpb size, unsigned int* |
65 | */ |
66 | enum vdec_get_param_type { |
67 | GET_PARAM_DISP_FRAME_BUFFER, |
68 | GET_PARAM_FREE_FRAME_BUFFER, |
69 | GET_PARAM_PIC_INFO, |
70 | GET_PARAM_CROP_INFO, |
71 | GET_PARAM_DPB_SIZE, |
72 | GET_PARAM_CONFIG_INFO |
73 | }; |
74 | |
75 | /* |
76 | * SET_PARAM_PS_INFO : set picture parms, data parsed from ucode. |
77 | */ |
78 | enum vdec_set_param_type { |
79 | SET_PARAM_WRITE_FRAME_SYNC, |
80 | SET_PARAM_PS_INFO, |
81 | SET_PARAM_HDR_INFO, |
82 | SET_PARAM_POST_EVENT |
83 | }; |
84 | |
85 | /** |
86 | * struct vdec_fb_node - decoder frame buffer node |
87 | * @list : list to hold this node |
88 | * @fb : point to frame buffer (vdec_fb), fb could point to frame buffer and |
89 | * working buffer this is for maintain buffers in different state |
90 | */ |
91 | struct vdec_fb_node { |
92 | struct list_head list; |
93 | struct vdec_fb *fb; |
94 | }; |
95 | |
96 | /** |
97 | * vdec_if_init() - initialize decode driver |
98 | * @ctx : [in] v4l2 context |
99 | * @fourcc : [in] video format fourcc, V4L2_PIX_FMT_H264/VP8/VP9.. |
100 | */ |
101 | int vdec_if_init(struct aml_vcodec_ctx *ctx, unsigned int fourcc); |
102 | |
103 | int vdec_if_probe(struct aml_vcodec_ctx *ctx, |
104 | struct aml_vcodec_mem *bs, void *out); |
105 | |
106 | /** |
107 | * vdec_if_deinit() - deinitialize decode driver |
108 | * @ctx : [in] v4l2 context |
109 | * |
110 | */ |
111 | void vdec_if_deinit(struct aml_vcodec_ctx *ctx); |
112 | |
113 | /** |
114 | * vdec_if_decode() - trigger decode |
115 | * @ctx : [in] v4l2 context |
116 | * @bs : [in] input bitstream |
117 | * @fb : [in] frame buffer to store decoded frame, when null menas parse |
118 | * header only |
119 | * @res_chg : [out] resolution change happens if current bs have different |
120 | * picture width/height |
121 | * Note: To flush the decoder when reaching EOF, set input bitstream as NULL. |
122 | * |
123 | * Return: 0 on success. -EIO on unrecoverable error. |
124 | */ |
125 | int vdec_if_decode(struct aml_vcodec_ctx *ctx, struct aml_vcodec_mem *bs, |
126 | u64 timestamp, bool *res_chg); |
127 | |
128 | /** |
129 | * vdec_if_get_param() - get driver's parameter |
130 | * @ctx : [in] v4l2 context |
131 | * @type : [in] input parameter type |
132 | * @out : [out] buffer to store query result |
133 | */ |
134 | int vdec_if_get_param(struct aml_vcodec_ctx *ctx, enum vdec_get_param_type type, |
135 | void *out); |
136 | |
137 | #endif |
138 |