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