diff options
author | David Härdeman <david@hardeman.nu> | 2010-10-29 16:08:23 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-12-29 08:16:37 -0200 |
commit | d8b4b5822f51e2142b731b42c81e3f03eec475b2 (patch) | |
tree | fce9a9b7ca5031adc95fbd6be118352fb2527da5 /drivers/media/rc/mceusb.c | |
parent | 4c7b355df6e7f05304e05f6b7a286e59a5f1cc54 (diff) |
[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: 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>
Diffstat (limited to 'drivers/media/rc/mceusb.c')
-rw-r--r-- | drivers/media/rc/mceusb.c | 112 |
1 files changed, 46 insertions, 66 deletions
diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c index 392ca24132d..539bec2974b 100644 --- a/drivers/media/rc/mceusb.c +++ b/drivers/media/rc/mceusb.c @@ -35,7 +35,6 @@ #include <linux/device.h> #include <linux/module.h> #include <linux/slab.h> -#include <linux/input.h> #include <linux/usb.h> #include <linux/usb/input.h> #include <media/ir-core.h> @@ -317,7 +316,7 @@ static struct usb_device_id mceusb_dev_table[] = { /* data structure for each usb transceiver */ struct mceusb_dev { /* ir-core bits */ - struct ir_dev_props *props; + struct rc_dev *rc; /* optional features we can enable */ bool carrier_report_enabled; @@ -325,7 +324,6 @@ struct mceusb_dev { /* core device bits */ struct device *dev; - struct input_dev *idev; /* usb */ struct usb_device *usbdev; @@ -663,9 +661,9 @@ static void mce_sync_in(struct mceusb_dev *ir, unsigned char *data, int size) } /* Send data out the IR blaster port(s) */ -static int mceusb_tx_ir(void *priv, int *txbuf, u32 n) +static int mceusb_tx_ir(struct rc_dev *dev, int *txbuf, u32 n) { - struct mceusb_dev *ir = priv; + struct mceusb_dev *ir = dev->priv; int i, ret = 0; int count, cmdcount = 0; unsigned char *cmdbuf; /* MCE command buffer */ @@ -749,9 +747,9 @@ out: } /* Sets active IR outputs -- mce devices typically have two */ -static int mceusb_set_tx_mask(void *priv, u32 mask) +static int mceusb_set_tx_mask(struct rc_dev *dev, u32 mask) { - struct mceusb_dev *ir = priv; + struct mceusb_dev *ir = dev->priv; if (ir->flags.tx_mask_normal) ir->tx_mask = mask; @@ -763,9 +761,9 @@ static int mceusb_set_tx_mask(void *priv, u32 mask) } /* Sets the send carrier frequency and mode */ -static int mceusb_set_tx_carrier(void *priv, u32 carrier) +static int mceusb_set_tx_carrier(struct rc_dev *dev, u32 carrier) { - struct mceusb_dev *ir = priv; + struct mceusb_dev *ir = dev->priv; int clk = 10000000; int prescaler = 0, divisor = 0; unsigned char cmdbuf[4] = { MCE_COMMAND_HEADER, @@ -819,7 +817,7 @@ static void mceusb_handle_command(struct mceusb_dev *ir, int index) switch (ir->buf_in[index]) { /* 2-byte return value commands */ case MCE_CMD_S_TIMEOUT: - ir->props->timeout = MS_TO_NS((hi << 8 | lo) / 2); + ir->rc->timeout = MS_TO_NS((hi << 8 | lo) / 2); break; /* 1-byte return value commands */ @@ -866,7 +864,7 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len) rawir.pulse ? "pulse" : "space", rawir.duration); - ir_raw_event_store_with_filter(ir->idev, &rawir); + ir_raw_event_store_with_filter(ir->rc, &rawir); break; case CMD_DATA: ir->rem--; @@ -893,7 +891,7 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len) ir->parser_state = CMD_HEADER; } dev_dbg(ir->dev, "processed IR data, calling ir_raw_event_handle\n"); - ir_raw_event_handle(ir->idev); + ir_raw_event_handle(ir->rc); } static void mceusb_dev_recv(struct urb *urb, struct pt_regs *regs) @@ -1035,72 +1033,54 @@ static void mceusb_get_parameters(struct mceusb_dev *ir) mce_sync_in(ir, NULL, maxp); } -static struct input_dev *mceusb_init_input_dev(struct mceusb_dev *ir) +static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir) { - struct input_dev *idev; - struct ir_dev_props *props; struct device *dev = ir->dev; - const char *rc_map = RC_MAP_RC6_MCE; - const char *name = "Media Center Ed. eHome Infrared Remote Transceiver"; - int ret = -ENODEV; - - idev = input_allocate_device(); - if (!idev) { - dev_err(dev, "remote input dev allocation failed\n"); - goto idev_alloc_failed; - } + struct rc_dev *rc; + int ret; - ret = -ENOMEM; - props = kzalloc(sizeof(struct ir_dev_props), GFP_KERNEL); - if (!props) { - dev_err(dev, "remote ir dev props allocation failed\n"); - goto props_alloc_failed; + rc = rc_allocate_device(); + if (!rc) { + dev_err(dev, "remote dev allocation failed\n"); + goto out; } - if (mceusb_model[ir->model].name) - name = mceusb_model[ir->model].name; - snprintf(ir->name, sizeof(ir->name), "%s (%04x:%04x)", - name, + mceusb_model[ir->model].name ? + mceusb_model[ir->model].name : + "Media Center Ed. eHome Infrared Remote Transceiver", le16_to_cpu(ir->usbdev->descriptor.idVendor), le16_to_cpu(ir->usbdev->descriptor.idProduct)); - idev->name = ir->name; usb_make_path(ir->usbdev, ir->phys, sizeof(ir->phys)); - strlcat(ir->phys, "/input0", sizeof(ir->phys)); - idev->phys = ir->phys; - props->priv = ir; - props->driver_type = RC_DRIVER_IR_RAW; - props->allowed_protos = IR_TYPE_ALL; - props->timeout = MS_TO_NS(1000); + rc->input_name = ir->name; + rc->input_phys = ir->phys; + usb_to_input_id(ir->usbdev, &rc->input_id); + rc->dev.parent = dev; + rc->priv = ir; + rc->driver_type = RC_DRIVER_IR_RAW; + rc->allowed_protos = IR_TYPE_ALL; + rc->timeout = MS_TO_NS(1000); if (!ir->flags.no_tx) { - props->s_tx_mask = mceusb_set_tx_mask; - props->s_tx_carrier = mceusb_set_tx_carrier; - props->tx_ir = mceusb_tx_ir; + rc->s_tx_mask = mceusb_set_tx_mask; + rc->s_tx_carrier = mceusb_set_tx_carrier; + rc->tx_ir = mceusb_tx_ir; } + rc->driver_name = DRIVER_NAME; + rc->map_name = mceusb_model[ir->model].rc_map ? + mceusb_model[ir->model].rc_map : RC_MAP_RC6_MCE; - ir->props = props; - - usb_to_input_id(ir->usbdev, &idev->id); - idev->dev.parent = ir->dev; - - if (mceusb_model[ir->model].rc_map) - rc_map = mceusb_model[ir->model].rc_map; - - ret = ir_input_register(idev, rc_map, props, DRIVER_NAME); + ret = rc_register_device(rc); if (ret < 0) { - dev_err(dev, "remote input device register failed\n"); - goto irdev_failed; + dev_err(dev, "remote dev registration failed\n"); + goto out; } - return idev; + return rc; -irdev_failed: - kfree(props); -props_alloc_failed: - input_free_device(idev); -idev_alloc_failed: +out: + rc_free_device(rc); return NULL; } @@ -1212,9 +1192,9 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf, snprintf(name + strlen(name), sizeof(name) - strlen(name), " %s", buf); - ir->idev = mceusb_init_input_dev(ir); - if (!ir->idev) - goto input_dev_fail; + ir->rc = mceusb_init_rc_dev(ir); + if (!ir->rc) + goto rc_dev_fail; /* flush buffers on the device */ mce_sync_in(ir, NULL, maxp); @@ -1235,7 +1215,7 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf, mceusb_get_parameters(ir); if (!ir->flags.no_tx) - mceusb_set_tx_mask(ir, MCE_DEFAULT_TX_MASK); + mceusb_set_tx_mask(ir->rc, MCE_DEFAULT_TX_MASK); usb_set_intfdata(intf, ir); @@ -1245,7 +1225,7 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf, return 0; /* Error-handling path */ -input_dev_fail: +rc_dev_fail: usb_free_urb(ir->urb_in); urb_in_alloc_fail: usb_free_coherent(dev, maxp, ir->buf_in, ir->dma_in); @@ -1269,7 +1249,7 @@ static void __devexit mceusb_dev_disconnect(struct usb_interface *intf) return; ir->usbdev = NULL; - ir_input_unregister(ir->idev); + rc_unregister_device(ir->rc); usb_kill_urb(ir->urb_in); usb_free_urb(ir->urb_in); usb_free_coherent(dev, ir->len_in, ir->buf_in, ir->dma_in); |