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