All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] [media] rc: Allow specifying properties for i2c IR's
       [not found] <cover.1289482268.git.mchehab@redhat.com>
@ 2010-11-11 13:33 ` Mauro Carvalho Chehab
  2010-11-11 13:33 ` [PATCH 2/2] [media] cx231xx: Don't register remote controls twice Mauro Carvalho Chehab
  1 sibling, 0 replies; 2+ messages in thread
From: Mauro Carvalho Chehab @ 2010-11-11 13:33 UTC (permalink / raw)
  Cc: Linux Media Mailing List

Several I2C IR's only provide part of the IR protocol message (in general,
they provide only the command part). Due to that, some props fields need
to be specified.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index aee8943..82834ea 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -270,6 +270,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
 	char *ir_codes = NULL;
 	const char *name = NULL;
+	struct ir_dev_props *props = NULL;
 	u64 ir_type = IR_TYPE_UNKNOWN;
 	struct IR_i2c *ir;
 	struct input_dev *input_dev;
@@ -337,6 +338,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
 		name = init_data->name;
 		if (init_data->type)
 			ir_type = init_data->type;
+		props = init_data->props;
 
 		if (init_data->polling_interval)
 			ir->polling_interval = init_data->polling_interval;
@@ -388,7 +390,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	input_dev->name       = ir->name;
 	input_dev->phys       = ir->phys;
 
-	err = ir_input_register(ir->input, ir->ir_codes, NULL, MODULE_NAME);
+	err = ir_input_register(ir->input, ir->ir_codes, props, MODULE_NAME);
 	if (err)
 		goto err_out_free;
 
diff --git a/include/media/ir-kbd-i2c.h b/include/media/ir-kbd-i2c.h
index 8c37b5e..19ea5fa 100644
--- a/include/media/ir-kbd-i2c.h
+++ b/include/media/ir-kbd-i2c.h
@@ -47,5 +47,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 ir_dev_props    *props;
 };
 #endif
-- 
1.7.1



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

* [PATCH 2/2] [media] cx231xx: Don't register remote controls twice
       [not found] <cover.1289482268.git.mchehab@redhat.com>
  2010-11-11 13:33 ` [PATCH 1/2] [media] rc: Allow specifying properties for i2c IR's Mauro Carvalho Chehab
@ 2010-11-11 13:33 ` Mauro Carvalho Chehab
  1 sibling, 0 replies; 2+ messages in thread
From: Mauro Carvalho Chehab @ 2010-11-11 13:33 UTC (permalink / raw)
  Cc: Linux Media Mailing List

There's a bug at cx231xx-input, where it were registering the remote controls
twice, one via ir-kbd-i2c and another directly. Fix it by registering it
only once.

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

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

