Skip to contentSkip to conversation

cx231xx: Fix i2c support at cx231xx-input

PATCH In review Mauro Carvalho Chehab 2 participants 3 messages Nov 12, 2010 1 message not in the archive Media (V4L/DVB)

lore
Share & tools
lore
#3 lore raw

PATCH 2/2 cx231xx: Fix i2c support at cx231xx-input

In reply to a message not in the archive

There was a bug at cx231xx-input, where it were registering the remote controls twice, one via ir-kbd-i2c and another directly. Also, the patch that added rc_register_device() broke compilation for it.

This patch fixes cx231xx-input by fixing the depends on, to point to the new symbol, and initializing the scanmask via platform_data.

While here, also fix Kconfig symbol change for IR core dependencies.

drivers/media/video/cx231xx/Kconfig +1 -1
index ab7d5df..d6a2350 100644
@@ -16,7 +16,7 @@ config VIDEO_CX231XX
 
 config VIDEO_CX231XX_RC
 	bool "Conexant cx231xx Remote Controller additional support"
-	depends on VIDEO_IR
+	depends on IR_CORE
 	depends on VIDEO_CX231XX
 	default y
 	---help---
drivers/media/video/cx231xx/cx231xx-input.c +17 -38

101 lines not on this page · raw message

drivers/media/video/cx231xx/cx231xx.h +1 -20
index c439e77..fcccc9d 100644
@@ -602,25 +602,6 @@ struct cx231xx_tsport {
 	void                       *port_priv;
 };
 
-struct cx231xx_ir_t {
-	struct input_dev *input_dev;
-	char name[40];
-	char phys[32];
-
-#if 0	
-	/*
-	 * Due to a Kconfig change, cx231xx-input is not being compiled.
-	 * This structure disappeared, but other fixes are also needed.
-	 * So, as a workaround, let's just comment this struct and let a
-	 * latter patch fix it.
-	 */
-	struct ir_dev_props props;
-#endif
-
-	/* I2C keyboard data */
-	struct IR_i2c_init_data    init_data;
-};
-
 /* main device struct */
 struct cx231xx {
 	/* generic device properties */
@@ -631,7 +612,7 @@ struct cx231xx {
 	struct cx231xx_board board;
 
 	/* For I2C IR support */
-	struct cx231xx_ir_t ir;
+	struct IR_i2c_init_data    init_data;
 
 	unsigned int stream_on:1;	/* Locks streams */
 	unsigned int vbi_stream_on:1;	/* Locks streams for VBI */
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/2 ir-kbd-i2c: add rc_dev as a parameter to the driver

In reply to a message not in the archive

There are several fields on rc_dev that drivers can benefit. Allow drivers to pass it as a parameter to the driver.

For now, the rc_dev parameter is optional. If drivers don't pass it, create them internally. However, the best is to create rc_dev inside the drivers, in order to fill other fields, like open(), close(), driver_name, etc. So, a latter patch making it mandatory and changing the caller drivers is welcome.

drivers/media/video/ir-kbd-i2c.c +33 -12
index 55a22e7..50bb627 100644
@@ -272,20 +272,16 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	const char *name = NULL;
 	u64 ir_type = IR_TYPE_UNKNOWN;
 	struct IR_i2c *ir;
-	struct rc_dev *rc;
+	struct rc_dev *rc = NULL;
 	struct i2c_adapter *adap = client->adapter;
 	unsigned short addr = client->addr;
 	int err;
 
-	ir = kzalloc(sizeof(struct IR_i2c),GFP_KERNEL);
-	rc = rc_allocate_device();
-	if (!ir || !rc) {
-		err = -ENOMEM;
-		goto err_out_free;
-	}
+	ir = kzalloc(sizeof(struct IR_i2c), GFP_KERNEL);
+	if (!ir)
+		return -ENOMEM;
 
 	ir->c = client;
-	ir->rc = rc;
 	ir->polling_interval = DEFAULT_POLLING_INTERVAL;
 	i2c_set_clientdata(client, ir);
 
@@ -334,6 +330,8 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
 						client->dev.platform_data;
 
 		ir_codes = init_data->ir_codes;
+		rc = init_data->rc_dev;
+
 		name = init_data->name;
 		if (init_data->type)
 			ir_type = init_data->type;
@@ -367,6 +365,19 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
 		}
 	}
 
+	if (!rc) {
+		/*
+		 * If platform_data doesn't specify rc_dev, initilize it
+		 * internally
+		 */
+		rc = rc_allocate_device();
+		if (!rc) {
+			err = -ENOMEM;
+			goto err_out_free;
+		}
+	}
+	ir->rc = rc;
+
 	/* Make sure we are all setup before going on */
 	if (!name || !ir->get_key || !ir_type || !ir_codes) {
 		dprintk(1, ": Unsupported device at address 0x%02x\n",
@@ -383,12 +394,21 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
 		 dev_name(&adap->dev),
 		 dev_name(&client->dev));
 
-	/* init + register input device */
+	/*
+	 * Initialize input_dev fields
+	 * It doesn't make sense to allow overriding them via platform_data
+	 */
 	rc->input_id.bustype = BUS_I2C;
-	rc->input_name       = ir->name;
 	rc->input_phys       = ir->phys;
-	rc->map_name         = ir->ir_codes;
-	rc->driver_name      = MODULE_NAME;
+	rc->input_name	     = ir->name;
+
+	/*
+	 * Initialize the other fields of rc_dev
+	 */
+	rc->map_name       = ir->ir_codes;
+	rc->allowed_protos = ir_type;
+	if (!rc->driver_name)
+		rc->driver_name = MODULE_NAME;
 
 	err = rc_register_device(rc);
 	if (err)
@@ -404,6 +424,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	return 0;
 
  err_out_free:
+	/* Only frees rc if it were allocated internally */
 	rc_free_device(rc);
 	kfree(ir);
 	return err;
include/media/ir-kbd-i2c.h +2 -0
index 4ee9b42..aca015e 100644
@@ -46,5 +46,7 @@ struct IR_i2c_init_data {
 	 */
 	int                    (*get_key)(struct IR_i2c*, u32*, u32*);
 	enum ir_kbd_get_key_fn internal_get_key_func;
+
+	struct rc_dev		*rc_dev;
 };
 #endif
Signature · 1 line
1.7.1
#2 lore raw

Re: [PATCH 1/2] [media] ir-kbd-i2c: add rc_dev as a parameter to the driver

Quoted 8 lines · Mauro Carvalho Chehab

There are several fields on rc_dev that drivers can benefit. Allow drivers to pass it as a parameter to the driver.

For now, the rc_dev parameter is optional. If drivers don't pass it, create them internally. However, the best is to create rc_dev inside the drivers, in order to fill other fields, like open(), close(), driver_name, etc. So, a latter patch making it mandatory and changing the caller drivers is welcome.

Looks good, no objections. Sorry for misinterpreting your suggested change.

Signature · 1 line
David Härdeman