xref: /linux/drivers/media/pci/cx18/cx18-cards.c (revision 4b4193256c8d3bc3a5397b5cd9494c2ad386317d)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  *  cx18 functions to query card hardware
4  *
5  *  Derived from ivtv-cards.c
6  *
7  *  Copyright (C) 2007  Hans Verkuil <hverkuil@xs4all.nl>
8  *  Copyright (C) 2008  Andy Walls <awalls@md.metrocast.net>
9  */
10 
11 #include "cx18-driver.h"
12 #include "cx18-cards.h"
13 #include "cx18-av-core.h"
14 #include "cx18-i2c.h"
15 #include <media/i2c/cs5345.h>
16 
17 #define V4L2_STD_PAL_SECAM (V4L2_STD_PAL|V4L2_STD_SECAM)
18 
19 /********************** card configuration *******************************/
20 
21 /* usual i2c tuner addresses to probe */
22 static struct cx18_card_tuner_i2c cx18_i2c_std = {
23 	.radio = { I2C_CLIENT_END },
24 	.demod = { 0x43, I2C_CLIENT_END },
25 	.tv    = { 0x61, 0x60, I2C_CLIENT_END },
26 };
27 
28 /*
29  * usual i2c tuner addresses to probe with additional demod address for
30  * an NXP TDA8295 at 0x42 (N.B. it can possibly be at 0x4b or 0x4c too).
31  */
32 static struct cx18_card_tuner_i2c cx18_i2c_nxp = {
33 	.radio = { I2C_CLIENT_END },
34 	.demod = { 0x42, 0x43, I2C_CLIENT_END },
35 	.tv    = { 0x61, 0x60, I2C_CLIENT_END },
36 };
37 
38 /* Please add new PCI IDs to: https://pci-ids.ucw.cz/
39    This keeps the PCI ID database up to date. Note that the entries
40    must be added under vendor 0x4444 (Conexant) as subsystem IDs.
41    New vendor IDs should still be added to the vendor ID list. */
42 
43 /* Hauppauge HVR-1600 cards */
44 
45 /* Note: for Hauppauge cards the tveeprom information is used instead
46    of PCI IDs */
47 static const struct cx18_card cx18_card_hvr1600_esmt = {
48 	.type = CX18_CARD_HVR_1600_ESMT,
49 	.name = "Hauppauge HVR-1600",
50 	.comment = "Simultaneous Digital and Analog TV capture supported\n",
51 	.v4l2_capabilities = CX18_CAP_ENCODER,
52 	.hw_audio_ctrl = CX18_HW_418_AV,
53 	.hw_muxer = CX18_HW_CS5345,
54 	.hw_all = CX18_HW_TVEEPROM | CX18_HW_418_AV | CX18_HW_TUNER |
55 		  CX18_HW_CS5345 | CX18_HW_DVB | CX18_HW_GPIO_RESET_CTRL |
56 		  CX18_HW_Z8F0811_IR_HAUP,
57 	.video_inputs = {
58 		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE7 },
59 		{ CX18_CARD_INPUT_SVIDEO1,    1, CX18_AV_SVIDEO1    },
60 		{ CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE3 },
61 		{ CX18_CARD_INPUT_SVIDEO2,    2, CX18_AV_SVIDEO2    },
62 		{ CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE4 },
63 	},
64 	.audio_inputs = {
65 		{ CX18_CARD_INPUT_AUD_TUNER,
66 		  CX18_AV_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 },
67 		{ CX18_CARD_INPUT_LINE_IN1,
68 		  CX18_AV_AUDIO_SERIAL1, CS5345_IN_2 },
69 		{ CX18_CARD_INPUT_LINE_IN2,
70 		  CX18_AV_AUDIO_SERIAL1, CS5345_IN_3 },
71 	},
72 	.radio_input = { CX18_CARD_INPUT_AUD_TUNER,
73 			 CX18_AV_AUDIO_SERIAL1, CS5345_IN_4 },
74 	.ddr = {
75 		/* ESMT M13S128324A-5B memory */
76 		.chip_config = 0x003,
77 		.refresh = 0x30c,
78 		.timing1 = 0x44220e82,
79 		.timing2 = 0x08,
80 		.tune_lane = 0,
81 		.initial_emrs = 0,
82 	},
83 	.gpio_init.initial_value = 0x3001,
84 	.gpio_init.direction = 0x3001,
85 	.gpio_i2c_slave_reset = {
86 		.active_lo_mask = 0x3001,
87 		.msecs_asserted = 10,
88 		.msecs_recovery = 40,
89 		.ir_reset_mask  = 0x0001,
90 	},
91 	.i2c = &cx18_i2c_std,
92 };
93 
94 static const struct cx18_card cx18_card_hvr1600_s5h1411 = {
95 	.type = CX18_CARD_HVR_1600_S5H1411,
96 	.name = "Hauppauge HVR-1600",
97 	.comment = "Simultaneous Digital and Analog TV capture supported\n",
98 	.v4l2_capabilities = CX18_CAP_ENCODER,
99 	.hw_audio_ctrl = CX18_HW_418_AV,
100 	.hw_muxer = CX18_HW_CS5345,
101 	.hw_all = CX18_HW_TVEEPROM | CX18_HW_418_AV | CX18_HW_TUNER |
102 		  CX18_HW_CS5345 | CX18_HW_DVB | CX18_HW_GPIO_RESET_CTRL |
103 		  CX18_HW_Z8F0811_IR_HAUP,
104 	.video_inputs = {
105 		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE7 },
106 		{ CX18_CARD_INPUT_SVIDEO1,    1, CX18_AV_SVIDEO1    },
107 		{ CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE3 },
108 		{ CX18_CARD_INPUT_SVIDEO2,    2, CX18_AV_SVIDEO2    },
109 		{ CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE4 },
110 	},
111 	.audio_inputs = {
112 		{ CX18_CARD_INPUT_AUD_TUNER,
113 		  CX18_AV_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 },
114 		{ CX18_CARD_INPUT_LINE_IN1,
115 		  CX18_AV_AUDIO_SERIAL1, CS5345_IN_2 },
116 		{ CX18_CARD_INPUT_LINE_IN2,
117 		  CX18_AV_AUDIO_SERIAL1, CS5345_IN_3 },
118 	},
119 	.radio_input = { CX18_CARD_INPUT_AUD_TUNER,
120 			 CX18_AV_AUDIO_SERIAL1, CS5345_IN_4 },
121 	.ddr = {
122 		/* ESMT M13S128324A-5B memory */
123 		.chip_config = 0x003,
124 		.refresh = 0x30c,
125 		.timing1 = 0x44220e82,
126 		.timing2 = 0x08,
127 		.tune_lane = 0,
128 		.initial_emrs = 0,
129 	},
130 	.gpio_init.initial_value = 0x3801,
131 	.gpio_init.direction = 0x3801,
132 	.gpio_i2c_slave_reset = {
133 		.active_lo_mask = 0x3801,
134 		.msecs_asserted = 10,
135 		.msecs_recovery = 40,
136 		.ir_reset_mask  = 0x0001,
137 	},
138 	.i2c = &cx18_i2c_nxp,
139 };
140 
141 static const struct cx18_card cx18_card_hvr1600_samsung = {
142 	.type = CX18_CARD_HVR_1600_SAMSUNG,
143 	.name = "Hauppauge HVR-1600 (Preproduction)",
144 	.comment = "Simultaneous Digital and Analog TV capture supported\n",
145 	.v4l2_capabilities = CX18_CAP_ENCODER,
146 	.hw_audio_ctrl = CX18_HW_418_AV,
147 	.hw_muxer = CX18_HW_CS5345,
148 	.hw_all = CX18_HW_TVEEPROM | CX18_HW_418_AV | CX18_HW_TUNER |
149 		  CX18_HW_CS5345 | CX18_HW_DVB | CX18_HW_GPIO_RESET_CTRL |
150 		  CX18_HW_Z8F0811_IR_HAUP,
151 	.video_inputs = {
152 		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE7 },
153 		{ CX18_CARD_INPUT_SVIDEO1,    1, CX18_AV_SVIDEO1    },
154 		{ CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE3 },
155 		{ CX18_CARD_INPUT_SVIDEO2,    2, CX18_AV_SVIDEO2    },
156 		{ CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE4 },
157 	},
158 	.audio_inputs = {
159 		{ CX18_CARD_INPUT_AUD_TUNER,
160 		  CX18_AV_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 },
161 		{ CX18_CARD_INPUT_LINE_IN1,
162 		  CX18_AV_AUDIO_SERIAL1, CS5345_IN_2 },
163 		{ CX18_CARD_INPUT_LINE_IN2,
164 		  CX18_AV_AUDIO_SERIAL1, CS5345_IN_3 },
165 	},
166 	.radio_input = { CX18_CARD_INPUT_AUD_TUNER,
167 			 CX18_AV_AUDIO_SERIAL1, CS5345_IN_4 },
168 	.ddr = {
169 		/* Samsung K4D263238G-VC33 memory */
170 		.chip_config = 0x003,
171 		.refresh = 0x30c,
172 		.timing1 = 0x23230b73,
173 		.timing2 = 0x08,
174 		.tune_lane = 0,
175 		.initial_emrs = 2,
176 	},
177 	.gpio_init.initial_value = 0x3001,
178 	.gpio_init.direction = 0x3001,
179 	.gpio_i2c_slave_reset = {
180 		.active_lo_mask = 0x3001,
181 		.msecs_asserted = 10,
182 		.msecs_recovery = 40,
183 		.ir_reset_mask  = 0x0001,
184 	},
185 	.i2c = &cx18_i2c_std,
186 };
187 
188 /* ------------------------------------------------------------------------- */
189 
190 /* Compro VideoMate H900: note that this card is analog only! */
191 
192 static const struct cx18_card_pci_info cx18_pci_h900[] = {
193 	{ PCI_DEVICE_ID_CX23418, CX18_PCI_ID_COMPRO, 0xe100 },
194 	{ 0, 0, 0 }
195 };
196 
197 static const struct cx18_card cx18_card_h900 = {
198 	.type = CX18_CARD_COMPRO_H900,
199 	.name = "Compro VideoMate H900",
200 	.comment = "Analog TV capture supported\n",
201 	.v4l2_capabilities = CX18_CAP_ENCODER,
202 	.hw_audio_ctrl = CX18_HW_418_AV,
203 	.hw_all = CX18_HW_418_AV | CX18_HW_TUNER | CX18_HW_GPIO_RESET_CTRL,
204 	.video_inputs = {
205 		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE2 },
206 		{ CX18_CARD_INPUT_SVIDEO1,    1,
207 			CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
208 		{ CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 },
209 	},
210 	.audio_inputs = {
211 		{ CX18_CARD_INPUT_AUD_TUNER,
212 		  CX18_AV_AUDIO5, 0 },
213 		{ CX18_CARD_INPUT_LINE_IN1,
214 		  CX18_AV_AUDIO_SERIAL1, 0 },
215 	},
216 	.radio_input = { CX18_CARD_INPUT_AUD_TUNER,
217 			 CX18_AV_AUDIO_SERIAL1, 0 },
218 	.tuners = {
219 		{ .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
220 	},
221 	.ddr = {
222 		/* EtronTech EM6A9160TS-5G memory */
223 		.chip_config = 0x50003,
224 		.refresh = 0x753,
225 		.timing1 = 0x24330e84,
226 		.timing2 = 0x1f,
227 		.tune_lane = 0,
228 		.initial_emrs = 0,
229 	},
230 	.xceive_pin = 15,
231 	.pci_list = cx18_pci_h900,
232 	.i2c = &cx18_i2c_std,
233 };
234 
235 /* ------------------------------------------------------------------------- */
236 
237 /* Yuan MPC718: not working at the moment! */
238 
239 static const struct cx18_card_pci_info cx18_pci_mpc718[] = {
240 	{ PCI_DEVICE_ID_CX23418, CX18_PCI_ID_YUAN, 0x0718 },
241 	{ 0, 0, 0 }
242 };
243 
244 static const struct cx18_card cx18_card_mpc718 = {
245 	.type = CX18_CARD_YUAN_MPC718,
246 	.name = "Yuan MPC718 MiniPCI DVB-T/Analog",
247 	.comment = "Experimenters needed for device to work well.\n"
248 		  "\tTo help, mail the linux-media list (www.linuxtv.org).\n",
249 	.v4l2_capabilities = CX18_CAP_ENCODER,
250 	.hw_audio_ctrl = CX18_HW_418_AV,
251 	.hw_muxer = CX18_HW_GPIO_MUX,
252 	.hw_all = CX18_HW_TVEEPROM | CX18_HW_418_AV | CX18_HW_TUNER |
253 		  CX18_HW_GPIO_MUX | CX18_HW_DVB | CX18_HW_GPIO_RESET_CTRL,
254 	.video_inputs = {
255 		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE2 },
256 		{ CX18_CARD_INPUT_SVIDEO1,    1,
257 				CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
258 		{ CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 },
259 		{ CX18_CARD_INPUT_SVIDEO2,    2,
260 				CX18_AV_SVIDEO_LUMA7 | CX18_AV_SVIDEO_CHROMA8 },
261 		{ CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE6 },
262 	},
263 	.audio_inputs = {
264 		{ CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5,        0 },
265 		{ CX18_CARD_INPUT_LINE_IN1,  CX18_AV_AUDIO_SERIAL1, 1 },
266 		{ CX18_CARD_INPUT_LINE_IN2,  CX18_AV_AUDIO_SERIAL2, 1 },
267 	},
268 	.tuners = {
269 		/* XC3028 tuner */
270 		{ .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
271 	},
272 	/* FIXME - the FM radio is just a guess and driver doesn't use SIF */
273 	.radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 2 },
274 	.ddr = {
275 		/* Hynix HY5DU283222B DDR RAM */
276 		.chip_config = 0x303,
277 		.refresh = 0x3bd,
278 		.timing1 = 0x36320966,
279 		.timing2 = 0x1f,
280 		.tune_lane = 0,
281 		.initial_emrs = 2,
282 	},
283 	.gpio_init.initial_value = 0x1,
284 	.gpio_init.direction = 0x3,
285 	/* FIXME - these GPIO's are just guesses */
286 	.gpio_audio_input = { .mask   = 0x3,
287 			      .tuner  = 0x1,
288 			      .linein = 0x3,
289 			      .radio  = 0x1 },
290 	.xceive_pin = 0,
291 	.pci_list = cx18_pci_mpc718,
292 	.i2c = &cx18_i2c_std,
293 };
294 
295 /* ------------------------------------------------------------------------- */
296 
297 /* GoTView PCI */
298 
299 static const struct cx18_card_pci_info cx18_pci_gotview_dvd3[] = {
300 	{ PCI_DEVICE_ID_CX23418, CX18_PCI_ID_GOTVIEW, 0x3343 },
301 	{ 0, 0, 0 }
302 };
303 
304 static const struct cx18_card cx18_card_gotview_dvd3 = {
305 	.type = CX18_CARD_GOTVIEW_PCI_DVD3,
306 	.name = "GoTView PCI DVD3 Hybrid",
307 	.comment = "Experimenters needed for device to work well.\n"
308 		  "\tTo help, mail the linux-media list (www.linuxtv.org).\n",
309 	.v4l2_capabilities = CX18_CAP_ENCODER,
310 	.hw_audio_ctrl = CX18_HW_418_AV,
311 	.hw_muxer = CX18_HW_GPIO_MUX,
312 	.hw_all = CX18_HW_TVEEPROM | CX18_HW_418_AV | CX18_HW_TUNER |
313 		  CX18_HW_GPIO_MUX | CX18_HW_DVB | CX18_HW_GPIO_RESET_CTRL,
314 	.video_inputs = {
315 		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE2 },
316 		{ CX18_CARD_INPUT_SVIDEO1,    1,
317 				CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
318 		{ CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 },
319 		{ CX18_CARD_INPUT_SVIDEO2,    2,
320 				CX18_AV_SVIDEO_LUMA7 | CX18_AV_SVIDEO_CHROMA8 },
321 		{ CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE6 },
322 	},
323 	.audio_inputs = {
324 		{ CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5,        0 },
325 		{ CX18_CARD_INPUT_LINE_IN1,  CX18_AV_AUDIO_SERIAL1, 1 },
326 		{ CX18_CARD_INPUT_LINE_IN2,  CX18_AV_AUDIO_SERIAL2, 1 },
327 	},
328 	.tuners = {
329 		/* XC3028 tuner */
330 		{ .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
331 	},
332 	/* FIXME - the FM radio is just a guess and driver doesn't use SIF */
333 	.radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 2 },
334 	.ddr = {
335 		/* Hynix HY5DU283222B DDR RAM */
336 		.chip_config = 0x303,
337 		.refresh = 0x3bd,
338 		.timing1 = 0x36320966,
339 		.timing2 = 0x1f,
340 		.tune_lane = 0,
341 		.initial_emrs = 2,
342 	},
343 	.gpio_init.initial_value = 0x1,
344 	.gpio_init.direction = 0x3,
345 
346 	.gpio_audio_input = { .mask   = 0x3,
347 			      .tuner  = 0x1,
348 			      .linein = 0x2,
349 			      .radio  = 0x1 },
350 	.xceive_pin = 0,
351 	.pci_list = cx18_pci_gotview_dvd3,
352 	.i2c = &cx18_i2c_std,
353 };
354 
355 /* ------------------------------------------------------------------------- */
356 
357 /* Conexant Raptor PAL/SECAM: note that this card is analog only! */
358 
359 static const struct cx18_card_pci_info cx18_pci_cnxt_raptor_pal[] = {
360 	{ PCI_DEVICE_ID_CX23418, CX18_PCI_ID_CONEXANT, 0x0009 },
361 	{ 0, 0, 0 }
362 };
363 
364 static const struct cx18_card cx18_card_cnxt_raptor_pal = {
365 	.type = CX18_CARD_CNXT_RAPTOR_PAL,
366 	.name = "Conexant Raptor PAL/SECAM",
367 	.comment = "Analog TV capture supported\n",
368 	.v4l2_capabilities = CX18_CAP_ENCODER,
369 	.hw_audio_ctrl = CX18_HW_418_AV,
370 	.hw_muxer = CX18_HW_GPIO_MUX,
371 	.hw_all = CX18_HW_418_AV | CX18_HW_TUNER | CX18_HW_GPIO_MUX,
372 	.video_inputs = {
373 		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE2 },
374 		{ CX18_CARD_INPUT_SVIDEO1,    1,
375 			CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
376 		{ CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 },
377 		{ CX18_CARD_INPUT_SVIDEO2,    2,
378 			CX18_AV_SVIDEO_LUMA7 | CX18_AV_SVIDEO_CHROMA8 },
379 		{ CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE6 },
380 	},
381 	.audio_inputs = {
382 		{ CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5,	    0 },
383 		{ CX18_CARD_INPUT_LINE_IN1,  CX18_AV_AUDIO_SERIAL1, 1 },
384 		{ CX18_CARD_INPUT_LINE_IN2,  CX18_AV_AUDIO_SERIAL2, 1 },
385 	},
386 	.tuners = {
387 		{ .std = V4L2_STD_PAL_SECAM, .tuner = TUNER_PHILIPS_FM1216ME_MK3 },
388 	},
389 	.radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO_SERIAL1, 2 },
390 	.ddr = {
391 		/* MT 46V16M16 memory */
392 		.chip_config = 0x50306,
393 		.refresh = 0x753,
394 		.timing1 = 0x33220953,
395 		.timing2 = 0x09,
396 		.tune_lane = 0,
397 		.initial_emrs = 0,
398 	},
399 	.gpio_init.initial_value = 0x1002,
400 	.gpio_init.direction = 0xf002,
401 	.gpio_audio_input = { .mask   = 0xf002,
402 			      .tuner  = 0x1002,   /* LED D1  Tuner AF  */
403 			      .linein = 0x2000,   /* LED D2  Line In 1 */
404 			      .radio  = 0x4002 }, /* LED D3  Tuner AF  */
405 	.pci_list = cx18_pci_cnxt_raptor_pal,
406 	.i2c = &cx18_i2c_std,
407 };
408 
409 /* ------------------------------------------------------------------------- */
410 
411 /* Toshiba Qosmio laptop internal DVB-T/Analog Hybrid Tuner */
412 
413 static const struct cx18_card_pci_info cx18_pci_toshiba_qosmio_dvbt[] = {
414 	{ PCI_DEVICE_ID_CX23418, CX18_PCI_ID_TOSHIBA, 0x0110 },
415 	{ 0, 0, 0 }
416 };
417 
418 static const struct cx18_card cx18_card_toshiba_qosmio_dvbt = {
419 	.type = CX18_CARD_TOSHIBA_QOSMIO_DVBT,
420 	.name = "Toshiba Qosmio DVB-T/Analog",
421 	.comment = "Experimenters and photos needed for device to work well.\n"
422 		  "\tTo help, mail the linux-media list (www.linuxtv.org).\n",
423 	.v4l2_capabilities = CX18_CAP_ENCODER,
424 	.hw_audio_ctrl = CX18_HW_418_AV,
425 	.hw_all = CX18_HW_418_AV | CX18_HW_TUNER | CX18_HW_GPIO_RESET_CTRL,
426 	.video_inputs = {
427 		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE6 },
428 		{ CX18_CARD_INPUT_SVIDEO1,    1,
429 			CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
430 		{ CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 },
431 	},
432 	.audio_inputs = {
433 		{ CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5,	    0 },
434 		{ CX18_CARD_INPUT_LINE_IN1,  CX18_AV_AUDIO_SERIAL1, 1 },
435 	},
436 	.tuners = {
437 		{ .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
438 	},
439 	.ddr = {
440 		.chip_config = 0x202,
441 		.refresh = 0x3bb,
442 		.timing1 = 0x33320a63,
443 		.timing2 = 0x0a,
444 		.tune_lane = 0,
445 		.initial_emrs = 0x42,
446 	},
447 	.xceive_pin = 15,
448 	.pci_list = cx18_pci_toshiba_qosmio_dvbt,
449 	.i2c = &cx18_i2c_std,
450 };
451 
452 /* ------------------------------------------------------------------------- */
453 
454 /* Leadtek WinFast PVR2100 */
455 
456 static const struct cx18_card_pci_info cx18_pci_leadtek_pvr2100[] = {
457 	{ PCI_DEVICE_ID_CX23418, CX18_PCI_ID_LEADTEK, 0x6f27 }, /* PVR2100   */
458 	{ 0, 0, 0 }
459 };
460 
461 static const struct cx18_card cx18_card_leadtek_pvr2100 = {
462 	.type = CX18_CARD_LEADTEK_PVR2100,
463 	.name = "Leadtek WinFast PVR2100",
464 	.comment = "Experimenters and photos needed for device to work well.\n"
465 		  "\tTo help, mail the linux-media list (www.linuxtv.org).\n",
466 	.v4l2_capabilities = CX18_CAP_ENCODER,
467 	.hw_audio_ctrl = CX18_HW_418_AV,
468 	.hw_muxer = CX18_HW_GPIO_MUX,
469 	.hw_all = CX18_HW_418_AV | CX18_HW_TUNER | CX18_HW_GPIO_MUX |
470 		  CX18_HW_GPIO_RESET_CTRL,
471 	.video_inputs = {
472 		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE2 },
473 		{ CX18_CARD_INPUT_SVIDEO1,    1,
474 			CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
475 		{ CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE7 },
476 		{ CX18_CARD_INPUT_COMPONENT1, 1, CX18_AV_COMPONENT1 },
477 	},
478 	.audio_inputs = {
479 		{ CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5,	    0 },
480 		{ CX18_CARD_INPUT_LINE_IN1,  CX18_AV_AUDIO_SERIAL1, 1 },
481 	},
482 	.tuners = {
483 		/* XC2028 tuner */
484 		{ .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
485 	},
486 	.radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 2 },
487 	.ddr = {
488 		/* Pointer to proper DDR config values provided by Terry Wu */
489 		.chip_config = 0x303,
490 		.refresh = 0x3bb,
491 		.timing1 = 0x24220e83,
492 		.timing2 = 0x1f,
493 		.tune_lane = 0,
494 		.initial_emrs = 0x2,
495 	},
496 	.gpio_init.initial_value = 0x6,
497 	.gpio_init.direction = 0x7,
498 	.gpio_audio_input = { .mask   = 0x7,
499 			      .tuner  = 0x6, .linein = 0x2, .radio  = 0x2 },
500 	.xceive_pin = 1,
501 	.pci_list = cx18_pci_leadtek_pvr2100,
502 	.i2c = &cx18_i2c_std,
503 };
504 
505 /* ------------------------------------------------------------------------- */
506 
507 /* Leadtek WinFast DVR3100 H */
508 
509 static const struct cx18_card_pci_info cx18_pci_leadtek_dvr3100h[] = {
510 	{ PCI_DEVICE_ID_CX23418, CX18_PCI_ID_LEADTEK, 0x6690 }, /* DVR3100 H */
511 	{ 0, 0, 0 }
512 };
513 
514 static const struct cx18_card cx18_card_leadtek_dvr3100h = {
515 	.type = CX18_CARD_LEADTEK_DVR3100H,
516 	.name = "Leadtek WinFast DVR3100 H",
517 	.comment = "Simultaneous DVB-T and Analog capture supported,\n"
518 		  "\texcept when capturing Analog from the antenna input.\n",
519 	.v4l2_capabilities = CX18_CAP_ENCODER,
520 	.hw_audio_ctrl = CX18_HW_418_AV,
521 	.hw_muxer = CX18_HW_GPIO_MUX,
522 	.hw_all = CX18_HW_418_AV | CX18_HW_TUNER | CX18_HW_GPIO_MUX |
523 		  CX18_HW_DVB | CX18_HW_GPIO_RESET_CTRL,
524 	.video_inputs = {
525 		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE2 },
526 		{ CX18_CARD_INPUT_SVIDEO1,    1,
527 			CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
528 		{ CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE7 },
529 		{ CX18_CARD_INPUT_COMPONENT1, 1, CX18_AV_COMPONENT1 },
530 	},
531 	.audio_inputs = {
532 		{ CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5,	    0 },
533 		{ CX18_CARD_INPUT_LINE_IN1,  CX18_AV_AUDIO_SERIAL1, 1 },
534 	},
535 	.tuners = {
536 		/* XC3028 tuner */
537 		{ .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
538 	},
539 	.radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 2 },
540 	.ddr = {
541 		/* Pointer to proper DDR config values provided by Terry Wu */
542 		.chip_config = 0x303,
543 		.refresh = 0x3bb,
544 		.timing1 = 0x24220e83,
545 		.timing2 = 0x1f,
546 		.tune_lane = 0,
547 		.initial_emrs = 0x2,
548 	},
549 	.gpio_init.initial_value = 0x6,
550 	.gpio_init.direction = 0x7,
551 	.gpio_audio_input = { .mask   = 0x7,
552 			      .tuner  = 0x6, .linein = 0x2, .radio  = 0x2 },
553 	.xceive_pin = 1,
554 	.pci_list = cx18_pci_leadtek_dvr3100h,
555 	.i2c = &cx18_i2c_std,
556 };
557 
558 /* ------------------------------------------------------------------------- */
559 
560 static const struct cx18_card *cx18_card_list[] = {
561 	&cx18_card_hvr1600_esmt,
562 	&cx18_card_hvr1600_samsung,
563 	&cx18_card_h900,
564 	&cx18_card_mpc718,
565 	&cx18_card_cnxt_raptor_pal,
566 	&cx18_card_toshiba_qosmio_dvbt,
567 	&cx18_card_leadtek_pvr2100,
568 	&cx18_card_leadtek_dvr3100h,
569 	&cx18_card_gotview_dvd3,
570 	&cx18_card_hvr1600_s5h1411
571 };
572 
cx18_get_card(u16 index)573 const struct cx18_card *cx18_get_card(u16 index)
574 {
575 	if (index >= ARRAY_SIZE(cx18_card_list))
576 		return NULL;
577 	return cx18_card_list[index];
578 }
579 
cx18_get_input(struct cx18 * cx,u16 index,struct v4l2_input * input)580 int cx18_get_input(struct cx18 *cx, u16 index, struct v4l2_input *input)
581 {
582 	const struct cx18_card_video_input *card_input =
583 		cx->card->video_inputs + index;
584 	static const char * const input_strs[] = {
585 		"Tuner 1",
586 		"S-Video 1",
587 		"S-Video 2",
588 		"Composite 1",
589 		"Composite 2",
590 		"Component 1"
591 	};
592 
593 	if (index >= cx->nof_inputs)
594 		return -EINVAL;
595 	input->index = index;
596 	strscpy(input->name, input_strs[card_input->video_type - 1],
597 		sizeof(input->name));
598 	input->type = (card_input->video_type == CX18_CARD_INPUT_VID_TUNER ?
599 			V4L2_INPUT_TYPE_TUNER : V4L2_INPUT_TYPE_CAMERA);
600 	input->audioset = (1 << cx->nof_audio_inputs) - 1;
601 	input->std = (input->type == V4L2_INPUT_TYPE_TUNER) ?
602 				cx->tuner_std : V4L2_STD_ALL;
603 	return 0;
604 }
605 
cx18_get_audio_input(struct cx18 * cx,u16 index,struct v4l2_audio * audio)606 int cx18_get_audio_input(struct cx18 *cx, u16 index, struct v4l2_audio *audio)
607 {
608 	const struct cx18_card_audio_input *aud_input =
609 		cx->card->audio_inputs + index;
610 	static const char * const input_strs[] = {
611 		"Tuner 1",
612 		"Line In 1",
613 		"Line In 2"
614 	};
615 
616 	memset(audio, 0, sizeof(*audio));
617 	if (index >= cx->nof_audio_inputs)
618 		return -EINVAL;
619 	strscpy(audio->name, input_strs[aud_input->audio_type - 1],
620 		sizeof(audio->name));
621 	audio->index = index;
622 	audio->capability = V4L2_AUDCAP_STEREO;
623 	return 0;
624 }
625