diff --git a/drivers/media/video/cx231xx/Kconfig b/drivers/media/video/cx231xx/Kconfig
index ab7d5df..d6a2350 100644
--- a/drivers/media/video/cx231xx/Kconfig
+++ b/drivers/media/video/cx231xx/Kconfig
@@ -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---
diff --git a/drivers/media/video/cx231xx/cx231xx-input.c b/drivers/media/video/cx231xx/cx231xx-input.c
index 6725244..6e06005 100644
--- a/drivers/media/video/cx231xx/cx231xx-input.c
+++ b/drivers/media/video/cx231xx/cx231xx-input.c
@@ -29,6 +29,8 @@ static int get_key_isdbt(struct IR_i2c *ir, u32 *ir_key,
 {
 	u8	cmd;
 
+	dev_dbg(&ir->input->dev, "%s\n", __func__);
+
 		/* poll IR chip */
 	if (1 != i2c_master_recv(ir->c, &cmd, 1))
 		return -EIO;
@@ -49,7 +51,6 @@ static int get_key_isdbt(struct IR_i2c *ir, u32 *ir_key,
 
 int cx231xx_ir_init(struct cx231xx *dev)
 {
-	struct input_dev *input_dev;
 	struct i2c_board_info info;
 	int rc;
 	u8 ir_i2c_bus;
@@ -60,34 +61,15 @@ int cx231xx_ir_init(struct cx231xx *dev)
 	if (!cx231xx_boards[dev->model].rc_map)
 		return -ENODEV;
 
-	input_dev = input_allocate_device();
-	if (!input_dev)
-		return -ENOMEM;
-
 	request_module("ir-kbd-i2c");
 
 	memset(&info, 0, sizeof(struct i2c_board_info));
-	memset(&dev->ir.init_data, 0, sizeof(dev->ir.init_data));
+	memset(&dev->init_data, 0, sizeof(dev->init_data));
 
-	dev->ir.input_dev = input_dev;
-	dev->ir.init_data.name = cx231xx_boards[dev->model].name;
-	dev->ir.props.priv = dev;
-	dev->ir.props.allowed_protos = IR_TYPE_NEC;
-	snprintf(dev->ir.name, sizeof(dev->ir.name),
-		 "cx231xx IR (%s)", cx231xx_boards[dev->model].name);
-	usb_make_path(dev->udev, dev->ir.phys, sizeof(dev->ir.phys));
-	strlcat(dev->ir.phys, "/input0", sizeof(dev->ir.phys));
+	dev->init_data.name = cx231xx_boards[dev->model].name;
 
 	strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
-	info.platform_data = &dev->ir.init_data;
-
-	input_dev->name = dev->ir.name;
-	input_dev->phys = dev->ir.phys;
-	input_dev->dev.parent = &dev->udev->dev;
-	input_dev->id.bustype = BUS_USB;
-	input_dev->id.version = 1;
-	input_dev->id.vendor = le16_to_cpu(dev->udev->descriptor.idVendor);
-	input_dev->id.product = le16_to_cpu(dev->udev->descriptor.idProduct);
+	info.platform_data = &dev->init_data;
 
 	/*
 	 * Board-dependent values
@@ -95,19 +77,17 @@ int cx231xx_ir_init(struct cx231xx *dev)
 	 * For now, there's just one type of hardware design using
 	 * an i2c device.
 	 */
-	dev->ir.init_data.get_key = get_key_isdbt;
-	dev->ir.init_data.ir_codes = cx231xx_boards[dev->model].rc_map;
+	dev->init_data.get_key = get_key_isdbt;
+	dev->init_data.ir_codes = cx231xx_boards[dev->model].rc_map;
 	/* The i2c micro-controller only outputs the cmd part of NEC protocol */
-	dev->ir.props.scanmask = 0xff;
+	dev->init_data.props = kzalloc(sizeof(*dev->init_data.props), GFP_KERNEL);
+	dev->init_data.props->scanmask = 0xff;
 	info.addr = 0x30;
 
-	rc = ir_input_register(input_dev, cx231xx_boards[dev->model].rc_map,
-			       &dev->ir.props, MODULE_NAME);
-	if (rc < 0)
-		return rc;
-
 	/* Load and bind ir-kbd-i2c */
 	ir_i2c_bus = cx231xx_boards[dev->model].ir_i2c_master;
+	dev_dbg(&dev->udev->dev, "Trying to bind ir at bus %d, addr 0x%02x\n",
+		ir_i2c_bus, info.addr);
 	i2c_new_device(&dev->i2c_bus[ir_i2c_bus].i2c_adap, &info);
 
 	return rc;
@@ -115,8 +95,5 @@ int cx231xx_ir_init(struct cx231xx *dev)
 
 void cx231xx_ir_exit(struct cx231xx *dev)
 {
-	if (dev->ir.input_dev) {
-		ir_input_unregister(dev->ir.input_dev);
-		dev->ir.input_dev = NULL;
-	}
+	kfree(dev->init_data.props);
 }
diff --git a/drivers/media/video/cx231xx/cx231xx.h b/drivers/media/video/cx231xx/cx231xx.h
index a09cef4..fcccc9d 100644
--- a/drivers/media/video/cx231xx/cx231xx.h
+++ b/drivers/media/video/cx231xx/cx231xx.h
@@ -602,17 +602,6 @@ struct cx231xx_tsport {
 	void                       *port_priv;
 };
 
-struct cx231xx_ir_t {
-	struct input_dev *input_dev;
-	char name[40];
-	char phys[32];
-
-	struct ir_dev_props props;
-
-	/* I2C keyboard data */
-	struct IR_i2c_init_data    init_data;
-};
-
 /* main device struct */
 struct cx231xx {
 	/* generic device properties */
@@ -623,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 */
-- 
1.7.1


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

end of thread, other threads:[~2010-11-11 13:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <cover.1289482268.git.mchehab@redhat.com>
2010-11-11 13:33 ` [PATCH 1/2] [media] rc: Allow specifying properties for i2c IR's Mauro Carvalho Chehab
2010-11-11 13:33 ` [PATCH 2/2] [media] cx231xx: Don't register remote controls twice Mauro Carvalho Chehab

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.