aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2010-10-29 15:08:23 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-12-29 05:16:37 -0500
commitd8b4b5822f51e2142b731b42c81e3f03eec475b2 (patch)
treefce9a9b7ca5031adc95fbd6be118352fb2527da5
parent4c7b355df6e7f05304e05f6b7a286e59a5f1cc54 (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>
-rw-r--r--drivers/media/dvb/dm1105/dm1105.c42
-rw-r--r--drivers/media/dvb/dvb-usb/af9015.c16
-rw-r--r--drivers/media/dvb/dvb-usb/anysee.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700.h2
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_core.c8
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_devices.c144
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-remote.c77
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb.h12
-rw-r--r--drivers/media/dvb/dvb-usb/lmedm04.c41
-rw-r--r--drivers/media/dvb/mantis/mantis_common.h4
-rw-r--r--drivers/media/dvb/mantis/mantis_input.c72
-rw-r--r--drivers/media/dvb/siano/smscoreapi.c2
-rw-r--r--drivers/media/dvb/siano/smsir.c52
-rw-r--r--drivers/media/dvb/siano/smsir.h3
-rw-r--r--drivers/media/dvb/ttpci/budget-ci.c49
-rw-r--r--drivers/media/rc/ene_ir.c129
-rw-r--r--drivers/media/rc/ene_ir.h3
-rw-r--r--drivers/media/rc/imon.c58
-rw-r--r--drivers/media/rc/ir-jvc-decoder.c13
-rw-r--r--drivers/media/rc/ir-lirc-codec.c121
-rw-r--r--drivers/media/rc/ir-nec-decoder.c15
-rw-r--r--drivers/media/rc/ir-rc5-decoder.c13
-rw-r--r--drivers/media/rc/ir-rc5-sz-decoder.c13
-rw-r--r--drivers/media/rc/ir-rc6-decoder.c17
-rw-r--r--drivers/media/rc/ir-sony-decoder.c11
-rw-r--r--drivers/media/rc/mceusb.c112
-rw-r--r--drivers/media/rc/nuvoton-cir.c85
-rw-r--r--drivers/media/rc/nuvoton-cir.h3
-rw-r--r--drivers/media/rc/rc-core-priv.h16
-rw-r--r--drivers/media/rc/rc-main.c612
-rw-r--r--drivers/media/rc/rc-raw.c191
-rw-r--r--drivers/media/rc/streamzap.c73
-rw-r--r--drivers/media/video/bt8xx/bttv-input.c41
-rw-r--r--drivers/media/video/cx231xx/cx231xx.h8
-rw-r--r--drivers/media/video/cx23885/cx23885-input.c64
-rw-r--r--drivers/media/video/cx23885/cx23885.h3
-rw-r--r--drivers/media/video/cx88/cx88-input.c96
-rw-r--r--drivers/media/video/em28xx/em28xx-input.c72
-rw-r--r--drivers/media/video/ir-kbd-i2c.c25
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c72
-rw-r--r--drivers/staging/tm6000/tm6000-input.c85
-rw-r--r--include/media/ir-common.h3
-rw-r--r--include/media/ir-core.h181
-rw-r--r--include/media/ir-kbd-i2c.h3
44 files changed, 1225 insertions, 1439 deletions
diff --git a/drivers/media/dvb/dm1105/dm1105.c b/drivers/media/dvb/dm1105/dm1105.c
index 5d404f1bf03..d1a43858f29 100644
--- a/drivers/media/dvb/dm1105/dm1105.c
+++ b/drivers/media/dvb/dm1105/dm1105.c
@@ -26,7 +26,6 @@
26#include <linux/proc_fs.h> 26#include <linux/proc_fs.h>
27#include <linux/pci.h> 27#include <linux/pci.h>
28#include <linux/dma-mapping.h> 28#include <linux/dma-mapping.h>
29#include <linux/input.h>
30#include <linux/slab.h> 29#include <linux/slab.h>
31#include <media/ir-core.h> 30#include <media/ir-core.h>
32 31
@@ -266,7 +265,7 @@ static void dm1105_card_list(struct pci_dev *pci)
266 265
267/* infrared remote control */ 266/* infrared remote control */
268struct infrared { 267struct infrared {
269 struct input_dev *input_dev; 268 struct rc_dev *dev;
270 char input_phys[32]; 269 char input_phys[32];
271 struct work_struct work; 270 struct work_struct work;
272 u32 ir_command; 271 u32 ir_command;
@@ -532,7 +531,7 @@ static void dm1105_emit_key(struct work_struct *work)
532 531
533 data = (ircom >> 8) & 0x7f; 532 data = (ircom >> 8) & 0x7f;
534 533
535 ir_keydown(ir->input_dev, data, 0); 534 ir_keydown(ir->dev, data, 0);
536} 535}
537 536
538/* work handler */ 537/* work handler */
@@ -593,46 +592,47 @@ static irqreturn_t dm1105_irq(int irq, void *dev_id)
593 592
594int __devinit dm1105_ir_init(struct dm1105_dev *dm1105) 593int __devinit dm1105_ir_init(struct dm1105_dev *dm1105)
595{ 594{
596 struct input_dev *input_dev; 595 struct rc_dev *dev;
597 char *ir_codes = RC_MAP_DM1105_NEC;
598 int err = -ENOMEM; 596 int err = -ENOMEM;
599 597
600 input_dev = input_allocate_device(); 598 dev = rc_allocate_device();
601 if (!input_dev) 599 if (!dev)
602 return -ENOMEM; 600 return -ENOMEM;
603 601
604 dm1105->ir.input_dev = input_dev;
605 snprintf(dm1105->ir.input_phys, sizeof(dm1105->ir.input_phys), 602 snprintf(dm1105->ir.input_phys, sizeof(dm1105->ir.input_phys),
606 "pci-%s/ir0", pci_name(dm1105->pdev)); 603 "pci-%s/ir0", pci_name(dm1105->pdev));
607 604
608 input_dev->name = "DVB on-card IR receiver"; 605 dev->driver_name = MODULE_NAME;
609 input_dev->phys = dm1105->ir.input_phys; 606 dev->map_name = RC_MAP_DM1105_NEC;
610 input_dev->id.bustype = BUS_PCI; 607 dev->driver_type = RC_DRIVER_SCANCODE;
611 input_dev->id.version = 1; 608 dev->input_name = "DVB on-card IR receiver";
609 dev->input_phys = dm1105->ir.input_phys;
610 dev->input_id.bustype = BUS_PCI;
611 dev->input_id.version = 1;
612 if (dm1105->pdev->subsystem_vendor) { 612 if (dm1105->pdev->subsystem_vendor) {
613 input_dev->id.vendor = dm1105->pdev->subsystem_vendor; 613 dev->input_id.vendor = dm1105->pdev->subsystem_vendor;
614 input_dev->id.product = dm1105->pdev->subsystem_device; 614 dev->input_id.product = dm1105->pdev->subsystem_device;
615 } else { 615 } else {
616 input_dev->id.vendor = dm1105->pdev->vendor; 616 dev->input_id.vendor = dm1105->pdev->vendor;
617 input_dev->id.product = dm1105->pdev->device; 617 dev->input_id.product = dm1105->pdev->device;
618 } 618 }
619 619 dev->dev.parent = &dm1105->pdev->dev;
620 input_dev->dev.parent = &dm1105->pdev->dev;
621 620
622 INIT_WORK(&dm1105->ir.work, dm1105_emit_key); 621 INIT_WORK(&dm1105->ir.work, dm1105_emit_key);
623 622
624 err = ir_input_register(input_dev, ir_codes, NULL, MODULE_NAME); 623 err = rc_register_device(dev);
625 if (err < 0) { 624 if (err < 0) {
626 input_free_device(input_dev); 625 rc_free_device(dev);
627 return err; 626 return err;
628 } 627 }
629 628
629 dm1105->ir.dev = dev;
630 return 0; 630 return 0;
631} 631}
632 632
633void __devexit dm1105_ir_exit(struct dm1105_dev *dm1105) 633void __devexit dm1105_ir_exit(struct dm1105_dev *dm1105)
634{ 634{
635 ir_input_unregister(dm1105->ir.input_dev); 635 rc_unregister_device(dm1105->ir.dev);
636} 636}
637 637
638static int __devinit dm1105_hw_init(struct dm1105_dev *dev) 638static int __devinit dm1105_hw_init(struct dm1105_dev *dev)
diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c
index 31c0a0ed39f..8b9ab3002e1 100644
--- a/drivers/media/dvb/dvb-usb/af9015.c
+++ b/drivers/media/dvb/dvb-usb/af9015.c
@@ -1041,13 +1041,13 @@ static int af9015_rc_query(struct dvb_usb_device *d)
1041 priv->rc_keycode = buf[12] << 16 | 1041 priv->rc_keycode = buf[12] << 16 |
1042 buf[13] << 8 | buf[14]; 1042 buf[13] << 8 | buf[14];
1043 } 1043 }
1044 ir_keydown(d->rc_input_dev, priv->rc_keycode, 0); 1044 ir_keydown(d->rc_dev, priv->rc_keycode, 0);
1045 } else { 1045 } else {
1046 priv->rc_keycode = 0; /* clear just for sure */ 1046 priv->rc_keycode = 0; /* clear just for sure */
1047 } 1047 }
1048 } else if (priv->rc_repeat != buf[6] || buf[0]) { 1048 } else if (priv->rc_repeat != buf[6] || buf[0]) {
1049 deb_rc("%s: key repeated\n", __func__); 1049 deb_rc("%s: key repeated\n", __func__);
1050 ir_keydown(d->rc_input_dev, priv->rc_keycode, 0); 1050 ir_keydown(d->rc_dev, priv->rc_keycode, 0);
1051 } else { 1051 } else {
1052 deb_rc("%s: no key press\n", __func__); 1052 deb_rc("%s: no key press\n", __func__);
1053 } 1053 }
@@ -1348,9 +1348,7 @@ static struct dvb_usb_device_properties af9015_properties[] = {
1348 .module_name = "af9015", 1348 .module_name = "af9015",
1349 .rc_query = af9015_rc_query, 1349 .rc_query = af9015_rc_query,
1350 .rc_interval = AF9015_RC_INTERVAL, 1350 .rc_interval = AF9015_RC_INTERVAL,
1351 .rc_props = { 1351 .allowed_protos = IR_TYPE_NEC,
1352 .allowed_protos = IR_TYPE_NEC,
1353 },
1354 }, 1352 },
1355 1353
1356 .i2c_algo = &af9015_i2c_algo, 1354 .i2c_algo = &af9015_i2c_algo,
@@ -1478,9 +1476,7 @@ static struct dvb_usb_device_properties af9015_properties[] = {
1478 .module_name = "af9015", 1476 .module_name = "af9015",
1479 .rc_query = af9015_rc_query, 1477 .rc_query = af9015_rc_query,
1480 .rc_interval = AF9015_RC_INTERVAL, 1478 .rc_interval = AF9015_RC_INTERVAL,
1481 .rc_props = { 1479 .allowed_protos = IR_TYPE_NEC,
1482 .allowed_protos = IR_TYPE_NEC,
1483 },
1484 }, 1480 },
1485 1481
1486 .i2c_algo = &af9015_i2c_algo, 1482 .i2c_algo = &af9015_i2c_algo,
@@ -1592,9 +1588,7 @@ static struct dvb_usb_device_properties af9015_properties[] = {
1592 .module_name = "af9015", 1588 .module_name = "af9015",
1593 .rc_query = af9015_rc_query, 1589 .rc_query = af9015_rc_query,
1594 .rc_interval = AF9015_RC_INTERVAL, 1590 .rc_interval = AF9015_RC_INTERVAL,
1595 .rc_props = { 1591 .allowed_protos = IR_TYPE_NEC,
1596 .allowed_protos = IR_TYPE_NEC,
1597 },
1598 }, 1592 },
1599 1593
1600 .i2c_algo = &af9015_i2c_algo, 1594 .i2c_algo = &af9015_i2c_algo,
diff --git a/drivers/media/dvb/dvb-usb/anysee.c b/drivers/media/dvb/dvb-usb/anysee.c
index 1759d26bca4..c6e4ba53ad6 100644
--- a/drivers/media/dvb/dvb-usb/anysee.c
+++ b/drivers/media/dvb/dvb-usb/anysee.c
@@ -394,7 +394,7 @@ static int anysee_rc_query(struct dvb_usb_device *d)
394 394
395 if (ircode[0]) { 395 if (ircode[0]) {
396 deb_rc("%s: key pressed %02x\n", __func__, ircode[1]); 396 deb_rc("%s: key pressed %02x\n", __func__, ircode[1]);
397 ir_keydown(d->rc_input_dev, 0x08 << 8 | ircode[1], 0); 397 ir_keydown(d->rc_dev, 0x08 << 8 | ircode[1], 0);
398 } 398 }
399 399
400 return 0; 400 return 0;
diff --git a/drivers/media/dvb/dvb-usb/dib0700.h b/drivers/media/dvb/dvb-usb/dib0700.h
index c2c9d236ec7..1e7d780332b 100644
--- a/drivers/media/dvb/dvb-usb/dib0700.h
+++ b/drivers/media/dvb/dvb-usb/dib0700.h
@@ -60,7 +60,7 @@ extern int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff);
60extern struct i2c_algorithm dib0700_i2c_algo; 60extern struct i2c_algorithm dib0700_i2c_algo;
61extern int dib0700_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props, 61extern int dib0700_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props,
62 struct dvb_usb_device_description **desc, int *cold); 62 struct dvb_usb_device_description **desc, int *cold);
63extern int dib0700_change_protocol(void *priv, u64 ir_type); 63extern int dib0700_change_protocol(struct rc_dev *dev, u64 ir_type);
64 64
65extern int dib0700_device_count; 65extern int dib0700_device_count;
66extern int dvb_usb_dib0700_ir_proto; 66extern int dvb_usb_dib0700_ir_proto;
diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c
index 48397f103d3..3b58f457568 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_core.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_core.c
@@ -471,9 +471,9 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
471 return dib0700_ctrl_wr(adap->dev, b, 4); 471 return dib0700_ctrl_wr(adap->dev, b, 4);
472} 472}
473 473
474int dib0700_change_protocol(void *priv, u64 ir_type) 474int dib0700_change_protocol(struct rc_dev *rc, u64 ir_type)
475{ 475{
476 struct dvb_usb_device *d = priv; 476 struct dvb_usb_device *d = rc->priv;
477 struct dib0700_state *st = d->priv; 477 struct dib0700_state *st = d->priv;
478 u8 rc_setup[3] = { REQUEST_SET_RC, 0, 0 }; 478 u8 rc_setup[3] = { REQUEST_SET_RC, 0, 0 };
479 int new_proto, ret; 479 int new_proto, ret;
@@ -535,7 +535,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
535 if (d == NULL) 535 if (d == NULL)
536 return; 536 return;
537 537
538 if (d->rc_input_dev == NULL) { 538 if (d->rc_dev == NULL) {
539 /* This will occur if disable_rc_polling=1 */ 539 /* This will occur if disable_rc_polling=1 */
540 usb_free_urb(purb); 540 usb_free_urb(purb);
541 return; 541 return;
@@ -600,7 +600,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
600 goto resubmit; 600 goto resubmit;
601 } 601 }
602 602
603 ir_keydown(d->rc_input_dev, keycode, toggle); 603 ir_keydown(d->rc_dev, keycode, toggle);
604 604
605resubmit: 605resubmit:
606 /* Clean the buffer before we requeue */ 606 /* Clean the buffer before we requeue */
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c
index e06acd1fecb..be167f2bea3 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c
@@ -520,13 +520,13 @@ static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d)
520 d->last_event = keycode; 520 d->last_event = keycode;
521 } 521 }
522 522
523 ir_keydown(d->rc_input_dev, keycode, 0); 523 ir_keydown(d->rc_dev, keycode, 0);
524 break; 524 break;
525 default: 525 default:
526 /* RC-5 protocol changes toggle bit on new keypress */ 526 /* RC-5 protocol changes toggle bit on new keypress */
527 keycode = key[3-2] << 8 | key[3-3]; 527 keycode = key[3-2] << 8 | key[3-3];
528 toggle = key[3-1]; 528 toggle = key[3-1];
529 ir_keydown(d->rc_input_dev, keycode, toggle); 529 ir_keydown(d->rc_dev, keycode, toggle);
530 530
531 break; 531 break;
532 } 532 }
@@ -1924,12 +1924,10 @@ struct dvb_usb_device_properties dib0700_devices[] = {
1924 .rc_interval = DEFAULT_RC_INTERVAL, 1924 .rc_interval = DEFAULT_RC_INTERVAL,
1925 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 1925 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
1926 .rc_query = dib0700_rc_query_old_firmware, 1926 .rc_query = dib0700_rc_query_old_firmware,
1927 .rc_props = { 1927 .allowed_protos = IR_TYPE_RC5 |
1928 .allowed_protos = IR_TYPE_RC5 | 1928 IR_TYPE_RC6 |
1929 IR_TYPE_RC6 | 1929 IR_TYPE_NEC,
1930 IR_TYPE_NEC, 1930 .change_protocol = dib0700_change_protocol,
1931 .change_protocol = dib0700_change_protocol,
1932 },
1933 }, 1931 },
1934 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 1932 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1935 1933
@@ -1960,12 +1958,10 @@ struct dvb_usb_device_properties dib0700_devices[] = {
1960 .rc_interval = DEFAULT_RC_INTERVAL, 1958 .rc_interval = DEFAULT_RC_INTERVAL,
1961 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 1959 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
1962 .rc_query = dib0700_rc_query_old_firmware, 1960 .rc_query = dib0700_rc_query_old_firmware,
1963 .rc_props = { 1961 .allowed_protos = IR_TYPE_RC5 |
1964 .allowed_protos = IR_TYPE_RC5 | 1962 IR_TYPE_RC6 |
1965 IR_TYPE_RC6 | 1963 IR_TYPE_NEC,
1966 IR_TYPE_NEC, 1964 .change_protocol = dib0700_change_protocol,
1967 .change_protocol = dib0700_change_protocol,
1968 },
1969 }, 1965 },
1970 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 1966 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
1971 1967
@@ -2021,12 +2017,10 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2021 .rc_interval = DEFAULT_RC_INTERVAL, 2017 .rc_interval = DEFAULT_RC_INTERVAL,
2022 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 2018 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
2023 .rc_query = dib0700_rc_query_old_firmware, 2019 .rc_query = dib0700_rc_query_old_firmware,
2024 .rc_props = { 2020 .allowed_protos = IR_TYPE_RC5 |
2025 .allowed_protos = IR_TYPE_RC5 | 2021 IR_TYPE_RC6 |
2026 IR_TYPE_RC6 | 2022 IR_TYPE_NEC,
2027 IR_TYPE_NEC, 2023 .change_protocol = dib0700_change_protocol,
2028 .change_protocol = dib0700_change_protocol,
2029 },
2030 }, 2024 },
2031 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 2025 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2032 2026
@@ -2065,12 +2059,10 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2065 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 2059 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
2066 .module_name = "dib0700", 2060 .module_name = "dib0700",
2067 .rc_query = dib0700_rc_query_old_firmware, 2061 .rc_query = dib0700_rc_query_old_firmware,
2068 .rc_props = { 2062 .allowed_protos = IR_TYPE_RC5 |
2069 .allowed_protos = IR_TYPE_RC5 | 2063 IR_TYPE_RC6 |
2070 IR_TYPE_RC6 | 2064 IR_TYPE_NEC,
2071 IR_TYPE_NEC, 2065 .change_protocol = dib0700_change_protocol,
2072 .change_protocol = dib0700_change_protocol,
2073 },
2074 }, 2066 },
2075 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 2067 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2076 2068
@@ -2143,12 +2135,10 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2143 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 2135 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
2144 .module_name = "dib0700", 2136 .module_name = "dib0700",
2145 .rc_query = dib0700_rc_query_old_firmware, 2137 .rc_query = dib0700_rc_query_old_firmware,
2146 .rc_props = { 2138 .allowed_protos = IR_TYPE_RC5 |
2147 .allowed_protos = IR_TYPE_RC5 | 2139 IR_TYPE_RC6 |
2148 IR_TYPE_RC6 | 2140 IR_TYPE_NEC,
2149 IR_TYPE_NEC, 2141 .change_protocol = dib0700_change_protocol,
2150 .change_protocol = dib0700_change_protocol,
2151 },
2152 }, 2142 },
2153 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 2143 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2154 2144
@@ -2189,12 +2179,10 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2189 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 2179 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
2190 .module_name = "dib0700", 2180 .module_name = "dib0700",
2191 .rc_query = dib0700_rc_query_old_firmware, 2181 .rc_query = dib0700_rc_query_old_firmware,
2192 .rc_props = { 2182 .allowed_protos = IR_TYPE_RC5 |
2193 .allowed_protos = IR_TYPE_RC5 | 2183 IR_TYPE_RC6 |
2194 IR_TYPE_RC6 | 2184 IR_TYPE_NEC,
2195 IR_TYPE_NEC, 2185 .change_protocol = dib0700_change_protocol,
2196 .change_protocol = dib0700_change_protocol,
2197 },
2198 }, 2186 },
2199 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 2187 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2200 2188
@@ -2259,12 +2247,10 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2259 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 2247 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
2260 .module_name = "dib0700", 2248 .module_name = "dib0700",
2261 .rc_query = dib0700_rc_query_old_firmware, 2249 .rc_query = dib0700_rc_query_old_firmware,
2262 .rc_props = { 2250 .allowed_protos = IR_TYPE_RC5 |
2263 .allowed_protos = IR_TYPE_RC5 | 2251 IR_TYPE_RC6 |
2264 IR_TYPE_RC6 | 2252 IR_TYPE_NEC,
2265 IR_TYPE_NEC, 2253 .change_protocol = dib0700_change_protocol,
2266 .change_protocol = dib0700_change_protocol,
2267 },
2268 }, 2254 },
2269 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 2255 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2270 2256
@@ -2308,12 +2294,10 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2308 .rc_codes = RC_MAP_DIB0700_NEC_TABLE, 2294 .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
2309 .module_name = "dib0700", 2295 .module_name = "dib0700",
2310 .rc_query = dib0700_rc_query_old_firmware, 2296 .rc_query = dib0700_rc_query_old_firmware,
2311 .rc_props = { 2297 .allowed_protos = IR_TYPE_RC5 |
2312 .allowed_protos = IR_TYPE_RC5 | 2298 IR_TYPE_RC6 |
2313 IR_TYPE_RC6 | 2299 IR_TYPE_NEC,
2314 IR_TYPE_NEC, 2300 .change_protocol = dib0700_change_protocol,
2315 .change_protocol = dib0700_change_protocol,
2316 },
2317 }, 2301 },
2318 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 2302 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2319 2303
@@ -2379,12 +2363,10 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2379 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 2363 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
2380 .module_name = "dib0700", 2364 .module_name = "dib0700",
2381 .rc_query = dib0700_rc_query_old_firmware, 2365 .rc_query = dib0700_rc_query_old_firmware,
2382 .rc_props = { 2366 .allowed_protos = IR_TYPE_RC5 |
2383 .allowed_protos = IR_TYPE_RC5 | 2367 IR_TYPE_RC6 |
2384 IR_TYPE_RC6 | 2368 IR_TYPE_NEC,
2385 IR_TYPE_NEC, 2369 .change_protocol = dib0700_change_protocol,
2386 .change_protocol = dib0700_change_protocol,
2387 },
2388 }, 2370 },
2389 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 2371 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2390 .num_adapters = 1, 2372 .num_adapters = 1,
@@ -2417,12 +2399,10 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2417 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 2399 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
2418 .module_name = "dib0700", 2400 .module_name = "dib0700",
2419 .rc_query = dib0700_rc_query_old_firmware, 2401 .rc_query = dib0700_rc_query_old_firmware,
2420 .rc_props = { 2402 .allowed_protos = IR_TYPE_RC5 |
2421 .allowed_protos = IR_TYPE_RC5 | 2403 IR_TYPE_RC6 |
2422 IR_TYPE_RC6 | 2404 IR_TYPE_NEC,
2423 IR_TYPE_NEC, 2405 .change_protocol = dib0700_change_protocol,
2424 .change_protocol = dib0700_change_protocol,
2425 },
2426 }, 2406 },
2427 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 2407 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2428 .num_adapters = 1, 2408 .num_adapters = 1,
@@ -2487,12 +2467,10 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2487 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 2467 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
2488 .module_name = "dib0700", 2468 .module_name = "dib0700",
2489 .rc_query = dib0700_rc_query_old_firmware, 2469 .rc_query = dib0700_rc_query_old_firmware,
2490 .rc_props = { 2470 .allowed_protos = IR_TYPE_RC5 |
2491 .allowed_protos = IR_TYPE_RC5 | 2471 IR_TYPE_RC6 |
2492 IR_TYPE_RC6 | 2472 IR_TYPE_NEC,
2493 IR_TYPE_NEC, 2473 .change_protocol = dib0700_change_protocol,
2494 .change_protocol = dib0700_change_protocol,
2495 },
2496 }, 2474 },
2497 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 2475 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2498 .num_adapters = 1, 2476 .num_adapters = 1,
@@ -2533,12 +2511,10 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2533 .rc_codes = RC_MAP_DIB0700_NEC_TABLE, 2511 .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
2534 .module_name = "dib0700", 2512 .module_name = "dib0700",
2535 .rc_query = dib0700_rc_query_old_firmware, 2513 .rc_query = dib0700_rc_query_old_firmware,
2536 .rc_props = { 2514 .allowed_protos = IR_TYPE_RC5 |
2537 .allowed_protos = IR_TYPE_RC5 | 2515 IR_TYPE_RC6 |
2538 IR_TYPE_RC6 | 2516 IR_TYPE_NEC,
2539 IR_TYPE_NEC, 2517 .change_protocol = dib0700_change_protocol,
2540 .change_protocol = dib0700_change_protocol,
2541 },
2542 }, 2518 },
2543 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 2519 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2544 .num_adapters = 2, 2520 .num_adapters = 2,
@@ -2584,12 +2560,10 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2584 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 2560 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
2585 .module_name = "dib0700", 2561 .module_name = "dib0700",
2586 .rc_query = dib0700_rc_query_old_firmware, 2562 .rc_query = dib0700_rc_query_old_firmware,
2587 .rc_props = { 2563 .allowed_protos = IR_TYPE_RC5 |
2588 .allowed_protos = IR_TYPE_RC5 | 2564 IR_TYPE_RC6 |
2589 IR_TYPE_RC6 | 2565 IR_TYPE_NEC,
2590 IR_TYPE_NEC, 2566 .change_protocol = dib0700_change_protocol,
2591 .change_protocol = dib0700_change_protocol,
2592 },
2593 }, 2567 },
2594 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 2568 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2595 .num_adapters = 1, 2569 .num_adapters = 1,
@@ -2623,12 +2597,10 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2623 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 2597 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
2624 .module_name = "dib0700", 2598 .module_name = "dib0700",
2625 .rc_query = dib0700_rc_query_old_firmware, 2599 .rc_query = dib0700_rc_query_old_firmware,
2626 .rc_props = { 2600 .allowed_protos = IR_TYPE_RC5 |
2627 .allowed_protos = IR_TYPE_RC5 | 2601 IR_TYPE_RC6 |
2628 IR_TYPE_RC6 | 2602 IR_TYPE_NEC,
2629 IR_TYPE_NEC, 2603 .change_protocol = dib0700_change_protocol,
2630 .change_protocol = dib0700_change_protocol,
2631 },
2632 }, 2604 },
2633 }, 2605 },
2634}; 2606};
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
index b579fed3ab3..bbba149a2ce 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
@@ -106,10 +106,10 @@ static void legacy_dvb_usb_read_remote_control(struct work_struct *work)
106 d->last_event = event; 106 d->last_event = event;
107 case REMOTE_KEY_REPEAT: 107 case REMOTE_KEY_REPEAT:
108 deb_rc("key repeated\n"); 108 deb_rc("key repeated\n");
109 input_event(d->rc_input_dev, EV_KEY, event, 1); 109 input_event(d->input_dev, EV_KEY, event, 1);
110 input_sync(d->rc_input_dev); 110 input_sync(d->input_dev);
111 input_event(d->rc_input_dev, EV_KEY, d->last_event, 0); 111 input_event(d->input_dev, EV_KEY, d->last_event, 0);
112 input_sync(d->rc_input_dev); 112 input_sync(d->input_dev);
113 break; 113 break;
114 default: 114 default:
115 break; 115 break;
@@ -154,10 +154,22 @@ schedule:
154 schedule_delayed_work(&d->rc_query_work,msecs_to_jiffies(d->props.rc.legacy.rc_interval)); 154 schedule_delayed_work(&d->rc_query_work,msecs_to_jiffies(d->props.rc.legacy.rc_interval));
155} 155}
156 156
157static int legacy_dvb_usb_remote_init(struct dvb_usb_device *d, 157static int legacy_dvb_usb_remote_init(struct dvb_usb_device *d)
158 struct input_dev *input_dev)
159{ 158{
160 int i, err, rc_interval; 159 int i, err, rc_interval;
160 struct input_dev *input_dev;
161
162 input_dev = input_allocate_device();
163 if (!input_dev)
164 return -ENOMEM;
165
166 input_dev->evbit[0] = BIT_MASK(EV_KEY);
167 input_dev->name = "IR-receiver inside an USB DVB receiver";
168 input_dev->phys = d->rc_phys;
169 usb_to_input_id(d->udev, &input_dev->id);
170 input_dev->dev.parent = &d->udev->dev;
171 d->input_dev = input_dev;
172 d->rc_dev = NULL;
161 173
162 input_dev->getkeycode = legacy_dvb_usb_getkeycode; 174 input_dev->getkeycode = legacy_dvb_usb_getkeycode;
163 input_dev->setkeycode = legacy_dvb_usb_setkeycode; 175 input_dev->setkeycode = legacy_dvb_usb_setkeycode;
@@ -221,18 +233,34 @@ static void dvb_usb_read_remote_control(struct work_struct *work)
221 msecs_to_jiffies(d->props.rc.core.rc_interval)); 233 msecs_to_jiffies(d->props.rc.core.rc_interval));
222} 234}
223 235
224static int rc_core_dvb_usb_remote_init(struct dvb_usb_device *d, 236static int rc_core_dvb_usb_remote_init(struct dvb_usb_device *d)
225 struct input_dev *input_dev)
226{ 237{
227 int err, rc_interval; 238 int err, rc_interval;
239 struct rc_dev *dev;
240
241 dev = rc_allocate_device();
242 if (!dev)
243 return -ENOMEM;
228 244
229 d->props.rc.core.rc_props.priv = d; 245 dev->driver_name = d->props.rc.core.module_name;
230 err = ir_input_register(input_dev, 246 dev->map_name = d->props.rc.core.rc_codes;
231 d->props.rc.core.rc_codes, 247 dev->change_protocol = d->props.rc.core.change_protocol;
232 &d->props.rc.core.rc_props, 248 dev->allowed_protos = d->props.rc.core.allowed_protos;
233 d->props.rc.core.module_name); 249 dev->driver_type = RC_DRIVER_SCANCODE;
234 if (err < 0) 250 usb_to_input_id(d->udev, &dev->input_id);
251 dev->input_name = "IR-receiver inside an USB DVB receiver";
252 dev->input_phys = d->rc_phys;
253 dev->dev.parent = &d->udev->dev;
254 dev->priv = d;
255
256 err = rc_register_device(dev);
257 if (err < 0) {
258 rc_free_device(dev);
235 return err; 259 return err;
260 }
261
262 d->input_dev = NULL;
263 d->rc_dev = dev;
236 264
237 if (!d->props.rc.core.rc_query || d->props.rc.core.bulk_mode) 265 if (!d->props.rc.core.rc_query || d->props.rc.core.bulk_mode)
238 return 0; 266 return 0;
@@ -251,7 +279,6 @@ static int rc_core_dvb_usb_remote_init(struct dvb_usb_device *d,
251 279
252int dvb_usb_remote_init(struct dvb_usb_device *d) 280int dvb_usb_remote_init(struct dvb_usb_device *d)
253{ 281{
254 struct input_dev *input_dev;
255 int err; 282 int err;
256 283
257 if (dvb_usb_disable_rc_polling) 284 if (dvb_usb_disable_rc_polling)
@@ -267,26 +294,14 @@ int dvb_usb_remote_init(struct dvb_usb_device *d)
267 usb_make_path(d->udev, d->rc_phys, sizeof(d->rc_phys)); 294 usb_make_path(d->udev, d->rc_phys, sizeof(d->rc_phys));
268 strlcat(d->rc_phys, "/ir0", sizeof(d->rc_phys)); 295 strlcat(d->rc_phys, "/ir0", sizeof(d->rc_phys));
269 296
270 input_dev = input_allocate_device();
271 if (!input_dev)
272 return -ENOMEM;
273
274 input_dev->evbit[0] = BIT_MASK(EV_KEY);
275 input_dev->name = "IR-receiver inside an USB DVB receiver";
276 input_dev->phys = d->rc_phys;
277 usb_to_input_id(d->udev, &input_dev->id);
278 input_dev->dev.parent = &d->udev->dev;
279
280 /* Start the remote-control polling. */ 297 /* Start the remote-control polling. */
281 if (d->props.rc.legacy.rc_interval < 40) 298 if (d->props.rc.legacy.rc_interval < 40)
282 d->props.rc.legacy.rc_interval = 100; /* default */ 299 d->props.rc.legacy.rc_interval = 100; /* default */
283 300
284 d->rc_input_dev = input_dev;
285
286 if (d->props.rc.mode == DVB_RC_LEGACY) 301 if (d->props.rc.mode == DVB_RC_LEGACY)
287 err = legacy_dvb_usb_remote_init(d, input_dev); 302 err = legacy_dvb_usb_remote_init(d);
288 else 303 else
289 err = rc_core_dvb_usb_remote_init(d, input_dev); 304 err = rc_core_dvb_usb_remote_init(d);
290 if (err) 305 if (err)
291 return err; 306 return err;
292 307
@@ -301,9 +316,9 @@ int dvb_usb_remote_exit(struct dvb_usb_device *d)
301 cancel_rearming_delayed_work(&d->rc_query_work); 316 cancel_rearming_delayed_work(&d->rc_query_work);
302 flush_scheduled_work(); 317 flush_scheduled_work();
303 if (d->props.rc.mode == DVB_RC_LEGACY) 318 if (d->props.rc.mode == DVB_RC_LEGACY)
304 input_unregister_device(d->rc_input_dev); 319 input_unregister_device(d->input_dev);
305 else 320 else
306 ir_input_unregister(d->rc_input_dev); 321 rc_unregister_device(d->rc_dev);
307 } 322 }
308 d->state &= ~DVB_USB_STATE_REMOTE; 323 d->state &= ~DVB_USB_STATE_REMOTE;
309 return 0; 324 return 0;
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h
index 34f7b3ba8cc..83aa9826560 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb.h
@@ -180,18 +180,20 @@ struct dvb_rc_legacy {
180 * struct dvb_rc properties of remote controller, using rc-core 180 * struct dvb_rc properties of remote controller, using rc-core
181 * @rc_codes: name of rc codes table 181 * @rc_codes: name of rc codes table
182 * @protocol: type of protocol(s) currently used by the driver 182 * @protocol: type of protocol(s) currently used by the driver
183 * @allowed_protos: protocol(s) supported by the driver
184 * @change_protocol: callback to change protocol
183 * @rc_query: called to query an event event. 185 * @rc_query: called to query an event event.
184 * @rc_interval: time in ms between two queries. 186 * @rc_interval: time in ms between two queries.
185 * @rc_props: remote controller properties
186 * @bulk_mode: device supports bulk mode for RC (disable polling mode) 187 * @bulk_mode: device supports bulk mode for RC (disable polling mode)
187 */ 188 */
188struct dvb_rc { 189struct dvb_rc {
189 char *rc_codes; 190 char *rc_codes;
190 u64 protocol; 191 u64 protocol;
192 u64 allowed_protos;
193 int (*change_protocol)(struct rc_dev *dev, u64 ir_type);
191 char *module_name; 194 char *module_name;
192 int (*rc_query) (struct dvb_usb_device *d); 195 int (*rc_query) (struct dvb_usb_device *d);
193 int rc_interval; 196 int rc_interval;
194 struct ir_dev_props rc_props;
195 bool bulk_mode; /* uses bulk mode */ 197 bool bulk_mode; /* uses bulk mode */
196}; 198};
197 199
@@ -385,7 +387,8 @@ struct dvb_usb_adapter {
385 * 387 *
386 * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB 388 * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB
387 * 389 *
388 * @rc_input_dev: input device for the remote control. 390 * @rc_dev: rc device for the remote control (rc-core mode)
391 * @input_dev: input device for the remote control (legacy mode)
389 * @rc_query_work: struct work_struct frequent rc queries 392 * @rc_query_work: struct work_struct frequent rc queries
390 * @last_event: last triggered event 393 * @last_event: last triggered event
391 * @last_state: last state (no, pressed, repeat) 394 * @last_state: last state (no, pressed, repeat)
@@ -418,7 +421,8 @@ struct dvb_usb_device {
418 struct dvb_usb_adapter adapter[MAX_NO_OF_ADAPTER_PER_DEVICE]; 421 struct dvb_usb_adapter adapter[MAX_NO_OF_ADAPTER_PER_DEVICE];
419 422
420 /* remote control */ 423 /* remote control */
421 struct input_dev *rc_input_dev; 424 struct rc_dev *rc_dev;
425 struct input_dev *input_dev;
422 char rc_phys[64]; 426 char rc_phys[64];
423 struct delayed_work rc_query_work; 427 struct delayed_work rc_query_work;
424 u32 last_event; 428 u32 last_event;
diff --git a/drivers/media/dvb/dvb-usb/lmedm04.c b/drivers/media/dvb/dvb-usb/lmedm04.c
index de7f1fbec92..d8f1b150e1c 100644
--- a/drivers/media/dvb/dvb-usb/lmedm04.c
+++ b/drivers/media/dvb/dvb-usb/lmedm04.c
@@ -198,7 +198,7 @@ static int lme2510_remote_keypress(struct dvb_usb_adapter *adap, u16 keypress)
198 deb_info(1, "INT Key Keypress =%04x", keypress); 198 deb_info(1, "INT Key Keypress =%04x", keypress);
199 199
200 if (keypress > 0) 200 if (keypress > 0)
201 ir_keydown(d->rc_input_dev, keypress, 0); 201 ir_keydown(d->rc_dev, keypress, 0);
202 202
203 return 0; 203 return 0;
204} 204}
@@ -555,42 +555,39 @@ static int lme2510_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
555static int lme2510_int_service(struct dvb_usb_adapter *adap) 555static int lme2510_int_service(struct dvb_usb_adapter *adap)
556{ 556{
557 struct dvb_usb_device *d = adap->dev; 557 struct dvb_usb_device *d = adap->dev;
558 struct input_dev *input_dev; 558 struct rc_dev *rc;
559 char *ir_codes = RC_MAP_LME2510; 559 int ret;
560 int ret = 0;
561 560
562 info("STA Configuring Remote"); 561 info("STA Configuring Remote");
563 562
564 usb_make_path(d->udev, d->rc_phys, sizeof(d->rc_phys)); 563 rc = rc_allocate_device();
565 564 if (!rc)
566 strlcat(d->rc_phys, "/ir0", sizeof(d->rc_phys));
567
568 input_dev = input_allocate_device();
569 if (!input_dev)
570 return -ENOMEM; 565 return -ENOMEM;
571 566
572 input_dev->name = "LME2510 Remote Control"; 567 usb_make_path(d->udev, d->rc_phys, sizeof(d->rc_phys));
573 input_dev->phys = d->rc_phys; 568 strlcat(d->rc_phys, "/ir0", sizeof(d->rc_phys));
574
575 usb_to_input_id(d->udev, &input_dev->id);
576 569
577 ret |= ir_input_register(input_dev, ir_codes, NULL, "LME 2510"); 570 rc->input_name = "LME2510 Remote Control";
571 rc->input_phys = d->rc_phys;
572 rc->map_name = RC_MAP_LME2510;
573 rc->driver_name = "LME 2510";
574 usb_to_input_id(d->udev, &rc->input_id);
578 575
576 ret = rc_register_device(rc);
579 if (ret) { 577 if (ret) {
580 input_free_device(input_dev); 578 rc_free_device(rc);
581 return ret; 579 return ret;
582 } 580 }
581 d->rc_dev = rc;
583 582
584 d->rc_input_dev = input_dev;
585 /* Start the Interupt */ 583 /* Start the Interupt */
586 ret = lme2510_int_read(adap); 584 ret = lme2510_int_read(adap);
587
588 if (ret < 0) { 585 if (ret < 0) {
589 ir_input_unregister(input_dev); 586 rc_unregister_device(rc);
590 input_free_device(input_dev); 587 return -ENODEV;
591 } 588 }
592 589
593 return (ret < 0) ? -ENODEV : 0; 590 return 0;
594} 591}
595 592
596static u8 check_sum(u8 *p, u8 len) 593static u8 check_sum(u8 *p, u8 len)
@@ -1025,7 +1022,7 @@ void *lme2510_exit_int(struct dvb_usb_device *d)
1025 usb_free_coherent(d->udev, 5000, st->buffer, 1022 usb_free_coherent(d->udev, 5000, st->buffer,
1026 st->lme_urb->transfer_dma); 1023 st->lme_urb->transfer_dma);
1027 info("Interupt Service Stopped"); 1024 info("Interupt Service Stopped");
1028 ir_input_unregister(d->rc_input_dev); 1025 rc_unregister_device(d->rc_dev);
1029 info("Remote Stopped"); 1026 info("Remote Stopped");
1030 } 1027 }
1031 return buffer; 1028 return buffer;
diff --git a/drivers/media/dvb/mantis/mantis_common.h b/drivers/media/dvb/mantis/mantis_common.h
index d0b645a483c..bd400d21b81 100644
--- a/drivers/media/dvb/mantis/mantis_common.h
+++ b/drivers/media/dvb/mantis/mantis_common.h
@@ -171,7 +171,9 @@ struct mantis_pci {
171 struct work_struct uart_work; 171 struct work_struct uart_work;
172 spinlock_t uart_lock; 172 spinlock_t uart_lock;
173 173
174 struct input_dev *rc; 174 struct rc_dev *rc;
175 char input_name[80];
176 char input_phys[80];
175}; 177};
176 178
177#define MANTIS_HIF_STATUS (mantis->gpio_status) 179#define MANTIS_HIF_STATUS (mantis->gpio_status)
diff --git a/drivers/media/dvb/mantis/mantis_input.c b/drivers/media/dvb/mantis/mantis_input.c
index a99489b8418..209f2110e20 100644
--- a/drivers/media/dvb/mantis/mantis_input.c
+++ b/drivers/media/dvb/mantis/mantis_input.c
@@ -18,7 +18,6 @@
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/ 19*/
20 20
21#include <linux/input.h>
22#include <media/ir-core.h> 21#include <media/ir-core.h>
23#include <linux/pci.h> 22#include <linux/pci.h>
24 23
@@ -33,6 +32,7 @@
33#include "mantis_uart.h" 32#include "mantis_uart.h"
34 33
35#define MODULE_NAME "mantis_core" 34#define MODULE_NAME "mantis_core"
35#define RC_MAP_MANTIS "rc-mantis"
36 36
37static struct ir_scancode mantis_ir_table[] = { 37static struct ir_scancode mantis_ir_table[] = {
38 { 0x29, KEY_POWER }, 38 { 0x29, KEY_POWER },
@@ -95,53 +95,65 @@ static struct ir_scancode mantis_ir_table[] = {
95 { 0x00, KEY_BLUE }, 95 { 0x00, KEY_BLUE },
96}; 96};
97 97
98struct ir_scancode_table ir_mantis = { 98static struct rc_keymap ir_mantis_map = {
99 .scan = mantis_ir_table, 99 .map = {
100 .size = ARRAY_SIZE(mantis_ir_table), 100 .scan = mantis_ir_table,
101 .size = ARRAY_SIZE(mantis_ir_table),
102 .ir_type = IR_TYPE_UNKNOWN,
103 .name = RC_MAP_MANTIS,
104 }
101}; 105};
102EXPORT_SYMBOL_GPL(ir_mantis);
103 106
104int mantis_input_init(struct mantis_pci *mantis) 107int mantis_input_init(struct mantis_pci *mantis)
105{ 108{
106 struct input_dev *rc; 109 struct rc_dev *dev;
107 char name[80], dev[80];
108 int err; 110 int err;
109 111
110 rc = input_allocate_device(); 112 err = ir_register_map(&ir_mantis_map);
111 if (!rc) { 113 if (err)
112 dprintk(MANTIS_ERROR, 1, "Input device allocate failed"); 114 goto out;
113 return -ENOMEM;
114 }
115 115
116 sprintf(name, "Mantis %s IR receiver", mantis->hwconfig->model_name); 116 dev = rc_allocate_device();
117 sprintf(dev, "pci-%s/ir0", pci_name(mantis->pdev)); 117 if (!dev) {
118 dprintk(MANTIS_ERROR, 1, "Remote device allocation failed");
119 err = -ENOMEM;
120 goto out_map;
121 }
118 122
119 rc->name = name; 123 sprintf(mantis->input_name, "Mantis %s IR receiver", mantis->hwconfig->model_name);
120 rc->phys = dev; 124 sprintf(mantis->input_phys, "pci-%s/ir0", pci_name(mantis->pdev));
121 125
122 rc->id.bustype = BUS_PCI; 126 dev->input_name = mantis->input_name;
123 rc->id.vendor = mantis->vendor_id; 127 dev->input_phys = mantis->input_phys;
124 rc->id.product = mantis->device_id; 128 dev->input_id.bustype = BUS_PCI;
125 rc->id.version = 1; 129 dev->input_id.vendor = mantis->vendor_id;
126 rc->dev = mantis->pdev->dev; 130 dev->input_id.product = mantis->device_id;
131 dev->input_id.version = 1;
132 dev->driver_name = MODULE_NAME;
133 dev->map_name = RC_MAP_MANTIS;
134 dev->dev.parent = &mantis->pdev->dev;
127 135
128 err = __ir_input_register(rc, &ir_mantis, NULL, MODULE_NAME); 136 err = rc_register_device(dev);
129 if (err) { 137 if (err) {
130 dprintk(MANTIS_ERROR, 1, "IR device registration failed, ret = %d", err); 138 dprintk(MANTIS_ERROR, 1, "IR device registration failed, ret = %d", err);
131 input_free_device(rc); 139 goto out_dev;
132 return -ENODEV;
133 } 140 }
134 141
135 mantis->rc = rc; 142 mantis->rc = dev;
136
137 return 0; 143 return 0;
144
145out_dev:
146 rc_free_device(dev);
147out_map:
148 ir_unregister_map(&ir_mantis_map);
149out:
150 return err;
138} 151}
139 152
140int mantis_exit(struct mantis_pci *mantis) 153int mantis_exit(struct mantis_pci *mantis)
141{ 154{
142 struct input_dev *rc = mantis->rc; 155 rc_unregister_device(mantis->rc);
143 156 ir_unregister_map(&ir_mantis_map);
144 ir_input_unregister(rc);
145
146 return 0; 157 return 0;
147} 158}
159
diff --git a/drivers/media/dvb/siano/smscoreapi.c b/drivers/media/dvb/siano/smscoreapi.c
index 135e45bd00c..78765ed2806 100644
--- a/drivers/media/dvb/siano/smscoreapi.c
+++ b/drivers/media/dvb/siano/smscoreapi.c
@@ -438,7 +438,7 @@ static int smscore_init_ir(struct smscore_device_t *coredev)
438 int rc; 438 int rc;
439 void *buffer; 439 void *buffer;
440 440
441 coredev->ir.input_dev = NULL; 441 coredev->ir.dev = NULL;
442 ir_io = sms_get_board(smscore_get_board_id(coredev))->board_cfg.ir; 442 ir_io = sms_get_board(smscore_get_board_id(coredev))->board_cfg.ir;
443 if (ir_io) {/* only if IR port exist we use IR sub-module */ 443 if (ir_io) {/* only if IR port exist we use IR sub-module */
444 sms_info("IR loading"); 444 sms_info("IR loading");
diff --git a/drivers/media/dvb/siano/smsir.c b/drivers/media/dvb/siano/smsir.c
index a27c44a8af5..ebd73059b51 100644
--- a/drivers/media/dvb/siano/smsir.c
+++ b/drivers/media/dvb/siano/smsir.c
@@ -45,25 +45,24 @@ void sms_ir_event(struct smscore_device_t *coredev, const char *buf, int len)
45 ev.duration = abs(samples[i]) * 1000; /* Convert to ns */ 45 ev.duration = abs(samples[i]) * 1000; /* Convert to ns */
46 ev.pulse = (samples[i] > 0) ? false : true; 46 ev.pulse = (samples[i] > 0) ? false : true;
47 47
48 ir_raw_event_store(coredev->ir.input_dev, &ev); 48 ir_raw_event_store(coredev->ir.dev, &ev);
49 } 49 }
50 ir_raw_event_handle(coredev->ir.input_dev); 50 ir_raw_event_handle(coredev->ir.dev);
51} 51}
52 52
53int sms_ir_init(struct smscore_device_t *coredev) 53int sms_ir_init(struct smscore_device_t *coredev)
54{ 54{
55 struct input_dev *input_dev; 55 int err;
56 int board_id = smscore_get_board_id(coredev); 56 int board_id = smscore_get_board_id(coredev);
57 struct rc_dev *dev;
57 58
58 sms_log("Allocating input device"); 59 sms_log("Allocating rc device");
59 input_dev = input_allocate_device(); 60 dev = rc_allocate_device();
60 if (!input_dev) { 61 if (!dev) {
61 sms_err("Not enough memory"); 62 sms_err("Not enough memory");
62 return -ENOMEM; 63 return -ENOMEM;
63 } 64 }
64 65
65 coredev->ir.input_dev = input_dev;
66
67 coredev->ir.controller = 0; /* Todo: vega/nova SPI number */ 66 coredev->ir.controller = 0; /* Todo: vega/nova SPI number */
68 coredev->ir.timeout = IR_DEFAULT_TIMEOUT; 67 coredev->ir.timeout = IR_DEFAULT_TIMEOUT;
69 sms_log("IR port %d, timeout %d ms", 68 sms_log("IR port %d, timeout %d ms",
@@ -75,38 +74,41 @@ int sms_ir_init(struct smscore_device_t *coredev)
75 strlcpy(coredev->ir.phys, coredev->devpath, sizeof(coredev->ir.phys)); 74 strlcpy(coredev->ir.phys, coredev->devpath, sizeof(coredev->ir.phys));
76 strlcat(coredev->ir.phys, "/ir0", sizeof(coredev->ir.phys)); 75 strlcat(coredev->ir.phys, "/ir0", sizeof(coredev->ir.phys));
77 76
78 input_dev->name = coredev->ir.name; 77 dev->input_name = coredev->ir.name;
79 input_dev->phys = coredev->ir.phys; 78 dev->input_phys = coredev->ir.phys;
80 input_dev->dev.parent = coredev->device; 79 dev->dev.parent = coredev->device;
81 80
82#if 0 81#if 0
83 /* TODO: properly initialize the parameters bellow */ 82 /* TODO: properly initialize the parameters bellow */
84 input_dev->id.bustype = BUS_USB; 83 dev->input_id.bustype = BUS_USB;
85 input_dev->id.version = 1; 84 dev->input_id.version = 1;
86 input_dev->id.vendor = le16_to_cpu(dev->udev->descriptor.idVendor); 85 dev->input_id.vendor = le16_to_cpu(dev->udev->descriptor.idVendor);
87 input_dev->id.product = le16_to_cpu(dev->udev->descriptor.idProduct); 86 dev->input_id.product = le16_to_cpu(dev->udev->descriptor.idProduct);
88#endif 87#endif
89 88
90 coredev->ir.props.priv = coredev; 89 dev->priv = coredev;
91 coredev->ir.props.driver_type = RC_DRIVER_IR_RAW; 90 dev->driver_type = RC_DRIVER_IR_RAW;
92 coredev->ir.props.allowed_protos = IR_TYPE_ALL; 91 dev->allowed_protos = IR_TYPE_ALL;
92 dev->map_name = sms_get_board(board_id)->rc_codes;
93 dev->driver_name = MODULE_NAME;
93 94
94 sms_log("Input device (IR) %s is set for key events", input_dev->name); 95 sms_log("Input device (IR) %s is set for key events", dev->input_name);
95 96
96 if (ir_input_register(input_dev, sms_get_board(board_id)->rc_codes, 97 err = rc_register_device(dev);
97 &coredev->ir.props, MODULE_NAME)) { 98 if (err < 0) {
98 sms_err("Failed to register device"); 99 sms_err("Failed to register device");
99 input_free_device(input_dev); 100 rc_free_device(dev);
100 return -EACCES; 101 return err;
101 } 102 }
102 103
104 coredev->ir.dev = dev;
103 return 0; 105 return 0;
104} 106}
105 107
106void sms_ir_exit(struct smscore_device_t *coredev) 108void sms_ir_exit(struct smscore_device_t *coredev)
107{ 109{
108 if (coredev->ir.input_dev) 110 if (coredev->ir.dev)
109 ir_input_unregister(coredev->ir.input_dev); 111 rc_unregister_device(coredev->ir.dev);
110 112
111 sms_log(""); 113 sms_log("");
112} 114}
diff --git a/drivers/media/dvb/siano/smsir.h b/drivers/media/dvb/siano/smsir.h
index 926e247523b..c2f68a460ee 100644
--- a/drivers/media/dvb/siano/smsir.h
+++ b/drivers/media/dvb/siano/smsir.h
@@ -35,13 +35,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
35struct smscore_device_t; 35struct smscore_device_t;
36 36
37struct ir_t { 37struct ir_t {
38 struct input_dev *input_dev; 38 struct rc_dev *dev;
39 char name[40]; 39 char name[40];
40 char phys[32]; 40 char phys[32];
41 41
42 char *rc_codes; 42 char *rc_codes;
43 u64 protocol; 43 u64 protocol;
44 struct ir_dev_props props;
45 44
46 u32 timeout; 45 u32 timeout;
47 u32 controller; 46 u32 controller;
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index a9c2c326df4..9aca0f37993 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -33,7 +33,6 @@
33#include <linux/errno.h> 33#include <linux/errno.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <linux/input.h>
37#include <linux/spinlock.h> 36#include <linux/spinlock.h>
38#include <media/ir-core.h> 37#include <media/ir-core.h>
39 38
@@ -96,7 +95,7 @@ MODULE_PARM_DESC(ir_debug, "enable debugging information for IR decoding");
96DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 95DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
97 96
98struct budget_ci_ir { 97struct budget_ci_ir {
99 struct input_dev *dev; 98 struct rc_dev *dev;
100 struct tasklet_struct msp430_irq_tasklet; 99 struct tasklet_struct msp430_irq_tasklet;
101 char name[72]; /* 40 + 32 for (struct saa7146_dev).name */ 100 char name[72]; /* 40 + 32 for (struct saa7146_dev).name */
102 char phys[32]; 101 char phys[32];
@@ -118,7 +117,7 @@ struct budget_ci {
118static void msp430_ir_interrupt(unsigned long data) 117static void msp430_ir_interrupt(unsigned long data)
119{ 118{
120 struct budget_ci *budget_ci = (struct budget_ci *) data; 119 struct budget_ci *budget_ci = (struct budget_ci *) data;
121 struct input_dev *dev = budget_ci->ir.dev; 120 struct rc_dev *dev = budget_ci->ir.dev;
122 u32 command = ttpci_budget_debiread(&budget_ci->budget, DEBINOSWAP, DEBIADDR_IR, 2, 1, 0) >> 8; 121 u32 command = ttpci_budget_debiread(&budget_ci->budget, DEBINOSWAP, DEBIADDR_IR, 2, 1, 0) >> 8;
123 122
124 /* 123 /*
@@ -166,13 +165,11 @@ static void msp430_ir_interrupt(unsigned long data)
166static int msp430_ir_init(struct budget_ci *budget_ci) 165static int msp430_ir_init(struct budget_ci *budget_ci)
167{ 166{
168 struct saa7146_dev *saa = budget_ci->budget.dev; 167 struct saa7146_dev *saa = budget_ci->budget.dev;
169 struct input_dev *input_dev = budget_ci->ir.dev; 168 struct rc_dev *dev;
170 int error; 169 int error;
171 char *ir_codes = NULL;
172 170
173 171 dev = rc_allocate_device();
174 budget_ci->ir.dev = input_dev = input_allocate_device(); 172 if (!dev) {
175 if (!input_dev) {
176 printk(KERN_ERR "budget_ci: IR interface initialisation failed\n"); 173 printk(KERN_ERR "budget_ci: IR interface initialisation failed\n");
177 return -ENOMEM; 174 return -ENOMEM;
178 } 175 }
@@ -182,19 +179,19 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
182 snprintf(budget_ci->ir.phys, sizeof(budget_ci->ir.phys), 179 snprintf(budget_ci->ir.phys, sizeof(budget_ci->ir.phys),
183 "pci-%s/ir0", pci_name(saa->pci)); 180 "pci-%s/ir0", pci_name(saa->pci));
184 181
185 input_dev->name = budget_ci->ir.name; 182 dev->driver_name = MODULE_NAME;
186 183 dev->input_name = budget_ci->ir.name;
187 input_dev->phys = budget_ci->ir.phys; 184 dev->input_phys = budget_ci->ir.phys;
188 input_dev->id.bustype = BUS_PCI; 185 dev->input_id.bustype = BUS_PCI;
189 input_dev->id.version = 1; 186 dev->input_id.version = 1;
190 if (saa->pci->subsystem_vendor) { 187 if (saa->pci->subsystem_vendor) {
191 input_dev->id.vendor = saa->pci->subsystem_vendor; 188 dev->input_id.vendor = saa->pci->subsystem_vendor;
192 input_dev->id.product = saa->pci->subsystem_device; 189 dev->input_id.product = saa->pci->subsystem_device;
193 } else { 190 } else {
194 input_dev->id.vendor = saa->pci->vendor; 191 dev->input_id.vendor = saa->pci->vendor;
195 input_dev->id.product = saa->pci->device; 192 dev->input_id.product = saa->pci->device;
196 } 193 }
197 input_dev->dev.parent = &saa->pci->dev; 194 dev->dev.parent = &saa->pci->dev;
198 195
199 if (rc5_device < 0) 196 if (rc5_device < 0)
200 budget_ci->ir.rc5_device = IR_DEVICE_ANY; 197 budget_ci->ir.rc5_device = IR_DEVICE_ANY;
@@ -208,7 +205,7 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
208 case 0x1011: 205 case 0x1011:
209 case 0x1012: 206 case 0x1012:
210 /* The hauppauge keymap is a superset of these remotes */ 207 /* The hauppauge keymap is a superset of these remotes */
211 ir_codes = RC_MAP_HAUPPAUGE_NEW; 208 dev->map_name = RC_MAP_HAUPPAUGE_NEW;
212 209
213 if (rc5_device < 0) 210 if (rc5_device < 0)
214 budget_ci->ir.rc5_device = 0x1f; 211 budget_ci->ir.rc5_device = 0x1f;
@@ -218,23 +215,22 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
218 case 0x1019: 215 case 0x1019:
219 case 0x101a: 216 case 0x101a:
220 /* for the Technotrend 1500 bundled remote */ 217 /* for the Technotrend 1500 bundled remote */
221 ir_codes = RC_MAP_TT_1500; 218 dev->map_name = RC_MAP_TT_1500;
222 break; 219 break;
223 default: 220 default:
224 /* unknown remote */ 221 /* unknown remote */
225 ir_codes = RC_MAP_BUDGET_CI_OLD; 222 dev->map_name = RC_MAP_BUDGET_CI_OLD;
226 break; 223 break;
227 } 224 }
228 225
229 error = ir_input_register(input_dev, ir_codes, NULL, MODULE_NAME); 226 error = rc_register_device(dev);
230 if (error) { 227 if (error) {
231 printk(KERN_ERR "budget_ci: could not init driver for IR device (code %d)\n", error); 228 printk(KERN_ERR "budget_ci: could not init driver for IR device (code %d)\n", error);
229 rc_free_device(dev);
232 return error; 230 return error;
233 } 231 }
234 232
235 /* note: these must be after input_register_device */ 233 budget_ci->ir.dev = dev;
236 input_dev->rep[REP_DELAY] = 400;
237 input_dev->rep[REP_PERIOD] = 250;
238 234
239 tasklet_init(&budget_ci->ir.msp430_irq_tasklet, msp430_ir_interrupt, 235 tasklet_init(&budget_ci->ir.msp430_irq_tasklet, msp430_ir_interrupt,
240 (unsigned long) budget_ci); 236 (unsigned long) budget_ci);
@@ -248,13 +244,12 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
248static void msp430_ir_deinit(struct budget_ci *budget_ci) 244static void msp430_ir_deinit(struct budget_ci *budget_ci)
249{ 245{
250 struct saa7146_dev *saa = budget_ci->budget.dev; 246 struct saa7146_dev *saa = budget_ci->budget.dev;
251 struct input_dev *dev = budget_ci->ir.dev;
252 247
253 SAA7146_IER_DISABLE(saa, MASK_06); 248 SAA7146_IER_DISABLE(saa, MASK_06);
254 saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT); 249 saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
255 tasklet_kill(&budget_ci->ir.msp430_irq_tasklet); 250 tasklet_kill(&budget_ci->ir.msp430_irq_tasklet);
256 251
257 ir_input_unregister(dev); 252 rc_unregister_device(budget_ci->ir.dev);
258} 253}
259 254
260static int ciintf_read_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address) 255static int ciintf_read_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address)
diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c
index 7637babcd26..0a4151f03c7 100644
--- a/drivers/media/rc/ene_ir.c
+++ b/drivers/media/rc/ene_ir.c
@@ -37,9 +37,7 @@
37#include <linux/interrupt.h> 37#include <linux/interrupt.h>
38#include <linux/sched.h> 38#include <linux/sched.h>
39#include <linux/slab.h> 39#include <linux/slab.h>
40#include <linux/input.h>
41#include <media/ir-core.h> 40#include <media/ir-core.h>
42#include <media/ir-common.h>
43#include "ene_ir.h" 41#include "ene_ir.h"
44 42
45static int sample_period; 43static int sample_period;
@@ -357,7 +355,7 @@ void ene_rx_sense_carrier(struct ene_device *dev)
357 ev.carrier_report = true; 355 ev.carrier_report = true;
358 ev.carrier = carrier; 356 ev.carrier = carrier;
359 ev.duty_cycle = duty_cycle; 357 ev.duty_cycle = duty_cycle;
360 ir_raw_event_store(dev->idev, &ev); 358 ir_raw_event_store(dev->rdev, &ev);
361 } 359 }
362} 360}
363 361
@@ -448,32 +446,32 @@ static void ene_rx_setup(struct ene_device *dev)
448 446
449select_timeout: 447select_timeout:
450 if (dev->rx_fan_input_inuse) { 448 if (dev->rx_fan_input_inuse) {
451 dev->props->rx_resolution = MS_TO_NS(ENE_FW_SAMPLE_PERIOD_FAN); 449 dev->rdev->rx_resolution = MS_TO_NS(ENE_FW_SAMPLE_PERIOD_FAN);
452 450
453 /* Fan input doesn't support timeouts, it just ends the 451 /* Fan input doesn't support timeouts, it just ends the
454 input with a maximum sample */ 452 input with a maximum sample */
455 dev->props->min_timeout = dev->props->max_timeout = 453 dev->rdev->min_timeout = dev->rdev->max_timeout =
456 MS_TO_NS(ENE_FW_SMPL_BUF_FAN_MSK * 454 MS_TO_NS(ENE_FW_SMPL_BUF_FAN_MSK *
457 ENE_FW_SAMPLE_PERIOD_FAN); 455 ENE_FW_SAMPLE_PERIOD_FAN);
458 } else { 456 } else {
459 dev->props->rx_resolution = MS_TO_NS(sample_period); 457 dev->rdev->rx_resolution = MS_TO_NS(sample_period);
460 458
461 /* Theoreticly timeout is unlimited, but we cap it 459 /* Theoreticly timeout is unlimited, but we cap it
462 * because it was seen that on one device, it 460 * because it was seen that on one device, it
463 * would stop sending spaces after around 250 msec. 461 * would stop sending spaces after around 250 msec.
464 * Besides, this is close to 2^32 anyway and timeout is u32. 462 * Besides, this is close to 2^32 anyway and timeout is u32.
465 */ 463 */
466 dev->props->min_timeout = MS_TO_NS(127 * sample_period); 464 dev->rdev->min_timeout = MS_TO_NS(127 * sample_period);
467 dev->props->max_timeout = MS_TO_NS(200000); 465 dev->rdev->max_timeout = MS_TO_NS(200000);
468 } 466 }
469 467
470 if (dev->hw_learning_and_tx_capable) 468 if (dev->hw_learning_and_tx_capable)
471 dev->props->tx_resolution = MS_TO_NS(sample_period); 469 dev->rdev->tx_resolution = MS_TO_NS(sample_period);
472 470
473 if (dev->props->timeout > dev->props->max_timeout) 471 if (dev->rdev->timeout > dev->rdev->max_timeout)
474 dev->props->timeout = dev->props->max_timeout; 472 dev->rdev->timeout = dev->rdev->max_timeout;
475 if (dev->props->timeout < dev->props->min_timeout) 473 if (dev->rdev->timeout < dev->rdev->min_timeout)
476 dev->props->timeout = dev->props->min_timeout; 474 dev->rdev->timeout = dev->rdev->min_timeout;
477} 475}
478 476
479/* Enable the device for receive */ 477/* Enable the device for receive */
@@ -504,7 +502,7 @@ static void ene_rx_enable(struct ene_device *dev)
504 ene_set_reg_mask(dev, ENE_FW1, ENE_FW1_ENABLE | ENE_FW1_IRQ); 502 ene_set_reg_mask(dev, ENE_FW1, ENE_FW1_ENABLE | ENE_FW1_IRQ);
505 503
506 /* enter idle mode */ 504 /* enter idle mode */
507 ir_raw_event_set_idle(dev->idev, true); 505 ir_raw_event_set_idle(dev->rdev, true);
508 dev->rx_enabled = true; 506 dev->rx_enabled = true;
509} 507}
510 508
@@ -518,7 +516,7 @@ static void ene_rx_disable(struct ene_device *dev)
518 /* disable hardware IRQ and firmware flag */ 516 /* disable hardware IRQ and firmware flag */
519 ene_clear_reg_mask(dev, ENE_FW1, ENE_FW1_ENABLE | ENE_FW1_IRQ); 517 ene_clear_reg_mask(dev, ENE_FW1, ENE_FW1_ENABLE | ENE_FW1_IRQ);
520 518
521 ir_raw_event_set_idle(dev->idev, true); 519 ir_raw_event_set_idle(dev->rdev, true);
522 dev->rx_enabled = false; 520 dev->rx_enabled = false;
523} 521}
524 522
@@ -805,10 +803,10 @@ static irqreturn_t ene_isr(int irq, void *data)
805 803
806 ev.duration = MS_TO_NS(hw_sample); 804 ev.duration = MS_TO_NS(hw_sample);
807 ev.pulse = pulse; 805 ev.pulse = pulse;
808 ir_raw_event_store_with_filter(dev->idev, &ev); 806 ir_raw_event_store_with_filter(dev->rdev, &ev);
809 } 807 }
810 808
811 ir_raw_event_handle(dev->idev); 809 ir_raw_event_handle(dev->rdev);
812unlock: 810unlock:
813 spin_unlock_irqrestore(&dev->hw_lock, flags); 811 spin_unlock_irqrestore(&dev->hw_lock, flags);
814 return retval; 812 return retval;
@@ -823,7 +821,7 @@ static void ene_setup_default_settings(struct ene_device *dev)
823 dev->learning_mode_enabled = learning_mode_force; 821 dev->learning_mode_enabled = learning_mode_force;
824 822
825 /* Set reasonable default timeout */ 823 /* Set reasonable default timeout */
826 dev->props->timeout = MS_TO_NS(150000); 824 dev->rdev->timeout = MS_TO_NS(150000);
827} 825}
828 826
829/* Upload all hardware settings at once. Used at load and resume time */ 827/* Upload all hardware settings at once. Used at load and resume time */
@@ -838,9 +836,9 @@ static void ene_setup_hw_settings(struct ene_device *dev)
838} 836}
839 837
840/* outside interface: called on first open*/ 838/* outside interface: called on first open*/
841static int ene_open(void *data) 839static int ene_open(struct rc_dev *rdev)
842{ 840{
843 struct ene_device *dev = (struct ene_device *)data; 841 struct ene_device *dev = rdev->priv;
844 unsigned long flags; 842 unsigned long flags;
845 843
846 spin_lock_irqsave(&dev->hw_lock, flags); 844 spin_lock_irqsave(&dev->hw_lock, flags);
@@ -850,9 +848,9 @@ static int ene_open(void *data)
850} 848}
851 849
852/* outside interface: called on device close*/ 850/* outside interface: called on device close*/
853static void ene_close(void *data) 851static void ene_close(struct rc_dev *rdev)
854{ 852{
855 struct ene_device *dev = (struct ene_device *)data; 853 struct ene_device *dev = rdev->priv;
856 unsigned long flags; 854 unsigned long flags;
857 spin_lock_irqsave(&dev->hw_lock, flags); 855 spin_lock_irqsave(&dev->hw_lock, flags);
858 856
@@ -861,9 +859,9 @@ static void ene_close(void *data)
861} 859}
862 860
863/* outside interface: set transmitter mask */ 861/* outside interface: set transmitter mask */
864static int ene_set_tx_mask(void *data, u32 tx_mask) 862static int ene_set_tx_mask(struct rc_dev *rdev, u32 tx_mask)
865{ 863{
866 struct ene_device *dev = (struct ene_device *)data; 864 struct ene_device *dev = rdev->priv;
867 dbg("TX: attempt to set transmitter mask %02x", tx_mask); 865 dbg("TX: attempt to set transmitter mask %02x", tx_mask);
868 866
869 /* invalid txmask */ 867 /* invalid txmask */
@@ -879,9 +877,9 @@ static int ene_set_tx_mask(void *data, u32 tx_mask)
879} 877}
880 878
881/* outside interface : set tx carrier */ 879/* outside interface : set tx carrier */
882static int ene_set_tx_carrier(void *data, u32 carrier) 880static int ene_set_tx_carrier(struct rc_dev *rdev, u32 carrier)
883{ 881{
884 struct ene_device *dev = (struct ene_device *)data; 882 struct ene_device *dev = rdev->priv;
885 u32 period = 2000000 / carrier; 883 u32 period = 2000000 / carrier;
886 884
887 dbg("TX: attempt to set tx carrier to %d kHz", carrier); 885 dbg("TX: attempt to set tx carrier to %d kHz", carrier);
@@ -900,9 +898,9 @@ static int ene_set_tx_carrier(void *data, u32 carrier)
900} 898}
901 899
902/*outside interface : set tx duty cycle */ 900/*outside interface : set tx duty cycle */
903static int ene_set_tx_duty_cycle(void *data, u32 duty_cycle) 901static int ene_set_tx_duty_cycle(struct rc_dev *rdev, u32 duty_cycle)
904{ 902{
905 struct ene_device *dev = (struct ene_device *)data; 903 struct ene_device *dev = rdev->priv;
906 dbg("TX: setting duty cycle to %d%%", duty_cycle); 904 dbg("TX: setting duty cycle to %d%%", duty_cycle);
907 dev->tx_duty_cycle = duty_cycle; 905 dev->tx_duty_cycle = duty_cycle;
908 ene_tx_set_carrier(dev); 906 ene_tx_set_carrier(dev);
@@ -910,9 +908,9 @@ static int ene_set_tx_duty_cycle(void *data, u32 duty_cycle)
910} 908}
911 909
912/* outside interface: enable learning mode */ 910/* outside interface: enable learning mode */
913static int ene_set_learning_mode(void *data, int enable) 911static int ene_set_learning_mode(struct rc_dev *rdev, int enable)
914{ 912{
915 struct ene_device *dev = (struct ene_device *)data; 913 struct ene_device *dev = rdev->priv;
916 unsigned long flags; 914 unsigned long flags;
917 if (enable == dev->learning_mode_enabled) 915 if (enable == dev->learning_mode_enabled)
918 return 0; 916 return 0;
@@ -926,9 +924,9 @@ static int ene_set_learning_mode(void *data, int enable)
926 return 0; 924 return 0;
927} 925}
928 926
929static int ene_set_carrier_report(void *data, int enable) 927static int ene_set_carrier_report(struct rc_dev *rdev, int enable)
930{ 928{
931 struct ene_device *dev = (struct ene_device *)data; 929 struct ene_device *dev = rdev->priv;
932 unsigned long flags; 930 unsigned long flags;
933 931
934 if (enable == dev->carrier_detect_enabled) 932 if (enable == dev->carrier_detect_enabled)
@@ -944,18 +942,20 @@ static int ene_set_carrier_report(void *data, int enable)
944} 942}
945 943
946/* outside interface: enable or disable idle mode */ 944/* outside interface: enable or disable idle mode */
947static void ene_set_idle(void *data, bool idle) 945static void ene_set_idle(struct rc_dev *rdev, bool idle)
948{ 946{
947 struct ene_device *dev = rdev->priv;
948
949 if (idle) { 949 if (idle) {
950 ene_rx_reset((struct ene_device *)data); 950 ene_rx_reset(dev);
951 dbg("RX: end of data"); 951 dbg("RX: end of data");
952 } 952 }
953} 953}
954 954
955/* outside interface: transmit */ 955/* outside interface: transmit */
956static int ene_transmit(void *data, int *buf, u32 n) 956static int ene_transmit(struct rc_dev *rdev, int *buf, u32 n)
957{ 957{
958 struct ene_device *dev = (struct ene_device *)data; 958 struct ene_device *dev = rdev->priv;
959 unsigned long flags; 959 unsigned long flags;
960 960
961 dev->tx_buffer = buf; 961 dev->tx_buffer = buf;
@@ -992,16 +992,13 @@ static int ene_transmit(void *data, int *buf, u32 n)
992static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id) 992static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
993{ 993{
994 int error = -ENOMEM; 994 int error = -ENOMEM;
995 struct ir_dev_props *ir_props; 995 struct rc_dev *rdev;
996 struct input_dev *input_dev;
997 struct ene_device *dev; 996 struct ene_device *dev;
998 997
999 /* allocate memory */ 998 /* allocate memory */
1000 input_dev = input_allocate_device();
1001 ir_props = kzalloc(sizeof(struct ir_dev_props), GFP_KERNEL);
1002 dev = kzalloc(sizeof(struct ene_device), GFP_KERNEL); 999 dev = kzalloc(sizeof(struct ene_device), GFP_KERNEL);
1003 1000 rdev = rc_allocate_device();
1004 if (!input_dev || !ir_props || !dev) 1001 if (!dev || !rdev)
1005 goto error1; 1002 goto error1;
1006 1003
1007 /* validate resources */ 1004 /* validate resources */
@@ -1054,24 +1051,25 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1054 if (!dev->hw_learning_and_tx_capable) 1051 if (!dev->hw_learning_and_tx_capable)
1055 learning_mode_force = false; 1052 learning_mode_force = false;
1056 1053
1057 ir_props->driver_type = RC_DRIVER_IR_RAW; 1054 rdev->driver_type = RC_DRIVER_IR_RAW;
1058 ir_props->allowed_protos = IR_TYPE_ALL; 1055 rdev->allowed_protos = IR_TYPE_ALL;
1059 ir_props->priv = dev; 1056 rdev->priv = dev;
1060 ir_props->open = ene_open; 1057 rdev->open = ene_open;
1061 ir_props->close = ene_close; 1058 rdev->close = ene_close;
1062 ir_props->s_idle = ene_set_idle; 1059 rdev->s_idle = ene_set_idle;
1063 1060 rdev->driver_name = ENE_DRIVER_NAME;
1064 dev->props = ir_props; 1061 rdev->map_name = RC_MAP_RC6_MCE;
1065 dev->idev = input_dev; 1062 rdev->input_name = "ENE eHome Infrared Remote Receiver";
1066 1063
1067 if (dev->hw_learning_and_tx_capable) { 1064 if (dev->hw_learning_and_tx_capable) {
1068 ir_props->s_learning_mode = ene_set_learning_mode; 1065 rdev->s_learning_mode = ene_set_learning_mode;
1069 init_completion(&dev->tx_complete); 1066 init_completion(&dev->tx_complete);
1070 ir_props->tx_ir = ene_transmit; 1067 rdev->tx_ir = ene_transmit;
1071 ir_props->s_tx_mask = ene_set_tx_mask; 1068 rdev->s_tx_mask = ene_set_tx_mask;
1072 ir_props->s_tx_carrier = ene_set_tx_carrier; 1069 rdev->s_tx_carrier = ene_set_tx_carrier;
1073 ir_props->s_tx_duty_cycle = ene_set_tx_duty_cycle; 1070 rdev->s_tx_duty_cycle = ene_set_tx_duty_cycle;
1074 ir_props->s_carrier_report = ene_set_carrier_report; 1071 rdev->s_carrier_report = ene_set_carrier_report;
1072 rdev->input_name = "ENE eHome Infrared Remote Transceiver";
1075 } 1073 }
1076 1074
1077 ene_rx_setup_hw_buffer(dev); 1075 ene_rx_setup_hw_buffer(dev);
@@ -1081,16 +1079,11 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1081 device_set_wakeup_capable(&pnp_dev->dev, true); 1079 device_set_wakeup_capable(&pnp_dev->dev, true);
1082 device_set_wakeup_enable(&pnp_dev->dev, true); 1080 device_set_wakeup_enable(&pnp_dev->dev, true);
1083 1081
1084 if (dev->hw_learning_and_tx_capable) 1082 error = rc_register_device(rdev);
1085 input_dev->name = "ENE eHome Infrared Remote Transceiver"; 1083 if (error < 0)
1086 else
1087 input_dev->name = "ENE eHome Infrared Remote Receiver";
1088
1089 error = -ENODEV;
1090 if (ir_input_register(input_dev, RC_MAP_RC6_MCE, ir_props,
1091 ENE_DRIVER_NAME))
1092 goto error; 1084 goto error;
1093 1085
1086 dev->rdev = rdev;
1094 ene_notice("driver has been succesfully loaded"); 1087 ene_notice("driver has been succesfully loaded");
1095 return 0; 1088 return 0;
1096error: 1089error:
@@ -1099,8 +1092,7 @@ error:
1099 if (dev && dev->hw_io >= 0) 1092 if (dev && dev->hw_io >= 0)
1100 release_region(dev->hw_io, ENE_IO_SIZE); 1093 release_region(dev->hw_io, ENE_IO_SIZE);
1101error1: 1094error1:
1102 input_free_device(input_dev); 1095 rc_free_device(rdev);
1103 kfree(ir_props);
1104 kfree(dev); 1096 kfree(dev);
1105 return error; 1097 return error;
1106} 1098}
@@ -1118,8 +1110,7 @@ static void ene_remove(struct pnp_dev *pnp_dev)
1118 1110
1119 free_irq(dev->irq, dev); 1111 free_irq(dev->irq, dev);
1120 release_region(dev->hw_io, ENE_IO_SIZE); 1112 release_region(dev->hw_io, ENE_IO_SIZE);
1121 ir_input_unregister(dev->idev); 1113 rc_unregister_device(dev->rdev);
1122 kfree(dev->props);
1123 kfree(dev); 1114 kfree(dev);
1124} 1115}
1125 1116
diff --git a/drivers/media/rc/ene_ir.h b/drivers/media/rc/ene_ir.h
index f5870667a43..c179baf34cb 100644
--- a/drivers/media/rc/ene_ir.h
+++ b/drivers/media/rc/ene_ir.h
@@ -205,8 +205,7 @@
205 205
206struct ene_device { 206struct ene_device {
207 struct pnp_dev *pnp_dev; 207 struct pnp_dev *pnp_dev;
208 struct input_dev *idev; 208 struct rc_dev *rdev;
209 struct ir_dev_props *props;
210 209
211 /* hw IO settings */ 210 /* hw IO settings */
212 long hw_io; 211 long hw_io;
diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 79f4f58c2ea..8d4b35d1ae5 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -88,7 +88,6 @@ static ssize_t lcd_write(struct file *file, const char *buf,
88 88
89struct imon_context { 89struct imon_context {
90 struct device *dev; 90 struct device *dev;
91 struct ir_dev_props *props;
92 /* Newer devices have two interfaces */ 91 /* Newer devices have two interfaces */
93 struct usb_device *usbdev_intf0; 92 struct usb_device *usbdev_intf0;
94 struct usb_device *usbdev_intf1; 93 struct usb_device *usbdev_intf1;
@@ -123,7 +122,7 @@ struct imon_context {
123 u16 vendor; /* usb vendor ID */ 122 u16 vendor; /* usb vendor ID */
124 u16 product; /* usb product ID */ 123 u16 product; /* usb product ID */
125 124
126 struct input_dev *rdev; /* input device for remote */ 125 struct rc_dev *rdev; /* rc-core device for remote */
127 struct input_dev *idev; /* input device for panel & IR mouse */ 126 struct input_dev *idev; /* input device for panel & IR mouse */
128 struct input_dev *touch; /* input device for touchscreen */ 127 struct input_dev *touch; /* input device for touchscreen */
129 128
@@ -984,16 +983,16 @@ static void imon_touch_display_timeout(unsigned long data)
984 * really just RC-6), but only one or the other at a time, as the signals 983 * really just RC-6), but only one or the other at a time, as the signals
985 * are decoded onboard the receiver. 984 * are decoded onboard the receiver.
986 */ 985 */
987int imon_ir_change_protocol(void *priv, u64 ir_type) 986static int imon_ir_change_protocol(struct rc_dev *rc, u64 ir_type)
988{ 987{
989 int retval; 988 int retval;
990 struct imon_context *ictx = priv; 989 struct imon_context *ictx = rc->priv;
991 struct device *dev = ictx->dev; 990 struct device *dev = ictx->dev;
992 bool pad_mouse; 991 bool pad_mouse;
993 unsigned char ir_proto_packet[] = { 992 unsigned char ir_proto_packet[] = {
994 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86 }; 993 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86 };
995 994
996 if (ir_type && !(ir_type & ictx->props->allowed_protos)) 995 if (ir_type && !(ir_type & rc->allowed_protos))
997 dev_warn(dev, "Looks like you're trying to use an IR protocol " 996 dev_warn(dev, "Looks like you're trying to use an IR protocol "
998 "this device does not support\n"); 997 "this device does not support\n");
999 998
@@ -1757,7 +1756,7 @@ static void imon_get_ffdc_type(struct imon_context *ictx)
1757 printk(KERN_CONT " (id 0x%02x)\n", ffdc_cfg_byte); 1756 printk(KERN_CONT " (id 0x%02x)\n", ffdc_cfg_byte);
1758 1757
1759 ictx->display_type = detected_display_type; 1758 ictx->display_type = detected_display_type;
1760 ictx->props->allowed_protos = allowed_protos; 1759 ictx->rdev->allowed_protos = allowed_protos;
1761 ictx->ir_type = allowed_protos; 1760 ictx->ir_type = allowed_protos;
1762} 1761}
1763 1762
@@ -1811,18 +1810,15 @@ static void imon_set_display_type(struct imon_context *ictx)
1811 ictx->display_type = configured_display_type; 1810 ictx->display_type = configured_display_type;
1812} 1811}
1813 1812
1814static struct input_dev *imon_init_rdev(struct imon_context *ictx) 1813static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
1815{ 1814{
1816 struct input_dev *rdev; 1815 struct rc_dev *rdev;
1817 struct ir_dev_props *props;
1818 int ret; 1816 int ret;
1819 char *ir_codes = NULL;
1820 const unsigned char fp_packet[] = { 0x40, 0x00, 0x00, 0x00, 1817 const unsigned char fp_packet[] = { 0x40, 0x00, 0x00, 0x00,
1821 0x00, 0x00, 0x00, 0x88 }; 1818 0x00, 0x00, 0x00, 0x88 };
1822 1819
1823 rdev = input_allocate_device(); 1820 rdev = rc_allocate_device();
1824 props = kzalloc(sizeof(*props), GFP_KERNEL); 1821 if (!rdev) {
1825 if (!rdev || !props) {
1826 dev_err(ictx->dev, "remote control dev allocation failed\n"); 1822 dev_err(ictx->dev, "remote control dev allocation failed\n");
1827 goto out; 1823 goto out;
1828 } 1824 }
@@ -1833,18 +1829,20 @@ static struct input_dev *imon_init_rdev(struct imon_context *ictx)
1833 sizeof(ictx->phys_rdev)); 1829 sizeof(ictx->phys_rdev));
1834 strlcat(ictx->phys_rdev, "/input0", sizeof(ictx->phys_rdev)); 1830 strlcat(ictx->phys_rdev, "/input0", sizeof(ictx->phys_rdev));
1835 1831
1836 rdev->name = ictx->name_rdev; 1832 rdev->input_name = ictx->name_rdev;
1837 rdev->phys = ictx->phys_rdev; 1833 rdev->input_phys = ictx->phys_rdev;
1838 usb_to_input_id(ictx->usbdev_intf0, &rdev->id); 1834 usb_to_input_id(ictx->usbdev_intf0, &rdev->input_id);
1839 rdev->dev.parent = ictx->dev; 1835 rdev->dev.parent = ictx->dev;
1840 rdev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
1841 input_set_drvdata(rdev, ictx);
1842 1836
1843 props->priv = ictx; 1837 rdev->priv = ictx;
1844 props->driver_type = RC_DRIVER_SCANCODE; 1838 rdev->driver_type = RC_DRIVER_SCANCODE;
1845 props->allowed_protos = IR_TYPE_OTHER | IR_TYPE_RC6; /* iMON PAD or MCE */ 1839 rdev->allowed_protos = IR_TYPE_OTHER | IR_TYPE_RC6; /* iMON PAD or MCE */
1846 props->change_protocol = imon_ir_change_protocol; 1840 rdev->change_protocol = imon_ir_change_protocol;
1847 ictx->props = props; 1841 rdev->driver_name = MOD_NAME;
1842 if (ictx->ir_type == IR_TYPE_RC6)
1843 rdev->map_name = RC_MAP_IMON_MCE;
1844 else
1845 rdev->map_name = RC_MAP_IMON_PAD;
1848 1846
1849 /* Enable front-panel buttons and/or knobs */ 1847 /* Enable front-panel buttons and/or knobs */
1850 memcpy(ictx->usb_tx_buf, &fp_packet, sizeof(fp_packet)); 1848 memcpy(ictx->usb_tx_buf, &fp_packet, sizeof(fp_packet));
@@ -1858,12 +1856,7 @@ static struct input_dev *imon_init_rdev(struct imon_context *ictx)
1858 1856
1859 imon_set_display_type(ictx); 1857 imon_set_display_type(ictx);
1860 1858
1861 if (ictx->ir_type == IR_TYPE_RC6) 1859 ret = rc_register_device(rdev);
1862 ir_codes = RC_MAP_IMON_MCE;
1863 else
1864 ir_codes = RC_MAP_IMON_PAD;
1865
1866 ret = ir_input_register(rdev, ir_codes, props, MOD_NAME);
1867 if (ret < 0) { 1860 if (ret < 0) {
1868 dev_err(ictx->dev, "remote input dev register failed\n"); 1861 dev_err(ictx->dev, "remote input dev register failed\n");
1869 goto out; 1862 goto out;
@@ -1872,8 +1865,7 @@ static struct input_dev *imon_init_rdev(struct imon_context *ictx)
1872 return rdev; 1865 return rdev;
1873 1866
1874out: 1867out:
1875 kfree(props); 1868 rc_free_device(rdev);
1876 input_free_device(rdev);
1877 return NULL; 1869 return NULL;
1878} 1870}
1879 1871
@@ -2144,7 +2136,7 @@ static struct imon_context *imon_init_intf0(struct usb_interface *intf)
2144 return ictx; 2136 return ictx;
2145 2137
2146urb_submit_failed: 2138urb_submit_failed:
2147 ir_input_unregister(ictx->rdev); 2139 rc_unregister_device(ictx->rdev);
2148rdev_setup_failed: 2140rdev_setup_failed:
2149 input_unregister_device(ictx->idev); 2141 input_unregister_device(ictx->idev);
2150idev_setup_failed: 2142idev_setup_failed:
@@ -2371,7 +2363,7 @@ static void __devexit imon_disconnect(struct usb_interface *interface)
2371 ictx->dev_present_intf0 = false; 2363 ictx->dev_present_intf0 = false;
2372 usb_kill_urb(ictx->rx_urb_intf0); 2364 usb_kill_urb(ictx->rx_urb_intf0);
2373 input_unregister_device(ictx->idev); 2365 input_unregister_device(ictx->idev);
2374 ir_input_unregister(ictx->rdev); 2366 rc_unregister_device(ictx->rdev);
2375 if (ictx->display_supported) { 2367 if (ictx->display_supported) {
2376 if (ictx->display_type == IMON_DISPLAY_TYPE_LCD) 2368 if (ictx->display_type == IMON_DISPLAY_TYPE_LCD)
2377 usb_deregister_dev(interface, &imon_lcd_class); 2369 usb_deregister_dev(interface, &imon_lcd_class);
diff --git a/drivers/media/rc/ir-jvc-decoder.c b/drivers/media/rc/ir-jvc-decoder.c
index d83a5f64bfe..cfe0e70440a 100644
--- a/drivers/media/rc/ir-jvc-decoder.c
+++ b/drivers/media/rc/ir-jvc-decoder.c
@@ -37,17 +37,16 @@ enum jvc_state {
37 37
38/** 38/**
39 * ir_jvc_decode() - Decode one JVC pulse or space 39 * ir_jvc_decode() - Decode one JVC pulse or space
40 * @input_dev: the struct input_dev descriptor of the device 40 * @dev: the struct rc_dev descriptor of the device
41 * @duration: the struct ir_raw_event descriptor of the pulse/space 41 * @duration: the struct ir_raw_event descriptor of the pulse/space
42 * 42 *
43 * This function returns -EINVAL if the pulse violates the state machine 43 * This function returns -EINVAL if the pulse violates the state machine
44 */ 44 */
45static int ir_jvc_decode(struct input_dev *input_dev, struct ir_raw_event ev) 45static int ir_jvc_decode(struct rc_dev *dev, struct ir_raw_event ev)
46{ 46{
47 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); 47 struct jvc_dec *data = &dev->raw->jvc;
48 struct jvc_dec *data = &ir_dev->raw->jvc;
49 48
50 if (!(ir_dev->raw->enabled_protocols & IR_TYPE_JVC)) 49 if (!(dev->raw->enabled_protocols & IR_TYPE_JVC))
51 return 0; 50 return 0;
52 51
53 if (!is_timing_event(ev)) { 52 if (!is_timing_event(ev)) {
@@ -140,12 +139,12 @@ again:
140 scancode = (bitrev8((data->bits >> 8) & 0xff) << 8) | 139 scancode = (bitrev8((data->bits >> 8) & 0xff) << 8) |
141 (bitrev8((data->bits >> 0) & 0xff) << 0); 140 (bitrev8((data->bits >> 0) & 0xff) << 0);
142 IR_dprintk(1, "JVC scancode 0x%04x\n", scancode); 141 IR_dprintk(1, "JVC scancode 0x%04x\n", scancode);
143 ir_keydown(input_dev, scancode, data->toggle); 142 ir_keydown(dev, scancode, data->toggle);
144 data->first = false; 143 data->first = false;
145 data->old_bits = data->bits; 144 data->old_bits = data->bits;
146 } else if (data->bits == data->old_bits) { 145 } else if (data->bits == data->old_bits) {
147 IR_dprintk(1, "JVC repeat\n"); 146 IR_dprintk(1, "JVC repeat\n");
148 ir_repeat(input_dev); 147 ir_repeat(dev);
149 } else { 148 } else {
150 IR_dprintk(1, "JVC invalid repeat msg\n"); 149 IR_dprintk(1, "JVC invalid repeat msg\n");
151 break; 150 break;
diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c
index 9345995dbf1..ceabea6053d 100644
--- a/drivers/media/rc/ir-lirc-codec.c
+++ b/drivers/media/rc/ir-lirc-codec.c
@@ -24,21 +24,20 @@
24/** 24/**
25 * ir_lirc_decode() - Send raw IR data to lirc_dev to be relayed to the 25 * ir_lirc_decode() - Send raw IR data to lirc_dev to be relayed to the
26 * lircd userspace daemon for decoding. 26 * lircd userspace daemon for decoding.
27 * @input_dev: the struct input_dev descriptor of the device 27 * @input_dev: the struct rc_dev descriptor of the device
28 * @duration: the struct ir_raw_event descriptor of the pulse/space 28 * @duration: the struct ir_raw_event descriptor of the pulse/space
29 * 29 *
30 * This function returns -EINVAL if the lirc interfaces aren't wired up. 30 * This function returns -EINVAL if the lirc interfaces aren't wired up.
31 */ 31 */
32static int ir_lirc_decode(struct input_dev *input_dev, struct ir_raw_event ev) 32static int ir_lirc_decode(struct rc_dev *dev, struct ir_raw_event ev)
33{ 33{
34 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); 34 struct lirc_codec *lirc = &dev->raw->lirc;
35 struct lirc_codec *lirc = &ir_dev->raw->lirc;
36 int sample; 35 int sample;
37 36
38 if (!(ir_dev->raw->enabled_protocols & IR_TYPE_LIRC)) 37 if (!(dev->raw->enabled_protocols & IR_TYPE_LIRC))
39 return 0; 38 return 0;
40 39
41 if (!ir_dev->raw->lirc.drv || !ir_dev->raw->lirc.drv->rbuf) 40 if (!dev->raw->lirc.drv || !dev->raw->lirc.drv->rbuf)
42 return -EINVAL; 41 return -EINVAL;
43 42
44 /* Packet start */ 43 /* Packet start */
@@ -79,7 +78,7 @@ static int ir_lirc_decode(struct input_dev *input_dev, struct ir_raw_event ev)
79 (u64)LIRC_VALUE_MASK); 78 (u64)LIRC_VALUE_MASK);
80 79
81 gap_sample = LIRC_SPACE(lirc->gap_duration); 80 gap_sample = LIRC_SPACE(lirc->gap_duration);
82 lirc_buffer_write(ir_dev->raw->lirc.drv->rbuf, 81 lirc_buffer_write(dev->raw->lirc.drv->rbuf,
83 (unsigned char *) &gap_sample); 82 (unsigned char *) &gap_sample);
84 lirc->gap = false; 83 lirc->gap = false;
85 } 84 }
@@ -88,9 +87,9 @@ static int ir_lirc_decode(struct input_dev *input_dev, struct ir_raw_event ev)
88 LIRC_SPACE(ev.duration / 1000); 87 LIRC_SPACE(ev.duration / 1000);
89 } 88 }
90 89
91 lirc_buffer_write(ir_dev->raw->lirc.drv->rbuf, 90 lirc_buffer_write(dev->raw->lirc.drv->rbuf,
92 (unsigned char *) &sample); 91 (unsigned char *) &sample);
93 wake_up(&ir_dev->raw->lirc.drv->rbuf->wait_poll); 92 wake_up(&dev->raw->lirc.drv->rbuf->wait_poll);
94 93
95 return 0; 94 return 0;
96} 95}
@@ -99,7 +98,7 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char *buf,
99 size_t n, loff_t *ppos) 98 size_t n, loff_t *ppos)
100{ 99{
101 struct lirc_codec *lirc; 100 struct lirc_codec *lirc;
102 struct ir_input_dev *ir_dev; 101 struct rc_dev *dev;
103 int *txbuf; /* buffer with values to transmit */ 102 int *txbuf; /* buffer with values to transmit */
104 int ret = 0, count; 103 int ret = 0, count;
105 104
@@ -118,14 +117,14 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char *buf,
118 if (IS_ERR(txbuf)) 117 if (IS_ERR(txbuf))
119 return PTR_ERR(txbuf); 118 return PTR_ERR(txbuf);
120 119
121 ir_dev = lirc->ir_dev; 120 dev = lirc->dev;
122 if (!ir_dev) { 121 if (!dev) {
123 ret = -EFAULT; 122 ret = -EFAULT;
124 goto out; 123 goto out;
125 } 124 }
126 125
127 if (ir_dev->props && ir_dev->props->tx_ir) 126 if (dev->tx_ir)
128 ret = ir_dev->props->tx_ir(ir_dev->props->priv, txbuf, (u32)n); 127 ret = dev->tx_ir(dev, txbuf, (u32)n);
129 128
130out: 129out:
131 kfree(txbuf); 130 kfree(txbuf);
@@ -136,21 +135,18 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd,
136 unsigned long __user arg) 135 unsigned long __user arg)
137{ 136{
138 struct lirc_codec *lirc; 137 struct lirc_codec *lirc;
139 struct ir_input_dev *ir_dev; 138 struct rc_dev *dev;
140 int ret = 0; 139 int ret = 0;
141 void *drv_data;
142 __u32 val = 0, tmp; 140 __u32 val = 0, tmp;
143 141
144 lirc = lirc_get_pdata(filep); 142 lirc = lirc_get_pdata(filep);
145 if (!lirc) 143 if (!lirc)
146 return -EFAULT; 144 return -EFAULT;
147 145
148 ir_dev = lirc->ir_dev; 146 dev = lirc->dev;
149 if (!ir_dev || !ir_dev->props || !ir_dev->props->priv) 147 if (!dev)
150 return -EFAULT; 148 return -EFAULT;
151 149
152 drv_data = ir_dev->props->priv;
153
154 if (_IOC_DIR(cmd) & _IOC_WRITE) { 150 if (_IOC_DIR(cmd) & _IOC_WRITE) {
155 ret = get_user(val, (__u32 *)arg); 151 ret = get_user(val, (__u32 *)arg);
156 if (ret) 152 if (ret)
@@ -171,84 +167,85 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd,
171 167
172 /* TX settings */ 168 /* TX settings */
173 case LIRC_SET_TRANSMITTER_MASK: 169 case LIRC_SET_TRANSMITTER_MASK:
174 if (!ir_dev->props->s_tx_mask) 170 if (!dev->s_tx_mask)
175 return -EINVAL; 171 return -EINVAL;
176 172
177 return ir_dev->props->s_tx_mask(drv_data, val); 173 return dev->s_tx_mask(dev, val);
178 174
179 case LIRC_SET_SEND_CARRIER: 175 case LIRC_SET_SEND_CARRIER:
180 if (!ir_dev->props->s_tx_carrier) 176 if (!dev->s_tx_carrier)
181 return -EINVAL; 177 return -EINVAL;
182 178
183 return ir_dev->props->s_tx_carrier(drv_data, val); 179 return dev->s_tx_carrier(dev, val);
184 180
185 case LIRC_SET_SEND_DUTY_CYCLE: 181 case LIRC_SET_SEND_DUTY_CYCLE:
186 if (!ir_dev->props->s_tx_duty_cycle) 182 if (!dev->s_tx_duty_cycle)
187 return -ENOSYS; 183 return -ENOSYS;
188 184
189 if (val <= 0 || val >= 100) 185 if (val <= 0 || val >= 100)
190 return -EINVAL; 186 return -EINVAL;
191 187
192 return ir_dev->props->s_tx_duty_cycle(drv_data, val); 188 return dev->s_tx_duty_cycle(dev, val);
193 189
194 /* RX settings */ 190 /* RX settings */
195 case LIRC_SET_REC_CARRIER: 191 case LIRC_SET_REC_CARRIER:
196 if (!ir_dev->props->s_rx_carrier_range) 192 if (!dev->s_rx_carrier_range)
197 return -ENOSYS; 193 return -ENOSYS;
198 194
199 if (val <= 0) 195 if (val <= 0)
200 return -EINVAL; 196 return -EINVAL;
201 197
202 return ir_dev->props->s_rx_carrier_range(drv_data, 198 return dev->s_rx_carrier_range(dev,
203 ir_dev->raw->lirc.carrier_low, val); 199 dev->raw->lirc.carrier_low,
200 val);
204 201
205 case LIRC_SET_REC_CARRIER_RANGE: 202 case LIRC_SET_REC_CARRIER_RANGE:
206 if (val <= 0) 203 if (val <= 0)
207 return -EINVAL; 204 return -EINVAL;
208 205
209 ir_dev->raw->lirc.carrier_low = val; 206 dev->raw->lirc.carrier_low = val;
210 return 0; 207 return 0;
211 208
212 case LIRC_GET_REC_RESOLUTION: 209 case LIRC_GET_REC_RESOLUTION:
213 val = ir_dev->props->rx_resolution; 210 val = dev->rx_resolution;
214 break; 211 break;
215 212
216 case LIRC_SET_WIDEBAND_RECEIVER: 213 case LIRC_SET_WIDEBAND_RECEIVER:
217 if (!ir_dev->props->s_learning_mode) 214 if (!dev->s_learning_mode)
218 return -ENOSYS; 215 return -ENOSYS;
219 216
220 return ir_dev->props->s_learning_mode(drv_data, !!val); 217 return dev->s_learning_mode(dev, !!val);
221 218
222 case LIRC_SET_MEASURE_CARRIER_MODE: 219 case LIRC_SET_MEASURE_CARRIER_MODE:
223 if (!ir_dev->props->s_carrier_report) 220 if (!dev->s_carrier_report)
224 return -ENOSYS; 221 return -ENOSYS;
225 222
226 return ir_dev->props->s_carrier_report(drv_data, !!val); 223 return dev->s_carrier_report(dev, !!val);
227 224
228 /* Generic timeout support */ 225 /* Generic timeout support */
229 case LIRC_GET_MIN_TIMEOUT: 226 case LIRC_GET_MIN_TIMEOUT:
230 if (!ir_dev->props->max_timeout) 227 if (!dev->max_timeout)
231 return -ENOSYS; 228 return -ENOSYS;
232 val = ir_dev->props->min_timeout / 1000; 229 val = dev->min_timeout / 1000;
233 break; 230 break;
234 231
235 case LIRC_GET_MAX_TIMEOUT: 232 case LIRC_GET_MAX_TIMEOUT:
236 if (!ir_dev->props->max_timeout) 233 if (!dev->max_timeout)
237 return -ENOSYS; 234 return -ENOSYS;
238 val = ir_dev->props->max_timeout / 1000; 235 val = dev->max_timeout / 1000;
239 break; 236 break;
240 237
241 case LIRC_SET_REC_TIMEOUT: 238 case LIRC_SET_REC_TIMEOUT:
242 if (!ir_dev->props->max_timeout) 239 if (!dev->max_timeout)
243 return -ENOSYS; 240 return -ENOSYS;
244 241
245 tmp = val * 1000; 242 tmp = val * 1000;
246 243
247 if (tmp < ir_dev->props->min_timeout || 244 if (tmp < dev->min_timeout ||
248 tmp > ir_dev->props->max_timeout) 245 tmp > dev->max_timeout)
249 return -EINVAL; 246 return -EINVAL;
250 247
251 ir_dev->props->timeout = tmp; 248 dev->timeout = tmp;
252 break; 249 break;
253 250
254 case LIRC_SET_REC_TIMEOUT_REPORTS: 251 case LIRC_SET_REC_TIMEOUT_REPORTS:
@@ -289,9 +286,8 @@ static struct file_operations lirc_fops = {
289 .llseek = no_llseek, 286 .llseek = no_llseek,
290}; 287};
291 288
292static int ir_lirc_register(struct input_dev *input_dev) 289static int ir_lirc_register(struct rc_dev *dev)
293{ 290{
294 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
295 struct lirc_driver *drv; 291 struct lirc_driver *drv;
296 struct lirc_buffer *rbuf; 292 struct lirc_buffer *rbuf;
297 int rc = -ENOMEM; 293 int rc = -ENOMEM;
@@ -310,44 +306,40 @@ static int ir_lirc_register(struct input_dev *input_dev)
310 goto rbuf_init_failed; 306 goto rbuf_init_failed;
311 307
312 features = LIRC_CAN_REC_MODE2; 308 features = LIRC_CAN_REC_MODE2;
313 if (ir_dev->props->tx_ir) { 309 if (dev->tx_ir) {
314
315 features |= LIRC_CAN_SEND_PULSE; 310 features |= LIRC_CAN_SEND_PULSE;
316 if (ir_dev->props->s_tx_mask) 311 if (dev->s_tx_mask)
317 features |= LIRC_CAN_SET_TRANSMITTER_MASK; 312 features |= LIRC_CAN_SET_TRANSMITTER_MASK;
318 if (ir_dev->props->s_tx_carrier) 313 if (dev->s_tx_carrier)
319 features |= LIRC_CAN_SET_SEND_CARRIER; 314 features |= LIRC_CAN_SET_SEND_CARRIER;
320 315 if (dev->s_tx_duty_cycle)
321 if (ir_dev->props->s_tx_duty_cycle)
322 features |= LIRC_CAN_SET_SEND_DUTY_CYCLE; 316 features |= LIRC_CAN_SET_SEND_DUTY_CYCLE;
323 } 317 }
324 318
325 if (ir_dev->props->s_rx_carrier_range) 319 if (dev->s_rx_carrier_range)
326 features |= LIRC_CAN_SET_REC_CARRIER | 320 features |= LIRC_CAN_SET_REC_CARRIER |
327 LIRC_CAN_SET_REC_CARRIER_RANGE; 321 LIRC_CAN_SET_REC_CARRIER_RANGE;
328 322
329 if (ir_dev->props->s_learning_mode) 323 if (dev->s_learning_mode)
330 features |= LIRC_CAN_USE_WIDEBAND_RECEIVER; 324 features |= LIRC_CAN_USE_WIDEBAND_RECEIVER;
331 325
332 if (ir_dev->props->s_carrier_report) 326 if (dev->s_carrier_report)
333 features |= LIRC_CAN_MEASURE_CARRIER; 327 features |= LIRC_CAN_MEASURE_CARRIER;
334 328
335 329 if (dev->max_timeout)
336 if (ir_dev->props->max_timeout)
337 features |= LIRC_CAN_SET_REC_TIMEOUT; 330 features |= LIRC_CAN_SET_REC_TIMEOUT;
338 331
339
340 snprintf(drv->name, sizeof(drv->name), "ir-lirc-codec (%s)", 332 snprintf(drv->name, sizeof(drv->name), "ir-lirc-codec (%s)",
341 ir_dev->driver_name); 333 dev->driver_name);
342 drv->minor = -1; 334 drv->minor = -1;
343 drv->features = features; 335 drv->features = features;
344 drv->data = &ir_dev->raw->lirc; 336 drv->data = &dev->raw->lirc;
345 drv->rbuf = rbuf; 337 drv->rbuf = rbuf;
346 drv->set_use_inc = &ir_lirc_open; 338 drv->set_use_inc = &ir_lirc_open;
347 drv->set_use_dec = &ir_lirc_close; 339 drv->set_use_dec = &ir_lirc_close;
348 drv->code_length = sizeof(struct ir_raw_event) * 8; 340 drv->code_length = sizeof(struct ir_raw_event) * 8;
349 drv->fops = &lirc_fops; 341 drv->fops = &lirc_fops;
350 drv->dev = &ir_dev->dev; 342 drv->dev = &dev->dev;
351 drv->owner = THIS_MODULE; 343 drv->owner = THIS_MODULE;
352 344
353 drv->minor = lirc_register_driver(drv); 345 drv->minor = lirc_register_driver(drv);
@@ -356,8 +348,8 @@ static int ir_lirc_register(struct input_dev *input_dev)
356 goto lirc_register_failed; 348 goto lirc_register_failed;
357 } 349 }
358 350
359 ir_dev->raw->lirc.drv = drv; 351 dev->raw->lirc.drv = drv;
360 ir_dev->raw->lirc.ir_dev = ir_dev; 352 dev->raw->lirc.dev = dev;
361 return 0; 353 return 0;
362 354
363lirc_register_failed: 355lirc_register_failed:
@@ -369,10 +361,9 @@ rbuf_alloc_failed:
369 return rc; 361 return rc;
370} 362}
371 363
372static int ir_lirc_unregister(struct input_dev *input_dev) 364static int ir_lirc_unregister(struct rc_dev *dev)
373{ 365{
374 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); 366 struct lirc_codec *lirc = &dev->raw->lirc;
375 struct lirc_codec *lirc = &ir_dev->raw->lirc;
376 367
377 lirc_unregister_driver(lirc->drv->minor); 368 lirc_unregister_driver(lirc->drv->minor);
378 lirc_buffer_free(lirc->drv->rbuf); 369 lirc_buffer_free(lirc->drv->rbuf);
diff --git a/drivers/media/rc/ir-nec-decoder.c b/drivers/media/rc/ir-nec-decoder.c
index cad4e994aa7..8ff157a140c 100644
--- a/drivers/media/rc/ir-nec-decoder.c
+++ b/drivers/media/rc/ir-nec-decoder.c
@@ -39,19 +39,18 @@ enum nec_state {
39 39
40/** 40/**
41 * ir_nec_decode() - Decode one NEC pulse or space 41 * ir_nec_decode() - Decode one NEC pulse or space
42 * @input_dev: the struct input_dev descriptor of the device 42 * @dev: the struct rc_dev descriptor of the device
43 * @duration: the struct ir_raw_event descriptor of the pulse/space 43 * @duration: the struct ir_raw_event descriptor of the pulse/space
44 * 44 *
45 * This function returns -EINVAL if the pulse violates the state machine 45 * This function returns -EINVAL if the pulse violates the state machine
46 */ 46 */
47static int ir_nec_decode(struct input_dev *input_dev, struct ir_raw_event ev) 47static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev)
48{ 48{
49 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); 49 struct nec_dec *data = &dev->raw->nec;
50 struct nec_dec *data = &ir_dev->raw->nec;
51 u32 scancode; 50 u32 scancode;
52 u8 address, not_address, command, not_command; 51 u8 address, not_address, command, not_command;
53 52
54 if (!(ir_dev->raw->enabled_protocols & IR_TYPE_NEC)) 53 if (!(dev->raw->enabled_protocols & IR_TYPE_NEC))
55 return 0; 54 return 0;
56 55
57 if (!is_timing_event(ev)) { 56 if (!is_timing_event(ev)) {
@@ -89,7 +88,7 @@ static int ir_nec_decode(struct input_dev *input_dev, struct ir_raw_event ev)
89 data->state = STATE_BIT_PULSE; 88 data->state = STATE_BIT_PULSE;
90 return 0; 89 return 0;
91 } else if (eq_margin(ev.duration, NEC_REPEAT_SPACE, NEC_UNIT / 2)) { 90 } else if (eq_margin(ev.duration, NEC_REPEAT_SPACE, NEC_UNIT / 2)) {
92 ir_repeat(input_dev); 91 ir_repeat(dev);
93 IR_dprintk(1, "Repeat last key\n"); 92 IR_dprintk(1, "Repeat last key\n");
94 data->state = STATE_TRAILER_PULSE; 93 data->state = STATE_TRAILER_PULSE;
95 return 0; 94 return 0;
@@ -115,7 +114,7 @@ static int ir_nec_decode(struct input_dev *input_dev, struct ir_raw_event ev)
115 geq_margin(ev.duration, 114 geq_margin(ev.duration,
116 NEC_TRAILER_SPACE, NEC_UNIT / 2)) { 115 NEC_TRAILER_SPACE, NEC_UNIT / 2)) {
117 IR_dprintk(1, "Repeat last key\n"); 116 IR_dprintk(1, "Repeat last key\n");
118 ir_repeat(input_dev); 117 ir_repeat(dev);
119 data->state = STATE_INACTIVE; 118 data->state = STATE_INACTIVE;
120 return 0; 119 return 0;
121 120
@@ -179,7 +178,7 @@ static int ir_nec_decode(struct input_dev *input_dev, struct ir_raw_event ev)
179 if (data->is_nec_x) 178 if (data->is_nec_x)
180 data->necx_repeat = true; 179 data->necx_repeat = true;
181 180
182 ir_keydown(input_dev, scancode, 0); 181 ir_keydown(dev, scancode, 0);
183 data->state = STATE_INACTIVE; 182 data->state = STATE_INACTIVE;
184 return 0; 183 return 0;
185 } 184 }
diff --git a/drivers/media/rc/ir-rc5-decoder.c b/drivers/media/rc/ir-rc5-decoder.c
index c07f6e0bb96..dae6f9a9b66 100644
--- a/drivers/media/rc/ir-rc5-decoder.c
+++ b/drivers/media/rc/ir-rc5-decoder.c
@@ -40,19 +40,18 @@ enum rc5_state {
40 40
41/** 41/**
42 * ir_rc5_decode() - Decode one RC-5 pulse or space 42 * ir_rc5_decode() - Decode one RC-5 pulse or space
43 * @input_dev: the struct input_dev descriptor of the device 43 * @dev: the struct rc_dev descriptor of the device
44 * @ev: the struct ir_raw_event descriptor of the pulse/space 44 * @ev: the struct ir_raw_event descriptor of the pulse/space
45 * 45 *
46 * This function returns -EINVAL if the pulse violates the state machine 46 * This function returns -EINVAL if the pulse violates the state machine
47 */ 47 */
48static int ir_rc5_decode(struct input_dev *input_dev, struct ir_raw_event ev) 48static int ir_rc5_decode(struct rc_dev *dev, struct ir_raw_event ev)
49{ 49{
50 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); 50 struct rc5_dec *data = &dev->raw->rc5;
51 struct rc5_dec *data = &ir_dev->raw->rc5;
52 u8 toggle; 51 u8 toggle;
53 u32 scancode; 52 u32 scancode;
54 53
55 if (!(ir_dev->raw->enabled_protocols & IR_TYPE_RC5)) 54 if (!(dev->raw->enabled_protocols & IR_TYPE_RC5))
56 return 0; 55 return 0;
57 56
58 if (!is_timing_event(ev)) { 57 if (!is_timing_event(ev)) {
@@ -96,7 +95,7 @@ again:
96 return 0; 95 return 0;
97 96
98 case STATE_BIT_END: 97 case STATE_BIT_END:
99 if (!is_transition(&ev, &ir_dev->raw->prev_ev)) 98 if (!is_transition(&ev, &dev->raw->prev_ev))
100 break; 99 break;
101 100
102 if (data->count == data->wanted_bits) 101 if (data->count == data->wanted_bits)
@@ -151,7 +150,7 @@ again:
151 scancode, toggle); 150 scancode, toggle);
152 } 151 }
153 152
154 ir_keydown(input_dev, scancode, toggle); 153 ir_keydown(dev, scancode, toggle);
155 data->state = STATE_INACTIVE; 154 data->state = STATE_INACTIVE;
156 return 0; 155 return 0;
157 } 156 }
diff --git a/drivers/media/rc/ir-rc5-sz-decoder.c b/drivers/media/rc/ir-rc5-sz-decoder.c
index 0c3b6eb4ccd..d8a53c02c1e 100644
--- a/drivers/media/rc/ir-rc5-sz-decoder.c
+++ b/drivers/media/rc/ir-rc5-sz-decoder.c
@@ -36,19 +36,18 @@ enum rc5_sz_state {
36 36
37/** 37/**
38 * ir_rc5_sz_decode() - Decode one RC-5 Streamzap pulse or space 38 * ir_rc5_sz_decode() - Decode one RC-5 Streamzap pulse or space
39 * @input_dev: the struct input_dev descriptor of the device 39 * @dev: the struct rc_dev descriptor of the device
40 * @ev: the struct ir_raw_event descriptor of the pulse/space 40 * @ev: the struct ir_raw_event descriptor of the pulse/space
41 * 41 *
42 * This function returns -EINVAL if the pulse violates the state machine 42 * This function returns -EINVAL if the pulse violates the state machine
43 */ 43 */
44static int ir_rc5_sz_decode(struct input_dev *input_dev, struct ir_raw_event ev) 44static int ir_rc5_sz_decode(struct rc_dev *dev, struct ir_raw_event ev)
45{ 45{
46 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); 46 struct rc5_sz_dec *data = &dev->raw->rc5_sz;
47 struct rc5_sz_dec *data = &ir_dev->raw->rc5_sz;
48 u8 toggle, command, system; 47 u8 toggle, command, system;
49 u32 scancode; 48 u32 scancode;
50 49
51 if (!(ir_dev->raw->enabled_protocols & IR_TYPE_RC5_SZ)) 50 if (!(dev->raw->enabled_protocols & IR_TYPE_RC5_SZ))
52 return 0; 51 return 0;
53 52
54 if (!is_timing_event(ev)) { 53 if (!is_timing_event(ev)) {
@@ -91,7 +90,7 @@ again:
91 return 0; 90 return 0;
92 91
93 case STATE_BIT_END: 92 case STATE_BIT_END:
94 if (!is_transition(&ev, &ir_dev->raw->prev_ev)) 93 if (!is_transition(&ev, &dev->raw->prev_ev))
95 break; 94 break;
96 95
97 if (data->count == data->wanted_bits) 96 if (data->count == data->wanted_bits)
@@ -115,7 +114,7 @@ again:
115 IR_dprintk(1, "RC5-sz scancode 0x%04x (toggle: %u)\n", 114 IR_dprintk(1, "RC5-sz scancode 0x%04x (toggle: %u)\n",
116 scancode, toggle); 115 scancode, toggle);
117 116
118 ir_keydown(input_dev, scancode, toggle); 117 ir_keydown(dev, scancode, toggle);
119 data->state = STATE_INACTIVE; 118 data->state = STATE_INACTIVE;
120 return 0; 119 return 0;
121 } 120 }
diff --git a/drivers/media/rc/ir-rc6-decoder.c b/drivers/media/rc/ir-rc6-decoder.c
index 48e82be5e01..2435bbd1dbc 100644
--- a/drivers/media/rc/ir-rc6-decoder.c
+++ b/drivers/media/rc/ir-rc6-decoder.c
@@ -70,19 +70,18 @@ static enum rc6_mode rc6_mode(struct rc6_dec *data)
70 70
71/** 71/**
72 * ir_rc6_decode() - Decode one RC6 pulse or space 72 * ir_rc6_decode() - Decode one RC6 pulse or space
73 * @input_dev: the struct input_dev descriptor of the device 73 * @dev: the struct rc_dev descriptor of the device
74 * @ev: the struct ir_raw_event descriptor of the pulse/space 74 * @ev: the struct ir_raw_event descriptor of the pulse/space
75 * 75 *
76 * This function returns -EINVAL if the pulse violates the state machine 76 * This function returns -EINVAL if the pulse violates the state machine
77 */ 77 */
78static int ir_rc6_decode(struct input_dev *input_dev, struct ir_raw_event ev) 78static int ir_rc6_decode(struct rc_dev *dev, struct ir_raw_event ev)
79{ 79{
80 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); 80 struct rc6_dec *data = &dev->raw->rc6;
81 struct rc6_dec *data = &ir_dev->raw->rc6;
82 u32 scancode; 81 u32 scancode;
83 u8 toggle; 82 u8 toggle;
84 83
85 if (!(ir_dev->raw->enabled_protocols & IR_TYPE_RC6)) 84 if (!(dev->raw->enabled_protocols & IR_TYPE_RC6))
86 return 0; 85 return 0;
87 86
88 if (!is_timing_event(ev)) { 87 if (!is_timing_event(ev)) {
@@ -139,7 +138,7 @@ again:
139 return 0; 138 return 0;
140 139
141 case STATE_HEADER_BIT_END: 140 case STATE_HEADER_BIT_END:
142 if (!is_transition(&ev, &ir_dev->raw->prev_ev)) 141 if (!is_transition(&ev, &dev->raw->prev_ev))
143 break; 142 break;
144 143
145 if (data->count == RC6_HEADER_NBITS) 144 if (data->count == RC6_HEADER_NBITS)
@@ -159,7 +158,7 @@ again:
159 return 0; 158 return 0;
160 159
161 case STATE_TOGGLE_END: 160 case STATE_TOGGLE_END:
162 if (!is_transition(&ev, &ir_dev->raw->prev_ev) || 161 if (!is_transition(&ev, &dev->raw->prev_ev) ||
163 !geq_margin(ev.duration, RC6_TOGGLE_END, RC6_UNIT / 2)) 162 !geq_margin(ev.duration, RC6_TOGGLE_END, RC6_UNIT / 2))
164 break; 163 break;
165 164
@@ -204,7 +203,7 @@ again:
204 return 0; 203 return 0;
205 204
206 case STATE_BODY_BIT_END: 205 case STATE_BODY_BIT_END:
207 if (!is_transition(&ev, &ir_dev->raw->prev_ev)) 206 if (!is_transition(&ev, &dev->raw->prev_ev))
208 break; 207 break;
209 208
210 if (data->count == data->wanted_bits) 209 if (data->count == data->wanted_bits)
@@ -243,7 +242,7 @@ again:
243 goto out; 242 goto out;
244 } 243 }
245 244
246 ir_keydown(input_dev, scancode, toggle); 245 ir_keydown(dev, scancode, toggle);
247 data->state = STATE_INACTIVE; 246 data->state = STATE_INACTIVE;
248 return 0; 247 return 0;
249 } 248 }
diff --git a/drivers/media/rc/ir-sony-decoder.c b/drivers/media/rc/ir-sony-decoder.c
index 0a5cadbf9bf..3138520fb9e 100644
--- a/drivers/media/rc/ir-sony-decoder.c
+++ b/drivers/media/rc/ir-sony-decoder.c
@@ -33,19 +33,18 @@ enum sony_state {
33 33
34/** 34/**
35 * ir_sony_decode() - Decode one Sony pulse or space 35 * ir_sony_decode() - Decode one Sony pulse or space
36 * @input_dev: the struct input_dev descriptor of the device 36 * @dev: the struct rc_dev descriptor of the device
37 * @ev: the struct ir_raw_event descriptor of the pulse/space 37 * @ev: the struct ir_raw_event descriptor of the pulse/space
38 * 38 *
39 * This function returns -EINVAL if the pulse violates the state machine 39 * This function returns -EINVAL if the pulse violates the state machine
40 */ 40 */
41static int ir_sony_decode(struct input_dev *input_dev, struct ir_raw_event ev) 41static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
42{ 42{
43 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); 43 struct sony_dec *data = &dev->raw->sony;
44 struct sony_dec *data = &ir_dev->raw->sony;
45 u32 scancode; 44 u32 scancode;
46 u8 device, subdevice, function; 45 u8 device, subdevice, function;
47 46
48 if (!(ir_dev->raw->enabled_protocols & IR_TYPE_SONY)) 47 if (!(dev->raw->enabled_protocols & IR_TYPE_SONY))
49 return 0; 48 return 0;
50 49
51 if (!is_timing_event(ev)) { 50 if (!is_timing_event(ev)) {
@@ -144,7 +143,7 @@ static int ir_sony_decode(struct input_dev *input_dev, struct ir_raw_event ev)
144 143
145 scancode = device << 16 | subdevice << 8 | function; 144 scancode = device << 16 | subdevice << 8 | function;
146 IR_dprintk(1, "Sony(%u) scancode 0x%05x\n", data->count, scancode); 145 IR_dprintk(1, "Sony(%u) scancode 0x%05x\n", data->count, scancode);
147 ir_keydown(input_dev, scancode, 0); 146 ir_keydown(dev, scancode, 0);
148 data->state = STATE_INACTIVE; 147 data->state = STATE_INACTIVE;
149 return 0; 148 return 0;
150 } 149 }
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 @@
35#include <linux/device.h> 35#include <linux/device.h>
36#include <linux/module.h> 36#include <linux/module.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/input.h>
39#include <linux/usb.h> 38#include <linux/usb.h>
40#include <linux/usb/input.h> 39#include <linux/usb/input.h>
41#include <media/ir-core.h> 40#include <media/ir-core.h>
@@ -317,7 +316,7 @@ static struct usb_device_id mceusb_dev_table[] = {
317/* data structure for each usb transceiver */ 316/* data structure for each usb transceiver */
318struct mceusb_dev { 317struct mceusb_dev {
319 /* ir-core bits */ 318 /* ir-core bits */
320 struct ir_dev_props *props; 319 struct rc_dev *rc;
321 320
322 /* optional features we can enable */ 321 /* optional features we can enable */
323 bool carrier_report_enabled; 322 bool carrier_report_enabled;
@@ -325,7 +324,6 @@ struct mceusb_dev {
325 324
326 /* core device bits */ 325 /* core device bits */
327 struct device *dev; 326 struct device *dev;
328 struct input_dev *idev;
329 327
330 /* usb */ 328 /* usb */
331 struct usb_device *usbdev; 329 struct usb_device *usbdev;
@@ -663,9 +661,9 @@ static void mce_sync_in(struct mceusb_dev *ir, unsigned char *data, int size)
663} 661}
664 662
665/* Send data out the IR blaster port(s) */ 663/* Send data out the IR blaster port(s) */
666static int mceusb_tx_ir(void *priv, int *txbuf, u32 n) 664static int mceusb_tx_ir(struct rc_dev *dev, int *txbuf, u32 n)
667{ 665{
668 struct mceusb_dev *ir = priv; 666 struct mceusb_dev *ir = dev->priv;
669 int i, ret = 0; 667 int i, ret = 0;
670 int count, cmdcount = 0; 668 int count, cmdcount = 0;
671 unsigned char *cmdbuf; /* MCE command buffer */ 669 unsigned char *cmdbuf; /* MCE command buffer */
@@ -749,9 +747,9 @@ out:
749} 747}
750 748
751/* Sets active IR outputs -- mce devices typically have two */ 749/* Sets active IR outputs -- mce devices typically have two */
752static int mceusb_set_tx_mask(void *priv, u32 mask) 750static int mceusb_set_tx_mask(struct rc_dev *dev, u32 mask)
753{ 751{
754 struct mceusb_dev *ir = priv; 752 struct mceusb_dev *ir = dev->priv;
755 753
756 if (ir->flags.tx_mask_normal) 754 if (ir->flags.tx_mask_normal)
757 ir->tx_mask = mask; 755 ir->tx_mask = mask;
@@ -763,9 +761,9 @@ static int mceusb_set_tx_mask(void *priv, u32 mask)
763} 761}
764 762
765/* Sets the send carrier frequency and mode */ 763/* Sets the send carrier frequency and mode */
766static int mceusb_set_tx_carrier(void *priv, u32 carrier) 764static int mceusb_set_tx_carrier(struct rc_dev *dev, u32 carrier)
767{ 765{
768 struct mceusb_dev *ir = priv; 766 struct mceusb_dev *ir = dev->priv;
769 int clk = 10000000; 767 int clk = 10000000;
770 int prescaler = 0, divisor = 0; 768 int prescaler = 0, divisor = 0;
771 unsigned char cmdbuf[4] = { MCE_COMMAND_HEADER, 769 unsigned char cmdbuf[4] = { MCE_COMMAND_HEADER,
@@ -819,7 +817,7 @@ static void mceusb_handle_command(struct mceusb_dev *ir, int index)
819 switch (ir->buf_in[index]) { 817 switch (ir->buf_in[index]) {
820 /* 2-byte return value commands */ 818 /* 2-byte return value commands */
821 case MCE_CMD_S_TIMEOUT: 819 case MCE_CMD_S_TIMEOUT:
822 ir->props->timeout = MS_TO_NS((hi << 8 | lo) / 2); 820 ir->rc->timeout = MS_TO_NS((hi << 8 | lo) / 2);
823 break; 821 break;
824 822
825 /* 1-byte return value commands */ 823 /* 1-byte return value commands */
@@ -866,7 +864,7 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len)
866 rawir.pulse ? "pulse" : "space", 864 rawir.pulse ? "pulse" : "space",
867 rawir.duration); 865 rawir.duration);
868 866
869 ir_raw_event_store_with_filter(ir->idev, &rawir); 867 ir_raw_event_store_with_filter(ir->rc, &rawir);
870 break; 868 break;
871 case CMD_DATA: 869 case CMD_DATA:
872 ir->rem--; 870 ir->rem--;
@@ -893,7 +891,7 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len)
893 ir->parser_state = CMD_HEADER; 891 ir->parser_state = CMD_HEADER;
894 } 892 }
895 dev_dbg(ir->dev, "processed IR data, calling ir_raw_event_handle\n"); 893 dev_dbg(ir->dev, "processed IR data, calling ir_raw_event_handle\n");
896 ir_raw_event_handle(ir->idev); 894 ir_raw_event_handle(ir->rc);
897} 895}
898 896
899static void mceusb_dev_recv(struct urb *urb, struct pt_regs *regs) 897static void mceusb_dev_recv(struct urb *urb, struct pt_regs *regs)
@@ -1035,72 +1033,54 @@ static void mceusb_get_parameters(struct mceusb_dev *ir)
1035 mce_sync_in(ir, NULL, maxp); 1033 mce_sync_in(ir, NULL, maxp);
1036} 1034}
1037 1035
1038static struct input_dev *mceusb_init_input_dev(struct mceusb_dev *ir) 1036static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir)
1039{ 1037{
1040 struct input_dev *idev;
1041 struct ir_dev_props *props;
1042 struct device *dev = ir->dev; 1038 struct device *dev = ir->dev;
1043 const char *rc_map = RC_MAP_RC6_MCE; 1039 struct rc_dev *rc;
1044 const char *name = "Media Center Ed. eHome Infrared Remote Transceiver"; 1040 int ret;
1045 int ret = -ENODEV;
1046
1047 idev = input_allocate_device();
1048 if (!idev) {
1049 dev_err(dev, "remote input dev allocation failed\n");
1050 goto idev_alloc_failed;
1051 }
1052 1041
1053 ret = -ENOMEM; 1042 rc = rc_allocate_device();
1054 props = kzalloc(sizeof(struct ir_dev_props), GFP_KERNEL); 1043 if (!rc) {
1055 if (!props) { 1044 dev_err(dev, "remote dev allocation failed\n");
1056 dev_err(dev, "remote ir dev props allocation failed\n"); 1045 goto out;
1057 goto props_alloc_failed;
1058 } 1046 }
1059 1047
1060 if (mceusb_model[ir->model].name)
1061 name = mceusb_model[ir->model].name;
1062
1063 snprintf(ir->name, sizeof(ir->name), "%s (%04x:%04x)", 1048 snprintf(ir->name, sizeof(ir->name), "%s (%04x:%04x)",
1064 name, 1049 mceusb_model[ir->model].name ?
1050 mceusb_model[ir->model].name :
1051 "Media Center Ed. eHome Infrared Remote Transceiver",
1065 le16_to_cpu(ir->usbdev->descriptor.idVendor), 1052 le16_to_cpu(ir->usbdev->descriptor.idVendor),
1066 le16_to_cpu(ir->usbdev->descriptor.idProduct)); 1053 le16_to_cpu(ir->usbdev->descriptor.idProduct));
1067 1054
1068 idev->name = ir->name;
1069 usb_make_path(ir->usbdev, ir->phys, sizeof(ir->phys)); 1055 usb_make_path(ir->usbdev, ir->phys, sizeof(ir->phys));
1070 strlcat(ir->phys, "/input0", sizeof(ir->phys));
1071 idev->phys = ir->phys;
1072 1056
1073 props->priv = ir; 1057 rc->input_name = ir->name;
1074 props->driver_type = RC_DRIVER_IR_RAW; 1058 rc->input_phys = ir->phys;
1075 props->allowed_protos = IR_TYPE_ALL; 1059 usb_to_input_id(ir->usbdev, &rc->input_id);
1076 props->timeout = MS_TO_NS(1000); 1060 rc->dev.parent = dev;
1061 rc->priv = ir;
1062 rc->driver_type = RC_DRIVER_IR_RAW;
1063 rc->allowed_protos = IR_TYPE_ALL;
1064 rc->timeout = MS_TO_NS(1000);
1077 if (!ir->flags.no_tx) { 1065 if (!ir->flags.no_tx) {
1078 props->s_tx_mask = mceusb_set_tx_mask; 1066 rc->s_tx_mask = mceusb_set_tx_mask;
1079 props->s_tx_carrier = mceusb_set_tx_carrier; 1067 rc->s_tx_carrier = mceusb_set_tx_carrier;
1080 props->tx_ir = mceusb_tx_ir; 1068 rc->tx_ir = mceusb_tx_ir;
1081 } 1069 }
1070 rc->driver_name = DRIVER_NAME;
1071 rc->map_name = mceusb_model[ir->model].rc_map ?
1072 mceusb_model[ir->model].rc_map : RC_MAP_RC6_MCE;
1082 1073
1083 ir->props = props; 1074 ret = rc_register_device(rc);
1084
1085 usb_to_input_id(ir->usbdev, &idev->id);
1086 idev->dev.parent = ir->dev;
1087
1088 if (mceusb_model[ir->model].rc_map)
1089 rc_map = mceusb_model[ir->model].rc_map;
1090
1091 ret = ir_input_register(idev, rc_map, props, DRIVER_NAME);
1092 if (ret < 0) { 1075 if (ret < 0) {
1093 dev_err(dev, "remote input device register failed\n"); 1076 dev_err(dev, "remote dev registration failed\n");
1094 goto irdev_failed; 1077 goto out;
1095 } 1078 }
1096 1079
1097 return idev; 1080 return rc;
1098 1081
1099irdev_failed: 1082out:
1100 kfree(props); 1083 rc_free_device(rc);
1101props_alloc_failed:
1102 input_free_device(idev);
1103idev_alloc_failed:
1104 return NULL; 1084 return NULL;
1105} 1085}
1106 1086
@@ -1212,9 +1192,9 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf,
1212 snprintf(name + strlen(name), sizeof(name) - strlen(name), 1192 snprintf(name + strlen(name), sizeof(name) - strlen(name),
1213 " %s", buf); 1193 " %s", buf);
1214 1194
1215 ir->idev = mceusb_init_input_dev(ir); 1195 ir->rc = mceusb_init_rc_dev(ir);
1216 if (!ir->idev) 1196 if (!ir->rc)
1217 goto input_dev_fail; 1197 goto rc_dev_fail;
1218 1198
1219 /* flush buffers on the device */ 1199 /* flush buffers on the device */
1220 mce_sync_in(ir, NULL, maxp); 1200 mce_sync_in(ir, NULL, maxp);
@@ -1235,7 +1215,7 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf,
1235 mceusb_get_parameters(ir); 1215 mceusb_get_parameters(ir);
1236 1216
1237 if (!ir->flags.no_tx) 1217 if (!ir->flags.no_tx)
1238 mceusb_set_tx_mask(ir, MCE_DEFAULT_TX_MASK); 1218 mceusb_set_tx_mask(ir->rc, MCE_DEFAULT_TX_MASK);
1239 1219
1240 usb_set_intfdata(intf, ir); 1220 usb_set_intfdata(intf, ir);
1241 1221
@@ -1245,7 +1225,7 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf,
1245 return 0; 1225 return 0;
1246 1226
1247 /* Error-handling path */ 1227 /* Error-handling path */
1248input_dev_fail: 1228rc_dev_fail:
1249 usb_free_urb(ir->urb_in); 1229 usb_free_urb(ir->urb_in);
1250urb_in_alloc_fail: 1230urb_in_alloc_fail:
1251 usb_free_coherent(dev, maxp, ir->buf_in, ir->dma_in); 1231 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)
1269 return; 1249 return;
1270 1250
1271 ir->usbdev = NULL; 1251 ir->usbdev = NULL;
1272 ir_input_unregister(ir->idev); 1252 rc_unregister_device(ir->rc);
1273 usb_kill_urb(ir->urb_in); 1253 usb_kill_urb(ir->urb_in);
1274 usb_free_urb(ir->urb_in); 1254 usb_free_urb(ir->urb_in);
1275 usb_free_coherent(dev, ir->len_in, ir->buf_in, ir->dma_in); 1255 usb_free_coherent(dev, ir->len_in, ir->buf_in, ir->dma_in);
diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
index acc729c79ce..0ce328f9dac 100644
--- a/drivers/media/rc/nuvoton-cir.c
+++ b/drivers/media/rc/nuvoton-cir.c
@@ -32,7 +32,6 @@
32#include <linux/interrupt.h> 32#include <linux/interrupt.h>
33#include <linux/sched.h> 33#include <linux/sched.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/input.h>
36#include <media/ir-core.h> 35#include <media/ir-core.h>
37#include <linux/pci_ids.h> 36#include <linux/pci_ids.h>
38 37
@@ -476,9 +475,9 @@ static u32 nvt_rx_carrier_detect(struct nvt_dev *nvt)
476 * always set CP as 0x81 475 * always set CP as 0x81
477 * set CC by SPEC, CC = 3MHz/carrier - 1 476 * set CC by SPEC, CC = 3MHz/carrier - 1
478 */ 477 */
479static int nvt_set_tx_carrier(void *data, u32 carrier) 478static int nvt_set_tx_carrier(struct rc_dev *dev, u32 carrier)
480{ 479{
481 struct nvt_dev *nvt = data; 480 struct nvt_dev *nvt = dev->priv;
482 u16 val; 481 u16 val;
483 482
484 nvt_cir_reg_write(nvt, 1, CIR_CP); 483 nvt_cir_reg_write(nvt, 1, CIR_CP);
@@ -509,9 +508,9 @@ static int nvt_set_tx_carrier(void *data, u32 carrier)
509 * number may larger than TXFCONT (0xff). So in interrupt_handler, it has to 508 * number may larger than TXFCONT (0xff). So in interrupt_handler, it has to
510 * set TXFCONT as 0xff, until buf_count less than 0xff. 509 * set TXFCONT as 0xff, until buf_count less than 0xff.
511 */ 510 */
512static int nvt_tx_ir(void *priv, int *txbuf, u32 n) 511static int nvt_tx_ir(struct rc_dev *dev, int *txbuf, u32 n)
513{ 512{
514 struct nvt_dev *nvt = priv; 513 struct nvt_dev *nvt = dev->priv;
515 unsigned long flags; 514 unsigned long flags;
516 size_t cur_count; 515 size_t cur_count;
517 unsigned int i; 516 unsigned int i;
@@ -948,9 +947,9 @@ static void nvt_disable_cir(struct nvt_dev *nvt)
948 nvt_efm_disable(nvt); 947 nvt_efm_disable(nvt);
949} 948}
950 949
951static int nvt_open(void *data) 950static int nvt_open(struct rc_dev *dev)
952{ 951{
953 struct nvt_dev *nvt = (struct nvt_dev *)data; 952 struct nvt_dev *nvt = dev->priv;
954 unsigned long flags; 953 unsigned long flags;
955 954
956 spin_lock_irqsave(&nvt->nvt_lock, flags); 955 spin_lock_irqsave(&nvt->nvt_lock, flags);
@@ -961,9 +960,9 @@ static int nvt_open(void *data)
961 return 0; 960 return 0;
962} 961}
963 962
964static void nvt_close(void *data) 963static void nvt_close(struct rc_dev *dev)
965{ 964{
966 struct nvt_dev *nvt = (struct nvt_dev *)data; 965 struct nvt_dev *nvt = dev->priv;
967 unsigned long flags; 966 unsigned long flags;
968 967
969 spin_lock_irqsave(&nvt->nvt_lock, flags); 968 spin_lock_irqsave(&nvt->nvt_lock, flags);
@@ -975,21 +974,16 @@ static void nvt_close(void *data)
975/* Allocate memory, probe hardware, and initialize everything */ 974/* Allocate memory, probe hardware, and initialize everything */
976static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) 975static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
977{ 976{
978 struct nvt_dev *nvt = NULL; 977 struct nvt_dev *nvt;
979 struct input_dev *rdev = NULL; 978 struct rc_dev *rdev;
980 struct ir_dev_props *props = NULL;
981 int ret = -ENOMEM; 979 int ret = -ENOMEM;
982 980
983 nvt = kzalloc(sizeof(struct nvt_dev), GFP_KERNEL); 981 nvt = kzalloc(sizeof(struct nvt_dev), GFP_KERNEL);
984 if (!nvt) 982 if (!nvt)
985 return ret; 983 return ret;
986 984
987 props = kzalloc(sizeof(struct ir_dev_props), GFP_KERNEL);
988 if (!props)
989 goto failure;
990
991 /* input device for IR remote (and tx) */ 985 /* input device for IR remote (and tx) */
992 rdev = input_allocate_device(); 986 rdev = rc_allocate_device();
993 if (!rdev) 987 if (!rdev)
994 goto failure; 988 goto failure;
995 989
@@ -1063,41 +1057,38 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1063 nvt_cir_regs_init(nvt); 1057 nvt_cir_regs_init(nvt);
1064 nvt_cir_wake_regs_init(nvt); 1058 nvt_cir_wake_regs_init(nvt);
1065 1059
1066 /* Set up ir-core props */ 1060 /* Set up the rc device */
1067 props->priv = nvt; 1061 rdev->priv = nvt;
1068 props->driver_type = RC_DRIVER_IR_RAW; 1062 rdev->driver_type = RC_DRIVER_IR_RAW;
1069 props->allowed_protos = IR_TYPE_ALL; 1063 rdev->allowed_protos = IR_TYPE_ALL;
1070 props->open = nvt_open; 1064 rdev->open = nvt_open;
1071 props->close = nvt_close; 1065 rdev->close = nvt_close;
1066 rdev->tx_ir = nvt_tx_ir;
1067 rdev->s_tx_carrier = nvt_set_tx_carrier;
1068 rdev->input_name = "Nuvoton w836x7hg Infrared Remote Transceiver";
1069 rdev->input_id.bustype = BUS_HOST;
1070 rdev->input_id.vendor = PCI_VENDOR_ID_WINBOND2;
1071 rdev->input_id.product = nvt->chip_major;
1072 rdev->input_id.version = nvt->chip_minor;
1073 rdev->driver_name = NVT_DRIVER_NAME;
1074 rdev->map_name = RC_MAP_RC6_MCE;
1072#if 0 1075#if 0
1073 props->min_timeout = XYZ; 1076 rdev->min_timeout = XYZ;
1074 props->max_timeout = XYZ; 1077 rdev->max_timeout = XYZ;
1075 props->timeout = XYZ; 1078 rdev->timeout = XYZ;
1076 /* rx resolution is hardwired to 50us atm, 1, 25, 100 also possible */ 1079 /* rx resolution is hardwired to 50us atm, 1, 25, 100 also possible */
1077 props->rx_resolution = XYZ; 1080 rdev->rx_resolution = XYZ;
1078
1079 /* tx bits */ 1081 /* tx bits */
1080 props->tx_resolution = XYZ; 1082 rdev->tx_resolution = XYZ;
1081#endif 1083#endif
1082 props->tx_ir = nvt_tx_ir;
1083 props->s_tx_carrier = nvt_set_tx_carrier;
1084
1085 rdev->name = "Nuvoton w836x7hg Infrared Remote Transceiver";
1086 rdev->id.bustype = BUS_HOST;
1087 rdev->id.vendor = PCI_VENDOR_ID_WINBOND2;
1088 rdev->id.product = nvt->chip_major;
1089 rdev->id.version = nvt->chip_minor;
1090
1091 nvt->props = props;
1092 nvt->rdev = rdev;
1093 1084
1094 device_set_wakeup_capable(&pdev->dev, 1); 1085 ret = rc_register_device(rdev);
1095 device_set_wakeup_enable(&pdev->dev, 1);
1096
1097 ret = ir_input_register(rdev, RC_MAP_RC6_MCE, props, NVT_DRIVER_NAME);
1098 if (ret) 1086 if (ret)
1099 goto failure; 1087 goto failure;
1100 1088
1089 device_set_wakeup_capable(&pdev->dev, 1);
1090 device_set_wakeup_enable(&pdev->dev, 1);
1091 nvt->rdev = rdev;
1101 nvt_pr(KERN_NOTICE, "driver has been successfully loaded\n"); 1092 nvt_pr(KERN_NOTICE, "driver has been successfully loaded\n");
1102 if (debug) { 1093 if (debug) {
1103 cir_dump_regs(nvt); 1094 cir_dump_regs(nvt);
@@ -1117,8 +1108,7 @@ failure:
1117 if (nvt->cir_wake_addr) 1108 if (nvt->cir_wake_addr)
1118 release_region(nvt->cir_wake_addr, CIR_IOREG_LENGTH); 1109 release_region(nvt->cir_wake_addr, CIR_IOREG_LENGTH);
1119 1110
1120 input_free_device(rdev); 1111 rc_free_device(rdev);
1121 kfree(props);
1122 kfree(nvt); 1112 kfree(nvt);
1123 1113
1124 return ret; 1114 return ret;
@@ -1143,9 +1133,8 @@ static void __devexit nvt_remove(struct pnp_dev *pdev)
1143 release_region(nvt->cir_addr, CIR_IOREG_LENGTH); 1133 release_region(nvt->cir_addr, CIR_IOREG_LENGTH);
1144 release_region(nvt->cir_wake_addr, CIR_IOREG_LENGTH); 1134 release_region(nvt->cir_wake_addr, CIR_IOREG_LENGTH);
1145 1135
1146 ir_input_unregister(nvt->rdev); 1136 rc_unregister_device(nvt->rdev);
1147 1137
1148 kfree(nvt->props);
1149 kfree(nvt); 1138 kfree(nvt);
1150} 1139}
1151 1140
diff --git a/drivers/media/rc/nuvoton-cir.h b/drivers/media/rc/nuvoton-cir.h
index 62dc53017c8..1df82351cb0 100644
--- a/drivers/media/rc/nuvoton-cir.h
+++ b/drivers/media/rc/nuvoton-cir.h
@@ -66,8 +66,7 @@ static int debug;
66 66
67struct nvt_dev { 67struct nvt_dev {
68 struct pnp_dev *pdev; 68 struct pnp_dev *pdev;
69 struct input_dev *rdev; 69 struct rc_dev *rdev;
70 struct ir_dev_props *props;
71 struct ir_raw_event rawir; 70 struct ir_raw_event rawir;
72 71
73 spinlock_t nvt_lock; 72 spinlock_t nvt_lock;
diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h
index 4be075780ad..3616c32d3f8 100644
--- a/drivers/media/rc/rc-core-priv.h
+++ b/drivers/media/rc/rc-core-priv.h
@@ -24,11 +24,11 @@ struct ir_raw_handler {
24 struct list_head list; 24 struct list_head list;
25 25
26 u64 protocols; /* which are handled by this handler */ 26 u64 protocols; /* which are handled by this handler */
27 int (*decode)(struct input_dev *input_dev, struct ir_raw_event event); 27 int (*decode)(struct rc_dev *dev, struct ir_raw_event event);
28 28
29 /* These two should only be used by the lirc decoder */ 29 /* These two should only be used by the lirc decoder */
30 int (*raw_register)(struct input_dev *input_dev); 30 int (*raw_register)(struct rc_dev *dev);
31 int (*raw_unregister)(struct input_dev *input_dev); 31 int (*raw_unregister)(struct rc_dev *dev);
32}; 32};
33 33
34struct ir_raw_event_ctrl { 34struct ir_raw_event_ctrl {
@@ -38,7 +38,7 @@ struct ir_raw_event_ctrl {
38 struct kfifo kfifo; /* fifo for the pulse/space durations */ 38 struct kfifo kfifo; /* fifo for the pulse/space durations */
39 ktime_t last_event; /* when last event occurred */ 39 ktime_t last_event; /* when last event occurred */
40 enum raw_event_type last_type; /* last event type */ 40 enum raw_event_type last_type; /* last event type */
41 struct input_dev *input_dev; /* pointer to the parent input_dev */ 41 struct rc_dev *dev; /* pointer to the parent rc_dev */
42 u64 enabled_protocols; /* enabled raw protocol decoders */ 42 u64 enabled_protocols; /* enabled raw protocol decoders */
43 43
44 /* raw decoder state follows */ 44 /* raw decoder state follows */
@@ -85,7 +85,7 @@ struct ir_raw_event_ctrl {
85 unsigned wanted_bits; 85 unsigned wanted_bits;
86 } rc5_sz; 86 } rc5_sz;
87 struct lirc_codec { 87 struct lirc_codec {
88 struct ir_input_dev *ir_dev; 88 struct rc_dev *dev;
89 struct lirc_driver *drv; 89 struct lirc_driver *drv;
90 int carrier_low; 90 int carrier_low;
91 91
@@ -131,11 +131,11 @@ static inline bool is_timing_event(struct ir_raw_event ev)
131#define TO_STR(is_pulse) ((is_pulse) ? "pulse" : "space") 131#define TO_STR(is_pulse) ((is_pulse) ? "pulse" : "space")
132 132
133/* 133/*
134 * Routines from ir-raw-event.c to be used internally and by decoders 134 * Routines from rc-raw.c to be used internally and by decoders
135 */ 135 */
136u64 ir_raw_get_allowed_protocols(void); 136u64 ir_raw_get_allowed_protocols(void);
137int ir_raw_event_register(struct input_dev *input_dev); 137int ir_raw_event_register(struct rc_dev *dev);
138void ir_raw_event_unregister(struct input_dev *input_dev); 138void ir_raw_event_unregister(struct rc_dev *dev);
139int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler); 139int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler);
140void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler); 140void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler);
141void ir_raw_init(void); 141void ir_raw_init(void);
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 67a6bd5d949..5b67eea96eb 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -20,11 +20,6 @@
20#include <linux/device.h> 20#include <linux/device.h>
21#include "rc-core-priv.h" 21#include "rc-core-priv.h"
22 22
23#define IRRCV_NUM_DEVICES 256
24
25/* bit array to represent IR sysfs device number */
26static unsigned long ir_core_dev_number;
27
28/* Sizes are in bytes, 256 bytes allows for 32 entries on x64 */ 23/* Sizes are in bytes, 256 bytes allows for 32 entries on x64 */
29#define IR_TAB_MIN_SIZE 256 24#define IR_TAB_MIN_SIZE 256
30#define IR_TAB_MAX_SIZE 8192 25#define IR_TAB_MAX_SIZE 8192
@@ -36,12 +31,6 @@ static unsigned long ir_core_dev_number;
36static LIST_HEAD(rc_map_list); 31static LIST_HEAD(rc_map_list);
37static DEFINE_SPINLOCK(rc_map_lock); 32static DEFINE_SPINLOCK(rc_map_lock);
38 33
39/* Forward declarations */
40static int ir_register_class(struct input_dev *input_dev);
41static void ir_unregister_class(struct input_dev *input_dev);
42static int ir_register_input(struct input_dev *input_dev);
43
44
45static struct rc_keymap *seek_rc_map(const char *name) 34static struct rc_keymap *seek_rc_map(const char *name)
46{ 35{
47 struct rc_keymap *map = NULL; 36 struct rc_keymap *map = NULL;
@@ -127,7 +116,7 @@ static struct rc_keymap empty_map = {
127 * @return: zero on success or a negative error code 116 * @return: zero on success or a negative error code
128 * 117 *
129 * This routine will initialize the ir_scancode_table and will allocate 118 * This routine will initialize the ir_scancode_table and will allocate
130 * memory to hold at least the specified number elements. 119 * memory to hold at least the specified number of elements.
131 */ 120 */
132static int ir_create_table(struct ir_scancode_table *rc_tab, 121static int ir_create_table(struct ir_scancode_table *rc_tab,
133 const char *name, u64 ir_type, size_t size) 122 const char *name, u64 ir_type, size_t size)
@@ -209,16 +198,16 @@ static int ir_resize_table(struct ir_scancode_table *rc_tab, gfp_t gfp_flags)
209 198
210/** 199/**
211 * ir_update_mapping() - set a keycode in the scancode->keycode table 200 * ir_update_mapping() - set a keycode in the scancode->keycode table
212 * @dev: the struct input_dev device descriptor 201 * @dev: the struct rc_dev device descriptor
213 * @rc_tab: scancode table to be adjusted 202 * @rc_tab: scancode table to be adjusted
214 * @index: index of the mapping that needs to be updated 203 * @index: index of the mapping that needs to be updated
215 * @keycode: the desired keycode 204 * @keycode: the desired keycode
216 * @return: previous keycode assigned to the mapping 205 * @return: previous keycode assigned to the mapping
217 * 206 *
218 * This routine is used to update scancode->keycopde mapping at given 207 * This routine is used to update scancode->keycode mapping at given
219 * position. 208 * position.
220 */ 209 */
221static unsigned int ir_update_mapping(struct input_dev *dev, 210static unsigned int ir_update_mapping(struct rc_dev *dev,
222 struct ir_scancode_table *rc_tab, 211 struct ir_scancode_table *rc_tab,
223 unsigned int index, 212 unsigned int index,
224 unsigned int new_keycode) 213 unsigned int new_keycode)
@@ -239,16 +228,16 @@ static unsigned int ir_update_mapping(struct input_dev *dev,
239 old_keycode == KEY_RESERVED ? "New" : "Replacing", 228 old_keycode == KEY_RESERVED ? "New" : "Replacing",
240 rc_tab->scan[index].scancode, new_keycode); 229 rc_tab->scan[index].scancode, new_keycode);
241 rc_tab->scan[index].keycode = new_keycode; 230 rc_tab->scan[index].keycode = new_keycode;
242 __set_bit(new_keycode, dev->keybit); 231 __set_bit(new_keycode, dev->input_dev->keybit);
243 } 232 }
244 233
245 if (old_keycode != KEY_RESERVED) { 234 if (old_keycode != KEY_RESERVED) {
246 /* A previous mapping was updated... */ 235 /* A previous mapping was updated... */
247 __clear_bit(old_keycode, dev->keybit); 236 __clear_bit(old_keycode, dev->input_dev->keybit);
248 /* ... but another scancode might use the same keycode */ 237 /* ... but another scancode might use the same keycode */
249 for (i = 0; i < rc_tab->len; i++) { 238 for (i = 0; i < rc_tab->len; i++) {
250 if (rc_tab->scan[i].keycode == old_keycode) { 239 if (rc_tab->scan[i].keycode == old_keycode) {
251 __set_bit(old_keycode, dev->keybit); 240 __set_bit(old_keycode, dev->input_dev->keybit);
252 break; 241 break;
253 } 242 }
254 } 243 }
@@ -262,7 +251,7 @@ static unsigned int ir_update_mapping(struct input_dev *dev,
262 251
263/** 252/**
264 * ir_establish_scancode() - set a keycode in the scancode->keycode table 253 * ir_establish_scancode() - set a keycode in the scancode->keycode table
265 * @ir_dev: the struct ir_input_dev device descriptor 254 * @dev: the struct rc_dev device descriptor
266 * @rc_tab: scancode table to be searched 255 * @rc_tab: scancode table to be searched
267 * @scancode: the desired scancode 256 * @scancode: the desired scancode
268 * @resize: controls whether we allowed to resize the table to 257 * @resize: controls whether we allowed to resize the table to
@@ -274,7 +263,7 @@ static unsigned int ir_update_mapping(struct input_dev *dev,
274 * If scancode is not yet present the routine will allocate a new slot 263 * If scancode is not yet present the routine will allocate a new slot
275 * for it. 264 * for it.
276 */ 265 */
277static unsigned int ir_establish_scancode(struct ir_input_dev *ir_dev, 266static unsigned int ir_establish_scancode(struct rc_dev *dev,
278 struct ir_scancode_table *rc_tab, 267 struct ir_scancode_table *rc_tab,
279 unsigned int scancode, 268 unsigned int scancode,
280 bool resize) 269 bool resize)
@@ -286,10 +275,11 @@ static unsigned int ir_establish_scancode(struct ir_input_dev *ir_dev,
286 * all bits for the complete IR code. In general, they provide only 275 * all bits for the complete IR code. In general, they provide only
287 * the command part of the IR code. Yet, as it is possible to replace 276 * the command part of the IR code. Yet, as it is possible to replace
288 * the provided IR with another one, it is needed to allow loading 277 * the provided IR with another one, it is needed to allow loading
289 * IR tables from other remotes. So, 278 * IR tables from other remotes. So, we support specifying a mask to
279 * indicate the valid bits of the scancodes.
290 */ 280 */
291 if (ir_dev->props && ir_dev->props->scanmask) 281 if (dev->scanmask)
292 scancode &= ir_dev->props->scanmask; 282 scancode &= dev->scanmask;
293 283
294 /* First check if we already have a mapping for this ir command */ 284 /* First check if we already have a mapping for this ir command */
295 for (i = 0; i < rc_tab->len; i++) { 285 for (i = 0; i < rc_tab->len; i++) {
@@ -320,19 +310,19 @@ static unsigned int ir_establish_scancode(struct ir_input_dev *ir_dev,
320 310
321/** 311/**
322 * ir_setkeycode() - set a keycode in the scancode->keycode table 312 * ir_setkeycode() - set a keycode in the scancode->keycode table
323 * @dev: the struct input_dev device descriptor 313 * @idev: the struct input_dev device descriptor
324 * @scancode: the desired scancode 314 * @scancode: the desired scancode
325 * @keycode: result 315 * @keycode: result
326 * @return: -EINVAL if the keycode could not be inserted, otherwise zero. 316 * @return: -EINVAL if the keycode could not be inserted, otherwise zero.
327 * 317 *
328 * This routine is used to handle evdev EVIOCSKEY ioctl. 318 * This routine is used to handle evdev EVIOCSKEY ioctl.
329 */ 319 */
330static int ir_setkeycode(struct input_dev *dev, 320static int ir_setkeycode(struct input_dev *idev,
331 const struct input_keymap_entry *ke, 321 const struct input_keymap_entry *ke,
332 unsigned int *old_keycode) 322 unsigned int *old_keycode)
333{ 323{
334 struct ir_input_dev *ir_dev = input_get_drvdata(dev); 324 struct rc_dev *rdev = input_get_drvdata(idev);
335 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab; 325 struct ir_scancode_table *rc_tab = &rdev->rc_tab;
336 unsigned int index; 326 unsigned int index;
337 unsigned int scancode; 327 unsigned int scancode;
338 int retval; 328 int retval;
@@ -351,14 +341,14 @@ static int ir_setkeycode(struct input_dev *dev,
351 if (retval) 341 if (retval)
352 goto out; 342 goto out;
353 343
354 index = ir_establish_scancode(ir_dev, rc_tab, scancode, true); 344 index = ir_establish_scancode(rdev, rc_tab, scancode, true);
355 if (index >= rc_tab->len) { 345 if (index >= rc_tab->len) {
356 retval = -ENOMEM; 346 retval = -ENOMEM;
357 goto out; 347 goto out;
358 } 348 }
359 } 349 }
360 350
361 *old_keycode = ir_update_mapping(dev, rc_tab, index, ke->keycode); 351 *old_keycode = ir_update_mapping(rdev, rc_tab, index, ke->keycode);
362 352
363out: 353out:
364 spin_unlock_irqrestore(&rc_tab->lock, flags); 354 spin_unlock_irqrestore(&rc_tab->lock, flags);
@@ -367,22 +357,22 @@ out:
367 357
368/** 358/**
369 * ir_setkeytable() - sets several entries in the scancode->keycode table 359 * ir_setkeytable() - sets several entries in the scancode->keycode table
370 * @dev: the struct input_dev device descriptor 360 * @dev: the struct rc_dev device descriptor
371 * @to: the struct ir_scancode_table to copy entries to 361 * @to: the struct ir_scancode_table to copy entries to
372 * @from: the struct ir_scancode_table to copy entries from 362 * @from: the struct ir_scancode_table to copy entries from
373 * @return: -ENOMEM if all keycodes could not be inserted, otherwise zero. 363 * @return: -ENOMEM if all keycodes could not be inserted, otherwise zero.
374 * 364 *
375 * This routine is used to handle table initialization. 365 * This routine is used to handle table initialization.
376 */ 366 */
377static int ir_setkeytable(struct ir_input_dev *ir_dev, 367static int ir_setkeytable(struct rc_dev *dev,
378 const struct ir_scancode_table *from) 368 const struct ir_scancode_table *from)
379{ 369{
380 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab; 370 struct ir_scancode_table *rc_tab = &dev->rc_tab;
381 unsigned int i, index; 371 unsigned int i, index;
382 int rc; 372 int rc;
383 373
384 rc = ir_create_table(&ir_dev->rc_tab, 374 rc = ir_create_table(rc_tab, from->name,
385 from->name, from->ir_type, from->size); 375 from->ir_type, from->size);
386 if (rc) 376 if (rc)
387 return rc; 377 return rc;
388 378
@@ -390,14 +380,14 @@ static int ir_setkeytable(struct ir_input_dev *ir_dev,
390 rc_tab->size, rc_tab->alloc); 380 rc_tab->size, rc_tab->alloc);
391 381
392 for (i = 0; i < from->size; i++) { 382 for (i = 0; i < from->size; i++) {
393 index = ir_establish_scancode(ir_dev, rc_tab, 383 index = ir_establish_scancode(dev, rc_tab,
394 from->scan[i].scancode, false); 384 from->scan[i].scancode, false);
395 if (index >= rc_tab->len) { 385 if (index >= rc_tab->len) {
396 rc = -ENOMEM; 386 rc = -ENOMEM;
397 break; 387 break;
398 } 388 }
399 389
400 ir_update_mapping(ir_dev->input_dev, rc_tab, index, 390 ir_update_mapping(dev, rc_tab, index,
401 from->scan[i].keycode); 391 from->scan[i].keycode);
402 } 392 }
403 393
@@ -409,7 +399,7 @@ static int ir_setkeytable(struct ir_input_dev *ir_dev,
409 399
410/** 400/**
411 * ir_lookup_by_scancode() - locate mapping by scancode 401 * ir_lookup_by_scancode() - locate mapping by scancode
412 * @rc_tab: the &struct ir_scancode_table to search 402 * @rc_tab: the struct ir_scancode_table to search
413 * @scancode: scancode to look for in the table 403 * @scancode: scancode to look for in the table
414 * @return: index in the table, -1U if not found 404 * @return: index in the table, -1U if not found
415 * 405 *
@@ -438,18 +428,18 @@ static unsigned int ir_lookup_by_scancode(const struct ir_scancode_table *rc_tab
438 428
439/** 429/**
440 * ir_getkeycode() - get a keycode from the scancode->keycode table 430 * ir_getkeycode() - get a keycode from the scancode->keycode table
441 * @dev: the struct input_dev device descriptor 431 * @idev: the struct input_dev device descriptor
442 * @scancode: the desired scancode 432 * @scancode: the desired scancode
443 * @keycode: used to return the keycode, if found, or KEY_RESERVED 433 * @keycode: used to return the keycode, if found, or KEY_RESERVED
444 * @return: always returns zero. 434 * @return: always returns zero.
445 * 435 *
446 * This routine is used to handle evdev EVIOCGKEY ioctl. 436 * This routine is used to handle evdev EVIOCGKEY ioctl.
447 */ 437 */
448static int ir_getkeycode(struct input_dev *dev, 438static int ir_getkeycode(struct input_dev *idev,
449 struct input_keymap_entry *ke) 439 struct input_keymap_entry *ke)
450{ 440{
451 struct ir_input_dev *ir_dev = input_get_drvdata(dev); 441 struct rc_dev *rdev = input_get_drvdata(idev);
452 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab; 442 struct ir_scancode_table *rc_tab = &rdev->rc_tab;
453 struct ir_scancode *entry; 443 struct ir_scancode *entry;
454 unsigned long flags; 444 unsigned long flags;
455 unsigned int index; 445 unsigned int index;
@@ -492,18 +482,17 @@ out:
492 482
493/** 483/**
494 * ir_g_keycode_from_table() - gets the keycode that corresponds to a scancode 484 * ir_g_keycode_from_table() - gets the keycode that corresponds to a scancode
495 * @input_dev: the struct input_dev descriptor of the device 485 * @dev: the struct rc_dev descriptor of the device
496 * @scancode: the scancode that we're seeking 486 * @scancode: the scancode to look for
487 * @return: the corresponding keycode, or KEY_RESERVED
497 * 488 *
498 * This routine is used by the input routines when a key is pressed at the 489 * This routine is used by drivers which need to convert a scancode to a
499 * IR. The scancode is received and needs to be converted into a keycode. 490 * keycode. Normally it should not be used since drivers should have no
500 * If the key is not found, it returns KEY_RESERVED. Otherwise, returns the 491 * interest in keycodes.
501 * corresponding keycode from the table.
502 */ 492 */
503u32 ir_g_keycode_from_table(struct input_dev *dev, u32 scancode) 493u32 ir_g_keycode_from_table(struct rc_dev *dev, u32 scancode)
504{ 494{
505 struct ir_input_dev *ir_dev = input_get_drvdata(dev); 495 struct ir_scancode_table *rc_tab = &dev->rc_tab;
506 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;
507 unsigned int keycode; 496 unsigned int keycode;
508 unsigned int index; 497 unsigned int index;
509 unsigned long flags; 498 unsigned long flags;
@@ -518,7 +507,7 @@ u32 ir_g_keycode_from_table(struct input_dev *dev, u32 scancode)
518 507
519 if (keycode != KEY_RESERVED) 508 if (keycode != KEY_RESERVED)
520 IR_dprintk(1, "%s: scancode 0x%04x keycode 0x%02x\n", 509 IR_dprintk(1, "%s: scancode 0x%04x keycode 0x%02x\n",
521 dev->name, scancode, keycode); 510 dev->input_name, scancode, keycode);
522 511
523 return keycode; 512 return keycode;
524} 513}
@@ -526,50 +515,49 @@ EXPORT_SYMBOL_GPL(ir_g_keycode_from_table);
526 515
527/** 516/**
528 * ir_do_keyup() - internal function to signal the release of a keypress 517 * ir_do_keyup() - internal function to signal the release of a keypress
529 * @ir: the struct ir_input_dev descriptor of the device 518 * @dev: the struct rc_dev descriptor of the device
530 * 519 *
531 * This function is used internally to release a keypress, it must be 520 * This function is used internally to release a keypress, it must be
532 * called with keylock held. 521 * called with keylock held.
533 */ 522 */
534static void ir_do_keyup(struct ir_input_dev *ir) 523static void ir_do_keyup(struct rc_dev *dev)
535{ 524{
536 if (!ir->keypressed) 525 if (!dev->keypressed)
537 return; 526 return;
538 527
539 IR_dprintk(1, "keyup key 0x%04x\n", ir->last_keycode); 528 IR_dprintk(1, "keyup key 0x%04x\n", dev->last_keycode);
540 input_report_key(ir->input_dev, ir->last_keycode, 0); 529 input_report_key(dev->input_dev, dev->last_keycode, 0);
541 input_sync(ir->input_dev); 530 input_sync(dev->input_dev);
542 ir->keypressed = false; 531 dev->keypressed = false;
543} 532}
544 533
545/** 534/**
546 * ir_keyup() - generates input event to signal the release of a keypress 535 * ir_keyup() - signals the release of a keypress
547 * @dev: the struct input_dev descriptor of the device 536 * @dev: the struct rc_dev descriptor of the device
548 * 537 *
549 * This routine is used to signal that a key has been released on the 538 * This routine is used to signal that a key has been released on the
550 * remote control. 539 * remote control.
551 */ 540 */
552void ir_keyup(struct input_dev *dev) 541void ir_keyup(struct rc_dev *dev)
553{ 542{
554 unsigned long flags; 543 unsigned long flags;
555 struct ir_input_dev *ir = input_get_drvdata(dev);
556 544
557 spin_lock_irqsave(&ir->keylock, flags); 545 spin_lock_irqsave(&dev->keylock, flags);
558 ir_do_keyup(ir); 546 ir_do_keyup(dev);
559 spin_unlock_irqrestore(&ir->keylock, flags); 547 spin_unlock_irqrestore(&dev->keylock, flags);
560} 548}
561EXPORT_SYMBOL_GPL(ir_keyup); 549EXPORT_SYMBOL_GPL(ir_keyup);
562 550
563/** 551/**
564 * ir_timer_keyup() - generates a keyup event after a timeout 552 * ir_timer_keyup() - generates a keyup event after a timeout
565 * @cookie: a pointer to struct ir_input_dev passed to setup_timer() 553 * @cookie: a pointer to the struct rc_dev for the device
566 * 554 *
567 * This routine will generate a keyup event some time after a keydown event 555 * This routine will generate a keyup event some time after a keydown event
568 * is generated when no further activity has been detected. 556 * is generated when no further activity has been detected.
569 */ 557 */
570static void ir_timer_keyup(unsigned long cookie) 558static void ir_timer_keyup(unsigned long cookie)
571{ 559{
572 struct ir_input_dev *ir = (struct ir_input_dev *)cookie; 560 struct rc_dev *dev = (struct rc_dev *)cookie;
573 unsigned long flags; 561 unsigned long flags;
574 562
575 /* 563 /*
@@ -582,43 +570,42 @@ static void ir_timer_keyup(unsigned long cookie)
582 * to allow the input subsystem to do its auto-repeat magic or 570 * to allow the input subsystem to do its auto-repeat magic or
583 * a keyup event might follow immediately after the keydown. 571 * a keyup event might follow immediately after the keydown.
584 */ 572 */
585 spin_lock_irqsave(&ir->keylock, flags); 573 spin_lock_irqsave(&dev->keylock, flags);
586 if (time_is_before_eq_jiffies(ir->keyup_jiffies)) 574 if (time_is_before_eq_jiffies(dev->keyup_jiffies))
587 ir_do_keyup(ir); 575 ir_do_keyup(dev);
588 spin_unlock_irqrestore(&ir->keylock, flags); 576 spin_unlock_irqrestore(&dev->keylock, flags);
589} 577}
590 578
591/** 579/**
592 * ir_repeat() - notifies the IR core that a key is still pressed 580 * ir_repeat() - signals that a key is still pressed
593 * @dev: the struct input_dev descriptor of the device 581 * @dev: the struct rc_dev descriptor of the device
594 * 582 *
595 * This routine is used by IR decoders when a repeat message which does 583 * This routine is used by IR decoders when a repeat message which does
596 * not include the necessary bits to reproduce the scancode has been 584 * not include the necessary bits to reproduce the scancode has been
597 * received. 585 * received.
598 */ 586 */
599void ir_repeat(struct input_dev *dev) 587void ir_repeat(struct rc_dev *dev)
600{ 588{
601 unsigned long flags; 589 unsigned long flags;
602 struct ir_input_dev *ir = input_get_drvdata(dev);
603 590
604 spin_lock_irqsave(&ir->keylock, flags); 591 spin_lock_irqsave(&dev->keylock, flags);
605 592
606 input_event(dev, EV_MSC, MSC_SCAN, ir->last_scancode); 593 input_event(dev->input_dev, EV_MSC, MSC_SCAN, dev->last_scancode);
607 594
608 if (!ir->keypressed) 595 if (!dev->keypressed)
609 goto out; 596 goto out;
610 597
611 ir->keyup_jiffies = jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT); 598 dev->keyup_jiffies = jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT);
612 mod_timer(&ir->timer_keyup, ir->keyup_jiffies); 599 mod_timer(&dev->timer_keyup, dev->keyup_jiffies);
613 600
614out: 601out:
615 spin_unlock_irqrestore(&ir->keylock, flags); 602 spin_unlock_irqrestore(&dev->keylock, flags);
616} 603}
617EXPORT_SYMBOL_GPL(ir_repeat); 604EXPORT_SYMBOL_GPL(ir_repeat);
618 605
619/** 606/**
620 * ir_do_keydown() - internal function to process a keypress 607 * ir_do_keydown() - internal function to process a keypress
621 * @dev: the struct input_dev descriptor of the device 608 * @dev: the struct rc_dev descriptor of the device
622 * @scancode: the scancode of the keypress 609 * @scancode: the scancode of the keypress
623 * @keycode: the keycode of the keypress 610 * @keycode: the keycode of the keypress
624 * @toggle: the toggle value of the keypress 611 * @toggle: the toggle value of the keypress
@@ -626,231 +613,96 @@ EXPORT_SYMBOL_GPL(ir_repeat);
626 * This function is used internally to register a keypress, it must be 613 * This function is used internally to register a keypress, it must be
627 * called with keylock held. 614 * called with keylock held.
628 */ 615 */
629static void ir_do_keydown(struct input_dev *dev, int scancode, 616static void ir_do_keydown(struct rc_dev *dev, int scancode,
630 u32 keycode, u8 toggle) 617 u32 keycode, u8 toggle)
631{ 618{
632 struct ir_input_dev *ir = input_get_drvdata(dev); 619 input_event(dev->input_dev, EV_MSC, MSC_SCAN, scancode);
633
634 input_event(dev, EV_MSC, MSC_SCAN, scancode);
635 620
636 /* Repeat event? */ 621 /* Repeat event? */
637 if (ir->keypressed && 622 if (dev->keypressed &&
638 ir->last_scancode == scancode && 623 dev->last_scancode == scancode &&
639 ir->last_toggle == toggle) 624 dev->last_toggle == toggle)
640 return; 625 return;
641 626
642 /* Release old keypress */ 627 /* Release old keypress */
643 ir_do_keyup(ir); 628 ir_do_keyup(dev);
644 629
645 ir->last_scancode = scancode; 630 dev->last_scancode = scancode;
646 ir->last_toggle = toggle; 631 dev->last_toggle = toggle;
647 ir->last_keycode = keycode; 632 dev->last_keycode = keycode;
648 633
649 if (keycode == KEY_RESERVED) 634 if (keycode == KEY_RESERVED)
650 return; 635 return;
651 636
652 /* Register a keypress */ 637 /* Register a keypress */
653 ir->keypressed = true; 638 dev->keypressed = true;
654 IR_dprintk(1, "%s: key down event, key 0x%04x, scancode 0x%04x\n", 639 IR_dprintk(1, "%s: key down event, key 0x%04x, scancode 0x%04x\n",
655 dev->name, keycode, scancode); 640 dev->input_name, keycode, scancode);
656 input_report_key(dev, ir->last_keycode, 1); 641 input_report_key(dev->input_dev, dev->last_keycode, 1);
657 input_sync(dev); 642 input_sync(dev->input_dev);
658} 643}
659 644
660/** 645/**
661 * ir_keydown() - generates input event for a key press 646 * ir_keydown() - generates input event for a key press
662 * @dev: the struct input_dev descriptor of the device 647 * @dev: the struct rc_dev descriptor of the device
663 * @scancode: the scancode that we're seeking 648 * @scancode: the scancode that we're seeking
664 * @toggle: the toggle value (protocol dependent, if the protocol doesn't 649 * @toggle: the toggle value (protocol dependent, if the protocol doesn't
665 * support toggle values, this should be set to zero) 650 * support toggle values, this should be set to zero)
666 * 651 *
667 * This routine is used by the input routines when a key is pressed at the 652 * This routine is used to signal that a key has been pressed on the
668 * IR. It gets the keycode for a scancode and reports an input event via 653 * remote control.
669 * input_report_key().
670 */ 654 */
671void ir_keydown(struct input_dev *dev, int scancode, u8 toggle) 655void ir_keydown(struct rc_dev *dev, int scancode, u8 toggle)
672{ 656{
673 unsigned long flags; 657 unsigned long flags;
674 struct ir_input_dev *ir = input_get_drvdata(dev);
675 u32 keycode = ir_g_keycode_from_table(dev, scancode); 658 u32 keycode = ir_g_keycode_from_table(dev, scancode);
676 659
677 spin_lock_irqsave(&ir->keylock, flags); 660 spin_lock_irqsave(&dev->keylock, flags);
678 ir_do_keydown(dev, scancode, keycode, toggle); 661 ir_do_keydown(dev, scancode, keycode, toggle);
679 662
680 if (ir->keypressed) { 663 if (dev->keypressed) {
681 ir->keyup_jiffies = jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT); 664 dev->keyup_jiffies = jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT);
682 mod_timer(&ir->timer_keyup, ir->keyup_jiffies); 665 mod_timer(&dev->timer_keyup, dev->keyup_jiffies);
683 } 666 }
684 spin_unlock_irqrestore(&ir->keylock, flags); 667 spin_unlock_irqrestore(&dev->keylock, flags);
685} 668}
686EXPORT_SYMBOL_GPL(ir_keydown); 669EXPORT_SYMBOL_GPL(ir_keydown);
687 670
688/** 671/**
689 * ir_keydown_notimeout() - generates input event for a key press without 672 * ir_keydown_notimeout() - generates input event for a key press without
690 * an automatic keyup event at a later time 673 * an automatic keyup event at a later time
691 * @dev: the struct input_dev descriptor of the device 674 * @dev: the struct rc_dev descriptor of the device
692 * @scancode: the scancode that we're seeking 675 * @scancode: the scancode that we're seeking
693 * @toggle: the toggle value (protocol dependent, if the protocol doesn't 676 * @toggle: the toggle value (protocol dependent, if the protocol doesn't
694 * support toggle values, this should be set to zero) 677 * support toggle values, this should be set to zero)
695 * 678 *
696 * This routine is used by the input routines when a key is pressed at the 679 * This routine is used to signal that a key has been pressed on the
697 * IR. It gets the keycode for a scancode and reports an input event via 680 * remote control. The driver must manually call ir_keyup() at a later stage.
698 * input_report_key(). The driver must manually call ir_keyup() at a later
699 * stage.
700 */ 681 */
701void ir_keydown_notimeout(struct input_dev *dev, int scancode, u8 toggle) 682void ir_keydown_notimeout(struct rc_dev *dev, int scancode, u8 toggle)
702{ 683{
703 unsigned long flags; 684 unsigned long flags;
704 struct ir_input_dev *ir = input_get_drvdata(dev);
705 u32 keycode = ir_g_keycode_from_table(dev, scancode); 685 u32 keycode = ir_g_keycode_from_table(dev, scancode);
706 686
707 spin_lock_irqsave(&ir->keylock, flags); 687 spin_lock_irqsave(&dev->keylock, flags);
708 ir_do_keydown(dev, scancode, keycode, toggle); 688 ir_do_keydown(dev, scancode, keycode, toggle);
709 spin_unlock_irqrestore(&ir->keylock, flags); 689 spin_unlock_irqrestore(&dev->keylock, flags);
710} 690}
711EXPORT_SYMBOL_GPL(ir_keydown_notimeout); 691EXPORT_SYMBOL_GPL(ir_keydown_notimeout);
712 692
713static int ir_open(struct input_dev *input_dev) 693static int ir_open(struct input_dev *idev)
714{
715 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
716
717 return ir_dev->props->open(ir_dev->props->priv);
718}
719
720static void ir_close(struct input_dev *input_dev)
721{
722 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
723
724 ir_dev->props->close(ir_dev->props->priv);
725}
726
727/**
728 * __ir_input_register() - sets the IR keycode table and add the handlers
729 * for keymap table get/set
730 * @input_dev: the struct input_dev descriptor of the device
731 * @rc_tab: the struct ir_scancode_table table of scancode/keymap
732 *
733 * This routine is used to initialize the input infrastructure
734 * to work with an IR.
735 * It will register the input/evdev interface for the device and
736 * register the syfs code for IR class
737 */
738int __ir_input_register(struct input_dev *input_dev,
739 const struct ir_scancode_table *rc_tab,
740 struct ir_dev_props *props,
741 const char *driver_name)
742{ 694{
743 struct ir_input_dev *ir_dev; 695 struct rc_dev *rdev = input_get_drvdata(idev);
744 int rc;
745
746 if (rc_tab->scan == NULL || !rc_tab->size)
747 return -EINVAL;
748
749 ir_dev = kzalloc(sizeof(*ir_dev), GFP_KERNEL);
750 if (!ir_dev)
751 return -ENOMEM;
752
753 ir_dev->driver_name = kasprintf(GFP_KERNEL, "%s", driver_name);
754 if (!ir_dev->driver_name) {
755 rc = -ENOMEM;
756 goto out_dev;
757 }
758
759 input_dev->getkeycode_new = ir_getkeycode;
760 input_dev->setkeycode_new = ir_setkeycode;
761 input_set_drvdata(input_dev, ir_dev);
762 ir_dev->input_dev = input_dev;
763
764 spin_lock_init(&ir_dev->rc_tab.lock);
765 spin_lock_init(&ir_dev->keylock);
766 setup_timer(&ir_dev->timer_keyup, ir_timer_keyup, (unsigned long)ir_dev);
767
768 if (props) {
769 ir_dev->props = props;
770 if (props->open)
771 input_dev->open = ir_open;
772 if (props->close)
773 input_dev->close = ir_close;
774 }
775
776 set_bit(EV_KEY, input_dev->evbit);
777 set_bit(EV_REP, input_dev->evbit);
778 set_bit(EV_MSC, input_dev->evbit);
779 set_bit(MSC_SCAN, input_dev->mscbit);
780
781 rc = ir_setkeytable(ir_dev, rc_tab);
782 if (rc)
783 goto out_name;
784 696
785 rc = ir_register_class(input_dev); 697 return rdev->open(rdev);
786 if (rc < 0)
787 goto out_table;
788
789 if (ir_dev->props)
790 if (ir_dev->props->driver_type == RC_DRIVER_IR_RAW) {
791 rc = ir_raw_event_register(input_dev);
792 if (rc < 0)
793 goto out_event;
794 }
795
796 rc = ir_register_input(input_dev);
797 if (rc < 0)
798 goto out_event;
799
800 IR_dprintk(1, "Registered input device on %s for %s remote%s.\n",
801 driver_name, rc_tab->name,
802 (ir_dev->props && ir_dev->props->driver_type == RC_DRIVER_IR_RAW) ?
803 " in raw mode" : "");
804
805 /*
806 * Default delay of 250ms is too short for some protocols, expecially
807 * since the timeout is currently set to 250ms. Increase it to 500ms,
808 * to avoid wrong repetition of the keycodes.
809 */
810 input_dev->rep[REP_DELAY] = 500;
811
812 return 0;
813
814out_event:
815 ir_unregister_class(input_dev);
816out_table:
817 ir_free_table(&ir_dev->rc_tab);
818out_name:
819 kfree(ir_dev->driver_name);
820out_dev:
821 kfree(ir_dev);
822 return rc;
823} 698}
824EXPORT_SYMBOL_GPL(__ir_input_register);
825
826/**
827 * ir_input_unregister() - unregisters IR and frees resources
828 * @input_dev: the struct input_dev descriptor of the device
829 699
830 * This routine is used to free memory and de-register interfaces. 700static void ir_close(struct input_dev *idev)
831 */
832void ir_input_unregister(struct input_dev *input_dev)
833{ 701{
834 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); 702 struct rc_dev *rdev = input_get_drvdata(idev);
835
836 if (!ir_dev)
837 return;
838
839 IR_dprintk(1, "Freed keycode table\n");
840 703
841 del_timer_sync(&ir_dev->timer_keyup); 704 rdev->close(rdev);
842 if (ir_dev->props)
843 if (ir_dev->props->driver_type == RC_DRIVER_IR_RAW)
844 ir_raw_event_unregister(input_dev);
845
846 ir_free_table(&ir_dev->rc_tab);
847
848 ir_unregister_class(input_dev);
849
850 kfree(ir_dev->driver_name);
851 kfree(ir_dev);
852} 705}
853EXPORT_SYMBOL_GPL(ir_input_unregister);
854 706
855/* class for /sys/class/rc */ 707/* class for /sys/class/rc */
856static char *ir_devnode(struct device *dev, mode_t *mode) 708static char *ir_devnode(struct device *dev, mode_t *mode)
@@ -881,7 +733,7 @@ static struct {
881 733
882/** 734/**
883 * show_protocols() - shows the current IR protocol(s) 735 * show_protocols() - shows the current IR protocol(s)
884 * @d: the device descriptor 736 * @device: the device descriptor
885 * @mattr: the device attribute struct (unused) 737 * @mattr: the device attribute struct (unused)
886 * @buf: a pointer to the output buffer 738 * @buf: a pointer to the output buffer
887 * 739 *
@@ -890,26 +742,25 @@ static struct {
890 * It returns the protocol names of supported protocols. 742 * It returns the protocol names of supported protocols.
891 * Enabled protocols are printed in brackets. 743 * Enabled protocols are printed in brackets.
892 */ 744 */
893static ssize_t show_protocols(struct device *d, 745static ssize_t show_protocols(struct device *device,
894 struct device_attribute *mattr, char *buf) 746 struct device_attribute *mattr, char *buf)
895{ 747{
896 struct ir_input_dev *ir_dev = dev_get_drvdata(d); 748 struct rc_dev *dev = to_rc_dev(device);
897 u64 allowed, enabled; 749 u64 allowed, enabled;
898 char *tmp = buf; 750 char *tmp = buf;
899 int i; 751 int i;
900 752
901 /* Device is being removed */ 753 /* Device is being removed */
902 if (!ir_dev) 754 if (!dev)
903 return -EINVAL; 755 return -EINVAL;
904 756
905 if (ir_dev->props && ir_dev->props->driver_type == RC_DRIVER_SCANCODE) { 757 if (dev->driver_type == RC_DRIVER_SCANCODE) {
906 enabled = ir_dev->rc_tab.ir_type; 758 enabled = dev->rc_tab.ir_type;
907 allowed = ir_dev->props->allowed_protos; 759 allowed = dev->allowed_protos;
908 } else if (ir_dev->raw) { 760 } else {
909 enabled = ir_dev->raw->enabled_protocols; 761 enabled = dev->raw->enabled_protocols;
910 allowed = ir_raw_get_allowed_protocols(); 762 allowed = ir_raw_get_allowed_protocols();
911 } else 763 }
912 return sprintf(tmp, "[builtin]\n");
913 764
914 IR_dprintk(1, "allowed - 0x%llx, enabled - 0x%llx\n", 765 IR_dprintk(1, "allowed - 0x%llx, enabled - 0x%llx\n",
915 (long long)allowed, 766 (long long)allowed,
@@ -930,12 +781,12 @@ static ssize_t show_protocols(struct device *d,
930 781
931/** 782/**
932 * store_protocols() - changes the current IR protocol(s) 783 * store_protocols() - changes the current IR protocol(s)
933 * @d: the device descriptor 784 * @device: the device descriptor
934 * @mattr: the device attribute struct (unused) 785 * @mattr: the device attribute struct (unused)
935 * @buf: a pointer to the input buffer 786 * @buf: a pointer to the input buffer
936 * @len: length of the input buffer 787 * @len: length of the input buffer
937 * 788 *
938 * This routine is a callback routine for changing the IR protocol type. 789 * This routine is for changing the IR protocol type.
939 * It is trigged by writing to /sys/class/rc/rc?/protocols. 790 * It is trigged by writing to /sys/class/rc/rc?/protocols.
940 * Writing "+proto" will add a protocol to the list of enabled protocols. 791 * Writing "+proto" will add a protocol to the list of enabled protocols.
941 * Writing "-proto" will remove a protocol from the list of enabled protocols. 792 * Writing "-proto" will remove a protocol from the list of enabled protocols.
@@ -944,12 +795,12 @@ static ssize_t show_protocols(struct device *d,
944 * Returns -EINVAL if an invalid protocol combination or unknown protocol name 795 * Returns -EINVAL if an invalid protocol combination or unknown protocol name
945 * is used, otherwise @len. 796 * is used, otherwise @len.
946 */ 797 */
947static ssize_t store_protocols(struct device *d, 798static ssize_t store_protocols(struct device *device,
948 struct device_attribute *mattr, 799 struct device_attribute *mattr,
949 const char *data, 800 const char *data,
950 size_t len) 801 size_t len)
951{ 802{
952 struct ir_input_dev *ir_dev = dev_get_drvdata(d); 803 struct rc_dev *dev = to_rc_dev(device);
953 bool enable, disable; 804 bool enable, disable;
954 const char *tmp; 805 const char *tmp;
955 u64 type; 806 u64 type;
@@ -958,13 +809,13 @@ static ssize_t store_protocols(struct device *d,
958 unsigned long flags; 809 unsigned long flags;
959 810
960 /* Device is being removed */ 811 /* Device is being removed */
961 if (!ir_dev) 812 if (!dev)
962 return -EINVAL; 813 return -EINVAL;
963 814
964 if (ir_dev->props && ir_dev->props->driver_type == RC_DRIVER_SCANCODE) 815 if (dev->driver_type == RC_DRIVER_SCANCODE)
965 type = ir_dev->rc_tab.ir_type; 816 type = dev->rc_tab.ir_type;
966 else if (ir_dev->raw) 817 else if (dev->raw)
967 type = ir_dev->raw->enabled_protocols; 818 type = dev->raw->enabled_protocols;
968 else { 819 else {
969 IR_dprintk(1, "Protocol switching not supported\n"); 820 IR_dprintk(1, "Protocol switching not supported\n");
970 return -EINVAL; 821 return -EINVAL;
@@ -1019,9 +870,8 @@ static ssize_t store_protocols(struct device *d,
1019 return -EINVAL; 870 return -EINVAL;
1020 } 871 }
1021 872
1022 if (ir_dev->props && ir_dev->props->change_protocol) { 873 if (dev->change_protocol) {
1023 rc = ir_dev->props->change_protocol(ir_dev->props->priv, 874 rc = dev->change_protocol(dev, type);
1024 type);
1025 if (rc < 0) { 875 if (rc < 0) {
1026 IR_dprintk(1, "Error setting protocols to 0x%llx\n", 876 IR_dprintk(1, "Error setting protocols to 0x%llx\n",
1027 (long long)type); 877 (long long)type);
@@ -1029,12 +879,12 @@ static ssize_t store_protocols(struct device *d,
1029 } 879 }
1030 } 880 }
1031 881
1032 if (ir_dev->props && ir_dev->props->driver_type == RC_DRIVER_SCANCODE) { 882 if (dev->driver_type == RC_DRIVER_SCANCODE) {
1033 spin_lock_irqsave(&ir_dev->rc_tab.lock, flags); 883 spin_lock_irqsave(&dev->rc_tab.lock, flags);
1034 ir_dev->rc_tab.ir_type = type; 884 dev->rc_tab.ir_type = type;
1035 spin_unlock_irqrestore(&ir_dev->rc_tab.lock, flags); 885 spin_unlock_irqrestore(&dev->rc_tab.lock, flags);
1036 } else { 886 } else {
1037 ir_dev->raw->enabled_protocols = type; 887 dev->raw->enabled_protocols = type;
1038 } 888 }
1039 889
1040 IR_dprintk(1, "Current protocol(s): 0x%llx\n", 890 IR_dprintk(1, "Current protocol(s): 0x%llx\n",
@@ -1043,6 +893,14 @@ static ssize_t store_protocols(struct device *d,
1043 return len; 893 return len;
1044} 894}
1045 895
896static void rc_dev_release(struct device *device)
897{
898 struct rc_dev *dev = to_rc_dev(device);
899
900 kfree(dev);
901 module_put(THIS_MODULE);
902}
903
1046#define ADD_HOTPLUG_VAR(fmt, val...) \ 904#define ADD_HOTPLUG_VAR(fmt, val...) \
1047 do { \ 905 do { \
1048 int err = add_uevent_var(env, fmt, val); \ 906 int err = add_uevent_var(env, fmt, val); \
@@ -1052,12 +910,12 @@ static ssize_t store_protocols(struct device *d,
1052 910
1053static int rc_dev_uevent(struct device *device, struct kobj_uevent_env *env) 911static int rc_dev_uevent(struct device *device, struct kobj_uevent_env *env)
1054{ 912{
1055 struct ir_input_dev *ir_dev = dev_get_drvdata(device); 913 struct rc_dev *dev = to_rc_dev(device);
1056 914
1057 if (ir_dev->rc_tab.name) 915 if (dev->rc_tab.name)
1058 ADD_HOTPLUG_VAR("NAME=%s", ir_dev->rc_tab.name); 916 ADD_HOTPLUG_VAR("NAME=%s", dev->rc_tab.name);
1059 if (ir_dev->driver_name) 917 if (dev->driver_name)
1060 ADD_HOTPLUG_VAR("DRV_NAME=%s", ir_dev->driver_name); 918 ADD_HOTPLUG_VAR("DRV_NAME=%s", dev->driver_name);
1061 919
1062 return 0; 920 return 0;
1063} 921}
@@ -1084,84 +942,162 @@ static const struct attribute_group *rc_dev_attr_groups[] = {
1084 942
1085static struct device_type rc_dev_type = { 943static struct device_type rc_dev_type = {
1086 .groups = rc_dev_attr_groups, 944 .groups = rc_dev_attr_groups,
945 .release = rc_dev_release,
1087 .uevent = rc_dev_uevent, 946 .uevent = rc_dev_uevent,
1088}; 947};
1089 948
1090/** 949struct rc_dev *rc_allocate_device(void)
1091 * ir_register_class() - creates the sysfs for /sys/class/rc/rc?
1092 * @input_dev: the struct input_dev descriptor of the device
1093 *
1094 * This routine is used to register the syfs code for IR class
1095 */
1096static int ir_register_class(struct input_dev *input_dev)
1097{ 950{
1098 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); 951 struct rc_dev *dev;
1099 int devno = find_first_zero_bit(&ir_core_dev_number,
1100 IRRCV_NUM_DEVICES);
1101
1102 if (unlikely(devno < 0))
1103 return devno;
1104
1105 ir_dev->dev.type = &rc_dev_type;
1106 ir_dev->devno = devno;
1107
1108 ir_dev->dev.class = &ir_input_class;
1109 ir_dev->dev.parent = input_dev->dev.parent;
1110 input_dev->dev.parent = &ir_dev->dev;
1111 dev_set_name(&ir_dev->dev, "rc%d", devno);
1112 dev_set_drvdata(&ir_dev->dev, ir_dev);
1113 return device_register(&ir_dev->dev);
1114};
1115 952
1116/** 953 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
1117 * ir_register_input - registers ir input device with input subsystem 954 if (!dev)
1118 * @input_dev: the struct input_dev descriptor of the device 955 return NULL;
1119 */ 956
957 dev->input_dev = input_allocate_device();
958 if (!dev->input_dev) {
959 kfree(dev);
960 return NULL;
961 }
962
963 dev->input_dev->getkeycode_new = ir_getkeycode;
964 dev->input_dev->setkeycode_new = ir_setkeycode;
965 input_set_drvdata(dev->input_dev, dev);
966
967 spin_lock_init(&dev->rc_tab.lock);
968 spin_lock_init(&dev->keylock);
969 setup_timer(&dev->timer_keyup, ir_timer_keyup, (unsigned long)dev);
1120 970
1121static int ir_register_input(struct input_dev *input_dev) 971 dev->dev.type = &rc_dev_type;
972 dev->dev.class = &ir_input_class;
973 device_initialize(&dev->dev);
974
975 __module_get(THIS_MODULE);
976 return dev;
977}
978EXPORT_SYMBOL_GPL(rc_allocate_device);
979
980void rc_free_device(struct rc_dev *dev)
1122{ 981{
1123 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); 982 if (dev) {
1124 int rc; 983 input_free_device(dev->input_dev);
984 put_device(&dev->dev);
985 }
986}
987EXPORT_SYMBOL_GPL(rc_free_device);
988
989int rc_register_device(struct rc_dev *dev)
990{
991 static atomic_t devno = ATOMIC_INIT(0);
992 struct ir_scancode_table *rc_tab;
1125 const char *path; 993 const char *path;
994 int rc;
1126 995
996 if (!dev || !dev->map_name)
997 return -EINVAL;
1127 998
1128 rc = input_register_device(input_dev); 999 rc_tab = get_rc_map(dev->map_name);
1129 if (rc < 0) { 1000 if (!rc_tab)
1130 device_del(&ir_dev->dev); 1001 rc_tab = get_rc_map(RC_MAP_EMPTY);
1002 if (!rc_tab || !rc_tab->scan || rc_tab->size == 0)
1003 return -EINVAL;
1004
1005 set_bit(EV_KEY, dev->input_dev->evbit);
1006 set_bit(EV_REP, dev->input_dev->evbit);
1007 set_bit(EV_MSC, dev->input_dev->evbit);
1008 set_bit(MSC_SCAN, dev->input_dev->mscbit);
1009 if (dev->open)
1010 dev->input_dev->open = ir_open;
1011 if (dev->close)
1012 dev->input_dev->close = ir_close;
1013
1014 dev->devno = (unsigned long)(atomic_inc_return(&devno) - 1);
1015 dev_set_name(&dev->dev, "rc%ld", dev->devno);
1016 dev_set_drvdata(&dev->dev, dev);
1017 rc = device_add(&dev->dev);
1018 if (rc)
1131 return rc; 1019 return rc;
1132 }
1133 1020
1134 __module_get(THIS_MODULE); 1021 rc = ir_setkeytable(dev, rc_tab);
1022 if (rc)
1023 goto out_dev;
1024
1025 dev->input_dev->dev.parent = &dev->dev;
1026 memcpy(&dev->input_dev->id, &dev->input_id, sizeof(dev->input_id));
1027 dev->input_dev->phys = dev->input_phys;
1028 dev->input_dev->name = dev->input_name;
1029 rc = input_register_device(dev->input_dev);
1030 if (rc)
1031 goto out_table;
1135 1032
1136 path = kobject_get_path(&ir_dev->dev.kobj, GFP_KERNEL); 1033 /*
1034 * Default delay of 250ms is too short for some protocols, expecially
1035 * since the timeout is currently set to 250ms. Increase it to 500ms,
1036 * to avoid wrong repetition of the keycodes. Note that this must be
1037 * set after the call to input_register_device().
1038 */
1039 dev->input_dev->rep[REP_DELAY] = 500;
1040
1041 path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL);
1137 printk(KERN_INFO "%s: %s as %s\n", 1042 printk(KERN_INFO "%s: %s as %s\n",
1138 dev_name(&ir_dev->dev), 1043 dev_name(&dev->dev),
1139 input_dev->name ? input_dev->name : "Unspecified device", 1044 dev->input_name ? dev->input_name : "Unspecified device",
1140 path ? path : "N/A"); 1045 path ? path : "N/A");
1141 kfree(path); 1046 kfree(path);
1142 1047
1143 set_bit(ir_dev->devno, &ir_core_dev_number); 1048 if (dev->driver_type == RC_DRIVER_IR_RAW) {
1049 rc = ir_raw_event_register(dev);
1050 if (rc < 0)
1051 goto out_input;
1052 }
1053
1054 if (dev->change_protocol) {
1055 rc = dev->change_protocol(dev, rc_tab->ir_type);
1056 if (rc < 0)
1057 goto out_raw;
1058 }
1059
1060 IR_dprintk(1, "Registered rc%ld (driver: %s, remote: %s, mode %s)\n",
1061 dev->devno,
1062 dev->driver_name ? dev->driver_name : "unknown",
1063 rc_tab->name ? rc_tab->name : "unknown",
1064 dev->driver_type == RC_DRIVER_IR_RAW ? "raw" : "cooked");
1065
1144 return 0; 1066 return 0;
1067
1068out_raw:
1069 if (dev->driver_type == RC_DRIVER_IR_RAW)
1070 ir_raw_event_unregister(dev);
1071out_input:
1072 input_unregister_device(dev->input_dev);
1073 dev->input_dev = NULL;
1074out_table:
1075 ir_free_table(&dev->rc_tab);
1076out_dev:
1077 device_del(&dev->dev);
1078 return rc;
1145} 1079}
1080EXPORT_SYMBOL_GPL(rc_register_device);
1146 1081
1147/** 1082void rc_unregister_device(struct rc_dev *dev)
1148 * ir_unregister_class() - removes the sysfs for sysfs for
1149 * /sys/class/rc/rc?
1150 * @input_dev: the struct input_dev descriptor of the device
1151 *
1152 * This routine is used to unregister the syfs code for IR class
1153 */
1154static void ir_unregister_class(struct input_dev *input_dev)
1155{ 1083{
1156 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); 1084 if (!dev)
1085 return;
1157 1086
1158 input_set_drvdata(input_dev, NULL); 1087 del_timer_sync(&dev->timer_keyup);
1159 clear_bit(ir_dev->devno, &ir_core_dev_number);
1160 input_unregister_device(input_dev);
1161 device_del(&ir_dev->dev);
1162 1088
1163 module_put(THIS_MODULE); 1089 if (dev->driver_type == RC_DRIVER_IR_RAW)
1090 ir_raw_event_unregister(dev);
1091
1092 input_unregister_device(dev->input_dev);
1093 dev->input_dev = NULL;
1094
1095 ir_free_table(&dev->rc_tab);
1096 IR_dprintk(1, "Freed keycode table\n");
1097
1098 device_unregister(&dev->dev);
1164} 1099}
1100EXPORT_SYMBOL_GPL(rc_unregister_device);
1165 1101
1166/* 1102/*
1167 * Init/exit code for the module. Basically, creates/removes /sys/class/rc 1103 * Init/exit code for the module. Basically, creates/removes /sys/class/rc
diff --git a/drivers/media/rc/rc-raw.c b/drivers/media/rc/rc-raw.c
index d6c556e3f0d..ab9b1e4071c 100644
--- a/drivers/media/rc/rc-raw.c
+++ b/drivers/media/rc/rc-raw.c
@@ -64,7 +64,7 @@ static int ir_raw_event_thread(void *data)
64 64
65 mutex_lock(&ir_raw_handler_lock); 65 mutex_lock(&ir_raw_handler_lock);
66 list_for_each_entry(handler, &ir_raw_handler_list, list) 66 list_for_each_entry(handler, &ir_raw_handler_list, list)
67 handler->decode(raw->input_dev, ev); 67 handler->decode(raw->dev, ev);
68 raw->prev_ev = ev; 68 raw->prev_ev = ev;
69 mutex_unlock(&ir_raw_handler_lock); 69 mutex_unlock(&ir_raw_handler_lock);
70 } 70 }
@@ -74,7 +74,7 @@ static int ir_raw_event_thread(void *data)
74 74
75/** 75/**
76 * ir_raw_event_store() - pass a pulse/space duration to the raw ir decoders 76 * ir_raw_event_store() - pass a pulse/space duration to the raw ir decoders
77 * @input_dev: the struct input_dev device descriptor 77 * @dev: the struct rc_dev device descriptor
78 * @ev: the struct ir_raw_event descriptor of the pulse/space 78 * @ev: the struct ir_raw_event descriptor of the pulse/space
79 * 79 *
80 * This routine (which may be called from an interrupt context) stores a 80 * This routine (which may be called from an interrupt context) stores a
@@ -82,17 +82,15 @@ static int ir_raw_event_thread(void *data)
82 * signalled as positive values and spaces as negative values. A zero value 82 * signalled as positive values and spaces as negative values. A zero value
83 * will reset the decoding state machines. 83 * will reset the decoding state machines.
84 */ 84 */
85int ir_raw_event_store(struct input_dev *input_dev, struct ir_raw_event *ev) 85int ir_raw_event_store(struct rc_dev *dev, struct ir_raw_event *ev)
86{ 86{
87 struct ir_input_dev *ir = input_get_drvdata(input_dev); 87 if (!dev->raw)
88
89 if (!ir->raw)
90 return -EINVAL; 88 return -EINVAL;
91 89
92 IR_dprintk(2, "sample: (%05dus %s)\n", 90 IR_dprintk(2, "sample: (%05dus %s)\n",
93 TO_US(ev->duration), TO_STR(ev->pulse)); 91 TO_US(ev->duration), TO_STR(ev->pulse));
94 92
95 if (kfifo_in(&ir->raw->kfifo, ev, sizeof(*ev)) != sizeof(*ev)) 93 if (kfifo_in(&dev->raw->kfifo, ev, sizeof(*ev)) != sizeof(*ev))
96 return -ENOMEM; 94 return -ENOMEM;
97 95
98 return 0; 96 return 0;
@@ -101,7 +99,7 @@ EXPORT_SYMBOL_GPL(ir_raw_event_store);
101 99
102/** 100/**
103 * ir_raw_event_store_edge() - notify raw ir decoders of the start of a pulse/space 101 * ir_raw_event_store_edge() - notify raw ir decoders of the start of a pulse/space
104 * @input_dev: the struct input_dev device descriptor 102 * @dev: the struct rc_dev device descriptor
105 * @type: the type of the event that has occurred 103 * @type: the type of the event that has occurred
106 * 104 *
107 * This routine (which may be called from an interrupt context) is used to 105 * This routine (which may be called from an interrupt context) is used to
@@ -110,50 +108,49 @@ EXPORT_SYMBOL_GPL(ir_raw_event_store);
110 * hardware which does not provide durations directly but only interrupts 108 * hardware which does not provide durations directly but only interrupts
111 * (or similar events) on state change. 109 * (or similar events) on state change.
112 */ 110 */
113int ir_raw_event_store_edge(struct input_dev *input_dev, enum raw_event_type type) 111int ir_raw_event_store_edge(struct rc_dev *dev, enum raw_event_type type)
114{ 112{
115 struct ir_input_dev *ir = input_get_drvdata(input_dev);
116 ktime_t now; 113 ktime_t now;
117 s64 delta; /* ns */ 114 s64 delta; /* ns */
118 struct ir_raw_event ev; 115 struct ir_raw_event ev;
119 int rc = 0; 116 int rc = 0;
120 117
121 if (!ir->raw) 118 if (!dev->raw)
122 return -EINVAL; 119 return -EINVAL;
123 120
124 now = ktime_get(); 121 now = ktime_get();
125 delta = ktime_to_ns(ktime_sub(now, ir->raw->last_event)); 122 delta = ktime_to_ns(ktime_sub(now, dev->raw->last_event));
126 123
127 /* Check for a long duration since last event or if we're 124 /* Check for a long duration since last event or if we're
128 * being called for the first time, note that delta can't 125 * being called for the first time, note that delta can't
129 * possibly be negative. 126 * possibly be negative.
130 */ 127 */
131 ev.duration = 0; 128 ev.duration = 0;
132 if (delta > IR_MAX_DURATION || !ir->raw->last_type) 129 if (delta > IR_MAX_DURATION || !dev->raw->last_type)
133 type |= IR_START_EVENT; 130 type |= IR_START_EVENT;
134 else 131 else
135 ev.duration = delta; 132 ev.duration = delta;
136 133
137 if (type & IR_START_EVENT) 134 if (type & IR_START_EVENT)
138 ir_raw_event_reset(input_dev); 135 ir_raw_event_reset(dev);
139 else if (ir->raw->last_type & IR_SPACE) { 136 else if (dev->raw->last_type & IR_SPACE) {
140 ev.pulse = false; 137 ev.pulse = false;
141 rc = ir_raw_event_store(input_dev, &ev); 138 rc = ir_raw_event_store(dev, &ev);
142 } else if (ir->raw->last_type & IR_PULSE) { 139 } else if (dev->raw->last_type & IR_PULSE) {
143 ev.pulse = true; 140 ev.pulse = true;
144 rc = ir_raw_event_store(input_dev, &ev); 141 rc = ir_raw_event_store(dev, &ev);
145 } else 142 } else
146 return 0; 143 return 0;
147 144
148 ir->raw->last_event = now; 145 dev->raw->last_event = now;
149 ir->raw->last_type = type; 146 dev->raw->last_type = type;
150 return rc; 147 return rc;
151} 148}
152EXPORT_SYMBOL_GPL(ir_raw_event_store_edge); 149EXPORT_SYMBOL_GPL(ir_raw_event_store_edge);
153 150
154/** 151/**
155 * ir_raw_event_store_with_filter() - pass next pulse/space to decoders with some processing 152 * ir_raw_event_store_with_filter() - pass next pulse/space to decoders with some processing
156 * @input_dev: the struct input_dev device descriptor 153 * @dev: the struct rc_dev device descriptor
157 * @type: the type of the event that has occurred 154 * @type: the type of the event that has occurred
158 * 155 *
159 * This routine (which may be called from an interrupt context) works 156 * This routine (which may be called from an interrupt context) works
@@ -161,84 +158,76 @@ EXPORT_SYMBOL_GPL(ir_raw_event_store_edge);
161 * This routine is intended for devices with limited internal buffer 158 * This routine is intended for devices with limited internal buffer
162 * It automerges samples of same type, and handles timeouts 159 * It automerges samples of same type, and handles timeouts
163 */ 160 */
164int ir_raw_event_store_with_filter(struct input_dev *input_dev, 161int ir_raw_event_store_with_filter(struct rc_dev *dev, struct ir_raw_event *ev)
165 struct ir_raw_event *ev)
166{ 162{
167 struct ir_input_dev *ir = input_get_drvdata(input_dev); 163 if (!dev->raw)
168 struct ir_raw_event_ctrl *raw = ir->raw;
169
170 if (!raw || !ir->props)
171 return -EINVAL; 164 return -EINVAL;
172 165
173 /* Ignore spaces in idle mode */ 166 /* Ignore spaces in idle mode */
174 if (ir->idle && !ev->pulse) 167 if (dev->idle && !ev->pulse)
175 return 0; 168 return 0;
176 else if (ir->idle) 169 else if (dev->idle)
177 ir_raw_event_set_idle(input_dev, false); 170 ir_raw_event_set_idle(dev, false);
178 171
179 if (!raw->this_ev.duration) { 172 if (!dev->raw->this_ev.duration)
180 raw->this_ev = *ev; 173 dev->raw->this_ev = *ev;
181 } else if (ev->pulse == raw->this_ev.pulse) { 174 else if (ev->pulse == dev->raw->this_ev.pulse)
182 raw->this_ev.duration += ev->duration; 175 dev->raw->this_ev.duration += ev->duration;
183 } else { 176 else {
184 ir_raw_event_store(input_dev, &raw->this_ev); 177 ir_raw_event_store(dev, &dev->raw->this_ev);
185 raw->this_ev = *ev; 178 dev->raw->this_ev = *ev;
186 } 179 }
187 180
188 /* Enter idle mode if nessesary */ 181 /* Enter idle mode if nessesary */
189 if (!ev->pulse && ir->props->timeout && 182 if (!ev->pulse && dev->timeout &&
190 raw->this_ev.duration >= ir->props->timeout) { 183 dev->raw->this_ev.duration >= dev->timeout)
191 ir_raw_event_set_idle(input_dev, true); 184 ir_raw_event_set_idle(dev, true);
192 } 185
193 return 0; 186 return 0;
194} 187}
195EXPORT_SYMBOL_GPL(ir_raw_event_store_with_filter); 188EXPORT_SYMBOL_GPL(ir_raw_event_store_with_filter);
196 189
197/** 190/**
198 * ir_raw_event_set_idle() - hint the ir core if device is receiving 191 * ir_raw_event_set_idle() - provide hint to rc-core when the device is idle or not
199 * IR data or not 192 * @dev: the struct rc_dev device descriptor
200 * @input_dev: the struct input_dev device descriptor 193 * @idle: whether the device is idle or not
201 * @idle: the hint value
202 */ 194 */
203void ir_raw_event_set_idle(struct input_dev *input_dev, bool idle) 195void ir_raw_event_set_idle(struct rc_dev *dev, bool idle)
204{ 196{
205 struct ir_input_dev *ir = input_get_drvdata(input_dev); 197 if (!dev->raw)
206 struct ir_raw_event_ctrl *raw = ir->raw;
207
208 if (!ir->props || !ir->raw)
209 return; 198 return;
210 199
211 IR_dprintk(2, "%s idle mode\n", idle ? "enter" : "leave"); 200 IR_dprintk(2, "%s idle mode\n", idle ? "enter" : "leave");
212 201
213 if (idle) { 202 if (idle) {
214 raw->this_ev.timeout = true; 203 dev->raw->this_ev.timeout = true;
215 ir_raw_event_store(input_dev, &raw->this_ev); 204 ir_raw_event_store(dev, &dev->raw->this_ev);
216 init_ir_raw_event(&raw->this_ev); 205 init_ir_raw_event(&dev->raw->this_ev);
217 } 206 }
218 207
219 if (ir->props->s_idle) 208 if (dev->s_idle)
220 ir->props->s_idle(ir->props->priv, idle); 209 dev->s_idle(dev, idle);
221 ir->idle = idle; 210
211 dev->idle = idle;
222} 212}
223EXPORT_SYMBOL_GPL(ir_raw_event_set_idle); 213EXPORT_SYMBOL_GPL(ir_raw_event_set_idle);
224 214
225/** 215/**
226 * ir_raw_event_handle() - schedules the decoding of stored ir data 216 * ir_raw_event_handle() - schedules the decoding of stored ir data
227 * @input_dev: the struct input_dev device descriptor 217 * @dev: the struct rc_dev device descriptor
228 * 218 *
229 * This routine will signal the workqueue to start decoding stored ir data. 219 * This routine will tell rc-core to start decoding stored ir data.
230 */ 220 */
231void ir_raw_event_handle(struct input_dev *input_dev) 221void ir_raw_event_handle(struct rc_dev *dev)
232{ 222{
233 struct ir_input_dev *ir = input_get_drvdata(input_dev);
234 unsigned long flags; 223 unsigned long flags;
235 224
236 if (!ir->raw) 225 if (!dev->raw)
237 return; 226 return;
238 227
239 spin_lock_irqsave(&ir->raw->lock, flags); 228 spin_lock_irqsave(&dev->raw->lock, flags);
240 wake_up_process(ir->raw->thread); 229 wake_up_process(dev->raw->thread);
241 spin_unlock_irqrestore(&ir->raw->lock, flags); 230 spin_unlock_irqrestore(&dev->raw->lock, flags);
242} 231}
243EXPORT_SYMBOL_GPL(ir_raw_event_handle); 232EXPORT_SYMBOL_GPL(ir_raw_event_handle);
244 233
@@ -256,69 +245,69 @@ ir_raw_get_allowed_protocols()
256/* 245/*
257 * Used to (un)register raw event clients 246 * Used to (un)register raw event clients
258 */ 247 */
259int ir_raw_event_register(struct input_dev *input_dev) 248int ir_raw_event_register(struct rc_dev *dev)
260{ 249{
261 struct ir_input_dev *ir = input_get_drvdata(input_dev);
262 int rc; 250 int rc;
263 struct ir_raw_handler *handler; 251 struct ir_raw_handler *handler;
264 252
265 ir->raw = kzalloc(sizeof(*ir->raw), GFP_KERNEL); 253 if (!dev)
266 if (!ir->raw) 254 return -EINVAL;
267 return -ENOMEM;
268 255
269 ir->raw->input_dev = input_dev; 256 dev->raw = kzalloc(sizeof(*dev->raw), GFP_KERNEL);
257 if (!dev->raw)
258 return -ENOMEM;
270 259
271 ir->raw->enabled_protocols = ~0; 260 dev->raw->dev = dev;
272 rc = kfifo_alloc(&ir->raw->kfifo, sizeof(s64) * MAX_IR_EVENT_SIZE, 261 dev->raw->enabled_protocols = ~0;
262 rc = kfifo_alloc(&dev->raw->kfifo,
263 sizeof(struct ir_raw_event) * MAX_IR_EVENT_SIZE,
273 GFP_KERNEL); 264 GFP_KERNEL);
274 if (rc < 0) { 265 if (rc < 0)
275 kfree(ir->raw); 266 goto out;
276 ir->raw = NULL;
277 return rc;
278 }
279 267
280 spin_lock_init(&ir->raw->lock); 268 spin_lock_init(&dev->raw->lock);
281 ir->raw->thread = kthread_run(ir_raw_event_thread, ir->raw, 269 dev->raw->thread = kthread_run(ir_raw_event_thread, dev->raw,
282 "rc%u", (unsigned int)ir->devno); 270 "rc%ld", dev->devno);
283 271
284 if (IS_ERR(ir->raw->thread)) { 272 if (IS_ERR(dev->raw->thread)) {
285 int ret = PTR_ERR(ir->raw->thread); 273 rc = PTR_ERR(dev->raw->thread);
286 274 goto out;
287 kfree(ir->raw);
288 ir->raw = NULL;
289 return ret;
290 } 275 }
291 276
292 mutex_lock(&ir_raw_handler_lock); 277 mutex_lock(&ir_raw_handler_lock);
293 list_add_tail(&ir->raw->list, &ir_raw_client_list); 278 list_add_tail(&dev->raw->list, &ir_raw_client_list);
294 list_for_each_entry(handler, &ir_raw_handler_list, list) 279 list_for_each_entry(handler, &ir_raw_handler_list, list)
295 if (handler->raw_register) 280 if (handler->raw_register)
296 handler->raw_register(ir->raw->input_dev); 281 handler->raw_register(dev);
297 mutex_unlock(&ir_raw_handler_lock); 282 mutex_unlock(&ir_raw_handler_lock);
298 283
299 return 0; 284 return 0;
285
286out:
287 kfree(dev->raw);
288 dev->raw = NULL;
289 return rc;
300} 290}
301 291
302void ir_raw_event_unregister(struct input_dev *input_dev) 292void ir_raw_event_unregister(struct rc_dev *dev)
303{ 293{
304 struct ir_input_dev *ir = input_get_drvdata(input_dev);
305 struct ir_raw_handler *handler; 294 struct ir_raw_handler *handler;
306 295
307 if (!ir->raw) 296 if (!dev || !dev->raw)
308 return; 297 return;
309 298
310 kthread_stop(ir->raw->thread); 299 kthread_stop(dev->raw->thread);
311 300
312 mutex_lock(&ir_raw_handler_lock); 301 mutex_lock(&ir_raw_handler_lock);
313 list_del(&ir->raw->list); 302 list_del(&dev->raw->list);
314 list_for_each_entry(handler, &ir_raw_handler_list, list) 303 list_for_each_entry(handler, &ir_raw_handler_list, list)
315 if (handler->raw_unregister) 304 if (handler->raw_unregister)
316 handler->raw_unregister(ir->raw->input_dev); 305 handler->raw_unregister(dev);
317 mutex_unlock(&ir_raw_handler_lock); 306 mutex_unlock(&ir_raw_handler_lock);
318 307
319 kfifo_free(&ir->raw->kfifo); 308 kfifo_free(&dev->raw->kfifo);
320 kfree(ir->raw); 309 kfree(dev->raw);
321 ir->raw = NULL; 310 dev->raw = NULL;
322} 311}
323 312
324/* 313/*
@@ -333,7 +322,7 @@ int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler)
333 list_add_tail(&ir_raw_handler->list, &ir_raw_handler_list); 322 list_add_tail(&ir_raw_handler->list, &ir_raw_handler_list);
334 if (ir_raw_handler->raw_register) 323 if (ir_raw_handler->raw_register)
335 list_for_each_entry(raw, &ir_raw_client_list, list) 324 list_for_each_entry(raw, &ir_raw_client_list, list)
336 ir_raw_handler->raw_register(raw->input_dev); 325 ir_raw_handler->raw_register(raw->dev);
337 available_protocols |= ir_raw_handler->protocols; 326 available_protocols |= ir_raw_handler->protocols;
338 mutex_unlock(&ir_raw_handler_lock); 327 mutex_unlock(&ir_raw_handler_lock);
339 328
@@ -349,7 +338,7 @@ void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler)
349 list_del(&ir_raw_handler->list); 338 list_del(&ir_raw_handler->list);
350 if (ir_raw_handler->raw_unregister) 339 if (ir_raw_handler->raw_unregister)
351 list_for_each_entry(raw, &ir_raw_client_list, list) 340 list_for_each_entry(raw, &ir_raw_client_list, list)
352 ir_raw_handler->raw_unregister(raw->input_dev); 341 ir_raw_handler->raw_unregister(raw->dev);
353 available_protocols &= ~ir_raw_handler->protocols; 342 available_protocols &= ~ir_raw_handler->protocols;
354 mutex_unlock(&ir_raw_handler_lock); 343 mutex_unlock(&ir_raw_handler_lock);
355} 344}
diff --git a/drivers/media/rc/streamzap.c b/drivers/media/rc/streamzap.c
index 3a20aef67d0..f05f5c173fd 100644
--- a/drivers/media/rc/streamzap.c
+++ b/drivers/media/rc/streamzap.c
@@ -34,7 +34,6 @@
34#include <linux/device.h> 34#include <linux/device.h>
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/input.h>
38#include <linux/usb.h> 37#include <linux/usb.h>
39#include <linux/usb/input.h> 38#include <linux/usb/input.h>
40#include <media/ir-core.h> 39#include <media/ir-core.h>
@@ -86,13 +85,11 @@ enum StreamzapDecoderState {
86 85
87/* structure to hold our device specific stuff */ 86/* structure to hold our device specific stuff */
88struct streamzap_ir { 87struct streamzap_ir {
89
90 /* ir-core */ 88 /* ir-core */
91 struct ir_dev_props *props; 89 struct rc_dev *rdev;
92 90
93 /* core device info */ 91 /* core device info */
94 struct device *dev; 92 struct device *dev;
95 struct input_dev *idev;
96 93
97 /* usb */ 94 /* usb */
98 struct usb_device *usbdev; 95 struct usb_device *usbdev;
@@ -143,7 +140,7 @@ static void sz_push(struct streamzap_ir *sz, struct ir_raw_event rawir)
143{ 140{
144 dev_dbg(sz->dev, "Storing %s with duration %u us\n", 141 dev_dbg(sz->dev, "Storing %s with duration %u us\n",
145 (rawir.pulse ? "pulse" : "space"), rawir.duration); 142 (rawir.pulse ? "pulse" : "space"), rawir.duration);
146 ir_raw_event_store_with_filter(sz->idev, &rawir); 143 ir_raw_event_store_with_filter(sz->rdev, &rawir);
147} 144}
148 145
149static void sz_push_full_pulse(struct streamzap_ir *sz, 146static void sz_push_full_pulse(struct streamzap_ir *sz,
@@ -271,11 +268,11 @@ static void streamzap_callback(struct urb *urb)
271 DEFINE_IR_RAW_EVENT(rawir); 268 DEFINE_IR_RAW_EVENT(rawir);
272 269
273 rawir.pulse = false; 270 rawir.pulse = false;
274 rawir.duration = sz->props->timeout; 271 rawir.duration = sz->rdev->timeout;
275 sz->idle = true; 272 sz->idle = true;
276 if (sz->timeout_enabled) 273 if (sz->timeout_enabled)
277 sz_push(sz, rawir); 274 sz_push(sz, rawir);
278 ir_raw_event_handle(sz->idev); 275 ir_raw_event_handle(sz->rdev);
279 } else { 276 } else {
280 sz_push_full_space(sz, sz->buf_in[i]); 277 sz_push_full_space(sz, sz->buf_in[i]);
281 } 278 }
@@ -298,57 +295,43 @@ static void streamzap_callback(struct urb *urb)
298 return; 295 return;
299} 296}
300 297
301static struct input_dev *streamzap_init_input_dev(struct streamzap_ir *sz) 298static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz)
302{ 299{
303 struct input_dev *idev; 300 struct rc_dev *rdev;
304 struct ir_dev_props *props;
305 struct device *dev = sz->dev; 301 struct device *dev = sz->dev;
306 int ret; 302 int ret;
307 303
308 idev = input_allocate_device(); 304 rdev = rc_allocate_device();
309 if (!idev) { 305 if (!rdev) {
310 dev_err(dev, "remote input dev allocation failed\n"); 306 dev_err(dev, "remote dev allocation failed\n");
311 goto idev_alloc_failed; 307 goto out;
312 }
313
314 props = kzalloc(sizeof(struct ir_dev_props), GFP_KERNEL);
315 if (!props) {
316 dev_err(dev, "remote ir dev props allocation failed\n");
317 goto props_alloc_failed;
318 } 308 }
319 309
320 snprintf(sz->name, sizeof(sz->name), "Streamzap PC Remote Infrared " 310 snprintf(sz->name, sizeof(sz->name), "Streamzap PC Remote Infrared "
321 "Receiver (%04x:%04x)", 311 "Receiver (%04x:%04x)",
322 le16_to_cpu(sz->usbdev->descriptor.idVendor), 312 le16_to_cpu(sz->usbdev->descriptor.idVendor),
323 le16_to_cpu(sz->usbdev->descriptor.idProduct)); 313 le16_to_cpu(sz->usbdev->descriptor.idProduct));
324
325 idev->name = sz->name;
326 usb_make_path(sz->usbdev, sz->phys, sizeof(sz->phys)); 314 usb_make_path(sz->usbdev, sz->phys, sizeof(sz->phys));
327 strlcat(sz->phys, "/input0", sizeof(sz->phys)); 315 strlcat(sz->phys, "/input0", sizeof(sz->phys));
328 idev->phys = sz->phys;
329
330 props->priv = sz;
331 props->driver_type = RC_DRIVER_IR_RAW;
332 props->allowed_protos = IR_TYPE_ALL;
333
334 sz->props = props;
335 316
336 usb_to_input_id(sz->usbdev, &idev->id); 317 rdev->input_name = sz->name;
337 idev->dev.parent = sz->dev; 318 rdev->input_phys = sz->phys;
319 rdev->priv = sz;
320 rdev->driver_type = RC_DRIVER_IR_RAW;
321 rdev->allowed_protos = IR_TYPE_ALL;
322 rdev->driver_name = DRIVER_NAME;
323 rdev->map_name = RC_MAP_STREAMZAP;
338 324
339 ret = ir_input_register(idev, RC_MAP_STREAMZAP, props, DRIVER_NAME); 325 ret = rc_register_device(rdev);
340 if (ret < 0) { 326 if (ret < 0) {
341 dev_err(dev, "remote input device register failed\n"); 327 dev_err(dev, "remote input device register failed\n");
342 goto irdev_failed; 328 goto out;
343 } 329 }
344 330
345 return idev; 331 return rdev;
346 332
347irdev_failed: 333out:
348 kfree(props); 334 rc_free_device(rdev);
349props_alloc_failed:
350 input_free_device(idev);
351idev_alloc_failed:
352 return NULL; 335 return NULL;
353} 336}
354 337
@@ -437,15 +420,15 @@ static int __devinit streamzap_probe(struct usb_interface *intf,
437 snprintf(name + strlen(name), sizeof(name) - strlen(name), 420 snprintf(name + strlen(name), sizeof(name) - strlen(name),
438 " %s", buf); 421 " %s", buf);
439 422
440 sz->idev = streamzap_init_input_dev(sz); 423 sz->rdev = streamzap_init_rc_dev(sz);
441 if (!sz->idev) 424 if (!sz->rdev)
442 goto input_dev_fail; 425 goto rc_dev_fail;
443 426
444 sz->idle = true; 427 sz->idle = true;
445 sz->decoder_state = PulseSpace; 428 sz->decoder_state = PulseSpace;
446 /* FIXME: don't yet have a way to set this */ 429 /* FIXME: don't yet have a way to set this */
447 sz->timeout_enabled = true; 430 sz->timeout_enabled = true;
448 sz->props->timeout = (((SZ_TIMEOUT * SZ_RESOLUTION * 1000) & 431 sz->rdev->timeout = (((SZ_TIMEOUT * SZ_RESOLUTION * 1000) &
449 IR_MAX_DURATION) | 0x03000000); 432 IR_MAX_DURATION) | 0x03000000);
450 #if 0 433 #if 0
451 /* not yet supported, depends on patches from maxim */ 434 /* not yet supported, depends on patches from maxim */
@@ -476,7 +459,7 @@ static int __devinit streamzap_probe(struct usb_interface *intf,
476 459
477 return 0; 460 return 0;
478 461
479input_dev_fail: 462rc_dev_fail:
480 usb_free_urb(sz->urb_in); 463 usb_free_urb(sz->urb_in);
481free_buf_in: 464free_buf_in:
482 usb_free_coherent(usbdev, maxp, sz->buf_in, sz->dma_in); 465 usb_free_coherent(usbdev, maxp, sz->buf_in, sz->dma_in);
@@ -507,7 +490,7 @@ static void streamzap_disconnect(struct usb_interface *interface)
507 return; 490 return;
508 491
509 sz->usbdev = NULL; 492 sz->usbdev = NULL;
510 ir_input_unregister(sz->idev); 493 rc_unregister_device(sz->rdev);
511 usb_kill_urb(sz->urb_in); 494 usb_kill_urb(sz->urb_in);
512 usb_free_urb(sz->urb_in); 495 usb_free_urb(sz->urb_in);
513 usb_free_coherent(usbdev, sz->buf_in_len, sz->buf_in, sz->dma_in); 496 usb_free_coherent(usbdev, sz->buf_in_len, sz->buf_in, sz->dma_in);
diff --git a/drivers/media/video/bt8xx/bttv-input.c b/drivers/media/video/bt8xx/bttv-input.c
index eb71c3ae36d..4b4f6137c6c 100644
--- a/drivers/media/video/bt8xx/bttv-input.c
+++ b/drivers/media/video/bt8xx/bttv-input.c
@@ -31,10 +31,6 @@
31 31
32static int ir_debug; 32static int ir_debug;
33module_param(ir_debug, int, 0644); 33module_param(ir_debug, int, 0644);
34static int repeat_delay = 500;
35module_param(repeat_delay, int, 0644);
36static int repeat_period = 33;
37module_param(repeat_period, int, 0644);
38 34
39static int ir_rc5_remote_gap = 885; 35static int ir_rc5_remote_gap = 885;
40module_param(ir_rc5_remote_gap, int, 0644); 36module_param(ir_rc5_remote_gap, int, 0644);
@@ -317,15 +313,15 @@ int bttv_input_init(struct bttv *btv)
317{ 313{
318 struct card_ir *ir; 314 struct card_ir *ir;
319 char *ir_codes = NULL; 315 char *ir_codes = NULL;
320 struct input_dev *input_dev; 316 struct rc_dev *rc;
321 int err = -ENOMEM; 317 int err = -ENOMEM;
322 318
323 if (!btv->has_remote) 319 if (!btv->has_remote)
324 return -ENODEV; 320 return -ENODEV;
325 321
326 ir = kzalloc(sizeof(*ir),GFP_KERNEL); 322 ir = kzalloc(sizeof(*ir),GFP_KERNEL);
327 input_dev = input_allocate_device(); 323 rc = rc_allocate_device();
328 if (!ir || !input_dev) 324 if (!ir || !rc)
329 goto err_out_free; 325 goto err_out_free;
330 326
331 /* detect & configure */ 327 /* detect & configure */
@@ -431,44 +427,43 @@ int bttv_input_init(struct bttv *btv)
431 } 427 }
432 428
433 /* init input device */ 429 /* init input device */
434 ir->dev = input_dev; 430 ir->dev = rc;
435 431
436 snprintf(ir->name, sizeof(ir->name), "bttv IR (card=%d)", 432 snprintf(ir->name, sizeof(ir->name), "bttv IR (card=%d)",
437 btv->c.type); 433 btv->c.type);
438 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", 434 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
439 pci_name(btv->c.pci)); 435 pci_name(btv->c.pci));
440 436
441 input_dev->name = ir->name; 437 rc->input_name = ir->name;
442 input_dev->phys = ir->phys; 438 rc->input_phys = ir->phys;
443 input_dev->id.bustype = BUS_PCI; 439 rc->input_id.bustype = BUS_PCI;
444 input_dev->id.version = 1; 440 rc->input_id.version = 1;
445 if (btv->c.pci->subsystem_vendor) { 441 if (btv->c.pci->subsystem_vendor) {
446 input_dev->id.vendor = btv->c.pci->subsystem_vendor; 442 rc->input_id.vendor = btv->c.pci->subsystem_vendor;
447 input_dev->id.product = btv->c.pci->subsystem_device; 443 rc->input_id.product = btv->c.pci->subsystem_device;
448 } else { 444 } else {
449 input_dev->id.vendor = btv->c.pci->vendor; 445 rc->input_id.vendor = btv->c.pci->vendor;
450 input_dev->id.product = btv->c.pci->device; 446 rc->input_id.product = btv->c.pci->device;
451 } 447 }
452 input_dev->dev.parent = &btv->c.pci->dev; 448 rc->dev.parent = &btv->c.pci->dev;
449 rc->map_name = ir_codes;
450 rc->driver_name = MODULE_NAME;
453 451
454 btv->remote = ir; 452 btv->remote = ir;
455 bttv_ir_start(btv, ir); 453 bttv_ir_start(btv, ir);
456 454
457 /* all done */ 455 /* all done */
458 err = ir_input_register(btv->remote->dev, ir_codes, NULL, MODULE_NAME); 456 err = rc_register_device(rc);
459 if (err) 457 if (err)
460 goto err_out_stop; 458 goto err_out_stop;
461 459
462 /* the remote isn't as bouncy as a keyboard */
463 ir->dev->rep[REP_DELAY] = repeat_delay;
464 ir->dev->rep[REP_PERIOD] = repeat_period;
465
466 return 0; 460 return 0;
467 461
468 err_out_stop: 462 err_out_stop:
469 bttv_ir_stop(btv); 463 bttv_ir_stop(btv);
470 btv->remote = NULL; 464 btv->remote = NULL;
471 err_out_free: 465 err_out_free:
466 rc_free_device(rc);
472 kfree(ir); 467 kfree(ir);
473 return err; 468 return err;
474} 469}
@@ -479,7 +474,7 @@ void bttv_input_fini(struct bttv *btv)
479 return; 474 return;
480 475
481 bttv_ir_stop(btv); 476 bttv_ir_stop(btv);
482 ir_input_unregister(btv->remote->dev); 477 rc_unregister_device(btv->remote->dev);
483 kfree(btv->remote); 478 kfree(btv->remote);
484 btv->remote = NULL; 479 btv->remote = NULL;
485} 480}
diff --git a/drivers/media/video/cx231xx/cx231xx.h b/drivers/media/video/cx231xx/cx231xx.h
index a09cef43d98..c439e778c4b 100644
--- a/drivers/media/video/cx231xx/cx231xx.h
+++ b/drivers/media/video/cx231xx/cx231xx.h
@@ -607,7 +607,15 @@ struct cx231xx_ir_t {
607 char name[40]; 607 char name[40];
608 char phys[32]; 608 char phys[32];
609 609
610#if 0
611 /*
612 * Due to a Kconfig change, cx231xx-input is not being compiled.
613 * This structure disappeared, but other fixes are also needed.
614 * So, as a workaround, let's just comment this struct and let a
615 * latter patch fix it.
616 */
610 struct ir_dev_props props; 617 struct ir_dev_props props;
618#endif
611 619
612 /* I2C keyboard data */ 620 /* I2C keyboard data */
613 struct IR_i2c_init_data init_data; 621 struct IR_i2c_init_data init_data;
diff --git a/drivers/media/video/cx23885/cx23885-input.c b/drivers/media/video/cx23885/cx23885-input.c
index bb61870b8d6..f1bb3a8683c 100644
--- a/drivers/media/video/cx23885/cx23885-input.c
+++ b/drivers/media/video/cx23885/cx23885-input.c
@@ -35,7 +35,6 @@
35 * 02110-1301, USA. 35 * 02110-1301, USA.
36 */ 36 */
37 37
38#include <linux/input.h>
39#include <linux/slab.h> 38#include <linux/slab.h>
40#include <media/ir-core.h> 39#include <media/ir-core.h>
41#include <media/v4l2-subdev.h> 40#include <media/v4l2-subdev.h>
@@ -62,16 +61,16 @@ static void cx23885_input_process_measurements(struct cx23885_dev *dev,
62 count = num / sizeof(struct ir_raw_event); 61 count = num / sizeof(struct ir_raw_event);
63 62
64 for (i = 0; i < count; i++) { 63 for (i = 0; i < count; i++) {
65 ir_raw_event_store(kernel_ir->inp_dev, 64 ir_raw_event_store(kernel_ir->rc,
66 &ir_core_event[i]); 65 &ir_core_event[i]);
67 handle = true; 66 handle = true;
68 } 67 }
69 } while (num != 0); 68 } while (num != 0);
70 69
71 if (overrun) 70 if (overrun)
72 ir_raw_event_reset(kernel_ir->inp_dev); 71 ir_raw_event_reset(kernel_ir->rc);
73 else if (handle) 72 else if (handle)
74 ir_raw_event_handle(kernel_ir->inp_dev); 73 ir_raw_event_handle(kernel_ir->rc);
75} 74}
76 75
77void cx23885_input_rx_work_handler(struct cx23885_dev *dev, u32 events) 76void cx23885_input_rx_work_handler(struct cx23885_dev *dev, u32 events)
@@ -197,9 +196,9 @@ static int cx23885_input_ir_start(struct cx23885_dev *dev)
197 return 0; 196 return 0;
198} 197}
199 198
200static int cx23885_input_ir_open(void *priv) 199static int cx23885_input_ir_open(struct rc_dev *rc)
201{ 200{
202 struct cx23885_kernel_ir *kernel_ir = priv; 201 struct cx23885_kernel_ir *kernel_ir = rc->priv;
203 202
204 if (kernel_ir->cx == NULL) 203 if (kernel_ir->cx == NULL)
205 return -ENODEV; 204 return -ENODEV;
@@ -234,9 +233,9 @@ static void cx23885_input_ir_stop(struct cx23885_dev *dev)
234 flush_scheduled_work(); 233 flush_scheduled_work();
235} 234}
236 235
237static void cx23885_input_ir_close(void *priv) 236static void cx23885_input_ir_close(struct rc_dev *rc)
238{ 237{
239 struct cx23885_kernel_ir *kernel_ir = priv; 238 struct cx23885_kernel_ir *kernel_ir = rc->priv;
240 239
241 if (kernel_ir->cx != NULL) 240 if (kernel_ir->cx != NULL)
242 cx23885_input_ir_stop(kernel_ir->cx); 241 cx23885_input_ir_stop(kernel_ir->cx);
@@ -245,9 +244,7 @@ static void cx23885_input_ir_close(void *priv)
245int cx23885_input_init(struct cx23885_dev *dev) 244int cx23885_input_init(struct cx23885_dev *dev)
246{ 245{
247 struct cx23885_kernel_ir *kernel_ir; 246 struct cx23885_kernel_ir *kernel_ir;
248 struct input_dev *inp_dev; 247 struct rc_dev *rc;
249 struct ir_dev_props *props;
250
251 char *rc_map; 248 char *rc_map;
252 enum rc_driver_type driver_type; 249 enum rc_driver_type driver_type;
253 unsigned long allowed_protos; 250 unsigned long allowed_protos;
@@ -294,37 +291,36 @@ int cx23885_input_init(struct cx23885_dev *dev)
294 pci_name(dev->pci)); 291 pci_name(dev->pci));
295 292
296 /* input device */ 293 /* input device */
297 inp_dev = input_allocate_device(); 294 rc = rc_allocate_device();
298 if (inp_dev == NULL) { 295 if (!rc) {
299 ret = -ENOMEM; 296 ret = -ENOMEM;
300 goto err_out_free; 297 goto err_out_free;
301 } 298 }
302 299
303 kernel_ir->inp_dev = inp_dev; 300 kernel_ir->rc = rc;
304 inp_dev->name = kernel_ir->name; 301 rc->input_name = kernel_ir->name;
305 inp_dev->phys = kernel_ir->phys; 302 rc->input_phys = kernel_ir->phys;
306 inp_dev->id.bustype = BUS_PCI; 303 rc->input_id.bustype = BUS_PCI;
307 inp_dev->id.version = 1; 304 rc->input_id.version = 1;
308 if (dev->pci->subsystem_vendor) { 305 if (dev->pci->subsystem_vendor) {
309 inp_dev->id.vendor = dev->pci->subsystem_vendor; 306 rc->input_id.vendor = dev->pci->subsystem_vendor;
310 inp_dev->id.product = dev->pci->subsystem_device; 307 rc->input_id.product = dev->pci->subsystem_device;
311 } else { 308 } else {
312 inp_dev->id.vendor = dev->pci->vendor; 309 rc->input_id.vendor = dev->pci->vendor;
313 inp_dev->id.product = dev->pci->device; 310 rc->input_id.product = dev->pci->device;
314 } 311 }
315 inp_dev->dev.parent = &dev->pci->dev; 312 rc->dev.parent = &dev->pci->dev;
316 313 rc->driver_type = driver_type;
317 /* kernel ir device properties */ 314 rc->allowed_protos = allowed_protos;
318 props = &kernel_ir->props; 315 rc->priv = kernel_ir;
319 props->driver_type = driver_type; 316 rc->open = cx23885_input_ir_open;
320 props->allowed_protos = allowed_protos; 317 rc->close = cx23885_input_ir_close;
321 props->priv = kernel_ir; 318 rc->map_name = rc_map;
322 props->open = cx23885_input_ir_open; 319 rc->driver_name = MODULE_NAME;
323 props->close = cx23885_input_ir_close;
324 320
325 /* Go */ 321 /* Go */
326 dev->kernel_ir = kernel_ir; 322 dev->kernel_ir = kernel_ir;
327 ret = ir_input_register(inp_dev, rc_map, props, MODULE_NAME); 323 ret = rc_register_device(rc);
328 if (ret) 324 if (ret)
329 goto err_out_stop; 325 goto err_out_stop;
330 326
@@ -333,7 +329,7 @@ int cx23885_input_init(struct cx23885_dev *dev)
333err_out_stop: 329err_out_stop:
334 cx23885_input_ir_stop(dev); 330 cx23885_input_ir_stop(dev);
335 dev->kernel_ir = NULL; 331 dev->kernel_ir = NULL;
336 /* TODO: double check clean-up of kernel_ir->inp_dev */ 332 rc_free_device(rc);
337err_out_free: 333err_out_free:
338 kfree(kernel_ir->phys); 334 kfree(kernel_ir->phys);
339 kfree(kernel_ir->name); 335 kfree(kernel_ir->name);
@@ -348,7 +344,7 @@ void cx23885_input_fini(struct cx23885_dev *dev)
348 344
349 if (dev->kernel_ir == NULL) 345 if (dev->kernel_ir == NULL)
350 return; 346 return;
351 ir_input_unregister(dev->kernel_ir->inp_dev); 347 rc_unregister_device(dev->kernel_ir->rc);
352 kfree(dev->kernel_ir->phys); 348 kfree(dev->kernel_ir->phys);
353 kfree(dev->kernel_ir->name); 349 kfree(dev->kernel_ir->name);
354 kfree(dev->kernel_ir); 350 kfree(dev->kernel_ir);
diff --git a/drivers/media/video/cx23885/cx23885.h b/drivers/media/video/cx23885/cx23885.h
index ed94b17dd8a..f350d88944e 100644
--- a/drivers/media/video/cx23885/cx23885.h
+++ b/drivers/media/video/cx23885/cx23885.h
@@ -310,8 +310,7 @@ struct cx23885_kernel_ir {
310 char *name; 310 char *name;
311 char *phys; 311 char *phys;
312 312
313 struct input_dev *inp_dev; 313 struct rc_dev *rc;
314 struct ir_dev_props props;
315}; 314};
316 315
317struct cx23885_dev { 316struct cx23885_dev {
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index 8c41124befb..3b2ef45d634 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -24,7 +24,6 @@
24 24
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/hrtimer.h> 26#include <linux/hrtimer.h>
27#include <linux/input.h>
28#include <linux/pci.h> 27#include <linux/pci.h>
29#include <linux/slab.h> 28#include <linux/slab.h>
30#include <linux/module.h> 29#include <linux/module.h>
@@ -38,8 +37,7 @@
38 37
39struct cx88_IR { 38struct cx88_IR {
40 struct cx88_core *core; 39 struct cx88_core *core;
41 struct input_dev *input; 40 struct rc_dev *dev;
42 struct ir_dev_props props;
43 41
44 int users; 42 int users;
45 43
@@ -125,26 +123,26 @@ static void cx88_ir_handle_key(struct cx88_IR *ir)
125 123
126 data = (data << 4) | ((gpio_key & 0xf0) >> 4); 124 data = (data << 4) | ((gpio_key & 0xf0) >> 4);
127 125
128 ir_keydown(ir->input, data, 0); 126 ir_keydown(ir->dev, data, 0);
129 127
130 } else if (ir->mask_keydown) { 128 } else if (ir->mask_keydown) {
131 /* bit set on keydown */ 129 /* bit set on keydown */
132 if (gpio & ir->mask_keydown) 130 if (gpio & ir->mask_keydown)
133 ir_keydown_notimeout(ir->input, data, 0); 131 ir_keydown_notimeout(ir->dev, data, 0);
134 else 132 else
135 ir_keyup(ir->input); 133 ir_keyup(ir->dev);
136 134
137 } else if (ir->mask_keyup) { 135 } else if (ir->mask_keyup) {
138 /* bit cleared on keydown */ 136 /* bit cleared on keydown */
139 if (0 == (gpio & ir->mask_keyup)) 137 if (0 == (gpio & ir->mask_keyup))
140 ir_keydown_notimeout(ir->input, data, 0); 138 ir_keydown_notimeout(ir->dev, data, 0);
141 else 139 else
142 ir_keyup(ir->input); 140 ir_keyup(ir->dev);
143 141
144 } else { 142 } else {
145 /* can't distinguish keydown/up :-/ */ 143 /* can't distinguish keydown/up :-/ */
146 ir_keydown_notimeout(ir->input, data, 0); 144 ir_keydown_notimeout(ir->dev, data, 0);
147 ir_keyup(ir->input); 145 ir_keyup(ir->dev);
148 } 146 }
149} 147}
150 148
@@ -219,17 +217,17 @@ void cx88_ir_stop(struct cx88_core *core)
219 __cx88_ir_stop(core); 217 __cx88_ir_stop(core);
220} 218}
221 219
222static int cx88_ir_open(void *priv) 220static int cx88_ir_open(struct rc_dev *rc)
223{ 221{
224 struct cx88_core *core = priv; 222 struct cx88_core *core = rc->priv;
225 223
226 core->ir->users++; 224 core->ir->users++;
227 return __cx88_ir_start(core); 225 return __cx88_ir_start(core);
228} 226}
229 227
230static void cx88_ir_close(void *priv) 228static void cx88_ir_close(struct rc_dev *rc)
231{ 229{
232 struct cx88_core *core = priv; 230 struct cx88_core *core = rc->priv;
233 231
234 core->ir->users--; 232 core->ir->users--;
235 if (!core->ir->users) 233 if (!core->ir->users)
@@ -241,7 +239,7 @@ static void cx88_ir_close(void *priv)
241int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) 239int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
242{ 240{
243 struct cx88_IR *ir; 241 struct cx88_IR *ir;
244 struct input_dev *input_dev; 242 struct rc_dev *dev;
245 char *ir_codes = NULL; 243 char *ir_codes = NULL;
246 u64 ir_type = IR_TYPE_OTHER; 244 u64 ir_type = IR_TYPE_OTHER;
247 int err = -ENOMEM; 245 int err = -ENOMEM;
@@ -250,11 +248,11 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
250 */ 248 */
251 249
252 ir = kzalloc(sizeof(*ir), GFP_KERNEL); 250 ir = kzalloc(sizeof(*ir), GFP_KERNEL);
253 input_dev = input_allocate_device(); 251 dev = rc_allocate_device();
254 if (!ir || !input_dev) 252 if (!ir || !dev)
255 goto err_out_free; 253 goto err_out_free;
256 254
257 ir->input = input_dev; 255 ir->dev = dev;
258 256
259 /* detect & configure */ 257 /* detect & configure */
260 switch (core->boardnr) { 258 switch (core->boardnr) {
@@ -435,43 +433,45 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
435 snprintf(ir->name, sizeof(ir->name), "cx88 IR (%s)", core->board.name); 433 snprintf(ir->name, sizeof(ir->name), "cx88 IR (%s)", core->board.name);
436 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci)); 434 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci));
437 435
438 input_dev->name = ir->name; 436 dev->input_name = ir->name;
439 input_dev->phys = ir->phys; 437 dev->input_phys = ir->phys;
440 input_dev->id.bustype = BUS_PCI; 438 dev->input_id.bustype = BUS_PCI;
441 input_dev->id.version = 1; 439 dev->input_id.version = 1;
442 if (pci->subsystem_vendor) { 440 if (pci->subsystem_vendor) {
443 input_dev->id.vendor = pci->subsystem_vendor; 441 dev->input_id.vendor = pci->subsystem_vendor;
444 input_dev->id.product = pci->subsystem_device; 442 dev->input_id.product = pci->subsystem_device;
445 } else { 443 } else {
446 input_dev->id.vendor = pci->vendor; 444 dev->input_id.vendor = pci->vendor;
447 input_dev->id.product = pci->device; 445 dev->input_id.product = pci->device;
448 } 446 }
449 input_dev->dev.parent = &pci->dev; 447 dev->dev.parent = &pci->dev;
450 /* record handles to ourself */ 448 dev->map_name = ir_codes;
451 ir->core = core; 449 dev->driver_name = MODULE_NAME;
452 core->ir = ir; 450 dev->priv = core;
451 dev->open = cx88_ir_open;
452 dev->close = cx88_ir_close;
453 dev->scanmask = hardware_mask;
453 454
454 if (ir->sampling) { 455 if (ir->sampling) {
455 ir_type = IR_TYPE_ALL; 456 dev->driver_type = RC_DRIVER_IR_RAW;
456 ir->props.driver_type = RC_DRIVER_IR_RAW; 457 dev->timeout = 10 * 1000 * 1000; /* 10 ms */
457 ir->props.timeout = 10 * 1000 * 1000; /* 10 ms */ 458 } else {
458 } else 459 dev->driver_type = RC_DRIVER_SCANCODE;
459 ir->props.driver_type = RC_DRIVER_SCANCODE; 460 dev->allowed_protos = ir_type;
460 461 }
461 ir->props.priv = core; 462
462 ir->props.open = cx88_ir_open; 463 ir->core = core;
463 ir->props.close = cx88_ir_close; 464 core->ir = ir;
464 ir->props.scanmask = hardware_mask;
465 ir->props.allowed_protos = ir_type;
466 465
467 /* all done */ 466 /* all done */
468 err = ir_input_register(ir->input, ir_codes, &ir->props, MODULE_NAME); 467 err = rc_register_device(dev);
469 if (err) 468 if (err)
470 goto err_out_free; 469 goto err_out_free;
471 470
472 return 0; 471 return 0;
473 472
474 err_out_free: 473err_out_free:
474 rc_free_device(dev);
475 core->ir = NULL; 475 core->ir = NULL;
476 kfree(ir); 476 kfree(ir);
477 return err; 477 return err;
@@ -486,7 +486,7 @@ int cx88_ir_fini(struct cx88_core *core)
486 return 0; 486 return 0;
487 487
488 cx88_ir_stop(core); 488 cx88_ir_stop(core);
489 ir_input_unregister(ir->input); 489 rc_unregister_device(ir->dev);
490 kfree(ir); 490 kfree(ir);
491 491
492 /* done */ 492 /* done */
@@ -502,7 +502,6 @@ void cx88_ir_irq(struct cx88_core *core)
502 u32 samples; 502 u32 samples;
503 unsigned todo, bits; 503 unsigned todo, bits;
504 struct ir_raw_event ev; 504 struct ir_raw_event ev;
505 struct ir_input_dev *irdev;
506 505
507 if (!ir || !ir->sampling) 506 if (!ir || !ir->sampling)
508 return; 507 return;
@@ -513,9 +512,8 @@ void cx88_ir_irq(struct cx88_core *core)
513 * represents a pulse. 512 * represents a pulse.
514 */ 513 */
515 samples = cx_read(MO_SAMPLE_IO); 514 samples = cx_read(MO_SAMPLE_IO);
516 irdev = input_get_drvdata(ir->input);
517 515
518 if (samples == 0xff && irdev->idle) 516 if (samples == 0xff && ir->dev->idle)
519 return; 517 return;
520 518
521 init_ir_raw_event(&ev); 519 init_ir_raw_event(&ev);
@@ -523,10 +521,10 @@ void cx88_ir_irq(struct cx88_core *core)
523 ev.pulse = samples & 0x80000000 ? false : true; 521 ev.pulse = samples & 0x80000000 ? false : true;
524 bits = min(todo, 32U - fls(ev.pulse ? samples : ~samples)); 522 bits = min(todo, 32U - fls(ev.pulse ? samples : ~samples));
525 ev.duration = (bits * NSEC_PER_SEC) / (1000 * ir_samplerate); 523 ev.duration = (bits * NSEC_PER_SEC) / (1000 * ir_samplerate);
526 ir_raw_event_store_with_filter(ir->input, &ev); 524 ir_raw_event_store_with_filter(ir->dev, &ev);
527 samples <<= bits; 525 samples <<= bits;
528 } 526 }
529 ir_raw_event_handle(ir->input); 527 ir_raw_event_handle(ir->dev);
530} 528}
531 529
532void cx88_i2c_init_ir(struct cx88_core *core) 530void cx88_i2c_init_ir(struct cx88_core *core)
diff --git a/drivers/media/video/em28xx/em28xx-input.c b/drivers/media/video/em28xx/em28xx-input.c
index 6759cd5570d..b7d3999f041 100644
--- a/drivers/media/video/em28xx/em28xx-input.c
+++ b/drivers/media/video/em28xx/em28xx-input.c
@@ -25,7 +25,6 @@
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/input.h>
29#include <linux/usb.h> 28#include <linux/usb.h>
30#include <linux/slab.h> 29#include <linux/slab.h>
31 30
@@ -64,7 +63,7 @@ struct em28xx_ir_poll_result {
64 63
65struct em28xx_IR { 64struct em28xx_IR {
66 struct em28xx *dev; 65 struct em28xx *dev;
67 struct input_dev *input; 66 struct rc_dev *rc;
68 char name[32]; 67 char name[32];
69 char phys[32]; 68 char phys[32];
70 69
@@ -75,10 +74,6 @@ struct em28xx_IR {
75 unsigned int last_readcount; 74 unsigned int last_readcount;
76 75
77 int (*get_key)(struct em28xx_IR *, struct em28xx_ir_poll_result *); 76 int (*get_key)(struct em28xx_IR *, struct em28xx_ir_poll_result *);
78
79 /* IR device properties */
80
81 struct ir_dev_props props;
82}; 77};
83 78
84/********************************************************** 79/**********************************************************
@@ -302,12 +297,12 @@ static void em28xx_ir_handle_key(struct em28xx_IR *ir)
302 poll_result.toggle_bit, poll_result.read_count, 297 poll_result.toggle_bit, poll_result.read_count,
303 poll_result.rc_address, poll_result.rc_data[0]); 298 poll_result.rc_address, poll_result.rc_data[0]);
304 if (ir->full_code) 299 if (ir->full_code)
305 ir_keydown(ir->input, 300 ir_keydown(ir->rc,
306 poll_result.rc_address << 8 | 301 poll_result.rc_address << 8 |
307 poll_result.rc_data[0], 302 poll_result.rc_data[0],
308 poll_result.toggle_bit); 303 poll_result.toggle_bit);
309 else 304 else
310 ir_keydown(ir->input, 305 ir_keydown(ir->rc,
311 poll_result.rc_data[0], 306 poll_result.rc_data[0],
312 poll_result.toggle_bit); 307 poll_result.toggle_bit);
313 308
@@ -331,9 +326,9 @@ static void em28xx_ir_work(struct work_struct *work)
331 schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling)); 326 schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling));
332} 327}
333 328
334static int em28xx_ir_start(void *priv) 329static int em28xx_ir_start(struct rc_dev *rc)
335{ 330{
336 struct em28xx_IR *ir = priv; 331 struct em28xx_IR *ir = rc->priv;
337 332
338 INIT_DELAYED_WORK(&ir->work, em28xx_ir_work); 333 INIT_DELAYED_WORK(&ir->work, em28xx_ir_work);
339 schedule_delayed_work(&ir->work, 0); 334 schedule_delayed_work(&ir->work, 0);
@@ -341,17 +336,17 @@ static int em28xx_ir_start(void *priv)
341 return 0; 336 return 0;
342} 337}
343 338
344static void em28xx_ir_stop(void *priv) 339static void em28xx_ir_stop(struct rc_dev *rc)
345{ 340{
346 struct em28xx_IR *ir = priv; 341 struct em28xx_IR *ir = rc->priv;
347 342
348 cancel_delayed_work_sync(&ir->work); 343 cancel_delayed_work_sync(&ir->work);
349} 344}
350 345
351int em28xx_ir_change_protocol(void *priv, u64 ir_type) 346int em28xx_ir_change_protocol(struct rc_dev *rc_dev, u64 ir_type)
352{ 347{
353 int rc = 0; 348 int rc = 0;
354 struct em28xx_IR *ir = priv; 349 struct em28xx_IR *ir = rc_dev->priv;
355 struct em28xx *dev = ir->dev; 350 struct em28xx *dev = ir->dev;
356 u8 ir_config = EM2874_IR_RC5; 351 u8 ir_config = EM2874_IR_RC5;
357 352
@@ -391,7 +386,7 @@ int em28xx_ir_change_protocol(void *priv, u64 ir_type)
391int em28xx_ir_init(struct em28xx *dev) 386int em28xx_ir_init(struct em28xx *dev)
392{ 387{
393 struct em28xx_IR *ir; 388 struct em28xx_IR *ir;
394 struct input_dev *input_dev; 389 struct rc_dev *rc;
395 int err = -ENOMEM; 390 int err = -ENOMEM;
396 391
397 if (dev->board.ir_codes == NULL) { 392 if (dev->board.ir_codes == NULL) {
@@ -400,28 +395,27 @@ int em28xx_ir_init(struct em28xx *dev)
400 } 395 }
401 396
402 ir = kzalloc(sizeof(*ir), GFP_KERNEL); 397 ir = kzalloc(sizeof(*ir), GFP_KERNEL);
403 input_dev = input_allocate_device(); 398 rc = rc_allocate_device();
404 if (!ir || !input_dev) 399 if (!ir || !rc)
405 goto err_out_free; 400 goto err_out_free;
406 401
407 /* record handles to ourself */ 402 /* record handles to ourself */
408 ir->dev = dev; 403 ir->dev = dev;
409 dev->ir = ir; 404 dev->ir = ir;
410 405 ir->rc = rc;
411 ir->input = input_dev;
412 406
413 /* 407 /*
414 * em2874 supports more protocols. For now, let's just announce 408 * em2874 supports more protocols. For now, let's just announce
415 * the two protocols that were already tested 409 * the two protocols that were already tested
416 */ 410 */
417 ir->props.allowed_protos = IR_TYPE_RC5 | IR_TYPE_NEC; 411 rc->allowed_protos = IR_TYPE_RC5 | IR_TYPE_NEC;
418 ir->props.priv = ir; 412 rc->priv = ir;
419 ir->props.change_protocol = em28xx_ir_change_protocol; 413 rc->change_protocol = em28xx_ir_change_protocol;
420 ir->props.open = em28xx_ir_start; 414 rc->open = em28xx_ir_start;
421 ir->props.close = em28xx_ir_stop; 415 rc->close = em28xx_ir_stop;
422 416
423 /* By default, keep protocol field untouched */ 417 /* By default, keep protocol field untouched */
424 err = em28xx_ir_change_protocol(ir, IR_TYPE_UNKNOWN); 418 err = em28xx_ir_change_protocol(rc, IR_TYPE_UNKNOWN);
425 if (err) 419 if (err)
426 goto err_out_free; 420 goto err_out_free;
427 421
@@ -435,27 +429,27 @@ int em28xx_ir_init(struct em28xx *dev)
435 usb_make_path(dev->udev, ir->phys, sizeof(ir->phys)); 429 usb_make_path(dev->udev, ir->phys, sizeof(ir->phys));
436 strlcat(ir->phys, "/input0", sizeof(ir->phys)); 430 strlcat(ir->phys, "/input0", sizeof(ir->phys));
437 431
438 input_dev->name = ir->name; 432 rc->input_name = ir->name;
439 input_dev->phys = ir->phys; 433 rc->input_phys = ir->phys;
440 input_dev->id.bustype = BUS_USB; 434 rc->input_id.bustype = BUS_USB;
441 input_dev->id.version = 1; 435 rc->input_id.version = 1;
442 input_dev->id.vendor = le16_to_cpu(dev->udev->descriptor.idVendor); 436 rc->input_id.vendor = le16_to_cpu(dev->udev->descriptor.idVendor);
443 input_dev->id.product = le16_to_cpu(dev->udev->descriptor.idProduct); 437 rc->input_id.product = le16_to_cpu(dev->udev->descriptor.idProduct);
444 438 rc->dev.parent = &dev->udev->dev;
445 input_dev->dev.parent = &dev->udev->dev; 439 rc->map_name = dev->board.ir_codes;
446 440 rc->driver_name = MODULE_NAME;
447
448 441
449 /* all done */ 442 /* all done */
450 err = ir_input_register(ir->input, dev->board.ir_codes, 443 err = rc_register_device(rc);
451 &ir->props, MODULE_NAME);
452 if (err) 444 if (err)
453 goto err_out_stop; 445 goto err_out_stop;
454 446
455 return 0; 447 return 0;
448
456 err_out_stop: 449 err_out_stop:
457 dev->ir = NULL; 450 dev->ir = NULL;
458 err_out_free: 451 err_out_free:
452 rc_free_device(rc);
459 kfree(ir); 453 kfree(ir);
460 return err; 454 return err;
461} 455}
@@ -468,8 +462,8 @@ int em28xx_ir_fini(struct em28xx *dev)
468 if (!ir) 462 if (!ir)
469 return 0; 463 return 0;
470 464
471 em28xx_ir_stop(ir); 465 em28xx_ir_stop(ir->rc);
472 ir_input_unregister(ir->input); 466 rc_unregister_device(ir->rc);
473 kfree(ir); 467 kfree(ir);
474 468
475 /* done */ 469 /* done */
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index a78883a6e0e..83b59a19523 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -252,7 +252,7 @@ static void ir_key_poll(struct IR_i2c *ir)
252 } 252 }
253 253
254 if (rc) 254 if (rc)
255 ir_keydown(ir->input, ir_key, 0); 255 ir_keydown(ir->rc, ir_key, 0);
256} 256}
257 257
258static void ir_work(struct work_struct *work) 258static void ir_work(struct work_struct *work)
@@ -271,20 +271,20 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
271 const char *name = NULL; 271 const char *name = NULL;
272 u64 ir_type = IR_TYPE_UNKNOWN; 272 u64 ir_type = IR_TYPE_UNKNOWN;
273 struct IR_i2c *ir; 273 struct IR_i2c *ir;
274 struct input_dev *input_dev; 274 struct rc_dev *rc;
275 struct i2c_adapter *adap = client->adapter; 275 struct i2c_adapter *adap = client->adapter;
276 unsigned short addr = client->addr; 276 unsigned short addr = client->addr;
277 int err; 277 int err;
278 278
279 ir = kzalloc(sizeof(struct IR_i2c),GFP_KERNEL); 279 ir = kzalloc(sizeof(struct IR_i2c),GFP_KERNEL);
280 input_dev = input_allocate_device(); 280 rc = rc_allocate_device();
281 if (!ir || !input_dev) { 281 if (!ir || !rc) {
282 err = -ENOMEM; 282 err = -ENOMEM;
283 goto err_out_free; 283 goto err_out_free;
284 } 284 }
285 285
286 ir->c = client; 286 ir->c = client;
287 ir->input = input_dev; 287 ir->rc = rc;
288 ir->polling_interval = DEFAULT_POLLING_INTERVAL; 288 ir->polling_interval = DEFAULT_POLLING_INTERVAL;
289 i2c_set_clientdata(client, ir); 289 i2c_set_clientdata(client, ir);
290 290
@@ -383,16 +383,18 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
383 dev_name(&client->dev)); 383 dev_name(&client->dev));
384 384
385 /* init + register input device */ 385 /* init + register input device */
386 input_dev->id.bustype = BUS_I2C; 386 rc->input_id.bustype = BUS_I2C;
387 input_dev->name = ir->name; 387 rc->input_name = ir->name;
388 input_dev->phys = ir->phys; 388 rc->input_phys = ir->phys;
389 rc->map_name = ir->ir_codes;
390 rc->driver_name = MODULE_NAME;
389 391
390 err = ir_input_register(ir->input, ir->ir_codes, NULL, MODULE_NAME); 392 err = rc_register_device(rc);
391 if (err) 393 if (err)
392 goto err_out_free; 394 goto err_out_free;
393 395
394 printk(MODULE_NAME ": %s detected at %s [%s]\n", 396 printk(MODULE_NAME ": %s detected at %s [%s]\n",
395 ir->input->name, ir->input->phys, adap->name); 397 ir->name, ir->phys, adap->name);
396 398
397 /* start polling via eventd */ 399 /* start polling via eventd */
398 INIT_DELAYED_WORK(&ir->work, ir_work); 400 INIT_DELAYED_WORK(&ir->work, ir_work);
@@ -401,6 +403,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
401 return 0; 403 return 0;
402 404
403 err_out_free: 405 err_out_free:
406 rc_free_device(rc);
404 kfree(ir); 407 kfree(ir);
405 return err; 408 return err;
406} 409}
@@ -413,7 +416,7 @@ static int ir_remove(struct i2c_client *client)
413 cancel_delayed_work_sync(&ir->work); 416 cancel_delayed_work_sync(&ir->work);
414 417
415 /* unregister device */ 418 /* unregister device */
416 ir_input_unregister(ir->input); 419 rc_unregister_device(ir->rc);
417 420
418 /* free memory */ 421 /* free memory */
419 kfree(ir); 422 kfree(ir);
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index 3e37593a328..fbb2ff17100 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -22,7 +22,6 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/input.h>
26#include <linux/slab.h> 25#include <linux/slab.h>
27 26
28#include "saa7134-reg.h" 27#include "saa7134-reg.h"
@@ -45,14 +44,6 @@ MODULE_PARM_DESC(pinnacle_remote, "Specify Pinnacle PCTV remote: 0=coloured, 1=g
45static int ir_rc5_remote_gap = 885; 44static int ir_rc5_remote_gap = 885;
46module_param(ir_rc5_remote_gap, int, 0644); 45module_param(ir_rc5_remote_gap, int, 0644);
47 46
48static int repeat_delay = 500;
49module_param(repeat_delay, int, 0644);
50MODULE_PARM_DESC(repeat_delay, "delay before key repeat started");
51static int repeat_period = 33;
52module_param(repeat_period, int, 0644);
53MODULE_PARM_DESC(repeat_period, "repeat period between "
54 "keypresses when key is down");
55
56static unsigned int disable_other_ir; 47static unsigned int disable_other_ir;
57module_param(disable_other_ir, int, 0644); 48module_param(disable_other_ir, int, 0644);
58MODULE_PARM_DESC(disable_other_ir, "disable full codes of " 49MODULE_PARM_DESC(disable_other_ir, "disable full codes of "
@@ -523,17 +514,17 @@ void saa7134_ir_stop(struct saa7134_dev *dev)
523 __saa7134_ir_stop(dev); 514 __saa7134_ir_stop(dev);
524} 515}
525 516
526static int saa7134_ir_open(void *priv) 517static int saa7134_ir_open(struct rc_dev *rc)
527{ 518{
528 struct saa7134_dev *dev = priv; 519 struct saa7134_dev *dev = rc->priv;
529 520
530 dev->remote->users++; 521 dev->remote->users++;
531 return __saa7134_ir_start(dev); 522 return __saa7134_ir_start(dev);
532} 523}
533 524
534static void saa7134_ir_close(void *priv) 525static void saa7134_ir_close(struct rc_dev *rc)
535{ 526{
536 struct saa7134_dev *dev = priv; 527 struct saa7134_dev *dev = rc->priv;
537 528
538 dev->remote->users--; 529 dev->remote->users--;
539 if (!dev->remote->users) 530 if (!dev->remote->users)
@@ -541,9 +532,9 @@ static void saa7134_ir_close(void *priv)
541} 532}
542 533
543 534
544static int saa7134_ir_change_protocol(void *priv, u64 ir_type) 535static int saa7134_ir_change_protocol(struct rc_dev *rc, u64 ir_type)
545{ 536{
546 struct saa7134_dev *dev = priv; 537 struct saa7134_dev *dev = rc->priv;
547 struct card_ir *ir = dev->remote; 538 struct card_ir *ir = dev->remote;
548 u32 nec_gpio, rc5_gpio; 539 u32 nec_gpio, rc5_gpio;
549 540
@@ -577,7 +568,7 @@ static int saa7134_ir_change_protocol(void *priv, u64 ir_type)
577int saa7134_input_init1(struct saa7134_dev *dev) 568int saa7134_input_init1(struct saa7134_dev *dev)
578{ 569{
579 struct card_ir *ir; 570 struct card_ir *ir;
580 struct input_dev *input_dev; 571 struct rc_dev *rc;
581 char *ir_codes = NULL; 572 char *ir_codes = NULL;
582 u32 mask_keycode = 0; 573 u32 mask_keycode = 0;
583 u32 mask_keydown = 0; 574 u32 mask_keydown = 0;
@@ -822,13 +813,13 @@ int saa7134_input_init1(struct saa7134_dev *dev)
822 } 813 }
823 814
824 ir = kzalloc(sizeof(*ir), GFP_KERNEL); 815 ir = kzalloc(sizeof(*ir), GFP_KERNEL);
825 input_dev = input_allocate_device(); 816 rc = rc_allocate_device();
826 if (!ir || !input_dev) { 817 if (!ir || !rc) {
827 err = -ENOMEM; 818 err = -ENOMEM;
828 goto err_out_free; 819 goto err_out_free;
829 } 820 }
830 821
831 ir->dev = input_dev; 822 ir->dev = rc;
832 dev->remote = ir; 823 dev->remote = ir;
833 824
834 ir->running = 0; 825 ir->running = 0;
@@ -848,43 +839,40 @@ int saa7134_input_init1(struct saa7134_dev *dev)
848 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", 839 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
849 pci_name(dev->pci)); 840 pci_name(dev->pci));
850 841
851 842 rc->priv = dev;
852 ir->props.priv = dev; 843 rc->open = saa7134_ir_open;
853 ir->props.open = saa7134_ir_open; 844 rc->close = saa7134_ir_close;
854 ir->props.close = saa7134_ir_close;
855
856 if (raw_decode) 845 if (raw_decode)
857 ir->props.driver_type = RC_DRIVER_IR_RAW; 846 rc->driver_type = RC_DRIVER_IR_RAW;
858 847
859 if (!raw_decode && allow_protocol_change) { 848 if (!raw_decode && allow_protocol_change) {
860 ir->props.allowed_protos = IR_TYPE_RC5 | IR_TYPE_NEC; 849 rc->allowed_protos = IR_TYPE_RC5 | IR_TYPE_NEC;
861 ir->props.change_protocol = saa7134_ir_change_protocol; 850 rc->change_protocol = saa7134_ir_change_protocol;
862 } 851 }
863 852
864 input_dev->name = ir->name; 853 rc->input_name = ir->name;
865 input_dev->phys = ir->phys; 854 rc->input_phys = ir->phys;
866 input_dev->id.bustype = BUS_PCI; 855 rc->input_id.bustype = BUS_PCI;
867 input_dev->id.version = 1; 856 rc->input_id.version = 1;
868 if (dev->pci->subsystem_vendor) { 857 if (dev->pci->subsystem_vendor) {
869 input_dev->id.vendor = dev->pci->subsystem_vendor; 858 rc->input_id.vendor = dev->pci->subsystem_vendor;
870 input_dev->id.product = dev->pci->subsystem_device; 859 rc->input_id.product = dev->pci->subsystem_device;
871 } else { 860 } else {
872 input_dev->id.vendor = dev->pci->vendor; 861 rc->input_id.vendor = dev->pci->vendor;
873 input_dev->id.product = dev->pci->device; 862 rc->input_id.product = dev->pci->device;
874 } 863 }
875 input_dev->dev.parent = &dev->pci->dev; 864 rc->dev.parent = &dev->pci->dev;
865 rc->map_name = ir_codes;
866 rc->driver_name = MODULE_NAME;
876 867
877 err = ir_input_register(ir->dev, ir_codes, &ir->props, MODULE_NAME); 868 err = rc_register_device(rc);
878 if (err) 869 if (err)
879 goto err_out_free; 870 goto err_out_free;
880 871
881 /* the remote isn't as bouncy as a keyboard */
882 ir->dev->rep[REP_DELAY] = repeat_delay;
883 ir->dev->rep[REP_PERIOD] = repeat_period;
884
885 return 0; 872 return 0;
886 873
887err_out_free: 874err_out_free:
875 rc_free_device(rc);
888 dev->remote = NULL; 876 dev->remote = NULL;
889 kfree(ir); 877 kfree(ir);
890 return err; 878 return err;
@@ -896,7 +884,7 @@ void saa7134_input_fini(struct saa7134_dev *dev)
896 return; 884 return;
897 885
898 saa7134_ir_stop(dev); 886 saa7134_ir_stop(dev);
899 ir_input_unregister(dev->remote->dev); 887 rc_unregister_device(dev->remote->dev);
900 kfree(dev->remote); 888 kfree(dev->remote);
901 dev->remote = NULL; 889 dev->remote = NULL;
902} 890}
diff --git a/drivers/staging/tm6000/tm6000-input.c b/drivers/staging/tm6000/tm6000-input.c
index 3e74884da25..3517d20c131 100644
--- a/drivers/staging/tm6000/tm6000-input.c
+++ b/drivers/staging/tm6000/tm6000-input.c
@@ -50,7 +50,7 @@ struct tm6000_ir_poll_result {
50 50
51struct tm6000_IR { 51struct tm6000_IR {
52 struct tm6000_core *dev; 52 struct tm6000_core *dev;
53 struct ir_input_dev *input; 53 struct rc_dev *rc;
54 char name[32]; 54 char name[32];
55 char phys[32]; 55 char phys[32];
56 56
@@ -66,7 +66,6 @@ struct tm6000_IR {
66 66
67 /* IR device properties */ 67 /* IR device properties */
68 u64 ir_type; 68 u64 ir_type;
69 struct ir_dev_props props;
70}; 69};
71 70
72 71
@@ -200,7 +199,7 @@ static void tm6000_ir_handle_key(struct tm6000_IR *ir)
200 dprintk("ir->get_key result data=%04x\n", poll_result.rc_data); 199 dprintk("ir->get_key result data=%04x\n", poll_result.rc_data);
201 200
202 if (ir->key) { 201 if (ir->key) {
203 ir_keydown(ir->input->input_dev, poll_result.rc_data, 0); 202 ir_keydown(ir->rc, poll_result.rc_data, 0);
204 ir->key = 0; 203 ir->key = 0;
205 } 204 }
206 return; 205 return;
@@ -214,9 +213,9 @@ static void tm6000_ir_work(struct work_struct *work)
214 schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling)); 213 schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling));
215} 214}
216 215
217static int tm6000_ir_start(void *priv) 216static int tm6000_ir_start(struct rc_dev *rc)
218{ 217{
219 struct tm6000_IR *ir = priv; 218 struct tm6000_IR *ir = rc->priv;
220 219
221 INIT_DELAYED_WORK(&ir->work, tm6000_ir_work); 220 INIT_DELAYED_WORK(&ir->work, tm6000_ir_work);
222 schedule_delayed_work(&ir->work, 0); 221 schedule_delayed_work(&ir->work, 0);
@@ -224,16 +223,16 @@ static int tm6000_ir_start(void *priv)
224 return 0; 223 return 0;
225} 224}
226 225
227static void tm6000_ir_stop(void *priv) 226static void tm6000_ir_stop(struct rc_dev *rc)
228{ 227{
229 struct tm6000_IR *ir = priv; 228 struct tm6000_IR *ir = rc->priv;
230 229
231 cancel_delayed_work_sync(&ir->work); 230 cancel_delayed_work_sync(&ir->work);
232} 231}
233 232
234int tm6000_ir_change_protocol(void *priv, u64 ir_type) 233int tm6000_ir_change_protocol(struct rc_dev *rc, u64 ir_type)
235{ 234{
236 struct tm6000_IR *ir = priv; 235 struct tm6000_IR *ir = rc->priv;
237 236
238 ir->get_key = default_polling_getkey; 237 ir->get_key = default_polling_getkey;
239 238
@@ -245,9 +244,9 @@ int tm6000_ir_change_protocol(void *priv, u64 ir_type)
245int tm6000_ir_init(struct tm6000_core *dev) 244int tm6000_ir_init(struct tm6000_core *dev)
246{ 245{
247 struct tm6000_IR *ir; 246 struct tm6000_IR *ir;
248 struct ir_input_dev *ir_input_dev; 247 struct rc_dev *rc;
249 int err = -ENOMEM; 248 int err = -ENOMEM;
250 int pipe, size, rc; 249 int pipe, size;
251 250
252 if (!enable_ir) 251 if (!enable_ir)
253 return -ENODEV; 252 return -ENODEV;
@@ -259,24 +258,22 @@ int tm6000_ir_init(struct tm6000_core *dev)
259 return 0; 258 return 0;
260 259
261 ir = kzalloc(sizeof(*ir), GFP_KERNEL); 260 ir = kzalloc(sizeof(*ir), GFP_KERNEL);
262 ir_input_dev = kzalloc(sizeof(*ir_input_dev), GFP_KERNEL); 261 rc = rc_allocate_device();
263 ir_input_dev->input_dev = input_allocate_device(); 262 if (!ir | !rc)
264 if (!ir || !ir_input_dev || !ir_input_dev->input_dev) 263 goto out;
265 goto err_out_free;
266 264
267 /* record handles to ourself */ 265 /* record handles to ourself */
268 ir->dev = dev; 266 ir->dev = dev;
269 dev->ir = ir; 267 dev->ir = ir;
270 268 ir->rc = rc;
271 ir->input = ir_input_dev;
272 269
273 /* input einrichten */ 270 /* input einrichten */
274 ir->props.allowed_protos = IR_TYPE_RC5 | IR_TYPE_NEC; 271 rc->allowed_protos = IR_TYPE_RC5 | IR_TYPE_NEC;
275 ir->props.priv = ir; 272 rc->priv = ir;
276 ir->props.change_protocol = tm6000_ir_change_protocol; 273 rc->change_protocol = tm6000_ir_change_protocol;
277 ir->props.open = tm6000_ir_start; 274 rc->open = tm6000_ir_start;
278 ir->props.close = tm6000_ir_stop; 275 rc->close = tm6000_ir_stop;
279 ir->props.driver_type = RC_DRIVER_SCANCODE; 276 rc->driver_type = RC_DRIVER_SCANCODE;
280 277
281 ir->polling = 50; 278 ir->polling = 50;
282 279
@@ -286,16 +283,17 @@ int tm6000_ir_init(struct tm6000_core *dev)
286 usb_make_path(dev->udev, ir->phys, sizeof(ir->phys)); 283 usb_make_path(dev->udev, ir->phys, sizeof(ir->phys));
287 strlcat(ir->phys, "/input0", sizeof(ir->phys)); 284 strlcat(ir->phys, "/input0", sizeof(ir->phys));
288 285
289 tm6000_ir_change_protocol(ir, IR_TYPE_UNKNOWN); 286 tm6000_ir_change_protocol(rc, IR_TYPE_UNKNOWN);
290
291 ir_input_dev->input_dev->name = ir->name;
292 ir_input_dev->input_dev->phys = ir->phys;
293 ir_input_dev->input_dev->id.bustype = BUS_USB;
294 ir_input_dev->input_dev->id.version = 1;
295 ir_input_dev->input_dev->id.vendor = le16_to_cpu(dev->udev->descriptor.idVendor);
296 ir_input_dev->input_dev->id.product = le16_to_cpu(dev->udev->descriptor.idProduct);
297 287
298 ir_input_dev->input_dev->dev.parent = &dev->udev->dev; 288 rc->input_name = ir->name;
289 rc->input_phys = ir->phys;
290 rc->input_id.bustype = BUS_USB;
291 rc->input_id.version = 1;
292 rc->input_id.vendor = le16_to_cpu(dev->udev->descriptor.idVendor);
293 rc->input_id.product = le16_to_cpu(dev->udev->descriptor.idProduct);
294 rc->map_name = dev->ir_codes;
295 rc->driver_name = "tm6000";
296 rc->dev.parent = &dev->udev->dev;
299 297
300 if (&dev->int_in) { 298 if (&dev->int_in) {
301 dprintk("IR over int\n"); 299 dprintk("IR over int\n");
@@ -312,35 +310,32 @@ int tm6000_ir_init(struct tm6000_core *dev)
312 ir->int_urb->transfer_buffer = kzalloc(size, GFP_KERNEL); 310 ir->int_urb->transfer_buffer = kzalloc(size, GFP_KERNEL);
313 if (ir->int_urb->transfer_buffer == NULL) { 311 if (ir->int_urb->transfer_buffer == NULL) {
314 usb_free_urb(ir->int_urb); 312 usb_free_urb(ir->int_urb);
315 goto err_out_stop; 313 goto out;
316 } 314 }
317 dprintk("int interval: %d\n", dev->int_in.endp->desc.bInterval); 315 dprintk("int interval: %d\n", dev->int_in.endp->desc.bInterval);
318 usb_fill_int_urb(ir->int_urb, dev->udev, pipe, 316 usb_fill_int_urb(ir->int_urb, dev->udev, pipe,
319 ir->int_urb->transfer_buffer, size, 317 ir->int_urb->transfer_buffer, size,
320 tm6000_ir_urb_received, dev, 318 tm6000_ir_urb_received, dev,
321 dev->int_in.endp->desc.bInterval); 319 dev->int_in.endp->desc.bInterval);
322 rc = usb_submit_urb(ir->int_urb, GFP_KERNEL); 320 err = usb_submit_urb(ir->int_urb, GFP_KERNEL);
323 if (rc) { 321 if (err) {
324 kfree(ir->int_urb->transfer_buffer); 322 kfree(ir->int_urb->transfer_buffer);
325 usb_free_urb(ir->int_urb); 323 usb_free_urb(ir->int_urb);
326 err = rc; 324 goto out;
327 goto err_out_stop;
328 } 325 }
329 ir->urb_data = kzalloc(size, GFP_KERNEL); 326 ir->urb_data = kzalloc(size, GFP_KERNEL);
330 } 327 }
331 328
332 /* ir register */ 329 /* ir register */
333 err = ir_input_register(ir->input->input_dev, dev->ir_codes, 330 err = rc_register_device(rc);
334 &ir->props, "tm6000");
335 if (err) 331 if (err)
336 goto err_out_stop; 332 goto out;
337 333
338 return 0; 334 return 0;
339 335
340err_out_stop: 336out:
341 dev->ir = NULL; 337 dev->ir = NULL;
342err_out_free: 338 rc_free_device(rc);
343 kfree(ir_input_dev);
344 kfree(ir); 339 kfree(ir);
345 return err; 340 return err;
346} 341}
@@ -354,7 +349,7 @@ int tm6000_ir_fini(struct tm6000_core *dev)
354 if (!ir) 349 if (!ir)
355 return 0; 350 return 0;
356 351
357 ir_input_unregister(ir->input->input_dev); 352 rc_unregister_device(ir->rc);
358 353
359 if (ir->int_urb) { 354 if (ir->int_urb) {
360 usb_kill_urb(ir->int_urb); 355 usb_kill_urb(ir->int_urb);
@@ -365,8 +360,6 @@ int tm6000_ir_fini(struct tm6000_core *dev)
365 ir->urb_data = NULL; 360 ir->urb_data = NULL;
366 } 361 }
367 362
368 kfree(ir->input);
369 ir->input = NULL;
370 kfree(ir); 363 kfree(ir);
371 dev->ir = NULL; 364 dev->ir = NULL;
372 365
diff --git a/include/media/ir-common.h b/include/media/ir-common.h
index d1ae869f962..41fefd9816e 100644
--- a/include/media/ir-common.h
+++ b/include/media/ir-common.h
@@ -36,12 +36,11 @@
36/* this was saa7134_ir and bttv_ir, moved here for 36/* this was saa7134_ir and bttv_ir, moved here for
37 * rc5 decoding. */ 37 * rc5 decoding. */
38struct card_ir { 38struct card_ir {
39 struct input_dev *dev; 39 struct rc_dev *dev;
40 char name[32]; 40 char name[32];
41 char phys[32]; 41 char phys[32];
42 int users; 42 int users;
43 u32 running:1; 43 u32 running:1;
44 struct ir_dev_props props;
45 44
46 /* Usual gpio signalling */ 45 /* Usual gpio signalling */
47 u32 mask_keycode; 46 u32 mask_keycode;
diff --git a/include/media/ir-core.h b/include/media/ir-core.h
index d41502d9919..c5909981b07 100644
--- a/include/media/ir-core.h
+++ b/include/media/ir-core.h
@@ -32,21 +32,38 @@ enum rc_driver_type {
32}; 32};
33 33
34/** 34/**
35 * struct ir_dev_props - Allow caller drivers to set special properties 35 * struct rc_dev - represents a remote control device
36 * @driver_type: specifies if the driver or hardware have already a decoder, 36 * @dev: driver model's view of this device
37 * or if it needs to use the IR raw event decoders to produce a scancode 37 * @input_name: name of the input child device
38 * @input_phys: physical path to the input child device
39 * @input_id: id of the input child device (struct input_id)
40 * @driver_name: name of the hardware driver which registered this device
41 * @map_name: name of the default keymap
42 * @rc_tab: current scan/key table
43 * @devno: unique remote control device number
44 * @raw: additional data for raw pulse/space devices
45 * @input_dev: the input child device used to communicate events to userspace
46 * @driver_type: specifies if protocol decoding is done in hardware or software
47 * @idle: used to keep track of RX state
38 * @allowed_protos: bitmask with the supported IR_TYPE_* protocols 48 * @allowed_protos: bitmask with the supported IR_TYPE_* protocols
39 * @scanmask: some hardware decoders are not capable of providing the full 49 * @scanmask: some hardware decoders are not capable of providing the full
40 * scancode to the application. As this is a hardware limit, we can't do 50 * scancode to the application. As this is a hardware limit, we can't do
41 * anything with it. Yet, as the same keycode table can be used with other 51 * anything with it. Yet, as the same keycode table can be used with other
42 * devices, a mask is provided to allow its usage. Drivers should generally 52 * devices, a mask is provided to allow its usage. Drivers should generally
43 * leave this field in blank 53 * leave this field in blank
54 * @priv: driver-specific data
55 * @keylock: protects the remaining members of the struct
56 * @keypressed: whether a key is currently pressed
57 * @keyup_jiffies: time (in jiffies) when the current keypress should be released
58 * @timer_keyup: timer for releasing a keypress
59 * @last_keycode: keycode of last keypress
60 * @last_scancode: scancode of last keypress
61 * @last_toggle: toggle value of last command
44 * @timeout: optional time after which device stops sending data 62 * @timeout: optional time after which device stops sending data
45 * @min_timeout: minimum timeout supported by device 63 * @min_timeout: minimum timeout supported by device
46 * @max_timeout: maximum timeout supported by device 64 * @max_timeout: maximum timeout supported by device
47 * @rx_resolution : resolution (in ns) of input sampler 65 * @rx_resolution : resolution (in ns) of input sampler
48 * @tx_resolution: resolution (in ns) of output sampler 66 * @tx_resolution: resolution (in ns) of output sampler
49 * @priv: driver-specific data, to be used on the callbacks
50 * @change_protocol: allow changing the protocol used on hardware decoders 67 * @change_protocol: allow changing the protocol used on hardware decoders
51 * @open: callback to allow drivers to enable polling/irq when IR input device 68 * @open: callback to allow drivers to enable polling/irq when IR input device
52 * is opened. 69 * is opened.
@@ -57,55 +74,50 @@ enum rc_driver_type {
57 * @s_tx_duty_cycle: set transmit duty cycle (0% - 100%) 74 * @s_tx_duty_cycle: set transmit duty cycle (0% - 100%)
58 * @s_rx_carrier: inform driver about carrier it is expected to handle 75 * @s_rx_carrier: inform driver about carrier it is expected to handle
59 * @tx_ir: transmit IR 76 * @tx_ir: transmit IR
60 * @s_idle: optional: enable/disable hardware idle mode, upon which, 77 * @s_idle: enable/disable hardware idle mode, upon which,
61 device doesn't interrupt host until it sees IR pulses 78 * device doesn't interrupt host until it sees IR pulses
62 * @s_learning_mode: enable wide band receiver used for learning 79 * @s_learning_mode: enable wide band receiver used for learning
63 * @s_carrier_report: enable carrier reports 80 * @s_carrier_report: enable carrier reports
64 */ 81 */
65struct ir_dev_props { 82struct rc_dev {
66 enum rc_driver_type driver_type; 83 struct device dev;
67 unsigned long allowed_protos; 84 const char *input_name;
68 u32 scanmask; 85 const char *input_phys;
69 86 struct input_id input_id;
70 u32 timeout; 87 char *driver_name;
71 u32 min_timeout; 88 const char *map_name;
72 u32 max_timeout; 89 struct ir_scancode_table rc_tab;
73 90 unsigned long devno;
74 u32 rx_resolution; 91 struct ir_raw_event_ctrl *raw;
75 u32 tx_resolution; 92 struct input_dev *input_dev;
76 93 enum rc_driver_type driver_type;
77 void *priv;
78 int (*change_protocol)(void *priv, u64 ir_type);
79 int (*open)(void *priv);
80 void (*close)(void *priv);
81 int (*s_tx_mask)(void *priv, u32 mask);
82 int (*s_tx_carrier)(void *priv, u32 carrier);
83 int (*s_tx_duty_cycle)(void *priv, u32 duty_cycle);
84 int (*s_rx_carrier_range)(void *priv, u32 min, u32 max);
85 int (*tx_ir)(void *priv, int *txbuf, u32 n);
86 void (*s_idle)(void *priv, bool enable);
87 int (*s_learning_mode)(void *priv, int enable);
88 int (*s_carrier_report) (void *priv, int enable);
89};
90
91struct ir_input_dev {
92 struct device dev; /* device */
93 char *driver_name; /* Name of the driver module */
94 struct ir_scancode_table rc_tab; /* scan/key table */
95 unsigned long devno; /* device number */
96 struct ir_dev_props *props; /* Device properties */
97 struct ir_raw_event_ctrl *raw; /* for raw pulse/space events */
98 struct input_dev *input_dev; /* the input device associated with this device */
99 bool idle; 94 bool idle;
100 95 u64 allowed_protos;
101 /* key info - needed by IR keycode handlers */ 96 u32 scanmask;
102 spinlock_t keylock; /* protects the below members */ 97 void *priv;
103 bool keypressed; /* current state */ 98 spinlock_t keylock;
104 unsigned long keyup_jiffies; /* when should the current keypress be released? */ 99 bool keypressed;
105 struct timer_list timer_keyup; /* timer for releasing a keypress */ 100 unsigned long keyup_jiffies;
106 u32 last_keycode; /* keycode of last command */ 101 struct timer_list timer_keyup;
107 u32 last_scancode; /* scancode of last command */ 102 u32 last_keycode;
108 u8 last_toggle; /* toggle of last command */ 103 u32 last_scancode;
104 u8 last_toggle;
105 u32 timeout;
106 u32 min_timeout;
107 u32 max_timeout;
108 u32 rx_resolution;
109 u32 tx_resolution;
110 int (*change_protocol)(struct rc_dev *dev, u64 ir_type);
111 int (*open)(struct rc_dev *dev);
112 void (*close)(struct rc_dev *dev);
113 int (*s_tx_mask)(struct rc_dev *dev, u32 mask);
114 int (*s_tx_carrier)(struct rc_dev *dev, u32 carrier);
115 int (*s_tx_duty_cycle)(struct rc_dev *dev, u32 duty_cycle);
116 int (*s_rx_carrier_range)(struct rc_dev *dev, u32 min, u32 max);
117 int (*tx_ir)(struct rc_dev *dev, int *txbuf, u32 n);
118 void (*s_idle)(struct rc_dev *dev, bool enable);
119 int (*s_learning_mode)(struct rc_dev *dev, int enable);
120 int (*s_carrier_report) (struct rc_dev *dev, int enable);
109}; 121};
110 122
111enum raw_event_type { 123enum raw_event_type {
@@ -115,52 +127,14 @@ enum raw_event_type {
115 IR_STOP_EVENT = (1 << 3), 127 IR_STOP_EVENT = (1 << 3),
116}; 128};
117 129
118#define to_ir_input_dev(_attr) container_of(_attr, struct ir_input_dev, attr) 130#define to_rc_dev(d) container_of(d, struct rc_dev, dev)
119
120int __ir_input_register(struct input_dev *dev,
121 const struct ir_scancode_table *ir_codes,
122 struct ir_dev_props *props,
123 const char *driver_name);
124
125static inline int ir_input_register(struct input_dev *dev,
126 const char *map_name,
127 struct ir_dev_props *props,
128 const char *driver_name) {
129 struct ir_scancode_table *ir_codes;
130 struct ir_input_dev *ir_dev;
131 int rc;
132
133 if (!map_name)
134 return -EINVAL;
135
136 ir_codes = get_rc_map(map_name);
137 if (!ir_codes) {
138 ir_codes = get_rc_map(RC_MAP_EMPTY);
139 131
140 if (!ir_codes)
141 return -EINVAL;
142 }
143 132
144 rc = __ir_input_register(dev, ir_codes, props, driver_name); 133void ir_repeat(struct rc_dev *dev);
145 if (rc < 0) 134void ir_keydown(struct rc_dev *dev, int scancode, u8 toggle);
146 return -EINVAL; 135void ir_keydown_notimeout(struct rc_dev *dev, int scancode, u8 toggle);
147 136void ir_keyup(struct rc_dev *dev);
148 ir_dev = input_get_drvdata(dev); 137u32 ir_g_keycode_from_table(struct rc_dev *dev, u32 scancode);
149
150 if (!rc && ir_dev->props && ir_dev->props->change_protocol)
151 rc = ir_dev->props->change_protocol(ir_dev->props->priv,
152 ir_codes->ir_type);
153
154 return rc;
155}
156
157void ir_input_unregister(struct input_dev *input_dev);
158
159void ir_repeat(struct input_dev *dev);
160void ir_keydown(struct input_dev *dev, int scancode, u8 toggle);
161void ir_keydown_notimeout(struct input_dev *dev, int scancode, u8 toggle);
162void ir_keyup(struct input_dev *dev);
163u32 ir_g_keycode_from_table(struct input_dev *input_dev, u32 scancode);
164 138
165/* From ir-raw-event.c */ 139/* From ir-raw-event.c */
166struct ir_raw_event { 140struct ir_raw_event {
@@ -194,20 +168,25 @@ static inline void init_ir_raw_event(struct ir_raw_event *ev)
194 168
195#define IR_MAX_DURATION 0xFFFFFFFF /* a bit more than 4 seconds */ 169#define IR_MAX_DURATION 0xFFFFFFFF /* a bit more than 4 seconds */
196 170
197void ir_raw_event_handle(struct input_dev *input_dev); 171struct rc_dev *rc_allocate_device(void);
198int ir_raw_event_store(struct input_dev *input_dev, struct ir_raw_event *ev); 172void rc_free_device(struct rc_dev *dev);
199int ir_raw_event_store_edge(struct input_dev *input_dev, enum raw_event_type type); 173int rc_register_device(struct rc_dev *dev);
200int ir_raw_event_store_with_filter(struct input_dev *input_dev, 174void rc_unregister_device(struct rc_dev *dev);
175
176void ir_raw_event_handle(struct rc_dev *dev);
177int ir_raw_event_store(struct rc_dev *dev, struct ir_raw_event *ev);
178int ir_raw_event_store_edge(struct rc_dev *dev, enum raw_event_type type);
179int ir_raw_event_store_with_filter(struct rc_dev *dev,
201 struct ir_raw_event *ev); 180 struct ir_raw_event *ev);
202void ir_raw_event_set_idle(struct input_dev *input_dev, bool idle); 181void ir_raw_event_set_idle(struct rc_dev *dev, bool idle);
203 182
204static inline void ir_raw_event_reset(struct input_dev *input_dev) 183static inline void ir_raw_event_reset(struct rc_dev *dev)
205{ 184{
206 DEFINE_IR_RAW_EVENT(ev); 185 DEFINE_IR_RAW_EVENT(ev);
207 ev.reset = true; 186 ev.reset = true;
208 187
209 ir_raw_event_store(input_dev, &ev); 188 ir_raw_event_store(dev, &ev);
210 ir_raw_event_handle(input_dev); 189 ir_raw_event_handle(dev);
211} 190}
212 191
213 192
diff --git a/include/media/ir-kbd-i2c.h b/include/media/ir-kbd-i2c.h
index 8c37b5ec0cf..4ee9b42cbf7 100644
--- a/include/media/ir-kbd-i2c.h
+++ b/include/media/ir-kbd-i2c.h
@@ -9,9 +9,8 @@ struct IR_i2c;
9 9
10struct IR_i2c { 10struct IR_i2c {
11 char *ir_codes; 11 char *ir_codes;
12
13 struct i2c_client *c; 12 struct i2c_client *c;
14 struct input_dev *input; 13 struct rc_dev *rc;
15 14
16 /* Used to avoid fast repeating */ 15 /* Used to avoid fast repeating */
17 unsigned char old; 16 unsigned char old;