From 304ce75dd501d84d33dbca3c544e903f1d3377f7 Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Wed, 10 Oct 2012 14:34:07 -0300 Subject: [media] media/ir_rx51: use module_platform_driver macro This patch removes some code duplication by using module_platform_driver. Signed-off-by: Srinivas Kandagatla Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/ir-rx51.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'drivers/media/rc') diff --git a/drivers/media/rc/ir-rx51.c b/drivers/media/rc/ir-rx51.c index 546199e9ccc7..8cfe3166bb54 100644 --- a/drivers/media/rc/ir-rx51.c +++ b/drivers/media/rc/ir-rx51.c @@ -480,18 +480,7 @@ struct platform_driver lirc_rx51_platform_driver = { .owner = THIS_MODULE, }, }; - -static int __init lirc_rx51_init(void) -{ - return platform_driver_register(&lirc_rx51_platform_driver); -} -module_init(lirc_rx51_init); - -static void __exit lirc_rx51_exit(void) -{ - platform_driver_unregister(&lirc_rx51_platform_driver); -} -module_exit(lirc_rx51_exit); +module_platform_driver(lirc_rx51_platform_driver); MODULE_DESCRIPTION("LIRC TX driver for Nokia RX51"); MODULE_AUTHOR("Nokia Corporation"); -- cgit v1.2.1 From c003ab1bedf028db15b0185b683d5c387204e8f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20H=C3=A4rdeman?= Date: Thu, 11 Oct 2012 19:11:54 -0300 Subject: [media] rc-core: add separate defines for protocol bitmaps and numbers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The RC_TYPE_* defines are currently used both where a single protocol is expected and where a bitmap of protocols is expected. Functions like rc_keydown() and functions which add/remove entries to the keytable want a single protocol. Future userspace APIs would also benefit from numeric protocols (rather than bitmap ones). Keytables are smaller if they can use a small(ish) integer rather than a bitmap. Other functions or struct members (e.g. allowed_protos, enabled_protocols, etc) accept multiple protocols and need a bitmap. Using different types reduces the risk of programmer error. Using a protocol enum whereever possible also makes for a more future-proof user-space API as we don't need to worry about a sufficient number of bits being available (e.g. in structs used for ioctl() calls). The use of both a number and a corresponding bit is dalso one in e.g. the input subsystem as well (see all the references to set/clear bit when changing keytables for example). This patch separate the different usages in preparation for upcoming patches. Where a single protocol is expected, enum rc_type is used; where one or more protocol(s) are expected, something like u64 is used. The patch has been rewritten so that the format of the sysfs "protocols" file is no longer altered (at the loss of some detail). The file itself should probably be deprecated in the future though. Signed-off-by: David Härdeman Cc: Andy Walls Cc: Maxim Levitsky Cc: Antti Palosaari Cc: Mike Isely Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/ati_remote.c | 2 +- drivers/media/rc/ene_ir.c | 2 +- drivers/media/rc/fintek-cir.c | 2 +- drivers/media/rc/gpio-ir-recv.c | 2 +- drivers/media/rc/iguanair.c | 2 +- drivers/media/rc/imon.c | 40 +++++++++---------- drivers/media/rc/ir-jvc-decoder.c | 4 +- drivers/media/rc/ir-lirc-codec.c | 4 +- drivers/media/rc/ir-mce_kbd-decoder.c | 4 +- drivers/media/rc/ir-nec-decoder.c | 4 +- drivers/media/rc/ir-rc5-decoder.c | 14 +++++-- drivers/media/rc/ir-rc5-sz-decoder.c | 6 +-- drivers/media/rc/ir-rc6-decoder.c | 8 +++- drivers/media/rc/ir-sanyo-decoder.c | 4 +- drivers/media/rc/ir-sony-decoder.c | 17 +++++++- drivers/media/rc/ite-cir.c | 2 +- drivers/media/rc/keymaps/rc-imon-mce.c | 2 +- drivers/media/rc/keymaps/rc-rc6-mce.c | 2 +- drivers/media/rc/mceusb.c | 2 +- drivers/media/rc/nuvoton-cir.c | 2 +- drivers/media/rc/rc-loopback.c | 2 +- drivers/media/rc/rc-main.c | 73 +++++++++++++++++++--------------- drivers/media/rc/redrat3.c | 2 +- drivers/media/rc/streamzap.c | 2 +- drivers/media/rc/ttusbir.c | 2 +- drivers/media/rc/winbond-cir.c | 2 +- 26 files changed, 119 insertions(+), 89 deletions(-) (limited to 'drivers/media/rc') diff --git a/drivers/media/rc/ati_remote.c b/drivers/media/rc/ati_remote.c index 49bb356ed14c..2d6fb26a0170 100644 --- a/drivers/media/rc/ati_remote.c +++ b/drivers/media/rc/ati_remote.c @@ -784,7 +784,7 @@ static void ati_remote_rc_init(struct ati_remote *ati_remote) rdev->priv = ati_remote; rdev->driver_type = RC_DRIVER_SCANCODE; - rdev->allowed_protos = RC_TYPE_OTHER; + rdev->allowed_protos = RC_BIT_OTHER; rdev->driver_name = "ati_remote"; rdev->open = ati_remote_rc_open; diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c index d05ac15b5de4..7467a6da39ff 100644 --- a/drivers/media/rc/ene_ir.c +++ b/drivers/media/rc/ene_ir.c @@ -1046,7 +1046,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id) learning_mode_force = false; rdev->driver_type = RC_DRIVER_IR_RAW; - rdev->allowed_protos = RC_TYPE_ALL; + rdev->allowed_protos = RC_BIT_ALL; rdev->priv = dev; rdev->open = ene_open; rdev->close = ene_close; diff --git a/drivers/media/rc/fintek-cir.c b/drivers/media/rc/fintek-cir.c index 52fd7696b1ba..d2d93cbe628c 100644 --- a/drivers/media/rc/fintek-cir.c +++ b/drivers/media/rc/fintek-cir.c @@ -541,7 +541,7 @@ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id /* Set up the rc device */ rdev->priv = fintek; rdev->driver_type = RC_DRIVER_IR_RAW; - rdev->allowed_protos = RC_TYPE_ALL; + rdev->allowed_protos = RC_BIT_ALL; rdev->open = fintek_open; rdev->close = fintek_close; rdev->input_name = FINTEK_DESCRIPTION; diff --git a/drivers/media/rc/gpio-ir-recv.c b/drivers/media/rc/gpio-ir-recv.c index 04cb272db16a..ba1a1eb356cf 100644 --- a/drivers/media/rc/gpio-ir-recv.c +++ b/drivers/media/rc/gpio-ir-recv.c @@ -95,7 +95,7 @@ static int __devinit gpio_ir_recv_probe(struct platform_device *pdev) if (pdata->allowed_protos) rcdev->allowed_protos = pdata->allowed_protos; else - rcdev->allowed_protos = RC_TYPE_ALL; + rcdev->allowed_protos = RC_BIT_ALL; rcdev->map_name = pdata->map_name ?: RC_MAP_EMPTY; gpio_dev->rcdev = rcdev; diff --git a/drivers/media/rc/iguanair.c b/drivers/media/rc/iguanair.c index 51d7057aca04..5a9163da63c3 100644 --- a/drivers/media/rc/iguanair.c +++ b/drivers/media/rc/iguanair.c @@ -499,7 +499,7 @@ static int __devinit iguanair_probe(struct usb_interface *intf, usb_to_input_id(ir->udev, &rc->input_id); rc->dev.parent = &intf->dev; rc->driver_type = RC_DRIVER_IR_RAW; - rc->allowed_protos = RC_TYPE_ALL; + rc->allowed_protos = RC_BIT_ALL; rc->priv = ir; rc->open = iguanair_open; rc->close = iguanair_close; diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c index 5dd0386604f0..8f6a28921ed4 100644 --- a/drivers/media/rc/imon.c +++ b/drivers/media/rc/imon.c @@ -1001,7 +1001,7 @@ static void imon_touch_display_timeout(unsigned long data) * it is not, so we must acquire it prior to calling send_packet, which * requires that the lock is held. */ -static int imon_ir_change_protocol(struct rc_dev *rc, u64 rc_type) +static int imon_ir_change_protocol(struct rc_dev *rc, u64 *rc_type) { int retval; struct imon_context *ictx = rc->priv; @@ -1010,31 +1010,27 @@ static int imon_ir_change_protocol(struct rc_dev *rc, u64 rc_type) unsigned char ir_proto_packet[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86 }; - if (rc_type && !(rc_type & rc->allowed_protos)) + if (*rc_type && !(*rc_type & rc->allowed_protos)) dev_warn(dev, "Looks like you're trying to use an IR protocol " "this device does not support\n"); - switch (rc_type) { - case RC_TYPE_RC6: + if (*rc_type & RC_BIT_RC6_MCE) { dev_dbg(dev, "Configuring IR receiver for MCE protocol\n"); ir_proto_packet[0] = 0x01; - break; - case RC_TYPE_UNKNOWN: - case RC_TYPE_OTHER: + *rc_type = RC_BIT_RC6_MCE; + } else if (*rc_type & RC_BIT_OTHER) { dev_dbg(dev, "Configuring IR receiver for iMON protocol\n"); if (!pad_stabilize) dev_dbg(dev, "PAD stabilize functionality disabled\n"); /* ir_proto_packet[0] = 0x00; // already the default */ - rc_type = RC_TYPE_OTHER; - break; - default: + *rc_type = RC_BIT_OTHER; + } else { dev_warn(dev, "Unsupported IR protocol specified, overriding " "to iMON IR protocol\n"); if (!pad_stabilize) dev_dbg(dev, "PAD stabilize functionality disabled\n"); /* ir_proto_packet[0] = 0x00; // already the default */ - rc_type = RC_TYPE_OTHER; - break; + *rc_type = RC_BIT_OTHER; } memcpy(ictx->usb_tx_buf, &ir_proto_packet, sizeof(ir_proto_packet)); @@ -1048,7 +1044,7 @@ static int imon_ir_change_protocol(struct rc_dev *rc, u64 rc_type) if (retval) goto out; - ictx->rc_type = rc_type; + ictx->rc_type = *rc_type; ictx->pad_mouse = false; out: @@ -1323,7 +1319,7 @@ static void imon_pad_to_keys(struct imon_context *ictx, unsigned char *buf) rel_x = buf[2]; rel_y = buf[3]; - if (ictx->rc_type == RC_TYPE_OTHER && pad_stabilize) { + if (ictx->rc_type == RC_BIT_OTHER && pad_stabilize) { if ((buf[1] == 0) && ((rel_x != 0) || (rel_y != 0))) { dir = stabilize((int)rel_x, (int)rel_y, timeout, threshold); @@ -1390,7 +1386,7 @@ static void imon_pad_to_keys(struct imon_context *ictx, unsigned char *buf) buf[0] = 0x01; buf[1] = buf[4] = buf[5] = buf[6] = buf[7] = 0; - if (ictx->rc_type == RC_TYPE_OTHER && pad_stabilize) { + if (ictx->rc_type == RC_BIT_OTHER && pad_stabilize) { dir = stabilize((int)rel_x, (int)rel_y, timeout, threshold); if (!dir) { @@ -1511,7 +1507,7 @@ static void imon_incoming_packet(struct imon_context *ictx, kc = imon_panel_key_lookup(scancode); } else { scancode = be32_to_cpu(*((u32 *)buf)); - if (ictx->rc_type == RC_TYPE_RC6) { + if (ictx->rc_type == RC_BIT_RC6_MCE) { ktype = IMON_KEY_IMON; if (buf[0] == 0x80) ktype = IMON_KEY_MCE; @@ -1744,7 +1740,7 @@ static void imon_get_ffdc_type(struct imon_context *ictx) { u8 ffdc_cfg_byte = ictx->usb_rx_buf[6]; u8 detected_display_type = IMON_DISPLAY_TYPE_NONE; - u64 allowed_protos = RC_TYPE_OTHER; + u64 allowed_protos = RC_BIT_OTHER; switch (ffdc_cfg_byte) { /* iMON Knob, no display, iMON IR + vol knob */ @@ -1775,13 +1771,13 @@ static void imon_get_ffdc_type(struct imon_context *ictx) case 0x9e: dev_info(ictx->dev, "0xffdc iMON VFD, MCE IR"); detected_display_type = IMON_DISPLAY_TYPE_VFD; - allowed_protos = RC_TYPE_RC6; + allowed_protos = RC_BIT_RC6_MCE; break; /* iMON LCD, MCE IR */ case 0x9f: dev_info(ictx->dev, "0xffdc iMON LCD, MCE IR"); detected_display_type = IMON_DISPLAY_TYPE_LCD; - allowed_protos = RC_TYPE_RC6; + allowed_protos = RC_BIT_RC6_MCE; break; default: dev_info(ictx->dev, "Unknown 0xffdc device, " @@ -1789,7 +1785,7 @@ static void imon_get_ffdc_type(struct imon_context *ictx) detected_display_type = IMON_DISPLAY_TYPE_VFD; /* We don't know which one it is, allow user to set the * RC6 one from userspace if OTHER wasn't correct. */ - allowed_protos |= RC_TYPE_RC6; + allowed_protos |= RC_BIT_RC6_MCE; break; } @@ -1875,7 +1871,7 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx) rdev->priv = ictx; rdev->driver_type = RC_DRIVER_SCANCODE; - rdev->allowed_protos = RC_TYPE_OTHER | RC_TYPE_RC6; /* iMON PAD or MCE */ + rdev->allowed_protos = RC_BIT_OTHER | RC_BIT_RC6_MCE; /* iMON PAD or MCE */ rdev->change_protocol = imon_ir_change_protocol; rdev->driver_name = MOD_NAME; @@ -1893,7 +1889,7 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx) imon_set_display_type(ictx); - if (ictx->rc_type == RC_TYPE_RC6) + if (ictx->rc_type == RC_BIT_RC6_MCE) rdev->map_name = RC_MAP_IMON_MCE; else rdev->map_name = RC_MAP_IMON_PAD; diff --git a/drivers/media/rc/ir-jvc-decoder.c b/drivers/media/rc/ir-jvc-decoder.c index 035668e27f6b..69edffb9fe9a 100644 --- a/drivers/media/rc/ir-jvc-decoder.c +++ b/drivers/media/rc/ir-jvc-decoder.c @@ -47,7 +47,7 @@ static int ir_jvc_decode(struct rc_dev *dev, struct ir_raw_event ev) { struct jvc_dec *data = &dev->raw->jvc; - if (!(dev->raw->enabled_protocols & RC_TYPE_JVC)) + if (!(dev->raw->enabled_protocols & RC_BIT_JVC)) return 0; if (!is_timing_event(ev)) { @@ -174,7 +174,7 @@ out: } static struct ir_raw_handler jvc_handler = { - .protocols = RC_TYPE_JVC, + .protocols = RC_BIT_JVC, .decode = ir_jvc_decode, }; diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c index 870c93052fd0..9945e5e7f61a 100644 --- a/drivers/media/rc/ir-lirc-codec.c +++ b/drivers/media/rc/ir-lirc-codec.c @@ -35,7 +35,7 @@ static int ir_lirc_decode(struct rc_dev *dev, struct ir_raw_event ev) struct lirc_codec *lirc = &dev->raw->lirc; int sample; - if (!(dev->raw->enabled_protocols & RC_TYPE_LIRC)) + if (!(dev->raw->enabled_protocols & RC_BIT_LIRC)) return 0; if (!dev->raw->lirc.drv || !dev->raw->lirc.drv->rbuf) @@ -408,7 +408,7 @@ static int ir_lirc_unregister(struct rc_dev *dev) } static struct ir_raw_handler lirc_handler = { - .protocols = RC_TYPE_LIRC, + .protocols = RC_BIT_LIRC, .decode = ir_lirc_decode, .raw_register = ir_lirc_register, .raw_unregister = ir_lirc_unregister, diff --git a/drivers/media/rc/ir-mce_kbd-decoder.c b/drivers/media/rc/ir-mce_kbd-decoder.c index 3784ebf80ec7..33fafa4cf7cb 100644 --- a/drivers/media/rc/ir-mce_kbd-decoder.c +++ b/drivers/media/rc/ir-mce_kbd-decoder.c @@ -216,7 +216,7 @@ static int ir_mce_kbd_decode(struct rc_dev *dev, struct ir_raw_event ev) u32 scancode; unsigned long delay; - if (!(dev->raw->enabled_protocols & RC_TYPE_MCE_KBD)) + if (!(dev->raw->enabled_protocols & RC_BIT_MCE_KBD)) return 0; if (!is_timing_event(ev)) { @@ -422,7 +422,7 @@ static int ir_mce_kbd_unregister(struct rc_dev *dev) } static struct ir_raw_handler mce_kbd_handler = { - .protocols = RC_TYPE_MCE_KBD, + .protocols = RC_BIT_MCE_KBD, .decode = ir_mce_kbd_decode, .raw_register = ir_mce_kbd_register, .raw_unregister = ir_mce_kbd_unregister, diff --git a/drivers/media/rc/ir-nec-decoder.c b/drivers/media/rc/ir-nec-decoder.c index 2ca509e6e16b..a47ee3634969 100644 --- a/drivers/media/rc/ir-nec-decoder.c +++ b/drivers/media/rc/ir-nec-decoder.c @@ -52,7 +52,7 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev) u8 address, not_address, command, not_command; bool send_32bits = false; - if (!(dev->raw->enabled_protocols & RC_TYPE_NEC)) + if (!(dev->raw->enabled_protocols & RC_BIT_NEC)) return 0; if (!is_timing_event(ev)) { @@ -201,7 +201,7 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev) } static struct ir_raw_handler nec_handler = { - .protocols = RC_TYPE_NEC, + .protocols = RC_BIT_NEC, .decode = ir_nec_decode, }; diff --git a/drivers/media/rc/ir-rc5-decoder.c b/drivers/media/rc/ir-rc5-decoder.c index 9ab663a507a4..5b4d1ddeac4e 100644 --- a/drivers/media/rc/ir-rc5-decoder.c +++ b/drivers/media/rc/ir-rc5-decoder.c @@ -52,8 +52,8 @@ static int ir_rc5_decode(struct rc_dev *dev, struct ir_raw_event ev) u8 toggle; u32 scancode; - if (!(dev->raw->enabled_protocols & RC_TYPE_RC5)) - return 0; + if (!(dev->raw->enabled_protocols & (RC_BIT_RC5 | RC_BIT_RC5X))) + return 0; if (!is_timing_event(ev)) { if (ev.reset) @@ -128,6 +128,10 @@ again: if (data->wanted_bits == RC5X_NBITS) { /* RC5X */ u8 xdata, command, system; + if (!(dev->raw->enabled_protocols & RC_BIT_RC5X)) { + data->state = STATE_INACTIVE; + return 0; + } xdata = (data->bits & 0x0003F) >> 0; command = (data->bits & 0x00FC0) >> 6; system = (data->bits & 0x1F000) >> 12; @@ -141,6 +145,10 @@ again: } else { /* RC5 */ u8 command, system; + if (!(dev->raw->enabled_protocols & RC_BIT_RC5)) { + data->state = STATE_INACTIVE; + return 0; + } command = (data->bits & 0x0003F) >> 0; system = (data->bits & 0x007C0) >> 6; toggle = (data->bits & 0x00800) ? 1 : 0; @@ -164,7 +172,7 @@ out: } static struct ir_raw_handler rc5_handler = { - .protocols = RC_TYPE_RC5, + .protocols = RC_BIT_RC5 | RC_BIT_RC5X, .decode = ir_rc5_decode, }; diff --git a/drivers/media/rc/ir-rc5-sz-decoder.c b/drivers/media/rc/ir-rc5-sz-decoder.c index ec8d4a2e2c5a..fd807a8308d8 100644 --- a/drivers/media/rc/ir-rc5-sz-decoder.c +++ b/drivers/media/rc/ir-rc5-sz-decoder.c @@ -48,8 +48,8 @@ static int ir_rc5_sz_decode(struct rc_dev *dev, struct ir_raw_event ev) u8 toggle, command, system; u32 scancode; - if (!(dev->raw->enabled_protocols & RC_TYPE_RC5_SZ)) - return 0; + if (!(dev->raw->enabled_protocols & RC_BIT_RC5_SZ)) + return 0; if (!is_timing_event(ev)) { if (ev.reset) @@ -128,7 +128,7 @@ out: } static struct ir_raw_handler rc5_sz_handler = { - .protocols = RC_TYPE_RC5_SZ, + .protocols = RC_BIT_RC5_SZ, .decode = ir_rc5_sz_decode, }; diff --git a/drivers/media/rc/ir-rc6-decoder.c b/drivers/media/rc/ir-rc6-decoder.c index 4cfdd7fa4bbd..e19072ffb36c 100644 --- a/drivers/media/rc/ir-rc6-decoder.c +++ b/drivers/media/rc/ir-rc6-decoder.c @@ -89,7 +89,9 @@ static int ir_rc6_decode(struct rc_dev *dev, struct ir_raw_event ev) u32 scancode; u8 toggle; - if (!(dev->raw->enabled_protocols & RC_TYPE_RC6)) + if (!(dev->raw->enabled_protocols & + (RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | + RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE))) return 0; if (!is_timing_event(ev)) { @@ -271,7 +273,9 @@ out: } static struct ir_raw_handler rc6_handler = { - .protocols = RC_TYPE_RC6, + .protocols = RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | + RC_BIT_RC6_6A_24 | RC_BIT_RC6_6A_32 | + RC_BIT_RC6_MCE, .decode = ir_rc6_decode, }; diff --git a/drivers/media/rc/ir-sanyo-decoder.c b/drivers/media/rc/ir-sanyo-decoder.c index 7e54ec57bcf9..7e69a3b65370 100644 --- a/drivers/media/rc/ir-sanyo-decoder.c +++ b/drivers/media/rc/ir-sanyo-decoder.c @@ -58,7 +58,7 @@ static int ir_sanyo_decode(struct rc_dev *dev, struct ir_raw_event ev) u32 scancode; u8 address, command, not_command; - if (!(dev->raw->enabled_protocols & RC_TYPE_SANYO)) + if (!(dev->raw->enabled_protocols & RC_BIT_SANYO)) return 0; if (!is_timing_event(ev)) { @@ -179,7 +179,7 @@ static int ir_sanyo_decode(struct rc_dev *dev, struct ir_raw_event ev) } static struct ir_raw_handler sanyo_handler = { - .protocols = RC_TYPE_SANYO, + .protocols = RC_BIT_SANYO, .decode = ir_sanyo_decode, }; diff --git a/drivers/media/rc/ir-sony-decoder.c b/drivers/media/rc/ir-sony-decoder.c index dab98b37621a..fb914342cf4d 100644 --- a/drivers/media/rc/ir-sony-decoder.c +++ b/drivers/media/rc/ir-sony-decoder.c @@ -45,7 +45,8 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev) u32 scancode; u8 device, subdevice, function; - if (!(dev->raw->enabled_protocols & RC_TYPE_SONY)) + if (!(dev->raw->enabled_protocols & + (RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20))) return 0; if (!is_timing_event(ev)) { @@ -123,16 +124,28 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev) switch (data->count) { case 12: + if (!(dev->raw->enabled_protocols & RC_BIT_SONY12)) { + data->state = STATE_INACTIVE; + return 0; + } device = bitrev8((data->bits << 3) & 0xF8); subdevice = 0; function = bitrev8((data->bits >> 4) & 0xFE); break; case 15: + if (!(dev->raw->enabled_protocols & RC_BIT_SONY15)) { + data->state = STATE_INACTIVE; + return 0; + } device = bitrev8((data->bits >> 0) & 0xFF); subdevice = 0; function = bitrev8((data->bits >> 7) & 0xFE); break; case 20: + if (!(dev->raw->enabled_protocols & RC_BIT_SONY20)) { + data->state = STATE_INACTIVE; + return 0; + } device = bitrev8((data->bits >> 5) & 0xF8); subdevice = bitrev8((data->bits >> 0) & 0xFF); function = bitrev8((data->bits >> 12) & 0xFE); @@ -157,7 +170,7 @@ out: } static struct ir_raw_handler sony_handler = { - .protocols = RC_TYPE_SONY, + .protocols = RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20, .decode = ir_sony_decode, }; diff --git a/drivers/media/rc/ite-cir.c b/drivers/media/rc/ite-cir.c index 24c77a42fc36..d63511511df4 100644 --- a/drivers/media/rc/ite-cir.c +++ b/drivers/media/rc/ite-cir.c @@ -1563,7 +1563,7 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id /* set up ir-core props */ rdev->priv = itdev; rdev->driver_type = RC_DRIVER_IR_RAW; - rdev->allowed_protos = RC_TYPE_ALL; + rdev->allowed_protos = RC_BIT_ALL; rdev->open = ite_open; rdev->close = ite_close; rdev->s_idle = ite_s_idle; diff --git a/drivers/media/rc/keymaps/rc-imon-mce.c b/drivers/media/rc/keymaps/rc-imon-mce.c index 124c7228ba8c..f0da960560b0 100644 --- a/drivers/media/rc/keymaps/rc-imon-mce.c +++ b/drivers/media/rc/keymaps/rc-imon-mce.c @@ -121,7 +121,7 @@ static struct rc_map_list imon_mce_map = { .scan = imon_mce, .size = ARRAY_SIZE(imon_mce), /* its RC6, but w/a hardware decoder */ - .rc_type = RC_TYPE_RC6, + .rc_type = RC_TYPE_RC6_MCE, .name = RC_MAP_IMON_MCE, } }; diff --git a/drivers/media/rc/keymaps/rc-rc6-mce.c b/drivers/media/rc/keymaps/rc-rc6-mce.c index 753e43ec787b..ef4006fe4de0 100644 --- a/drivers/media/rc/keymaps/rc-rc6-mce.c +++ b/drivers/media/rc/keymaps/rc-rc6-mce.c @@ -97,7 +97,7 @@ static struct rc_map_list rc6_mce_map = { .map = { .scan = rc6_mce, .size = ARRAY_SIZE(rc6_mce), - .rc_type = RC_TYPE_RC6, + .rc_type = RC_TYPE_RC6_MCE, .name = RC_MAP_RC6_MCE, } }; diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c index 850547fe711c..b2146cd99fd8 100644 --- a/drivers/media/rc/mceusb.c +++ b/drivers/media/rc/mceusb.c @@ -1205,7 +1205,7 @@ static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir) rc->dev.parent = dev; rc->priv = ir; rc->driver_type = RC_DRIVER_IR_RAW; - rc->allowed_protos = RC_TYPE_ALL; + rc->allowed_protos = RC_BIT_ALL; rc->timeout = MS_TO_NS(100); if (!ir->flags.no_tx) { rc->s_tx_mask = mceusb_set_tx_mask; diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c index 2ea913a44ae8..0190dfc2ad41 100644 --- a/drivers/media/rc/nuvoton-cir.c +++ b/drivers/media/rc/nuvoton-cir.c @@ -1045,7 +1045,7 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) /* Set up the rc device */ rdev->priv = nvt; rdev->driver_type = RC_DRIVER_IR_RAW; - rdev->allowed_protos = RC_TYPE_ALL; + rdev->allowed_protos = RC_BIT_ALL; rdev->open = nvt_open; rdev->close = nvt_close; rdev->tx_ir = nvt_tx_ir; diff --git a/drivers/media/rc/rc-loopback.c b/drivers/media/rc/rc-loopback.c index f9be68132c67..53d02827a472 100644 --- a/drivers/media/rc/rc-loopback.c +++ b/drivers/media/rc/rc-loopback.c @@ -195,7 +195,7 @@ static int __init loop_init(void) rc->map_name = RC_MAP_EMPTY; rc->priv = &loopdev; rc->driver_type = RC_DRIVER_IR_RAW; - rc->allowed_protos = RC_TYPE_ALL; + rc->allowed_protos = RC_BIT_ALL; rc->timeout = 100 * 1000 * 1000; /* 100 ms */ rc->min_timeout = 1; rc->max_timeout = UINT_MAX; diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index cabc19c10515..601d1ac1c688 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -725,25 +725,36 @@ static struct class ir_input_class = { .devnode = ir_devnode, }; +/* + * These are the protocol textual descriptions that are + * used by the sysfs protocols file. Note that the order + * of the entries is relevant. + */ static struct { u64 type; char *name; } proto_names[] = { - { RC_TYPE_UNKNOWN, "unknown" }, - { RC_TYPE_RC5, "rc-5" }, - { RC_TYPE_NEC, "nec" }, - { RC_TYPE_RC6, "rc-6" }, - { RC_TYPE_JVC, "jvc" }, - { RC_TYPE_SONY, "sony" }, - { RC_TYPE_RC5_SZ, "rc-5-sz" }, - { RC_TYPE_SANYO, "sanyo" }, - { RC_TYPE_MCE_KBD, "mce_kbd" }, - { RC_TYPE_LIRC, "lirc" }, - { RC_TYPE_OTHER, "other" }, + { RC_BIT_NONE, "none" }, + { RC_BIT_OTHER, "other" }, + { RC_BIT_UNKNOWN, "unknown" }, + { RC_BIT_RC5 | + RC_BIT_RC5X, "rc-5" }, + { RC_BIT_NEC, "nec" }, + { RC_BIT_RC6_0 | + RC_BIT_RC6_6A_20 | + RC_BIT_RC6_6A_24 | + RC_BIT_RC6_6A_32 | + RC_BIT_RC6_MCE, "rc-6" }, + { RC_BIT_JVC, "jvc" }, + { RC_BIT_SONY12 | + RC_BIT_SONY15 | + RC_BIT_SONY20, "sony" }, + { RC_BIT_RC5_SZ, "rc-5-sz" }, + { RC_BIT_SANYO, "sanyo" }, + { RC_BIT_MCE_KBD, "mce_kbd" }, + { RC_BIT_LIRC, "lirc" }, }; -#define PROTO_NONE "none" - /** * show_protocols() - shows the current IR protocol(s) * @device: the device descriptor @@ -790,6 +801,9 @@ static ssize_t show_protocols(struct device *device, tmp += sprintf(tmp, "[%s] ", proto_names[i].name); else if (allowed & proto_names[i].type) tmp += sprintf(tmp, "%s ", proto_names[i].name); + + if (allowed & proto_names[i].type) + allowed &= ~proto_names[i].type; } if (tmp != buf) @@ -867,26 +881,20 @@ static ssize_t store_protocols(struct device *device, disable = false; } - if (!enable && !disable && !strncasecmp(tmp, PROTO_NONE, sizeof(PROTO_NONE))) { - tmp += sizeof(PROTO_NONE); - mask = 0; - count++; - } else { - for (i = 0; i < ARRAY_SIZE(proto_names); i++) { - if (!strcasecmp(tmp, proto_names[i].name)) { - tmp += strlen(proto_names[i].name); - mask = proto_names[i].type; - break; - } - } - if (i == ARRAY_SIZE(proto_names)) { - IR_dprintk(1, "Unknown protocol: '%s'\n", tmp); - ret = -EINVAL; - goto out; + for (i = 0; i < ARRAY_SIZE(proto_names); i++) { + if (!strcasecmp(tmp, proto_names[i].name)) { + mask = proto_names[i].type; + break; } - count++; } + if (i == ARRAY_SIZE(proto_names)) { + IR_dprintk(1, "Unknown protocol: '%s'\n", tmp); + return -EINVAL; + } + + count++; + if (enable) type |= mask; else if (disable) @@ -902,7 +910,7 @@ static ssize_t store_protocols(struct device *device, } if (dev->change_protocol) { - rc = dev->change_protocol(dev, type); + rc = dev->change_protocol(dev, &type); if (rc < 0) { IR_dprintk(1, "Error setting protocols to 0x%llx\n", (long long)type); @@ -1117,7 +1125,8 @@ int rc_register_device(struct rc_dev *dev) } if (dev->change_protocol) { - rc = dev->change_protocol(dev, rc_map->rc_type); + u64 rc_type = (1 << rc_map->rc_type); + rc = dev->change_protocol(dev, &rc_type); if (rc < 0) goto out_raw; } diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c index 9f5a17bb5ef5..a8887aba9faf 100644 --- a/drivers/media/rc/redrat3.c +++ b/drivers/media/rc/redrat3.c @@ -1082,7 +1082,7 @@ static struct rc_dev *redrat3_init_rc_dev(struct redrat3_dev *rr3) rc->dev.parent = dev; rc->priv = rr3; rc->driver_type = RC_DRIVER_IR_RAW; - rc->allowed_protos = RC_TYPE_ALL; + rc->allowed_protos = RC_BIT_ALL; rc->timeout = US_TO_NS(2750); rc->tx_ir = redrat3_transmit_ir; rc->s_tx_carrier = redrat3_set_tx_carrier; diff --git a/drivers/media/rc/streamzap.c b/drivers/media/rc/streamzap.c index d6f4bfe09391..c720f12f661e 100644 --- a/drivers/media/rc/streamzap.c +++ b/drivers/media/rc/streamzap.c @@ -322,7 +322,7 @@ static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz) rdev->dev.parent = dev; rdev->priv = sz; rdev->driver_type = RC_DRIVER_IR_RAW; - rdev->allowed_protos = RC_TYPE_ALL; + rdev->allowed_protos = RC_BIT_ALL; rdev->driver_name = DRIVER_NAME; rdev->map_name = RC_MAP_STREAMZAP; diff --git a/drivers/media/rc/ttusbir.c b/drivers/media/rc/ttusbir.c index fef05235234a..f0921b5483eb 100644 --- a/drivers/media/rc/ttusbir.c +++ b/drivers/media/rc/ttusbir.c @@ -316,7 +316,7 @@ static int __devinit ttusbir_probe(struct usb_interface *intf, usb_to_input_id(tt->udev, &rc->input_id); rc->dev.parent = &intf->dev; rc->driver_type = RC_DRIVER_IR_RAW; - rc->allowed_protos = RC_TYPE_ALL; + rc->allowed_protos = RC_BIT_ALL; rc->priv = tt; rc->driver_name = DRIVER_NAME; rc->map_name = RC_MAP_TT_1500; diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c index 7c9b5f33113b..569d8863f439 100644 --- a/drivers/media/rc/winbond-cir.c +++ b/drivers/media/rc/winbond-cir.c @@ -1022,7 +1022,7 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id) data->dev->priv = data; data->dev->dev.parent = &device->dev; data->dev->timeout = MS_TO_NS(100); - data->dev->allowed_protos = RC_TYPE_ALL; + data->dev->allowed_protos = RC_BIT_ALL; if (!request_region(data->wbase, WAKEUP_IOMEM_LEN, DRVNAME)) { dev_err(dev, "Region 0x%lx-0x%lx already in use!\n", -- cgit v1.2.1 From e03cd645dfecb27746c6d488c73605fef6ae635f Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 27 Oct 2012 13:46:53 -0300 Subject: [media] ene_cir: get rid of warning: no previous prototype drivers/media/rc/ene_ir.c:332:6: warning: no previous prototype for 'ene_rx_sense_carrier' [-Wmissing-prototypes] Cc: Maxim Levitsky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/ene_ir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/media/rc') diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c index 7467a6da39ff..dd3c510a6ae8 100644 --- a/drivers/media/rc/ene_ir.c +++ b/drivers/media/rc/ene_ir.c @@ -329,7 +329,7 @@ static int ene_rx_get_sample_reg(struct ene_device *dev) } /* Sense current received carrier */ -void ene_rx_sense_carrier(struct ene_device *dev) +static void ene_rx_sense_carrier(struct ene_device *dev) { DEFINE_IR_RAW_EVENT(ev); -- cgit v1.2.1 From 3d4bf09c1d9cb315af18a7eb825f0ddce0dbe5b4 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 27 Oct 2012 13:48:14 -0300 Subject: [media] ite-cir.c: get rid of warning: no previous prototype drivers/media/rc/ite-cir.c:1711:5: warning: no previous prototype for 'ite_init' [-Wmissing-prototypes] drivers/media/rc/ite-cir.c:1716:6: warning: no previous prototype for 'ite_exit' [-Wmissing-prototypes] Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/ite-cir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/media/rc') diff --git a/drivers/media/rc/ite-cir.c b/drivers/media/rc/ite-cir.c index d63511511df4..5e5a7f2b8184 100644 --- a/drivers/media/rc/ite-cir.c +++ b/drivers/media/rc/ite-cir.c @@ -1708,12 +1708,12 @@ static struct pnp_driver ite_driver = { .shutdown = ite_shutdown, }; -int ite_init(void) +static int ite_init(void) { return pnp_register_driver(&ite_driver); } -void ite_exit(void) +static void ite_exit(void) { pnp_unregister_driver(&ite_driver); } -- cgit v1.2.1 From 8e1803f4cd4bab0a66a24945a00e2c3a89457a32 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 27 Oct 2012 13:49:04 -0300 Subject: [media] nuvoton-cir: get rid of warning: no previous prototype drivers/media/rc/nuvoton-cir.c:1223:5: warning: no previous prototype for 'nvt_init' [-Wmissing-prototypes] drivers/media/rc/nuvoton-cir.c:1228:6: warning: no previous prototype for 'nvt_exit' [-Wmissing-prototypes] Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/nuvoton-cir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/media/rc') diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c index 0190dfc2ad41..44ba834c363d 100644 --- a/drivers/media/rc/nuvoton-cir.c +++ b/drivers/media/rc/nuvoton-cir.c @@ -1220,12 +1220,12 @@ static struct pnp_driver nvt_driver = { .shutdown = nvt_shutdown, }; -int nvt_init(void) +static int nvt_init(void) { return pnp_register_driver(&nvt_driver); } -void nvt_exit(void) +static void nvt_exit(void) { pnp_unregister_driver(&nvt_driver); } -- cgit v1.2.1 From 230dc94a2a6e5786b8529e3218979719758f1fa0 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 27 Oct 2012 13:54:09 -0300 Subject: [media] nuvoton-cir: carrier detect support is broken - remove it The carrier detect return value is never used on nuvoton driver: drivers/media/rc/nuvoton-cir.c: In function 'nvt_process_rx_ir_data': drivers/media/rc/nuvoton-cir.c:623:6: warning: variable 'carrier' set but not used [-Wunused-but-set-variable] Also, this would be called only if a boolean variable is enabled, but there's no condition that enables it inside the driver. So, comment the carrier detection code, as it might be useful later, and remove the unused glue code. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/nuvoton-cir.c | 7 ++----- drivers/media/rc/nuvoton-cir.h | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) (limited to 'drivers/media/rc') diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c index 44ba834c363d..e4ea89a11eed 100644 --- a/drivers/media/rc/nuvoton-cir.c +++ b/drivers/media/rc/nuvoton-cir.c @@ -472,6 +472,7 @@ static void nvt_enable_wake(struct nvt_dev *nvt) nvt_cir_wake_reg_write(nvt, 0, CIR_WAKE_IREN); } +#if 0 /* Currently unused */ /* rx carrier detect only works in learning mode, must be called w/nvt_lock */ static u32 nvt_rx_carrier_detect(struct nvt_dev *nvt) { @@ -504,7 +505,7 @@ static u32 nvt_rx_carrier_detect(struct nvt_dev *nvt) return carrier; } - +#endif /* * set carrier frequency * @@ -620,7 +621,6 @@ static void nvt_dump_rx_buf(struct nvt_dev *nvt) static void nvt_process_rx_ir_data(struct nvt_dev *nvt) { DEFINE_IR_RAW_EVENT(rawir); - u32 carrier; u8 sample; int i; @@ -629,9 +629,6 @@ static void nvt_process_rx_ir_data(struct nvt_dev *nvt) if (debug) nvt_dump_rx_buf(nvt); - if (nvt->carrier_detect_enabled) - carrier = nvt_rx_carrier_detect(nvt); - nvt_dbg_verbose("Processing buffer of len %d", nvt->pkts); init_ir_raw_event(&rawir); diff --git a/drivers/media/rc/nuvoton-cir.h b/drivers/media/rc/nuvoton-cir.h index 0d5e0872a2ea..7c3674ff5ea2 100644 --- a/drivers/media/rc/nuvoton-cir.h +++ b/drivers/media/rc/nuvoton-cir.h @@ -103,7 +103,6 @@ struct nvt_dev { /* rx settings */ bool learning_enabled; - bool carrier_detect_enabled; /* track cir wake state */ u8 wake_state; -- cgit v1.2.1 From a3faff2b39ca67684fb294a84d3e2d1ad2f4dfa2 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 27 Oct 2012 18:34:23 -0200 Subject: fintek-cir: get rid of warning: no previous prototype Cc: Linux Media Mailing List drivers/media/rc/fintek-cir.c:687:5: warning: no previous prototype for 'fintek_init' [-Wmissing-prototypes] drivers/media/rc/fintek-cir.c:692:6: warning: no previous prototype for 'fintek_exit' [-Wmissing-prototypes] Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/fintek-cir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/media/rc') diff --git a/drivers/media/rc/fintek-cir.c b/drivers/media/rc/fintek-cir.c index d2d93cbe628c..936c3f79b62c 100644 --- a/drivers/media/rc/fintek-cir.c +++ b/drivers/media/rc/fintek-cir.c @@ -684,12 +684,12 @@ static struct pnp_driver fintek_driver = { .shutdown = fintek_shutdown, }; -int fintek_init(void) +static int fintek_init(void) { return pnp_register_driver(&fintek_driver); } -void fintek_exit(void) +static void fintek_exit(void) { pnp_unregister_driver(&fintek_driver); } -- cgit v1.2.1 From 56411c0f1eec7495bcf1fd6b83a51bb57be608d4 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Mon, 15 Oct 2012 07:13:44 -0300 Subject: [media] ene-ir: Fix cleanup on probe failure This makes the cleanup on probe failure more consistent with other drivers. This is similar to what commit f27b853ea24a9b70585f9251384d97929e6551c3 ("[media] rc: Fix invalid free_region and/or free_irq on probe failure") did for some other drivers. In addition to making the cleanup more consistent, this also fixes a case where (on a ene_hw_detect failure) free_region would be called on a region that was not requested yet. This last problem was probably introduced by the moving of code in commit b31b021988fed9e3741a46918f14ba9b063811db ("[media] ene_ir: Fix driver initialisation") and commit 9ef449c6b31bb6a8e6dedc24de475a3b8c79be20 ("[media] rc: Postpone ISR registration"). Signed-off-by: Matthijs Kooijman Cc: Maxim Levitsky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/ene_ir.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'drivers/media/rc') diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c index dd3c510a6ae8..22231dd4f62b 100644 --- a/drivers/media/rc/ene_ir.c +++ b/drivers/media/rc/ene_ir.c @@ -1003,7 +1003,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id) dev = kzalloc(sizeof(struct ene_device), GFP_KERNEL); rdev = rc_allocate_device(); if (!dev || !rdev) - goto error1; + goto failure; /* validate resources */ error = -ENODEV; @@ -1014,10 +1014,10 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id) if (!pnp_port_valid(pnp_dev, 0) || pnp_port_len(pnp_dev, 0) < ENE_IO_SIZE) - goto error; + goto failure; if (!pnp_irq_valid(pnp_dev, 0)) - goto error; + goto failure; spin_lock_init(&dev->hw_lock); @@ -1033,7 +1033,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id) /* detect hardware version and features */ error = ene_hw_detect(dev); if (error) - goto error; + goto failure; if (!dev->hw_learning_and_tx_capable && txsim) { dev->hw_learning_and_tx_capable = true; @@ -1078,30 +1078,27 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id) /* claim the resources */ error = -EBUSY; if (!request_region(dev->hw_io, ENE_IO_SIZE, ENE_DRIVER_NAME)) { - dev->hw_io = -1; - dev->irq = -1; - goto error; + goto failure; } dev->irq = pnp_irq(pnp_dev, 0); if (request_irq(dev->irq, ene_isr, IRQF_SHARED, ENE_DRIVER_NAME, (void *)dev)) { - dev->irq = -1; - goto error; + goto failure2; } error = rc_register_device(rdev); if (error < 0) - goto error; + goto failure3; pr_notice("driver has been successfully loaded\n"); return 0; -error: - if (dev && dev->irq >= 0) - free_irq(dev->irq, dev); - if (dev && dev->hw_io >= 0) - release_region(dev->hw_io, ENE_IO_SIZE); -error1: + +failure3: + free_irq(dev->irq, dev); +failure2: + release_region(dev->hw_io, ENE_IO_SIZE); +failure: rc_free_device(rdev); kfree(dev); return error; -- cgit v1.2.1 From a66cd0b691c730ed751dbf66ffbd0edf18241790 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Wed, 17 Oct 2012 11:38:21 -0300 Subject: [media] winbond-cir: do not rename input name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "54fd321 [media] winbond: remove space from driver name" inadvertently renamed the input device name. Signed-off-by: Sean Young Acked-by: David Härdeman Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/winbond-cir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/media/rc') diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c index 569d8863f439..45d2fff764bc 100644 --- a/drivers/media/rc/winbond-cir.c +++ b/drivers/media/rc/winbond-cir.c @@ -184,7 +184,7 @@ enum wbcir_txstate { }; /* Misc */ -#define WBCIR_NAME "winbond-cir" +#define WBCIR_NAME "Winbond CIR" #define WBCIR_ID_FAMILY 0xF1 /* Family ID for the WPCD376I */ #define WBCIR_ID_CHIP 0x04 /* Chip ID for the WPCD376I */ #define INVALID_SCANCODE 0x7FFFFFFF /* Invalid with all protos */ @@ -1007,7 +1007,7 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id) } data->dev->driver_type = RC_DRIVER_IR_RAW; - data->dev->driver_name = WBCIR_NAME; + data->dev->driver_name = DRVNAME; data->dev->input_name = WBCIR_NAME; data->dev->input_phys = "wbcir/cir0"; data->dev->input_id.bustype = BUS_HOST; -- cgit v1.2.1 From e5eda7faea23c28836f17487962c6539fd3b3e27 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Wed, 24 Oct 2012 17:22:40 -0300 Subject: [media] winbond-cir: fix idle mode The receiver is never disabled by idle mode since rxstate never gets set to RXSTATE_ACTIVE, so we keep on getting interrupts after the first IR activity ends. Note that ir_raw_event_reset() already calls ir_raw_event_handle(). Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/winbond-cir.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'drivers/media/rc') diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c index 45d2fff764bc..16ba38e8183f 100644 --- a/drivers/media/rc/winbond-cir.c +++ b/drivers/media/rc/winbond-cir.c @@ -207,7 +207,6 @@ struct wbcir_data { /* RX state */ enum wbcir_rxstate rxstate; struct led_trigger *rxtrigger; - struct ir_raw_event rxev; /* TX state */ enum wbcir_txstate txstate; @@ -339,9 +338,12 @@ wbcir_idle_rx(struct rc_dev *dev, bool idle) led_trigger_event(data->rxtrigger, LED_FULL); } - if (idle && data->rxstate != WBCIR_RXSTATE_INACTIVE) + if (idle && data->rxstate != WBCIR_RXSTATE_INACTIVE) { + data->rxstate = WBCIR_RXSTATE_INACTIVE; + led_trigger_event(data->rxtrigger, LED_OFF); /* Tell hardware to go idle by setting RXINACTIVE */ outb(WBCIR_RX_DISABLE, data->sbase + WBCIR_REG_SP3_ASCR); + } } static void @@ -360,12 +362,6 @@ wbcir_irq_rx(struct wbcir_data *data, struct pnp_dev *device) ir_raw_event_store_with_filter(data->dev, &rawir); } - /* Check if we should go idle */ - if (data->dev->idle) { - led_trigger_event(data->rxtrigger, LED_OFF); - data->rxstate = WBCIR_RXSTATE_INACTIVE; - } - ir_raw_event_handle(data->dev); } @@ -915,9 +911,8 @@ wbcir_init_hw(struct wbcir_data *data) /* Clear RX state */ data->rxstate = WBCIR_RXSTATE_INACTIVE; - data->rxev.duration = 0; ir_raw_event_reset(data->dev); - ir_raw_event_handle(data->dev); + ir_raw_event_set_idle(data->dev, true); /* Clear TX state */ if (data->txstate == WBCIR_TXSTATE_ACTIVE) { -- cgit v1.2.1 From c496e716e0a7e3c486b99edbab5a6db7649824b1 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Wed, 24 Oct 2012 17:22:41 -0300 Subject: [media] winbond-cir: increase IR receiver resolution This is needed for carrier reporting. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/winbond-cir.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'drivers/media/rc') diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c index 16ba38e8183f..f040bbfd2100 100644 --- a/drivers/media/rc/winbond-cir.c +++ b/drivers/media/rc/winbond-cir.c @@ -358,7 +358,7 @@ wbcir_irq_rx(struct wbcir_data *data, struct pnp_dev *device) if (data->rxstate == WBCIR_RXSTATE_ERROR) continue; rawir.pulse = irdata & 0x80 ? false : true; - rawir.duration = US_TO_NS(((irdata & 0x7F) + 1) * 10); + rawir.duration = US_TO_NS(((irdata & 0x7F) + 1) * 2); ir_raw_event_store_with_filter(data->dev, &rawir); } @@ -862,8 +862,8 @@ wbcir_init_hw(struct wbcir_data *data) /* prescaler 1.0, tx/rx fifo lvl 16 */ outb(0x30, data->sbase + WBCIR_REG_SP3_EXCR2); - /* Set baud divisor to sample every 10 us */ - outb(0x0F, data->sbase + WBCIR_REG_SP3_BGDL); + /* Set baud divisor to sample every 2 ns */ + outb(0x03, data->sbase + WBCIR_REG_SP3_BGDL); outb(0x00, data->sbase + WBCIR_REG_SP3_BGDH); /* Set CEIR mode */ @@ -872,9 +872,12 @@ wbcir_init_hw(struct wbcir_data *data) inb(data->sbase + WBCIR_REG_SP3_LSR); /* Clear LSR */ inb(data->sbase + WBCIR_REG_SP3_MSR); /* Clear MSR */ - /* Disable RX demod, enable run-length enc/dec, set freq span */ + /* + * Disable RX demod, enable run-length enc/dec, set freq span and + * enable over-sampling + */ wbcir_select_bank(data, WBCIR_BANK_7); - outb(0x90, data->sbase + WBCIR_REG_SP3_RCCFG); + outb(0xd0, data->sbase + WBCIR_REG_SP3_RCCFG); /* Disable timer */ wbcir_select_bank(data, WBCIR_BANK_4); @@ -1017,6 +1020,7 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id) data->dev->priv = data; data->dev->dev.parent = &device->dev; data->dev->timeout = MS_TO_NS(100); + data->dev->rx_resolution = US_TO_NS(2); data->dev->allowed_protos = RC_BIT_ALL; if (!request_region(data->wbase, WAKEUP_IOMEM_LEN, DRVNAME)) { -- cgit v1.2.1 From 37b0b4e90d799cddfdd5d0a90ed470933f7e9859 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Wed, 24 Oct 2012 17:22:42 -0300 Subject: [media] winbond-cir: add carrier detection The winbond hardware has a counter for leading edges, which increases as they are received. As we read raw IR from a fifo in an interrupt handler, we cannot correlate them to specific IR pulses so we simply count all pulses and edges until we go idle and disable the receiver. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/winbond-cir.c | 80 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 75 insertions(+), 5 deletions(-) (limited to 'drivers/media/rc') diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c index f040bbfd2100..7f3c476dde05 100644 --- a/drivers/media/rc/winbond-cir.c +++ b/drivers/media/rc/winbond-cir.c @@ -7,6 +7,7 @@ * with minor modifications. * * Original Author: David Härdeman + * Copyright (C) 2012 Sean Young * Copyright (C) 2009 - 2011 David Härdeman * * Dedicated to my daughter Matilda, without whose loving attention this @@ -22,9 +23,7 @@ * o IR Receive * o IR Transmit * o Wake-On-CIR functionality - * - * To do: - * o Learning + * o Carrier detection * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -149,6 +148,12 @@ #define WBCIR_REGSEL_MASK 0x20 /* Starting address of selected register in WBCIR_REG_WCEIR_INDEX */ #define WBCIR_REG_ADDR0 0x00 +/* Enable carrier counter */ +#define WBCIR_CNTR_EN 0x01 +/* Reset carrier counter */ +#define WBCIR_CNTR_R 0x02 +/* Invert TX */ +#define WBCIR_IRTX_INV 0x04 /* Valid banks for the SP3 UART */ enum wbcir_bank { @@ -207,6 +212,8 @@ struct wbcir_data { /* RX state */ enum wbcir_rxstate rxstate; struct led_trigger *rxtrigger; + int carrier_report_enabled; + u32 pulse_duration; /* TX state */ enum wbcir_txstate txstate; @@ -328,6 +335,30 @@ wbcir_to_rc6cells(u8 val) * *****************************************************************************/ +static void +wbcir_carrier_report(struct wbcir_data *data) +{ + unsigned counter = inb(data->ebase + WBCIR_REG_ECEIR_CNT_LO) | + inb(data->ebase + WBCIR_REG_ECEIR_CNT_HI) << 8; + + if (counter > 0 && counter < 0xffff) { + DEFINE_IR_RAW_EVENT(ev); + + ev.carrier_report = 1; + ev.carrier = DIV_ROUND_CLOSEST(counter * 1000000u, + data->pulse_duration); + + ir_raw_event_store(data->dev, &ev); + } + + /* reset and restart the counter */ + data->pulse_duration = 0; + wbcir_set_bits(data->ebase + WBCIR_REG_ECEIR_CCTL, WBCIR_CNTR_R, + WBCIR_CNTR_EN | WBCIR_CNTR_R); + wbcir_set_bits(data->ebase + WBCIR_REG_ECEIR_CCTL, WBCIR_CNTR_EN, + WBCIR_CNTR_EN | WBCIR_CNTR_R); +} + static void wbcir_idle_rx(struct rc_dev *dev, bool idle) { @@ -341,6 +372,10 @@ wbcir_idle_rx(struct rc_dev *dev, bool idle) if (idle && data->rxstate != WBCIR_RXSTATE_INACTIVE) { data->rxstate = WBCIR_RXSTATE_INACTIVE; led_trigger_event(data->rxtrigger, LED_OFF); + + if (data->carrier_report_enabled) + wbcir_carrier_report(data); + /* Tell hardware to go idle by setting RXINACTIVE */ outb(WBCIR_RX_DISABLE, data->sbase + WBCIR_REG_SP3_ASCR); } @@ -351,14 +386,21 @@ wbcir_irq_rx(struct wbcir_data *data, struct pnp_dev *device) { u8 irdata; DEFINE_IR_RAW_EVENT(rawir); + unsigned duration; /* Since RXHDLEV is set, at least 8 bytes are in the FIFO */ while (inb(data->sbase + WBCIR_REG_SP3_LSR) & WBCIR_RX_AVAIL) { irdata = inb(data->sbase + WBCIR_REG_SP3_RXDATA); if (data->rxstate == WBCIR_RXSTATE_ERROR) continue; + + duration = ((irdata & 0x7F) + 1) * 2; rawir.pulse = irdata & 0x80 ? false : true; - rawir.duration = US_TO_NS(((irdata & 0x7F) + 1) * 2); + rawir.duration = US_TO_NS(duration); + + if (rawir.pulse) + data->pulse_duration += duration; + ir_raw_event_store_with_filter(data->dev, &rawir); } @@ -487,6 +529,33 @@ wbcir_irq_handler(int irqno, void *cookie) * *****************************************************************************/ +static int +wbcir_set_carrier_report(struct rc_dev *dev, int enable) +{ + struct wbcir_data *data = dev->priv; + unsigned long flags; + + spin_lock_irqsave(&data->spinlock, flags); + + if (data->carrier_report_enabled == enable) { + spin_unlock_irqrestore(&data->spinlock, flags); + return 0; + } + + data->pulse_duration = 0; + wbcir_set_bits(data->ebase + WBCIR_REG_ECEIR_CCTL, WBCIR_CNTR_R, + WBCIR_CNTR_EN | WBCIR_CNTR_R); + + if (enable && data->dev->idle) + wbcir_set_bits(data->ebase + WBCIR_REG_ECEIR_CCTL, + WBCIR_CNTR_EN, WBCIR_CNTR_EN | WBCIR_CNTR_R); + + data->carrier_report_enabled = enable; + spin_unlock_irqrestore(&data->spinlock, flags); + + return 0; +} + static int wbcir_txcarrier(struct rc_dev *dev, u32 carrier) { @@ -833,7 +902,7 @@ wbcir_init_hw(struct wbcir_data *data) /* Set IRTX_INV */ if (invert) - outb(0x04, data->ebase + WBCIR_REG_ECEIR_CCTL); + outb(WBCIR_IRTX_INV, data->ebase + WBCIR_REG_ECEIR_CCTL); else outb(0x00, data->ebase + WBCIR_REG_ECEIR_CCTL); @@ -1014,6 +1083,7 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id) data->dev->input_id.version = WBCIR_ID_CHIP; data->dev->map_name = RC_MAP_RC6_MCE; data->dev->s_idle = wbcir_idle_rx; + data->dev->s_carrier_report = wbcir_set_carrier_report; data->dev->s_tx_mask = wbcir_txmask; data->dev->s_tx_carrier = wbcir_txcarrier; data->dev->tx_ir = wbcir_tx; -- cgit v1.2.1