2 * cx18 functions to query card hardware
4 * Derived from ivtv-cards.c
6 * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl>
7 * Copyright (C) 2008 Andy Walls <awalls@radix.net>
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.
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.
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
25 #include "cx18-driver.h"
26 #include "cx18-cards.h"
27 #include "cx18-av-core.h"
29 #include <media/cs5345.h>
31 #define V4L2_STD_PAL_SECAM (V4L2_STD_PAL|V4L2_STD_SECAM)
33 /********************** card configuration *******************************/
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 },
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. */
47 /* Hauppauge HVR-1600 cards */
49 /* Note: for Hauppauge cards the tveeprom information is used instead
51 static const struct cx18_card cx18_card_hvr1600_esmt = {
52 .type = CX18_CARD_HVR_1600_ESMT,
53 .name = "Hauppauge HVR-1600",
54 .comment = "VBI is not yet supported\n",
55 .v4l2_capabilities = CX18_CAP_ENCODER,
56 .hw_audio_ctrl = CX18_HW_CX23418,
57 .hw_muxer = CX18_HW_CS5345,
58 .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER |
59 CX18_HW_CS5345 | CX18_HW_DVB,
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 },
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 },
75 .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
76 CX18_AV_AUDIO_SERIAL1, CS5345_IN_4 },
78 /* ESMT M13S128324A-5B memory */
81 .timing1 = 0x44220e82,
86 .gpio_init.initial_value = 0x3001,
87 .gpio_init.direction = 0x3001,
88 .gpio_i2c_slave_reset = {
89 .active_lo_mask = 0x3001,
92 .ir_reset_mask = 0x0001,
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 = "VBI is not yet supported\n",
101 .v4l2_capabilities = CX18_CAP_ENCODER,
102 .hw_audio_ctrl = CX18_HW_CX23418,
103 .hw_muxer = CX18_HW_CS5345,
104 .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER |
105 CX18_HW_CS5345 | CX18_HW_DVB,
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 },
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 },
121 .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
122 CX18_AV_AUDIO_SERIAL1, CS5345_IN_4 },
124 /* Samsung K4D263238G-VC33 memory */
125 .chip_config = 0x003,
127 .timing1 = 0x23230b73,
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,
140 .i2c = &cx18_i2c_std,
143 /* ------------------------------------------------------------------------- */
145 /* Compro VideoMate H900: note that this card is analog only! */
147 static const struct cx18_card_pci_info cx18_pci_h900[] = {
148 { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_COMPRO, 0xe100 },
152 static const struct cx18_card cx18_card_h900 = {
153 .type = CX18_CARD_COMPRO_H900,
154 .name = "Compro VideoMate H900",
155 .comment = "VBI is not yet supported\n",
156 .v4l2_capabilities = CX18_CAP_ENCODER,
157 .hw_audio_ctrl = CX18_HW_CX23418,
158 .hw_all = CX18_HW_TUNER,
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 },
166 { CX18_CARD_INPUT_AUD_TUNER,
168 { CX18_CARD_INPUT_LINE_IN1,
169 CX18_AV_AUDIO_SERIAL1, 0 },
171 .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
172 CX18_AV_AUDIO_SERIAL1, 0 },
174 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
177 /* EtronTech EM6A9160TS-5G memory */
178 .chip_config = 0x50003,
180 .timing1 = 0x24330e84,
186 .pci_list = cx18_pci_h900,
187 .i2c = &cx18_i2c_std,
190 /* ------------------------------------------------------------------------- */
192 /* Yuan MPC718: not working at the moment! */
194 static const struct cx18_card_pci_info cx18_pci_mpc718[] = {
195 { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_YUAN, 0x0718 },
199 static const struct cx18_card cx18_card_mpc718 = {
200 .type = CX18_CARD_YUAN_MPC718,
201 .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_CX23418,
205 .hw_all = CX18_HW_TUNER,
207 { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE2 },
208 { CX18_CARD_INPUT_SVIDEO1, 1,
209 CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
210 { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 },
211 { CX18_CARD_INPUT_SVIDEO2, 2,
212 CX18_AV_SVIDEO_LUMA7 | CX18_AV_SVIDEO_CHROMA8 },
213 { CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE6 },
214 { CX18_CARD_INPUT_COMPOSITE3, 2, CX18_AV_COMPOSITE3 },
217 { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 0 },
218 { CX18_CARD_INPUT_LINE_IN1, CX18_AV_AUDIO_SERIAL1, 0 },
219 { CX18_CARD_INPUT_LINE_IN2, CX18_AV_AUDIO_SERIAL1, 0 },
221 .radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO_SERIAL1, 0 },
224 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
227 /* Probably Samsung K4D263238G-VC33 memory */
228 .chip_config = 0x003,
230 .timing1 = 0x23230b73,
236 .pci_list = cx18_pci_mpc718,
237 .i2c = &cx18_i2c_std,
240 /* ------------------------------------------------------------------------- */
242 /* Conexant Raptor PAL/SECAM: note that this card is analog only! */
244 static const struct cx18_card_pci_info cx18_pci_cnxt_raptor_pal[] = {
245 { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_CONEXANT, 0x0009 },
249 static const struct cx18_card cx18_card_cnxt_raptor_pal = {
250 .type = CX18_CARD_CNXT_RAPTOR_PAL,
251 .name = "Conexant Raptor PAL/SECAM",
252 .comment = "VBI is not yet supported\n",
253 .v4l2_capabilities = CX18_CAP_ENCODER,
254 .hw_audio_ctrl = CX18_HW_CX23418,
255 .hw_muxer = CX18_HW_GPIO,
256 .hw_all = CX18_HW_TUNER | CX18_HW_GPIO,
258 { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE2 },
259 { CX18_CARD_INPUT_SVIDEO1, 1,
260 CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
261 { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 },
262 { CX18_CARD_INPUT_SVIDEO2, 2,
263 CX18_AV_SVIDEO_LUMA7 | CX18_AV_SVIDEO_CHROMA8 },
264 { CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE6 },
267 { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 0 },
268 { CX18_CARD_INPUT_LINE_IN1, CX18_AV_AUDIO_SERIAL1, 1 },
269 { CX18_CARD_INPUT_LINE_IN2, CX18_AV_AUDIO_SERIAL2, 1 },
272 { .std = V4L2_STD_PAL_SECAM, .tuner = TUNER_PHILIPS_FM1216ME_MK3 },
274 .radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO_SERIAL1, 2 },
276 /* MT 46V16M16 memory */
277 .chip_config = 0x50306,
279 .timing1 = 0x33220953,
284 .gpio_init.initial_value = 0x1002,
285 .gpio_init.direction = 0xf002,
286 .gpio_audio_input = { .mask = 0xf002,
287 .tuner = 0x1002, /* LED D1 Tuner AF */
288 .linein = 0x2000, /* LED D2 Line In 1 */
289 .radio = 0x4002 }, /* LED D3 Tuner AF */
290 .pci_list = cx18_pci_cnxt_raptor_pal,
291 .i2c = &cx18_i2c_std,
294 /* ------------------------------------------------------------------------- */
296 /* Toshiba Qosmio laptop internal DVB-T/Analog Hybrid Tuner */
298 static const struct cx18_card_pci_info cx18_pci_toshiba_qosmio_dvbt[] = {
299 { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_TOSHIBA, 0x0110 },
303 static const struct cx18_card cx18_card_toshiba_qosmio_dvbt = {
304 .type = CX18_CARD_TOSHIBA_QOSMIO_DVBT,
305 .name = "Toshiba Qosmio DVB-T/Analog",
306 .comment = "Experimenters and photos needed for device to work well.\n"
307 "\tTo help, mail the ivtv-devel list (www.ivtvdriver.org).\n",
308 .v4l2_capabilities = CX18_CAP_ENCODER,
309 .hw_audio_ctrl = CX18_HW_CX23418,
310 .hw_all = CX18_HW_TUNER,
312 { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE6 },
313 { CX18_CARD_INPUT_SVIDEO1, 1,
314 CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
315 { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 },
318 { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 0 },
319 { CX18_CARD_INPUT_LINE_IN1, CX18_AV_AUDIO_SERIAL1, 1 },
322 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
325 .chip_config = 0x202,
327 .timing1 = 0x33320a63,
330 .initial_emrs = 0x42,
333 .pci_list = cx18_pci_toshiba_qosmio_dvbt,
334 .i2c = &cx18_i2c_std,
337 /* ------------------------------------------------------------------------- */
339 /* Leadtek WinFast PVR2100 */
341 static const struct cx18_card_pci_info cx18_pci_leadtek_pvr2100[] = {
342 { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_LEADTEK, 0x6f27 },
346 static const struct cx18_card cx18_card_leadtek_pvr2100 = {
347 .type = CX18_CARD_LEADTEK_PVR2100,
348 .name = "Leadtek WinFast PVR2100",
349 .comment = "Experimenters and photos needed for device to work well.\n"
350 "\tTo help, mail the ivtv-devel list (www.ivtvdriver.org).\n",
351 .v4l2_capabilities = CX18_CAP_ENCODER,
352 .hw_audio_ctrl = CX18_HW_CX23418,
353 .hw_muxer = CX18_HW_GPIO,
354 .hw_all = CX18_HW_TUNER | CX18_HW_GPIO,
356 { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE2 },
357 { CX18_CARD_INPUT_SVIDEO1, 1,
358 CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
359 { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE7 },
362 { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 0 },
363 { CX18_CARD_INPUT_LINE_IN1, CX18_AV_AUDIO_SERIAL1, 1 },
367 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
369 .radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 2 },
372 * Pointer to proper DDR config values provided by
373 * Terry Wu <terrywu at leadtek.com.tw>
375 .chip_config = 0x303,
377 .timing1 = 0x24220e83,
382 .gpio_init.initial_value = 0x6,
383 .gpio_init.direction = 0x7,
384 .gpio_audio_input = { .mask = 0x7,
385 .tuner = 0x6, .linein = 0x2, .radio = 0x2 },
387 .pci_list = cx18_pci_leadtek_pvr2100,
388 .i2c = &cx18_i2c_std,
391 /* ------------------------------------------------------------------------- */
393 static const struct cx18_card *cx18_card_list[] = {
394 &cx18_card_hvr1600_esmt,
395 &cx18_card_hvr1600_samsung,
398 &cx18_card_cnxt_raptor_pal,
399 &cx18_card_toshiba_qosmio_dvbt,
400 &cx18_card_leadtek_pvr2100,
403 const struct cx18_card *cx18_get_card(u16 index)
405 if (index >= ARRAY_SIZE(cx18_card_list))
407 return cx18_card_list[index];
410 int cx18_get_input(struct cx18 *cx, u16 index, struct v4l2_input *input)
412 const struct cx18_card_video_input *card_input =
413 cx->card->video_inputs + index;
414 static const char * const input_strs[] = {
423 memset(input, 0, sizeof(*input));
424 if (index >= cx->nof_inputs)
426 input->index = index;
427 strlcpy(input->name, input_strs[card_input->video_type - 1],
428 sizeof(input->name));
429 input->type = (card_input->video_type == CX18_CARD_INPUT_VID_TUNER ?
430 V4L2_INPUT_TYPE_TUNER : V4L2_INPUT_TYPE_CAMERA);
431 input->audioset = (1 << cx->nof_audio_inputs) - 1;
432 input->std = (input->type == V4L2_INPUT_TYPE_TUNER) ?
433 cx->tuner_std : V4L2_STD_ALL;
437 int cx18_get_audio_input(struct cx18 *cx, u16 index, struct v4l2_audio *audio)
439 const struct cx18_card_audio_input *aud_input =
440 cx->card->audio_inputs + index;
441 static const char * const input_strs[] = {
447 memset(audio, 0, sizeof(*audio));
448 if (index >= cx->nof_audio_inputs)
450 strlcpy(audio->name, input_strs[aud_input->audio_type - 1],
451 sizeof(audio->name));
452 audio->index = index;
453 audio->capability = V4L2_AUDCAP_STEREO;