tuner-types.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * descriptions for simple tuners.
  4. */
  5. #ifndef __TUNER_TYPES_H__
  6. #define __TUNER_TYPES_H__
  7. /**
  8. * enum param_type - type of the tuner pameters
  9. *
  10. * @TUNER_PARAM_TYPE_RADIO: Tuner params are for FM and/or AM radio
  11. * @TUNER_PARAM_TYPE_PAL: Tuner params are for PAL color TV standard
  12. * @TUNER_PARAM_TYPE_SECAM: Tuner params are for SECAM color TV standard
  13. * @TUNER_PARAM_TYPE_NTSC: Tuner params are for NTSC color TV standard
  14. * @TUNER_PARAM_TYPE_DIGITAL: Tuner params are for digital TV
  15. */
  16. enum param_type {
  17. TUNER_PARAM_TYPE_RADIO,
  18. TUNER_PARAM_TYPE_PAL,
  19. TUNER_PARAM_TYPE_SECAM,
  20. TUNER_PARAM_TYPE_NTSC,
  21. TUNER_PARAM_TYPE_DIGITAL,
  22. };
  23. /**
  24. * struct tuner_range - define the frequencies supported by the tuner
  25. *
  26. * @limit: Max frequency supported by that range, in 62.5 kHz
  27. * (TV) or 62.5 Hz (Radio), as defined by
  28. * V4L2_TUNER_CAP_LOW.
  29. * @config: Value of the band switch byte (BB) to setup this mode.
  30. * @cb: Value of the CB byte to setup this mode.
  31. *
  32. * Please notice that digital tuners like xc3028/xc4000/xc5000 don't use
  33. * those ranges, as they're defined inside the driver. This is used by
  34. * analog tuners that are compatible with the "Philips way" to setup the
  35. * tuners. On those devices, the tuner set is done via 4 bytes:
  36. *
  37. * #) divider byte1 (DB1)
  38. * #) divider byte 2 (DB2)
  39. * #) Control byte (CB)
  40. * #) band switch byte (BB)
  41. *
  42. * Some tuners also have an additional optional Auxiliary byte (AB).
  43. */
  44. struct tuner_range {
  45. unsigned short limit;
  46. unsigned char config;
  47. unsigned char cb;
  48. };
  49. /**
  50. * struct tuner_params - Parameters to be used to setup the tuner. Those
  51. * are used by drivers/media/tuners/tuner-types.c in
  52. * order to specify the tuner properties. Most of
  53. * the parameters are for tuners based on tda9887 IF-PLL
  54. * multi-standard analog TV/Radio demodulator, with is
  55. * very common on legacy analog tuners.
  56. *
  57. * @type: Type of the tuner parameters, as defined at
  58. * enum param_type. If the tuner supports multiple
  59. * standards, an array should be used, with one
  60. * row per different standard.
  61. * @cb_first_if_lower_freq: Many Philips-based tuners have a comment in
  62. * their datasheet like
  63. * "For channel selection involving band
  64. * switching, and to ensure smooth tuning to the
  65. * desired channel without causing unnecessary
  66. * charge pump action, it is recommended to
  67. * consider the difference between wanted channel
  68. * frequency and the current channel frequency.
  69. * Unnecessary charge pump action will result
  70. * in very low tuning voltage which may drive the
  71. * oscillator to extreme conditions".
  72. * Set cb_first_if_lower_freq to 1, if this check
  73. * is required for this tuner. I tested this for
  74. * PAL by first setting the TV frequency to
  75. * 203 MHz and then switching to 96.6 MHz FM
  76. * radio. The result was static unless the
  77. * control byte was sent first.
  78. * @has_tda9887: Set to 1 if this tuner uses a tda9887
  79. * @port1_fm_high_sensitivity: Many Philips tuners use tda9887 PORT1 to select
  80. * the FM radio sensitivity. If this setting is 1,
  81. * then set PORT1 to 1 to get proper FM reception.
  82. * @port2_fm_high_sensitivity: Some Philips tuners use tda9887 PORT2 to select
  83. * the FM radio sensitivity. If this setting is 1,
  84. * then set PORT2 to 1 to get proper FM reception.
  85. * @fm_gain_normal: Some Philips tuners use tda9887 cGainNormal to
  86. * select the FM radio sensitivity. If this
  87. * setting is 1, e register will use cGainNormal
  88. * instead of cGainLow.
  89. * @intercarrier_mode: Most tuners with a tda9887 use QSS mode.
  90. * Some (cheaper) tuners use Intercarrier mode.
  91. * If this setting is 1, then the tuner needs to
  92. * be set to intercarrier mode.
  93. * @port1_active: This setting sets the default value for PORT1.
  94. * 0 means inactive, 1 means active. Note: the
  95. * actual bit value written to the tda9887 is
  96. * inverted. So a 0 here means a 1 in the B6 bit.
  97. * @port2_active: This setting sets the default value for PORT2.
  98. * 0 means inactive, 1 means active. Note: the
  99. * actual bit value written to the tda9887 is
  100. * inverted. So a 0 here means a 1 in the B7 bit.
  101. * @port1_invert_for_secam_lc: Sometimes PORT1 is inverted when the SECAM-L'
  102. * standard is selected. Set this bit to 1 if this
  103. * is needed.
  104. * @port2_invert_for_secam_lc: Sometimes PORT2 is inverted when the SECAM-L'
  105. * standard is selected. Set this bit to 1 if this
  106. * is needed.
  107. * @port1_set_for_fm_mono: Some cards require PORT1 to be 1 for mono Radio
  108. * FM and 0 for stereo.
  109. * @default_pll_gating_18: Select 18% (or according to datasheet 0%)
  110. * L standard PLL gating, vs the driver default
  111. * of 36%.
  112. * @radio_if: IF to use in radio mode. Tuners with a
  113. * separate radio IF filter seem to use 10.7,
  114. * while those without use 33.3 for PAL/SECAM
  115. * tuners and 41.3 for NTSC tuners.
  116. * 0 = 10.7, 1 = 33.3, 2 = 41.3
  117. * @default_top_low: Default tda9887 TOP value in dB for the low
  118. * band. Default is 0. Range: -16:+15
  119. * @default_top_mid: Default tda9887 TOP value in dB for the mid
  120. * band. Default is 0. Range: -16:+15
  121. * @default_top_high: Default tda9887 TOP value in dB for the high
  122. * band. Default is 0. Range: -16:+15
  123. * @default_top_secam_low: Default tda9887 TOP value in dB for SECAM-L/L'
  124. * for the low band. Default is 0. Several tuners
  125. * require a different TOP value for the
  126. * SECAM-L/L' standards. Range: -16:+15
  127. * @default_top_secam_mid: Default tda9887 TOP value in dB for SECAM-L/L'
  128. * for the mid band. Default is 0. Several tuners
  129. * require a different TOP value for the
  130. * SECAM-L/L' standards. Range: -16:+15
  131. * @default_top_secam_high: Default tda9887 TOP value in dB for SECAM-L/L'
  132. * for the high band. Default is 0. Several tuners
  133. * require a different TOP value for the
  134. * SECAM-L/L' standards. Range: -16:+15
  135. * @iffreq: Intermediate frequency (IF) used by the tuner
  136. * on digital mode.
  137. * @count: Size of the ranges array.
  138. * @ranges: Array with the frequency ranges supported by
  139. * the tuner.
  140. */
  141. struct tuner_params {
  142. enum param_type type;
  143. unsigned int cb_first_if_lower_freq:1;
  144. unsigned int has_tda9887:1;
  145. unsigned int port1_fm_high_sensitivity:1;
  146. unsigned int port2_fm_high_sensitivity:1;
  147. unsigned int fm_gain_normal:1;
  148. unsigned int intercarrier_mode:1;
  149. unsigned int port1_active:1;
  150. unsigned int port2_active:1;
  151. unsigned int port1_invert_for_secam_lc:1;
  152. unsigned int port2_invert_for_secam_lc:1;
  153. unsigned int port1_set_for_fm_mono:1;
  154. unsigned int default_pll_gating_18:1;
  155. unsigned int radio_if:2;
  156. signed int default_top_low:5;
  157. signed int default_top_mid:5;
  158. signed int default_top_high:5;
  159. signed int default_top_secam_low:5;
  160. signed int default_top_secam_mid:5;
  161. signed int default_top_secam_high:5;
  162. u16 iffreq;
  163. unsigned int count;
  164. struct tuner_range *ranges;
  165. };
  166. /**
  167. * struct tunertype - describes the known tuners.
  168. *
  169. * @name: string with the tuner's name.
  170. * @count: size of &struct tuner_params array.
  171. * @params: pointer to &struct tuner_params array.
  172. *
  173. * @min: minimal tuner frequency, in 62.5 kHz step.
  174. * should be multiplied to 16 to convert to MHz.
  175. * @max: minimal tuner frequency, in 62.5 kHz step.
  176. * Should be multiplied to 16 to convert to MHz.
  177. * @stepsize: frequency step, in Hz.
  178. * @initdata: optional byte sequence to initialize the tuner.
  179. * @sleepdata: optional byte sequence to power down the tuner.
  180. */
  181. struct tunertype {
  182. char *name;
  183. unsigned int count;
  184. struct tuner_params *params;
  185. u16 min;
  186. u16 max;
  187. u32 stepsize;
  188. u8 *initdata;
  189. u8 *sleepdata;
  190. };
  191. extern struct tunertype tuners[];
  192. extern unsigned const int tuner_count;
  193. #endif