All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] ir-kbd-i2c conversion to the new i2c binding model (v2)
@ 2009-04-17 20:29 Jean Delvare
  2009-04-17 20:30 ` [PATCH 1/6] ir-kbd-i2c: Don't use i2c_client.name for our own needs Jean Delvare
                   ` (6 more replies)
  0 siblings, 7 replies; 20+ messages in thread
From: Jean Delvare @ 2009-04-17 20:29 UTC (permalink / raw)
  To: LMML

Hi all,

Here comes an update of my conversion of ir-kbd-i2c to the new i2c
binding model. I've split it into 6 pieces for easier review. Firstly
there is 1 preliminary patch:

01-ir-kbd-i2c-dont-abuse-client-name.patch

Then 3 patches doing the actual conversion:

02-ir-kbd-i2c-convert-to-new-style.patch
03-configure-ir-receiver.patch
04-ir-kbd-i2c-dont-bind-to-unsupported-devices.patch

And lastly 2 patches cleaning up saa7134-input thanks to the new
possibilities offered by the conversion:

04-saa7134-input-cleanup-msi-ir.patch
05-saa7134-input-cleanup-avermedia-cardbus.patch

This patch set is against the v4l-dvb repository, but I didn't pay
attention to the compatibility issues. I simply build-tested it on
2.6.27 and 2.6.29.

This patch set touches many different drivers and I can't test any of
them. My only TV card with an IR receiver doesn't make use of
ir-kbd-i2c. So I would warmly welcome testers. The more testing my
changes can get, the better.

And of course I welcome reviews and comments as well. I had to touch
many drivers I don't know anything about so it is possible that I
missed something.

The main difference with my initial patch set is that the ir-kbd-i2c
devices are named ir_video instead of ir-kbd. The new name was chosen
neutral to make it clear that alternative drivers can bind to these
devices if so is the user's desire (lirc comes to mind). Such drivers
will need to be updated, but with the legacy binding model going away,
that had to happen anyway.

I'll post all 6 patches as replies to this post. They can also be
temporarily downloaded from:
  http://jdelvare.pck.nerim.net/linux/ir-kbd-i2c/
Additionally I've put a combined patch there, to make testing easier:
  http://jdelvare.pck.nerim.net/linux/ir-kbd-i2c/ir-kbd-i2c-conversion-ALL-IN-ONE.patch
But for review the individual patches are much better.

Thanks,
-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/6] ir-kbd-i2c: Don't use i2c_client.name for our own needs
  2009-04-17 20:29 [PATCH 0/6] ir-kbd-i2c conversion to the new i2c binding model (v2) Jean Delvare
@ 2009-04-17 20:30 ` Jean Delvare
  2009-04-17 20:31 ` [PATCH 2/6] ir-kbd-i2c: Switch to the new-style device binding model Jean Delvare
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Jean Delvare @ 2009-04-17 20:30 UTC (permalink / raw)
  To: LMML

In the standard device driver binding model, the name field of
struct i2c_client is used to match devices to their drivers, so we
must stop using it for internal purposes. Define a separate field
in struct IR_i2c as a replacement, and use it.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
---
 linux/drivers/media/video/cx231xx/cx231xx-input.c |    2 +-
 linux/drivers/media/video/em28xx/em28xx-cards.c   |    6 +++---
 linux/drivers/media/video/em28xx/em28xx-input.c   |    2 +-
 linux/drivers/media/video/ir-kbd-i2c.c            |    5 +++--
 linux/drivers/media/video/saa7134/saa7134-input.c |   12 ++++++------
 linux/include/media/ir-kbd-i2c.h                  |    1 +
 6 files changed, 15 insertions(+), 13 deletions(-)

