adv7842.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /*
  2. * adv7842 - Analog Devices ADV7842 video decoder driver
  3. *
  4. * Copyright 2013 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
  5. *
  6. * This program is free software; you may redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; version 2 of the License.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  11. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  12. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  13. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  14. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  15. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  16. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  17. * SOFTWARE.
  18. *
  19. */
  20. #ifndef _ADV7842_
  21. #define _ADV7842_
  22. /* Analog input muxing modes (AFE register 0x02, [2:0]) */
  23. enum adv7842_ain_sel {
  24. ADV7842_AIN1_2_3_NC_SYNC_1_2 = 0,
  25. ADV7842_AIN4_5_6_NC_SYNC_2_1 = 1,
  26. ADV7842_AIN7_8_9_NC_SYNC_3_1 = 2,
  27. ADV7842_AIN10_11_12_NC_SYNC_4_1 = 3,
  28. ADV7842_AIN9_4_5_6_SYNC_2_1 = 4,
  29. };
  30. /* Bus rotation and reordering (IO register 0x04, [7:5]) */
  31. enum adv7842_op_ch_sel {
  32. ADV7842_OP_CH_SEL_GBR = 0,
  33. ADV7842_OP_CH_SEL_GRB = 1,
  34. ADV7842_OP_CH_SEL_BGR = 2,
  35. ADV7842_OP_CH_SEL_RGB = 3,
  36. ADV7842_OP_CH_SEL_BRG = 4,
  37. ADV7842_OP_CH_SEL_RBG = 5,
  38. };
  39. /* Mode of operation */
  40. enum adv7842_mode {
  41. ADV7842_MODE_SDP,
  42. ADV7842_MODE_COMP,
  43. ADV7842_MODE_RGB,
  44. ADV7842_MODE_HDMI
  45. };
  46. /* Video standard select (IO register 0x00, [5:0]) */
  47. enum adv7842_vid_std_select {
  48. /* SDP */
  49. ADV7842_SDP_VID_STD_CVBS_SD_4x1 = 0x01,
  50. ADV7842_SDP_VID_STD_YC_SD4_x1 = 0x09,
  51. /* RGB */
  52. ADV7842_RGB_VID_STD_AUTO_GRAPH_MODE = 0x07,
  53. /* HDMI GR */
  54. ADV7842_HDMI_GR_VID_STD_AUTO_GRAPH_MODE = 0x02,
  55. /* HDMI COMP */
  56. ADV7842_HDMI_COMP_VID_STD_HD_1250P = 0x1e,
  57. };
  58. /* Input Color Space (IO register 0x02, [7:4]) */
  59. enum adv7842_inp_color_space {
  60. ADV7842_INP_COLOR_SPACE_LIM_RGB = 0,
  61. ADV7842_INP_COLOR_SPACE_FULL_RGB = 1,
  62. ADV7842_INP_COLOR_SPACE_LIM_YCbCr_601 = 2,
  63. ADV7842_INP_COLOR_SPACE_LIM_YCbCr_709 = 3,
  64. ADV7842_INP_COLOR_SPACE_XVYCC_601 = 4,
  65. ADV7842_INP_COLOR_SPACE_XVYCC_709 = 5,
  66. ADV7842_INP_COLOR_SPACE_FULL_YCbCr_601 = 6,
  67. ADV7842_INP_COLOR_SPACE_FULL_YCbCr_709 = 7,
  68. ADV7842_INP_COLOR_SPACE_AUTO = 0xf,
  69. };
  70. /* Select output format (IO register 0x03, [7:0]) */
  71. enum adv7842_op_format_sel {
  72. ADV7842_OP_FORMAT_SEL_SDR_ITU656_8 = 0x00,
  73. ADV7842_OP_FORMAT_SEL_SDR_ITU656_10 = 0x01,
  74. ADV7842_OP_FORMAT_SEL_SDR_ITU656_12_MODE0 = 0x02,
  75. ADV7842_OP_FORMAT_SEL_SDR_ITU656_12_MODE1 = 0x06,
  76. ADV7842_OP_FORMAT_SEL_SDR_ITU656_12_MODE2 = 0x0a,
  77. ADV7842_OP_FORMAT_SEL_DDR_422_8 = 0x20,
  78. ADV7842_OP_FORMAT_SEL_DDR_422_10 = 0x21,
  79. ADV7842_OP_FORMAT_SEL_DDR_422_12_MODE0 = 0x22,
  80. ADV7842_OP_FORMAT_SEL_DDR_422_12_MODE1 = 0x23,
  81. ADV7842_OP_FORMAT_SEL_DDR_422_12_MODE2 = 0x24,
  82. ADV7842_OP_FORMAT_SEL_SDR_444_24 = 0x40,
  83. ADV7842_OP_FORMAT_SEL_SDR_444_30 = 0x41,
  84. ADV7842_OP_FORMAT_SEL_SDR_444_36_MODE0 = 0x42,
  85. ADV7842_OP_FORMAT_SEL_DDR_444_24 = 0x60,
  86. ADV7842_OP_FORMAT_SEL_DDR_444_30 = 0x61,
  87. ADV7842_OP_FORMAT_SEL_DDR_444_36 = 0x62,
  88. ADV7842_OP_FORMAT_SEL_SDR_ITU656_16 = 0x80,
  89. ADV7842_OP_FORMAT_SEL_SDR_ITU656_20 = 0x81,
  90. ADV7842_OP_FORMAT_SEL_SDR_ITU656_24_MODE0 = 0x82,
  91. ADV7842_OP_FORMAT_SEL_SDR_ITU656_24_MODE1 = 0x86,
  92. ADV7842_OP_FORMAT_SEL_SDR_ITU656_24_MODE2 = 0x8a,
  93. };
  94. enum adv7842_select_input {
  95. ADV7842_SELECT_HDMI_PORT_A,
  96. ADV7842_SELECT_HDMI_PORT_B,
  97. ADV7842_SELECT_VGA_RGB,
  98. ADV7842_SELECT_VGA_COMP,
  99. ADV7842_SELECT_SDP_CVBS,
  100. ADV7842_SELECT_SDP_YC,
  101. };
  102. enum adv7842_drive_strength {
  103. ADV7842_DR_STR_LOW = 0,
  104. ADV7842_DR_STR_MEDIUM_LOW = 1,
  105. ADV7842_DR_STR_MEDIUM_HIGH = 2,
  106. ADV7842_DR_STR_HIGH = 3,
  107. };
  108. struct adv7842_sdp_csc_coeff {
  109. bool manual;
  110. uint16_t scaling;
  111. uint16_t A1;
  112. uint16_t A2;
  113. uint16_t A3;
  114. uint16_t A4;
  115. uint16_t B1;
  116. uint16_t B2;
  117. uint16_t B3;
  118. uint16_t B4;
  119. uint16_t C1;
  120. uint16_t C2;
  121. uint16_t C3;
  122. uint16_t C4;
  123. };
  124. struct adv7842_sdp_io_sync_adjustment {
  125. bool adjust;
  126. uint16_t hs_beg;
  127. uint16_t hs_width;
  128. uint16_t de_beg;
  129. uint16_t de_end;
  130. uint8_t vs_beg_o;
  131. uint8_t vs_beg_e;
  132. uint8_t vs_end_o;
  133. uint8_t vs_end_e;
  134. uint8_t de_v_beg_o;
  135. uint8_t de_v_beg_e;
  136. uint8_t de_v_end_o;
  137. uint8_t de_v_end_e;
  138. };
  139. /* Platform dependent definition */
  140. struct adv7842_platform_data {
  141. /* chip reset during probe */
  142. unsigned chip_reset:1;
  143. /* DIS_PWRDNB: 1 if the PWRDNB pin is unused and unconnected */
  144. unsigned disable_pwrdnb:1;
  145. /* DIS_CABLE_DET_RST: 1 if the 5V pins are unused and unconnected */
  146. unsigned disable_cable_det_rst:1;
  147. /* Analog input muxing mode */
  148. enum adv7842_ain_sel ain_sel;
  149. /* Bus rotation and reordering */
  150. enum adv7842_op_ch_sel op_ch_sel;
  151. /* Default mode */
  152. enum adv7842_mode mode;
  153. /* Default input */
  154. unsigned input;
  155. /* Video standard */
  156. enum adv7842_vid_std_select vid_std_select;
  157. /* Select output format */
  158. enum adv7842_op_format_sel op_format_sel;
  159. /* IO register 0x02 */
  160. unsigned alt_gamma:1;
  161. unsigned op_656_range:1;
  162. unsigned rgb_out:1;
  163. unsigned alt_data_sat:1;
  164. /* IO register 0x05 */
  165. unsigned blank_data:1;
  166. unsigned insert_av_codes:1;
  167. unsigned replicate_av_codes:1;
  168. unsigned invert_cbcr:1;
  169. /* IO register 0x30 */
  170. unsigned output_bus_lsb_to_msb:1;
  171. /* IO register 0x14 */
  172. enum adv7842_drive_strength dr_str_data;
  173. enum adv7842_drive_strength dr_str_clk;
  174. enum adv7842_drive_strength dr_str_sync;
  175. /*
  176. * IO register 0x19: Adjustment to the LLC DLL phase in
  177. * increments of 1/32 of a clock period.
  178. */
  179. unsigned llc_dll_phase:5;
  180. /* External RAM for 3-D comb or frame synchronizer */
  181. unsigned sd_ram_size; /* ram size in MB */
  182. unsigned sd_ram_ddr:1; /* ddr or sdr sdram */
  183. /* HDMI free run, CP-reg 0xBA */
  184. unsigned hdmi_free_run_enable:1;
  185. /* 0 = Mode 0: run when there is no TMDS clock
  186. 1 = Mode 1: run when there is no TMDS clock or the
  187. video resolution does not match programmed one. */
  188. unsigned hdmi_free_run_mode:1;
  189. /* SDP free run, CP-reg 0xDD */
  190. unsigned sdp_free_run_auto:1;
  191. unsigned sdp_free_run_man_col_en:1;
  192. unsigned sdp_free_run_cbar_en:1;
  193. unsigned sdp_free_run_force:1;
  194. /* HPA manual (0) or auto (1), affects HDMI register 0x69 */
  195. unsigned hpa_auto:1;
  196. struct adv7842_sdp_csc_coeff sdp_csc_coeff;
  197. struct adv7842_sdp_io_sync_adjustment sdp_io_sync_625;
  198. struct adv7842_sdp_io_sync_adjustment sdp_io_sync_525;
  199. /* i2c addresses */
  200. u8 i2c_sdp_io;
  201. u8 i2c_sdp;
  202. u8 i2c_cp;
  203. u8 i2c_vdp;
  204. u8 i2c_afe;
  205. u8 i2c_hdmi;
  206. u8 i2c_repeater;
  207. u8 i2c_edid;
  208. u8 i2c_infoframe;
  209. u8 i2c_cec;
  210. u8 i2c_avlink;
  211. };
  212. #define V4L2_CID_ADV_RX_ANALOG_SAMPLING_PHASE (V4L2_CID_DV_CLASS_BASE + 0x1000)
  213. #define V4L2_CID_ADV_RX_FREE_RUN_COLOR_MANUAL (V4L2_CID_DV_CLASS_BASE + 0x1001)
  214. #define V4L2_CID_ADV_RX_FREE_RUN_COLOR (V4L2_CID_DV_CLASS_BASE + 0x1002)
  215. /* notify events */
  216. #define ADV7842_FMT_CHANGE 1
  217. /* custom ioctl, used to test the external RAM that's used by the
  218. * deinterlacer. */
  219. #define ADV7842_CMD_RAM_TEST _IO('V', BASE_VIDIOC_PRIVATE)
  220. #define ADV7842_EDID_PORT_A 0
  221. #define ADV7842_EDID_PORT_B 1
  222. #define ADV7842_EDID_PORT_VGA 2
  223. #endif