cx18-cards.c 15.9 KB
Newer Older
1 2 3 4 5 6
/*
 *  cx18 functions to query card hardware
 *
 *  Derived from ivtv-cards.c
 *
 *  Copyright (C) 2007  Hans Verkuil <hverkuil@xs4all.nl>
7
 *  Copyright (C) 2008  Andy Walls <awalls@radix.net>
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 *  02111-1307  USA
 */

#include "cx18-driver.h"
#include "cx18-cards.h"
27
#include "cx18-av-core.h"
28 29 30
#include "cx18-i2c.h"
#include <media/cs5345.h>

31
#define V4L2_STD_PAL_SECAM (V4L2_STD_PAL|V4L2_STD_SECAM)
32

33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
/********************** card configuration *******************************/

/* usual i2c tuner addresses to probe */
static struct cx18_card_tuner_i2c cx18_i2c_std = {
	.radio = { I2C_CLIENT_END },
	.demod = { 0x43, I2C_CLIENT_END },
	.tv    = { 0x61, 0x60, I2C_CLIENT_END },
};

/* Please add new PCI IDs to: http://pci-ids.ucw.cz/iii
   This keeps the PCI ID database up to date. Note that the entries
   must be added under vendor 0x4444 (Conexant) as subsystem IDs.
   New vendor IDs should still be added to the vendor ID list. */

/* Hauppauge HVR-1600 cards */

/* Note: for Hauppauge cards the tveeprom information is used instead
   of PCI IDs */
static const struct cx18_card cx18_card_hvr1600_esmt = {
	.type = CX18_CARD_HVR_1600_ESMT,
	.name = "Hauppauge HVR-1600",
54
	.comment = "Simultaneous Digital and Analog TV capture supported\n",
55
	.v4l2_capabilities = CX18_CAP_ENCODER,
56
	.hw_audio_ctrl = CX18_HW_418_AV,
57
	.hw_muxer = CX18_HW_CS5345,
58
	.hw_all = CX18_HW_TVEEPROM | CX18_HW_418_AV | CX18_HW_TUNER |
59
		  CX18_HW_CS5345 | CX18_HW_DVB | CX18_HW_GPIO_RESET_CTRL,
60
	.video_inputs = {
61 62 63 64 65
		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE7 },
		{ CX18_CARD_INPUT_SVIDEO1,    1, CX18_AV_SVIDEO1    },
		{ CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE3 },
		{ CX18_CARD_INPUT_SVIDEO2,    2, CX18_AV_SVIDEO2    },
		{ CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE4 },
66 67 68
	},
	.audio_inputs = {
		{ CX18_CARD_INPUT_AUD_TUNER,
69
		  CX18_AV_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 },
70
		{ CX18_CARD_INPUT_LINE_IN1,
71
		  CX18_AV_AUDIO_SERIAL1, CS5345_IN_2 },
72
		{ CX18_CARD_INPUT_LINE_IN2,
73
		  CX18_AV_AUDIO_SERIAL1, CS5345_IN_3 },
74 75
	},
	.radio_input = { CX18_CARD_INPUT_AUD_TUNER,
76
			 CX18_AV_AUDIO_SERIAL1, CS5345_IN_4 },
77 78 79 80 81 82 83 84 85 86 87
	.ddr = {
		/* ESMT M13S128324A-5B memory */
		.chip_config = 0x003,
		.refresh = 0x30c,
		.timing1 = 0x44220e82,
		.timing2 = 0x08,
		.tune_lane = 0,
		.initial_emrs = 0,
	},
	.gpio_init.initial_value = 0x3001,
	.gpio_init.direction = 0x3001,
88 89 90 91
	.gpio_i2c_slave_reset = {
		.active_lo_mask = 0x3001,
		.msecs_asserted = 10,
		.msecs_recovery = 40,
92
		.ir_reset_mask  = 0x0001,
93
	},
94 95 96 97 98 99
	.i2c = &cx18_i2c_std,
};