--- v4l-dvb.orig/linux/drivers/media/video/cx231xx/cx231xx-input.c	2009-04-08 11:27:31.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/cx231xx/cx231xx-input.c	2009-04-17 12:54:18.000000000 +0200
@@ -37,7 +37,7 @@ MODULE_PARM_DESC(ir_debug, "enable debug
 
 #define i2cdprintk(fmt, arg...) \
 	if (ir_debug) { \
-		printk(KERN_DEBUG "%s/ir: " fmt, ir->c.name , ## arg); \
+		printk(KERN_DEBUG "%s/ir: " fmt, ir->name , ## arg); \
 	}
 
 #define dprintk(fmt, arg...) \
--- v4l-dvb.orig/linux/drivers/media/video/em28xx/em28xx-cards.c	2009-04-17 11:22:56.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/em28xx/em28xx-cards.c	2009-04-17 12:54:18.000000000 +0200
@@ -1948,19 +1948,19 @@ void em28xx_set_ir(struct em28xx *dev, s
 	case (EM2820_BOARD_TERRATEC_CINERGY_250):
 		ir->ir_codes = ir_codes_em_terratec;
 		ir->get_key = em28xx_get_key_terratec;
-		snprintf(ir->c.name, sizeof(ir->c.name),
+		snprintf(ir->name, sizeof(ir->name),
 			 "i2c IR (EM28XX Terratec)");
 		break;
 	case (EM2820_BOARD_PINNACLE_USB_2):
 		ir->ir_codes = ir_codes_pinnacle_grey;
 		ir->get_key = em28xx_get_key_pinnacle_usb_grey;
-		snprintf(ir->c.name, sizeof(ir->c.name),
+		snprintf(ir->name, sizeof(ir->name),
 			 "i2c IR (EM28XX Pinnacle PCTV)");
 		break;
 	case (EM2820_BOARD_HAUPPAUGE_WINTV_USB_2):
 		ir->ir_codes = ir_codes_hauppauge_new;
 		ir->get_key = em28xx_get_key_em_haup;
-		snprintf(ir->c.name, sizeof(ir->c.name),
+		snprintf(ir->name, sizeof(ir->name),
 			 "i2c IR (EM2840 Hauppauge)");
 		break;
 	case (EM2820_BOARD_MSI_VOX_USB_2):
--- v4l-dvb.orig/linux/drivers/media/video/em28xx/em28xx-input.c	2009-04-08 11:27:31.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/em28xx/em28xx-input.c	2009-04-17 12:54:18.000000000 +0200
@@ -41,7 +41,7 @@ MODULE_PARM_DESC(ir_debug, "enable debug
 
 #define i2cdprintk(fmt, arg...) \
 	if (ir_debug) { \
-		printk(KERN_DEBUG "%s/ir: " fmt, ir->c.name , ## arg); \
+		printk(KERN_DEBUG "%s/ir: " fmt, ir->name , ## arg); \
 	}
 
 #define dprintk(fmt, arg...) \
--- v4l-dvb.orig/linux/drivers/media/video/ir-kbd-i2c.c	2009-04-08 11:27:31.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/ir-kbd-i2c.c	2009-04-17 12:54:18.000000000 +0200
@@ -346,6 +346,7 @@ static int ir_attach(struct i2c_adapter
 
 	ir->c.adapter = adap;
 	ir->c.addr    = addr;
+	snprintf(ir->c.name, sizeof(ir->c.name), "ir-kbd");
 
 	i2c_set_clientdata(&ir->c, ir);
 
@@ -419,7 +420,7 @@ static int ir_attach(struct i2c_adapter
 	}
 
 	/* Sets name */
-	snprintf(ir->c.name, sizeof(ir->c.name), "i2c IR (%s)", name);
+	snprintf(ir->name, sizeof(ir->name), "i2c IR (%s)", name);
 	ir->ir_codes = ir_codes;
 
 	/* register i2c device
@@ -444,7 +445,7 @@ static int ir_attach(struct i2c_adapter
 	/* init + register input device */
 	ir_input_init(input_dev, &ir->ir, ir_type, ir->ir_codes);
 	input_dev->id.bustype = BUS_I2C;
-	input_dev->name       = ir->c.name;
+	input_dev->name       = ir->name;
 	input_dev->phys       = ir->phys;
 
 	err = input_register_device(ir->input);
--- v4l-dvb.orig/linux/drivers/media/video/saa7134/saa7134-input.c	2009-04-17 11:22:56.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/saa7134/saa7134-input.c	2009-04-17 12:54:18.000000000 +0200
@@ -60,7 +60,7 @@ MODULE_PARM_DESC(disable_other_ir, "disa
 #define dprintk(fmt, arg...)	if (ir_debug) \
 	printk(KERN_DEBUG "%s/ir: " fmt, dev->name , ## arg)
 #define i2cdprintk(fmt, arg...)    if (ir_debug) \
-	printk(KERN_DEBUG "%s/ir: " fmt, ir->c.name , ## arg)
+	printk(KERN_DEBUG "%s/ir: " fmt, ir->name , ## arg)
 
 /* Helper functions for RC5 and NEC decoding at GPIO16 or GPIO18 */
 static int saa7134_rc5_irq(struct saa7134_dev *dev);
@@ -694,7 +694,7 @@ void saa7134_set_i2c_ir(struct saa7134_d
 	switch (dev->board) {
 	case SAA7134_BOARD_PINNACLE_PCTV_110i:
 	case SAA7134_BOARD_PINNACLE_PCTV_310i:
-		snprintf(ir->c.name, sizeof(ir->c.name), "Pinnacle PCTV");
+		snprintf(ir->name, sizeof(ir->name), "Pinnacle PCTV");
 		if (pinnacle_remote == 0) {
 			ir->get_key   = get_key_pinnacle_color;
 			ir->ir_codes = ir_codes_pinnacle_color;
@@ -704,17 +704,17 @@ void saa7134_set_i2c_ir(struct saa7134_d
 		}
 		break;
 	case SAA7134_BOARD_UPMOST_PURPLE_TV:
-		snprintf(ir->c.name, sizeof(ir->c.name), "Purple TV");
+		snprintf(ir->name, sizeof(ir->name), "Purple TV");
 		ir->get_key   = get_key_purpletv;
 		ir->ir_codes  = ir_codes_purpletv;
 		break;
 	case SAA7134_BOARD_MSI_TVATANYWHERE_PLUS:
-		snprintf(ir->c.name, sizeof(ir->c.name), "MSI TV@nywhere Plus");
+		snprintf(ir->name, sizeof(ir->name), "MSI TV@nywhere Plus");
 		ir->get_key  = get_key_msi_tvanywhere_plus;
 		ir->ir_codes = ir_codes_msi_tvanywhere_plus;
 		break;
 	case SAA7134_BOARD_HAUPPAUGE_HVR1110:
-		snprintf(ir->c.name, sizeof(ir->c.name), "HVR 1110");
+		snprintf(ir->name, sizeof(ir->name), "HVR 1110");
 		ir->get_key   = get_key_hvr1110;
 		ir->ir_codes  = ir_codes_hauppauge_new;
 		break;
@@ -723,7 +723,7 @@ void saa7134_set_i2c_ir(struct saa7134_d
 	case SAA7134_BOARD_BEHOLD_M63:
 	case SAA7134_BOARD_BEHOLD_M6_EXTRA:
 	case SAA7134_BOARD_BEHOLD_H6:
-		snprintf(ir->c.name, sizeof(ir->c.name), "BeholdTV");
+		snprintf(ir->name, sizeof(ir->name), "BeholdTV");
 		ir->get_key   = get_key_beholdm6xx;
 		ir->ir_codes  = ir_codes_behold;
 		break;
--- v4l-dvb.orig/linux/include/media/ir-kbd-i2c.h	2009-04-08 11:27:31.000000000 +0200
+++ v4l-dvb/linux/include/media/ir-kbd-i2c.h	2009-04-17 12:54:18.000000000 +0200
@@ -15,6 +15,7 @@ struct IR_i2c {
 	unsigned char          old;
 
 	struct delayed_work    work;
+	char                   name[32];
 	char                   phys[32];
 	int                    (*get_key)(struct IR_i2c*, u32*, u32*);
 };

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 2/6] ir-kbd-i2c: Switch to the new-style device binding model
  2009-04-17 20:29 [PATCH 0/6] ir-kbd-i2c conversion to the new i2c binding model (v2) Jean Delvare
  2009-04-17 20:30 ` [PATCH 1/6] ir-kbd-i2c: Don't use i2c_client.name for our own needs Jean Delvare
@ 2009-04-17 20:31 ` Jean Delvare
  2009-04-17 23:35   ` Mike Isely
  2009-04-17 20:32 ` [PATCH 3/6] ir-kbd-i2c: Use initialization data Jean Delvare
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 20+ messages in thread
From: Jean Delvare @ 2009-04-17 20:31 UTC (permalink / raw)
  To: LMML

Let card drivers probe for IR receiver devices and instantiate them if
found. Ultimately it would be better if we could stop probing
completely, but I suspect this won't be possible for all card types.

There's certainly room for cleanups. For example, some drivers are
sharing I2C adapter IDs, so they also had to share the list of I2C
addresses being probed for an IR receiver. Now that each driver
explicitly says which addresses should be probed, maybe some addresses
can be dropped from some drivers.

Also, the special cases in saa7134-i2c should probably be handled on a
per-board basis. This would be more efficient and less risky than always
probing extra addresses on all boards. I'll give it a try later.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
Cc: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Andy Walls <awalls@radix.net>
Cc: Mike Isely <isely@pobox.com>
---
 linux/drivers/media/video/bt8xx/bttv-i2c.c           |   21 +
 linux/drivers/media/video/cx231xx/cx231xx-cards.c    |   11 
 linux/drivers/media/video/cx231xx/cx231xx-i2c.c      |    3 
 linux/drivers/media/video/cx231xx/cx231xx.h          |    1 
 linux/drivers/media/video/cx23885/cx23885-i2c.c      |   12 +
 linux/drivers/media/video/cx88/cx88-i2c.c            |   13 +
 linux/drivers/media/video/em28xx/em28xx-cards.c      |   20 +
 linux/drivers/media/video/em28xx/em28xx-i2c.c        |    3 
 linux/drivers/media/video/em28xx/em28xx-input.c      |    6 
 linux/drivers/media/video/em28xx/em28xx.h            |    1 
 linux/drivers/media/video/ir-kbd-i2c.c               |  200 +++---------------
 linux/drivers/media/video/ivtv/ivtv-i2c.c            |   31 ++
 linux/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c |   24 ++
 linux/drivers/media/video/saa7134/saa7134-i2c.c      |    3 
 linux/drivers/media/video/saa7134/saa7134-input.c    |   86 ++++++-
 linux/drivers/media/video/saa7134/saa7134.h          |    1 
 linux/include/media/ir-kbd-i2c.h                     |    2 
 17 files changed, 244 insertions(+), 194 deletions(-)

--- v4l-dvb.orig/linux/drivers/media/video/bt8xx/bttv-i2c.c	2009-04-17 14:36:51.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/bt8xx/bttv-i2c.c	2009-04-17 14:37:54.000000000 +0200
@@ -405,6 +405,27 @@ int __devinit init_bttv_i2c(struct bttv
 	}
 	if (0 == btv->i2c_rc && i2c_scan)
 		do_i2c_scan(btv->c.v4l2_dev.name, &btv->i2c_client);
+
+	/* Instantiate the IR receiver device, if present */
+	if (0 == btv->i2c_rc) {
+		struct i2c_board_info info;
+		/* 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
+		*/
+		const unsigned short addr_list[] = {
+			0x1a, 0x18, 0x4b, 0x64, 0x30,
+			I2C_CLIENT_END
+		};
+
+		memset(&info, 0, sizeof(struct i2c_board_info));
+		strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
+		i2c_new_probed_device(&btv->c.i2c_adap, &info, addr_list);
+	}
 	return btv->i2c_rc;
 }
 
--- v4l-dvb.orig/linux/drivers/media/video/cx231xx/cx231xx-cards.c	2009-04-17 14:36:51.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/cx231xx/cx231xx-cards.c	2009-04-17 14:37:54.000000000 +0200
@@ -282,13 +282,16 @@ static void cx231xx_config_tuner(struct
 }
 
 /* ----------------------------------------------------------------------- */
-void cx231xx_set_ir(struct cx231xx *dev, struct IR_i2c *ir)
+void cx231xx_register_i2c_ir(struct cx231xx *dev)
 {
-	if (disable_ir) {
-		ir->get_key = NULL;
+	if (disable_ir)
 		return;
-	}
 
+	/* REVISIT: instantiate IR device */
+}
+
+void cx231xx_set_ir(struct cx231xx *dev, struct IR_i2c *ir)
+{
 	/* detect & configure */
 	switch (dev->model) {
 
--- v4l-dvb.orig/linux/drivers/media/video/cx231xx/cx231xx-i2c.c	2009-04-17 14:36:51.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/cx231xx/cx231xx-i2c.c	2009-04-17 14:37:54.000000000 +0200
@@ -540,6 +540,9 @@ int cx231xx_i2c_register(struct cx231xx_
 	if (0 == bus->i2c_rc) {
 		if (i2c_scan)
 			cx231xx_do_i2c_scan(dev, &bus->i2c_client);
+
+		/* Instantiate the IR receiver device, if present */
+		cx231xx_register_i2c_ir(dev);
 	} else
 		cx231xx_warn("%s: i2c bus %d register FAILED\n",
 			     dev->name, bus->nr);
--- v4l-dvb.orig/linux/drivers/media/video/cx231xx/cx231xx.h	2009-04-17 14:36:51.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/cx231xx/cx231xx.h	2009-04-17 14:37:54.000000000 +0200
@@ -747,6 +747,7 @@ extern void cx231xx_card_setup(struct cx
 extern struct cx231xx_board cx231xx_boards[];
 extern struct usb_device_id cx231xx_id_table[];
 extern const unsigned int cx231xx_bcount;
+void cx231xx_register_i2c_ir(struct cx231xx *dev);
 void cx231xx_set_ir(struct cx231xx *dev, struct IR_i2c *ir);
 int cx231xx_tuner_callback(void *ptr, int component, int command, int arg);
 
--- v4l-dvb.orig/linux/drivers/media/video/cx23885/cx23885-i2c.c	2009-04-17 14:36:51.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/cx23885/cx23885-i2c.c	2009-04-17 14:37:54.000000000 +0200
@@ -364,6 +364,18 @@ int cx23885_i2c_register(struct cx23885_
 		printk(KERN_WARNING "%s: i2c bus %d register FAILED\n",
 			dev->name, bus->nr);
 
+	/* Instantiate the IR receiver device, if present */
+	if (0 == bus->i2c_rc) {
+		struct i2c_board_info info;
+		const unsigned short addr_list[] = {
+			0x6b, I2C_CLIENT_END
+		};
+
+		memset(&info, 0, sizeof(struct i2c_board_info));
+		strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
+		i2c_new_probed_device(&bus->i2c_adap, &info, addr_list);
+	}
+
 	return bus->i2c_rc;
 }
 
--- v4l-dvb.orig/linux/drivers/media/video/cx88/cx88-i2c.c	2009-04-17 14:36:51.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/cx88/cx88-i2c.c	2009-04-17 14:37:54.000000000 +0200
@@ -186,6 +186,19 @@ int cx88_i2c_init(struct cx88_core *core
 			do_i2c_scan(core->name,&core->i2c_client);
 	} else
 		printk("%s: i2c register FAILED\n", core->name);
+
+	/* Instantiate the IR receiver device, if present */
+	if (0 == core->i2c_rc) {
+		struct i2c_board_info info;
+		const unsigned short addr_list[] = {
+			0x18, 0x6b, 0x71,
+			I2C_CLIENT_END
+		};
+
+		memset(&info, 0, sizeof(struct i2c_board_info));
+		strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
+		i2c_new_probed_device(&core->i2c_adap, &info, addr_list);
+	}
 	return core->i2c_rc;
 }
 
--- v4l-dvb.orig/linux/drivers/media/video/em28xx/em28xx-cards.c	2009-04-17 14:36:51.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/em28xx/em28xx-cards.c	2009-04-17 14:37:54.000000000 +0200
@@ -1931,13 +1931,23 @@ static int em28xx_hint_board(struct em28
 }
 
 /* ----------------------------------------------------------------------- */
-void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir)
+void em28xx_register_i2c_ir(struct em28xx *dev)
 {
-	if (disable_ir) {
-		ir->get_key = NULL;
-		return ;
-	}
+	struct i2c_board_info info;
+	const unsigned short addr_list[] = {
+		 0x30, 0x47, I2C_CLIENT_END
+	};
+
+	if (disable_ir)
+		return;
+
+	memset(&info, 0, sizeof(struct i2c_board_info));
+	strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
+	i2c_new_probed_device(&dev->i2c_adap, &info, addr_list);
+}
 
+void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir)
+{
 	/* detect & configure */
 	switch (dev->model) {
 	case (EM2800_BOARD_UNKNOWN):
--- v4l-dvb.orig/linux/drivers/media/video/em28xx/em28xx-i2c.c	2009-04-17 14:36:51.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/em28xx/em28xx-i2c.c	2009-04-17 14:37:54.000000000 +0200
@@ -581,6 +581,9 @@ int em28xx_i2c_register(struct em28xx *d
 	if (i2c_scan)
 		em28xx_do_i2c_scan(dev);
 
+	/* Instantiate the IR receiver device, if present */
+	em28xx_register_i2c_ir(dev);
+
 	return 0;
 }
 
--- v4l-dvb.orig/linux/drivers/media/video/em28xx/em28xx-input.c	2009-04-17 14:36:51.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/em28xx/em28xx-input.c	2009-04-17 14:37:54.000000000 +0200
@@ -86,7 +86,7 @@ int em28xx_get_key_terratec(struct IR_i2
 	unsigned char b;
 
 	/* poll IR chip */
-	if (1 != i2c_master_recv(&ir->c, &b, 1)) {
+	if (1 != i2c_master_recv(ir->c, &b, 1)) {
 		i2cdprintk("read error\n");
 		return -EIO;
 	}
@@ -115,7 +115,7 @@ int em28xx_get_key_em_haup(struct IR_i2c
 	unsigned char code;
 
 	/* poll IR chip */
-	if (2 != i2c_master_recv(&ir->c, buf, 2))
+	if (2 != i2c_master_recv(ir->c, buf, 2))
 		return -EIO;
 
 	/* Does eliminate repeated parity code */
@@ -153,7 +153,7 @@ int em28xx_get_key_pinnacle_usb_grey(str
 
 	/* poll IR chip */
 
-	if (3 != i2c_master_recv(&ir->c, buf, 3)) {
+	if (3 != i2c_master_recv(ir->c, buf, 3)) {
 		i2cdprintk("read error\n");
 		return -EIO;
 	}
--- v4l-dvb.orig/linux/drivers/media/video/em28xx/em28xx.h	2009-04-17 14:36:51.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/em28xx/em28xx.h	2009-04-17 14:37:54.000000000 +0200
@@ -649,6 +649,7 @@ extern void em28xx_card_setup(struct em2
 extern struct em28xx_board em28xx_boards[];
 extern struct usb_device_id em28xx_id_table[];
 extern const unsigned int em28xx_bcount;
+void em28xx_register_i2c_ir(struct em28xx *dev);
 void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir);
 int em28xx_tuner_callback(void *ptr, int component, int command, int arg);
 void em28xx_release_resources(struct em28xx *dev);
--- v4l-dvb.orig/linux/drivers/media/video/ir-kbd-i2c.c	2009-04-17 14:36:51.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/ir-kbd-i2c.c	2009-04-17 14:37:54.000000000 +0200
@@ -75,7 +75,7 @@ static int get_key_haup_common(struct IR
 	int start, range, toggle, dev, code, ircode;
 
 	/* poll IR chip */
-	if (size != i2c_master_recv(&ir->c,buf,size))
+	if (size != i2c_master_recv(ir->c, buf, size))
 		return -EIO;
 
 	/* split rc5 data block ... */
@@ -138,7 +138,7 @@ static int get_key_pixelview(struct IR_i
 	unsigned char b;
 
 	/* poll IR chip */
-	if (1 != i2c_master_recv(&ir->c,&b,1)) {
+	if (1 != i2c_master_recv(ir->c, &b, 1)) {
 		dprintk(1,"read error\n");
 		return -EIO;
 	}
@@ -152,7 +152,7 @@ static int get_key_pv951(struct IR_i2c *
 	unsigned char b;
 
 	/* poll IR chip */
-	if (1 != i2c_master_recv(&ir->c,&b,1)) {
+	if (1 != i2c_master_recv(ir->c, &b, 1)) {
 		dprintk(1,"read error\n");
 		return -EIO;
 	}
@@ -172,7 +172,7 @@ static int get_key_fusionhdtv(struct IR_
 	unsigned char buf[4];
 
 	/* poll IR chip */
-	if (4 != i2c_master_recv(&ir->c,buf,4)) {
+	if (4 != i2c_master_recv(ir->c, buf, 4)) {
 		dprintk(1,"read error\n");
 		return -EIO;
 	}
@@ -196,7 +196,7 @@ static int get_key_knc1(struct IR_i2c *i
 	unsigned char b;
 
 	/* poll IR chip */
-	if (1 != i2c_master_recv(&ir->c,&b,1)) {
+	if (1 != i2c_master_recv(ir->c, &b, 1)) {
 		dprintk(1,"read error\n");
 		return -EIO;
 	}
@@ -223,12 +223,12 @@ static int get_key_avermedia_cardbus(str
 				     u32 *ir_key, u32 *ir_raw)
 {
 	unsigned char subaddr, key, keygroup;
-	struct i2c_msg msg[] = { { .addr = ir->c.addr, .flags = 0,
+	struct i2c_msg msg[] = { { .addr = ir->c->addr, .flags = 0,
 				   .buf = &subaddr, .len = 1},
-				 { .addr = ir->c.addr, .flags = I2C_M_RD,
+				 { .addr = ir->c->addr, .flags = I2C_M_RD,
 				  .buf = &key, .len = 1} };
 	subaddr = 0x0d;
-	if (2 != i2c_transfer(ir->c.adapter, msg, 2)) {
+	if (2 != i2c_transfer(ir->c->adapter, msg, 2)) {
 		dprintk(1, "read error\n");
 		return -EIO;
 	}
@@ -238,7 +238,7 @@ static int get_key_avermedia_cardbus(str
 
 	subaddr = 0x0b;
 	msg[1].buf = &keygroup;
-	if (2 != i2c_transfer(ir->c.adapter, msg, 2)) {
+	if (2 != i2c_transfer(ir->c->adapter, msg, 2)) {
 		dprintk(1, "read error\n");
 		return -EIO;
 	}
@@ -295,7 +295,7 @@ static void ir_work(struct work_struct *
 
 	/* MSI TV@nywhere Plus requires more frequent polling
 	   otherwise it will miss some keypresses */
-	if (ir->c.adapter->id == I2C_HW_SAA7134 && ir->c.addr == 0x30)
+	if (ir->c->adapter->id == I2C_HW_SAA7134 && ir->c->addr == 0x30)
 		polling_interval = 50;
 
 	ir_key_poll(ir);
@@ -304,34 +304,15 @@ static void ir_work(struct work_struct *
 
 /* ----------------------------------------------------------------------- */
 
-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_template =
-{
-	.name = "unset",
-	.driver = &driver
-};
-
-static int ir_attach(struct i2c_adapter *adap, int addr,
-		     unsigned short flags, int kind)
+static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
 	IR_KEYTAB_TYPE *ir_codes = NULL;
 	char *name;
 	int ir_type;
 	struct IR_i2c *ir;
 	struct input_dev *input_dev;
+	struct i2c_adapter *adap = client->adapter;
+	unsigned short addr = client->addr;
 	int err;
 
 	ir = kzalloc(sizeof(struct IR_i2c),GFP_KERNEL);
@@ -341,14 +322,9 @@ static int ir_attach(struct i2c_adapter
 		goto err_out_free;
 	}
 
-	ir->c = client_template;
+	ir->c = client;
 	ir->input = input_dev;
-
-	ir->c.adapter = adap;
-	ir->c.addr    = addr;
-	snprintf(ir->c.name, sizeof(ir->c.name), "ir-kbd");
-
-	i2c_set_clientdata(&ir->c, ir);
+	i2c_set_clientdata(client, ir);
 
 	switch(addr) {
 	case 0x64:
@@ -423,24 +399,9 @@ static int ir_attach(struct i2c_adapter
 	snprintf(ir->name, sizeof(ir->name), "i2c IR (%s)", name);
 	ir->ir_codes = ir_codes;
 
-	/* 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) */
 	snprintf(ir->phys, sizeof(ir->phys), "%s/%s/ir0",
-		 dev_name(&ir->c.adapter->dev),
-		 dev_name(&ir->c.dev));
+		 dev_name(&adap->dev),
+		 dev_name(&client->dev));
 
 	/* init + register input device */
 	ir_input_init(input_dev, &ir->ir, ir_type, ir->ir_codes);
@@ -450,7 +411,7 @@ static int ir_attach(struct i2c_adapter
 
 	err = input_register_device(ir->input);
 	if (err)
-		goto err_out_detach;
+		goto err_out_free;
 
 	printk(DEVNAME ": %s detected at %s [%s]\n",
 	       ir->input->name, ir->input->phys, adap->name);
@@ -465,135 +426,42 @@ static int ir_attach(struct i2c_adapter
 
 	return 0;
 
- err_out_detach:
-	i2c_detach_client(&ir->c);
  err_out_free:
 	input_free_device(input_dev);
 	kfree(ir);
 	return err;
 }
 
-static int ir_detach(struct i2c_client *client)
+static int ir_remove(struct i2c_client *client)
 {
 	struct IR_i2c *ir = i2c_get_clientdata(client);
 
 	/* kill outstanding polls */
 	cancel_delayed_work_sync(&ir->work);
 
-	/* unregister devices */
+	/* unregister device */
 	input_unregister_device(ir->input);
-	i2c_detach_client(&ir->c);
 
 	/* free memory */
 	kfree(ir);
 	return 0;
 }
 
-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);
-	}
+static const struct i2c_device_id ir_kbd_id[] = {
+	/* Generic entry for any IR receiver */
+	{ "ir_video", 0 },
+	/* IR device specific entries could be added here */
+	{ }
+};
 
-	return 0;
-}
+static struct i2c_driver driver = {
+	.driver = {
+		.name   = "ir-kbd-i2c",
+	},
+	.probe          = ir_probe,
+	.remove         = ir_remove,
+	.id_table       = ir_kbd_id,
+};
 
 /* ----------------------------------------------------------------------- */
 
--- v4l-dvb.orig/linux/drivers/media/video/ivtv/ivtv-i2c.c	2009-04-17 14:36:51.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/ivtv/ivtv-i2c.c	2009-04-17 14:37:54.000000000 +0200
@@ -592,9 +592,11 @@ static struct i2c_client ivtv_i2c_client
 	.name = "ivtv internal",
 };
 
-/* init + register i2c algo-bit adapter */
+/* init + register i2c adapter + instantiate IR receiver */
 int init_ivtv_i2c(struct ivtv *itv)
 {
+	int retval;
+
 	IVTV_DEBUG_I2C("i2c init\n");
 
 	/* Sanity checks for the I2C hardware arrays. They must be the
@@ -634,9 +636,32 @@ int init_ivtv_i2c(struct ivtv *itv)
 	ivtv_setsda(itv, 1);
 
 	if (itv->options.newi2c > 0)
-		return i2c_add_adapter(&itv->i2c_adap);
+		retval = i2c_add_adapter(&itv->i2c_adap);
 	else
-		return i2c_bit_add_bus(&itv->i2c_adap);
+		retval = i2c_bit_add_bus(&itv->i2c_adap);
+
+	/* Instantiate the IR receiver device, if present */
+	if (retval == 0) {
+		struct i2c_board_info info;
+		/* 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
+		*/
+		const unsigned short addr_list[] = {
+			0x1a, 0x18, 0x64, 0x30,
+			I2C_CLIENT_END
+		};
+
+		memset(&info, 0, sizeof(struct i2c_board_info));
+		strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
+		i2c_new_probed_device(&itv->i2c_adap, &info, addr_list);
+	}
+
+	return retval;
 }
 
 void exit_ivtv_i2c(struct ivtv *itv)
--- v4l-dvb.orig/linux/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c	2009-04-17 14:36:51.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c	2009-04-17 14:37:54.000000000 +0200
@@ -637,6 +637,27 @@ static void do_i2c_scan(struct pvr2_hdw
 	printk(KERN_INFO "%s: i2c scan done.\n", hdw->name);
 }
 
+static void pvr2_i2c_register_ir(struct i2c_adapter *i2c_adap)
+{
+	struct i2c_board_info info;
+	/* 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
+	*/
+	const unsigned short addr_list[] = {
+		0x1a, 0x18, 0x4b, 0x64, 0x30,
+		I2C_CLIENT_END
+	};
+
+	memset(&info, 0, sizeof(struct i2c_board_info));
+	strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
+	i2c_new_probed_device(i2c_adap, &info, addr_list);
+}
+
 void pvr2_i2c_core_init(struct pvr2_hdw *hdw)
 {
 	unsigned int idx;
@@ -684,6 +705,9 @@ void pvr2_i2c_core_init(struct pvr2_hdw
 		}
 	}
 	if (i2c_scan) do_i2c_scan(hdw);
+
+	/* Instantiate the IR receiver device, if present */
+	pvr2_i2c_register_ir(&hdw->i2c_adap);
 }
 
 void pvr2_i2c_core_done(struct pvr2_hdw *hdw)
--- v4l-dvb.orig/linux/drivers/media/video/saa7134/saa7134-i2c.c	2009-04-17 14:36:51.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/saa7134/saa7134-i2c.c	2009-04-17 14:37:54.000000000 +0200
@@ -444,6 +444,9 @@ int saa7134_i2c_register(struct saa7134_
 	saa7134_i2c_eeprom(dev,dev->eedata,sizeof(dev->eedata));
 	if (i2c_scan)
 		do_i2c_scan(dev->name,&dev->i2c_client);
+
+	/* Instantiate the IR receiver device, if present */
+	saa7134_probe_i2c_ir(dev);
 	return 0;
 }
 
--- v4l-dvb.orig/linux/drivers/media/video/saa7134/saa7134-input.c	2009-04-17 14:36:51.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/saa7134/saa7134-input.c	2009-04-17 14:37:54.000000000 +0200
@@ -134,10 +134,10 @@ static int get_key_msi_tvanywhere_plus(s
 	int gpio;
 
 	/* <dev> is needed to access GPIO. Used by the saa_readl macro. */
-	struct saa7134_dev *dev = ir->c.adapter->algo_data;
+	struct saa7134_dev *dev = ir->c->adapter->algo_data;
 	if (dev == NULL) {
 		dprintk("get_key_msi_tvanywhere_plus: "
-			"gir->c.adapter->algo_data is NULL!\n");
+			"gir->c->adapter->algo_data is NULL!\n");
 		return -EIO;
 	}
 
@@ -156,7 +156,7 @@ static int get_key_msi_tvanywhere_plus(s
 
 	/* GPIO says there is a button press. Get it. */
 
-	if (1 != i2c_master_recv(&ir->c, &b, 1)) {
+	if (1 != i2c_master_recv(ir->c, &b, 1)) {
 		i2cdprintk("read error\n");
 		return -EIO;
 	}
@@ -179,7 +179,7 @@ static int get_key_purpletv(struct IR_i2
 	unsigned char b;
 
 	/* poll IR chip */
-	if (1 != i2c_master_recv(&ir->c,&b,1)) {
+	if (1 != i2c_master_recv(ir->c, &b, 1)) {
 		i2cdprintk("read error\n");
 		return -EIO;
 	}
@@ -202,7 +202,7 @@ static int get_key_hvr1110(struct IR_i2c
 	unsigned char buf[5], cod4, code3, code4;
 
 	/* poll IR chip */
-	if (5 != i2c_master_recv(&ir->c,buf,5))
+	if (5 != i2c_master_recv(ir->c, buf, 5))
 		return -EIO;
 
 	cod4	= buf[4];
@@ -224,7 +224,7 @@ static int get_key_beholdm6xx(struct IR_
 	unsigned char data[12];
 	u32 gpio;
 
-	struct saa7134_dev *dev = ir->c.adapter->algo_data;
+	struct saa7134_dev *dev = ir->c->adapter->algo_data;
 
 	/* rising SAA7134_GPIO_GPRESCAN reads the status */
 	saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
@@ -235,9 +235,9 @@ static int get_key_beholdm6xx(struct IR_
 	if (0x400000 & ~gpio)
 		return 0; /* No button press */
 
-	ir->c.addr = 0x5a >> 1;
+	ir->c->addr = 0x5a >> 1;
 
-	if (12 != i2c_master_recv(&ir->c, data, 12)) {
+	if (12 != i2c_master_recv(ir->c, data, 12)) {
 		i2cdprintk("read error\n");
 		return -EIO;
 	}
@@ -267,7 +267,7 @@ static int get_key_pinnacle(struct IR_i2
 	unsigned int start = 0,parity = 0,code = 0;
 
 	/* poll IR chip */
-	if (4 != i2c_master_recv(&ir->c, b, 4)) {
+	if (4 != i2c_master_recv(ir->c, b, 4)) {
 		i2cdprintk("read error\n");
 		return -EIO;
 	}
@@ -683,14 +683,76 @@ void saa7134_input_fini(struct saa7134_d
 	dev->remote = NULL;
 }
 
-void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir)
+void saa7134_probe_i2c_ir(struct saa7134_dev *dev)
 {
+	struct i2c_board_info info;
+	const unsigned short addr_list[] = {
+		0x7a, 0x47, 0x71, 0x2d,
+		I2C_CLIENT_END
+	};
+
+	const unsigned short addr_list_msi[] = {
+		0x30, I2C_CLIENT_END
+	};
+	struct i2c_msg msg_msi = {
+		.addr = 0x50,
+		.flags = I2C_M_RD,
+		.len = 0,
+		.buf = NULL,
+	};
+
+	unsigned char subaddr, data;
+	struct i2c_msg msg_avermedia[] = { {
+		.addr = 0x40,
+		.flags = 0,
+		.len = 1,
+		.buf = &subaddr,
+	}, {
+		.addr = 0x40,
+		.flags = I2C_M_RD,
+		.len = 1,
+		.buf = &data,
+	} };
+
+	struct i2c_client *client;
+	int rc;
+
 	if (disable_ir) {
-		dprintk("Found supported i2c remote, but IR has been disabled\n");
-		ir->get_key=NULL;
+		dprintk("IR has been disabled, not probing for i2c remote\n");
+		return;
+	}
+
+	memset(&info, 0, sizeof(struct i2c_board_info));
+	strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
+	client = i2c_new_probed_device(&dev->i2c_adap, &info, addr_list);
+	if (client)
 		return;
+
+	/* MSI TV@nywhere Plus controller doesn't seem to
+	   respond to probes unless we read something from
+	   an existing device. Weird... */
+	rc = i2c_transfer(&dev->i2c_adap, &msg_msi, 1);
+	dprintk(KERN_DEBUG "probe 0x%02x @ %s: %s\n",
+		msg_msi.addr, dev->i2c_adap.name,
+		(1 == rc) ? "yes" : "no");
+	client = i2c_new_probed_device(&dev->i2c_adap, &info, addr_list_msi);
+	if (client)
+		return;
+
+	/* Special case for AVerMedia Cardbus remote */
+	subaddr = 0x0d;
+	rc = i2c_transfer(&dev->i2c_adap, msg_avermedia, 2);
+	dprintk(KERN_DEBUG "probe 0x%02x/0x%02x @ %s: %s\n",
+		msg_avermedia[0].addr, subaddr, dev->i2c_adap.name,
+		(2 == rc) ? "yes" : "no");
+	if (2 == rc) {
+		info.addr = msg_avermedia[0].addr;
+		i2c_new_device(&dev->i2c_adap, &info);
 	}
+}
 
+void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir)
+{
 	switch (dev->board) {
 	case SAA7134_BOARD_PINNACLE_PCTV_110i:
 	case SAA7134_BOARD_PINNACLE_PCTV_310i:
--- v4l-dvb.orig/linux/drivers/media/video/saa7134/saa7134.h	2009-04-17 14:36:51.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/saa7134/saa7134.h	2009-04-17 14:37:54.000000000 +0200
@@ -792,6 +792,7 @@ void saa7134_irq_oss_done(struct saa7134
 int  saa7134_input_init1(struct saa7134_dev *dev);
 void saa7134_input_fini(struct saa7134_dev *dev);
 void saa7134_input_irq(struct saa7134_dev *dev);
+void saa7134_probe_i2c_ir(struct saa7134_dev *dev);
 void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir);
 void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir);
 void saa7134_ir_stop(struct saa7134_dev *dev);
--- v4l-dvb.orig/linux/include/media/ir-kbd-i2c.h	2009-04-17 14:36:50.000000000 +0200
+++ v4l-dvb/linux/include/media/ir-kbd-i2c.h	2009-04-17 14:37:54.000000000 +0200
@@ -7,7 +7,7 @@ struct IR_i2c;
 
 struct IR_i2c {
 	IR_KEYTAB_TYPE         *ir_codes;
-	struct i2c_client      c;
+	struct i2c_client      *c;
 	struct input_dev       *input;
 	struct ir_input_state  ir;
 

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 3/6] ir-kbd-i2c: Use initialization data
  2009-04-17 20:29 [PATCH 0/6] ir-kbd-i2c conversion to the new i2c binding model (v2) Jean Delvare
  2009-04-17 20:30 ` [PATCH 1/6] ir-kbd-i2c: Don't use i2c_client.name for our own needs Jean Delvare
  2009-04-17 20:31 ` [PATCH 2/6] ir-kbd-i2c: Switch to the new-style device binding model Jean Delvare
@ 2009-04-17 20:32 ` Jean Delvare
  2009-04-17 20:32 ` [PATCH 4/6] ir-kbd-i2c: Don't assume all IR receivers are supported Jean Delvare
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Jean Delvare @ 2009-04-17 20:32 UTC (permalink / raw)
  To: LMML

For specific boards, pass initialization data to ir-kbd-i2c instead
of modifying the settings after the device is initialized. This is
more efficient and easier to read.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
---
 linux/drivers/media/video/cx231xx/cx231xx-cards.c |    3 
 linux/drivers/media/video/cx231xx/cx231xx-i2c.c   |   29 ------
 linux/drivers/media/video/cx231xx/cx231xx.h       |    1 
 linux/drivers/media/video/em28xx/em28xx-cards.c   |   31 +++----
 linux/drivers/media/video/em28xx/em28xx-i2c.c     |   22 -----
 linux/drivers/media/video/em28xx/em28xx.h         |    1 
 linux/drivers/media/video/ir-kbd-i2c.c            |   12 ++
 linux/drivers/media/video/saa7134/saa7134-i2c.c   |   28 ------
 linux/drivers/media/video/saa7134/saa7134-input.c |   88 ++++++++++-----------
 linux/drivers/media/video/saa7134/saa7134.h       |    1 
 linux/include/media/ir-kbd-i2c.h                  |    7 +
 11 files changed, 76 insertions(+), 147 deletions(-)

--- v4l-dvb.orig/linux/drivers/media/video/cx231xx/cx231xx-cards.c	2009-04-17 14:37:54.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/cx231xx/cx231xx-cards.c	2009-04-17 14:53:35.000000000 +0200
@@ -288,10 +288,7 @@ void cx231xx_register_i2c_ir(struct cx23
 		return;
 
 	/* REVISIT: instantiate IR device */
-}
 
-void cx231xx_set_ir(struct cx231xx *dev, struct IR_i2c *ir)
-{
 	/* detect & configure */
 	switch (dev->model) {
 
--- v4l-dvb.orig/linux/drivers/media/video/cx231xx/cx231xx-i2c.c	2009-04-17 14:37:54.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/cx231xx/cx231xx-i2c.c	2009-04-17 14:53:35.000000000 +0200
@@ -424,34 +424,6 @@ static u32 functionality(struct i2c_adap
 	return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_I2C;
 }
 
-/*
- * attach_inform()
- * gets called when a device attaches to the i2c bus
- * does some basic configuration
- */
-static int attach_inform(struct i2c_client *client)
-{
-	struct cx231xx_i2c *bus = i2c_get_adapdata(client->adapter);
-	struct cx231xx *dev = bus->dev;
-
-	switch (client->addr << 1) {
-	case 0x8e:
-		{
-			struct IR_i2c *ir = i2c_get_clientdata(client);
-			dprintk1(1, "attach_inform: IR detected (%s).\n",
-				 ir->phys);
-			cx231xx_set_ir(dev, ir);
-			break;
-		}
-		break;
-
-	default:
-		break;
-	}
-
-	return 0;
-}
-
 static struct i2c_algorithm cx231xx_algo = {
 	.master_xfer = cx231xx_i2c_xfer,
 	.functionality = functionality,
@@ -465,7 +437,6 @@ static struct i2c_adapter cx231xx_adap_t
 	.name = "cx231xx",
 	.id = I2C_HW_B_CX231XX,
 	.algo = &cx231xx_algo,
-	.client_register = attach_inform,
 };
 
 static struct i2c_client cx231xx_client_template = {
--- v4l-dvb.orig/linux/drivers/media/video/cx231xx/cx231xx.h	2009-04-17 14:37:54.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/cx231xx/cx231xx.h	2009-04-17 14:53:35.000000000 +0200
@@ -748,7 +748,6 @@ extern struct cx231xx_board cx231xx_boar
 extern struct usb_device_id cx231xx_id_table[];
 extern const unsigned int cx231xx_bcount;
 void cx231xx_register_i2c_ir(struct cx231xx *dev);
-void cx231xx_set_ir(struct cx231xx *dev, struct IR_i2c *ir);
 int cx231xx_tuner_callback(void *ptr, int component, int command, int arg);
 
 /* Provided by cx231xx-input.c */
--- v4l-dvb.orig/linux/drivers/media/video/em28xx/em28xx-cards.c	2009-04-17 14:37:54.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/em28xx/em28xx-cards.c	2009-04-17 14:53:35.000000000 +0200
@@ -1934,6 +1934,7 @@ static int em28xx_hint_board(struct em28
 void em28xx_register_i2c_ir(struct em28xx *dev)
 {
 	struct i2c_board_info info;
+	struct IR_i2c_init_data init_data;
 	const unsigned short addr_list[] = {
 		 0x30, 0x47, I2C_CLIENT_END
 	};
@@ -1942,12 +1943,9 @@ void em28xx_register_i2c_ir(struct em28x
 		return;
 
 	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);
-	i2c_new_probed_device(&dev->i2c_adap, &info, addr_list);
-}
 
-void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir)
-{
 	/* detect & configure */
 	switch (dev->model) {
 	case (EM2800_BOARD_UNKNOWN):
@@ -1956,22 +1954,19 @@ void em28xx_set_ir(struct em28xx *dev, s
 		break;
 	case (EM2800_BOARD_TERRATEC_CINERGY_200):
 	case (EM2820_BOARD_TERRATEC_CINERGY_250):
-		ir->ir_codes = ir_codes_em_terratec;
-		ir->get_key = em28xx_get_key_terratec;
-		snprintf(ir->name, sizeof(ir->name),
-			 "i2c IR (EM28XX Terratec)");
+		init_data.ir_codes = ir_codes_em_terratec;
+		init_data.get_key = em28xx_get_key_terratec;
+		init_data.name = "i2c IR (EM28XX Terratec)";
 		break;
 	case (EM2820_BOARD_PINNACLE_USB_2):
-		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)");
+		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)";
 		break;
 	case (EM2820_BOARD_HAUPPAUGE_WINTV_USB_2):
-		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)");
+		init_data.ir_codes = ir_codes_hauppauge_new;
+		init_data.get_key = em28xx_get_key_em_haup;
+		init_data.name = "i2c IR (EM2840 Hauppauge)";
 		break;
 	case (EM2820_BOARD_MSI_VOX_USB_2):
 		break;
@@ -1982,6 +1977,10 @@ void em28xx_set_ir(struct em28xx *dev, s
 	case (EM2800_BOARD_GRABBEEX_USB2800):
 		break;
 	}
+
+	if (init_data.name)
+		info.platform_data = &init_data;
+	i2c_new_probed_device(&dev->i2c_adap, &info, addr_list);
 }
 
 void em28xx_card_setup(struct em28xx *dev)
--- v4l-dvb.orig/linux/drivers/media/video/em28xx/em28xx-i2c.c	2009-04-17 14:37:54.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/em28xx/em28xx-i2c.c	2009-04-17 14:53:35.000000000 +0200
@@ -451,27 +451,6 @@ static u32 functionality(struct i2c_adap
 	return I2C_FUNC_SMBUS_EMUL;
 }
 
-/*
- * attach_inform()
- * gets called when a device attaches to the i2c bus
- * does some basic configuration
- */
-static int attach_inform(struct i2c_client *client)
-{
-	struct em28xx *dev = client->adapter->algo_data;
-	struct IR_i2c *ir = i2c_get_clientdata(client);
-
-	switch (client->addr << 1) {
-	case 0x60:
-	case 0x8e:
-		dprintk1(1, "attach_inform: IR detected (%s).\n", ir->phys);
-		em28xx_set_ir(dev, ir);
-		break;
-	}
-
-	return 0;
-}
-
 static struct i2c_algorithm em28xx_algo = {
 	.master_xfer   = em28xx_i2c_xfer,
 	.functionality = functionality,
@@ -488,7 +467,6 @@ static struct i2c_adapter em28xx_adap_te
 	.name = "em28xx",
 	.id = I2C_HW_B_EM28XX,
 	.algo = &em28xx_algo,
-	.client_register = attach_inform,
 };
 
 static struct i2c_client em28xx_client_template = {
--- v4l-dvb.orig/linux/drivers/media/video/em28xx/em28xx.h	2009-04-17 14:37:54.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/em28xx/em28xx.h	2009-04-17 14:53:35.000000000 +0200
@@ -650,7 +650,6 @@ extern struct em28xx_board em28xx_boards
 extern struct usb_device_id em28xx_id_table[];
 extern const unsigned int em28xx_bcount;
 void em28xx_register_i2c_ir(struct em28xx *dev);
-void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir);
 int em28xx_tuner_callback(void *ptr, int component, int command, int arg);
 void em28xx_release_resources(struct em28xx *dev);
 
--- v4l-dvb.orig/linux/drivers/media/video/ir-kbd-i2c.c	2009-04-17 14:37:54.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/ir-kbd-i2c.c	2009-04-17 14:53:35.000000000 +0200
@@ -307,7 +307,7 @@ static void ir_work(struct work_struct *
 static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
 	IR_KEYTAB_TYPE *ir_codes = NULL;
-	char *name;
+	const char *name;
 	int ir_type;
 	struct IR_i2c *ir;
 	struct input_dev *input_dev;
@@ -395,6 +395,16 @@ static int ir_probe(struct i2c_client *c
 		goto err_out_free;
 	}
 
+	/* Let the caller override settings */
+	if (client->dev.platform_data) {
+		const struct IR_i2c_init_data *init_data =
+						client->dev.platform_data;
+
+		ir_codes = init_data->ir_codes;
+		name = init_data->name;
+		ir->get_key = init_data->get_key;
+	}
+
 	/* Sets name */
 	snprintf(ir->name, sizeof(ir->name), "i2c IR (%s)", name);
 	ir->ir_codes = ir_codes;
--- v4l-dvb.orig/linux/drivers/media/video/saa7134/saa7134-i2c.c	2009-04-17 14:37:54.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/saa7134/saa7134-i2c.c	2009-04-17 14:53:35.000000000 +0200
@@ -326,33 +326,6 @@ static u32 functionality(struct i2c_adap
 	return I2C_FUNC_SMBUS_EMUL;
 }
 
-static int attach_inform(struct i2c_client *client)
-{
-	struct saa7134_dev *dev = client->adapter->algo_data;
-
-	d1printk( "%s i2c attach [addr=0x%x,client=%s]\n",
-		client->driver->driver.name, client->addr, client->name);
-
-	/* Am I an i2c remote control? */
-
-	switch (client->addr) {
-		case 0x7a:
-		case 0x47:
-		case 0x71:
-		case 0x2d:
-		case 0x30:
-		{
-			struct IR_i2c *ir = i2c_get_clientdata(client);
-			d1printk("%s i2c IR detected (%s).\n",
-				 client->driver->driver.name, ir->phys);
-			saa7134_set_i2c_ir(dev,ir);
-			break;
-		}
-	}
-
-	return 0;
-}
-
 static struct i2c_algorithm saa7134_algo = {
 	.master_xfer   = saa7134_i2c_xfer,
 	.functionality = functionality,
@@ -369,7 +342,6 @@ static struct i2c_adapter saa7134_adap_t
 	.name          = "saa7134",
 	.id            = I2C_HW_SAA7134,
 	.algo          = &saa7134_algo,
-	.client_register = attach_inform,
 };
 
 static struct i2c_client saa7134_client_template = {
--- v4l-dvb.orig/linux/drivers/media/video/saa7134/saa7134-input.c	2009-04-17 14:37:54.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/saa7134/saa7134-input.c	2009-04-17 14:53:35.000000000 +0200
@@ -686,6 +686,7 @@ void saa7134_input_fini(struct saa7134_d
 void saa7134_probe_i2c_ir(struct saa7134_dev *dev)
 {
 	struct i2c_board_info info;
+	struct IR_i2c_init_data init_data;
 	const unsigned short addr_list[] = {
 		0x7a, 0x47, 0x71, 0x2d,
 		I2C_CLIENT_END
@@ -723,7 +724,49 @@ void saa7134_probe_i2c_ir(struct saa7134
 	}
 
 	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);
+
+	switch (dev->board) {
+	case SAA7134_BOARD_PINNACLE_PCTV_110i:
+	case SAA7134_BOARD_PINNACLE_PCTV_310i:
+		init_data.name = "Pinnacle PCTV";
+		if (pinnacle_remote == 0) {
+			init_data.get_key = get_key_pinnacle_color;
+			init_data.ir_codes = ir_codes_pinnacle_color;
+		} else {
+			init_data.get_key = get_key_pinnacle_grey;
+			init_data.ir_codes = ir_codes_pinnacle_grey;
+		}
+		break;
+	case SAA7134_BOARD_UPMOST_PURPLE_TV:
+		init_data.name = "Purple TV";
+		init_data.get_key = get_key_purpletv;
+		init_data.ir_codes = ir_codes_purpletv;
+		break;
+	case SAA7134_BOARD_MSI_TVATANYWHERE_PLUS:
+		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;
+		break;
+	case SAA7134_BOARD_HAUPPAUGE_HVR1110:
+		init_data.name = "HVR 1110";
+		init_data.get_key = get_key_hvr1110;
+		init_data.ir_codes = ir_codes_hauppauge_new;
+		break;
+	case SAA7134_BOARD_BEHOLD_607_9FM:
+	case SAA7134_BOARD_BEHOLD_M6:
+	case SAA7134_BOARD_BEHOLD_M63:
+	case SAA7134_BOARD_BEHOLD_M6_EXTRA:
+	case SAA7134_BOARD_BEHOLD_H6:
+		init_data.name = "BeholdTV";
+		init_data.get_key = get_key_beholdm6xx;
+		init_data.ir_codes = ir_codes_behold;
+		break;
+	}
+
+	if (init_data.name)
+		info.platform_data = &init_data;
 	client = i2c_new_probed_device(&dev->i2c_adap, &info, addr_list);
 	if (client)
 		return;
@@ -751,51 +794,6 @@ void saa7134_probe_i2c_ir(struct saa7134
 	}
 }
 
-void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir)
-{
-	switch (dev->board) {
-	case SAA7134_BOARD_PINNACLE_PCTV_110i:
-	case SAA7134_BOARD_PINNACLE_PCTV_310i:
-		snprintf(ir->name, sizeof(ir->name), "Pinnacle PCTV");
-		if (pinnacle_remote == 0) {
-			ir->get_key   = get_key_pinnacle_color;
-			ir->ir_codes = ir_codes_pinnacle_color;
-		} else {
-			ir->get_key   = get_key_pinnacle_grey;
-			ir->ir_codes = ir_codes_pinnacle_grey;
-		}
-		break;
-	case SAA7134_BOARD_UPMOST_PURPLE_TV:
-		snprintf(ir->name, sizeof(ir->name), "Purple TV");
-		ir->get_key   = get_key_purpletv;
-		ir->ir_codes  = ir_codes_purpletv;
-		break;
-	case SAA7134_BOARD_MSI_TVATANYWHERE_PLUS:
-		snprintf(ir->name, sizeof(ir->name), "MSI TV@nywhere Plus");
-		ir->get_key  = get_key_msi_tvanywhere_plus;
-		ir->ir_codes = ir_codes_msi_tvanywhere_plus;
-		break;
-	case SAA7134_BOARD_HAUPPAUGE_HVR1110:
-		snprintf(ir->name, sizeof(ir->name), "HVR 1110");
-		ir->get_key   = get_key_hvr1110;
-		ir->ir_codes  = ir_codes_hauppauge_new;
-		break;
-	case SAA7134_BOARD_BEHOLD_607_9FM:
-	case SAA7134_BOARD_BEHOLD_M6:
-	case SAA7134_BOARD_BEHOLD_M63:
-	case SAA7134_BOARD_BEHOLD_M6_EXTRA:
-	case SAA7134_BOARD_BEHOLD_H6:
-		snprintf(ir->name, sizeof(ir->name), "BeholdTV");
-		ir->get_key   = get_key_beholdm6xx;
-		ir->ir_codes  = ir_codes_behold;
-		break;
-	default:
-		dprintk("Shouldn't get here: Unknown board %x for I2C IR?\n",dev->board);
-		break;
-	}
-
-}
-
 static int saa7134_rc5_irq(struct saa7134_dev *dev)
 {
 	struct card_ir *ir = dev->remote;
--- v4l-dvb.orig/linux/drivers/media/video/saa7134/saa7134.h	2009-04-17 14:37:54.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/saa7134/saa7134.h	2009-04-17 14:53:35.000000000 +0200
@@ -793,7 +793,6 @@ int  saa7134_input_init1(struct saa7134_
 void saa7134_input_fini(struct saa7134_dev *dev);
 void saa7134_input_irq(struct saa7134_dev *dev);
 void saa7134_probe_i2c_ir(struct saa7134_dev *dev);
-void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir);
 void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir);
 void saa7134_ir_stop(struct saa7134_dev *dev);
 
--- v4l-dvb.orig/linux/include/media/ir-kbd-i2c.h	2009-04-17 14:37:54.000000000 +0200
+++ v4l-dvb/linux/include/media/ir-kbd-i2c.h	2009-04-17 14:53:35.000000000 +0200
@@ -19,4 +19,11 @@ struct IR_i2c {
 	char                   phys[32];
 	int                    (*get_key)(struct IR_i2c*, u32*, u32*);
 };
+
+/* Can be passed when instantiating an ir_video i2c device */
+struct IR_i2c_init_data {
+	IR_KEYTAB_TYPE         *ir_codes;
+	const char             *name;
+	int                    (*get_key)(struct IR_i2c*, u32*, u32*);
+};
 #endif

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 4/6] ir-kbd-i2c: Don't assume all IR receivers are supported
  2009-04-17 20:29 [PATCH 0/6] ir-kbd-i2c conversion to the new i2c binding model (v2) Jean Delvare
                   ` (2 preceding siblings ...)
  2009-04-17 20:32 ` [PATCH 3/6] ir-kbd-i2c: Use initialization data Jean Delvare
@ 2009-04-17 20:32 ` Jean Delvare
  2009-04-17 20:33 ` [PATCH 5/6] saa7134: Simplify handling of IR on MSI TV@nywhere Plus Jean Delvare
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Jean Delvare @ 2009-04-17 20:32 UTC (permalink / raw)
  To: LMML

The code in ir_probe makes the dangerous assumption that all IR
receivers are supported by the driver. The new i2c model makes it
possible for bridge drivers to instantiate IR devices before they are
supported, therefore the ir-kbd-i2c drivers must be made more robust
to not spam the logs or even crash on unsupported IR devices. Simply,
the driver will not bind to the unsupported devices.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Andy Walls <awalls@radix.net>
---
 linux/drivers/media/video/ir-kbd-i2c.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

--- v4l-dvb.orig/linux/drivers/media/video/ir-kbd-i2c.c	2009-04-07 21:35:53.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/ir-kbd-i2c.c	2009-04-07 22:49:10.000000000 +0200
@@ -307,7 +307,7 @@ static void ir_work(struct work_struct *
 static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
 	IR_KEYTAB_TYPE *ir_codes = NULL;
-	const char *name;
+	const char *name = NULL;
 	int ir_type;
 	struct IR_i2c *ir;
 	struct input_dev *input_dev;
@@ -389,8 +389,7 @@ static int ir_probe(struct i2c_client *c
 		ir_codes    = ir_codes_avermedia_cardbus;
 		break;
 	default:
-		/* shouldn't happen */
-		printk(DEVNAME ": Huh? unknown i2c address (0x%02x)?\n", addr);
+		dprintk(1, DEVNAME ": Unsupported i2c address 0x%02x\n", addr);
 		err = -ENODEV;
 		goto err_out_free;
 	}
@@ -405,6 +404,14 @@ static int ir_probe(struct i2c_client *c
 		ir->get_key = init_data->get_key;
 	}
 
+	/* Make sure we are all setup before going on */
+	if (!name || !ir->get_key || !ir_codes) {
+		dprintk(1, DEVNAME ": Unsupported device at address 0x%02x\n",
+			addr);
+		err = -ENODEV;
+		goto err_out_free;
+	}
+
 	/* Sets name */
 	snprintf(ir->name, sizeof(ir->name), "i2c IR (%s)", name);
 	ir->ir_codes = ir_codes;

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 5/6] saa7134: Simplify handling of IR on MSI TV@nywhere Plus
  2009-04-17 20:29 [PATCH 0/6] ir-kbd-i2c conversion to the new i2c binding model (v2) Jean Delvare
                   ` (3 preceding siblings ...)
  2009-04-17 20:32 ` [PATCH 4/6] ir-kbd-i2c: Don't assume all IR receivers are supported Jean Delvare
@ 2009-04-17 20:33 ` Jean Delvare
  2009-04-17 20:34 ` [PATCH 6/6] saa7134: Simplify handling of IR on AVerMedia Cardbus E506R Jean Delvare
  2009-04-29 12:29 ` [PATCH 0/6] ir-kbd-i2c conversion to the new i2c binding model (v2) Jean Delvare
  6 siblings, 0 replies; 20+ messages in thread
From: Jean Delvare @ 2009-04-17 20:33 UTC (permalink / raw)
  To: LMML

Now that we instantiate I2C IR devices explicitly, we can skip probing
altogether on boards where the I2C IR device address is known. The MSI
TV@nywhere Plus is one of these boards.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
---
 linux/drivers/media/video/saa7134/saa7134-input.c |   28 +++++++++++----------
 1 file changed, 15 insertions(+), 13 deletions(-)

--- v4l-dvb.orig/linux/drivers/media/video/saa7134/saa7134-input.c	2009-04-17 14:53:35.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/saa7134/saa7134-input.c	2009-04-17 15:10:55.000000000 +0200
@@ -692,9 +692,6 @@ void saa7134_probe_i2c_ir(struct saa7134
 		I2C_CLIENT_END
 	};
 
-	const unsigned short addr_list_msi[] = {
-		0x30, I2C_CLIENT_END
-	};
 	struct i2c_msg msg_msi = {
 		.addr = 0x50,
 		.flags = I2C_M_RD,
@@ -748,6 +745,15 @@ void saa7134_probe_i2c_ir(struct saa7134
 		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;
+		info.addr = 0x30;
+		/* MSI TV@nywhere Plus controller doesn't seem to
+		   respond to probes unless we read something from
+		   an existing device. Weird...
+		   REVISIT: might no longer be needed */
+		rc = i2c_transfer(&dev->i2c_adap, &msg_msi, 1);
+		dprintk(KERN_DEBUG "probe 0x%02x @ %s: %s\n",
+			msg_msi.addr, dev->i2c_adap.name,
+			(1 == rc) ? "yes" : "no");
 		break;
 	case SAA7134_BOARD_HAUPPAUGE_HVR1110:
 		init_data.name = "HVR 1110";
@@ -767,18 +773,14 @@ void saa7134_probe_i2c_ir(struct saa7134
 
 	if (init_data.name)
 		info.platform_data = &init_data;
-	client = i2c_new_probed_device(&dev->i2c_adap, &info, addr_list);
-	if (client)
+	/* No need to probe if address is known */
+	if (info.addr) {
+		i2c_new_device(&dev->i2c_adap, &info);
 		return;
+	}
 
-	/* MSI TV@nywhere Plus controller doesn't seem to
-	   respond to probes unless we read something from
-	   an existing device. Weird... */
-	rc = i2c_transfer(&dev->i2c_adap, &msg_msi, 1);
-	dprintk(KERN_DEBUG "probe 0x%02x @ %s: %s\n",
-		msg_msi.addr, dev->i2c_adap.name,
-		(1 == rc) ? "yes" : "no");
-	client = i2c_new_probed_device(&dev->i2c_adap, &info, addr_list_msi);
+	/* Address not known, fallback to probing */
+	client = i2c_new_probed_device(&dev->i2c_adap, &info, addr_list);
 	if (client)
 		return;
 

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 6/6] saa7134: Simplify handling of IR on AVerMedia Cardbus E506R
  2009-04-17 20:29 [PATCH 0/6] ir-kbd-i2c conversion to the new i2c binding model (v2) Jean Delvare
                   ` (4 preceding siblings ...)
  2009-04-17 20:33 ` [PATCH 5/6] saa7134: Simplify handling of IR on MSI TV@nywhere Plus Jean Delvare
@ 2009-04-17 20:34 ` Jean Delvare
  2009-04-29 12:29 ` [PATCH 0/6] ir-kbd-i2c conversion to the new i2c binding model (v2) Jean Delvare
  6 siblings, 0 replies; 20+ messages in thread
From: Jean Delvare @ 2009-04-17 20:34 UTC (permalink / raw)
  To: LMML

Now that we instantiate I2C IR devices explicitly, we can skip probing
altogether on boards where the I2C IR device address is known. The
AVerMedia Cardbus E506R is one of these boards.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Tested-by: Oldrich Jedlicka <oldium.pro@seznam.cz>
---
 linux/drivers/media/video/saa7134/saa7134-input.c |   32 ++-------------------
 1 file changed, 4 insertions(+), 28 deletions(-)

--- v4l-dvb.orig/linux/drivers/media/video/saa7134/saa7134-input.c	2009-04-17 15:10:55.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/saa7134/saa7134-input.c	2009-04-17 15:44:21.000000000 +0200
@@ -699,20 +699,6 @@ void saa7134_probe_i2c_ir(struct saa7134
 		.buf = NULL,
 	};
 
-	unsigned char subaddr, data;
-	struct i2c_msg msg_avermedia[] = { {
-		.addr = 0x40,
-		.flags = 0,
-		.len = 1,
-		.buf = &subaddr,
-	}, {
-		.addr = 0x40,
-		.flags = I2C_M_RD,
-		.len = 1,
-		.buf = &data,
-	} };
-
-	struct i2c_client *client;
 	int rc;
 
 	if (disable_ir) {
@@ -769,6 +755,9 @@ void saa7134_probe_i2c_ir(struct saa7134
 		init_data.get_key = get_key_beholdm6xx;
 		init_data.ir_codes = ir_codes_behold;
 		break;
+	case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
+		info.addr = 0x40;
+		break;
 	}
 
 	if (init_data.name)
@@ -780,20 +769,7 @@ void saa7134_probe_i2c_ir(struct saa7134
 	}
 
 	/* Address not known, fallback to probing */
-	client = i2c_new_probed_device(&dev->i2c_adap, &info, addr_list);
-	if (client)
-		return;
-
-	/* Special case for AVerMedia Cardbus remote */
-	subaddr = 0x0d;
-	rc = i2c_transfer(&dev->i2c_adap, msg_avermedia, 2);
-	dprintk(KERN_DEBUG "probe 0x%02x/0x%02x @ %s: %s\n",
-		msg_avermedia[0].addr, subaddr, dev->i2c_adap.name,
-		(2 == rc) ? "yes" : "no");
-	if (2 == rc) {
-		info.addr = msg_avermedia[0].addr;
-		i2c_new_device(&dev->i2c_adap, &info);
-	}
+	i2c_new_probed_device(&dev->i2c_adap, &info, addr_list);
 }
 
 static int saa7134_rc5_irq(struct saa7134_dev *dev)

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/6] ir-kbd-i2c: Switch to the new-style device binding model
  2009-04-17 20:31 ` [PATCH 2/6] ir-kbd-i2c: Switch to the new-style device binding model Jean Delvare
@ 2009-04-17 23:35   ` Mike Isely
  2009-04-18  9:25     ` Jean Delvare
  0 siblings, 1 reply; 20+ messages in thread
From: Mike Isely @ 2009-04-17 23:35 UTC (permalink / raw)
  To: Jean Delvare; +Cc: LMML, Mauro Carvalho Chehab


I thought we were going to leave the pvrusb2 driver out of this since 
I've already got a change ready that also includes additional logic to 
take into account the properties of the hardware device (i.e. only 
activate ir-kbd-i2c when we know it has a chance of working).

  -Mike


On Fri, 17 Apr 2009, Jean Delvare wrote:

> Let card drivers probe for IR receiver devices and instantiate them if
> found. Ultimately it would be better if we could stop probing
> completely, but I suspect this won't be possible for all card types.
> 
> There's certainly room for cleanups. For example, some drivers are
> sharing I2C adapter IDs, so they also had to share the list of I2C
> addresses being probed for an IR receiver. Now that each driver
> explicitly says which addresses should be probed, maybe some addresses
> can be dropped from some drivers.
> 
> Also, the special cases in saa7134-i2c should probably be handled on a
> per-board basis. This would be more efficient and less risky than always
> probing extra addresses on all boards. I'll give it a try later.
> 
> Signed-off-by: Jean Delvare <khali@linux-fr.org>
> Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
> Cc: Hans Verkuil <hverkuil@xs4all.nl>
> Cc: Andy Walls <awalls@radix.net>
> Cc: Mike Isely <isely@pobox.com>
> ---
>  linux/drivers/media/video/bt8xx/bttv-i2c.c           |   21 +
>  linux/drivers/media/video/cx231xx/cx231xx-cards.c    |   11 
>  linux/drivers/media/video/cx231xx/cx231xx-i2c.c      |    3 
>  linux/drivers/media/video/cx231xx/cx231xx.h          |    1 
>  linux/drivers/media/video/cx23885/cx23885-i2c.c      |   12 +
>  linux/drivers/media/video/cx88/cx88-i2c.c            |   13 +
>  linux/drivers/media/video/em28xx/em28xx-cards.c      |   20 +
>  linux/drivers/media/video/em28xx/em28xx-i2c.c        |    3 
>  linux/drivers/media/video/em28xx/em28xx-input.c      |    6 
>  linux/drivers/media/video/em28xx/em28xx.h            |    1 
>  linux/drivers/media/video/ir-kbd-i2c.c               |  200 +++---------------
>  linux/drivers/media/video/ivtv/ivtv-i2c.c            |   31 ++
>  linux/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c |   24 ++
>  linux/drivers/media/video/saa7134/saa7134-i2c.c      |    3 
>  linux/drivers/media/video/saa7134/saa7134-input.c    |   86 ++++++-
>  linux/drivers/media/video/saa7134/saa7134.h          |    1 
>  linux/include/media/ir-kbd-i2c.h                     |    2 
>  17 files changed, 244 insertions(+), 194 deletions(-)

   [...]

-- 

Mike Isely
isely @ pobox (dot) com
PGP: 03 54 43 4D 75 E5 CC 92 71 16 01 E2 B5 F5 C1 E8

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/6] ir-kbd-i2c: Switch to the new-style device binding model
  2009-04-17 23:35   ` Mike Isely
@ 2009-04-18  9:25     ` Jean Delvare
  2009-04-18 13:16       ` Jean Delvare
  0 siblings, 1 reply; 20+ messages in thread
From: Jean Delvare @ 2009-04-18  9:25 UTC (permalink / raw)
  To: Mike Isely; +Cc: isely, LMML, Mauro Carvalho Chehab

Hi Mike,

On Fri, 17 Apr 2009 18:35:55 -0500 (CDT), Mike Isely wrote:
> I thought we were going to leave the pvrusb2 driver out of this since 
> I've already got a change ready that also includes additional logic to 
> take into account the properties of the hardware device (i.e. only 
> activate ir-kbd-i2c when we know it has a chance of working).

Hmm, I thought that our latest discussions had (at least partly)
obsoleted your patches. Remember that we want to always instantiate
ir_video I2C devices even when ir-kbd-i2c can't driver them, otherwise
lirc won't be able to bind to the devices in question as soon as the
legacy binding model is gone. So the conditionals in your second patch
(which is all that makes it differ from mine) are no longer desirable.

I'll work on lirc patches today or tomorrow, so that lirc doesn't break
when my patches hit mainline.

Your first patch is still interesting but it is independent from my own
patches, so it can be merged before or after, it doesn't matter.

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/6] ir-kbd-i2c: Switch to the new-style device binding model
  2009-04-18  9:25     ` Jean Delvare
@ 2009-04-18 13:16       ` Jean Delvare
  2009-04-18 13:53         ` Mike Isely
  0 siblings, 1 reply; 20+ messages in thread
From: Jean Delvare @ 2009-04-18 13:16 UTC (permalink / raw)
  To: Mike Isely; +Cc: isely, LMML, Mauro Carvalho Chehab

Hi again Mike,

On Sat, 18 Apr 2009 11:25:19 +0200, Jean Delvare wrote:
> On Fri, 17 Apr 2009 18:35:55 -0500 (CDT), Mike Isely wrote:
> > I thought we were going to leave the pvrusb2 driver out of this since 
> > I've already got a change ready that also includes additional logic to 
> > take into account the properties of the hardware device (i.e. only 
> > activate ir-kbd-i2c when we know it has a chance of working).
> 
> Hmm, I thought that our latest discussions had (at least partly)
> obsoleted your patches. Remember that we want to always instantiate
> ir_video I2C devices even when ir-kbd-i2c can't driver them, otherwise
> lirc won't be able to bind to the devices in question as soon as the
> legacy binding model is gone. So the conditionals in your second patch
> (which is all that makes it differ from mine) are no longer desirable.
> 
> I'll work on lirc patches today or tomorrow, so that lirc doesn't break
> when my patches hit mainline.

Speaking of this: do you know all the I2C addresses that can host IR
devices on pvrusb2 cards? I understand that the only address supported
by ir-kbd-i2c is 0x18, but I also need to know the addresses supported
by lirc_i2c and possibly lirc_zilog, if you happen to know this.

Thanks,
-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/6] ir-kbd-i2c: Switch to the new-style device binding model
  2009-04-18 13:16       ` Jean Delvare
@ 2009-04-18 13:53         ` Mike Isely
  2009-04-23  9:00           ` Jean Delvare
  0 siblings, 1 reply; 20+ messages in thread
From: Mike Isely @ 2009-04-18 13:53 UTC (permalink / raw)
  To: Jean Delvare; +Cc: LMML, Mauro Carvalho Chehab

On Sat, 18 Apr 2009, Jean Delvare wrote:

> Hi again Mike,
> 
> On Sat, 18 Apr 2009 11:25:19 +0200, Jean Delvare wrote:
> > On Fri, 17 Apr 2009 18:35:55 -0500 (CDT), Mike Isely wrote:
> > > I thought we were going to leave the pvrusb2 driver out of this since 
> > > I've already got a change ready that also includes additional logic to 
> > > take into account the properties of the hardware device (i.e. only 
> > > activate ir-kbd-i2c when we know it has a chance of working).
> > 
> > Hmm, I thought that our latest discussions had (at least partly)
> > obsoleted your patches. Remember that we want to always instantiate
> > ir_video I2C devices even when ir-kbd-i2c can't driver them, otherwise
> > lirc won't be able to bind to the devices in question as soon as the
> > legacy binding model is gone. So the conditionals in your second patch
> > (which is all that makes it differ from mine) are no longer desirable.

Jean:

The differences between my patch(es) and yours are:

1. My patch only attempts to bind the driver if the hardware actually 
supports it.

2. My patch selects the right I2C address for the case(s) where it makes 
sense to bind.

3. My patch provides a module option to completely disable binding.

You are probably thinking about (3) but you forgot that I had also taken 
care of (1).  Difference (1) is why I don't want your patch.  If your 
patch gets merged I will have to partially redo my patch to make (1) 
work again.

When I had issued my pull request to Mauro (which he didn't pull), there 
were actually 2 patches.  The first one dealt with (1) and the second 
dealt with (2) and (3), while taking advantage of (1).  Had Mauro pulled 
those patches at that time then you could have made further changes on 
top without losing (1).  But since he didn't, it's best just to leave 
the pvrusb2 driver alone and I'll make the needed additional change(s) 
there after your stuff is merged.


> > 
> > I'll work on lirc patches today or tomorrow, so that lirc doesn't break
> > when my patches hit mainline.
> 
> Speaking of this: do you know all the I2C addresses that can host IR
> devices on pvrusb2 cards? I understand that the only address supported
> by ir-kbd-i2c is 0x18, but I also need to know the addresses supported
> by lirc_i2c and possibly lirc_zilog, if you happen to know this.

Right now I only care about 0x18 (for 29xxx and early 24xxx devices).  
I noticed the thread where Andy got IR reception to work with ir-kbd-i2c 
using 0x71 (lirc_zilog type) and I suspect that same set of ir-kbd-i2c 
changes will probably work with the pvrusb2 driver for MCE 24xxx and 
HVR-1900/HVR-1950 devices.  But I figured once Andy's stuff gets into 
ir-kbd-i2c I'd simply test for this and if it worked I would make the 
appropriate adjustments in the pvrusb2 driver to enable ir-kbd-i2c 
binding in those cases as well (an easy change).  However even with that 
change, there are other pvrusb2-driven devices that cannot support 
ir-kbd-i2c.

  -Mike


-- 

Mike Isely
isely @ pobox (dot) com
PGP: 03 54 43 4D 75 E5 CC 92 71 16 01 E2 B5 F5 C1 E8

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/6] ir-kbd-i2c: Switch to the new-style device binding model
  2009-04-18 13:53         ` Mike Isely
@ 2009-04-23  9:00           ` Jean Delvare
  2009-04-24  2:44             ` Mike Isely
  0 siblings, 1 reply; 20+ messages in thread
From: Jean Delvare @ 2009-04-23  9:00 UTC (permalink / raw)
  To: Mike Isely; +Cc: isely, LMML, Mauro Carvalho Chehab

Hi Mike,

Sorry for the late answer.

On Sat, 18 Apr 2009 08:53:35 -0500 (CDT), Mike Isely wrote:
> On Sat, 18 Apr 2009, Jean Delvare wrote:
> > On Sat, 18 Apr 2009 11:25:19 +0200, Jean Delvare wrote:
> > > Hmm, I thought that our latest discussions had (at least partly)
> > > obsoleted your patches. Remember that we want to always instantiate
> > > ir_video I2C devices even when ir-kbd-i2c can't driver them, otherwise
> > > lirc won't be able to bind to the devices in question as soon as the
> > > legacy binding model is gone. So the conditionals in your second patch
> > > (which is all that makes it differ from mine) are no longer desirable.
> 
> Jean:
> 
> The differences between my patch(es) and yours are:
> 
> 1. My patch only attempts to bind the driver if the hardware actually 
> supports it.

That's not clear to me. I seem to understand that your patch
instantiates the ir_video device if and only if the ir-kbd-i2c driver
supports it. This is not what we want to do. We want to create the
ir_video device if an IR receiver exists, even if ir-kbd-i2c doesn't
support it. The reason is that ir-kbd-i2c could be extended to support
the IR receiver in question in the future, and that alternative drivers
(lirc_i2c comes to mind) could also be used.

I also don't understand why you use i2c_new_probed_device() rather than
i2c_new_device() if you already know for sure that the IR receiver
device is present?

> 2. My patch selects the right I2C address for the case(s) where it makes 
> sense to bind.

This is a good thing, although your implementation isn't exactly what I
would expect. The address list should depend on the value of
hdw->ir_scheme_active. At the moment you support only 2 schemes and
they happen to use the same I2C address, but I presume this will change
in the future.

> 3. My patch provides a module option to completely disable binding.

I agree this can be useful, as discussed earlier, although I still
object to the name you chose (disable_autoload_ir_kbd). This module
option is only remotely related to the i2c binding model change.

> You are probably thinking about (3) but you forgot that I had also taken 
> care of (1).  Difference (1) is why I don't want your patch.  If your 
> patch gets merged I will have to partially redo my patch to make (1) 
> work again.

This is correct. But if your second patch is merged before my own
changes, then IR support will be broken for all pvrusb2 users, unless
they temporarily load the driver with disable_autoload_ir_kbd=1. But
they will have to remove the parameter as soon as my own patches are
merged. This approach doesn't strike me as the best user experience.

If my patches are merged first and yours go second (which I admit means
you'll have to adjust your patches a bit) then everything will keep
working for the user. This is the reason why I was proposing this order.

> When I had issued my pull request to Mauro (which he didn't pull), there 
> were actually 2 patches.  The first one dealt with (1) and the second 
> dealt with (2) and (3), while taking advantage of (1).  Had Mauro pulled 
> those patches at that time then you could have made further changes on 
> top without losing (1).  But since he didn't, it's best just to leave 
> the pvrusb2 driver alone and I'll make the needed additional change(s) 
> there after your stuff is merged.

I can't "leave the pvrusb2 driver alone", unless you consider it
acceptable that your users lose IR support between my patches and
yours. When ir-kbd-i2c is converted to the new-style i2c binding, all
bridge drivers must be updated too.

> > > I'll work on lirc patches today or tomorrow, so that lirc doesn't break
> > > when my patches hit mainline.
> > 
> > Speaking of this: do you know all the I2C addresses that can host IR
> > devices on pvrusb2 cards? I understand that the only address supported
> > by ir-kbd-i2c is 0x18, but I also need to know the addresses supported
> > by lirc_i2c and possibly lirc_zilog, if you happen to know this.
> 
> Right now I only care about 0x18 (for 29xxx and early 24xxx devices).

I've seen this, but this isn't my question. If lirc_i2c supports other
IR devices that are present on pvrusb2 devices, we must declare them as
well so that we don't break lirc_i2c. So, once again: do you know all
the I2C addresses where pvrusb2 cards can have IR devices?

> I noticed the thread where Andy got IR reception to work with ir-kbd-i2c 
> using 0x71 (lirc_zilog type) and I suspect that same set of ir-kbd-i2c 
> changes will probably work with the pvrusb2 driver for MCE 24xxx and 
> HVR-1900/HVR-1950 devices.  But I figured once Andy's stuff gets into 
> ir-kbd-i2c I'd simply test for this and if it worked I would make the 
> appropriate adjustments in the pvrusb2 driver to enable ir-kbd-i2c 
> binding in those cases as well (an easy change).  However even with that 
> change, there are other pvrusb2-driven devices that cannot support 
> ir-kbd-i2c.

I'm worried that this means doing several changes first and only then
converting ir-kbd-i2c to the new i2c binding model. Similar to Mauro
who was suggesting that we should merge lirc in the kernel first and
only the convert to the new i2c model. There is really no good reason to
delay the i2c binding model change, and I would like to remind everyone
that my point here was to take care of that quickly because it is
delaying other i2c changes.

I am willing to collaborate with you v4l-dvb people, but if your answer
is "we'll do many unrelated changes first and then we'll look at your
patches", this isn't acceptable. I would hate to push the changes to
Linus' tree directly without going through the v4l-dvb tree, as I know
this means more work for you, but if you do not give me any other
choice, it might happen.

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/6] ir-kbd-i2c: Switch to the new-style device binding model
  2009-04-23  9:00           ` Jean Delvare
@ 2009-04-24  2:44             ` Mike Isely
  2009-05-02  1:30               ` Mike Isely
  0 siblings, 1 reply; 20+ messages in thread
From: Mike Isely @ 2009-04-24  2:44 UTC (permalink / raw)
  To: Jean Delvare; +Cc: LMML, Mauro Carvalho Chehab, isely


Hi Jean,

I had actually written out a longer, detailed, point-by-point reply 
earlier today, but before I could finish it I got interrupted with a 
crisis.  And then another.  And that's kind of how my day went.  Now I'm 
finally back to this, but I have another e-mail debacle to immediately 
deal with (thank you pobox.com, not!) so I'm tossing that unfinished 
lengthy reply.  I think I can sum this whole thing up very simply.  
Here's what I think should be happening:

1a. Your existing IR changeset, minus the pvrusb2 changes, should be 
merged.

1b. In parallel with (1a) I modify my pvrusb2 changeset to use the right 
module name and I adjust the driver option name to match.

2. My pvrusb2 changeset, with changes from (1b) is merged.

3. Andy's proposed change for ir_kbd_i2c to support additional IR 
devices is investigated and probably merged.

4. I test the changed ir_kbd_i2c against additional pvrusb2 devices 
known not to work previously with ir_kbd_i2c.  If they work, then I will 
create a pvrusb2 patch to load ir_video in those cases as well as the 
cases already set up (which still won't cover all possible 
pvrusb2-driven devices).

I think this satisfies the remaining issues, except that from between 
steps 1 and 2 ir_kbd_i2c won't work with the pvrusb2 driver.  But you 
know, I'm OK with that.  I expect (2) to happen within a few days after 
(1) so the impact should be minimal.  It certainly won't escape into the 
kernel tree that way.  In addition, my impression from the community of 
pvrusb2 users is that the preferred IR strategy is lirc anyway, and it's 
a foregone conclusion that they are all going to be, uh, impacted once 
your compatibility parts are gone from i2c.  From where I'm sitting the 
"gap" from (1) to (2) is trivial compared to that impending mess - 
realize I'm not complaining since after all (a) it really falls to the 
lirc developers to fix that, (b) you do need to get your changes in, and 
(c) there's little I can do for lirc there except to keep it working as 
long as possible with the pvrusb2 driver.  I'm just pointing out that 
I'm OK with the step 1 -> 2 gap for the pvrusb2 driver because it's 
small and will be nothing compared to what's about to happen with lirc.

If you still don't like any of that, well, then I give up.  In that 
case, then merge your changes with the pvrusb2 changes included.  I 
won't ack them, but I'll just deal with it later.  Because while your 
changes might keep ir_kbd_i2c going, they will also immediately break 
the more-useful and apparently more-used lirc (by always binding 
ir_kbd_i2c even in cases in the pvrusb2 driver where it's known that it 
can't even work but lirc would have) which as far as I'm concerned is 
far worse than the step 1 - 2 gap above.  But it's just another gap and 
I'll push another pvrusb2 changeset on top to clean it up.  So just do 
whatever you think is best right now, if you disagree with the sequence 
above.

Now I will go off and deal with the steamer that pobox.com has just 
handed me :-(

  -Mike


-- 

Mike Isely
isely @ pobox (dot) com
PGP: 03 54 43 4D 75 E5 CC 92 71 16 01 E2 B5 F5 C1 E8

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 0/6] ir-kbd-i2c conversion to the new i2c binding model (v2)
  2009-04-17 20:29 [PATCH 0/6] ir-kbd-i2c conversion to the new i2c binding model (v2) Jean Delvare
                   ` (5 preceding siblings ...)
  2009-04-17 20:34 ` [PATCH 6/6] saa7134: Simplify handling of IR on AVerMedia Cardbus E506R Jean Delvare
@ 2009-04-29 12:29 ` Jean Delvare
  2009-04-29 22:40   ` hermann pitton
  2009-04-30  2:58   ` Devin Heitmueller
  6 siblings, 2 replies; 20+ messages in thread
From: Jean Delvare @ 2009-04-29 12:29 UTC (permalink / raw)
  To: LMML

On Fri, 17 Apr 2009 22:29:27 +0200, Jean Delvare wrote:
> Here comes an update of my conversion of ir-kbd-i2c to the new i2c
> binding model. I've split it into 6 pieces for easier review. (...)

Did anyone test these patches, please?

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 0/6] ir-kbd-i2c conversion to the new i2c binding model (v2)
  2009-04-29 12:29 ` [PATCH 0/6] ir-kbd-i2c conversion to the new i2c binding model (v2) Jean Delvare
@ 2009-04-29 22:40   ` hermann pitton
  2009-04-30  2:58   ` Devin Heitmueller
  1 sibling, 0 replies; 20+ messages in thread
From: hermann pitton @ 2009-04-29 22:40 UTC (permalink / raw)
  To: Jean Delvare; +Cc: LMML

Hi Jean,

Am Mittwoch, den 29.04.2009, 14:29 +0200 schrieb Jean Delvare:
> On Fri, 17 Apr 2009 22:29:27 +0200, Jean Delvare wrote:
> > Here comes an update of my conversion of ir-kbd-i2c to the new i2c
> > binding model. I've split it into 6 pieces for easier review. (...)
> 
> Did anyone test these patches, please?

it took me about two years to fix the obviously wrong radio
configuration on the MSI TV@nywhere Plus, also some other input was
wrong and similar happened on other cards.

To get no reply unfortunately happens quite often and it is not meant as
an offense, but either you don't reach people with that hardware on the
list currently or they are simply ignorant for some even most simple
test. To have done most tricky things previously does not prevent them
from ignoring simple test requests.

I don't have anything using ir-kbd-i2c.

Also don't know anything about the subscribers count on linux-media
currently. On video4linux alone it have been almost 2500 in average.

Maybe a test repo on linuxtv.org might help, without the need to apply
patches manually and also mail to the old lists for testers?

Cheers,
Hermann



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 0/6] ir-kbd-i2c conversion to the new i2c binding model (v2)
  2009-04-29 12:29 ` [PATCH 0/6] ir-kbd-i2c conversion to the new i2c binding model (v2) Jean Delvare
  2009-04-29 22:40   ` hermann pitton
@ 2009-04-30  2:58   ` Devin Heitmueller
  1 sibling, 0 replies; 20+ messages in thread
From: Devin Heitmueller @ 2009-04-30  2:58 UTC (permalink / raw)
  To: Jean Delvare; +Cc: LMML

On Wed, Apr 29, 2009 at 8:29 AM, Jean Delvare <khali@linux-fr.org> wrote:
> On Fri, 17 Apr 2009 22:29:27 +0200, Jean Delvare wrote:
>> Here comes an update of my conversion of ir-kbd-i2c to the new i2c
>> binding model. I've split it into 6 pieces for easier review. (...)
>
> Did anyone test these patches, please?

Hello Jean,

I'm still going to get these tested this week for em28xx.  I got
sidetracked yesterday on a race condition I discovered in the dvb
core.

Devin

-- 
Devin J. Heitmueller
http://www.devinheitmueller.com
AIM: devinheitmueller

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/6] ir-kbd-i2c: Switch to the new-style device binding model
  2009-04-24  2:44             ` Mike Isely
@ 2009-05-02  1:30               ` Mike Isely
  2009-05-02  7:12                 ` Jean Delvare
  0 siblings, 1 reply; 20+ messages in thread
From: Mike Isely @ 2009-05-02  1:30 UTC (permalink / raw)
  To: Jean Delvare; +Cc: LMML, Mauro Carvalho Chehab, Mike Isely


Jean:

I have another idea that I think you'll like.  I'm putting the finishing 
touches on the patch right now.

What I have implements correct ir_video loading for the pvrusb2 driver.  
It also includes a lookup table (though with only 1 entry right now) to 
determine the proper I2C address and I use i2c_new_device() now instead 
of i2c_new_probed_device().  I've also renamed things to be "ir_video" 
everywhere instead of ir_kbd_i2c as was discussed.

In particular the disable option is there like before, but now it's 
called disable_autoload_ir_video.

So far this is exactly what I was saying before.  But I'm also making 
one more change: the disable_autoload_ir_video option default value will 
- for now - be 1, i.e. everything above I just described starts off 
disabled.  This means that the entire patch can be pulled _right_ _now_ 
without breaking anything at all, because the outward behavior is still 
unchanged.

Then, when you're ready to bring your stuff in, all you need to do is 
include a 1-line change to pvrusb2-i2c-core.c to switch the default 
value of disable_autoload_ir_video back to 0, which now enables all the 
corresponding pvrusb2 changes that you need to avoid any breakage inside 
my driver.  Just to be absolutely crystal clear, here's the change you 
will be able to do once these changes are in:

diff -r 8d2e1361520c linux/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
--- a/linux/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c	Fri May 01 20:23:39 2009 -0500
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c	Fri May 01 20:24:23 2009 -0500
@@ -43,7 +43,7 @@
 module_param_array(ir_mode, int, NULL, 0444);
 MODULE_PARM_DESC(ir_mode,"specify: 0=disable IR reception, 1=normal IR");
 
+static int pvr2_disable_ir_video;
-static int pvr2_disable_ir_video = 1;
 module_param_named(disable_autoload_ir_video, pvr2_disable_ir_video,
 		   int, S_IRUGO|S_IWUSR);
 MODULE_PARM_DESC(disable_autoload_ir_video,

So with all this, what I am setting up right now will cause no harm to 
the existing situation, requires no actual messing with module options, 
and once you're reading, just include the 1-line change above and you're 
set.  There's no "race here", no gap in IR handling.

  -Mike


On Thu, 23 Apr 2009, Mike Isely wrote:

> 
> Hi Jean,
> 
> I had actually written out a longer, detailed, point-by-point reply 
> earlier today, but before I could finish it I got interrupted with a 
> crisis.  And then another.  And that's kind of how my day went.  Now I'm 
> finally back to this, but I have another e-mail debacle to immediately 
> deal with (thank you pobox.com, not!) so I'm tossing that unfinished 
> lengthy reply.  I think I can sum this whole thing up very simply.  
> Here's what I think should be happening:
> 
> 1a. Your existing IR changeset, minus the pvrusb2 changes, should be 
> merged.
> 
> 1b. In parallel with (1a) I modify my pvrusb2 changeset to use the right 
> module name and I adjust the driver option name to match.
> 
> 2. My pvrusb2 changeset, with changes from (1b) is merged.
> 
> 3. Andy's proposed change for ir_kbd_i2c to support additional IR 
> devices is investigated and probably merged.
> 
> 4. I test the changed ir_kbd_i2c against additional pvrusb2 devices 
> known not to work previously with ir_kbd_i2c.  If they work, then I will 
> create a pvrusb2 patch to load ir_video in those cases as well as the 
> cases already set up (which still won't cover all possible 
> pvrusb2-driven devices).
> 
> I think this satisfies the remaining issues, except that from between 
> steps 1 and 2 ir_kbd_i2c won't work with the pvrusb2 driver.  But you 
> know, I'm OK with that.  I expect (2) to happen within a few days after 
> (1) so the impact should be minimal.  It certainly won't escape into the 
> kernel tree that way.  In addition, my impression from the community of 
> pvrusb2 users is that the preferred IR strategy is lirc anyway, and it's 
> a foregone conclusion that they are all going to be, uh, impacted once 
> your compatibility parts are gone from i2c.  From where I'm sitting the 
> "gap" from (1) to (2) is trivial compared to that impending mess - 
> realize I'm not complaining since after all (a) it really falls to the 
> lirc developers to fix that, (b) you do need to get your changes in, and 
> (c) there's little I can do for lirc there except to keep it working as 
> long as possible with the pvrusb2 driver.  I'm just pointing out that 
> I'm OK with the step 1 -> 2 gap for the pvrusb2 driver because it's 
> small and will be nothing compared to what's about to happen with lirc.
> 
> If you still don't like any of that, well, then I give up.  In that 
> case, then merge your changes with the pvrusb2 changes included.  I 
> won't ack them, but I'll just deal with it later.  Because while your 
> changes might keep ir_kbd_i2c going, they will also immediately break 
> the more-useful and apparently more-used lirc (by always binding 
> ir_kbd_i2c even in cases in the pvrusb2 driver where it's known that it 
> can't even work but lirc would have) which as far as I'm concerned is 
> far worse than the step 1 - 2 gap above.  But it's just another gap and 
> I'll push another pvrusb2 changeset on top to clean it up.  So just do 
> whatever you think is best right now, if you disagree with the sequence 
> above.
> 
> Now I will go off and deal with the steamer that pobox.com has just 
> handed me :-(
> 
>   -Mike
> 
> 
> 

-- 

Mike Isely
isely @ isely (dot) net
PGP: 03 54 43 4D 75 E5 CC 92 71 16 01 E2 B5 F5 C1 E8

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/6] ir-kbd-i2c: Switch to the new-style device binding model
  2009-05-02  1:30               ` Mike Isely
@ 2009-05-02  7:12                 ` Jean Delvare
  2009-05-11  8:17                   ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 20+ messages in thread
From: Jean Delvare @ 2009-05-02  7:12 UTC (permalink / raw)
  To: Mike Isely, Mauro Carvalho Chehab; +Cc: LMML

Hi Mike,

Sorry for not answering your previous post...

On Fri, 1 May 2009 20:30:48 -0500 (CDT), Mike Isely wrote:
> Jean:
> 
> I have another idea that I think you'll like.  I'm putting the finishing 
> touches on the patch right now.
> 
> What I have implements correct ir_video loading for the pvrusb2 driver.  
> It also includes a lookup table (though with only 1 entry right now) to 
> determine the proper I2C address and I use i2c_new_device() now instead 
> of i2c_new_probed_device().  I've also renamed things to be "ir_video" 
> everywhere instead of ir_kbd_i2c as was discussed.

This sounds really good. The more we know about cards, the less we have
to probe, the better.

> In particular the disable option is there like before, but now it's 
> called disable_autoload_ir_video.

Call me a nitpicker, but once again, there's nothing autoloading here
so this name is a little confusing.

> So far this is exactly what I was saying before.  But I'm also making 
> one more change: the disable_autoload_ir_video option default value will 
> - for now - be 1, i.e. everything above I just described starts off 
> disabled.  This means that the entire patch can be pulled _right_ _now_ 
> without breaking anything at all, because the outward behavior is still 
> unchanged.

Yes, this is correct, and will obviously make merging easier. Thanks
for coming up with this.

> Then, when you're ready to bring your stuff in, all you need to do is 
> include a 1-line change to pvrusb2-i2c-core.c to switch the default 
> value of disable_autoload_ir_video back to 0, which now enables all the 
> corresponding pvrusb2 changes that you need to avoid any breakage inside 
> my driver.  Just to be absolutely crystal clear, here's the change you 
> will be able to do once these changes are in:
> 
> diff -r 8d2e1361520c linux/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
> --- a/linux/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c	Fri May 01 20:23:39 2009 -0500
> +++ b/linux/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c	Fri May 01 20:24:23 2009 -0500
> @@ -43,7 +43,7 @@
>  module_param_array(ir_mode, int, NULL, 0444);
>  MODULE_PARM_DESC(ir_mode,"specify: 0=disable IR reception, 1=normal IR");
>  
> +static int pvr2_disable_ir_video;
> -static int pvr2_disable_ir_video = 1;
>  module_param_named(disable_autoload_ir_video, pvr2_disable_ir_video,
>  		   int, S_IRUGO|S_IWUSR);
>  MODULE_PARM_DESC(disable_autoload_ir_video,
> 
> So with all this, what I am setting up right now will cause no harm to 
> the existing situation, requires no actual messing with module options, 
> and once you're reading, just include the 1-line change above and you're 
> set.  There's no "race here", no gap in IR handling.

This is all fine with me. Well, at this point, pretty much everything
which pushes the ir-kbd-i2c conversion forward is fine with me, as it
seems to be kind of stuck. The theory was that we would use the 2.6.31
development cycle to merge lirc and then convert ir-kbd-i2c, however I
don't see much happening in this direction, while we're probably 5
weeks away from the next merge window or so.

Mauro, please pull Mike's pvrusb2-dev work as soon as he asks you to do
so. Then I'll rebase my own patch set and send it again.

Thanks,
-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/6] ir-kbd-i2c: Switch to the new-style device binding model
  2009-05-02  7:12                 ` Jean Delvare
@ 2009-05-11  8:17                   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 20+ messages in thread
From: Mauro Carvalho Chehab @ 2009-05-11  8:17 UTC (permalink / raw)
  To: Jean Delvare, Mike Isely, Linux Media Mailing List

Em Sat, 2 May 2009 09:12:11 +0200
Jean Delvare <khali@linux-fr.org> escreveu:

> Mauro, please pull Mike's pvrusb2-dev work as soon as he asks you to do
> so. Then I'll rebase my own patch set and send it again.

Jean and Mike,

Any news about this subject?



Cheers,
Mauro

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 5/6] saa7134: Simplify handling of IR on MSI TV@nywhere Plus
  2009-04-04 12:24 [PATCH 0/6] ir-kbd-i2c conversion to the new i2c binding model Jean Delvare
@ 2009-04-04 12:30 ` Jean Delvare
  0 siblings, 0 replies; 20+ messages in thread
From: Jean Delvare @ 2009-04-04 12:30 UTC (permalink / raw)
  To: LMML; +Cc: Andy Walls, Hans Verkuil, Mauro Carvalho Chehab, Mike Isely

Now that we instantiate I2C IR devices explicitly, we can skip probing
altogether on boards where the I2C IR device address is known. The MSI
TV@nywhere Plus is one of these boards.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
---
 linux/drivers/media/video/saa7134/saa7134-input.c |   27 +++++----------------
 1 file changed, 7 insertions(+), 20 deletions(-)

--- v4l-dvb.orig/linux/drivers/media/video/saa7134/saa7134-input.c	2009-04-04 10:07:49.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/saa7134/saa7134-input.c	2009-04-04 10:22:14.000000000 +0200
@@ -691,16 +691,6 @@ void saa7134_probe_i2c_ir(struct saa7134
 		I2C_CLIENT_END
 	};
 
-	const unsigned short addr_list_msi[] = {
-		0x30, I2C_CLIENT_END
-	};
-	struct i2c_msg msg_msi = {
-		.addr = 0x50,
-		.flags = I2C_M_RD,
-		.len = 0,
-		.buf = NULL,
-	};
-
 	unsigned char subaddr, data;
 	struct i2c_msg msg_avermedia[] = { {
 		.addr = 0x40,
@@ -747,6 +737,7 @@ void saa7134_probe_i2c_ir(struct saa7134
 		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;
+		info.addr = 0x30;
 		break;
 	case SAA7134_BOARD_HAUPPAUGE_HVR1110:
 		init_data.name = "HVR 1110";
@@ -766,18 +757,14 @@ void saa7134_probe_i2c_ir(struct saa7134
 
 	if (init_data.name)
 		info.platform_data = &init_data;
-	client = i2c_new_probed_device(&dev->i2c_adap, &info, addr_list);
-	if (client)
+	/* No need to probe if address is known */
+	if (info.addr) {
+		i2c_new_device(&dev->i2c_adap, &info);
 		return;
+	}
 
-	/* MSI TV@nywhere Plus controller doesn't seem to
-	   respond to probes unless we read something from
-	   an existing device. Weird... */
-	rc = i2c_transfer(&dev->i2c_adap, &msg_msi, 1);
-	dprintk(KERN_DEBUG "probe 0x%02x @ %s: %s\n",
-		msg_msi.addr, dev->i2c_adap.name,
-		(1 == rc) ? "yes" : "no");
-	client = i2c_new_probed_device(&dev->i2c_adap, &info, addr_list_msi);
+	/* Address not known, fallback to probing */
+	client = i2c_new_probed_device(&dev->i2c_adap, &info, addr_list);
 	if (client)
 		return;
 

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2009-05-11  8:17 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-17 20:29 [PATCH 0/6] ir-kbd-i2c conversion to the new i2c binding model (v2) Jean Delvare
2009-04-17 20:30 ` [PATCH 1/6] ir-kbd-i2c: Don't use i2c_client.name for our own needs Jean Delvare
2009-04-17 20:31 ` [PATCH 2/6] ir-kbd-i2c: Switch to the new-style device binding model Jean Delvare
2009-04-17 23:35   ` Mike Isely
2009-04-18  9:25     ` Jean Delvare
2009-04-18 13:16       ` Jean Delvare
2009-04-18 13:53         ` Mike Isely
2009-04-23  9:00           ` Jean Delvare
2009-04-24  2:44             ` Mike Isely
2009-05-02  1:30               ` Mike Isely
2009-05-02  7:12                 ` Jean Delvare
2009-05-11  8:17                   ` Mauro Carvalho Chehab
2009-04-17 20:32 ` [PATCH 3/6] ir-kbd-i2c: Use initialization data Jean Delvare
2009-04-17 20:32 ` [PATCH 4/6] ir-kbd-i2c: Don't assume all IR receivers are supported Jean Delvare
2009-04-17 20:33 ` [PATCH 5/6] saa7134: Simplify handling of IR on MSI TV@nywhere Plus Jean Delvare
2009-04-17 20:34 ` [PATCH 6/6] saa7134: Simplify handling of IR on AVerMedia Cardbus E506R Jean Delvare
2009-04-29 12:29 ` [PATCH 0/6] ir-kbd-i2c conversion to the new i2c binding model (v2) Jean Delvare
2009-04-29 22:40   ` hermann pitton
2009-04-30  2:58   ` Devin Heitmueller
  -- strict thread matches above, loose matches on Subject: below --
2009-04-04 12:24 [PATCH 0/6] ir-kbd-i2c conversion to the new i2c binding model Jean Delvare
2009-04-04 12:30 ` [PATCH 5/6] saa7134: Simplify handling of IR on MSI TV@nywhere Plus Jean Delvare

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.