aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/ivtv/ivtv-driver.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2007-12-07 19:01:15 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:03:24 -0500
commitd9009201207c4bdce9b95a0bd903b3f087e8eda1 (patch)
tree86801fb674777c7a4693622363ac18a7a7896ec1 /drivers/media/video/ivtv/ivtv-driver.c
parent9d1a16a4fc39bd908d85e0b7ce167048200d2d2b (diff)
V4L/DVB (6765): ivtv: convert to bus-based i2c API
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/ivtv/ivtv-driver.c')
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.c86
1 files changed, 40 insertions, 46 deletions
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;