cx25840.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * cx25840.h - definition for cx25840/1/2/3 inputs
  4. *
  5. * Copyright (C) 2006 Hans Verkuil ([email protected])
  6. */
  7. #ifndef _CX25840_H_
  8. #define _CX25840_H_
  9. /*
  10. * Note that the cx25840 driver requires that the bridge driver calls the
  11. * v4l2_subdev's load_fw operation in order to load the driver's firmware.
  12. * This will load the firmware on the first invocation (further ones are NOP).
  13. * Without this the audio standard detection will fail and you will
  14. * only get mono.
  15. * Alternatively, you can call the reset operation (this can be done
  16. * multiple times if needed, each invocation will fully reinitialize
  17. * the device).
  18. *
  19. * Since loading the firmware is often problematic when the driver is
  20. * compiled into the kernel I recommend postponing calling this function
  21. * until the first open of the video device. Another reason for
  22. * postponing it is that loading this firmware takes a long time (seconds)
  23. * due to the slow i2c bus speed. So it will speed up the boot process if
  24. * you can avoid loading the fw as long as the video device isn't used.
  25. */
  26. enum cx25840_video_input {
  27. /* Composite video inputs In1-In8 */
  28. CX25840_COMPOSITE1 = 1,
  29. CX25840_COMPOSITE2,
  30. CX25840_COMPOSITE3,
  31. CX25840_COMPOSITE4,
  32. CX25840_COMPOSITE5,
  33. CX25840_COMPOSITE6,
  34. CX25840_COMPOSITE7,
  35. CX25840_COMPOSITE8,
  36. /*
  37. * S-Video inputs consist of one luma input (In1-In8) ORed with one
  38. * chroma input (In5-In8)
  39. */
  40. CX25840_SVIDEO_LUMA1 = 0x10,
  41. CX25840_SVIDEO_LUMA2 = 0x20,
  42. CX25840_SVIDEO_LUMA3 = 0x30,
  43. CX25840_SVIDEO_LUMA4 = 0x40,
  44. CX25840_SVIDEO_LUMA5 = 0x50,
  45. CX25840_SVIDEO_LUMA6 = 0x60,
  46. CX25840_SVIDEO_LUMA7 = 0x70,
  47. CX25840_SVIDEO_LUMA8 = 0x80,
  48. CX25840_SVIDEO_CHROMA4 = 0x400,
  49. CX25840_SVIDEO_CHROMA5 = 0x500,
  50. CX25840_SVIDEO_CHROMA6 = 0x600,
  51. CX25840_SVIDEO_CHROMA7 = 0x700,
  52. CX25840_SVIDEO_CHROMA8 = 0x800,
  53. /* S-Video aliases for common luma/chroma combinations */
  54. CX25840_SVIDEO1 = 0x510,
  55. CX25840_SVIDEO2 = 0x620,
  56. CX25840_SVIDEO3 = 0x730,
  57. CX25840_SVIDEO4 = 0x840,
  58. /* Allow frames to specify specific input configurations */
  59. CX25840_VIN1_CH1 = 0x80000000,
  60. CX25840_VIN2_CH1 = 0x80000001,
  61. CX25840_VIN3_CH1 = 0x80000002,
  62. CX25840_VIN4_CH1 = 0x80000003,
  63. CX25840_VIN5_CH1 = 0x80000004,
  64. CX25840_VIN6_CH1 = 0x80000005,
  65. CX25840_VIN7_CH1 = 0x80000006,
  66. CX25840_VIN8_CH1 = 0x80000007,
  67. CX25840_VIN4_CH2 = 0x80000000,
  68. CX25840_VIN5_CH2 = 0x80000010,
  69. CX25840_VIN6_CH2 = 0x80000020,
  70. CX25840_NONE_CH2 = 0x80000030,
  71. CX25840_VIN7_CH3 = 0x80000000,
  72. CX25840_VIN8_CH3 = 0x80000040,
  73. CX25840_NONE0_CH3 = 0x80000080,
  74. CX25840_NONE1_CH3 = 0x800000c0,
  75. CX25840_SVIDEO_ON = 0x80000100,
  76. CX25840_COMPONENT_ON = 0x80000200,
  77. CX25840_DIF_ON = 0x80000400,
  78. };
  79. /*
  80. * The defines below are used to set the chip video output settings
  81. * in the generic mode that can be enabled by calling the subdevice
  82. * init core op.
  83. *
  84. * The requested settings can be passed to the init core op as
  85. * @val parameter and to the s_routing video op as @config parameter.
  86. *
  87. * For details please refer to the section 3.7 Video Output Formatting and
  88. * to Video Out Control 1 to 4 registers in the section 5.6 Video Decoder Core
  89. * of the chip datasheet.
  90. */
  91. #define CX25840_VCONFIG_FMT_SHIFT 0
  92. #define CX25840_VCONFIG_FMT_MASK GENMASK(2, 0)
  93. #define CX25840_VCONFIG_FMT_BT601 BIT(0)
  94. #define CX25840_VCONFIG_FMT_BT656 BIT(1)
  95. #define CX25840_VCONFIG_FMT_VIP11 GENMASK(1, 0)
  96. #define CX25840_VCONFIG_FMT_VIP2 BIT(2)
  97. #define CX25840_VCONFIG_RES_SHIFT 3
  98. #define CX25840_VCONFIG_RES_MASK GENMASK(4, 3)
  99. #define CX25840_VCONFIG_RES_8BIT BIT(3)
  100. #define CX25840_VCONFIG_RES_10BIT BIT(4)
  101. #define CX25840_VCONFIG_VBIRAW_SHIFT 5
  102. #define CX25840_VCONFIG_VBIRAW_MASK GENMASK(6, 5)
  103. #define CX25840_VCONFIG_VBIRAW_DISABLED BIT(5)
  104. #define CX25840_VCONFIG_VBIRAW_ENABLED BIT(6)
  105. #define CX25840_VCONFIG_ANCDATA_SHIFT 7
  106. #define CX25840_VCONFIG_ANCDATA_MASK GENMASK(8, 7)
  107. #define CX25840_VCONFIG_ANCDATA_DISABLED BIT(7)
  108. #define CX25840_VCONFIG_ANCDATA_ENABLED BIT(8)
  109. #define CX25840_VCONFIG_TASKBIT_SHIFT 9
  110. #define CX25840_VCONFIG_TASKBIT_MASK GENMASK(10, 9)
  111. #define CX25840_VCONFIG_TASKBIT_ZERO BIT(9)
  112. #define CX25840_VCONFIG_TASKBIT_ONE BIT(10)
  113. #define CX25840_VCONFIG_ACTIVE_SHIFT 11
  114. #define CX25840_VCONFIG_ACTIVE_MASK GENMASK(12, 11)
  115. #define CX25840_VCONFIG_ACTIVE_COMPOSITE BIT(11)
  116. #define CX25840_VCONFIG_ACTIVE_HORIZONTAL BIT(12)
  117. #define CX25840_VCONFIG_VALID_SHIFT 13
  118. #define CX25840_VCONFIG_VALID_MASK GENMASK(14, 13)
  119. #define CX25840_VCONFIG_VALID_NORMAL BIT(13)
  120. #define CX25840_VCONFIG_VALID_ANDACTIVE BIT(14)
  121. #define CX25840_VCONFIG_HRESETW_SHIFT 15
  122. #define CX25840_VCONFIG_HRESETW_MASK GENMASK(16, 15)
  123. #define CX25840_VCONFIG_HRESETW_NORMAL BIT(15)
  124. #define CX25840_VCONFIG_HRESETW_PIXCLK BIT(16)
  125. #define CX25840_VCONFIG_CLKGATE_SHIFT 17
  126. #define CX25840_VCONFIG_CLKGATE_MASK GENMASK(18, 17)
  127. #define CX25840_VCONFIG_CLKGATE_NONE BIT(17)
  128. #define CX25840_VCONFIG_CLKGATE_VALID BIT(18)
  129. #define CX25840_VCONFIG_CLKGATE_VALIDACTIVE GENMASK(18, 17)
  130. #define CX25840_VCONFIG_DCMODE_SHIFT 19
  131. #define CX25840_VCONFIG_DCMODE_MASK GENMASK(20, 19)
  132. #define CX25840_VCONFIG_DCMODE_DWORDS BIT(19)
  133. #define CX25840_VCONFIG_DCMODE_BYTES BIT(20)
  134. #define CX25840_VCONFIG_IDID0S_SHIFT 21
  135. #define CX25840_VCONFIG_IDID0S_MASK GENMASK(22, 21)
  136. #define CX25840_VCONFIG_IDID0S_NORMAL BIT(21)
  137. #define CX25840_VCONFIG_IDID0S_LINECNT BIT(22)
  138. #define CX25840_VCONFIG_VIPCLAMP_SHIFT 23
  139. #define CX25840_VCONFIG_VIPCLAMP_MASK GENMASK(24, 23)
  140. #define CX25840_VCONFIG_VIPCLAMP_ENABLED BIT(23)
  141. #define CX25840_VCONFIG_VIPCLAMP_DISABLED BIT(24)
  142. enum cx25840_audio_input {
  143. /* Audio inputs: serial or In4-In8 */
  144. CX25840_AUDIO_SERIAL,
  145. CX25840_AUDIO4 = 4,
  146. CX25840_AUDIO5,
  147. CX25840_AUDIO6,
  148. CX25840_AUDIO7,
  149. CX25840_AUDIO8,
  150. };
  151. enum cx25840_io_pin {
  152. CX25840_PIN_DVALID_PRGM0 = 0,
  153. CX25840_PIN_FIELD_PRGM1,
  154. CX25840_PIN_HRESET_PRGM2,
  155. CX25840_PIN_VRESET_HCTL_PRGM3,
  156. CX25840_PIN_IRQ_N_PRGM4,
  157. CX25840_PIN_IR_TX_PRGM6,
  158. CX25840_PIN_IR_RX_PRGM5,
  159. CX25840_PIN_GPIO0_PRGM8,
  160. CX25840_PIN_GPIO1_PRGM9,
  161. CX25840_PIN_SA_SDIN, /* Alternate GP Input only */
  162. CX25840_PIN_SA_SDOUT, /* Alternate GP Input only */
  163. CX25840_PIN_PLL_CLK_PRGM7,
  164. CX25840_PIN_CHIP_SEL_VIPCLK, /* Output only */
  165. };
  166. enum cx25840_io_pad {
  167. /* Output pads, these must match the actual chip register values */
  168. CX25840_PAD_DEFAULT = 0,
  169. CX25840_PAD_ACTIVE,
  170. CX25840_PAD_VACTIVE,
  171. CX25840_PAD_CBFLAG,
  172. CX25840_PAD_VID_DATA_EXT0,
  173. CX25840_PAD_VID_DATA_EXT1,
  174. CX25840_PAD_GPO0,
  175. CX25840_PAD_GPO1,
  176. CX25840_PAD_GPO2,
  177. CX25840_PAD_GPO3,
  178. CX25840_PAD_IRQ_N,
  179. CX25840_PAD_AC_SYNC,
  180. CX25840_PAD_AC_SDOUT,
  181. CX25840_PAD_PLL_CLK,
  182. CX25840_PAD_VRESET,
  183. CX25840_PAD_RESERVED,
  184. /* Pads for PLL_CLK output only */
  185. CX25840_PAD_XTI_X5_DLL,
  186. CX25840_PAD_AUX_PLL,
  187. CX25840_PAD_VID_PLL,
  188. CX25840_PAD_XTI,
  189. /* Input Pads */
  190. CX25840_PAD_GPI0,
  191. CX25840_PAD_GPI1,
  192. CX25840_PAD_GPI2,
  193. CX25840_PAD_GPI3,
  194. };
  195. enum cx25840_io_pin_strength {
  196. CX25840_PIN_DRIVE_MEDIUM = 0,
  197. CX25840_PIN_DRIVE_SLOW,
  198. CX25840_PIN_DRIVE_FAST,
  199. };
  200. enum cx23885_io_pin {
  201. CX23885_PIN_IR_RX_GPIO19,
  202. CX23885_PIN_IR_TX_GPIO20,
  203. CX23885_PIN_I2S_SDAT_GPIO21,
  204. CX23885_PIN_I2S_WCLK_GPIO22,
  205. CX23885_PIN_I2S_BCLK_GPIO23,
  206. CX23885_PIN_IRQ_N_GPIO16,
  207. };
  208. enum cx23885_io_pad {
  209. CX23885_PAD_IR_RX,
  210. CX23885_PAD_GPIO19,
  211. CX23885_PAD_IR_TX,
  212. CX23885_PAD_GPIO20,
  213. CX23885_PAD_I2S_SDAT,
  214. CX23885_PAD_GPIO21,
  215. CX23885_PAD_I2S_WCLK,
  216. CX23885_PAD_GPIO22,
  217. CX23885_PAD_I2S_BCLK,
  218. CX23885_PAD_GPIO23,
  219. CX23885_PAD_IRQ_N,
  220. CX23885_PAD_GPIO16,
  221. };
  222. /*
  223. * pvr150_workaround activates a workaround for a hardware bug that is
  224. * present in Hauppauge PVR-150 (and possibly PVR-500) cards that have
  225. * certain NTSC tuners (tveeprom tuner model numbers 85, 99 and 112). The
  226. * audio autodetect fails on some channels for these models and the workaround
  227. * is to select the audio standard explicitly. Many thanks to Hauppauge for
  228. * providing this information.
  229. *
  230. * This platform data only needs to be supplied by the ivtv driver.
  231. */
  232. struct cx25840_platform_data {
  233. int pvr150_workaround;
  234. };
  235. #endif