s5p_mfc_opr.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. /*
  2. * drivers/media/platform/s5p-mfc/s5p_mfc_opr.h
  3. *
  4. * Header file for Samsung MFC (Multi Function Codec - FIMV) driver
  5. * Contains declarations of hw related functions.
  6. *
  7. * Kamil Debski, Copyright (C) 2012 Samsung Electronics Co., Ltd.
  8. * http://www.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 version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #ifndef S5P_MFC_OPR_H_
  15. #define S5P_MFC_OPR_H_
  16. #include "s5p_mfc_common.h"
  17. struct s5p_mfc_regs {
  18. /* codec common registers */
  19. volatile void __iomem *risc_on;
  20. volatile void __iomem *risc2host_int;
  21. volatile void __iomem *host2risc_int;
  22. volatile void __iomem *risc_base_address;
  23. volatile void __iomem *mfc_reset;
  24. volatile void __iomem *host2risc_command;
  25. volatile void __iomem *risc2host_command;
  26. volatile void __iomem *mfc_bus_reset_ctrl;
  27. volatile void __iomem *firmware_version;
  28. volatile void __iomem *instance_id;
  29. volatile void __iomem *codec_type;
  30. volatile void __iomem *context_mem_addr;
  31. volatile void __iomem *context_mem_size;
  32. volatile void __iomem *pixel_format;
  33. volatile void __iomem *metadata_enable;
  34. volatile void __iomem *mfc_version;
  35. volatile void __iomem *dbg_info_enable;
  36. volatile void __iomem *dbg_buffer_addr;
  37. volatile void __iomem *dbg_buffer_size;
  38. volatile void __iomem *hed_control;
  39. volatile void __iomem *mfc_timeout_value;
  40. volatile void __iomem *hed_shared_mem_addr;
  41. volatile void __iomem *dis_shared_mem_addr;/* only v7 */
  42. volatile void __iomem *ret_instance_id;
  43. volatile void __iomem *error_code;
  44. volatile void __iomem *dbg_buffer_output_size;
  45. volatile void __iomem *metadata_status;
  46. volatile void __iomem *metadata_addr_mb_info;
  47. volatile void __iomem *metadata_size_mb_info;
  48. volatile void __iomem *dbg_info_stage_counter;
  49. /* decoder registers */
  50. volatile void __iomem *d_crc_ctrl;
  51. volatile void __iomem *d_dec_options;
  52. volatile void __iomem *d_display_delay;
  53. volatile void __iomem *d_set_frame_width;
  54. volatile void __iomem *d_set_frame_height;
  55. volatile void __iomem *d_sei_enable;
  56. volatile void __iomem *d_min_num_dpb;
  57. volatile void __iomem *d_min_first_plane_dpb_size;
  58. volatile void __iomem *d_min_second_plane_dpb_size;
  59. volatile void __iomem *d_min_third_plane_dpb_size;/* only v8 */
  60. volatile void __iomem *d_min_num_mv;
  61. volatile void __iomem *d_mvc_num_views;
  62. volatile void __iomem *d_min_num_dis;/* only v7 */
  63. volatile void __iomem *d_min_first_dis_size;/* only v7 */
  64. volatile void __iomem *d_min_second_dis_size;/* only v7 */
  65. volatile void __iomem *d_min_third_dis_size;/* only v7 */
  66. volatile void __iomem *d_post_filter_luma_dpb0;/* v7 and v8 */
  67. volatile void __iomem *d_post_filter_luma_dpb1;/* v7 and v8 */
  68. volatile void __iomem *d_post_filter_luma_dpb2;/* only v7 */
  69. volatile void __iomem *d_post_filter_chroma_dpb0;/* v7 and v8 */
  70. volatile void __iomem *d_post_filter_chroma_dpb1;/* v7 and v8 */
  71. volatile void __iomem *d_post_filter_chroma_dpb2;/* only v7 */
  72. volatile void __iomem *d_num_dpb;
  73. volatile void __iomem *d_num_mv;
  74. volatile void __iomem *d_init_buffer_options;
  75. volatile void __iomem *d_first_plane_dpb_stride_size;/* only v8 */
  76. volatile void __iomem *d_second_plane_dpb_stride_size;/* only v8 */
  77. volatile void __iomem *d_third_plane_dpb_stride_size;/* only v8 */
  78. volatile void __iomem *d_first_plane_dpb_size;
  79. volatile void __iomem *d_second_plane_dpb_size;
  80. volatile void __iomem *d_third_plane_dpb_size;/* only v8 */
  81. volatile void __iomem *d_mv_buffer_size;
  82. volatile void __iomem *d_first_plane_dpb;
  83. volatile void __iomem *d_second_plane_dpb;
  84. volatile void __iomem *d_third_plane_dpb;
  85. volatile void __iomem *d_mv_buffer;
  86. volatile void __iomem *d_scratch_buffer_addr;
  87. volatile void __iomem *d_scratch_buffer_size;
  88. volatile void __iomem *d_metadata_buffer_addr;
  89. volatile void __iomem *d_metadata_buffer_size;
  90. volatile void __iomem *d_nal_start_options;/* v7 and v8 */
  91. volatile void __iomem *d_cpb_buffer_addr;
  92. volatile void __iomem *d_cpb_buffer_size;
  93. volatile void __iomem *d_available_dpb_flag_upper;
  94. volatile void __iomem *d_available_dpb_flag_lower;
  95. volatile void __iomem *d_cpb_buffer_offset;
  96. volatile void __iomem *d_slice_if_enable;
  97. volatile void __iomem *d_picture_tag;
  98. volatile void __iomem *d_stream_data_size;
  99. volatile void __iomem *d_dynamic_dpb_flag_upper;/* v7 and v8 */
  100. volatile void __iomem *d_dynamic_dpb_flag_lower;/* v7 and v8 */
  101. volatile void __iomem *d_display_frame_width;
  102. volatile void __iomem *d_display_frame_height;
  103. volatile void __iomem *d_display_status;
  104. volatile void __iomem *d_display_first_plane_addr;
  105. volatile void __iomem *d_display_second_plane_addr;
  106. volatile void __iomem *d_display_third_plane_addr;/* only v8 */
  107. volatile void __iomem *d_display_frame_type;
  108. volatile void __iomem *d_display_crop_info1;
  109. volatile void __iomem *d_display_crop_info2;
  110. volatile void __iomem *d_display_picture_profile;
  111. volatile void __iomem *d_display_luma_crc;/* v7 and v8 */
  112. volatile void __iomem *d_display_chroma0_crc;/* v7 and v8 */
  113. volatile void __iomem *d_display_chroma1_crc;/* only v8 */
  114. volatile void __iomem *d_display_luma_crc_top;/* only v6 */
  115. volatile void __iomem *d_display_chroma_crc_top;/* only v6 */
  116. volatile void __iomem *d_display_luma_crc_bot;/* only v6 */
  117. volatile void __iomem *d_display_chroma_crc_bot;/* only v6 */
  118. volatile void __iomem *d_display_aspect_ratio;
  119. volatile void __iomem *d_display_extended_ar;
  120. volatile void __iomem *d_decoded_frame_width;
  121. volatile void __iomem *d_decoded_frame_height;
  122. volatile void __iomem *d_decoded_status;
  123. volatile void __iomem *d_decoded_first_plane_addr;
  124. volatile void __iomem *d_decoded_second_plane_addr;
  125. volatile void __iomem *d_decoded_third_plane_addr;/* only v8 */
  126. volatile void __iomem *d_decoded_frame_type;
  127. volatile void __iomem *d_decoded_crop_info1;
  128. volatile void __iomem *d_decoded_crop_info2;
  129. volatile void __iomem *d_decoded_picture_profile;
  130. volatile void __iomem *d_decoded_nal_size;
  131. volatile void __iomem *d_decoded_luma_crc;
  132. volatile void __iomem *d_decoded_chroma0_crc;
  133. volatile void __iomem *d_decoded_chroma1_crc;/* only v8 */
  134. volatile void __iomem *d_ret_picture_tag_top;
  135. volatile void __iomem *d_ret_picture_tag_bot;
  136. volatile void __iomem *d_ret_picture_time_top;
  137. volatile void __iomem *d_ret_picture_time_bot;
  138. volatile void __iomem *d_chroma_format;
  139. volatile void __iomem *d_vc1_info;/* v7 and v8 */
  140. volatile void __iomem *d_mpeg4_info;
  141. volatile void __iomem *d_h264_info;
  142. volatile void __iomem *d_metadata_addr_concealed_mb;
  143. volatile void __iomem *d_metadata_size_concealed_mb;
  144. volatile void __iomem *d_metadata_addr_vc1_param;
  145. volatile void __iomem *d_metadata_size_vc1_param;
  146. volatile void __iomem *d_metadata_addr_sei_nal;
  147. volatile void __iomem *d_metadata_size_sei_nal;
  148. volatile void __iomem *d_metadata_addr_vui;
  149. volatile void __iomem *d_metadata_size_vui;
  150. volatile void __iomem *d_metadata_addr_mvcvui;/* v7 and v8 */
  151. volatile void __iomem *d_metadata_size_mvcvui;/* v7 and v8 */
  152. volatile void __iomem *d_mvc_view_id;
  153. volatile void __iomem *d_frame_pack_sei_avail;
  154. volatile void __iomem *d_frame_pack_arrgment_id;
  155. volatile void __iomem *d_frame_pack_sei_info;
  156. volatile void __iomem *d_frame_pack_grid_pos;
  157. volatile void __iomem *d_display_recovery_sei_info;/* v7 and v8 */
  158. volatile void __iomem *d_decoded_recovery_sei_info;/* v7 and v8 */
  159. volatile void __iomem *d_display_first_addr;/* only v7 */
  160. volatile void __iomem *d_display_second_addr;/* only v7 */
  161. volatile void __iomem *d_display_third_addr;/* only v7 */
  162. volatile void __iomem *d_decoded_first_addr;/* only v7 */
  163. volatile void __iomem *d_decoded_second_addr;/* only v7 */
  164. volatile void __iomem *d_decoded_third_addr;/* only v7 */
  165. volatile void __iomem *d_used_dpb_flag_upper;/* v7 and v8 */
  166. volatile void __iomem *d_used_dpb_flag_lower;/* v7 and v8 */
  167. /* encoder registers */
  168. volatile void __iomem *e_frame_width;
  169. volatile void __iomem *e_frame_height;
  170. volatile void __iomem *e_cropped_frame_width;
  171. volatile void __iomem *e_cropped_frame_height;
  172. volatile void __iomem *e_frame_crop_offset;
  173. volatile void __iomem *e_enc_options;
  174. volatile void __iomem *e_picture_profile;
  175. volatile void __iomem *e_vbv_buffer_size;
  176. volatile void __iomem *e_vbv_init_delay;
  177. volatile void __iomem *e_fixed_picture_qp;
  178. volatile void __iomem *e_rc_config;
  179. volatile void __iomem *e_rc_qp_bound;
  180. volatile void __iomem *e_rc_qp_bound_pb;/* v7 and v8 */
  181. volatile void __iomem *e_rc_mode;
  182. volatile void __iomem *e_mb_rc_config;
  183. volatile void __iomem *e_padding_ctrl;
  184. volatile void __iomem *e_air_threshold;
  185. volatile void __iomem *e_mv_hor_range;
  186. volatile void __iomem *e_mv_ver_range;
  187. volatile void __iomem *e_num_dpb;
  188. volatile void __iomem *e_luma_dpb;
  189. volatile void __iomem *e_chroma_dpb;
  190. volatile void __iomem *e_me_buffer;
  191. volatile void __iomem *e_scratch_buffer_addr;
  192. volatile void __iomem *e_scratch_buffer_size;
  193. volatile void __iomem *e_tmv_buffer0;
  194. volatile void __iomem *e_tmv_buffer1;
  195. volatile void __iomem *e_ir_buffer_addr;/* v7 and v8 */
  196. volatile void __iomem *e_source_first_plane_addr;
  197. volatile void __iomem *e_source_second_plane_addr;
  198. volatile void __iomem *e_source_third_plane_addr;/* v7 and v8 */
  199. volatile void __iomem *e_source_first_plane_stride;/* v7 and v8 */
  200. volatile void __iomem *e_source_second_plane_stride;/* v7 and v8 */
  201. volatile void __iomem *e_source_third_plane_stride;/* v7 and v8 */
  202. volatile void __iomem *e_stream_buffer_addr;
  203. volatile void __iomem *e_stream_buffer_size;
  204. volatile void __iomem *e_roi_buffer_addr;
  205. volatile void __iomem *e_param_change;
  206. volatile void __iomem *e_ir_size;
  207. volatile void __iomem *e_gop_config;
  208. volatile void __iomem *e_mslice_mode;
  209. volatile void __iomem *e_mslice_size_mb;
  210. volatile void __iomem *e_mslice_size_bits;
  211. volatile void __iomem *e_frame_insertion;
  212. volatile void __iomem *e_rc_frame_rate;
  213. volatile void __iomem *e_rc_bit_rate;
  214. volatile void __iomem *e_rc_roi_ctrl;
  215. volatile void __iomem *e_picture_tag;
  216. volatile void __iomem *e_bit_count_enable;
  217. volatile void __iomem *e_max_bit_count;
  218. volatile void __iomem *e_min_bit_count;
  219. volatile void __iomem *e_metadata_buffer_addr;
  220. volatile void __iomem *e_metadata_buffer_size;
  221. volatile void __iomem *e_encoded_source_first_plane_addr;
  222. volatile void __iomem *e_encoded_source_second_plane_addr;
  223. volatile void __iomem *e_encoded_source_third_plane_addr;/* v7 and v8 */
  224. volatile void __iomem *e_stream_size;
  225. volatile void __iomem *e_slice_type;
  226. volatile void __iomem *e_picture_count;
  227. volatile void __iomem *e_ret_picture_tag;
  228. volatile void __iomem *e_stream_buffer_write_pointer; /* only v6 */
  229. volatile void __iomem *e_recon_luma_dpb_addr;
  230. volatile void __iomem *e_recon_chroma_dpb_addr;
  231. volatile void __iomem *e_metadata_addr_enc_slice;
  232. volatile void __iomem *e_metadata_size_enc_slice;
  233. volatile void __iomem *e_mpeg4_options;
  234. volatile void __iomem *e_mpeg4_hec_period;
  235. volatile void __iomem *e_aspect_ratio;
  236. volatile void __iomem *e_extended_sar;
  237. volatile void __iomem *e_h264_options;
  238. volatile void __iomem *e_h264_options_2;/* v7 and v8 */
  239. volatile void __iomem *e_h264_lf_alpha_offset;
  240. volatile void __iomem *e_h264_lf_beta_offset;
  241. volatile void __iomem *e_h264_i_period;
  242. volatile void __iomem *e_h264_fmo_slice_grp_map_type;
  243. volatile void __iomem *e_h264_fmo_num_slice_grp_minus1;
  244. volatile void __iomem *e_h264_fmo_slice_grp_change_dir;
  245. volatile void __iomem *e_h264_fmo_slice_grp_change_rate_minus1;
  246. volatile void __iomem *e_h264_fmo_run_length_minus1_0;
  247. volatile void __iomem *e_h264_aso_slice_order_0;
  248. volatile void __iomem *e_h264_chroma_qp_offset;
  249. volatile void __iomem *e_h264_num_t_layer;
  250. volatile void __iomem *e_h264_hierarchical_qp_layer0;
  251. volatile void __iomem *e_h264_frame_packing_sei_info;
  252. volatile void __iomem *e_h264_nal_control;/* v7 and v8 */
  253. volatile void __iomem *e_mvc_frame_qp_view1;
  254. volatile void __iomem *e_mvc_rc_bit_rate_view1;
  255. volatile void __iomem *e_mvc_rc_qbound_view1;
  256. volatile void __iomem *e_mvc_rc_mode_view1;
  257. volatile void __iomem *e_mvc_inter_view_prediction_on;
  258. volatile void __iomem *e_vp8_options;/* v7 and v8 */
  259. volatile void __iomem *e_vp8_filter_options;/* v7 and v8 */
  260. volatile void __iomem *e_vp8_golden_frame_option;/* v7 and v8 */
  261. volatile void __iomem *e_vp8_num_t_layer;/* v7 and v8 */
  262. volatile void __iomem *e_vp8_hierarchical_qp_layer0;/* v7 and v8 */
  263. volatile void __iomem *e_vp8_hierarchical_qp_layer1;/* v7 and v8 */
  264. volatile void __iomem *e_vp8_hierarchical_qp_layer2;/* v7 and v8 */
  265. };
  266. struct s5p_mfc_hw_ops {
  267. int (*alloc_dec_temp_buffers)(struct s5p_mfc_ctx *ctx);
  268. void (*release_dec_desc_buffer)(struct s5p_mfc_ctx *ctx);
  269. int (*alloc_codec_buffers)(struct s5p_mfc_ctx *ctx);
  270. void (*release_codec_buffers)(struct s5p_mfc_ctx *ctx);
  271. int (*alloc_instance_buffer)(struct s5p_mfc_ctx *ctx);
  272. void (*release_instance_buffer)(struct s5p_mfc_ctx *ctx);
  273. int (*alloc_dev_context_buffer)(struct s5p_mfc_dev *dev);
  274. void (*release_dev_context_buffer)(struct s5p_mfc_dev *dev);
  275. void (*dec_calc_dpb_size)(struct s5p_mfc_ctx *ctx);
  276. void (*enc_calc_src_size)(struct s5p_mfc_ctx *ctx);
  277. int (*set_dec_stream_buffer)(struct s5p_mfc_ctx *ctx,
  278. int buf_addr, unsigned int start_num_byte,
  279. unsigned int buf_size);
  280. int (*set_dec_frame_buffer)(struct s5p_mfc_ctx *ctx);
  281. int (*set_enc_stream_buffer)(struct s5p_mfc_ctx *ctx,
  282. unsigned long addr, unsigned int size);
  283. void (*set_enc_frame_buffer)(struct s5p_mfc_ctx *ctx,
  284. unsigned long y_addr, unsigned long c_addr);
  285. void (*get_enc_frame_buffer)(struct s5p_mfc_ctx *ctx,
  286. unsigned long *y_addr, unsigned long *c_addr);
  287. int (*set_enc_ref_buffer)(struct s5p_mfc_ctx *ctx);
  288. int (*init_decode)(struct s5p_mfc_ctx *ctx);
  289. int (*init_encode)(struct s5p_mfc_ctx *ctx);
  290. int (*encode_one_frame)(struct s5p_mfc_ctx *ctx);
  291. void (*try_run)(struct s5p_mfc_dev *dev);
  292. void (*cleanup_queue)(struct list_head *lh,
  293. struct vb2_queue *vq);
  294. void (*clear_int_flags)(struct s5p_mfc_dev *dev);
  295. void (*write_info)(struct s5p_mfc_ctx *ctx, unsigned int data,
  296. unsigned int ofs);
  297. unsigned int (*read_info)(struct s5p_mfc_ctx *ctx,
  298. unsigned long ofs);
  299. int (*get_dspl_y_adr)(struct s5p_mfc_dev *dev);
  300. int (*get_dec_y_adr)(struct s5p_mfc_dev *dev);
  301. int (*get_dspl_status)(struct s5p_mfc_dev *dev);
  302. int (*get_dec_status)(struct s5p_mfc_dev *dev);
  303. int (*get_dec_frame_type)(struct s5p_mfc_dev *dev);
  304. int (*get_disp_frame_type)(struct s5p_mfc_ctx *ctx);
  305. int (*get_consumed_stream)(struct s5p_mfc_dev *dev);
  306. int (*get_int_reason)(struct s5p_mfc_dev *dev);
  307. int (*get_int_err)(struct s5p_mfc_dev *dev);
  308. int (*err_dec)(unsigned int err);
  309. int (*err_dspl)(unsigned int err);
  310. int (*get_img_width)(struct s5p_mfc_dev *dev);
  311. int (*get_img_height)(struct s5p_mfc_dev *dev);
  312. int (*get_dpb_count)(struct s5p_mfc_dev *dev);
  313. int (*get_mv_count)(struct s5p_mfc_dev *dev);
  314. int (*get_inst_no)(struct s5p_mfc_dev *dev);
  315. int (*get_enc_strm_size)(struct s5p_mfc_dev *dev);
  316. int (*get_enc_slice_type)(struct s5p_mfc_dev *dev);
  317. int (*get_enc_dpb_count)(struct s5p_mfc_dev *dev);
  318. int (*get_enc_pic_count)(struct s5p_mfc_dev *dev);
  319. int (*get_sei_avail_status)(struct s5p_mfc_ctx *ctx);
  320. int (*get_mvc_num_views)(struct s5p_mfc_dev *dev);
  321. int (*get_mvc_view_id)(struct s5p_mfc_dev *dev);
  322. unsigned int (*get_pic_type_top)(struct s5p_mfc_ctx *ctx);
  323. unsigned int (*get_pic_type_bot)(struct s5p_mfc_ctx *ctx);
  324. unsigned int (*get_crop_info_h)(struct s5p_mfc_ctx *ctx);
  325. unsigned int (*get_crop_info_v)(struct s5p_mfc_ctx *ctx);
  326. };
  327. void s5p_mfc_init_hw_ops(struct s5p_mfc_dev *dev);
  328. void s5p_mfc_init_regs(struct s5p_mfc_dev *dev);
  329. int s5p_mfc_alloc_priv_buf(struct device *dev, dma_addr_t base,
  330. struct s5p_mfc_priv_buf *b);
  331. void s5p_mfc_release_priv_buf(struct device *dev,
  332. struct s5p_mfc_priv_buf *b);
  333. #endif /* S5P_MFC_OPR_H_ */