Merge branch 'topic/cleanup' into for-linus
[pandora-kernel.git] / drivers / media / video / cx18 / cx18-cards.c
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@radix.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 /* Please add new PCI IDs to: http://pci-ids.ucw.cz/iii
43    This keeps the PCI ID database up to date. Note that the entries
44    must be added under vendor 0x4444 (Conexant) as subsystem IDs.
45    New vendor IDs should still be added to the vendor ID list. */
46
47 /* Hauppauge HVR-1600 cards */
48
49 /* Note: for Hauppauge cards the tveeprom information is used instead
50    of PCI IDs */
51 static const struct cx18_card cx18_card_hvr1600_esmt = {
52         .type = CX18_CARD_HVR_1600_ESMT,
53         .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                 { CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE7 },
62                 { CX18_CARD_INPUT_SVIDEO1,    1, CX18_AV_SVIDEO1    },
63                 { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE3 },
64                 { CX18_CARD_INPUT_SVIDEO2,    2, CX18_AV_SVIDEO2    },
65                 { CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE4 },
66         },
67         .audio_inputs = {
68                 { 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         .ddr = {
78                 /* ESMT M13S128324A-5B memory */
79                 .chip_config = 0x003,
80                 .refresh = 0x30c,
81                 .timing1 = 0x44220e82,
82                 .timing2 = 0x08,
83                 .tune_lane = 0,
84                 .initial_emrs = 0,
85         },
86         .gpio_init.initial_value = 0x3001,
87         .gpio_init.direction = 0x3001,
88         .gpio_i2c_slave_reset = {
89                 .active_lo_mask = 0x3001,
90                 .msecs_asserted = 10,
91                 .msecs_recovery = 40,
92                 .ir_reset_mask  = 0x0001,
93         },
94         .i2c = &cx18_i2c_std,
95 };
96
97 static const struct cx18_card cx18_card_hvr1600_samsung = {
98         .type = CX18_CARD_HVR_1600_SAMSUNG,
99         .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                 { CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE7 },
108                 { CX18_CARD_INPUT_SVIDEO1,    1, CX18_AV_SVIDEO1    },
109                 { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE3 },
110                 { CX18_CARD_INPUT_SVIDEO2,    2, CX18_AV_SVIDEO2    },
111                 { CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE4 },
112         },
113         .audio_inputs = {
114                 { 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         .ddr = {
124                 /* Samsung K4D263238G-VC33 memory */
125                 .chip_config = 0x003,
126                 .refresh = 0x30c,
127                 .timing1 = 0x23230b73,
128                 .timing2 = 0x08,
129                 .tune_lane = 0,
130                 .initial_emrs = 2,
131         },
132         .gpio_init.initial_value = 0x3001,
133         .gpio_init.direction = 0x3001,
134         .gpio_i2c_slave_reset = {
135                 .active_lo_mask = 0x3001,
136                 .msecs_asserted = 10,
137                 .msecs_recovery = 40,
138                 .ir_reset_mask  = 0x0001,
139         },
140         .i2c = &cx18_i2c_std,
141 };
142
143 /* ------------------------------------------------------------------------- */
144
145 /* Compro VideoMate H900: note that this card is analog only! */
146
147 static const struct cx18_card_pci_info cx18_pci_h900[] = {
148         { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_COMPRO, 0xe100 },
149         { 0, 0, 0 }
150 };
151
152 static const struct cx18_card cx18_card_h900 = {
153         .type = CX18_CARD_COMPRO_H900,
154         .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                         CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
163                 { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 },
164         },
165         .audio_inputs = {
166                 { 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         .tuners = {
174                 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
175         },
176         .ddr = {
177                 /* EtronTech EM6A9160TS-5G memory */
178                 .chip_config = 0x50003,
179                 .refresh = 0x753,
180                 .timing1 = 0x24330e84,
181                 .timing2 = 0x1f,
182                 .tune_lane = 0,
183                 .initial_emrs = 0,
184         },
185         .xceive_pin = 15,
186         .pci_list = cx18_pci_h900,
187         .i2c = &cx18_i2c_std,
188 };
189
190 /* ------------------------------------------------------------------------- */
191
192 /* Yuan MPC718: not working at the moment! */
193
194 static const struct cx18_card_pci_info cx18_pci_mpc718[] = {
195         { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_YUAN, 0x0718 },
196         { 0, 0, 0 }
197 };
198
199 static const struct cx18_card cx18_card_mpc718 = {
200         .type = CX18_CARD_YUAN_MPC718,
201         .name = "Yuan MPC718 MiniPCI DVB-T/Analog",
202         .comment = "Experimenters needed for device to work well.\n"
203                   "\tTo help, mail the ivtv-devel list (www.ivtvdriver.org).\n",
204         .v4l2_capabilities = CX18_CAP_ENCODER,
205         .hw_audio_ctrl = CX18_HW_418_AV,
206         .hw_muxer = CX18_HW_GPIO_MUX,
207         .hw_all = CX18_HW_418_AV | CX18_HW_TUNER |
208                   CX18_HW_GPIO_MUX | CX18_HW_DVB | CX18_HW_GPIO_RESET_CTRL,
209         .video_inputs = {
210                 { CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE2 },
211                 { CX18_CARD_INPUT_SVIDEO1,    1,
212                                 CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
213                 { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 },
214                 { CX18_CARD_INPUT_SVIDEO2,    2,
215                                 CX18_AV_SVIDEO_LUMA7 | CX18_AV_SVIDEO_CHROMA8 },
216                 { CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE6 },
217         },
218         .audio_inputs = {
219                 { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5,        0 },
220                 { CX18_CARD_INPUT_LINE_IN1,  CX18_AV_AUDIO_SERIAL1, 1 },
221                 { CX18_CARD_INPUT_LINE_IN2,  CX18_AV_AUDIO_SERIAL2, 1 },
222         },
223         .tuners = {
224                 /* XC3028 tuner */
225                 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
226         },
227         /* FIXME - the FM radio is just a guess and driver doesn't use SIF */
228         .radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 2 },
229         .ddr = {
230                 /* Hynix HY5DU283222B DDR RAM */
231                 .chip_config = 0x303,
232                 .refresh = 0x3bd,
233                 .timing1 = 0x36320966,
234                 .timing2 = 0x1f,
235                 .tune_lane = 0,
236                 .initial_emrs = 2,
237         },
238         .gpio_init.initial_value = 0x1,
239         .gpio_init.direction = 0x3,
240         /* FIXME - these GPIO's are just guesses */
241         .gpio_audio_input = { .mask   = 0x3,
242                               .tuner  = 0x1,
243                               .linein = 0x3,
244                               .radio  = 0x1 },
245         .xceive_pin = 0,
246         .pci_list = cx18_pci_mpc718,
247         .i2c = &cx18_i2c_std,
248 };
249
250 /* ------------------------------------------------------------------------- */
251
252 /* Conexant Raptor PAL/SECAM: note that this card is analog only! */
253
254 static const struct cx18_card_pci_info cx18_pci_cnxt_raptor_pal[] = {
255         { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_CONEXANT, 0x0009 },
256         { 0, 0, 0 }
257 };
258
259 static const struct cx18_card cx18_card_cnxt_raptor_pal = {
260         .type = CX18_CARD_CNXT_RAPTOR_PAL,
261         .name = "Conexant Raptor PAL/SECAM",
262         .comment = "Analog TV capture supported\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_418_AV | CX18_HW_TUNER | CX18_HW_GPIO_MUX,
267         .video_inputs = {
268                 { CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE2 },
269                 { CX18_CARD_INPUT_SVIDEO1,    1,
270                         CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
271                 { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 },
272                 { CX18_CARD_INPUT_SVIDEO2,    2,
273                         CX18_AV_SVIDEO_LUMA7 | CX18_AV_SVIDEO_CHROMA8 },
274                 { CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE6 },
275         },
276         .audio_inputs = {
277                 { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5,        0 },
278                 { CX18_CARD_INPUT_LINE_IN1,  CX18_AV_AUDIO_SERIAL1, 1 },
279                 { CX18_CARD_INPUT_LINE_IN2,  CX18_AV_AUDIO_SERIAL2, 1 },
280         },
281         .tuners = {
282                 { .std = V4L2_STD_PAL_SECAM, .tuner = TUNER_PHILIPS_FM1216ME_MK3 },
283         },
284         .radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO_SERIAL1, 2 },
285         .ddr = {
286                 /* MT 46V16M16 memory */
287                 .chip_config = 0x50306,
288                 .refresh = 0x753,
289                 .timing1 = 0x33220953,
290                 .timing2 = 0x09,
291                 .tune_lane = 0,
292                 .initial_emrs = 0,
293         },
294         .gpio_init.initial_value = 0x1002,
295         .gpio_init.direction = 0xf002,
296         .gpio_audio_input = { .mask   = 0xf002,
297                               .tuner  = 0x1002,   /* LED D1  Tuner AF  */
298                               .linein = 0x2000,   /* LED D2  Line In 1 */
299                               .radio  = 0x4002 }, /* LED D3  Tuner AF  */
300         .pci_list = cx18_pci_cnxt_raptor_pal,
301         .i2c = &cx18_i2c_std,
302 };
303
304 /* ------------------------------------------------------------------------- */
305
306 /* Toshiba Qosmio laptop internal DVB-T/Analog Hybrid Tuner */
307
308 static const struct cx18_card_pci_info cx18_pci_toshiba_qosmio_dvbt[] = {
309         { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_TOSHIBA, 0x0110 },
310         { 0, 0, 0 }
311 };
312
313 static const struct cx18_card cx18_card_toshiba_qosmio_dvbt = {
314         .type = CX18_CARD_TOSHIBA_QOSMIO_DVBT,
315         .name = "Toshiba Qosmio DVB-T/Analog",
316         .comment = "Experimenters and photos 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_all = CX18_HW_418_AV | CX18_HW_TUNER | CX18_HW_GPIO_RESET_CTRL,
321         .video_inputs = {
322                 { CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE6 },
323                 { CX18_CARD_INPUT_SVIDEO1,    1,
324                         CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
325                 { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 },
326         },
327         .audio_inputs = {
328                 { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5,        0 },
329                 { CX18_CARD_INPUT_LINE_IN1,  CX18_AV_AUDIO_SERIAL1, 1 },
330         },
331         .tuners = {
332                 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
333         },
334         .ddr = {
335                 .chip_config = 0x202,
336                 .refresh = 0x3bb,
337                 .timing1 = 0x33320a63,
338                 .timing2 = 0x0a,
339                 .tune_lane = 0,
340                 .initial_emrs = 0x42,
341         },
342         .xceive_pin = 15,
343         .pci_list = cx18_pci_toshiba_qosmio_dvbt,
344         .i2c = &cx18_i2c_std,
345 };
346
347 /* ------------------------------------------------------------------------- */
348
349 /* Leadtek WinFast PVR2100 */
350
351 static const struct cx18_card_pci_info cx18_pci_leadtek_pvr2100[] = {
352         { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_LEADTEK, 0x6f27 }, /* PVR2100   */
353         { 0, 0, 0 }
354 };
355
356 static const struct cx18_card cx18_card_leadtek_pvr2100 = {
357         .type = CX18_CARD_LEADTEK_PVR2100,
358         .name = "Leadtek WinFast PVR2100",
359         .comment = "Experimenters and photos needed for device to work well.\n"
360                   "\tTo help, mail the ivtv-devel list (www.ivtvdriver.org).\n",
361         .v4l2_capabilities = CX18_CAP_ENCODER,
362         .hw_audio_ctrl = CX18_HW_418_AV,
363         .hw_muxer = CX18_HW_GPIO_MUX,
364         .hw_all = CX18_HW_418_AV | CX18_HW_TUNER | CX18_HW_GPIO_MUX |
365                   CX18_HW_GPIO_RESET_CTRL,
366         .video_inputs = {
367                 { CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE2 },
368                 { CX18_CARD_INPUT_SVIDEO1,    1,
369                         CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
370                 { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE7 },
371         },
372         .audio_inputs = {
373                 { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5,        0 },
374                 { CX18_CARD_INPUT_LINE_IN1,  CX18_AV_AUDIO_SERIAL1, 1 },
375         },
376         .tuners = {
377                 /* XC2028 tuner */
378                 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
379         },
380         .radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 2 },
381         .ddr = {
382                 /* Pointer to proper DDR config values provided by Terry Wu */
383                 .chip_config = 0x303,
384                 .refresh = 0x3bb,
385                 .timing1 = 0x24220e83,
386                 .timing2 = 0x1f,
387                 .tune_lane = 0,
388                 .initial_emrs = 0x2,
389         },
390         .gpio_init.initial_value = 0x6,
391         .gpio_init.direction = 0x7,
392         .gpio_audio_input = { .mask   = 0x7,
393                               .tuner  = 0x6, .linein = 0x2, .radio  = 0x2 },
394         .xceive_pin = 15,
395         .pci_list = cx18_pci_leadtek_pvr2100,
396         .i2c = &cx18_i2c_std,
397 };
398
399 /* ------------------------------------------------------------------------- */
400
401 /* Leadtek WinFast DVR3100 H */
402
403 static const struct cx18_card_pci_info cx18_pci_leadtek_dvr3100h[] = {
404         { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_LEADTEK, 0x6690 }, /* DVR3100 H */
405         { 0, 0, 0 }
406 };
407
408 static const struct cx18_card cx18_card_leadtek_dvr3100h = {
409         .type = CX18_CARD_LEADTEK_DVR3100H,
410         .name = "Leadtek WinFast DVR3100 H",
411         .comment = "Simultaneous DVB-T and Analog capture supported,\n"
412                   "\texcept when capturing Analog from the antenna input.\n",
413         .v4l2_capabilities = CX18_CAP_ENCODER,
414         .hw_audio_ctrl = CX18_HW_418_AV,
415         .hw_muxer = CX18_HW_GPIO_MUX,
416         .hw_all = CX18_HW_418_AV | CX18_HW_TUNER | CX18_HW_GPIO_MUX |
417                   CX18_HW_DVB | CX18_HW_GPIO_RESET_CTRL,
418         .video_inputs = {
419                 { CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE2 },
420                 { CX18_CARD_INPUT_SVIDEO1,    1,
421                         CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
422                 { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE7 },
423         },
424         .audio_inputs = {
425                 { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5,        0 },
426                 { CX18_CARD_INPUT_LINE_IN1,  CX18_AV_AUDIO_SERIAL1, 1 },
427         },
428         .tuners = {
429                 /* XC3028 tuner */
430                 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
431         },
432         .radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 2 },
433         .ddr = {
434                 /* Pointer to proper DDR config values provided by Terry Wu */
435                 .chip_config = 0x303,
436                 .refresh = 0x3bb,
437                 .timing1 = 0x24220e83,
438                 .timing2 = 0x1f,
439                 .tune_lane = 0,
440                 .initial_emrs = 0x2,
441         },
442         .gpio_init.initial_value = 0x6,
443         .gpio_init.direction = 0x7,
444         .gpio_audio_input = { .mask   = 0x7,
445                               .tuner  = 0x6, .linein = 0x2, .radio  = 0x2 },
446         .xceive_pin = 1,
447         .pci_list = cx18_pci_leadtek_dvr3100h,
448         .i2c = &cx18_i2c_std,
449 };
450
451 /* ------------------------------------------------------------------------- */
452
453 static const struct cx18_card *cx18_card_list[] = {
454         &cx18_card_hvr1600_esmt,
455         &cx18_card_hvr1600_samsung,
456         &cx18_card_h900,
457         &cx18_card_mpc718,
458         &cx18_card_cnxt_raptor_pal,
459         &cx18_card_toshiba_qosmio_dvbt,
460         &cx18_card_leadtek_pvr2100,
461         &cx18_card_leadtek_dvr3100h,
462 };
463
464 const struct cx18_card *cx18_get_card(u16 index)
465 {
466         if (index >= ARRAY_SIZE(cx18_card_list))
467                 return NULL;
468         return cx18_card_list[index];
469 }
470
471 int cx18_get_input(struct cx18 *cx, u16 index, struct v4l2_input *input)
472 {
473         const struct cx18_card_video_input *card_input =
474                 cx->card->video_inputs + index;
475         static const char * const input_strs[] = {
476                 "Tuner 1",
477                 "S-Video 1",
478                 "S-Video 2",
479                 "Composite 1",
480                 "Composite 2",
481                 "Composite 3"
482         };
483
484         memset(input, 0, sizeof(*input));
485         if (index >= cx->nof_inputs)
486                 return -EINVAL;
487         input->index = index;
488         strlcpy(input->name, input_strs[card_input->video_type - 1],
489                         sizeof(input->name));
490         input->type = (card_input->video_type == CX18_CARD_INPUT_VID_TUNER ?
491                         V4L2_INPUT_TYPE_TUNER : V4L2_INPUT_TYPE_CAMERA);
492         input->audioset = (1 << cx->nof_audio_inputs) - 1;
493         input->std = (input->type == V4L2_INPUT_TYPE_TUNER) ?
494                                 cx->tuner_std : V4L2_STD_ALL;
495         return 0;
496 }
497
498 int cx18_get_audio_input(struct cx18 *cx, u16 index, struct v4l2_audio *audio)
499 {
500         const struct cx18_card_audio_input *aud_input =
501                 cx->card->audio_inputs + index;
502         static const char * const input_strs[] = {
503                 "Tuner 1",
504                 "Line In 1",
505                 "Line In 2"
506         };
507
508         memset(audio, 0, sizeof(*audio));
509         if (index >= cx->nof_audio_inputs)
510                 return -EINVAL;
511         strlcpy(audio->name, input_strs[aud_input->audio_type - 1],
512                         sizeof(audio->name));
513         audio->index = index;
514         audio->capability = V4L2_AUDCAP_STEREO;
515         return 0;
516 }