Skip to content

Commit

Permalink
[media] ir-core: make struct rc_dev the primary interface
Browse files Browse the repository at this point in the history
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: David Härdeman <david@hardeman.nu>
Acked-by: Jarod Wilson <jarod@redhat.com>
Tested-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
David Härdeman authored and Mauro Carvalho Chehab committed Dec 29, 2010
1 parent 4c7b355 commit d8b4b58
Show file tree
Hide file tree
Showing 44 changed files with 1,225 additions and 1,439 deletions.
42 changes: 21 additions & 21 deletions drivers/media/dvb/dm1105/dm1105.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 5 additions & 11 deletions drivers/media/dvb/dvb-usb/af9015.c
Original file line number Diff line number Diff line change
Expand Up @@ -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__);
}
Expand Down Expand Up @@ -1348,9 +1348,7 @@ 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,
},
.allowed_protos = IR_TYPE_NEC,
},

.i2c_algo = &af9015_i2c_algo,
Expand Down Expand Up @@ -1478,9 +1476,7 @@ 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,
},
.allowed_protos = IR_TYPE_NEC,
},

.i2c_algo = &af9015_i2c_algo,
Expand Down Expand Up @@ -1592,9 +1588,7 @@ 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,
},
.allowed_protos = IR_TYPE_NEC,
},

.i2c_algo = &af9015_i2c_algo,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/dvb/dvb-usb/anysee.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/dvb/dvb-usb/dib0700.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions drivers/media/dvb/dvb-usb/dib0700_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down
Loading

0 comments on commit d8b4b58

Please sign in to comment.