static const struct cx18_card cx18_card_hvr1600_samsung = {
	.type = CX18_CARD_HVR_1600_SAMSUNG,
	.name = "Hauppauge HVR-1600 (Preproduction)",
100
	.comment = "Simultaneous Digital and Analog TV capture supported\n",
101
	.v4l2_capabilities = CX18_CAP_ENCODER,
102
	.hw_audio_ctrl = CX18_HW_418_AV,
103
	.hw_muxer = CX18_HW_CS5345,
104
	.hw_all = CX18_HW_TVEEPROM | CX18_HW_418_AV | CX18_HW_TUNER |
105
		  CX18_HW_CS5345 | CX18_HW_DVB | CX18_HW_GPIO_RESET_CTRL,
106
	.video_inputs = {
107 108 109 110 111
		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE7 },
		{ CX18_CARD_INPUT_SVIDEO1,    1, CX18_AV_SVIDEO1    },
		{ CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE3 },
		{ CX18_CARD_INPUT_SVIDEO2,    2, CX18_AV_SVIDEO2    },
		{ CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE4 },
112 113 114
	},
	.audio_inputs = {
		{ CX18_CARD_INPUT_AUD_TUNER,
115
		  CX18_AV_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 },
116
		{ CX18_CARD_INPUT_LINE_IN1,
117
		  CX18_AV_AUDIO_SERIAL1, CS5345_IN_2 },
118
		{ CX18_CARD_INPUT_LINE_IN2,
119
		  CX18_AV_AUDIO_SERIAL1, CS5345_IN_3 },
120 121
	},
	.radio_input = { CX18_CARD_INPUT_AUD_TUNER,
122
			 CX18_AV_AUDIO_SERIAL1, CS5345_IN_4 },
123 124 125 126 127 128 129 130 131 132 133
	.ddr = {
		/* Samsung K4D263238G-VC33 memory */
		.chip_config = 0x003,
		.refresh = 0x30c,
		.timing1 = 0x23230b73,
		.timing2 = 0x08,
		.tune_lane = 0,
		.initial_emrs = 2,
	},
	.gpio_init.initial_value = 0x3001,
	.gpio_init.direction = 0x3001,
134 135 136 137
	.gpio_i2c_slave_reset = {
		.active_lo_mask = 0x3001,
		.msecs_asserted = 10,
		.msecs_recovery = 40,
138
		.ir_reset_mask  = 0x0001,
139
	},
140 141 142 143 144
	.i2c = &cx18_i2c_std,
};

/* ------------------------------------------------------------------------- */

145
/* Compro VideoMate H900: note that this card is analog only! */
146 147 148 149 150 151 152 153 154

static const struct cx18_card_pci_info cx18_pci_h900[] = {
	{ PCI_DEVICE_ID_CX23418, CX18_PCI_ID_COMPRO, 0xe100 },
	{ 0, 0, 0 }
};

