2 * cx18 functions to query card hardware
4 * Derived from ivtv-cards.c
6 * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
24 #include "cx18-driver.h"
25 #include "cx18-cards.h"
26 #include "cx18-av-core.h"
28 #include <media/cs5345.h>
30 #define V4L2_STD_PAL_SECAM (V4L2_STD_PAL|V4L2_STD_SECAM)
32 /********************** card configuration *******************************/
34 /* usual i2c tuner addresses to probe */
35 static struct cx18_card_tuner_i2c cx18_i2c_std = {
36 .radio = { I2C_CLIENT_END },
37 .demod = { 0x43, I2C_CLIENT_END },
38 .tv = { 0x61, 0x60, I2C_CLIENT_END },
41 /* Please add new PCI IDs to: http://pci-ids.ucw.cz/iii
42 This keeps the PCI ID database up to date. Note that the entries
43 must be added under vendor 0x4444 (Conexant) as subsystem IDs.
44 New vendor IDs should still be added to the vendor ID list. */
46 /* Hauppauge HVR-1600 cards */
48 /* Note: for Hauppauge cards the tveeprom information is used instead
50 static const struct cx18_card cx18_card_hvr1600_esmt = {
51 .type = CX18_CARD_HVR_1600_ESMT,
52 .name = "Hauppauge HVR-1600",
53 .comment = "VBI is not yet supported\n",
54 .v4l2_capabilities = CX18_CAP_ENCODER,
55 .hw_audio_ctrl = CX18_HW_CX23418,
56 .hw_muxer = CX18_HW_CS5345,
57 .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER |
58 CX18_HW_CS5345 | CX18_HW_DVB,
60 { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE7 },
61 { CX18_CARD_INPUT_SVIDEO1, 1, CX18_AV_SVIDEO1 },
62 { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE3 },
63 { CX18_CARD_INPUT_SVIDEO2, 2, CX18_AV_SVIDEO2 },
64 { CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE4 },
67 { CX18_CARD_INPUT_AUD_TUNER,
68 CX18_AV_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 },
69 { CX18_CARD_INPUT_LINE_IN1,
70 CX18_AV_AUDIO_SERIAL1, CS5345_IN_2 },
71 { CX18_CARD_INPUT_LINE_IN2,
72 CX18_AV_AUDIO_SERIAL1, CS5345_IN_3 },
74 .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
75 CX18_AV_AUDIO_SERIAL1, CS5345_IN_4 },
77 /* ESMT M13S128324A-5B memory */
80 .timing1 = 0x44220e82,
85 .gpio_init.initial_value = 0x3001,
86 .gpio_init.direction = 0x3001,
87 .gpio_i2c_slave_reset = {
88 .active_lo_mask = 0x3001,
91 .ir_reset_mask = 0x0001,
96 static const struct cx18_card cx18_card_hvr1600_samsung = {
97 .type = CX18_CARD_HVR_1600_SAMSUNG,
98 .name = "Hauppauge HVR-1600 (Preproduction)",
99 .comment = "VBI is not yet supported\n",
100 .v4l2_capabilities = CX18_CAP_ENCODER,
101 .hw_audio_ctrl = CX18_HW_CX23418,
102 .hw_muxer = CX18_HW_CS5345,
103 .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER |
104 CX18_HW_CS5345 | CX18_HW_DVB,
106 { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE7 },
107 { CX18_CARD_INPUT_SVIDEO1, 1, CX18_AV_SVIDEO1 },
108 { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE3 },
109 { CX18_CARD_INPUT_SVIDEO2, 2, CX18_AV_SVIDEO2 },
110 { CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE4 },
113 { CX18_CARD_INPUT_AUD_TUNER,
114 CX18_AV_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 },
115 { CX18_CARD_INPUT_LINE_IN1,
116 CX18_AV_AUDIO_SERIAL1, CS5345_IN_2 },
117 { CX18_CARD_INPUT_LINE_IN2,
118 CX18_AV_AUDIO_SERIAL1, CS5345_IN_3 },
120 .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
121 CX18_AV_AUDIO_SERIAL1, CS5345_IN_4 },
123 /* Samsung K4D263238G-VC33 memory */
124 .chip_config = 0x003,
126 .timing1 = 0x23230b73,
131 .gpio_init.initial_value = 0x3001,
132 .gpio_init.direction = 0x3001,
133 .gpio_i2c_slave_reset = {
134 .active_lo_mask = 0x3001,
135 .msecs_asserted = 10,
136 .msecs_recovery = 40,
137 .ir_reset_mask = 0x0001,
139 .i2c = &cx18_i2c_std,
142 /* ------------------------------------------------------------------------- */
144 /* Compro VideoMate H900: note that this card is analog only! */
146 static const struct cx18_card_pci_info cx18_pci_h900[] = {
147 { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_COMPRO, 0xe100 },
151 static const struct cx18_card cx18_card_h900 = {
152 .type = CX18_CARD_COMPRO_H900,
153 .name = "Compro VideoMate H900",
154 .comment = "VBI is not yet supported\n",
155 .v4l2_capabilities = CX18_CAP_ENCODER,
156 .hw_audio_ctrl = CX18_HW_CX23418,
157 .hw_all = CX18_HW_TUNER,
159 { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE2 },
160 { CX18_CARD_INPUT_SVIDEO1, 1,
161 CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
162 { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 },
165 { CX18_CARD_INPUT_AUD_TUNER,
167 { CX18_CARD_INPUT_LINE_IN1,
168 CX18_AV_AUDIO_SERIAL1, 0 },
170 .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
171 CX18_AV_AUDIO_SERIAL1, 0 },
173 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
176 /* EtronTech EM6A9160TS-5G memory */
177 .chip_config = 0x50003,
179 .timing1 = 0x24330e84,
185 .pci_list = cx18_pci_h900,
186 .i2c = &cx18_i2c_std,
189 /* ------------------------------------------------------------------------- */
191 /* Yuan MPC718: not working at the moment! */
193 static const struct cx18_card_pci_info cx18_pci_mpc718[] = {
194 { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_YUAN, 0x0718 },
198 static const struct cx18_card cx18_card_mpc718 = {
199 .type = CX18_CARD_YUAN_MPC718,
200 .name = "Yuan MPC718",
201 .comment = "Analog video capture works; some audio line in may not.\n",
202 .v4l2_capabilities = CX18_CAP_ENCODER,
203 .hw_audio_ctrl = CX18_HW_CX23418,
204 .hw_all = CX18_HW_TUNER,
206 { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE2 },
207 { CX18_CARD_INPUT_SVIDEO1, 1,
208 CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
209 { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 },
210 { CX18_CARD_INPUT_SVIDEO2, 2,
211 CX18_AV_SVIDEO_LUMA7 | CX18_AV_SVIDEO_CHROMA8 },
212 { CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE6 },
213 { CX18_CARD_INPUT_COMPOSITE3, 2, CX18_AV_COMPOSITE3 },
216 { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 0 },
217 { CX18_CARD_INPUT_LINE_IN1, CX18_AV_AUDIO_SERIAL1, 0 },
218 { CX18_CARD_INPUT_LINE_IN2, CX18_AV_AUDIO_SERIAL1, 0 },
220 .radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO_SERIAL1, 0 },
223 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
226 /* Probably Samsung K4D263238G-VC33 memory */
227 .chip_config = 0x003,
229 .timing1 = 0x23230b73,
235 .pci_list = cx18_pci_mpc718,
236 .i2c = &cx18_i2c_std,
239 /* ------------------------------------------------------------------------- */
241 /* Conexant Raptor PAL/SECAM: note that this card is analog only! */
243 static const struct cx18_card_pci_info cx18_pci_cnxt_raptor_pal[] = {
244 { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_CONEXANT, 0x0009 },
248 static const struct cx18_card cx18_card_cnxt_raptor_pal = {
249 .type = CX18_CARD_CNXT_RAPTOR_PAL,
250 .name = "Conexant Raptor PAL/SECAM",
251 .comment = "VBI is not yet supported\n",
252 .v4l2_capabilities = CX18_CAP_ENCODER,
253 .hw_audio_ctrl = CX18_HW_CX23418,
254 .hw_muxer = CX18_HW_GPIO,
255 .hw_all = CX18_HW_TUNER | CX18_HW_GPIO,
257 { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE2 },
258 { CX18_CARD_INPUT_SVIDEO1, 1,
259 CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
260 { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 },
261 { CX18_CARD_INPUT_SVIDEO2, 2,
262 CX18_AV_SVIDEO_LUMA7 | CX18_AV_SVIDEO_CHROMA8 },
263 { CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE6 },
266 { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 0 },
267 { CX18_CARD_INPUT_LINE_IN1, CX18_AV_AUDIO_SERIAL1, 1 },
268 { CX18_CARD_INPUT_LINE_IN2, CX18_AV_AUDIO_SERIAL2, 1 },
271 { .std = V4L2_STD_PAL_SECAM, .tuner = TUNER_PHILIPS_FM1216ME_MK3 },
273 .radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO_SERIAL1, 2 },
275 /* MT 46V16M16 memory */
276 .chip_config = 0x50306,
278 .timing1 = 0x33220953,
283 .gpio_init.initial_value = 0x1002,
284 .gpio_init.direction = 0xf002,
285 .gpio_audio_input = { .mask = 0xf002,
286 .tuner = 0x1002, /* LED D1 Tuner AF */
287 .linein = 0x2000, /* LED D2 Line In 1 */
288 .radio = 0x4002 }, /* LED D3 Tuner AF */
289 .pci_list = cx18_pci_cnxt_raptor_pal,
290 .i2c = &cx18_i2c_std,
293 /* ------------------------------------------------------------------------- */
295 /* Toshiba Qosmio laptop internal DVB-T/Analog Hybrid Tuner */
297 static const struct cx18_card_pci_info cx18_pci_toshiba_qosmio_dvbt[] = {
298 { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_TOSHIBA, 0x0110 },
302 static const struct cx18_card cx18_card_toshiba_qosmio_dvbt = {
303 .type = CX18_CARD_TOSHIBA_QOSMIO_DVBT,
304 .name = "Toshiba Qosmio DVB-T/Analog",
305 .comment = "Experimenters and photos needed for device to work well.\n"
306 "\tTo help, mail the ivtv-devel list (www.ivtvdriver.org).\n",
307 .v4l2_capabilities = CX18_CAP_ENCODER,
308 .hw_audio_ctrl = CX18_HW_CX23418,
309 .hw_all = CX18_HW_TUNER,
311 { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE6 },
312 { CX18_CARD_INPUT_SVIDEO1, 1,
313 CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
314 { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 },
317 { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 0 },
318 { CX18_CARD_INPUT_LINE_IN1, CX18_AV_AUDIO_SERIAL1, 1 },
321 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
324 .chip_config = 0x202,
326 .timing1 = 0x33320a63,
329 .initial_emrs = 0x42,
332 .pci_list = cx18_pci_toshiba_qosmio_dvbt,
333 .i2c = &cx18_i2c_std,
336 /* ------------------------------------------------------------------------- */
338 /* Leadtek WinFast PVR2100 */
340 static const struct cx18_card_pci_info cx18_pci_leadtek_pvr2100[] = {
341 { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_LEADTEK, 0x6f27 },
345 static const struct cx18_card cx18_card_leadtek_pvr2100 = {
346 .type = CX18_CARD_LEADTEK_PVR2100,
347 .name = "Leadtek WinFast PVR2100",
348 .comment = "Experimenters and photos needed for device to work well.\n"
349 "\tTo help, mail the ivtv-devel list (www.ivtvdriver.org).\n",
350 .v4l2_capabilities = CX18_CAP_ENCODER,
351 .hw_audio_ctrl = CX18_HW_CX23418,
352 .hw_muxer = CX18_HW_GPIO,
353 .hw_all = CX18_HW_TUNER | CX18_HW_GPIO,
355 { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE2 },
356 { CX18_CARD_INPUT_SVIDEO1, 1,
357 CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
358 { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE7 },
361 { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 0 },
362 { CX18_CARD_INPUT_LINE_IN1, CX18_AV_AUDIO_SERIAL1, 1 },
366 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
368 .radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 2 },
371 * Pointer to proper DDR config values provided by
372 * Terry Wu <terrywu at leadtek.com.tw>
374 .chip_config = 0x303,
376 .timing1 = 0x24220e83,
381 .gpio_init.initial_value = 0x6,
382 .gpio_init.direction = 0x7,
383 .gpio_audio_input = { .mask = 0x7,
384 .tuner = 0x6, .linein = 0x2, .radio = 0x2 },
386 .pci_list = cx18_pci_leadtek_pvr2100,
387 .i2c = &cx18_i2c_std,
390 /* ------------------------------------------------------------------------- */
392 static const struct cx18_card *cx18_card_list[] = {
393 &cx18_card_hvr1600_esmt,
394 &cx18_card_hvr1600_samsung,
397 &cx18_card_cnxt_raptor_pal,
398 &cx18_card_toshiba_qosmio_dvbt,
399 &cx18_card_leadtek_pvr2100,
402 const struct cx18_card *cx18_get_card(u16 index)
404 if (index >= ARRAY_SIZE(cx18_card_list))
406 return cx18_card_list[index];
409 int cx18_get_input(struct cx18 *cx, u16 index, struct v4l2_input *input)
411 const struct cx18_card_video_input *card_input =
412 cx->card->video_inputs + index;
413 static const char * const input_strs[] = {
422 memset(input, 0, sizeof(*input));
423 if (index >= cx->nof_inputs)
425 input->index = index;
426 strlcpy(input->name, input_strs[card_input->video_type - 1],
427 sizeof(input->name));
428 input->type = (card_input->video_type == CX18_CARD_INPUT_VID_TUNER ?
429 V4L2_INPUT_TYPE_TUNER : V4L2_INPUT_TYPE_CAMERA);
430 input->audioset = (1 << cx->nof_audio_inputs) - 1;
431 input->std = (input->type == V4L2_INPUT_TYPE_TUNER) ?
432 cx->tuner_std : V4L2_STD_ALL;
436 int cx18_get_audio_input(struct cx18 *cx, u16 index, struct v4l2_audio *audio)
438 const struct cx18_card_audio_input *aud_input =
439 cx->card->audio_inputs + index;
440 static const char * const input_strs[] = {
446 memset(audio, 0, sizeof(*audio));
447 if (index >= cx->nof_audio_inputs)
449 strlcpy(audio->name, input_strs[aud_input->audio_type - 1],
450 sizeof(audio->name));
451 audio->index = index;
452 audio->capability = V4L2_AUDCAP_STEREO;