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