Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cx18-cards.c
Go to the documentation of this file.
1 /*
2  * cx18 functions to query card hardware
3  *
4  * Derived from ivtv-cards.c
5  *
6  * Copyright (C) 2007 Hans Verkuil <[email protected]>
7  * Copyright (C) 2008 Andy Walls <[email protected]>
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 /*
43  * usual i2c tuner addresses to probe with additional demod address for
44  * an NXP TDA8295 at 0x42 (N.B. it can possibly be at 0x4b or 0x4c too).
45  */
46 static struct cx18_card_tuner_i2c cx18_i2c_nxp = {
47  .radio = { I2C_CLIENT_END },
48  .demod = { 0x42, 0x43, I2C_CLIENT_END },
49  .tv = { 0x61, 0x60, I2C_CLIENT_END },
50 };
51 
52 /* Please add new PCI IDs to: http://pci-ids.ucw.cz/
53  This keeps the PCI ID database up to date. Note that the entries
54  must be added under vendor 0x4444 (Conexant) as subsystem IDs.
55  New vendor IDs should still be added to the vendor ID list. */
56 
57 /* Hauppauge HVR-1600 cards */
58 
59 /* Note: for Hauppauge cards the tveeprom information is used instead
60  of PCI IDs */
61 static const struct cx18_card cx18_card_hvr1600_esmt = {
63  .name = "Hauppauge HVR-1600",
64  .comment = "Simultaneous Digital and Analog TV capture supported\n",
65  .v4l2_capabilities = CX18_CAP_ENCODER,
66  .hw_audio_ctrl = CX18_HW_418_AV,
67  .hw_muxer = CX18_HW_CS5345,
71  .video_inputs = {
77  },
78  .audio_inputs = {
85  },
86  .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
88  .ddr = {
89  /* ESMT M13S128324A-5B memory */
90  .chip_config = 0x003,
91  .refresh = 0x30c,
92  .timing1 = 0x44220e82,
93  .timing2 = 0x08,
94  .tune_lane = 0,
95  .initial_emrs = 0,
96  },
97  .gpio_init.initial_value = 0x3001,
98  .gpio_init.direction = 0x3001,
99  .gpio_i2c_slave_reset = {
100  .active_lo_mask = 0x3001,
101  .msecs_asserted = 10,
102  .msecs_recovery = 40,
103  .ir_reset_mask = 0x0001,
104  },
105  .i2c = &cx18_i2c_std,
106 };
107 
108 static const struct cx18_card cx18_card_hvr1600_s5h1411 = {
110  .name = "Hauppauge HVR-1600",
111  .comment = "Simultaneous Digital and Analog TV capture supported\n",
112  .v4l2_capabilities = CX18_CAP_ENCODER,
113  .hw_audio_ctrl = CX18_HW_418_AV,
114  .hw_muxer = CX18_HW_CS5345,
118  .video_inputs = {
124  },
125  .audio_inputs = {
132  },
133  .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
135  .ddr = {
136  /* ESMT M13S128324A-5B memory */
137  .chip_config = 0x003,
138  .refresh = 0x30c,
139  .timing1 = 0x44220e82,
140  .timing2 = 0x08,
141  .tune_lane = 0,
142  .initial_emrs = 0,
143  },
144  .gpio_init.initial_value = 0x3801,
145  .gpio_init.direction = 0x3801,
146  .gpio_i2c_slave_reset = {
147  .active_lo_mask = 0x3801,
148  .msecs_asserted = 10,
149  .msecs_recovery = 40,
150  .ir_reset_mask = 0x0001,
151  },
152  .i2c = &cx18_i2c_nxp,
153 };
154 
155 static const struct cx18_card cx18_card_hvr1600_samsung = {
157  .name = "Hauppauge HVR-1600 (Preproduction)",
158  .comment = "Simultaneous Digital and Analog TV capture supported\n",
159  .v4l2_capabilities = CX18_CAP_ENCODER,
160  .hw_audio_ctrl = CX18_HW_418_AV,
161  .hw_muxer = CX18_HW_CS5345,
165  .video_inputs = {
171  },
172  .audio_inputs = {
179  },
180  .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
182  .ddr = {
183  /* Samsung K4D263238G-VC33 memory */
184  .chip_config = 0x003,
185  .refresh = 0x30c,
186  .timing1 = 0x23230b73,
187  .timing2 = 0x08,
188  .tune_lane = 0,
189  .initial_emrs = 2,
190  },
191  .gpio_init.initial_value = 0x3001,
192  .gpio_init.direction = 0x3001,
193  .gpio_i2c_slave_reset = {
194  .active_lo_mask = 0x3001,
195  .msecs_asserted = 10,
196  .msecs_recovery = 40,
197  .ir_reset_mask = 0x0001,
198  },
199  .i2c = &cx18_i2c_std,
200 };
201 
202 /* ------------------------------------------------------------------------- */
203 
204 /* Compro VideoMate H900: note that this card is analog only! */
205 
206 static const struct cx18_card_pci_info cx18_pci_h900[] = {
208  { 0, 0, 0 }
209 };
210 
211 static const struct cx18_card cx18_card_h900 = {
212  .type = CX18_CARD_COMPRO_H900,
213  .name = "Compro VideoMate H900",
214  .comment = "Analog TV capture supported\n",
215  .v4l2_capabilities = CX18_CAP_ENCODER,
216  .hw_audio_ctrl = CX18_HW_418_AV,
218  .video_inputs = {
223  },
224  .audio_inputs = {
226  CX18_AV_AUDIO5, 0 },
229  },
230  .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
232  .tuners = {
233  { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
234  },
235  .ddr = {
236  /* EtronTech EM6A9160TS-5G memory */
237  .chip_config = 0x50003,
238  .refresh = 0x753,
239  .timing1 = 0x24330e84,
240  .timing2 = 0x1f,
241  .tune_lane = 0,
242  .initial_emrs = 0,
243  },
244  .xceive_pin = 15,
245  .pci_list = cx18_pci_h900,
246  .i2c = &cx18_i2c_std,
247 };
248 
249 /* ------------------------------------------------------------------------- */
250 
251 /* Yuan MPC718: not working at the moment! */
252 
253 static const struct cx18_card_pci_info cx18_pci_mpc718[] = {
255  { 0, 0, 0 }
256 };
257 
258 static const struct cx18_card cx18_card_mpc718 = {
259  .type = CX18_CARD_YUAN_MPC718,
260  .name = "Yuan MPC718 MiniPCI DVB-T/Analog",
261  .comment = "Experimenters needed for device to work well.\n"
262  "\tTo help, mail the ivtv-devel list (www.ivtvdriver.org).\n",
263  .v4l2_capabilities = CX18_CAP_ENCODER,
264  .hw_audio_ctrl = CX18_HW_418_AV,
265  .hw_muxer = CX18_HW_GPIO_MUX,
268  .video_inputs = {
276  },
277  .audio_inputs = {
281  },
282  .tuners = {
283  /* XC3028 tuner */
284  { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
285  },
286  /* FIXME - the FM radio is just a guess and driver doesn't use SIF */
287  .radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 2 },
288  .ddr = {
289  /* Hynix HY5DU283222B DDR RAM */
290  .chip_config = 0x303,
291  .refresh = 0x3bd,
292  .timing1 = 0x36320966,
293  .timing2 = 0x1f,
294  .tune_lane = 0,
295  .initial_emrs = 2,
296  },
297  .gpio_init.initial_value = 0x1,
298  .gpio_init.direction = 0x3,
299  /* FIXME - these GPIO's are just guesses */
300  .gpio_audio_input = { .mask = 0x3,
301  .tuner = 0x1,
302  .linein = 0x3,
303  .radio = 0x1 },
304  .xceive_pin = 0,
305  .pci_list = cx18_pci_mpc718,
306  .i2c = &cx18_i2c_std,
307 };
308 
309 /* ------------------------------------------------------------------------- */
310 
311 /* GoTView PCI */
312 
313 static const struct cx18_card_pci_info cx18_pci_gotview_dvd3[] = {
315  { 0, 0, 0 }
316 };
317 
318 static const struct cx18_card cx18_card_gotview_dvd3 = {
320  .name = "GoTView PCI DVD3 Hybrid",
321  .comment = "Experimenters needed for device to work well.\n"
322  "\tTo help, mail the ivtv-devel list (www.ivtvdriver.org).\n",
323  .v4l2_capabilities = CX18_CAP_ENCODER,
324  .hw_audio_ctrl = CX18_HW_418_AV,
325  .hw_muxer = CX18_HW_GPIO_MUX,
328  .video_inputs = {
336  },
337  .audio_inputs = {
341  },
342  .tuners = {
343  /* XC3028 tuner */
344  { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
345  },
346  /* FIXME - the FM radio is just a guess and driver doesn't use SIF */
347  .radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 2 },
348  .ddr = {
349  /* Hynix HY5DU283222B DDR RAM */
350  .chip_config = 0x303,
351  .refresh = 0x3bd,
352  .timing1 = 0x36320966,
353  .timing2 = 0x1f,
354  .tune_lane = 0,
355  .initial_emrs = 2,
356  },
357  .gpio_init.initial_value = 0x1,
358  .gpio_init.direction = 0x3,
359 
360  .gpio_audio_input = { .mask = 0x3,
361  .tuner = 0x1,
362  .linein = 0x2,
363  .radio = 0x1 },
364  .xceive_pin = 0,
365  .pci_list = cx18_pci_gotview_dvd3,
366  .i2c = &cx18_i2c_std,
367 };
368 
369 /* ------------------------------------------------------------------------- */
370 
371 /* Conexant Raptor PAL/SECAM: note that this card is analog only! */
372 
373 static const struct cx18_card_pci_info cx18_pci_cnxt_raptor_pal[] = {
375  { 0, 0, 0 }
376 };
377 
378 static const struct cx18_card cx18_card_cnxt_raptor_pal = {
380  .name = "Conexant Raptor PAL/SECAM",
381  .comment = "Analog TV capture supported\n",
382  .v4l2_capabilities = CX18_CAP_ENCODER,
383  .hw_audio_ctrl = CX18_HW_418_AV,
384  .hw_muxer = CX18_HW_GPIO_MUX,
386  .video_inputs = {
394  },
395  .audio_inputs = {
399  },
400  .tuners = {
401  { .std = V4L2_STD_PAL_SECAM, .tuner = TUNER_PHILIPS_FM1216ME_MK3 },
402  },
403  .radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO_SERIAL1, 2 },
404  .ddr = {
405  /* MT 46V16M16 memory */
406  .chip_config = 0x50306,
407  .refresh = 0x753,
408  .timing1 = 0x33220953,
409  .timing2 = 0x09,
410  .tune_lane = 0,
411  .initial_emrs = 0,
412  },
413  .gpio_init.initial_value = 0x1002,
414  .gpio_init.direction = 0xf002,
415  .gpio_audio_input = { .mask = 0xf002,
416  .tuner = 0x1002, /* LED D1 Tuner AF */
417  .linein = 0x2000, /* LED D2 Line In 1 */
418  .radio = 0x4002 }, /* LED D3 Tuner AF */
419  .pci_list = cx18_pci_cnxt_raptor_pal,
420  .i2c = &cx18_i2c_std,
421 };
422 
423 /* ------------------------------------------------------------------------- */
424 
425 /* Toshiba Qosmio laptop internal DVB-T/Analog Hybrid Tuner */
426 
427 static const struct cx18_card_pci_info cx18_pci_toshiba_qosmio_dvbt[] = {
429  { 0, 0, 0 }
430 };
431 
432 static const struct cx18_card cx18_card_toshiba_qosmio_dvbt = {
434  .name = "Toshiba Qosmio DVB-T/Analog",
435  .comment = "Experimenters and photos needed for device to work well.\n"
436  "\tTo help, mail the ivtv-devel list (www.ivtvdriver.org).\n",
437  .v4l2_capabilities = CX18_CAP_ENCODER,
438  .hw_audio_ctrl = CX18_HW_418_AV,
440  .video_inputs = {
445  },
446  .audio_inputs = {
449  },
450  .tuners = {
451  { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
452  },
453  .ddr = {
454  .chip_config = 0x202,
455  .refresh = 0x3bb,
456  .timing1 = 0x33320a63,
457  .timing2 = 0x0a,
458  .tune_lane = 0,
459  .initial_emrs = 0x42,
460  },
461  .xceive_pin = 15,
462  .pci_list = cx18_pci_toshiba_qosmio_dvbt,
463  .i2c = &cx18_i2c_std,
464 };
465 
466 /* ------------------------------------------------------------------------- */
467 
468 /* Leadtek WinFast PVR2100 */
469 
470 static const struct cx18_card_pci_info cx18_pci_leadtek_pvr2100[] = {
471  { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_LEADTEK, 0x6f27 }, /* PVR2100 */
472  { 0, 0, 0 }
473 };
474 
475 static const struct cx18_card cx18_card_leadtek_pvr2100 = {
477  .name = "Leadtek WinFast PVR2100",
478  .comment = "Experimenters and photos needed for device to work well.\n"
479  "\tTo help, mail the ivtv-devel list (www.ivtvdriver.org).\n",
480  .v4l2_capabilities = CX18_CAP_ENCODER,
481  .hw_audio_ctrl = CX18_HW_418_AV,
482  .hw_muxer = CX18_HW_GPIO_MUX,
485  .video_inputs = {
491  },
492  .audio_inputs = {
495  },
496  .tuners = {
497  /* XC2028 tuner */
498  { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
499  },
500  .radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 2 },
501  .ddr = {
502  /* Pointer to proper DDR config values provided by Terry Wu */
503  .chip_config = 0x303,
504  .refresh = 0x3bb,
505  .timing1 = 0x24220e83,
506  .timing2 = 0x1f,
507  .tune_lane = 0,
508  .initial_emrs = 0x2,
509  },
510  .gpio_init.initial_value = 0x6,
511  .gpio_init.direction = 0x7,
512  .gpio_audio_input = { .mask = 0x7,
513  .tuner = 0x6, .linein = 0x2, .radio = 0x2 },
514  .xceive_pin = 1,
515  .pci_list = cx18_pci_leadtek_pvr2100,
516  .i2c = &cx18_i2c_std,
517 };
518 
519 /* ------------------------------------------------------------------------- */
520 
521 /* Leadtek WinFast DVR3100 H */
522 
523 static const struct cx18_card_pci_info cx18_pci_leadtek_dvr3100h[] = {
524  { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_LEADTEK, 0x6690 }, /* DVR3100 H */
525  { 0, 0, 0 }
526 };
527 
528 static const struct cx18_card cx18_card_leadtek_dvr3100h = {
530  .name = "Leadtek WinFast DVR3100 H",
531  .comment = "Simultaneous DVB-T and Analog capture supported,\n"
532  "\texcept when capturing Analog from the antenna input.\n",
533  .v4l2_capabilities = CX18_CAP_ENCODER,
534  .hw_audio_ctrl = CX18_HW_418_AV,
535  .hw_muxer = CX18_HW_GPIO_MUX,
538  .video_inputs = {
544  },
545  .audio_inputs = {
548  },
549  .tuners = {
550  /* XC3028 tuner */
551  { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
552  },
553  .radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 2 },
554  .ddr = {
555  /* Pointer to proper DDR config values provided by Terry Wu */
556  .chip_config = 0x303,
557  .refresh = 0x3bb,
558  .timing1 = 0x24220e83,
559  .timing2 = 0x1f,
560  .tune_lane = 0,
561  .initial_emrs = 0x2,
562  },
563  .gpio_init.initial_value = 0x6,
564  .gpio_init.direction = 0x7,
565  .gpio_audio_input = { .mask = 0x7,
566  .tuner = 0x6, .linein = 0x2, .radio = 0x2 },
567  .xceive_pin = 1,
568  .pci_list = cx18_pci_leadtek_dvr3100h,
569  .i2c = &cx18_i2c_std,
570 };
571 
572 /* ------------------------------------------------------------------------- */
573 
574 static const struct cx18_card *cx18_card_list[] = {
575  &cx18_card_hvr1600_esmt,
576  &cx18_card_hvr1600_samsung,
577  &cx18_card_h900,
578  &cx18_card_mpc718,
579  &cx18_card_cnxt_raptor_pal,
580  &cx18_card_toshiba_qosmio_dvbt,
581  &cx18_card_leadtek_pvr2100,
582  &cx18_card_leadtek_dvr3100h,
583  &cx18_card_gotview_dvd3,
584  &cx18_card_hvr1600_s5h1411
585 };
586 
588 {
589  if (index >= ARRAY_SIZE(cx18_card_list))
590  return NULL;
591  return cx18_card_list[index];
592 }
593 
594 int cx18_get_input(struct cx18 *cx, u16 index, struct v4l2_input *input)
595 {
596  const struct cx18_card_video_input *card_input =
597  cx->card->video_inputs + index;
598  static const char * const input_strs[] = {
599  "Tuner 1",
600  "S-Video 1",
601  "S-Video 2",
602  "Composite 1",
603  "Composite 2",
604  "Component 1"
605  };
606 
607  if (index >= cx->nof_inputs)
608  return -EINVAL;
609  input->index = index;
610  strlcpy(input->name, input_strs[card_input->video_type - 1],
611  sizeof(input->name));
612  input->type = (card_input->video_type == CX18_CARD_INPUT_VID_TUNER ?
614  input->audioset = (1 << cx->nof_audio_inputs) - 1;
615  input->std = (input->type == V4L2_INPUT_TYPE_TUNER) ?
616  cx->tuner_std : V4L2_STD_ALL;
617  return 0;
618 }
619 
621 {
622  const struct cx18_card_audio_input *aud_input =
623  cx->card->audio_inputs + index;
624  static const char * const input_strs[] = {
625  "Tuner 1",
626  "Line In 1",
627  "Line In 2"
628  };
629 
630  memset(audio, 0, sizeof(*audio));
631  if (index >= cx->nof_audio_inputs)
632  return -EINVAL;
633  strlcpy(audio->name, input_strs[aud_input->audio_type - 1],
634  sizeof(audio->name));
635  audio->index = index;
637  return 0;
638 }