adv7842.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. /*
  31. * Bus rotation and reordering. This is used to specify component reordering on
  32. * the board and describes the components order on the bus when the ADV7842
  33. * outputs RGB.
  34. */
  35. enum adv7842_bus_order {
  36. ADV7842_BUS_ORDER_RGB, /* No operation */
  37. ADV7842_BUS_ORDER_GRB, /* Swap 1-2 */
  38. ADV7842_BUS_ORDER_RBG, /* Swap 2-3 */
  39. ADV7842_BUS_ORDER_BGR, /* Swap 1-3 */
  40. ADV7842_BUS_ORDER_BRG, /* Rotate right */
  41. ADV7842_BUS_ORDER_GBR, /* Rotate left */
  42. };
  43. /* Input Color Space (IO register 0x02, [7:4]) */
  44. enum adv7842_inp_color_space {
  45. ADV7842_INP_COLOR_SPACE_LIM_RGB = 0,
  46. ADV7842_INP_COLOR_SPACE_FULL_RGB = 1,
  47. ADV7842_INP_COLOR_SPACE_LIM_YCbCr_601 = 2,
  48. ADV7842_INP_COLOR_SPACE_LIM_YCbCr_709 = 3,
  49. ADV7842_INP_COLOR_SPACE_XVYCC_601 = 4,
  50. ADV7842_INP_COLOR_SPACE_XVYCC_709 = 5,
  51. ADV7842_INP_COLOR_SPACE_FULL_YCbCr_601 = 6,
  52. ADV7842_INP_COLOR_SPACE_FULL_YCbCr_709 = 7,
  53. ADV7842_INP_COLOR_SPACE_AUTO = 0xf,
  54. };
  55. /* Select output format (IO register 0x03, [4:2]) */
  56. enum adv7842_op_format_mode_sel {
  57. ADV7842_OP_FORMAT_MODE0 = 0x00,
  58. ADV7842_OP_FORMAT_MODE1 = 0x04,
  59. ADV7842_OP_FORMAT_MODE2 = 0x08,
  60. };
  61. /* Mode of operation */
  62. enum adv7842_mode {
  63. ADV7842_MODE_SDP,
  64. ADV7842_MODE_COMP,
  65. ADV7842_MODE_RGB,
  66. ADV7842_MODE_HDMI
  67. };
  68. /* Video standard select (IO register 0x00, [5:0]) */
  69. enum adv7842_vid_std_select {
  70. /* SDP */
  71. ADV7842_SDP_VID_STD_CVBS_SD_4x1 = 0x01,
  72. ADV7842_SDP_VID_STD_YC_SD4_x1 = 0x09,
  73. /* RGB */
  74. ADV7842_RGB_VID_STD_AUTO_GRAPH_MODE = 0x07,
  75. /* HDMI GR */
  76. ADV7842_HDMI_GR_VID_STD_AUTO_GRAPH_MODE = 0x02,
  77. /* HDMI COMP */
  78. ADV7842_HDMI_COMP_VID_STD_HD_1250P = 0x1e,
  79. };
  80. enum adv7842_select_input {
  81. ADV7842_SELECT_HDMI_PORT_A,
  82. ADV7842_SELECT_HDMI_PORT_B,
  83. ADV7842_SELECT_VGA_RGB,
  84. ADV7842_SELECT_VGA_COMP,
  85. ADV7842_SELECT_SDP_CVBS,
  86. ADV7842_SELECT_SDP_YC,
  87. };
  88. enum adv7842_drive_strength {
  89. ADV7842_DR_STR_LOW = 0,
  90. ADV7842_DR_STR_MEDIUM_LOW = 1,
  91. ADV7842_DR_STR_MEDIUM_HIGH = 2,
  92. ADV7842_DR_STR_HIGH = 3,
  93. };
  94. struct adv7842_sdp_csc_coeff {
  95. bool manual;
  96. u16 scaling;
  97. u16 A1;
  98. u16 A2;
  99. u16 A3;
  100. u16 A4;
  101. u16 B1;
  102. u16 B2;
  103. u16 B3;
  104. u16 B4;
  105. u16 C1;
  106. u16 C2;
  107. u16 C3;
  108. u16 C4;
  109. };
  110. struct adv7842_sdp_io_sync_adjustment {
  111. bool adjust;
  112. u16 hs_beg;
  113. u16 hs_width;
  114. u16 de_beg;
  115. u16 de_end;
  116. u8 vs_beg_o;
  117. u8 vs_beg_e;
  118. u8 vs_end_o;
  119. u8 vs_end_e;
  120. u8 de_v_beg_o;
  121. u8 de_v_beg_e;
  122. u8 de_v_end_o;
  123. u8 de_v_end_e;
  124. };
  125. /* Platform dependent definition */
  126. struct adv7842_platform_data {
  127. /* chip reset during probe */
  128. unsigned chip_reset:1;
  129. /* DIS_PWRDNB: 1 if the PWRDNB pin is unused and unconnected */
  130. unsigned disable_pwrdnb:1;
  131. /* DIS_CABLE_DET_RST: 1 if the 5V pins are unused and unconnected */
  132. unsigned disable_cable_det_rst:1;
  133. /* Analog input muxing mode */
  134. enum adv7842_ain_sel ain_sel;
  135. /* Bus rotation and reordering */
  136. enum adv7842_bus_order bus_order;
  137. /* Select output format mode */
  138. enum adv7842_op_format_mode_sel op_format_mode_sel;
  139. /* Default mode */
  140. enum adv7842_mode mode;
  141. /* Default input */
  142. unsigned input;
  143. /* Video standard */
  144. enum adv7842_vid_std_select vid_std_select;
  145. /* IO register 0x02 */
  146. unsigned alt_gamma:1;
  147. unsigned op_656_range:1;
  148. unsigned alt_data_sat:1;
  149. /* IO register 0x05 */
  150. unsigned blank_data:1;
  151. unsigned insert_av_codes:1;
  152. unsigned replicate_av_codes:1;
  153. /* IO register 0x30 */
  154. unsigned output_bus_lsb_to_msb:1;
  155. /* IO register 0x14 */
  156. enum adv7842_drive_strength dr_str_data;
  157. enum adv7842_drive_strength dr_str_clk;
  158. enum adv7842_drive_strength dr_str_sync;
  159. /*
  160. * IO register 0x19: Adjustment to the LLC DLL phase in
  161. * increments of 1/32 of a clock period.
  162. */
  163. unsigned llc_dll_phase:5;
  164. /* External RAM for 3-D comb or frame synchronizer */
  165. unsigned sd_ram_size; /* ram size in MB */
  166. unsigned sd_ram_ddr:1; /* ddr or sdr sdram */
  167. /* HDMI free run, CP-reg 0xBA */
  168. unsigned hdmi_free_run_enable:1;
  169. /* 0 = Mode 0: run when there is no TMDS clock
  170. 1 = Mode 1: run when there is no TMDS clock or the
  171. video resolution does not match programmed one. */
  172. unsigned hdmi_free_run_mode:1;
  173. /* SDP free run, CP-reg 0xDD */
  174. unsigned sdp_free_run_auto:1;
  175. unsigned sdp_free_run_man_col_en:1;
  176. unsigned sdp_free_run_cbar_en:1;
  177. unsigned sdp_free_run_force:1;
  178. /* HPA manual (0) or auto (1), affects HDMI register 0x69 */
  179. unsigned hpa_auto:1;
  180. struct adv7842_sdp_csc_coeff sdp_csc_coeff;
  181. struct adv7842_sdp_io_sync_adjustment sdp_io_sync_625;
  182. struct adv7842_sdp_io_sync_adjustment sdp_io_sync_525;
  183. /* i2c addresses */
  184. u8 i2c_sdp_io;
  185. u8 i2c_sdp;
  186. u8 i2c_cp;
  187. u8 i2c_vdp;
  188. u8 i2c_afe;
  189. u8 i2c_hdmi;
  190. u8 i2c_repeater;
  191. u8 i2c_edid;
  192. u8 i2c_infoframe;
  193. u8 i2c_cec;
  194. u8 i2c_avlink;
  195. };
  196. #define V4L2_CID_ADV_RX_ANALOG_SAMPLING_PHASE (V4L2_CID_DV_CLASS_BASE + 0x1000)
  197. #define V4L2_CID_ADV_RX_FREE_RUN_COLOR_MANUAL (V4L2_CID_DV_CLASS_BASE + 0x1001)
  198. #define V4L2_CID_ADV_RX_FREE_RUN_COLOR (V4L2_CID_DV_CLASS_BASE + 0x1002)
  199. /* custom ioctl, used to test the external RAM that's used by the
  200. * deinterlacer. */
  201. #define ADV7842_CMD_RAM_TEST _IO('V', BASE_VIDIOC_PRIVATE)
  202. #define ADV7842_EDID_PORT_A 0
  203. #define ADV7842_EDID_PORT_B 1
  204. #define ADV7842_EDID_PORT_VGA 2
  205. #define ADV7842_PAD_SOURCE 3
  206. #endif