saa7191.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /*
  2. * saa7191.h - Philips SAA7191 video decoder driver
  3. *
  4. * Copyright (C) 2003 Ladislav Michl <ladis@linux-mips.org>
  5. * Copyright (C) 2004,2005 Mikael Nousiainen <tmnousia@cc.hut.fi>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #ifndef _SAA7191_H_
  12. #define _SAA7191_H_
  13. /* Philips SAA7191 DMSD I2C bus address */
  14. #define SAA7191_ADDR 0x8a
  15. /* Register subaddresses. */
  16. #define SAA7191_REG_IDEL 0x00
  17. #define SAA7191_REG_HSYB 0x01
  18. #define SAA7191_REG_HSYS 0x02
  19. #define SAA7191_REG_HCLB 0x03
  20. #define SAA7191_REG_HCLS 0x04
  21. #define SAA7191_REG_HPHI 0x05
  22. #define SAA7191_REG_LUMA 0x06
  23. #define SAA7191_REG_HUEC 0x07
  24. #define SAA7191_REG_CKTQ 0x08 /* bits 3-7 */
  25. #define SAA7191_REG_CKTS 0x09 /* bits 3-7 */
  26. #define SAA7191_REG_PLSE 0x0a
  27. #define SAA7191_REG_SESE 0x0b
  28. #define SAA7191_REG_GAIN 0x0c
  29. #define SAA7191_REG_STDC 0x0d
  30. #define SAA7191_REG_IOCK 0x0e
  31. #define SAA7191_REG_CTL3 0x0f
  32. #define SAA7191_REG_CTL4 0x10
  33. #define SAA7191_REG_CHCV 0x11
  34. #define SAA7191_REG_HS6B 0x14
  35. #define SAA7191_REG_HS6S 0x15
  36. #define SAA7191_REG_HC6B 0x16
  37. #define SAA7191_REG_HC6S 0x17
  38. #define SAA7191_REG_HP6I 0x18
  39. #define SAA7191_REG_STATUS 0xff /* not really a subaddress */
  40. /* Status Register definitions */
  41. #define SAA7191_STATUS_CODE 0x01 /* color detected flag */
  42. #define SAA7191_STATUS_FIDT 0x20 /* signal type 50/60 Hz */
  43. #define SAA7191_STATUS_HLCK 0x40 /* PLL unlocked(1)/locked(0) */
  44. #define SAA7191_STATUS_STTC 0x80 /* tv/vtr time constant */
  45. /* Luminance Control Register definitions */
  46. /* input mode select bit:
  47. * 0=CVBS (chrominance trap active), 1=S-Video (trap bypassed) */
  48. #define SAA7191_LUMA_BYPS 0x80
  49. /* pre-filter (only when chrominance trap is active) */
  50. #define SAA7191_LUMA_PREF 0x40
  51. /* aperture bandpass to select different characteristics with maximums
  52. * (bits 4-5) */
  53. #define SAA7191_LUMA_BPSS_MASK 0x30
  54. #define SAA7191_LUMA_BPSS_SHIFT 4
  55. #define SAA7191_LUMA_BPSS_3 0x30
  56. #define SAA7191_LUMA_BPSS_2 0x20
  57. #define SAA7191_LUMA_BPSS_1 0x10
  58. #define SAA7191_LUMA_BPSS_0 0x00
  59. /* coring range for high frequency components according to 8-bit luminance
  60. * (bits 2-3)
  61. * 0=coring off, n= (+-)n LSB */
  62. #define SAA7191_LUMA_CORI_MASK 0x0c
  63. #define SAA7191_LUMA_CORI_SHIFT 2
  64. #define SAA7191_LUMA_CORI_3 0x0c
  65. #define SAA7191_LUMA_CORI_2 0x08
  66. #define SAA7191_LUMA_CORI_1 0x04
  67. #define SAA7191_LUMA_CORI_0 0x00
  68. /* aperture bandpass filter weights high frequency components of luminance
  69. * signal (bits 0-1)
  70. * 0=factor 0, 1=0.25, 2=0.5, 3=1 */
  71. #define SAA7191_LUMA_APER_MASK 0x03
  72. #define SAA7191_LUMA_APER_SHIFT 0
  73. #define SAA7191_LUMA_APER_3 0x03
  74. #define SAA7191_LUMA_APER_2 0x02
  75. #define SAA7191_LUMA_APER_1 0x01
  76. #define SAA7191_LUMA_APER_0 0x00
  77. /* Chrominance Gain Control Settings Register definitions */
  78. /* colour on: 0=automatic colour-killer enabled, 1=forced colour on */
  79. #define SAA7191_GAIN_COLO 0x80
  80. /* chrominance gain control (AGC filter)
  81. * 0=loop filter time constant slow, 1=medium, 2=fast, 3=actual gain */
  82. #define SAA7191_GAIN_LFIS_MASK 0x60
  83. #define SAA7191_GAIN_LFIS_SHIFT 5
  84. #define SAA7191_GAIN_LFIS_3 0x60
  85. #define SAA7191_GAIN_LFIS_2 0x40
  86. #define SAA7191_GAIN_LFIS_1 0x20
  87. #define SAA7191_GAIN_LFIS_0 0x00
  88. /* Standard/Mode Control Register definitions */
  89. /* tv/vtr mode bit: 0=TV mode (slow time constant),
  90. * 1=VTR mode (fast time constant) */
  91. #define SAA7191_STDC_VTRC 0x80
  92. /* SAA7191B-specific functions enable (RTCO, ODD and GPSW0 outputs)
  93. * 0=outputs set to high-impedance (circuit equals SAA7191), 1=enabled */
  94. #define SAA7191_STDC_NFEN 0x08
  95. /* HREF generation: 0=like SAA7191, 1=HREF is 8xLLC2 clocks earlier */
  96. #define SAA7191_STDC_HRMV 0x04
  97. /* general purpose switch 0
  98. * (not used with VINO afaik) */
  99. #define SAA7191_STDC_GPSW0 0x02
  100. /* SECAM mode bit: 0=other standards, 1=SECAM */
  101. #define SAA7191_STDC_SECS 0x01
  102. /* I/O and Clock Control Register definitions */
  103. /* horizontal clock PLL: 0=PLL closed,
  104. * 1=PLL circuit open and horizontal freq fixed */
  105. #define SAA7191_IOCK_HPLL 0x80
  106. /* colour-difference output enable (outputs UV0-UV7) */
  107. #define SAA7191_IOCK_OEDC 0x40
  108. /* H-sync output enable */
  109. #define SAA7191_IOCK_OEHS 0x20
  110. /* V-sync output enable */
  111. #define SAA7191_IOCK_OEVS 0x10
  112. /* luminance output enable (outputs Y0-Y7) */
  113. #define SAA7191_IOCK_OEDY 0x08
  114. /* S-VHS bit (chrominance from CVBS or from chrominance input):
  115. * 0=controlled by BYPS-bit, 1=from chrominance input */
  116. #define SAA7191_IOCK_CHRS 0x04
  117. /* general purpose switch 2
  118. * VINO-specific: 0=used with CVBS, 1=used with S-Video */
  119. #define SAA7191_IOCK_GPSW2 0x02
  120. /* general purpose switch 1 */
  121. /* VINO-specific: 0=always, 1=not used!*/
  122. #define SAA7191_IOCK_GPSW1 0x01
  123. /* Miscellaneous Control #1 Register definitions */
  124. /* automatic field detection (50/60Hz standard) */
  125. #define SAA7191_CTL3_AUFD 0x80
  126. /* field select: (if AUFD=0)
  127. * 0=50Hz (625 lines), 1=60Hz (525 lines) */
  128. #define SAA7191_CTL3_FSEL 0x40
  129. /* SECAM cross-colour reduction enable */
  130. #define SAA7191_CTL3_SXCR 0x20
  131. /* sync and clamping pulse enable (HCL and HSY outputs) */
  132. #define SAA7191_CTL3_SCEN 0x10
  133. /* output format: 0=4:1:1, 1=4:2:2 (4:2:2 for VINO) */
  134. #define SAA7191_CTL3_OFTS 0x08
  135. /* luminance delay compensation
  136. * 0=0*2/LLC, 1=+1*2/LLC, 2=+2*2/LLC, 3=+3*2/LLC,
  137. * 4=-4*2/LLC, 5=-3*2/LLC, 6=-2*2/LLC, 7=-1*2/LLC
  138. * step size = 2/LLC = 67.8ns for 50Hz, 81.5ns for 60Hz */
  139. #define SAA7191_CTL3_YDEL_MASK 0x07
  140. #define SAA7191_CTL3_YDEL_SHIFT 0
  141. #define SAA7191_CTL3_YDEL2 0x04
  142. #define SAA7191_CTL3_YDEL1 0x02
  143. #define SAA7191_CTL3_YDEL0 0x01
  144. /* Miscellaneous Control #2 Register definitions */
  145. /* select HREF position
  146. * 0=normal, HREF is matched to YUV output port,
  147. * 1=HREF is matched to CVBS input port */
  148. #define SAA7191_CTL4_HRFS 0x04
  149. /* vertical noise reduction
  150. * 0=normal, 1=searching window, 2=auto-deflection, 3=reduction bypassed */
  151. #define SAA7191_CTL4_VNOI_MASK 0x03
  152. #define SAA7191_CTL4_VNOI_SHIFT 0
  153. #define SAA7191_CTL4_VNOI_3 0x03
  154. #define SAA7191_CTL4_VNOI_2 0x02
  155. #define SAA7191_CTL4_VNOI_1 0x01
  156. #define SAA7191_CTL4_VNOI_0 0x00
  157. /* Chrominance Gain Control Register definitions
  158. * - for QAM-modulated input signals, effects output amplitude
  159. * (SECAM gain fixed)
  160. * (nominal values for UV CCIR level) */
  161. #define SAA7191_CHCV_NTSC 0x2c
  162. #define SAA7191_CHCV_PAL 0x59
  163. /* Driver interface definitions */
  164. #define SAA7191_INPUT_COMPOSITE 0
  165. #define SAA7191_INPUT_SVIDEO 1
  166. #define SAA7191_NORM_PAL 1
  167. #define SAA7191_NORM_NTSC 2
  168. #define SAA7191_NORM_SECAM 3
  169. struct saa7191_status {
  170. /* 0=no signal, 1=signal detected */
  171. int signal;
  172. /* 0=50hz (pal) signal, 1=60hz (ntsc) signal */
  173. int signal_60hz;
  174. /* 0=no color detected, 1=color detected */
  175. int color;
  176. /* current SAA7191_INPUT_ */
  177. int input;
  178. /* current SAA7191_NORM_ */
  179. int norm;
  180. };
  181. #define SAA7191_BANDPASS_MIN 0x00
  182. #define SAA7191_BANDPASS_MAX 0x03
  183. #define SAA7191_BANDPASS_DEFAULT 0x00
  184. #define SAA7191_BANDPASS_WEIGHT_MIN 0x00
  185. #define SAA7191_BANDPASS_WEIGHT_MAX 0x03
  186. #define SAA7191_BANDPASS_WEIGHT_DEFAULT 0x01
  187. #define SAA7191_CORING_MIN 0x00
  188. #define SAA7191_CORING_MAX 0x03
  189. #define SAA7191_CORING_DEFAULT 0x00
  190. #define SAA7191_HUE_MIN 0x00
  191. #define SAA7191_HUE_MAX 0xff
  192. #define SAA7191_HUE_DEFAULT 0x80
  193. #define SAA7191_VTRC_MIN 0x00
  194. #define SAA7191_VTRC_MAX 0x01
  195. #define SAA7191_VTRC_DEFAULT 0x00
  196. #define SAA7191_FORCE_COLOUR_MIN 0x00
  197. #define SAA7191_FORCE_COLOUR_MAX 0x01
  198. #define SAA7191_FORCE_COLOUR_DEFAULT 0x00
  199. #define SAA7191_CHROMA_GAIN_MIN 0x00
  200. #define SAA7191_CHROMA_GAIN_MAX 0x03
  201. #define SAA7191_CHROMA_GAIN_DEFAULT 0x00
  202. #define SAA7191_LUMA_DELAY_MIN -0x04
  203. #define SAA7191_LUMA_DELAY_MAX 0x03
  204. #define SAA7191_LUMA_DELAY_DEFAULT 0x01
  205. #define SAA7191_VNR_MIN 0x00
  206. #define SAA7191_VNR_MAX 0x03
  207. #define SAA7191_VNR_DEFAULT 0x00
  208. #define SAA7191_CONTROL_BANDPASS (V4L2_CID_PRIVATE_BASE + 0)
  209. #define SAA7191_CONTROL_BANDPASS_WEIGHT (V4L2_CID_PRIVATE_BASE + 1)
  210. #define SAA7191_CONTROL_CORING (V4L2_CID_PRIVATE_BASE + 2)
  211. #define SAA7191_CONTROL_FORCE_COLOUR (V4L2_CID_PRIVATE_BASE + 3)
  212. #define SAA7191_CONTROL_CHROMA_GAIN (V4L2_CID_PRIVATE_BASE + 4)
  213. #define SAA7191_CONTROL_VTRC (V4L2_CID_PRIVATE_BASE + 5)
  214. #define SAA7191_CONTROL_LUMA_DELAY (V4L2_CID_PRIVATE_BASE + 6)
  215. #define SAA7191_CONTROL_VNR (V4L2_CID_PRIVATE_BASE + 7)
  216. #define DECODER_SAA7191_GET_STATUS _IOR('d', 195, struct saa7191_status)
  217. #define DECODER_SAA7191_SET_NORM _IOW('d', 196, int)
  218. #endif