diff options
Diffstat (limited to 'linux/drivers/media/video')
-rw-r--r-- | linux/drivers/media/video/bt8xx/bttv-i2c.c | 2 | ||||
-rw-r--r-- | linux/drivers/media/video/cx231xx/cx231xx-cards.c | 13 | ||||
-rw-r--r-- | linux/drivers/media/video/cx231xx/cx231xx-i2c.c | 2 | ||||
-rw-r--r-- | linux/drivers/media/video/cx231xx/cx231xx.h | 4 | ||||
-rw-r--r-- | linux/drivers/media/video/cx23885/cx23885-i2c.c | 2 | ||||
-rw-r--r-- | linux/drivers/media/video/cx88/cx88-i2c.c | 2 | ||||
-rw-r--r-- | linux/drivers/media/video/em28xx/em28xx-cards.c | 34 | ||||
-rw-r--r-- | linux/drivers/media/video/em28xx/em28xx-i2c.c | 2 | ||||
-rw-r--r-- | linux/drivers/media/video/em28xx/em28xx-input.c | 12 | ||||
-rw-r--r-- | linux/drivers/media/video/em28xx/em28xx.h | 2 | ||||
-rw-r--r-- | linux/drivers/media/video/ir-kbd-i2c.c | 231 | ||||
-rw-r--r-- | linux/drivers/media/video/ivtv/ivtv-i2c.c | 4 | ||||
-rw-r--r-- | linux/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c | 2 | ||||
-rw-r--r-- | linux/drivers/media/video/saa7134/saa7134-i2c.c | 2 | ||||
-rw-r--r-- | linux/drivers/media/video/saa7134/saa7134-input.c | 99 | ||||
-rw-r--r-- | linux/drivers/media/video/saa7134/saa7134.h | 4 | ||||
-rw-r--r-- | linux/drivers/media/video/v4l2-device.c | 2 |
17 files changed, 416 insertions, 3 deletions
diff --git a/linux/drivers/media/video/bt8xx/bttv-i2c.c b/linux/drivers/media/video/bt8xx/bttv-i2c.c index 31f2f07d9..4febaf881 100644 --- a/linux/drivers/media/video/bt8xx/bttv-i2c.c +++ b/linux/drivers/media/video/bt8xx/bttv-i2c.c @@ -405,6 +405,7 @@ int __devinit init_bttv_i2c(struct bttv *btv) } if (0 == btv->i2c_rc && i2c_scan) do_i2c_scan(btv->c.v4l2_dev.name, &btv->i2c_client); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) /* Instantiate the IR receiver device, if present */ if (0 == btv->i2c_rc) { @@ -426,6 +427,7 @@ int __devinit init_bttv_i2c(struct bttv *btv) strlcpy(info.type, "ir_video", I2C_NAME_SIZE); i2c_new_probed_device(&btv->c.i2c_adap, &info, addr_list); } +#endif return btv->i2c_rc; } diff --git a/linux/drivers/media/video/cx231xx/cx231xx-cards.c b/linux/drivers/media/video/cx231xx/cx231xx-cards.c index 68f92da9e..f388262bd 100644 --- a/linux/drivers/media/video/cx231xx/cx231xx-cards.c +++ b/linux/drivers/media/video/cx231xx/cx231xx-cards.c @@ -282,12 +282,25 @@ static void cx231xx_config_tuner(struct cx231xx *dev) } /* ----------------------------------------------------------------------- */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) +void cx231xx_set_ir(struct cx231xx *dev, struct IR_i2c *ir) +#else void cx231xx_register_i2c_ir(struct cx231xx *dev) +#endif { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + if (disable_ir) { + ir->get_key = NULL; +#else if (disable_ir) +#endif return; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + } +#else /* REVISIT: instantiate IR device */ +#endif /* detect & configure */ switch (dev->model) { diff --git a/linux/drivers/media/video/cx231xx/cx231xx-i2c.c b/linux/drivers/media/video/cx231xx/cx231xx-i2c.c index e71005c59..4525fab35 100644 --- a/linux/drivers/media/video/cx231xx/cx231xx-i2c.c +++ b/linux/drivers/media/video/cx231xx/cx231xx-i2c.c @@ -511,9 +511,11 @@ int cx231xx_i2c_register(struct cx231xx_i2c *bus) if (0 == bus->i2c_rc) { if (i2c_scan) cx231xx_do_i2c_scan(dev, &bus->i2c_client); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) /* Instantiate the IR receiver device, if present */ cx231xx_register_i2c_ir(dev); +#endif } else cx231xx_warn("%s: i2c bus %d register FAILED\n", dev->name, bus->nr); diff --git a/linux/drivers/media/video/cx231xx/cx231xx.h b/linux/drivers/media/video/cx231xx/cx231xx.h index d3c05186e..c436f2b0d 100644 --- a/linux/drivers/media/video/cx231xx/cx231xx.h +++ b/linux/drivers/media/video/cx231xx/cx231xx.h @@ -747,7 +747,11 @@ extern void cx231xx_card_setup(struct cx231xx *dev); extern struct cx231xx_board cx231xx_boards[]; extern struct usb_device_id cx231xx_id_table[]; extern const unsigned int cx231xx_bcount; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) +void cx231xx_set_ir(struct cx231xx *dev, struct IR_i2c *ir); +#else void cx231xx_register_i2c_ir(struct cx231xx *dev); +#endif int cx231xx_tuner_callback(void *ptr, int component, int command, int arg); /* Provided by cx231xx-input.c */ diff --git a/linux/drivers/media/video/cx23885/cx23885-i2c.c b/linux/drivers/media/video/cx23885/cx23885-i2c.c index 4369470a3..2e3f3d37c 100644 --- a/linux/drivers/media/video/cx23885/cx23885-i2c.c +++ b/linux/drivers/media/video/cx23885/cx23885-i2c.c @@ -364,6 +364,7 @@ int cx23885_i2c_register(struct cx23885_i2c *bus) printk(KERN_WARNING "%s: i2c bus %d register FAILED\n", dev->name, bus->nr); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) /* Instantiate the IR receiver device, if present */ if (0 == bus->i2c_rc) { struct i2c_board_info info; @@ -376,6 +377,7 @@ int cx23885_i2c_register(struct cx23885_i2c *bus) i2c_new_probed_device(&bus->i2c_adap, &info, addr_list); } +#endif return bus->i2c_rc; } diff --git a/linux/drivers/media/video/cx88/cx88-i2c.c b/linux/drivers/media/video/cx88/cx88-i2c.c index dbd629511..b5833aa29 100644 --- a/linux/drivers/media/video/cx88/cx88-i2c.c +++ b/linux/drivers/media/video/cx88/cx88-i2c.c @@ -186,6 +186,7 @@ int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci) do_i2c_scan(core->name,&core->i2c_client); } else printk("%s: i2c register FAILED\n", core->name); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) /* Instantiate the IR receiver device, if present */ if (0 == core->i2c_rc) { @@ -199,6 +200,7 @@ int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci) strlcpy(info.type, "ir_video", I2C_NAME_SIZE); i2c_new_probed_device(&core->i2c_adap, &info, addr_list); } +#endif return core->i2c_rc; } diff --git a/linux/drivers/media/video/em28xx/em28xx-cards.c b/linux/drivers/media/video/em28xx/em28xx-cards.c index c765d769b..384aead65 100644 --- a/linux/drivers/media/video/em28xx/em28xx-cards.c +++ b/linux/drivers/media/video/em28xx/em28xx-cards.c @@ -1981,8 +1981,18 @@ static int em28xx_hint_board(struct em28xx *dev) } /* ----------------------------------------------------------------------- */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) +void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir) +#else void em28xx_register_i2c_ir(struct em28xx *dev) +#endif { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + if (disable_ir) { + ir->get_key = NULL; + return ; + } +#else struct i2c_board_info info; struct IR_i2c_init_data init_data; const unsigned short addr_list[] = { @@ -1995,6 +2005,7 @@ void em28xx_register_i2c_ir(struct em28xx *dev) memset(&info, 0, sizeof(struct i2c_board_info)); memset(&init_data, 0, sizeof(struct IR_i2c_init_data)); strlcpy(info.type, "ir_video", I2C_NAME_SIZE); +#endif /* detect & configure */ switch (dev->model) { @@ -2004,19 +2015,40 @@ void em28xx_register_i2c_ir(struct em28xx *dev) break; case (EM2800_BOARD_TERRATEC_CINERGY_200): case (EM2820_BOARD_TERRATEC_CINERGY_250): +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + ir->ir_codes = ir_codes_em_terratec; + ir->get_key = em28xx_get_key_terratec; + snprintf(ir->name, sizeof(ir->name), + "i2c IR (EM28XX Terratec)"); +#else init_data.ir_codes = ir_codes_em_terratec; init_data.get_key = em28xx_get_key_terratec; init_data.name = "i2c IR (EM28XX Terratec)"; +#endif break; case (EM2820_BOARD_PINNACLE_USB_2): +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + ir->ir_codes = ir_codes_pinnacle_grey; + ir->get_key = em28xx_get_key_pinnacle_usb_grey; + snprintf(ir->name, sizeof(ir->name), + "i2c IR (EM28XX Pinnacle PCTV)"); +#else init_data.ir_codes = ir_codes_pinnacle_grey; init_data.get_key = em28xx_get_key_pinnacle_usb_grey; init_data.name = "i2c IR (EM28XX Pinnacle PCTV)"; +#endif break; case (EM2820_BOARD_HAUPPAUGE_WINTV_USB_2): +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + ir->ir_codes = ir_codes_hauppauge_new; + ir->get_key = em28xx_get_key_em_haup; + snprintf(ir->name, sizeof(ir->name), + "i2c IR (EM2840 Hauppauge)"); +#else init_data.ir_codes = ir_codes_hauppauge_new; init_data.get_key = em28xx_get_key_em_haup; init_data.name = "i2c IR (EM2840 Hauppauge)"; +#endif break; case (EM2820_BOARD_MSI_VOX_USB_2): break; @@ -2027,10 +2059,12 @@ void em28xx_register_i2c_ir(struct em28xx *dev) case (EM2800_BOARD_GRABBEEX_USB2800): break; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) if (init_data.name) info.platform_data = &init_data; i2c_new_probed_device(&dev->i2c_adap, &info, addr_list); +#endif } void em28xx_card_setup(struct em28xx *dev) diff --git a/linux/drivers/media/video/em28xx/em28xx-i2c.c b/linux/drivers/media/video/em28xx/em28xx-i2c.c index fd6be0e2c..1cdd88361 100644 --- a/linux/drivers/media/video/em28xx/em28xx-i2c.c +++ b/linux/drivers/media/video/em28xx/em28xx-i2c.c @@ -559,9 +559,11 @@ int em28xx_i2c_register(struct em28xx *dev) if (i2c_scan) em28xx_do_i2c_scan(dev); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) /* Instantiate the IR receiver device, if present */ em28xx_register_i2c_ir(dev); +#endif return 0; } diff --git a/linux/drivers/media/video/em28xx/em28xx-input.c b/linux/drivers/media/video/em28xx/em28xx-input.c index bfe2cb8f6..df58b4c5b 100644 --- a/linux/drivers/media/video/em28xx/em28xx-input.c +++ b/linux/drivers/media/video/em28xx/em28xx-input.c @@ -86,7 +86,11 @@ int em28xx_get_key_terratec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) unsigned char b; /* poll IR chip */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + if (1 != i2c_master_recv(&ir->c, &b, 1)) { +#else if (1 != i2c_master_recv(ir->c, &b, 1)) { +#endif i2cdprintk("read error\n"); return -EIO; } @@ -115,7 +119,11 @@ int em28xx_get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) unsigned char code; /* poll IR chip */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + if (2 != i2c_master_recv(&ir->c, buf, 2)) +#else if (2 != i2c_master_recv(ir->c, buf, 2)) +#endif return -EIO; /* Does eliminate repeated parity code */ @@ -153,7 +161,11 @@ int em28xx_get_key_pinnacle_usb_grey(struct IR_i2c *ir, u32 *ir_key, /* poll IR chip */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + if (3 != i2c_master_recv(&ir->c, buf, 3)) { +#else if (3 != i2c_master_recv(ir->c, buf, 3)) { +#endif i2cdprintk("read error\n"); return -EIO; } diff --git a/linux/drivers/media/video/em28xx/em28xx.h b/linux/drivers/media/video/em28xx/em28xx.h index e4ddc50c5..1c61b98e6 100644 --- a/linux/drivers/media/video/em28xx/em28xx.h +++ b/linux/drivers/media/video/em28xx/em28xx.h @@ -105,7 +105,7 @@ #define EM2820_BOARD_IODATA_GVMVP_SZ 65 #define EM2880_BOARD_EMPIRE_DUAL_TV 66 #define EM2860_BOARD_TERRATEC_GRABBY 67 -#define EM2860_BOARD_TERRATEC_AV350 68 +#define EM2860_BOARD_TERRATEC_AV350 68 /* Limits minimum and default number of buffers */ #define EM28XX_MIN_BUF 4 diff --git a/linux/drivers/media/video/ir-kbd-i2c.c b/linux/drivers/media/video/ir-kbd-i2c.c index 0a18d07c7..cdf369129 100644 --- a/linux/drivers/media/video/ir-kbd-i2c.c +++ b/linux/drivers/media/video/ir-kbd-i2c.c @@ -75,7 +75,11 @@ static int get_key_haup_common(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw, int start, range, toggle, dev, code, ircode; /* poll IR chip */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + if (size != i2c_master_recv(&ir->c,buf,size)) +#else if (size != i2c_master_recv(ir->c, buf, size)) +#endif return -EIO; /* split rc5 data block ... */ @@ -138,7 +142,11 @@ static int get_key_pixelview(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) unsigned char b; /* poll IR chip */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + if (1 != i2c_master_recv(&ir->c,&b,1)) { +#else if (1 != i2c_master_recv(ir->c, &b, 1)) { +#endif dprintk(1,"read error\n"); return -EIO; } @@ -152,7 +160,11 @@ static int get_key_pv951(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) unsigned char b; /* poll IR chip */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + if (1 != i2c_master_recv(&ir->c,&b,1)) { +#else if (1 != i2c_master_recv(ir->c, &b, 1)) { +#endif dprintk(1,"read error\n"); return -EIO; } @@ -172,7 +184,11 @@ static int get_key_fusionhdtv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) unsigned char buf[4]; /* poll IR chip */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + if (4 != i2c_master_recv(&ir->c,buf,4)) { +#else if (4 != i2c_master_recv(ir->c, buf, 4)) { +#endif dprintk(1,"read error\n"); return -EIO; } @@ -196,7 +212,11 @@ static int get_key_knc1(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) unsigned char b; /* poll IR chip */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + if (1 != i2c_master_recv(&ir->c,&b,1)) { +#else if (1 != i2c_master_recv(ir->c, &b, 1)) { +#endif dprintk(1,"read error\n"); return -EIO; } @@ -223,12 +243,24 @@ static int get_key_avermedia_cardbus(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) { unsigned char subaddr, key, keygroup; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + struct i2c_msg msg[] = { { .addr = ir->c.addr, .flags = 0, +#else struct i2c_msg msg[] = { { .addr = ir->c->addr, .flags = 0, +#endif .buf = &subaddr, .len = 1}, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + { .addr = ir->c.addr, .flags = I2C_M_RD, +#else { .addr = ir->c->addr, .flags = I2C_M_RD, +#endif .buf = &key, .len = 1} }; subaddr = 0x0d; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + if (2 != i2c_transfer(ir->c.adapter, msg, 2)) { +#else if (2 != i2c_transfer(ir->c->adapter, msg, 2)) { +#endif dprintk(1, "read error\n"); return -EIO; } @@ -238,7 +270,11 @@ static int get_key_avermedia_cardbus(struct IR_i2c *ir, subaddr = 0x0b; msg[1].buf = &keygroup; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + if (2 != i2c_transfer(ir->c.adapter, msg, 2)) { +#else if (2 != i2c_transfer(ir->c->adapter, msg, 2)) { +#endif dprintk(1, "read error\n"); return -EIO; } @@ -295,7 +331,11 @@ static void ir_work(struct work_struct *work) /* MSI TV@nywhere Plus requires more frequent polling otherwise it will miss some keypresses */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + if (ir->c.adapter->id == I2C_HW_SAA7134 && ir->c.addr == 0x30) +#else if (ir->c->adapter->id == I2C_HW_SAA7134 && ir->c->addr == 0x30) +#endif polling_interval = 50; ir_key_poll(ir); @@ -304,15 +344,42 @@ static void ir_work(struct work_struct *work) /* ----------------------------------------------------------------------- */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) +static int ir_attach(struct i2c_adapter *adap, int addr, + unsigned short flags, int kind); +static int ir_detach(struct i2c_client *client); +static int ir_probe(struct i2c_adapter *adap); + +static struct i2c_driver driver = { + .driver = { + .name = "ir-kbd-i2c", + }, + .id = I2C_DRIVERID_INFRARED, + .attach_adapter = ir_probe, + .detach_client = ir_detach, +}; + +static struct i2c_client client = +{ + .name = "unset", + .driver = &driver + }; + +static int ir_attach(struct i2c_adapter *adap, int addr, + unsigned short flags, int kind) +#else static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) +#endif { IR_KEYTAB_TYPE *ir_codes = NULL; const char *name = NULL; int ir_type; struct IR_i2c *ir; struct input_dev *input_dev; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) struct i2c_adapter *adap = client->adapter; unsigned short addr = client->addr; +#endif int err; ir = kzalloc(sizeof(struct IR_i2c),GFP_KERNEL); @@ -324,7 +391,16 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) ir->c = client; ir->input = input_dev; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + + ir->c.adapter = adap; + ir->c.addr = addr; + snprintf(ir->c.name, sizeof(ir->c.name), "ir-kbd"); + + i2c_set_clientdata(&ir->c, ir); +#else i2c_set_clientdata(client, ir); +#endif switch(addr) { case 0x64: @@ -394,6 +470,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) goto err_out_free; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) /* Let the caller override settings */ if (client->dev.platform_data) { const struct IR_i2c_init_data *init_data = @@ -411,14 +488,41 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) err = -ENODEV; goto err_out_free; } +#endif /* Sets name */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + snprintf(ir->c.name, sizeof(ir->c.name), "i2c IR (%s)", name); +#else snprintf(ir->name, sizeof(ir->name), "i2c IR (%s)", name); +#endif ir->ir_codes = ir_codes; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + /* register i2c device + * At device register, IR codes may be changed to be + * board dependent. + */ + err = i2c_attach_client(&ir->c); + if (err) + goto err_out_free; + + /* If IR not supported or disabled, unregisters driver */ + if (ir->get_key == NULL) { + err = -ENODEV; + goto err_out_detach; + } + + /* Phys addr can only be set after attaching (for ir->c.dev) */ +#endif snprintf(ir->phys, sizeof(ir->phys), "%s/%s/ir0", +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + dev_name(&ir->c.adapter->dev), + dev_name(&ir->c.dev)); +#else dev_name(&adap->dev), dev_name(&client->dev)); +#endif /* init + register input device */ ir_input_init(input_dev, &ir->ir, ir_type, ir->ir_codes); @@ -428,7 +532,11 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) err = input_register_device(ir->input); if (err) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + goto err_out_detach; +#else goto err_out_free; +#endif printk(DEVNAME ": %s detected at %s [%s]\n", ir->input->name, ir->input->phys, adap->name); @@ -443,27 +551,149 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) return 0; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + err_out_detach: + i2c_detach_client(&ir->c); +#endif err_out_free: input_free_device(input_dev); kfree(ir); return err; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) +static int ir_detach(struct i2c_client *client) +#else static int ir_remove(struct i2c_client *client) +#endif { struct IR_i2c *ir = i2c_get_clientdata(client); /* kill outstanding polls */ cancel_delayed_work_sync(&ir->work); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + /* unregister devices */ +#else /* unregister device */ +#endif input_unregister_device(ir->input); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + i2c_detach_client(&ir->c); +#endif /* free memory */ kfree(ir); return 0; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) +static int ir_probe(struct i2c_adapter *adap) +{ + + /* The external IR receiver is at i2c address 0x34 (0x35 for + reads). Future Hauppauge cards will have an internal + receiver at 0x30 (0x31 for reads). In theory, both can be + fitted, and Hauppauge suggest an external overrides an + internal. + + That's why we probe 0x1a (~0x34) first. CB + */ + + static const int probe_bttv[] = { 0x1a, 0x18, 0x4b, 0x64, 0x30, -1}; + static const int probe_saa7134[] = { 0x7a, 0x47, 0x71, 0x2d, -1 }; + static const int probe_em28XX[] = { 0x30, 0x47, -1 }; + static const int probe_cx88[] = { 0x18, 0x6b, 0x71, -1 }; + static const int probe_cx23885[] = { 0x6b, -1 }; + const int *probe; + struct i2c_msg msg = { + .flags = I2C_M_RD, + .len = 0, + .buf = NULL, + }; + int i, rc; + + switch (adap->id) { + case I2C_HW_B_BT848: + probe = probe_bttv; + break; + case I2C_HW_B_CX2341X: + probe = probe_bttv; + break; + case I2C_HW_SAA7134: + probe = probe_saa7134; + break; + case I2C_HW_B_EM28XX: + probe = probe_em28XX; + break; + case I2C_HW_B_CX2388x: + probe = probe_cx88; + break; + case I2C_HW_B_CX23885: + probe = probe_cx23885; + break; + default: + return 0; + } + + for (i = 0; -1 != probe[i]; i++) { + msg.addr = probe[i]; + rc = i2c_transfer(adap, &msg, 1); + dprintk(1,"probe 0x%02x @ %s: %s\n", + probe[i], adap->name, + (1 == rc) ? "yes" : "no"); + if (1 == rc) { + ir_attach(adap, probe[i], 0, 0); + return 0; + } + } + + /* Special case for MSI TV@nywhere Plus remote */ + if (adap->id == I2C_HW_SAA7134) { + u8 temp; + + /* MSI TV@nywhere Plus controller doesn't seem to + respond to probes unless we read something from + an existing device. Weird... */ + + msg.addr = 0x50; + rc = i2c_transfer(adap, &msg, 1); + dprintk(1, "probe 0x%02x @ %s: %s\n", + msg.addr, adap->name, + (1 == rc) ? "yes" : "no"); + + /* Now do the probe. The controller does not respond + to 0-byte reads, so we use a 1-byte read instead. */ + msg.addr = 0x30; + msg.len = 1; + msg.buf = &temp; + rc = i2c_transfer(adap, &msg, 1); + dprintk(1, "probe 0x%02x @ %s: %s\n", + msg.addr, adap->name, + (1 == rc) ? "yes" : "no"); + if (1 == rc) + ir_attach(adap, msg.addr, 0, 0); + } + + /* Special case for AVerMedia Cardbus remote */ + if (adap->id == I2C_HW_SAA7134) { + unsigned char subaddr, data; + struct i2c_msg msg[] = { { .addr = 0x40, .flags = 0, + .buf = &subaddr, .len = 1}, + { .addr = 0x40, .flags = I2C_M_RD, + .buf = &data, .len = 1} }; + subaddr = 0x0d; + rc = i2c_transfer(adap, msg, 2); + dprintk(1, "probe 0x%02x/0x%02x @ %s: %s\n", + msg[0].addr, subaddr, adap->name, + (2 == rc) ? "yes" : "no"); + if (2 == rc) + ir_attach(adap, msg[0].addr, 0, 0); + } + + return 0; +} +#else static const struct i2c_device_id ir_kbd_id[] = { /* Generic entry for any IR receiver */ { "ir_video", 0 }, @@ -479,6 +709,7 @@ static struct i2c_driver driver = { .remove = ir_remove, .id_table = ir_kbd_id, }; +#endif /* ----------------------------------------------------------------------- */ diff --git a/linux/drivers/media/video/ivtv/ivtv-i2c.c b/linux/drivers/media/video/ivtv/ivtv-i2c.c index 0d18c2220..eed4d2364 100644 --- a/linux/drivers/media/video/ivtv/ivtv-i2c.c +++ b/linux/drivers/media/video/ivtv/ivtv-i2c.c @@ -639,7 +639,7 @@ int init_ivtv_i2c(struct ivtv *itv) retval = i2c_add_adapter(&itv->i2c_adap); else retval = i2c_bit_add_bus(&itv->i2c_adap); - +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) /* Instantiate the IR receiver device, if present */ if (retval == 0) { struct i2c_board_info info; @@ -665,7 +665,7 @@ int init_ivtv_i2c(struct ivtv *itv) strlcpy(info.type, "ir_video", I2C_NAME_SIZE); i2c_new_probed_device(&itv->i2c_adap, &info, addr_list); } - +#endif return retval; } diff --git a/linux/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c b/linux/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c index 694e51f58..24644fc96 100644 --- a/linux/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c +++ b/linux/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c @@ -651,6 +651,7 @@ static void do_i2c_scan(struct pvr2_hdw *hdw) static void pvr2_i2c_register_ir(struct pvr2_hdw *hdw) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) struct i2c_board_info info; unsigned char addr = 0; if (pvr2_disable_ir_video) { @@ -672,6 +673,7 @@ static void pvr2_i2c_register_ir(struct pvr2_hdw *hdw) strlcpy(info.type, "ir_video", I2C_NAME_SIZE); info.addr = addr; i2c_new_device(&hdw->i2c_adap, &info); +#endif } void pvr2_i2c_core_init(struct pvr2_hdw *hdw) diff --git a/linux/drivers/media/video/saa7134/saa7134-i2c.c b/linux/drivers/media/video/saa7134/saa7134-i2c.c index a8185693f..f6cf7c1be 100644 --- a/linux/drivers/media/video/saa7134/saa7134-i2c.c +++ b/linux/drivers/media/video/saa7134/saa7134-i2c.c @@ -416,9 +416,11 @@ int saa7134_i2c_register(struct saa7134_dev *dev) saa7134_i2c_eeprom(dev,dev->eedata,sizeof(dev->eedata)); if (i2c_scan) do_i2c_scan(dev->name,&dev->i2c_client); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) /* Instantiate the IR receiver device, if present */ saa7134_probe_i2c_ir(dev); +#endif return 0; } diff --git a/linux/drivers/media/video/saa7134/saa7134-input.c b/linux/drivers/media/video/saa7134/saa7134-input.c index 36913d22b..b54bfd645 100644 --- a/linux/drivers/media/video/saa7134/saa7134-input.c +++ b/linux/drivers/media/video/saa7134/saa7134-input.c @@ -59,8 +59,13 @@ MODULE_PARM_DESC(disable_other_ir, "disable full codes of " #define dprintk(fmt, arg...) if (ir_debug) \ printk(KERN_DEBUG "%s/ir: " fmt, dev->name , ## arg) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) +#define i2cdprintk(fmt, arg...) if (ir_debug) \ + printk(KERN_DEBUG "%s/ir: " fmt, ir->c.name , ## arg) +#else #define i2cdprintk(fmt, arg...) if (ir_debug) \ printk(KERN_DEBUG "%s/ir: " fmt, ir->name , ## arg) +#endif /* Helper functions for RC5 and NEC decoding at GPIO16 or GPIO18 */ static int saa7134_rc5_irq(struct saa7134_dev *dev); @@ -134,10 +139,18 @@ static int get_key_msi_tvanywhere_plus(struct IR_i2c *ir, u32 *ir_key, int gpio; /* <dev> is needed to access GPIO. Used by the saa_readl macro. */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + struct saa7134_dev *dev = ir->c.adapter->algo_data; +#else struct saa7134_dev *dev = ir->c->adapter->algo_data; +#endif if (dev == NULL) { dprintk("get_key_msi_tvanywhere_plus: " +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + "gir->c.adapter->algo_data is NULL!\n"); +#else "gir->c->adapter->algo_data is NULL!\n"); +#endif return -EIO; } @@ -156,7 +169,11 @@ static int get_key_msi_tvanywhere_plus(struct IR_i2c *ir, u32 *ir_key, /* GPIO says there is a button press. Get it. */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + if (1 != i2c_master_recv(&ir->c, &b, 1)) { +#else if (1 != i2c_master_recv(ir->c, &b, 1)) { +#endif i2cdprintk("read error\n"); return -EIO; } @@ -179,7 +196,11 @@ static int get_key_purpletv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) unsigned char b; /* poll IR chip */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + if (1 != i2c_master_recv(&ir->c,&b,1)) { +#else if (1 != i2c_master_recv(ir->c, &b, 1)) { +#endif i2cdprintk("read error\n"); return -EIO; } @@ -202,7 +223,11 @@ static int get_key_hvr1110(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) unsigned char buf[5], cod4, code3, code4; /* poll IR chip */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + if (5 != i2c_master_recv(&ir->c,buf,5)) +#else if (5 != i2c_master_recv(ir->c, buf, 5)) +#endif return -EIO; cod4 = buf[4]; @@ -224,7 +249,11 @@ static int get_key_beholdm6xx(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) unsigned char data[12]; u32 gpio; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + struct saa7134_dev *dev = ir->c.adapter->algo_data; +#else struct saa7134_dev *dev = ir->c->adapter->algo_data; +#endif /* rising SAA7134_GPIO_GPRESCAN reads the status */ saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); @@ -235,9 +264,17 @@ static int get_key_beholdm6xx(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) if (0x400000 & ~gpio) return 0; /* No button press */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + ir->c.addr = 0x5a >> 1; +#else ir->c->addr = 0x5a >> 1; +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + if (12 != i2c_master_recv(&ir->c, data, 12)) { +#else if (12 != i2c_master_recv(ir->c, data, 12)) { +#endif i2cdprintk("read error\n"); return -EIO; } @@ -267,7 +304,11 @@ static int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw, unsigned int start = 0,parity = 0,code = 0; /* poll IR chip */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + if (4 != i2c_master_recv(&ir->c, b, 4)) { +#else if (4 != i2c_master_recv(ir->c, b, 4)) { +#endif i2cdprintk("read error\n"); return -EIO; } @@ -686,8 +727,13 @@ void saa7134_input_fini(struct saa7134_dev *dev) dev->remote = NULL; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) +void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir) +#else void saa7134_probe_i2c_ir(struct saa7134_dev *dev) +#endif { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) struct i2c_board_info info; struct IR_i2c_init_data init_data; const unsigned short addr_list[] = { @@ -704,33 +750,66 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev) int rc; +#endif if (disable_ir) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + dprintk("Found supported i2c remote, but IR has been disabled\n"); + ir->get_key=NULL; +#else dprintk("IR has been disabled, not probing for i2c remote\n"); +#endif return; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) memset(&info, 0, sizeof(struct i2c_board_info)); memset(&init_data, 0, sizeof(struct IR_i2c_init_data)); strlcpy(info.type, "ir_video", I2C_NAME_SIZE); +#endif switch (dev->board) { case SAA7134_BOARD_PINNACLE_PCTV_110i: case SAA7134_BOARD_PINNACLE_PCTV_310i: +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + snprintf(ir->c.name, sizeof(ir->c.name), "Pinnacle PCTV"); +#else init_data.name = "Pinnacle PCTV"; +#endif if (pinnacle_remote == 0) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + ir->get_key = get_key_pinnacle_color; + ir->ir_codes = ir_codes_pinnacle_color; +#else init_data.get_key = get_key_pinnacle_color; init_data.ir_codes = ir_codes_pinnacle_color; +#endif } else { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + ir->get_key = get_key_pinnacle_grey; + ir->ir_codes = ir_codes_pinnacle_grey; +#else init_data.get_key = get_key_pinnacle_grey; init_data.ir_codes = ir_codes_pinnacle_grey; +#endif } break; case SAA7134_BOARD_UPMOST_PURPLE_TV: +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + snprintf(ir->c.name, sizeof(ir->c.name), "Purple TV"); + ir->get_key = get_key_purpletv; + ir->ir_codes = ir_codes_purpletv; +#else init_data.name = "Purple TV"; init_data.get_key = get_key_purpletv; init_data.ir_codes = ir_codes_purpletv; +#endif break; case SAA7134_BOARD_MSI_TVATANYWHERE_PLUS: +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + snprintf(ir->c.name, sizeof(ir->c.name), "MSI TV@nywhere Plus"); + ir->get_key = get_key_msi_tvanywhere_plus; + ir->ir_codes = ir_codes_msi_tvanywhere_plus; +#else init_data.name = "MSI TV@nywhere Plus"; init_data.get_key = get_key_msi_tvanywhere_plus; init_data.ir_codes = ir_codes_msi_tvanywhere_plus; @@ -743,11 +822,18 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev) dprintk(KERN_DEBUG "probe 0x%02x @ %s: %s\n", msg_msi.addr, dev->i2c_adap.name, (1 == rc) ? "yes" : "no"); +#endif break; case SAA7134_BOARD_HAUPPAUGE_HVR1110: +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + snprintf(ir->c.name, sizeof(ir->c.name), "HVR 1110"); + ir->get_key = get_key_hvr1110; + ir->ir_codes = ir_codes_hauppauge_new; +#else init_data.name = "HVR 1110"; init_data.get_key = get_key_hvr1110; init_data.ir_codes = ir_codes_hauppauge_new; +#endif break; case SAA7134_BOARD_BEHOLD_607FM_MK3: case SAA7134_BOARD_BEHOLD_607FM_MK5: @@ -761,16 +847,28 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev) case SAA7134_BOARD_BEHOLD_M63: case SAA7134_BOARD_BEHOLD_M6_EXTRA: case SAA7134_BOARD_BEHOLD_H6: +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + snprintf(ir->c.name, sizeof(ir->c.name), "BeholdTV"); + ir->get_key = get_key_beholdm6xx; + ir->ir_codes = ir_codes_behold; +#else init_data.name = "BeholdTV"; init_data.get_key = get_key_beholdm6xx; init_data.ir_codes = ir_codes_behold; +#endif break; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + default: + dprintk("Shouldn't get here: Unknown board %x for I2C IR?\n",dev->board); +#else case SAA7134_BOARD_AVERMEDIA_CARDBUS_501: case SAA7134_BOARD_AVERMEDIA_CARDBUS_506: info.addr = 0x40; +#endif break; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) if (init_data.name) info.platform_data = &init_data; /* No need to probe if address is known */ @@ -781,6 +879,7 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev) /* Address not known, fallback to probing */ i2c_new_probed_device(&dev->i2c_adap, &info, addr_list); +#endif } static int saa7134_rc5_irq(struct saa7134_dev *dev) diff --git a/linux/drivers/media/video/saa7134/saa7134.h b/linux/drivers/media/video/saa7134/saa7134.h index be6763dde..385bc26bd 100644 --- a/linux/drivers/media/video/saa7134/saa7134.h +++ b/linux/drivers/media/video/saa7134/saa7134.h @@ -804,7 +804,11 @@ void saa7134_irq_oss_done(struct saa7134_dev *dev, unsigned long status); int saa7134_input_init1(struct saa7134_dev *dev); void saa7134_input_fini(struct saa7134_dev *dev); void saa7134_input_irq(struct saa7134_dev *dev); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) +void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir); +#else void saa7134_probe_i2c_ir(struct saa7134_dev *dev); +#endif void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir); void saa7134_ir_stop(struct saa7134_dev *dev); diff --git a/linux/drivers/media/video/v4l2-device.c b/linux/drivers/media/video/v4l2-device.c index b962862fe..18d404499 100644 --- a/linux/drivers/media/video/v4l2-device.c +++ b/linux/drivers/media/video/v4l2-device.c @@ -87,6 +87,7 @@ void v4l2_device_unregister(struct v4l2_device *v4l2_dev) list_for_each_entry_safe(sd, next, &v4l2_dev->subdevs, list) { v4l2_device_unregister_subdev(sd); #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) if (sd->flags & V4L2_SUBDEV_FL_IS_I2C) { struct i2c_client *client = v4l2_get_subdevdata(sd); @@ -98,6 +99,7 @@ void v4l2_device_unregister(struct v4l2_device *v4l2_dev) i2c_unregister_device(client); } #endif +#endif } } EXPORT_SYMBOL_GPL(v4l2_device_unregister); |