This source file includes following definitions.
- to_inst
- to_hfi_priv
- venus_caps_by_codec
1
2
3
4
5
6
7 #ifndef __VENUS_CORE_H_
8 #define __VENUS_CORE_H_
9
10 #include <linux/list.h>
11 #include <media/videobuf2-v4l2.h>
12 #include <media/v4l2-ctrls.h>
13 #include <media/v4l2-device.h>
14
15 #include "hfi.h"
16
17 #define VIDC_CLKS_NUM_MAX 4
18
19 struct freq_tbl {
20 unsigned int load;
21 unsigned long freq;
22 };
23
24 struct reg_val {
25 u32 reg;
26 u32 value;
27 };
28
29 struct venus_resources {
30 u64 dma_mask;
31 const struct freq_tbl *freq_tbl;
32 unsigned int freq_tbl_size;
33 const struct reg_val *reg_tbl;
34 unsigned int reg_tbl_size;
35 const char * const clks[VIDC_CLKS_NUM_MAX];
36 unsigned int clks_num;
37 enum hfi_version hfi_version;
38 u32 max_load;
39 unsigned int vmem_id;
40 u32 vmem_size;
41 u32 vmem_addr;
42 const char *fwname;
43 };
44
45 struct venus_format {
46 u32 pixfmt;
47 unsigned int num_planes;
48 u32 type;
49 u32 flags;
50 };
51
52 #define MAX_PLANES 4
53 #define MAX_FMT_ENTRIES 32
54 #define MAX_CAP_ENTRIES 32
55 #define MAX_ALLOC_MODE_ENTRIES 16
56 #define MAX_CODEC_NUM 32
57
58 struct raw_formats {
59 u32 buftype;
60 u32 fmt;
61 };
62
63 struct venus_caps {
64 u32 codec;
65 u32 domain;
66 bool cap_bufs_mode_dynamic;
67 unsigned int num_caps;
68 struct hfi_capability caps[MAX_CAP_ENTRIES];
69 unsigned int num_pl;
70 struct hfi_profile_level pl[HFI_MAX_PROFILE_COUNT];
71 unsigned int num_fmts;
72 struct raw_formats fmts[MAX_FMT_ENTRIES];
73 bool valid;
74 };
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110 struct venus_core {
111 void __iomem *base;
112 int irq;
113 struct clk *clks[VIDC_CLKS_NUM_MAX];
114 struct clk *core0_clk;
115 struct clk *core1_clk;
116 struct clk *core0_bus_clk;
117 struct clk *core1_bus_clk;
118 struct video_device *vdev_dec;
119 struct video_device *vdev_enc;
120 struct v4l2_device v4l2_dev;
121 const struct venus_resources *res;
122 struct device *dev;
123 struct device *dev_dec;
124 struct device *dev_enc;
125 unsigned int use_tz;
126 struct video_firmware {
127 struct device *dev;
128 struct iommu_domain *iommu_domain;
129 size_t mapped_mem_size;
130 } fw;
131 struct mutex lock;
132 struct list_head instances;
133 atomic_t insts_count;
134 unsigned int state;
135 struct completion done;
136 unsigned int error;
137 bool sys_error;
138 const struct hfi_core_ops *core_ops;
139 unsigned long enc_codecs;
140 unsigned long dec_codecs;
141 unsigned int max_sessions_supported;
142 #define ENC_ROTATION_CAPABILITY 0x1
143 #define ENC_SCALING_CAPABILITY 0x2
144 #define ENC_DEINTERLACE_CAPABILITY 0x4
145 #define DEC_MULTI_STREAM_CAPABILITY 0x8
146 unsigned int core_caps;
147 void *priv;
148 const struct hfi_ops *ops;
149 struct delayed_work work;
150 struct venus_caps caps[MAX_CODEC_NUM];
151 unsigned int codecs_count;
152 };
153
154 struct vdec_controls {
155 u32 post_loop_deb_mode;
156 u32 profile;
157 u32 level;
158 };
159
160 struct venc_controls {
161 u16 gop_size;
162 u32 num_p_frames;
163 u32 num_b_frames;
164 u32 bitrate_mode;
165 u32 bitrate;
166 u32 bitrate_peak;
167
168 u32 h264_i_period;
169 u32 h264_entropy_mode;
170 u32 h264_i_qp;
171 u32 h264_p_qp;
172 u32 h264_b_qp;
173 u32 h264_min_qp;
174 u32 h264_max_qp;
175 u32 h264_loop_filter_mode;
176 s32 h264_loop_filter_alpha;
177 s32 h264_loop_filter_beta;
178
179 u32 vp8_min_qp;
180 u32 vp8_max_qp;
181
182 u32 multi_slice_mode;
183 u32 multi_slice_max_bytes;
184 u32 multi_slice_max_mb;
185
186 u32 header_mode;
187
188 struct {
189 u32 mpeg4;
190 u32 h264;
191 u32 vpx;
192 u32 hevc;
193 } profile;
194 struct {
195 u32 mpeg4;
196 u32 h264;
197 u32 hevc;
198 } level;
199 };
200
201 struct venus_buffer {
202 struct vb2_v4l2_buffer vb;
203 struct list_head list;
204 dma_addr_t dma_addr;
205 u32 size;
206 struct list_head reg_list;
207 u32 flags;
208 struct list_head ref_list;
209 };
210
211 #define to_venus_buffer(ptr) container_of(ptr, struct venus_buffer, vb)
212
213 enum venus_dec_state {
214 VENUS_DEC_STATE_DEINIT = 0,
215 VENUS_DEC_STATE_INIT = 1,
216 VENUS_DEC_STATE_CAPTURE_SETUP = 2,
217 VENUS_DEC_STATE_STOPPED = 3,
218 VENUS_DEC_STATE_SEEK = 4,
219 VENUS_DEC_STATE_DRAIN = 5,
220 VENUS_DEC_STATE_DECODING = 6,
221 VENUS_DEC_STATE_DRC = 7
222 };
223
224 struct venus_ts_metadata {
225 bool used;
226 u64 ts_ns;
227 u64 ts_us;
228 u32 flags;
229 struct v4l2_timecode tc;
230 };
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287 struct venus_inst {
288 struct list_head list;
289 struct mutex lock;
290 struct venus_core *core;
291 struct list_head dpbbufs;
292 struct list_head internalbufs;
293 struct list_head registeredbufs;
294 struct list_head delayed_process;
295 struct work_struct delayed_process_work;
296
297 struct v4l2_ctrl_handler ctrl_handler;
298 union {
299 struct vdec_controls dec;
300 struct venc_controls enc;
301 } controls;
302 struct v4l2_fh fh;
303 unsigned int streamon_cap, streamon_out;
304 u32 width;
305 u32 height;
306 u32 out_width;
307 u32 out_height;
308 u32 colorspace;
309 u8 ycbcr_enc;
310 u8 quantization;
311 u8 xfer_func;
312 enum venus_dec_state codec_state;
313 wait_queue_head_t reconf_wait;
314 unsigned int subscriptions;
315 int buf_count;
316 struct venus_ts_metadata tss[VIDEO_MAX_FRAME];
317 u64 fps;
318 struct v4l2_fract timeperframe;
319 const struct venus_format *fmt_out;
320 const struct venus_format *fmt_cap;
321 unsigned int num_input_bufs;
322 unsigned int num_output_bufs;
323 unsigned int input_buf_size;
324 unsigned int output_buf_size;
325 unsigned int output2_buf_size;
326 u32 dpb_buftype;
327 u32 dpb_fmt;
328 u32 opb_buftype;
329 u32 opb_fmt;
330 bool reconfig;
331 u32 hfi_codec;
332 u32 sequence_cap;
333 u32 sequence_out;
334 struct v4l2_m2m_dev *m2m_dev;
335 struct v4l2_m2m_ctx *m2m_ctx;
336 unsigned int state;
337 struct completion done;
338 unsigned int error;
339 bool session_error;
340 const struct hfi_inst_ops *ops;
341 u32 session_type;
342 union hfi_get_property hprop;
343 };
344
345 #define IS_V1(core) ((core)->res->hfi_version == HFI_VERSION_1XX)
346 #define IS_V3(core) ((core)->res->hfi_version == HFI_VERSION_3XX)
347 #define IS_V4(core) ((core)->res->hfi_version == HFI_VERSION_4XX)
348
349 #define ctrl_to_inst(ctrl) \
350 container_of((ctrl)->handler, struct venus_inst, ctrl_handler)
351
352 static inline struct venus_inst *to_inst(struct file *filp)
353 {
354 return container_of(filp->private_data, struct venus_inst, fh);
355 }
356
357 static inline void *to_hfi_priv(struct venus_core *core)
358 {
359 return core->priv;
360 }
361
362 static inline struct venus_caps *
363 venus_caps_by_codec(struct venus_core *core, u32 codec, u32 domain)
364 {
365 unsigned int c;
366
367 for (c = 0; c < core->codecs_count; c++) {
368 if (core->caps[c].codec == codec &&
369 core->caps[c].domain == domain)
370 return &core->caps[c];
371 }
372
373 return NULL;
374 }
375
376 #endif