s5p_mfc_common.h 18 KB

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