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