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