Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d8b4b582 authored by David Härdeman's avatar David Härdeman Committed by Mauro Carvalho Chehab
Browse files

[media] ir-core: make struct rc_dev the primary interface



This patch merges the ir_input_dev and ir_dev_props structs into a single
struct called rc_dev. The drivers and various functions in rc-core used
by the drivers are also changed to use rc_dev as the primary interface
when dealing with rc-core.

This means that the input_dev is abstracted away from the drivers which
is necessary if we ever want to support multiple input devs per rc device.

The new API is similar to what the input subsystem uses, i.e:
rc_device_alloc()
rc_device_free()
rc_device_register()
rc_device_unregister()

[mchehab@redhat.com: Fix compilation on mceusb and cx231xx, due to merge conflicts]
Signed-off-by: default avatarDavid Härdeman <david@hardeman.nu>
Acked-by: default avatarJarod Wilson <jarod@redhat.com>
Tested-by: default avatarJarod Wilson <jarod@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 4c7b355d
Loading
Loading
Loading
Loading
+21 −21
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@
#include <linux/proc_fs.h>
#include <linux/pci.h>
#include <linux/dma-mapping.h>
#include <linux/input.h>
#include <linux/slab.h>
#include <media/ir-core.h>

@@ -266,7 +265,7 @@ static void dm1105_card_list(struct pci_dev *pci)

/* infrared remote control */
struct infrared {
	struct input_dev	*input_dev;
	struct rc_dev		*dev;
	char			input_phys[32];
	struct work_struct	work;
	u32			ir_command;
@@ -532,7 +531,7 @@ static void dm1105_emit_key(struct work_struct *work)

	data = (ircom >> 8) & 0x7f;

	ir_keydown(ir->input_dev, data, 0);
	ir_keydown(ir->dev, data, 0);
}

/* work handler */
@@ -593,46 +592,47 @@ static irqreturn_t dm1105_irq(int irq, void *dev_id)

int __devinit dm1105_ir_init(struct dm1105_dev *dm1105)
{
	struct input_dev *input_dev;
	char *ir_codes = RC_MAP_DM1105_NEC;
	struct rc_dev *dev;
	int err = -ENOMEM;

	input_dev = input_allocate_device();
	if (!input_dev)
	dev = rc_allocate_device();
	if (!dev)
		return -ENOMEM;

	dm1105->ir.input_dev = input_dev;
	snprintf(dm1105->ir.input_phys, sizeof(dm1105->ir.input_phys),
		"pci-%s/ir0", pci_name(dm1105->pdev));

	input_dev->name = "DVB on-card IR receiver";
	input_dev->phys = dm1105->ir.input_phys;
	input_dev->id.bustype = BUS_PCI;
	input_dev->id.version = 1;
	dev->driver_name = MODULE_NAME;
	dev->map_name = RC_MAP_DM1105_NEC;
	dev->driver_type = RC_DRIVER_SCANCODE;
	dev->input_name = "DVB on-card IR receiver";
	dev->input_phys = dm1105->ir.input_phys;
	dev->input_id.bustype = BUS_PCI;
	dev->input_id.version = 1;
	if (dm1105->pdev->subsystem_vendor) {
		input_dev->id.vendor = dm1105->pdev->subsystem_vendor;
		input_dev->id.product = dm1105->pdev->subsystem_device;
		dev->input_id.vendor = dm1105->pdev->subsystem_vendor;
		dev->input_id.product = dm1105->pdev->subsystem_device;
	} else {
		input_dev->id.vendor = dm1105->pdev->vendor;
		input_dev->id.product = dm1105->pdev->device;
		dev->input_id.vendor = dm1105->pdev->vendor;
		dev->input_id.product = dm1105->pdev->device;
	}

	input_dev->dev.parent = &dm1105->pdev->dev;
	dev->dev.parent = &dm1105->pdev->dev;

	INIT_WORK(&dm1105->ir.work, dm1105_emit_key);

	err = ir_input_register(input_dev, ir_codes, NULL, MODULE_NAME);
	err = rc_register_device(dev);
	if (err < 0) {
		input_free_device(input_dev);
		rc_free_device(dev);
		return err;
	}

	dm1105->ir.dev = dev;
	return 0;
}