static const struct cx18_card cx18_card_h900 = {
	.type = CX18_CARD_COMPRO_H900,
	.name = "Compro VideoMate H900",
155
	.comment = "Analog TV capture supported\n",
156
	.v4l2_capabilities = CX18_CAP_ENCODER,
157
	.hw_audio_ctrl = CX18_HW_418_AV,
158
	.hw_all = CX18_HW_418_AV | CX18_HW_TUNER | CX18_HW_GPIO_RESET_CTRL,
159
	.video_inputs = {
160
		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE2 },
161
		{ CX18_CARD_INPUT_SVIDEO1,    1,
162 163
			CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
		{ CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 },
164 165 166
	},
	.audio_inputs = {
		{ CX18_CARD_INPUT_AUD_TUNER,
167
		  CX18_AV_AUDIO5, 0 },
168
		{ CX18_CARD_INPUT_LINE_IN1,
169
		  CX18_AV_AUDIO_SERIAL1, 0 },
170 171
	},
	.radio_input = { CX18_CARD_INPUT_AUD_TUNER,
172
			 CX18_AV_AUDIO_SERIAL1, 0 },
173 174 175 176 177 178 179 180 181 182 183 184
	.tuners = {
		{ .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
	},
	.ddr = {
		/* EtronTech EM6A9160TS-5G memory */
		.chip_config = 0x50003,
		.refresh = 0x753,
		.timing1 = 0x24330e84,
		.timing2 = 0x1f,
		.tune_lane = 0,
		.initial_emrs = 0,
	},
185
	.xceive_pin = 15,
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
	.pci_list = cx18_pci_h900,
	.i2c = &cx18_i2c_std,
};

/* ------------------------------------------------------------------------- */

/* Yuan MPC718: not working at the moment! */

static const struct cx18_card_pci_info cx18_pci_mpc718[] = {
	{ PCI_DEVICE_ID_CX23418, CX18_PCI_ID_YUAN, 0x0718 },
	{ 0, 0, 0 }
};

static const struct cx18_card cx18_card_mpc718 = {
	.type = CX18_CARD_YUAN_MPC718,
	.name = "Yuan MPC718",
202
	.comment = "Analog video capture works; some audio line in may not.\n",
203
	.v4l2_capabilities = CX18_CAP_ENCODER,
204
	.hw_audio_ctrl = CX18_HW_418_AV,
205
	.hw_all = CX18_HW_418_AV | CX18_HW_TUNER | CX18_HW_GPIO_RESET_CTRL,
206
	.video_inputs = {
207 208 209 210 211 212 213 214
		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE2 },
		{ CX18_CARD_INPUT_SVIDEO1,    1,
				CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
		{ CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 },
		{ CX18_CARD_INPUT_SVIDEO2,    2,
				CX18_AV_SVIDEO_LUMA7 | CX18_AV_SVIDEO_CHROMA8 },
		{ CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE6 },
		{ CX18_CARD_INPUT_COMPOSITE3, 2, CX18_AV_COMPOSITE3 },
215 216
	},
	.audio_inputs = {
217 218 219
		{ CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5,        0 },
		{ CX18_CARD_INPUT_LINE_IN1,  CX18_AV_AUDIO_SERIAL1, 0 },
		{ CX18_CARD_INPUT_LINE_IN2,  CX18_AV_AUDIO_SERIAL1, 0 },
220
	},
221
	.radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO_SERIAL1, 0 },
222 223 224 225 226 227 228 229 230 231 232 233 234
	.tuners = {
		/* XC3028 tuner */
		{ .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
	},
	.ddr = {
		/* Probably Samsung K4D263238G-VC33 memory */
		.chip_config = 0x003,
		.refresh = 0x30c,
		.timing1 = 0x23230b73,
		.timing2 = 0x08,
		.tune_lane = 0,
		.initial_emrs = 2,
	},
235
	.xceive_pin = 0,
236 237 238 239
	.pci_list = cx18_pci_mpc718,
	.i2c = &cx18_i2c_std,
};

240 241 242 243 244 245 246 247 248 249 250 251
/* ------------------------------------------------------------------------- */

/* Conexant Raptor PAL/SECAM: note that this card is analog only! */

static const struct cx18_card_pci_info cx18_pci_cnxt_raptor_pal[] = {
	{ PCI_DEVICE_ID_CX23418, CX18_PCI_ID_CONEXANT, 0x0009 },
	{ 0, 0, 0 }
};

static const struct cx18_card cx18_card_cnxt_raptor_pal = {
	.type = CX18_CARD_CNXT_RAPTOR_PAL,
	.name = "Conexant Raptor PAL/SECAM",
252
	.comment = "Analog TV capture supported\n",
253
	.v4l2_capabilities = CX18_CAP_ENCODER,
254
	.hw_audio_ctrl = CX18_HW_418_AV,
255 256
	.hw_muxer = CX18_HW_GPIO_MUX,
	.hw_all = CX18_HW_418_AV | CX18_HW_TUNER | CX18_HW_GPIO_MUX,
257 258 259 260 261 262 263 264 265 266
	.video_inputs = {
		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE2 },
		{ CX18_CARD_INPUT_SVIDEO1,    1,
			CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
		{ CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 },
		{ CX18_CARD_INPUT_SVIDEO2,    2,
			CX18_AV_SVIDEO_LUMA7 | CX18_AV_SVIDEO_CHROMA8 },
		{ CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE6 },
	},
	.audio_inputs = {
267 268 269
		{ CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 	    0 },
		{ CX18_CARD_INPUT_LINE_IN1,  CX18_AV_AUDIO_SERIAL1, 1 },
		{ CX18_CARD_INPUT_LINE_IN2,  CX18_AV_AUDIO_SERIAL2, 1 },
270 271
	},
	.tuners = {
272
		{ .std = V4L2_STD_PAL_SECAM, .tuner = TUNER_PHILIPS_FM1216ME_MK3 },
273
	},
274
	.radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO_SERIAL1, 2 },
275 276 277 278 279 280 281 282 283
	.ddr = {
		/* MT 46V16M16 memory */
		.chip_config = 0x50306,
		.refresh = 0x753,
		.timing1 = 0x33220953,
		.timing2 = 0x09,
		.tune_lane = 0,
		.initial_emrs = 0,
	},
284 285 286 287 288 289
	.gpio_init.initial_value = 0x1002,
	.gpio_init.direction = 0xf002,
	.gpio_audio_input = { .mask   = 0xf002,
			      .tuner  = 0x1002,   /* LED D1  Tuner AF  */
			      .linein = 0x2000,   /* LED D2  Line In 1 */
			      .radio  = 0x4002 }, /* LED D3  Tuner AF  */
290 291 292 293 294 295
	.pci_list = cx18_pci_cnxt_raptor_pal,
	.i2c = &cx18_i2c_std,
};

