aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/video/ivtv/ivtv-cards.c47
-rw-r--r--drivers/media/video/ivtv/ivtv-cards.h24
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.c86
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.h2
-rw-r--r--drivers/media/video/ivtv/ivtv-i2c.c110
-rw-r--r--drivers/media/video/ivtv/ivtv-i2c.h1
6 files changed, 187 insertions, 83 deletions
diff --git a/drivers/media/video/ivtv/ivtv-cards.c b/drivers/media/video/ivtv/ivtv-cards.c
index 715285e60089..26322e933999 100644
--- a/drivers/media/video/ivtv/ivtv-cards.c
+++ b/drivers/media/video/ivtv/ivtv-cards.c
@@ -40,6 +40,27 @@
40#define MSP_MONO MSP_INPUT(MSP_IN_MONO, MSP_IN_TUNER1, \ 40#define MSP_MONO MSP_INPUT(MSP_IN_MONO, MSP_IN_TUNER1, \
41 MSP_DSP_IN_SCART, MSP_DSP_IN_SCART) 41 MSP_DSP_IN_SCART, MSP_DSP_IN_SCART)
42 42
43/* usual i2c tuner addresses to probe */
44static struct ivtv_card_tuner_i2c ivtv_i2c_std = {
45 .radio = { I2C_CLIENT_END },
46 .demod = { 0x43, I2C_CLIENT_END },
47 .tv = { 0x61, 0x60, I2C_CLIENT_END },
48};
49
50/* as above, but with possible radio tuner */
51static struct ivtv_card_tuner_i2c ivtv_i2c_radio = {
52 .radio = { 0x60, I2C_CLIENT_END },
53 .demod = { 0x43, I2C_CLIENT_END },
54 .tv = { 0x61, I2C_CLIENT_END },
55};
56
57/* using the tda8290+75a combo */
58static struct ivtv_card_tuner_i2c ivtv_i2c_tda8290 = {
59 .radio = { I2C_CLIENT_END },
60 .demod = { I2C_CLIENT_END },
61 .tv = { 0x4b, I2C_CLIENT_END },
62};
63
43/********************** card configuration *******************************/ 64/********************** card configuration *******************************/
44 65
45/* Please add new PCI IDs to: http://pci-ids.ucw.cz/iii 66/* Please add new PCI IDs to: http://pci-ids.ucw.cz/iii
@@ -73,6 +94,7 @@ static const struct ivtv_card ivtv_card_pvr250 = {
73 { IVTV_CARD_INPUT_LINE_IN2, MSP_SCART3 }, 94 { IVTV_CARD_INPUT_LINE_IN2, MSP_SCART3 },
74 }, 95 },
75 .radio_input = { IVTV_CARD_INPUT_AUD_TUNER, MSP_SCART2 }, 96 .radio_input = { IVTV_CARD_INPUT_AUD_TUNER, MSP_SCART2 },
97 .i2c = &ivtv_i2c_std,
76}; 98};
77 99
78/* ------------------------------------------------------------------------- */ 100/* ------------------------------------------------------------------------- */
@@ -127,6 +149,7 @@ static const struct ivtv_card ivtv_card_pvr350 = {
127 { IVTV_CARD_INPUT_LINE_IN2, MSP_SCART3 }, 149 { IVTV_CARD_INPUT_LINE_IN2, MSP_SCART3 },
128 }, 150 },
129 .radio_input = { IVTV_CARD_INPUT_AUD_TUNER, MSP_SCART2 }, 151 .radio_input = { IVTV_CARD_INPUT_AUD_TUNER, MSP_SCART2 },
152 .i2c = &ivtv_i2c_std,
130}; 153};
131 154
132/* PVR-350 V1 boards have a different audio tuner input and use a 155/* PVR-350 V1 boards have a different audio tuner input and use a
@@ -158,6 +181,7 @@ static const struct ivtv_card ivtv_card_pvr350_v1 = {
158 { IVTV_CARD_INPUT_LINE_IN2, MSP_SCART3 }, 181 { IVTV_CARD_INPUT_LINE_IN2, MSP_SCART3 },
159 }, 182 },
160 .radio_input = { IVTV_CARD_INPUT_AUD_TUNER, MSP_SCART2 }, 183 .radio_input = { IVTV_CARD_INPUT_AUD_TUNER, MSP_SCART2 },
184 .i2c = &ivtv_i2c_std,
161}; 185};
162 186
163/* ------------------------------------------------------------------------- */ 187/* ------------------------------------------------------------------------- */
@@ -193,6 +217,7 @@ static const struct ivtv_card ivtv_card_pvr150 = {
193 CX25840_AUDIO_SERIAL, WM8775_AIN4 }, 217 CX25840_AUDIO_SERIAL, WM8775_AIN4 },
194 /* apparently needed for the IR blaster */ 218 /* apparently needed for the IR blaster */
195 .gpio_init = { .direction = 0x1f01, .initial_value = 0x26f3 }, 219 .gpio_init = { .direction = 0x1f01, .initial_value = 0x26f3 },
220 .i2c = &ivtv_i2c_std,
196}; 221};
197 222
198/* ------------------------------------------------------------------------- */ 223/* ------------------------------------------------------------------------- */
@@ -235,6 +260,7 @@ static const struct ivtv_card ivtv_card_m179 = {
235 { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_NTSC }, 260 { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_NTSC },
236 }, 261 },
237 .pci_list = ivtv_pci_m179, 262 .pci_list = ivtv_pci_m179,
263 .i2c = &ivtv_i2c_std,
238}; 264};
239 265
240/* ------------------------------------------------------------------------- */ 266/* ------------------------------------------------------------------------- */
@@ -276,6 +302,7 @@ static const struct ivtv_card ivtv_card_mpg600 = {
276 { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FQ1286 }, 302 { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FQ1286 },
277 }, 303 },
278 .pci_list = ivtv_pci_mpg600, 304 .pci_list = ivtv_pci_mpg600,
305 .i2c = &ivtv_i2c_std,
279}; 306};
280 307
281/* ------------------------------------------------------------------------- */ 308/* ------------------------------------------------------------------------- */
@@ -316,6 +343,7 @@ static const struct ivtv_card ivtv_card_mpg160 = {
316 { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FQ1286 }, 343 { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FQ1286 },
317 }, 344 },
318 .pci_list = ivtv_pci_mpg160, 345 .pci_list = ivtv_pci_mpg160,
346 .i2c = &ivtv_i2c_std,
319}; 347};
320 348
321/* ------------------------------------------------------------------------- */ 349/* ------------------------------------------------------------------------- */
@@ -351,6 +379,7 @@ static const struct ivtv_card ivtv_card_pg600 = {
351 { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FQ1286 }, 379 { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FQ1286 },
352 }, 380 },
353 .pci_list = ivtv_pci_pg600, 381 .pci_list = ivtv_pci_pg600,
382 .i2c = &ivtv_i2c_std,
354}; 383};
355 384
356/* ------------------------------------------------------------------------- */ 385/* ------------------------------------------------------------------------- */
@@ -394,6 +423,7 @@ static const struct ivtv_card ivtv_card_avc2410 = {
394 { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FM1236_MK3 }, 423 { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FM1236_MK3 },
395 }, 424 },
396 .pci_list = ivtv_pci_avc2410, 425 .pci_list = ivtv_pci_avc2410,
426 .i2c = &ivtv_i2c_std,
397}; 427};
398 428
399/* ------------------------------------------------------------------------- */ 429/* ------------------------------------------------------------------------- */
@@ -464,6 +494,7 @@ static const struct ivtv_card ivtv_card_tg5000tv = {
464 { .std = V4L2_STD_525_60, .tuner = TUNER_PHILIPS_FQ1286 }, 494 { .std = V4L2_STD_525_60, .tuner = TUNER_PHILIPS_FQ1286 },
465 }, 495 },
466 .pci_list = ivtv_pci_tg5000tv, 496 .pci_list = ivtv_pci_tg5000tv,
497 .i2c = &ivtv_i2c_std,
467}; 498};
468 499
469/* ------------------------------------------------------------------------- */ 500/* ------------------------------------------------------------------------- */
@@ -494,6 +525,7 @@ static const struct ivtv_card ivtv_card_va2000 = {
494 { .std = V4L2_STD_525_60, .tuner = TUNER_PHILIPS_FQ1286 }, 525 { .std = V4L2_STD_525_60, .tuner = TUNER_PHILIPS_FQ1286 },
495 }, 526 },
496 .pci_list = ivtv_pci_va2000, 527 .pci_list = ivtv_pci_va2000,
528 .i2c = &ivtv_i2c_std,
497}; 529};
498 530
499/* ------------------------------------------------------------------------- */ 531/* ------------------------------------------------------------------------- */
@@ -538,6 +570,7 @@ static const struct ivtv_card ivtv_card_cx23416gyc = {
538 { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FM1236_MK3 }, 570 { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FM1236_MK3 },
539 }, 571 },
540 .pci_list = ivtv_pci_cx23416gyc, 572 .pci_list = ivtv_pci_cx23416gyc,
573 .i2c = &ivtv_i2c_std,
541}; 574};
542 575
543static const struct ivtv_card ivtv_card_cx23416gyc_nogr = { 576static const struct ivtv_card ivtv_card_cx23416gyc_nogr = {
@@ -568,6 +601,7 @@ static const struct ivtv_card ivtv_card_cx23416gyc_nogr = {
568 { .std = V4L2_STD_625_50, .tuner = TUNER_PHILIPS_FM1216ME_MK3 }, 601 { .std = V4L2_STD_625_50, .tuner = TUNER_PHILIPS_FM1216ME_MK3 },
569 { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FM1236_MK3 }, 602 { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FM1236_MK3 },
570 }, 603 },
604 .i2c = &ivtv_i2c_std,
571}; 605};
572 606
573static const struct ivtv_card ivtv_card_cx23416gyc_nogrycs = { 607static const struct ivtv_card ivtv_card_cx23416gyc_nogrycs = {
@@ -597,6 +631,7 @@ static const struct ivtv_card ivtv_card_cx23416gyc_nogrycs = {
597 { .std = V4L2_STD_625_50, .tuner = TUNER_PHILIPS_FM1216ME_MK3 }, 631 { .std = V4L2_STD_625_50, .tuner = TUNER_PHILIPS_FM1216ME_MK3 },
598 { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FM1236_MK3 }, 632 { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FM1236_MK3 },
599 }, 633 },
634 .i2c = &ivtv_i2c_std,
600}; 635};
601 636
602/* ------------------------------------------------------------------------- */ 637/* ------------------------------------------------------------------------- */
@@ -636,6 +671,7 @@ static const struct ivtv_card ivtv_card_gv_mvprx = {
636 { .std = V4L2_STD_525_60, .tuner = TUNER_PANASONIC_VP27 }, 671 { .std = V4L2_STD_525_60, .tuner = TUNER_PANASONIC_VP27 },
637 }, 672 },
638 .pci_list = ivtv_pci_gv_mvprx, 673 .pci_list = ivtv_pci_gv_mvprx,
674 .i2c = &ivtv_i2c_std,
639}; 675};
640 676
641/* ------------------------------------------------------------------------- */ 677/* ------------------------------------------------------------------------- */
@@ -672,6 +708,7 @@ static const struct ivtv_card ivtv_card_gv_mvprx2e = {
672 { .std = V4L2_STD_525_60, .tuner = TUNER_PANASONIC_VP27 }, 708 { .std = V4L2_STD_525_60, .tuner = TUNER_PANASONIC_VP27 },
673 }, 709 },
674 .pci_list = ivtv_pci_gv_mvprx2e, 710 .pci_list = ivtv_pci_gv_mvprx2e,
711 .i2c = &ivtv_i2c_std,
675}; 712};
676 713
677/* ------------------------------------------------------------------------- */ 714/* ------------------------------------------------------------------------- */
@@ -706,6 +743,7 @@ static const struct ivtv_card ivtv_card_gotview_pci_dvd = {
706 { .std = V4L2_STD_625_50, .tuner = TUNER_PHILIPS_FM1216ME_MK3 }, 743 { .std = V4L2_STD_625_50, .tuner = TUNER_PHILIPS_FM1216ME_MK3 },
707 }, 744 },
708 .pci_list = ivtv_pci_gotview_pci_dvd, 745 .pci_list = ivtv_pci_gotview_pci_dvd,
746 .i2c = &ivtv_i2c_std,
709}; 747};
710 748
711/* ------------------------------------------------------------------------- */ 749/* ------------------------------------------------------------------------- */
@@ -744,6 +782,7 @@ static const struct ivtv_card ivtv_card_gotview_pci_dvd2 = {
744 { .std = V4L2_STD_625_50, .tuner = TUNER_PHILIPS_FM1216ME_MK3 }, 782 { .std = V4L2_STD_625_50, .tuner = TUNER_PHILIPS_FM1216ME_MK3 },
745 }, 783 },
746 .pci_list = ivtv_pci_gotview_pci_dvd2, 784 .pci_list = ivtv_pci_gotview_pci_dvd2,
785 .i2c = &ivtv_i2c_std,
747}; 786};
748 787
749/* ------------------------------------------------------------------------- */ 788/* ------------------------------------------------------------------------- */
@@ -779,6 +818,7 @@ static const struct ivtv_card ivtv_card_yuan_mpc622 = {
779 { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_TDA8290 }, 818 { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_TDA8290 },
780 }, 819 },
781 .pci_list = ivtv_pci_yuan_mpc622, 820 .pci_list = ivtv_pci_yuan_mpc622,
821 .i2c = &ivtv_i2c_tda8290,
782}; 822};
783 823
784/* ------------------------------------------------------------------------- */ 824/* ------------------------------------------------------------------------- */
@@ -820,6 +860,7 @@ static const struct ivtv_card ivtv_card_dctmvtvp1 = {
820 { .std = V4L2_STD_525_60, .tuner = TUNER_PHILIPS_FQ1286 }, 860 { .std = V4L2_STD_525_60, .tuner = TUNER_PHILIPS_FQ1286 },
821 }, 861 },
822 .pci_list = ivtv_pci_dctmvtvp1, 862 .pci_list = ivtv_pci_dctmvtvp1,
863 .i2c = &ivtv_i2c_std,
823}; 864};
824 865
825/* ------------------------------------------------------------------------- */ 866/* ------------------------------------------------------------------------- */
@@ -852,6 +893,7 @@ static const struct ivtv_card ivtv_card_pg600v2 = {
852 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 }, 893 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
853 }, 894 },
854 .pci_list = ivtv_pci_pg600v2, 895 .pci_list = ivtv_pci_pg600v2,
896 .i2c = &ivtv_i2c_std,
855}; 897};
856 898
857/* ------------------------------------------------------------------------- */ 899/* ------------------------------------------------------------------------- */
@@ -883,6 +925,7 @@ static const struct ivtv_card ivtv_card_club3d = {
883 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 }, 925 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
884 }, 926 },
885 .pci_list = ivtv_pci_club3d, 927 .pci_list = ivtv_pci_club3d,
928 .i2c = &ivtv_i2c_std,
886}; 929};
887 930
888/* ------------------------------------------------------------------------- */ 931/* ------------------------------------------------------------------------- */
@@ -914,6 +957,7 @@ static const struct ivtv_card ivtv_card_avertv_mce116 = {
914 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 }, 957 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
915 }, 958 },
916 .pci_list = ivtv_pci_avertv_mce116, 959 .pci_list = ivtv_pci_avertv_mce116,
960 .i2c = &ivtv_i2c_std,
917}; 961};
918 962
919/* ------------------------------------------------------------------------- */ 963/* ------------------------------------------------------------------------- */
@@ -952,6 +996,7 @@ static const struct ivtv_card ivtv_card_aver_pvr150 = {
952 { .std = V4L2_STD_525_60, .tuner = TUNER_TCL_2002N }, 996 { .std = V4L2_STD_525_60, .tuner = TUNER_TCL_2002N },
953 }, 997 },
954 .pci_list = ivtv_pci_aver_pvr150, 998 .pci_list = ivtv_pci_aver_pvr150,
999 .i2c = &ivtv_i2c_radio,
955}; 1000};
956 1001
957/* ------------------------------------------------------------------------- */ 1002/* ------------------------------------------------------------------------- */
@@ -979,6 +1024,7 @@ static const struct ivtv_card ivtv_card_aver_ezmaker = {
979 { IVTV_CARD_INPUT_LINE_IN1, CX25840_AUDIO_SERIAL, 0 }, 1024 { IVTV_CARD_INPUT_LINE_IN1, CX25840_AUDIO_SERIAL, 0 },
980 }, 1025 },
981 .gpio_init = { .direction = 0x4000, .initial_value = 0x4000 }, 1026 .gpio_init = { .direction = 0x4000, .initial_value = 0x4000 },
1027 /* Does not have a tuner */
982 .pci_list = ivtv_pci_aver_ezmaker, 1028 .pci_list = ivtv_pci_aver_ezmaker,
983}; 1029};
984 1030
@@ -1018,6 +1064,7 @@ static const struct ivtv_card ivtv_card_asus_falcon2 = {
1018 { .std = V4L2_STD_525_60, .tuner = TUNER_PHILIPS_FM1236_MK3 }, 1064 { .std = V4L2_STD_525_60, .tuner = TUNER_PHILIPS_FM1236_MK3 },
1019 }, 1065 },
1020 .pci_list = ivtv_pci_asus_falcon2, 1066 .pci_list = ivtv_pci_asus_falcon2,
1067 .i2c = &ivtv_i2c_std,
1021}; 1068};
1022 1069
1023static const struct ivtv_card *ivtv_card_list[] = { 1070static const struct ivtv_card *ivtv_card_list[] = {
diff --git a/drivers/media/video/ivtv/ivtv-cards.h b/drivers/media/video/ivtv/ivtv-cards.h
index b982fb06c584..191aafdd9968 100644
--- a/drivers/media/video/ivtv/ivtv-cards.h
+++ b/drivers/media/video/ivtv/ivtv-cards.h
@@ -84,7 +84,7 @@
84#define IVTV_PCI_ID_GOTVIEW1 0xffac 84#define IVTV_PCI_ID_GOTVIEW1 0xffac
85#define IVTV_PCI_ID_GOTVIEW2 0xffad 85#define IVTV_PCI_ID_GOTVIEW2 0xffad
86 86
87/* hardware flags */ 87/* hardware flags, no gaps allowed, IVTV_HW_GPIO must always be last */
88#define IVTV_HW_CX25840 (1 << 0) 88#define IVTV_HW_CX25840 (1 << 0)
89#define IVTV_HW_SAA7115 (1 << 1) 89#define IVTV_HW_SAA7115 (1 << 1)
90#define IVTV_HW_SAA7127 (1 << 2) 90#define IVTV_HW_SAA7127 (1 << 2)
@@ -94,14 +94,13 @@
94#define IVTV_HW_CS53L32A (1 << 6) 94#define IVTV_HW_CS53L32A (1 << 6)
95#define IVTV_HW_TVEEPROM (1 << 7) 95#define IVTV_HW_TVEEPROM (1 << 7)
96#define IVTV_HW_SAA7114 (1 << 8) 96#define IVTV_HW_SAA7114 (1 << 8)
97#define IVTV_HW_TVAUDIO (1 << 9) 97#define IVTV_HW_UPD64031A (1 << 9)
98#define IVTV_HW_UPD64031A (1 << 10) 98#define IVTV_HW_UPD6408X (1 << 10)
99#define IVTV_HW_UPD6408X (1 << 11) 99#define IVTV_HW_SAA717X (1 << 11)
100#define IVTV_HW_SAA717X (1 << 12) 100#define IVTV_HW_WM8739 (1 << 12)
101#define IVTV_HW_WM8739 (1 << 13) 101#define IVTV_HW_VP27SMPX (1 << 13)
102#define IVTV_HW_VP27SMPX (1 << 14) 102#define IVTV_HW_M52790 (1 << 14)
103#define IVTV_HW_M52790 (1 << 15) 103#define IVTV_HW_GPIO (1 << 15)
104#define IVTV_HW_GPIO (1 << 16)
105 104
106#define IVTV_HW_SAA711X (IVTV_HW_SAA7115 | IVTV_HW_SAA7114) 105#define IVTV_HW_SAA711X (IVTV_HW_SAA7115 | IVTV_HW_SAA7114)
107 106
@@ -235,6 +234,12 @@ struct ivtv_card_tuner {
235 int tuner; /* tuner ID (from tuner.h) */ 234 int tuner; /* tuner ID (from tuner.h) */
236}; 235};
237 236
237struct ivtv_card_tuner_i2c {
238 unsigned short radio[2];/* radio tuner i2c address to probe */
239 unsigned short demod[2];/* demodulator i2c address to probe */
240 unsigned short tv[4]; /* tv tuner i2c addresses to probe */
241};
242
238/* for card information/parameters */ 243/* for card information/parameters */
239struct ivtv_card { 244struct ivtv_card {
240 int type; 245 int type;
@@ -262,6 +267,7 @@ struct ivtv_card {
262 struct ivtv_gpio_audio_detect gpio_audio_detect; 267 struct ivtv_gpio_audio_detect gpio_audio_detect;
263 268
264 struct ivtv_card_tuner tuners[IVTV_CARD_MAX_TUNERS]; 269 struct ivtv_card_tuner tuners[IVTV_CARD_MAX_TUNERS];
270 struct ivtv_card_tuner_i2c *i2c;
265 271
266 /* list of device and subsystem vendor/devices that 272 /* list of device and subsystem vendor/devices that
267 correspond to this card type. */ 273 correspond to this card type. */
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c
index 4595c7807f2c..4994dc59d40c 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -400,6 +400,7 @@ static void ivtv_process_eeprom(struct ivtv *itv)
400 400
401 itv->v4l2_cap = itv->card->v4l2_capabilities; 401 itv->v4l2_cap = itv->card->v4l2_capabilities;
402 itv->card_name = itv->card->name; 402 itv->card_name = itv->card->name;
403 itv->card_i2c = itv->card->i2c;
403 404
404 /* If this is a PVR500 then it should be possible to detect whether it is the 405 /* If this is a PVR500 then it should be possible to detect whether it is the
405 first or second unit by looking at the subsystem device ID: is bit 4 is 406 first or second unit by looking at the subsystem device ID: is bit 4 is
@@ -417,7 +418,14 @@ static void ivtv_process_eeprom(struct ivtv *itv)
417 This detection is needed since the eeprom reports incorrectly that a radio is 418 This detection is needed since the eeprom reports incorrectly that a radio is
418 present on the second unit. */ 419 present on the second unit. */
419 if (tv.model / 1000 == 23) { 420 if (tv.model / 1000 == 23) {
421 static const struct ivtv_card_tuner_i2c ivtv_i2c_radio = {
422 .radio = { 0x60, I2C_CLIENT_END },
423 .demod = { 0x43, I2C_CLIENT_END },
424 .tv = { 0x61, I2C_CLIENT_END },
425 };
426
420 itv->card_name = "WinTV PVR 500"; 427 itv->card_name = "WinTV PVR 500";
428 itv->card_i2c = &ivtv_i2c_radio;
421 if (pci_slot == 8 || pci_slot == 9) { 429 if (pci_slot == 8 || pci_slot == 9) {
422 int is_first = (pci_slot & 1) == 0; 430 int is_first = (pci_slot & 1) == 0;
423 431
@@ -635,6 +643,7 @@ done:
635 } 643 }
636 itv->v4l2_cap = itv->card->v4l2_capabilities; 644 itv->v4l2_cap = itv->card->v4l2_capabilities;
637 itv->card_name = itv->card->name; 645 itv->card_name = itv->card->name;
646 itv->card_i2c = itv->card->i2c;
638} 647}
639 648
640/* Precondition: the ivtv structure has been memset to 0. Only 649/* Precondition: the ivtv structure has been memset to 0. Only
@@ -816,79 +825,66 @@ static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *dev,
816 return 0; 825 return 0;
817} 826}
818 827
819static void ivtv_request_module(struct ivtv *itv, const char *name) 828static u32 ivtv_request_module(struct ivtv *itv, u32 hw,
829 const char *name, u32 id)
820{ 830{
831 if ((hw & id) == 0)
832 return hw;
821 if (request_module(name) != 0) { 833 if (request_module(name) != 0) {
822 IVTV_ERR("Failed to load module %s\n", name); 834 IVTV_ERR("Failed to load module %s\n", name);
823 } else { 835 return hw & ~id;
824 IVTV_DEBUG_INFO("Loaded module %s\n", name);
825 } 836 }
837 IVTV_DEBUG_INFO("Loaded module %s\n", name);
838 return hw;
826} 839}
827 840
828static void ivtv_load_and_init_modules(struct ivtv *itv) 841static void ivtv_load_and_init_modules(struct ivtv *itv)
829{ 842{
830 u32 hw = itv->card->hw_all; 843 u32 hw = itv->card->hw_all;
831 int i; 844 unsigned i;
832 845
833 /* load modules */ 846 /* load modules */
834#ifndef CONFIG_VIDEO_TUNER 847 if ((hw & IVTV_HW_TUNER) && itv->options.tuner == TUNER_XC2028) {
835 if (hw & IVTV_HW_TUNER) { 848 IVTV_INFO("Xceive tuner not yet supported, only composite\n");
836 if (itv->options.tuner == TUNER_XC2028) { 849 IVTV_INFO("and S-Video inputs will be available\n");
837 IVTV_INFO("Xceive tuner not yet supported, only composite and S-Video inputs will be available\n"); 850 hw &= ~IVTV_HW_TUNER;
838 itv->tunerid = 1;
839 }
840 else {
841 ivtv_request_module(itv, "tuner");
842 }
843 } 851 }
852#ifndef CONFIG_VIDEO_TUNER
853 hw = ivtv_request_module(itv, hw, "tuner", IVTV_HW_TUNER);
844#endif 854#endif
845#ifndef CONFIG_VIDEO_CX25840 855#ifndef CONFIG_VIDEO_CX25840
846 if (hw & IVTV_HW_CX25840) 856 hw = ivtv_request_module(itv, hw, "cx25840", IVTV_HW_CX25840);
847 ivtv_request_module(itv, "cx25840");
848#endif 857#endif
849#ifndef CONFIG_VIDEO_SAA711X 858#ifndef CONFIG_VIDEO_SAA711X
850 if (hw & IVTV_HW_SAA711X) 859 hw = ivtv_request_module(itv, hw, "saa7115", IVTV_HW_SAA711X);
851 ivtv_request_module(itv, "saa7115");
852#endif 860#endif
853#ifndef CONFIG_VIDEO_SAA7127 861#ifndef CONFIG_VIDEO_SAA7127
854 if (hw & IVTV_HW_SAA7127) 862 hw = ivtv_request_module(itv, hw, "saa7127", IVTV_HW_SAA7127);
855 ivtv_request_module(itv, "saa7127");
856#endif 863#endif
857 if (hw & IVTV_HW_SAA717X) 864 hw = ivtv_request_module(itv, hw, "saa717x", IVTV_HW_SAA717X);
858 ivtv_request_module(itv, "saa717x");
859#ifndef CONFIG_VIDEO_UPD64031A 865#ifndef CONFIG_VIDEO_UPD64031A
860 if (hw & IVTV_HW_UPD64031A) 866 hw = ivtv_request_module(itv, hw, "upd64031a", IVTV_HW_UPD64031A);
861 ivtv_request_module(itv, "upd64031a");
862#endif 867#endif
863#ifndef CONFIG_VIDEO_UPD64083 868#ifndef CONFIG_VIDEO_UPD64083
864 if (hw & IVTV_HW_UPD6408X) 869 hw = ivtv_request_module(itv, hw, "upd64083", IVTV_HW_UPD6408X);
865 ivtv_request_module(itv, "upd64083");
866#endif 870#endif
867#ifndef CONFIG_VIDEO_MSP3400 871#ifndef CONFIG_VIDEO_MSP3400
868 if (hw & IVTV_HW_MSP34XX) 872 hw = ivtv_request_module(itv, hw, "msp3400", IVTV_HW_MSP34XX);
869 ivtv_request_module(itv, "msp3400");
870#endif 873#endif
871#ifndef CONFIG_VIDEO_VP27SMPX 874#ifndef CONFIG_VIDEO_VP27SMPX
872 if (hw & IVTV_HW_VP27SMPX) 875 hw = ivtv_request_module(itv, hw, "vp27smpx", IVTV_HW_VP27SMPX);
873 ivtv_request_module(itv, "vp27smpx");
874#endif 876#endif
875 if (hw & IVTV_HW_TVAUDIO)
876 ivtv_request_module(itv, "tvaudio");
877#ifndef CONFIG_VIDEO_WM8775 877#ifndef CONFIG_VIDEO_WM8775
878 if (hw & IVTV_HW_WM8775) 878 hw = ivtv_request_module(itv, hw, "wm8775", IVTV_HW_WM8775);
879 ivtv_request_module(itv, "wm8775");
880#endif 879#endif
881#ifndef CONFIG_VIDEO_WM8739 880#ifndef CONFIG_VIDEO_WM8739
882 if (hw & IVTV_HW_WM8739) 881 hw = ivtv_request_module(itv, hw, "wm8739", IVTV_HW_WM8739);
883 ivtv_request_module(itv, "wm8739");
884#endif 882#endif
885#ifndef CONFIG_VIDEO_CS53L32A 883#ifndef CONFIG_VIDEO_CS53L32A
886 if (hw & IVTV_HW_CS53L32A) 884 hw = ivtv_request_module(itv, hw, "cs53l32a", IVTV_HW_CS53L32A);
887 ivtv_request_module(itv, "cs53l32a");
888#endif 885#endif
889#ifndef CONFIG_VIDEO_M52790 886#ifndef CONFIG_VIDEO_M52790
890 if (hw & IVTV_HW_M52790) 887 hw = ivtv_request_module(itv, hw, "m52790", IVTV_HW_M52790);
891 ivtv_request_module(itv, "m52790");
892#endif 888#endif
893 889
894 /* check which i2c devices are actually found */ 890 /* check which i2c devices are actually found */
@@ -897,11 +893,12 @@ static void ivtv_load_and_init_modules(struct ivtv *itv)
897 893
898 if (!(device & hw)) 894 if (!(device & hw))
899 continue; 895 continue;
900 if (device == IVTV_HW_GPIO) { 896 if (device == IVTV_HW_GPIO || device == IVTV_HW_TVEEPROM) {
901 /* GPIO is always available */ 897 /* GPIO and TVEEPROM do not use i2c probing */
902 itv->hw_flags |= IVTV_HW_GPIO; 898 itv->hw_flags |= device;
903 continue; 899 continue;
904 } 900 }
901 ivtv_i2c_register(itv, i);
905 if (ivtv_i2c_hw_addr(itv, device) > 0) 902 if (ivtv_i2c_hw_addr(itv, device) > 0)
906 itv->hw_flags |= device; 903 itv->hw_flags |= device;
907 } 904 }
@@ -1075,9 +1072,6 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
1075 IVTV_DEBUG_INFO("Active card count: %d.\n", ivtv_cards_active); 1072 IVTV_DEBUG_INFO("Active card count: %d.\n", ivtv_cards_active);
1076 1073
1077 if (itv->card->hw_all & IVTV_HW_TVEEPROM) { 1074 if (itv->card->hw_all & IVTV_HW_TVEEPROM) {
1078#ifdef CONFIG_VIDEO_TVEEPROM_MODULE
1079 ivtv_request_module(itv, "tveeprom");
1080#endif
1081 /* Based on the model number the cardtype may be changed. 1075 /* Based on the model number the cardtype may be changed.
1082 The PCI IDs are not always reliable. */ 1076 The PCI IDs are not always reliable. */
1083 ivtv_process_eeprom(itv); 1077 ivtv_process_eeprom(itv);
@@ -1150,7 +1144,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
1150 if (itv->options.radio > 0) 1144 if (itv->options.radio > 0)
1151 itv->v4l2_cap |= V4L2_CAP_RADIO; 1145 itv->v4l2_cap |= V4L2_CAP_RADIO;
1152 1146
1153 if (itv->options.tuner > -1 && itv->tunerid == 0) { 1147 if (itv->options.tuner > -1) {
1154 struct tuner_setup setup; 1148 struct tuner_setup setup;
1155 1149
1156 setup.addr = ADDR_UNSET; 1150 setup.addr = ADDR_UNSET;
diff --git a/drivers/media/video/ivtv/ivtv-driver.h b/drivers/media/video/ivtv/ivtv-driver.h
index 19a9b3bac190..8eeea3a0c700 100644
--- a/drivers/media/video/ivtv/ivtv-driver.h
+++ b/drivers/media/video/ivtv/ivtv-driver.h
@@ -590,13 +590,13 @@ struct ivtv {
590 struct pci_dev *dev; /* PCI device */ 590 struct pci_dev *dev; /* PCI device */
591 const struct ivtv_card *card; /* card information */ 591 const struct ivtv_card *card; /* card information */
592 const char *card_name; /* full name of the card */ 592 const char *card_name; /* full name of the card */
593 const struct ivtv_card_tuner_i2c *card_i2c; /* i2c addresses to probe for tuner */
593 u8 has_cx23415; /* 1 if it is a cx23415 based card, 0 for cx23416 */ 594 u8 has_cx23415; /* 1 if it is a cx23415 based card, 0 for cx23416 */
594 u8 pvr150_workaround; /* 1 if the cx25840 needs to workaround a PVR150 bug */ 595 u8 pvr150_workaround; /* 1 if the cx25840 needs to workaround a PVR150 bug */
595 u8 nof_inputs; /* number of video inputs */ 596 u8 nof_inputs; /* number of video inputs */
596 u8 nof_audio_inputs; /* number of audio inputs */ 597 u8 nof_audio_inputs; /* number of audio inputs */
597 u32 v4l2_cap; /* V4L2 capabilities of card */ 598 u32 v4l2_cap; /* V4L2 capabilities of card */
598 u32 hw_flags; /* hardware description of the board */ 599 u32 hw_flags; /* hardware description of the board */
599 int tunerid; /* userspace tuner ID for experimental Xceive tuner support */
600 v4l2_std_id tuner_std; /* the norm of the card's tuner (fixed) */ 600 v4l2_std_id tuner_std; /* the norm of the card's tuner (fixed) */
601 /* controlling video decoder function */ 601 /* controlling video decoder function */
602 int (*video_dec_func)(struct ivtv *, unsigned int, void *); 602 int (*video_dec_func)(struct ivtv *, unsigned int, void *);
diff --git a/drivers/media/video/ivtv/ivtv-i2c.c b/drivers/media/video/ivtv/ivtv-i2c.c
index 7f513ecc0781..9acfde68116a 100644
--- a/drivers/media/video/ivtv/ivtv-i2c.c
+++ b/drivers/media/video/ivtv/ivtv-i2c.c
@@ -92,7 +92,8 @@
92#define IVTV_TEA5767_I2C_ADDR 0x60 92#define IVTV_TEA5767_I2C_ADDR 0x60
93#define IVTV_UPD64031A_I2C_ADDR 0x12 93#define IVTV_UPD64031A_I2C_ADDR 0x12
94#define IVTV_UPD64083_I2C_ADDR 0x5c 94#define IVTV_UPD64083_I2C_ADDR 0x5c
95#define IVTV_TDA985X_I2C_ADDR 0x5b 95#define IVTV_VP27SMPX_I2C_ADDR 0x5b
96#define IVTV_M52790_I2C_ADDR 0x48
96 97
97/* This array should match the IVTV_HW_ defines */ 98/* This array should match the IVTV_HW_ defines */
98static const u8 hw_driverids[] = { 99static const u8 hw_driverids[] = {
@@ -105,7 +106,6 @@ static const u8 hw_driverids[] = {
105 I2C_DRIVERID_CS53L32A, 106 I2C_DRIVERID_CS53L32A,
106 I2C_DRIVERID_TVEEPROM, 107 I2C_DRIVERID_TVEEPROM,
107 I2C_DRIVERID_SAA711X, 108 I2C_DRIVERID_SAA711X,
108 I2C_DRIVERID_TVAUDIO,
109 I2C_DRIVERID_UPD64031A, 109 I2C_DRIVERID_UPD64031A,
110 I2C_DRIVERID_UPD64083, 110 I2C_DRIVERID_UPD64083,
111 I2C_DRIVERID_SAA717X, 111 I2C_DRIVERID_SAA717X,
@@ -116,8 +116,28 @@ static const u8 hw_driverids[] = {
116}; 116};
117 117
118/* This array should match the IVTV_HW_ defines */ 118/* This array should match the IVTV_HW_ defines */
119static const u8 hw_addrs[] = {
120 IVTV_CX25840_I2C_ADDR,
121 IVTV_SAA7115_I2C_ADDR,
122 IVTV_SAA7127_I2C_ADDR,
123 IVTV_MSP3400_I2C_ADDR,
124 0,
125 IVTV_WM8775_I2C_ADDR,
126 IVTV_CS53L32A_I2C_ADDR,
127 0,
128 IVTV_SAA7115_I2C_ADDR,
129 IVTV_UPD64031A_I2C_ADDR,
130 IVTV_UPD64083_I2C_ADDR,
131 IVTV_SAA717x_I2C_ADDR,
132 IVTV_WM8739_I2C_ADDR,
133 IVTV_VP27SMPX_I2C_ADDR,
134 IVTV_M52790_I2C_ADDR,
135 0 /* IVTV_HW_GPIO dummy driver ID */
136};
137
138/* This array should match the IVTV_HW_ defines */
119static const char * const hw_drivernames[] = { 139static const char * const hw_drivernames[] = {
120 "cx2584x", 140 "cx25840",
121 "saa7115", 141 "saa7115",
122 "saa7127", 142 "saa7127",
123 "msp3400", 143 "msp3400",
@@ -125,8 +145,7 @@ static const char * const hw_drivernames[] = {
125 "wm8775", 145 "wm8775",
126 "cs53l32a", 146 "cs53l32a",
127 "tveeprom", 147 "tveeprom",
128 "saa7114", 148 "saa7115",
129 "tvaudio",
130 "upd64031a", 149 "upd64031a",
131 "upd64083", 150 "upd64083",
132 "saa717x", 151 "saa717x",
@@ -136,21 +155,57 @@ static const char * const hw_drivernames[] = {
136 "gpio", 155 "gpio",
137}; 156};
138 157
139static int attach_inform(struct i2c_client *client) 158int ivtv_i2c_register(struct ivtv *itv, unsigned idx)
140{ 159{
141 struct ivtv *itv = (struct ivtv *)i2c_get_adapdata(client->adapter); 160 struct i2c_board_info info;
161 struct i2c_client *c;
162 u8 id;
142 int i; 163 int i;
143 164
144 IVTV_DEBUG_I2C("i2c client attach\n"); 165 IVTV_DEBUG_I2C("i2c client register\n");
145 for (i = 0; i < I2C_CLIENTS_MAX; i++) { 166 if (idx >= ARRAY_SIZE(hw_driverids) || hw_driverids[idx] == 0)
146 if (itv->i2c_clients[i] == NULL) { 167 return -1;
147 itv->i2c_clients[i] = client; 168 id = hw_driverids[idx];
148 break; 169 memset(&info, 0, sizeof(info));
149 } 170 strcpy(info.driver_name, hw_drivernames[idx]);
150 } 171 info.addr = hw_addrs[idx];
172 for (i = 0; itv->i2c_clients[i] && i < I2C_CLIENTS_MAX; i++) {}
173
151 if (i == I2C_CLIENTS_MAX) { 174 if (i == I2C_CLIENTS_MAX) {
152 IVTV_ERR("Insufficient room for new I2C client\n"); 175 IVTV_ERR("insufficient room for new I2C client!\n");
176 return -ENOMEM;
153 } 177 }
178
179 if (id != I2C_DRIVERID_TUNER) {
180 c = i2c_new_device(&itv->i2c_adap, &info);
181 if (c->driver == NULL)
182 i2c_unregister_device(c);
183 else
184 itv->i2c_clients[i] = c;
185 return itv->i2c_clients[i] ? 0 : -ENODEV;
186 }
187
188 /* special tuner handling */
189 c = i2c_new_probed_device(&itv->i2c_adap, &info, itv->card_i2c->radio);
190 if (c && c->driver == NULL)
191 i2c_unregister_device(c);
192 else if (c)
193 itv->i2c_clients[i++] = c;
194 c = i2c_new_probed_device(&itv->i2c_adap, &info, itv->card_i2c->demod);
195 if (c && c->driver == NULL)
196 i2c_unregister_device(c);
197 else if (c)
198 itv->i2c_clients[i++] = c;
199 c = i2c_new_probed_device(&itv->i2c_adap, &info, itv->card_i2c->tv);
200 if (c && c->driver == NULL)
201 i2c_unregister_device(c);
202 else if (c)
203 itv->i2c_clients[i++] = c;
204 return 0;
205}
206
207static int attach_inform(struct i2c_client *client)
208{
154 return 0; 209 return 0;
155} 210}
156 211
@@ -478,9 +533,6 @@ static struct i2c_adapter ivtv_i2c_adap_hw_template = {
478 .client_register = attach_inform, 533 .client_register = attach_inform,
479 .client_unregister = detach_inform, 534 .client_unregister = detach_inform,
480 .owner = THIS_MODULE, 535 .owner = THIS_MODULE,
481#ifdef I2C_ADAP_CLASS_TV_ANALOG
482 .class = I2C_ADAP_CLASS_TV_ANALOG,
483#endif
484}; 536};
485 537
486static void ivtv_setscl_old(void *data, int state) 538static void ivtv_setscl_old(void *data, int state)
@@ -534,9 +586,6 @@ static struct i2c_adapter ivtv_i2c_adap_template = {
534 .client_register = attach_inform, 586 .client_register = attach_inform,
535 .client_unregister = detach_inform, 587 .client_unregister = detach_inform,
536 .owner = THIS_MODULE, 588 .owner = THIS_MODULE,
537#ifdef I2C_ADAP_CLASS_TV_ANALOG
538 .class = I2C_ADAP_CLASS_TV_ANALOG,
539#endif
540}; 589};
541 590
542static const struct i2c_algo_bit_data ivtv_i2c_algo_template = { 591static const struct i2c_algo_bit_data ivtv_i2c_algo_template = {
@@ -561,12 +610,9 @@ int ivtv_call_i2c_client(struct ivtv *itv, int addr, unsigned int cmd, void *arg
561 IVTV_DEBUG_I2C("call_i2c_client addr=%02x\n", addr); 610 IVTV_DEBUG_I2C("call_i2c_client addr=%02x\n", addr);
562 for (i = 0; i < I2C_CLIENTS_MAX; i++) { 611 for (i = 0; i < I2C_CLIENTS_MAX; i++) {
563 client = itv->i2c_clients[i]; 612 client = itv->i2c_clients[i];
564 if (client == NULL) { 613 if (client == NULL || client->driver == NULL ||
565 continue; 614 client->driver->command == NULL)
566 }
567 if (client->driver->command == NULL) {
568 continue; 615 continue;
569 }
570 if (addr == client->addr) { 616 if (addr == client->addr) {
571 retval = client->driver->command(client, cmd, arg); 617 retval = client->driver->command(client, cmd, arg);
572 return retval; 618 return retval;
@@ -587,7 +633,7 @@ static int ivtv_i2c_id_addr(struct ivtv *itv, u32 id)
587 633
588 for (i = 0; i < I2C_CLIENTS_MAX; i++) { 634 for (i = 0; i < I2C_CLIENTS_MAX; i++) {
589 client = itv->i2c_clients[i]; 635 client = itv->i2c_clients[i];
590 if (client == NULL) 636 if (client == NULL || client->driver == NULL)
591 continue; 637 continue;
592 if (id == client->driver->id) { 638 if (id == client->driver->id) {
593 retval = client->addr; 639 retval = client->addr;
@@ -713,6 +759,16 @@ int init_ivtv_i2c(struct ivtv *itv)
713{ 759{
714 IVTV_DEBUG_I2C("i2c init\n"); 760 IVTV_DEBUG_I2C("i2c init\n");
715 761
762 /* Sanity checks for the I2C hardware arrays. They must be the
763 * same size and GPIO must be the last entry.
764 */
765 if (ARRAY_SIZE(hw_driverids) != ARRAY_SIZE(hw_addrs) ||
766 ARRAY_SIZE(hw_drivernames) != ARRAY_SIZE(hw_addrs) ||
767 IVTV_HW_GPIO != (1 << (ARRAY_SIZE(hw_addrs) - 1)) ||
768 hw_driverids[ARRAY_SIZE(hw_addrs) - 1]) {
769 IVTV_ERR("Mismatched I2C hardware arrays\n");
770 return -ENODEV;
771 }
716 if (itv->options.newi2c > 0) { 772 if (itv->options.newi2c > 0) {
717 memcpy(&itv->i2c_adap, &ivtv_i2c_adap_hw_template, 773 memcpy(&itv->i2c_adap, &ivtv_i2c_adap_hw_template,
718 sizeof(struct i2c_adapter)); 774 sizeof(struct i2c_adapter));
diff --git a/drivers/media/video/ivtv/ivtv-i2c.h b/drivers/media/video/ivtv/ivtv-i2c.h
index 987042c09b64..022978cf533d 100644
--- a/drivers/media/video/ivtv/ivtv-i2c.h
+++ b/drivers/media/video/ivtv/ivtv-i2c.h
@@ -33,6 +33,7 @@ int ivtv_i2c_hw(struct ivtv *itv, u32 hw, unsigned int cmd, void *arg);
33int ivtv_i2c_id(struct ivtv *itv, u32 id, unsigned int cmd, void *arg); 33int ivtv_i2c_id(struct ivtv *itv, u32 id, unsigned int cmd, void *arg);
34int ivtv_call_i2c_client(struct ivtv *itv, int addr, unsigned int cmd, void *arg); 34int ivtv_call_i2c_client(struct ivtv *itv, int addr, unsigned int cmd, void *arg);
35void ivtv_call_i2c_clients(struct ivtv *itv, unsigned int cmd, void *arg); 35void ivtv_call_i2c_clients(struct ivtv *itv, unsigned int cmd, void *arg);
36int ivtv_i2c_register(struct ivtv *itv, unsigned idx);
36 37
37/* init + register i2c algo-bit adapter */ 38/* init + register i2c algo-bit adapter */
38int init_ivtv_i2c(struct ivtv *itv); 39int init_ivtv_i2c(struct ivtv *itv);