adv7842.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. struct adv7842_sdp_csc_coeff {
  103. bool manual;
  104. uint16_t scaling;
  105. uint16_t A1;
  106. uint16_t A2;
  107. uint16_t A3;
  108. uint16_t A4;
  109. uint16_t B1;
  110. uint16_t B2;
  111. uint16_t B3;
  112. uint16_t B4;
  113. uint16_t C1;
  114. uint16_t C2;
  115. uint16_t C3;
  116. uint16_t C4;
  117. };
  118. struct adv7842_sdp_io_sync_adjustment {
  119. bool adjust;
  120. uint16_t hs_beg;
  121. uint16_t hs_width;
  122. uint16_t de_beg;
  123. uint16_t de_end;
  124. };
  125. /* Platform dependent definition */
  126. struct adv7842_platform_data {
  127. /* connector - HDMI or DVI? */
  128. unsigned connector_hdmi:1;
  129. /* chip reset during probe */
  130. unsigned chip_reset:1;
  131. /* DIS_PWRDNB: 1 if the PWRDNB pin is unused and unconnected */
  132. unsigned disable_pwrdnb:1;
  133. /* DIS_CABLE_DET_RST: 1 if the 5V pins are unused and unconnected */
  134. unsigned disable_cable_det_rst:1;
  135. /* Analog input muxing mode */
  136. enum adv7842_ain_sel ain_sel;
  137. /* Bus rotation and reordering */
  138. enum adv7842_op_ch_sel op_ch_sel;
  139. /* Default mode */
  140. enum adv7842_mode mode;
  141. /* Video standard */
  142. enum adv7842_vid_std_select vid_std_select;
  143. /* Input Color Space */
  144. enum adv7842_inp_color_space inp_color_space;
  145. /* Select output format */
  146. enum adv7842_op_format_sel op_format_sel;
  147. /* IO register 0x02 */
  148. unsigned alt_gamma:1;
  149. unsigned op_656_range:1;
  150. unsigned rgb_out:1;
  151. unsigned alt_data_sat:1;
  152. /* IO register 0x05 */
  153. unsigned blank_data:1;
  154. unsigned insert_av_codes:1;
  155. unsigned replicate_av_codes:1;
  156. unsigned invert_cbcr:1;
  157. /* IO register 0x30 */
  158. unsigned output_bus_lsb_to_msb:1;
  159. /* IO register 0x14 */
  160. struct {
  161. unsigned data:2;
  162. unsigned clock:2;
  163. unsigned sync:2;
  164. } drive_strength;
  165. /* External RAM for 3-D comb or frame synchronizer */
  166. unsigned sd_ram_size; /* ram size in MB */
  167. unsigned sd_ram_ddr:1; /* ddr or sdr sdram */
  168. /* Free run */
  169. unsigned hdmi_free_run_mode;
  170. struct adv7842_sdp_csc_coeff sdp_csc_coeff;
  171. struct adv7842_sdp_io_sync_adjustment sdp_io_sync;
  172. /* i2c addresses */
  173. u8 i2c_sdp_io;
  174. u8 i2c_sdp;
  175. u8 i2c_cp;
  176. u8 i2c_vdp;
  177. u8 i2c_afe;
  178. u8 i2c_hdmi;
  179. u8 i2c_repeater;
  180. u8 i2c_edid;
  181. u8 i2c_infoframe;
  182. u8 i2c_cec;
  183. u8 i2c_avlink;
  184. };
  185. #define V4L2_CID_ADV_RX_ANALOG_SAMPLING_PHASE (V4L2_CID_DV_CLASS_BASE + 0x1000)
  186. #define V4L2_CID_ADV_RX_FREE_RUN_COLOR_MANUAL (V4L2_CID_DV_CLASS_BASE + 0x1001)
  187. #define V4L2_CID_ADV_RX_FREE_RUN_COLOR (V4L2_CID_DV_CLASS_BASE + 0x1002)
  188. /* notify events */
  189. #define ADV7842_FMT_CHANGE 1
  190. /* custom ioctl, used to test the external RAM that's used by the
  191. * deinterlacer. */
  192. #define ADV7842_CMD_RAM_TEST _IO('V', BASE_VIDIOC_PRIVATE)
  193. #endif