Merge tag 'v3.10.75' into update
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / media / platform / s5p-mfc / s5p_mfc_common.h
CommitLineData
af935746
KD
1/*
2 * Samsung S5P Multi Format Codec v 5.0
3 *
4 * This file contains definitions of enums and structs used by the codec
5 * driver.
6 *
7 * Copyright (C) 2011 Samsung Electronics Co., Ltd.
8 * Kamil Debski, <k.debski@samsung.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the
13 * License, or (at your option) any later version
14 */
15
16#ifndef S5P_MFC_COMMON_H_
17#define S5P_MFC_COMMON_H_
18
af935746
KD
19#include <linux/platform_device.h>
20#include <linux/videodev2.h>
21#include <media/v4l2-ctrls.h>
22#include <media/v4l2-device.h>
23#include <media/v4l2-ioctl.h>
24#include <media/videobuf2-core.h>
f96f3cfa
JP
25#include "regs-mfc.h"
26#include "regs-mfc-v6.h"
af935746
KD
27
28/* Definitions related to MFC memory */
29
30/* Offset base used to differentiate between CAPTURE and OUTPUT
31* while mmaping */
1190df7d 32#define DST_QUEUE_OFF_BASE (1 << 30)
af935746 33
af935746
KD
34#define MFC_BANK1_ALLOC_CTX 0
35#define MFC_BANK2_ALLOC_CTX 1
36
37#define MFC_BANK1_ALIGN_ORDER 13
38#define MFC_BANK2_ALIGN_ORDER 13
39#define MFC_BASE_ALIGN_ORDER 17
40
41#include <media/videobuf2-dma-contig.h>
42
43static inline dma_addr_t s5p_mfc_mem_cookie(void *a, void *b)
44{
45 /* Same functionality as the vb2_dma_contig_plane_paddr */
46 dma_addr_t *paddr = vb2_dma_contig_memops.cookie(b);
47
48 return *paddr;
49}
50
51/* MFC definitions */
52#define MFC_MAX_EXTRA_DPB 5
53#define MFC_MAX_BUFFERS 32
54#define MFC_NUM_CONTEXTS 4
55/* Interrupt timeout */
56#define MFC_INT_TIMEOUT 2000
57/* Busy wait timeout */
58#define MFC_BW_TIMEOUT 500
59/* Watchdog interval */
60#define MFC_WATCHDOG_INTERVAL 1000
61/* After how many executions watchdog should assume lock up */
62#define MFC_WATCHDOG_CNT 10
63#define MFC_NO_INSTANCE_SET -1
64#define MFC_ENC_CAP_PLANE_COUNT 1
65#define MFC_ENC_OUT_PLANE_COUNT 2
66#define STUFF_BYTE 4
43a1ea1f
AK
67#define MFC_MAX_CTRLS 70
68
69#define S5P_MFC_CODEC_NONE -1
70#define S5P_MFC_CODEC_H264_DEC 0
71#define S5P_MFC_CODEC_H264_MVC_DEC 1
72#define S5P_MFC_CODEC_VC1_DEC 2
73#define S5P_MFC_CODEC_MPEG4_DEC 3
74#define S5P_MFC_CODEC_MPEG2_DEC 4
75#define S5P_MFC_CODEC_H263_DEC 5
76#define S5P_MFC_CODEC_VC1RCV_DEC 6
77#define S5P_MFC_CODEC_VP8_DEC 7
78
79#define S5P_MFC_CODEC_H264_ENC 20
80#define S5P_MFC_CODEC_H264_MVC_ENC 21
81#define S5P_MFC_CODEC_MPEG4_ENC 22
82#define S5P_MFC_CODEC_H263_ENC 23
83
84#define S5P_MFC_R2H_CMD_EMPTY 0
85#define S5P_MFC_R2H_CMD_SYS_INIT_RET 1
86#define S5P_MFC_R2H_CMD_OPEN_INSTANCE_RET 2
87#define S5P_MFC_R2H_CMD_SEQ_DONE_RET 3
88#define S5P_MFC_R2H_CMD_INIT_BUFFERS_RET 4
89#define S5P_MFC_R2H_CMD_CLOSE_INSTANCE_RET 6
90#define S5P_MFC_R2H_CMD_SLEEP_RET 7
91#define S5P_MFC_R2H_CMD_WAKEUP_RET 8
92#define S5P_MFC_R2H_CMD_COMPLETE_SEQ_RET 9
93#define S5P_MFC_R2H_CMD_DPB_FLUSH_RET 10
94#define S5P_MFC_R2H_CMD_NAL_ABORT_RET 11
95#define S5P_MFC_R2H_CMD_FW_STATUS_RET 12
96#define S5P_MFC_R2H_CMD_FRAME_DONE_RET 13
97#define S5P_MFC_R2H_CMD_FIELD_DONE_RET 14
98#define S5P_MFC_R2H_CMD_SLICE_DONE_RET 15
99#define S5P_MFC_R2H_CMD_ENC_BUFFER_FUL_RET 16
100#define S5P_MFC_R2H_CMD_ERR_RET 32
af935746
KD
101
102#define mfc_read(dev, offset) readl(dev->regs_base + (offset))
103#define mfc_write(dev, data, offset) writel((data), dev->regs_base + \
104 (offset))
105
106/**
107 * enum s5p_mfc_fmt_type - type of the pixelformat
108 */
109enum s5p_mfc_fmt_type {
110 MFC_FMT_DEC,
111 MFC_FMT_ENC,
112 MFC_FMT_RAW,
113};
114
af935746
KD
115/**
116 * enum s5p_mfc_inst_type - The type of an MFC instance.
117 */
118enum s5p_mfc_inst_type {
119 MFCINST_INVALID,
120 MFCINST_DECODER,
121 MFCINST_ENCODER,
122};
123
124/**
125 * enum s5p_mfc_inst_state - The state of an MFC instance.
126 */
127enum s5p_mfc_inst_state {
128 MFCINST_FREE = 0,
129 MFCINST_INIT = 100,
130 MFCINST_GOT_INST,
131 MFCINST_HEAD_PARSED,
e9d98ddc 132 MFCINST_HEAD_PRODUCED,
af935746
KD
133 MFCINST_BUFS_SET,
134 MFCINST_RUNNING,
135 MFCINST_FINISHING,
136 MFCINST_FINISHED,
137 MFCINST_RETURN_INST,
138 MFCINST_ERROR,
139 MFCINST_ABORT,
8f23cc02 140 MFCINST_FLUSH,
af935746
KD
141 MFCINST_RES_CHANGE_INIT,
142 MFCINST_RES_CHANGE_FLUSH,
143 MFCINST_RES_CHANGE_END,
144};
145
146/**
147 * enum s5p_mfc_queue_state - The state of buffer queue.
148 */
149enum s5p_mfc_queue_state {
150 QUEUE_FREE,
151 QUEUE_BUFS_REQUESTED,
152 QUEUE_BUFS_QUERIED,
153 QUEUE_BUFS_MMAPED,
154};
155
156/**
157 * enum s5p_mfc_decode_arg - type of frame decoding
158 */
159enum s5p_mfc_decode_arg {
160 MFC_DEC_FRAME,
161 MFC_DEC_LAST_FRAME,
162 MFC_DEC_RES_CHANGE,
163};
164
f9f715a9
AH
165#define MFC_BUF_FLAG_USED (1 << 0)
166#define MFC_BUF_FLAG_EOS (1 << 1)
167
af935746
KD
168struct s5p_mfc_ctx;
169
170/**
171 * struct s5p_mfc_buf - MFC buffer
172 */
173struct s5p_mfc_buf {
174 struct list_head list;
175 struct vb2_buffer *b;
176 union {
177 struct {
178 size_t luma;
179 size_t chroma;
180 } raw;
181 size_t stream;
182 } cookie;
f9f715a9 183 int flags;
af935746
KD
184};
185
186/**
187 * struct s5p_mfc_pm - power management data structure
188 */
189struct s5p_mfc_pm {
190 struct clk *clock;
191 struct clk *clock_gate;
192 atomic_t power;
193 struct device *device;
194};
195
8f532a7f
AK
196struct s5p_mfc_buf_size_v5 {
197 unsigned int h264_ctx;
198 unsigned int non_h264_ctx;
199 unsigned int dsc;
200 unsigned int shm;
201};
202
f96f3cfa
JP
203struct s5p_mfc_buf_size_v6 {
204 unsigned int dev_ctx;
205 unsigned int h264_dec_ctx;
206 unsigned int other_dec_ctx;
207 unsigned int h264_enc_ctx;
208 unsigned int other_enc_ctx;
209};
210
8f532a7f
AK
211struct s5p_mfc_buf_size {
212 unsigned int fw;
213 unsigned int cpb;
214 void *priv;
215};
216
217struct s5p_mfc_buf_align {
218 unsigned int base;
219};
220
221struct s5p_mfc_variant {
222 unsigned int version;
223 unsigned int port_num;
224 struct s5p_mfc_buf_size *buf_size;
225 struct s5p_mfc_buf_align *buf_align;
f96f3cfa 226 char *fw_name;
8f532a7f
AK
227};
228
229/**
230 * struct s5p_mfc_priv_buf - represents internal used buffer
231 * @alloc: allocation-specific context for each buffer
232 * (videobuf2 allocator)
233 * @ofs: offset of each buffer, will be used for MFC
234 * @virt: kernel virtual address, only valid when the
235 * buffer accessed by driver
236 * @dma: DMA address, only valid when kernel DMA API used
237 * @size: size of the buffer
238 */
239struct s5p_mfc_priv_buf {
240 void *alloc;
241 unsigned long ofs;
242 void *virt;
243 dma_addr_t dma;
244 size_t size;
245};
246
af935746
KD
247/**
248 * struct s5p_mfc_dev - The struct containing driver internal parameters.
249 *
250 * @v4l2_dev: v4l2_device
251 * @vfd_dec: video device for decoding
252 * @vfd_enc: video device for encoding
253 * @plat_dev: platform device
254 * @mem_dev_l: child device of the left memory bank (0)
255 * @mem_dev_r: child device of the right memory bank (1)
256 * @regs_base: base address of the MFC hw registers
257 * @irq: irq resource
af935746
KD
258 * @dec_ctrl_handler: control framework handler for decoding
259 * @enc_ctrl_handler: control framework handler for encoding
260 * @pm: power management control
8f532a7f 261 * @variant: MFC hardware variant information
af935746
KD
262 * @num_inst: couter of active MFC instances
263 * @irqlock: lock for operations on videobuf2 queues
264 * @condlock: lock for changing/checking if a context is ready to be
265 * processed
266 * @mfc_mutex: lock for video_device
267 * @int_cond: variable used by the waitqueue
268 * @int_type: type of last interrupt
269 * @int_err: error number for last interrupt
270 * @queue: waitqueue for waiting for completion of device commands
271 * @fw_size: size of firmware
2e731e44
KD
272 * @fw_virt_addr: virtual firmware address
273 * @bank1: address of the beginning of bank 1 memory
274 * @bank2: address of the beginning of bank 2 memory
af935746
KD
275 * @hw_lock: used for hardware locking
276 * @ctx: array of driver contexts
277 * @curr_ctx: number of the currently running context
278 * @ctx_work_bits: used to mark which contexts are waiting for hardware
279 * @watchdog_cnt: counter for the watchdog
280 * @watchdog_workqueue: workqueue for the watchdog
281 * @watchdog_work: worker for the watchdog
282 * @alloc_ctx: videobuf2 allocator contexts for two memory banks
283 * @enter_suspend: flag set when entering suspend
f96f3cfa 284 * @ctx_buf: common context memory (MFCv6)
43a1ea1f
AK
285 * @warn_start: hardware error code from which warnings start
286 * @mfc_ops: ops structure holding HW operation function pointers
287 * @mfc_cmds: cmd structure holding HW commands function pointers
af935746
KD
288 *
289 */
290struct s5p_mfc_dev {
291 struct v4l2_device v4l2_dev;
292 struct video_device *vfd_dec;
293 struct video_device *vfd_enc;
294 struct platform_device *plat_dev;
295 struct device *mem_dev_l;
296 struct device *mem_dev_r;
297 void __iomem *regs_base;
298 int irq;
af935746
KD
299 struct v4l2_ctrl_handler dec_ctrl_handler;
300 struct v4l2_ctrl_handler enc_ctrl_handler;
301 struct s5p_mfc_pm pm;
8f532a7f 302 struct s5p_mfc_variant *variant;
af935746
KD
303 int num_inst;
304 spinlock_t irqlock; /* lock when operating on videobuf2 queues */
305 spinlock_t condlock; /* lock when changing/checking if a context is
306 ready to be processed */
307 struct mutex mfc_mutex; /* video_device lock */
308 int int_cond;
309 int int_type;
310 unsigned int int_err;
311 wait_queue_head_t queue;
312 size_t fw_size;
2e731e44
KD
313 void *fw_virt_addr;
314 dma_addr_t bank1;
315 dma_addr_t bank2;
af935746
KD
316 unsigned long hw_lock;
317 struct s5p_mfc_ctx *ctx[MFC_NUM_CONTEXTS];
318 int curr_ctx;
319 unsigned long ctx_work_bits;
320 atomic_t watchdog_cnt;
321 struct timer_list watchdog_timer;
322 struct workqueue_struct *watchdog_workqueue;
323 struct work_struct watchdog_work;
324 void *alloc_ctx[2];
325 unsigned long enter_suspend;
43a1ea1f 326
f96f3cfa 327 struct s5p_mfc_priv_buf ctx_buf;
43a1ea1f
AK
328 int warn_start;
329 struct s5p_mfc_hw_ops *mfc_ops;
330 struct s5p_mfc_hw_cmds *mfc_cmds;
af935746
KD
331};
332
333/**
334 * struct s5p_mfc_h264_enc_params - encoding parameters for h264
335 */
336struct s5p_mfc_h264_enc_params {
337 enum v4l2_mpeg_video_h264_profile profile;
338 enum v4l2_mpeg_video_h264_loop_filter_mode loop_filter_mode;
339 s8 loop_filter_alpha;
340 s8 loop_filter_beta;
341 enum v4l2_mpeg_video_h264_entropy_mode entropy_mode;
342 u8 max_ref_pic;
343 u8 num_ref_pic_4p;
344 int _8x8_transform;
af935746
KD
345 int rc_mb_dark;
346 int rc_mb_smooth;
347 int rc_mb_static;
348 int rc_mb_activity;
349 int vui_sar;
350 u8 vui_sar_idc;
351 u16 vui_ext_sar_width;
352 u16 vui_ext_sar_height;
353 int open_gop;
354 u16 open_gop_size;
355 u8 rc_frame_qp;
356 u8 rc_min_qp;
357 u8 rc_max_qp;
358 u8 rc_p_frame_qp;
359 u8 rc_b_frame_qp;
360 enum v4l2_mpeg_video_h264_level level_v4l2;
361 int level;
362 u16 cpb_size;
8f532a7f 363 int interlace;
f96f3cfa
JP
364 u8 hier_qp;
365 u8 hier_qp_type;
366 u8 hier_qp_layer;
367 u8 hier_qp_layer_qp[7];
368 u8 sei_frame_packing;
369 u8 sei_fp_curr_frame_0;
370 u8 sei_fp_arrangement_type;
371
372 u8 fmo;
373 u8 fmo_map_type;
374 u8 fmo_slice_grp;
375 u8 fmo_chg_dir;
376 u32 fmo_chg_rate;
377 u32 fmo_run_len[4];
378 u8 aso;
379 u32 aso_slice_order[8];
af935746
KD
380};
381
382/**
383 * struct s5p_mfc_mpeg4_enc_params - encoding parameters for h263 and mpeg4
384 */
385struct s5p_mfc_mpeg4_enc_params {
386 /* MPEG4 Only */
387 enum v4l2_mpeg_video_mpeg4_profile profile;
388 int quarter_pixel;
389 /* Common for MPEG4, H263 */
390 u16 vop_time_res;
391 u16 vop_frm_delta;
392 u8 rc_frame_qp;
393 u8 rc_min_qp;
394 u8 rc_max_qp;
395 u8 rc_p_frame_qp;
396 u8 rc_b_frame_qp;
397 enum v4l2_mpeg_video_mpeg4_level level_v4l2;
398 int level;
399};
400
401/**
402 * struct s5p_mfc_enc_params - general encoding parameters
403 */
404struct s5p_mfc_enc_params {
405 u16 width;
406 u16 height;
407
408 u16 gop_size;
409 enum v4l2_mpeg_video_multi_slice_mode slice_mode;
410 u16 slice_mb;
411 u32 slice_bit;
412 u16 intra_refresh_mb;
413 int pad;
414 u8 pad_luma;
415 u8 pad_cb;
416 u8 pad_cr;
417 int rc_frame;
8f532a7f 418 int rc_mb;
af935746
KD
419 u32 rc_bitrate;
420 u16 rc_reaction_coeff;
421 u16 vbv_size;
f96f3cfa 422 u32 vbv_delay;
af935746
KD
423
424 enum v4l2_mpeg_video_header_mode seq_hdr_mode;
425 enum v4l2_mpeg_mfc51_video_frame_skip_mode frame_skip_mode;
426 int fixed_target_bit;
427
428 u8 num_b_frame;
429 u32 rc_framerate_num;
430 u32 rc_framerate_denom;
af935746 431
ac5f867f 432 struct {
af935746
KD
433 struct s5p_mfc_h264_enc_params h264;
434 struct s5p_mfc_mpeg4_enc_params mpeg4;
435 } codec;
436
437};
438
439/**
440 * struct s5p_mfc_codec_ops - codec ops, used by encoding
441 */
442struct s5p_mfc_codec_ops {
443 /* initialization routines */
444 int (*pre_seq_start) (struct s5p_mfc_ctx *ctx);
445 int (*post_seq_start) (struct s5p_mfc_ctx *ctx);
446 /* execution routines */
447 int (*pre_frame_start) (struct s5p_mfc_ctx *ctx);
448 int (*post_frame_start) (struct s5p_mfc_ctx *ctx);
449};
450
451#define call_cop(c, op, args...) \
452 (((c)->c_ops->op) ? \
453 ((c)->c_ops->op(args)) : 0)
454
455/**
456 * struct s5p_mfc_ctx - This struct contains the instance context
457 *
458 * @dev: pointer to the s5p_mfc_dev of the device
459 * @fh: struct v4l2_fh
460 * @num: number of the context that this structure describes
461 * @int_cond: variable used by the waitqueue
462 * @int_type: type of the last interrupt
463 * @int_err: error number received from MFC hw in the interrupt
464 * @queue: waitqueue that can be used to wait for this context to
465 * finish
466 * @src_fmt: source pixelformat information
467 * @dst_fmt: destination pixelformat information
468 * @vq_src: vb2 queue for source buffers
469 * @vq_dst: vb2 queue for destination buffers
470 * @src_queue: driver internal queue for source buffers
471 * @dst_queue: driver internal queue for destination buffers
472 * @src_queue_cnt: number of buffers queued on the source internal queue
473 * @dst_queue_cnt: number of buffers queued on the dest internal queue
474 * @type: type of the instance - decoder or encoder
475 * @state: state of the context
476 * @inst_no: number of hw instance associated with the context
477 * @img_width: width of the image that is decoded or encoded
478 * @img_height: height of the image that is decoded or encoded
479 * @buf_width: width of the buffer for processed image
480 * @buf_height: height of the buffer for processed image
481 * @luma_size: size of a luma plane
482 * @chroma_size: size of a chroma plane
483 * @mv_size: size of a motion vectors buffer
484 * @consumed_stream: number of bytes that have been used so far from the
485 * decoding buffer
486 * @dpb_flush_flag: flag used to indicate that a DPB buffers are being
487 * flushed
f96f3cfa
JP
488 * @head_processed: flag mentioning whether the header data is processed
489 * completely or not
317b4ca4 490 * @bank1: handle to memory allocated for temporary buffers from
af935746 491 * memory bank 1
317b4ca4 492 * @bank2: handle to memory allocated for temporary buffers from
af935746
KD
493 * memory bank 2
494 * @capture_state: state of the capture buffers queue
495 * @output_state: state of the output buffers queue
496 * @src_bufs: information on allocated source buffers
497 * @dst_bufs: information on allocated destination buffers
498 * @sequence: counter for the sequence number for v4l2
499 * @dec_dst_flag: flags for buffers queued in the hardware
500 * @dec_src_buf_size: size of the buffer for source buffers in decoding
501 * @codec_mode: number of codec mode used by MFC hw
502 * @slice_interface: slice interface flag
503 * @loop_filter_mpeg4: loop filter for MPEG4 flag
504 * @display_delay: value of the display delay for H264
505 * @display_delay_enable: display delay for H264 enable flag
506 * @after_packed_pb: flag used to track buffer when stream is in
507 * Packed PB format
f96f3cfa 508 * @sei_fp_parse: enable/disable parsing of frame packing SEI information
af935746
KD
509 * @dpb_count: count of the DPB buffers required by MFC hw
510 * @total_dpb_count: count of DPB buffers with additional buffers
511 * requested by the application
8f532a7f
AK
512 * @ctx: context buffer information
513 * @dsc: descriptor buffer information
514 * @shm: shared memory buffer information
f96f3cfa 515 * @mv_count: number of MV buffers allocated for decoding
af935746
KD
516 * @enc_params: encoding parameters for MFC
517 * @enc_dst_buf_size: size of the buffers for encoder output
f96f3cfa
JP
518 * @luma_dpb_size: dpb buffer size for luma
519 * @chroma_dpb_size: dpb buffer size for chroma
520 * @me_buffer_size: size of the motion estimation buffer
521 * @tmv_buffer_size: size of temporal predictor motion vector buffer
af935746
KD
522 * @frame_type: used to force the type of the next encoded frame
523 * @ref_queue: list of the reference buffers for encoding
524 * @ref_queue_cnt: number of the buffers in the reference list
525 * @c_ops: ops for encoding
526 * @ctrls: array of controls, used when adding controls to the
527 * v4l2 control framework
528 * @ctrl_handler: handler for v4l2 framework
529 */
530struct s5p_mfc_ctx {
531 struct s5p_mfc_dev *dev;
532 struct v4l2_fh fh;
533
534 int num;
535
536 int int_cond;
537 int int_type;
538 unsigned int int_err;
539 wait_queue_head_t queue;
540
541 struct s5p_mfc_fmt *src_fmt;
542 struct s5p_mfc_fmt *dst_fmt;
543
544 struct vb2_queue vq_src;
545 struct vb2_queue vq_dst;
546
547 struct list_head src_queue;
548 struct list_head dst_queue;
549
550 unsigned int src_queue_cnt;
551 unsigned int dst_queue_cnt;
552
553 enum s5p_mfc_inst_type type;
554 enum s5p_mfc_inst_state state;
555 int inst_no;
556
557 /* Image parameters */
558 int img_width;
559 int img_height;
560 int buf_width;
561 int buf_height;
562
563 int luma_size;
564 int chroma_size;
565 int mv_size;
566
567 unsigned long consumed_stream;
568
569 unsigned int dpb_flush_flag;
f96f3cfa 570 unsigned int head_processed;
af935746 571
317b4ca4
KD
572 struct s5p_mfc_priv_buf bank1;
573 struct s5p_mfc_priv_buf bank2;
af935746
KD
574
575 enum s5p_mfc_queue_state capture_state;
576 enum s5p_mfc_queue_state output_state;
577
578 struct s5p_mfc_buf src_bufs[MFC_MAX_BUFFERS];
579 int src_bufs_cnt;
580 struct s5p_mfc_buf dst_bufs[MFC_MAX_BUFFERS];
581 int dst_bufs_cnt;
582
583 unsigned int sequence;
584 unsigned long dec_dst_flag;
585 size_t dec_src_buf_size;
586
587 /* Control values */
588 int codec_mode;
589 int slice_interface;
590 int loop_filter_mpeg4;
591 int display_delay;
592 int display_delay_enable;
593 int after_packed_pb;
f96f3cfa 594 int sei_fp_parse;
af935746 595
e9d98ddc 596 int pb_count;
af935746 597 int total_dpb_count;
f96f3cfa 598 int mv_count;
af935746 599 /* Buffers */
8f532a7f
AK
600 struct s5p_mfc_priv_buf ctx;
601 struct s5p_mfc_priv_buf dsc;
602 struct s5p_mfc_priv_buf shm;
af935746
KD
603
604 struct s5p_mfc_enc_params enc_params;
605
606 size_t enc_dst_buf_size;
f96f3cfa
JP
607 size_t luma_dpb_size;
608 size_t chroma_dpb_size;
609 size_t me_buffer_size;
610 size_t tmv_buffer_size;
af935746
KD
611
612 enum v4l2_mpeg_mfc51_video_force_frame_type force_frame_type;
613
614 struct list_head ref_queue;
615 unsigned int ref_queue_cnt;
616
f96f3cfa
JP
617 enum v4l2_mpeg_video_multi_slice_mode slice_mode;
618 union {
619 unsigned int mb;
620 unsigned int bits;
621 } slice_size;
622
af935746
KD
623 struct s5p_mfc_codec_ops *c_ops;
624
625 struct v4l2_ctrl *ctrls[MFC_MAX_CTRLS];
626 struct v4l2_ctrl_handler ctrl_handler;
f96f3cfa
JP
627 unsigned int frame_tag;
628 size_t scratch_buf_size;
af935746
KD
629};
630
631/*
632 * struct s5p_mfc_fmt - structure used to store information about pixelformats
633 * used by the MFC
634 */
635struct s5p_mfc_fmt {
636 char *name;
637 u32 fourcc;
638 u32 codec_mode;
639 enum s5p_mfc_fmt_type type;
640 u32 num_planes;
641};
642
643/**
644 * struct mfc_control - structure used to store information about MFC controls
645 * it is used to initialize the control framework.
646 */
647struct mfc_control {
648 __u32 id;
649 enum v4l2_ctrl_type type;
650 __u8 name[32]; /* Whatever */
651 __s32 minimum; /* Note signedness */
652 __s32 maximum;
653 __s32 step;
654 __u32 menu_skip_mask;
655 __s32 default_value;
656 __u32 flags;
657 __u32 reserved[2];
658 __u8 is_volatile;
659};
660
43a1ea1f
AK
661/* Macro for making hardware specific calls */
662#define s5p_mfc_hw_call(f, op, args...) \
663 ((f && f->op) ? f->op(args) : -ENODEV)
af935746
KD
664
665#define fh_to_ctx(__fh) container_of(__fh, struct s5p_mfc_ctx, fh)
666#define ctrl_to_ctx(__ctrl) \
667 container_of((__ctrl)->handler, struct s5p_mfc_ctx, ctrl_handler)
668
7fb89eca
AH
669void clear_work_bit(struct s5p_mfc_ctx *ctx);
670void set_work_bit(struct s5p_mfc_ctx *ctx);
671void clear_work_bit_irqsave(struct s5p_mfc_ctx *ctx);
672void set_work_bit_irqsave(struct s5p_mfc_ctx *ctx);
673
f96f3cfa
JP
674#define HAS_PORTNUM(dev) (dev ? (dev->variant ? \
675 (dev->variant->port_num ? 1 : 0) : 0) : 0)
676#define IS_TWOPORT(dev) (dev->variant->port_num == 2 ? 1 : 0)
677#define IS_MFCV6(dev) (dev->variant->version >= 0x60 ? 1 : 0)
678
af935746 679#endif /* S5P_MFC_COMMON_H_ */