adv7842.h 5.4 KB

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