diff options
Diffstat (limited to 'drivers/media/rc/ttusbir.c')
| -rw-r--r-- | drivers/media/rc/ttusbir.c | 54 |
1 files changed, 20 insertions, 34 deletions
diff --git a/drivers/media/rc/ttusbir.c b/drivers/media/rc/ttusbir.c index 891762d167ed..560a26f3965c 100644 --- a/drivers/media/rc/ttusbir.c +++ b/drivers/media/rc/ttusbir.c @@ -1,21 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * TechnoTrend USB IR Receiver * * Copyright (C) 2012 Sean Young <sean@mess.org> - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <linux/module.h> @@ -33,8 +20,8 @@ * messages per second (!), whether IR is idle or not. */ #define NUM_URBS 4 -#define NS_PER_BYTE 62500 -#define NS_PER_BIT (NS_PER_BYTE/8) +#define US_PER_BYTE 62 +#define US_PER_BIT (US_PER_BYTE / 8) struct ttusbir { struct rc_dev *rc; @@ -103,7 +90,6 @@ static void ttusbir_bulk_complete(struct urb *urb) case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: - usb_unlink_urb(urb); return; case -EPIPE: default: @@ -121,24 +107,22 @@ static void ttusbir_bulk_complete(struct urb *urb) */ static void ttusbir_process_ir_data(struct ttusbir *tt, uint8_t *buf) { - struct ir_raw_event rawir; + struct ir_raw_event rawir = {}; unsigned i, v, b; bool event = false; - init_ir_raw_event(&rawir); - for (i = 0; i < 128; i++) { v = buf[i] & 0xfe; switch (v) { case 0xfe: rawir.pulse = false; - rawir.duration = NS_PER_BYTE; + rawir.duration = US_PER_BYTE; if (ir_raw_event_store_with_filter(tt->rc, &rawir)) event = true; break; case 0: rawir.pulse = true; - rawir.duration = NS_PER_BYTE; + rawir.duration = US_PER_BYTE; if (ir_raw_event_store_with_filter(tt->rc, &rawir)) event = true; break; @@ -152,12 +136,12 @@ static void ttusbir_process_ir_data(struct ttusbir *tt, uint8_t *buf) rawir.pulse = false; } - rawir.duration = NS_PER_BIT * (8 - b); + rawir.duration = US_PER_BIT * (8 - b); if (ir_raw_event_store_with_filter(tt->rc, &rawir)) event = true; rawir.pulse = !rawir.pulse; - rawir.duration = NS_PER_BIT * b; + rawir.duration = US_PER_BIT * b; if (ir_raw_event_store_with_filter(tt->rc, &rawir)) event = true; break; @@ -181,7 +165,6 @@ static void ttusbir_urb_complete(struct urb *urb) case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: - usb_unlink_urb(urb); return; case -EPIPE: default: @@ -205,7 +188,7 @@ static int ttusbir_probe(struct usb_interface *intf, int altsetting = -1; tt = kzalloc(sizeof(*tt), GFP_KERNEL); - rc = rc_allocate_device(); + rc = rc_allocate_device(RC_DRIVER_IR_RAW); if (!tt || !rc) { ret = -ENOMEM; goto out; @@ -302,6 +285,7 @@ static int ttusbir_probe(struct usb_interface *intf, ttusbir_bulk_complete, tt); tt->led.name = "ttusbir:green:power"; + tt->led.default_trigger = "rc-feedback"; tt->led.brightness_set = ttusbir_brightness_set; tt->led.brightness_get = ttusbir_brightness_get; tt->is_led_on = tt->led_on = true; @@ -312,21 +296,23 @@ static int ttusbir_probe(struct usb_interface *intf, usb_make_path(tt->udev, tt->phys, sizeof(tt->phys)); - rc->input_name = DRIVER_DESC; + rc->device_name = DRIVER_DESC; rc->input_phys = tt->phys; 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_BIT_ALL; + rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER; rc->priv = tt; rc->driver_name = DRIVER_NAME; rc->map_name = RC_MAP_TT_1500; - rc->timeout = MS_TO_NS(100); + rc->min_timeout = 1; + rc->timeout = IR_DEFAULT_TIMEOUT; + rc->max_timeout = 10 * IR_DEFAULT_TIMEOUT; + /* - * The precision is NS_PER_BIT, but since every 8th bit can be - * overwritten with garbage the accuracy is at best 2 * NS_PER_BIT. + * The precision is US_PER_BIT, but since every 8th bit can be + * overwritten with garbage the accuracy is at best 2 * US_PER_BIT. */ - rc->rx_resolution = NS_PER_BIT; + rc->rx_resolution = 2 * US_PER_BIT; ret = rc_register_device(rc); if (ret) { @@ -414,7 +400,7 @@ static int ttusbir_resume(struct usb_interface *intf) led_classdev_resume(&tt->led); for (i = 0; i < NUM_URBS; i++) { - rc = usb_submit_urb(tt->urb[i], GFP_KERNEL); + rc = usb_submit_urb(tt->urb[i], GFP_NOIO); if (rc) { dev_warn(tt->dev, "failed to submit urb: %d\n", rc); break; |
