aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-core.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
index afb53b49b31a..72d615a87c36 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
@@ -948,22 +948,32 @@ static struct i2c_adapter pvr2_i2c_adap_template = {
948 .client_unregister = pvr2_i2c_detach_inform, 948 .client_unregister = pvr2_i2c_detach_inform,
949}; 949};
950 950
951static void do_i2c_scan(struct pvr2_hdw *hdw) 951
952/* Return true if device exists at given address */
953static int do_i2c_probe(struct pvr2_hdw *hdw, int addr)
952{ 954{
953 struct i2c_msg msg[1]; 955 struct i2c_msg msg[1];
954 int i,rc; 956 int rc;
955 msg[0].addr = 0; 957 msg[0].addr = 0;
956 msg[0].flags = I2C_M_RD; 958 msg[0].flags = I2C_M_RD;
957 msg[0].len = 0; 959 msg[0].len = 0;
958 msg[0].buf = NULL; 960 msg[0].buf = NULL;
959 printk("%s: i2c scan beginning\n",hdw->name); 961 msg[0].addr = addr;
962 rc = i2c_transfer(&hdw->i2c_adap, msg, ARRAY_SIZE(msg));
963 return rc == 1;
964}
965
966static void do_i2c_scan(struct pvr2_hdw *hdw)
967{
968 int i;
969 printk(KERN_INFO "%s: i2c scan beginning\n", hdw->name);
960 for (i = 0; i < 128; i++) { 970 for (i = 0; i < 128; i++) {
961 msg[0].addr = i; 971 if (do_i2c_probe(hdw, i)) {
962 rc = i2c_transfer(&hdw->i2c_adap,msg, ARRAY_SIZE(msg)); 972 printk(KERN_INFO "%s: i2c scan: found device @ 0x%x\n",
963 if (rc != 1) continue; 973 hdw->name, i);
964 printk("%s: i2c scan: found device @ 0x%x\n",hdw->name,i); 974 }
965 } 975 }
966 printk("%s: i2c scan done.\n",hdw->name); 976 printk(KERN_INFO "%s: i2c scan done.\n", hdw->name);
967} 977}
968 978
969void pvr2_i2c_core_init(struct pvr2_hdw *hdw) 979void pvr2_i2c_core_init(struct pvr2_hdw *hdw)
@@ -1008,6 +1018,16 @@ void pvr2_i2c_core_init(struct pvr2_hdw *hdw)
1008 mutex_init(&hdw->i2c_list_lock); 1018 mutex_init(&hdw->i2c_list_lock);
1009 hdw->i2c_linked = !0; 1019 hdw->i2c_linked = !0;
1010 i2c_add_adapter(&hdw->i2c_adap); 1020 i2c_add_adapter(&hdw->i2c_adap);
1021 if (hdw->i2c_func[0x18] == i2c_24xxx_ir) {
1022 /* Probe for a different type of IR receiver on this
1023 device. If present, disable the emulated IR receiver. */
1024 if (do_i2c_probe(hdw, 0x71)) {
1025 pvr2_trace(PVR2_TRACE_INFO,
1026 "Device has newer IR hardware;"
1027 " disabling unneeded virtual IR device");
1028 hdw->i2c_func[0x18] = NULL;
1029 }
1030 }
1011 if (i2c_scan) do_i2c_scan(hdw); 1031 if (i2c_scan) do_i2c_scan(hdw);
1012} 1032}
1013 1033