/* ------------------------------------------------------------------------- */

296 297 298 299 300 301 302 303 304 305 306 307 308
/* Toshiba Qosmio laptop internal DVB-T/Analog Hybrid Tuner */

static const struct cx18_card_pci_info cx18_pci_toshiba_qosmio_dvbt[] = {
	{ PCI_DEVICE_ID_CX23418, CX18_PCI_ID_TOSHIBA, 0x0110 },
	{ 0, 0, 0 }
};

static const struct cx18_card cx18_card_toshiba_qosmio_dvbt = {
	.type = CX18_CARD_TOSHIBA_QOSMIO_DVBT,
	.name = "Toshiba Qosmio DVB-T/Analog",
	.comment = "Experimenters and photos needed for device to work well.\n"
		  "\tTo help, mail the ivtv-devel list (www.ivtvdriver.org).\n",
	.v4l2_capabilities = CX18_CAP_ENCODER,
309
	.hw_audio_ctrl = CX18_HW_418_AV,
310
	.hw_all = CX18_HW_418_AV | CX18_HW_TUNER | CX18_HW_GPIO_RESET_CTRL,
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
	.video_inputs = {
		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE6 },
		{ CX18_CARD_INPUT_SVIDEO1,    1,
			CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
		{ CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 },
	},
	.audio_inputs = {
		{ CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 	    0 },
		{ CX18_CARD_INPUT_LINE_IN1,  CX18_AV_AUDIO_SERIAL1, 1 },
	},
	.tuners = {
		{ .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
	},
	.ddr = {
		.chip_config = 0x202,
		.refresh = 0x3bb,
		.timing1 = 0x33320a63,
		.timing2 = 0x0a,
		.tune_lane = 0,
		.initial_emrs = 0x42,
	},
	.xceive_pin = 15,
	.pci_list = cx18_pci_toshiba_qosmio_dvbt,
	.i2c = &cx18_i2c_std,
};

/* ------------------------------------------------------------------------- */

/* Leadtek WinFast PVR2100 */

static const struct cx18_card_pci_info cx18_pci_leadtek_pvr2100[] = {
342
	{ PCI_DEVICE_ID_CX23418, CX18_PCI_ID_LEADTEK, 0x6f27 }, /* PVR2100   */
343 344 345 346 347
	{ 0, 0, 0 }
};

static const struct cx18_card cx18_card_leadtek_pvr2100 = {
	.type = CX18_CARD_LEADTEK_PVR2100,
348
	.name = "Leadtek WinFast PVR2100",
349 350 351
	.comment = "Experimenters and photos needed for device to work well.\n"
		  "\tTo help, mail the ivtv-devel list (www.ivtvdriver.org).\n",
	.v4l2_capabilities = CX18_CAP_ENCODER,
352
	.hw_audio_ctrl = CX18_HW_418_AV,
353 354 355
	.hw_muxer = CX18_HW_GPIO_MUX,
	.hw_all = CX18_HW_418_AV | CX18_HW_TUNER | CX18_HW_GPIO_MUX |
		  CX18_HW_GPIO_RESET_CTRL,
356 357 358 359 360 361 362 363 364 365 366
	.video_inputs = {
		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE2 },
		{ CX18_CARD_INPUT_SVIDEO1,    1,
			CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
		{ CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE7 },
	},
	.audio_inputs = {
		{ CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 	    0 },
		{ CX18_CARD_INPUT_LINE_IN1,  CX18_AV_AUDIO_SERIAL1, 1 },
	},
	.tuners = {
367
		/* XC2028 tuner */
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
		{ .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
	},
	.radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 2 },
	.ddr = {
		/*
		 * Pointer to proper DDR config values provided by
		 * Terry Wu <terrywu at leadtek.com.tw>
		 */
		.chip_config = 0x303,
		.refresh = 0x3bb,
		.timing1 = 0x24220e83,
		.timing2 = 0x1f,
		.tune_lane = 0,
		.initial_emrs = 0x2,
	},
	.gpio_init.initial_value = 0x6,
	.gpio_init.direction = 0x7,
	.gpio_audio_input = { .mask   = 0x7,
			      .tuner  = 0x6, .linein = 0x2, .radio  = 0x2 },
	.xceive_pin = 15,
	.pci_list = cx18_pci_leadtek_pvr2100,
	.i2c = &cx18_i2c_std,
};

/* ------------------------------------------------------------------------- */

394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448
/* Leadtek WinFast DVR3100 H */

static const struct cx18_card_pci_info cx18_pci_leadtek_dvr3100h[] = {
	{ PCI_DEVICE_ID_CX23418, CX18_PCI_ID_LEADTEK, 0x6690 }, /* DVR3100 H */
	{ 0, 0, 0 }
};

static const struct cx18_card cx18_card_leadtek_dvr3100h = {
	.type = CX18_CARD_LEADTEK_DVR3100H,
	.name = "Leadtek WinFast DVR3100 H",
	.comment = "Experimenters and photos needed for device to work well.\n"
		  "\tTo help, mail the ivtv-devel list (www.ivtvdriver.org).\n",
	.v4l2_capabilities = CX18_CAP_ENCODER,
	.hw_audio_ctrl = CX18_HW_418_AV,
	.hw_muxer = CX18_HW_GPIO_MUX,
	.hw_all = CX18_HW_418_AV | CX18_HW_TUNER | CX18_HW_GPIO_MUX |
		  CX18_HW_GPIO_RESET_CTRL,
	.video_inputs = {
		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE2 },
		{ CX18_CARD_INPUT_SVIDEO1,    1,
			CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
		{ CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE7 },
	},
	.audio_inputs = {
		{ CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 	    0 },
		{ CX18_CARD_INPUT_LINE_IN1,  CX18_AV_AUDIO_SERIAL1, 1 },
	},
	.tuners = {
		/* XC3028 tuner */
		{ .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
	},
	.radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 2 },
	.ddr = {
		/*
		 * Pointer to proper DDR config values provided by
		 * Terry Wu <terrywu at leadtek.com.tw>
		 */
		.chip_config = 0x303,
		.refresh = 0x3bb,
		.timing1 = 0x24220e83,
		.timing2 = 0x1f,
		.tune_lane = 0,
		.initial_emrs = 0x2,
	},
	.gpio_init.initial_value = 0x6,
	.gpio_init.direction = 0x7,
	.gpio_audio_input = { .mask   = 0x7,
			      .tuner  = 0x6, .linein = 0x2, .radio  = 0x2 },
	.xceive_pin = 15,
	.pci_list = cx18_pci_leadtek_dvr3100h,
	.i2c = &cx18_i2c_std,
};

/* ------------------------------------------------------------------------- */

449 450 451 452 453
static const struct cx18_card *cx18_card_list[] = {
	&cx18_card_hvr1600_esmt,
	&cx18_card_hvr1600_samsung,
	&cx18_card_h900,
	&cx18_card_mpc718,
454
	&cx18_card_cnxt_raptor_pal,
455 456
	&cx18_card_toshiba_qosmio_dvbt,
	&cx18_card_leadtek_pvr2100,
457
	&cx18_card_leadtek_dvr3100h,
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512
};

const struct cx18_card *cx18_get_card(u16 index)
{
	if (index >= ARRAY_SIZE(cx18_card_list))
		return NULL;
	return cx18_card_list[index];
}

int cx18_get_input(struct cx18 *cx, u16 index, struct v4l2_input *input)
{
	const struct cx18_card_video_input *card_input =
		cx->card->video_inputs + index;
	static const char * const input_strs[] = {
		"Tuner 1",
		"S-Video 1",
		"S-Video 2",
		"Composite 1",
		"Composite 2",
		"Composite 3"
	};

	memset(input, 0, sizeof(*input));
	if (index >= cx->nof_inputs)
		return -EINVAL;
	input->index = index;
	strlcpy(input->name, input_strs[card_input->video_type - 1],
			sizeof(input->name));
	input->type = (card_input->video_type == CX18_CARD_INPUT_VID_TUNER ?
			V4L2_INPUT_TYPE_TUNER : V4L2_INPUT_TYPE_CAMERA);
	input->audioset = (1 << cx->nof_audio_inputs) - 1;
	input->std = (input->type == V4L2_INPUT_TYPE_TUNER) ?
				cx->tuner_std : V4L2_STD_ALL;
	return 0;
}

int cx18_get_audio_input(struct cx18 *cx, u16 index, struct v4l2_audio *audio)
{
	const struct cx18_card_audio_input *aud_input =
		cx->card->audio_inputs + index;
	static const char * const input_strs[] = {
		"Tuner 1",
		"Line In 1",
		"Line In 2"
	};

	memset(audio, 0, sizeof(*audio));
	if (index >= cx->nof_audio_inputs)
		return -EINVAL;
	strlcpy(audio->name, input_strs[aud_input->audio_type - 1],
			sizeof(audio->name));
	audio->index = index;
	audio->capability = V4L2_AUDCAP_STEREO;
	return 0;
}