void __devexit dm1105_ir_exit(struct dm1105_dev *dm1105)
{
	ir_input_unregister(dm1105->ir.input_dev);
	rc_unregister_device(dm1105->ir.dev);
}

static int __devinit dm1105_hw_init(struct dm1105_dev *dev)
+5 −11
Original line number Diff line number Diff line
@@ -1041,13 +1041,13 @@ static int af9015_rc_query(struct dvb_usb_device *d)
				priv->rc_keycode = buf[12] << 16 |
					buf[13] << 8 | buf[14];
			}
			ir_keydown(d->rc_input_dev, priv->rc_keycode, 0);
			ir_keydown(d->rc_dev, priv->rc_keycode, 0);
		} else {
			priv->rc_keycode = 0; /* clear just for sure */
		}
	} else if (priv->rc_repeat != buf[6] || buf[0]) {
		deb_rc("%s: key repeated\n", __func__);
		ir_keydown(d->rc_input_dev, priv->rc_keycode, 0);
		ir_keydown(d->rc_dev, priv->rc_keycode, 0);
	} else {
		deb_rc("%s: no key press\n", __func__);
	}
@@ -1348,10 +1348,8 @@ static struct dvb_usb_device_properties af9015_properties[] = {
			.module_name      = "af9015",
			.rc_query         = af9015_rc_query,
			.rc_interval      = AF9015_RC_INTERVAL,
			.rc_props = {
			.allowed_protos   = IR_TYPE_NEC,
		},
		},

		.i2c_algo = &af9015_i2c_algo,

@@ -1478,10 +1476,8 @@ static struct dvb_usb_device_properties af9015_properties[] = {
			.module_name      = "af9015",
			.rc_query         = af9015_rc_query,
			.rc_interval      = AF9015_RC_INTERVAL,
			.rc_props = {
			.allowed_protos   = IR_TYPE_NEC,
		},
		},

		.i2c_algo = &af9015_i2c_algo,

@@ -1592,10 +1588,8 @@ static struct dvb_usb_device_properties af9015_properties[] = {
			.module_name      = "af9015",
			.rc_query         = af9015_rc_query,
			.rc_interval      = AF9015_RC_INTERVAL,
			.rc_props = {
			.allowed_protos   = IR_TYPE_NEC,
		},
		},

		.i2c_algo = &af9015_i2c_algo,

+1 −1
Original line number Diff line number Diff line
@@ -394,7 +394,7 @@ static int anysee_rc_query(struct dvb_usb_device *d)

	if (ircode[0]) {
		deb_rc("%s: key pressed %02x\n", __func__, ircode[1]);
		ir_keydown(d->rc_input_dev, 0x08 << 8 | ircode[1], 0);
		ir_keydown(d->rc_dev, 0x08 << 8 | ircode[1], 0);
	}

	return 0;
+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ extern int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff);
extern struct i2c_algorithm dib0700_i2c_algo;
extern int dib0700_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props,
			struct dvb_usb_device_description **desc, int *cold);
extern int dib0700_change_protocol(void *priv, u64 ir_type);
extern int dib0700_change_protocol(struct rc_dev *dev, u64 ir_type);

extern int dib0700_device_count;
extern int dvb_usb_dib0700_ir_proto;
+4 −4
Original line number Diff line number Diff line
@@ -471,9 +471,9 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
	return dib0700_ctrl_wr(adap->dev, b, 4);
}

int dib0700_change_protocol(void *priv, u64 ir_type)
int dib0700_change_protocol(struct rc_dev *rc, u64 ir_type)
{
	struct dvb_usb_device *d = priv;
	struct dvb_usb_device *d = rc->priv;
	struct dib0700_state *st = d->priv;
	u8 rc_setup[3] = { REQUEST_SET_RC, 0, 0 };
	int new_proto, ret;
@@ -535,7 +535,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
	if (d == NULL)
		return;

	if (d->rc_input_dev == NULL) {
	if (d->rc_dev == NULL) {
		/* This will occur if disable_rc_polling=1 */
		usb_free_urb(purb);
		return;
@@ -600,7 +600,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
		goto resubmit;
	}

	ir_keydown(d->rc_input_dev, keycode, toggle);
	ir_keydown(d->rc_dev, keycode, toggle);

resubmit:
	/* Clean the buffer before we requeue */
Loading