| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * USB RedRat3 IR Transceiver rc-core driver |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 28 | 29 | * It uses its own little protocol to communicate, the required |
|---|
| 29 | 30 | * parts of which are embedded within this driver. |
|---|
| 30 | 31 | * -- |
|---|
| 31 | | - * |
|---|
| 32 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 33 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 34 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 35 | | - * (at your option) any later version. |
|---|
| 36 | | - * |
|---|
| 37 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 38 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 39 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 40 | | - * GNU General Public License for more details. |
|---|
| 41 | | - * |
|---|
| 42 | 32 | */ |
|---|
| 43 | 33 | |
|---|
| 44 | 34 | #include <asm/unaligned.h> |
|---|
| .. | .. |
|---|
| 140 | 130 | * When receiving a continuous ir stream (for example when a user is |
|---|
| 141 | 131 | * holding a button down on a remote), this specifies the minimum size |
|---|
| 142 | 132 | * of a space when the redrat3 sends a irdata packet to the host. Specified |
|---|
| 143 | | - * in miliseconds. Default value 18ms. |
|---|
| 133 | + * in milliseconds. Default value 18ms. |
|---|
| 144 | 134 | * The value can be between 2 and 30 inclusive. |
|---|
| 145 | 135 | */ |
|---|
| 146 | 136 | static int minimum_pause = 18; |
|---|
| .. | .. |
|---|
| 348 | 338 | |
|---|
| 349 | 339 | static void redrat3_process_ir_data(struct redrat3_dev *rr3) |
|---|
| 350 | 340 | { |
|---|
| 351 | | - DEFINE_IR_RAW_EVENT(rawir); |
|---|
| 341 | + struct ir_raw_event rawir = {}; |
|---|
| 352 | 342 | struct device *dev; |
|---|
| 353 | | - unsigned int i, sig_size, single_len, offset, val; |
|---|
| 343 | + unsigned int i, sig_size, offset, val; |
|---|
| 354 | 344 | u32 mod_freq; |
|---|
| 355 | 345 | |
|---|
| 356 | 346 | dev = rr3->dev; |
|---|
| .. | .. |
|---|
| 358 | 348 | mod_freq = redrat3_val_to_mod_freq(&rr3->irdata); |
|---|
| 359 | 349 | dev_dbg(dev, "Got mod_freq of %u\n", mod_freq); |
|---|
| 360 | 350 | if (mod_freq && rr3->wideband) { |
|---|
| 361 | | - DEFINE_IR_RAW_EVENT(ev); |
|---|
| 362 | | - |
|---|
| 363 | | - ev.carrier_report = 1; |
|---|
| 364 | | - ev.carrier = mod_freq; |
|---|
| 351 | + struct ir_raw_event ev = { |
|---|
| 352 | + .carrier_report = 1, |
|---|
| 353 | + .carrier = mod_freq |
|---|
| 354 | + }; |
|---|
| 365 | 355 | |
|---|
| 366 | 356 | ir_raw_event_store(rr3->rc, &ev); |
|---|
| 367 | 357 | } |
|---|
| .. | .. |
|---|
| 371 | 361 | for (i = 0; i < sig_size; i++) { |
|---|
| 372 | 362 | offset = rr3->irdata.sigdata[i]; |
|---|
| 373 | 363 | val = get_unaligned_be16(&rr3->irdata.lens[offset]); |
|---|
| 374 | | - single_len = redrat3_len_to_us(val); |
|---|
| 375 | 364 | |
|---|
| 376 | 365 | /* we should always get pulse/space/pulse/space samples */ |
|---|
| 377 | 366 | if (i % 2) |
|---|
| .. | .. |
|---|
| 379 | 368 | else |
|---|
| 380 | 369 | rawir.pulse = true; |
|---|
| 381 | 370 | |
|---|
| 382 | | - rawir.duration = US_TO_NS(single_len); |
|---|
| 371 | + rawir.duration = redrat3_len_to_us(val); |
|---|
| 383 | 372 | /* cap the value to IR_MAX_DURATION */ |
|---|
| 384 | 373 | rawir.duration = (rawir.duration > IR_MAX_DURATION) ? |
|---|
| 385 | 374 | IR_MAX_DURATION : rawir.duration; |
|---|
| .. | .. |
|---|
| 505 | 494 | return timeout; |
|---|
| 506 | 495 | } |
|---|
| 507 | 496 | |
|---|
| 508 | | -static int redrat3_set_timeout(struct rc_dev *rc_dev, unsigned int timeoutns) |
|---|
| 497 | +static int redrat3_set_timeout(struct rc_dev *rc_dev, unsigned int timeoutus) |
|---|
| 509 | 498 | { |
|---|
| 510 | 499 | struct redrat3_dev *rr3 = rc_dev->priv; |
|---|
| 511 | 500 | struct usb_device *udev = rr3->udev; |
|---|
| .. | .. |
|---|
| 517 | 506 | if (!timeout) |
|---|
| 518 | 507 | return -ENOMEM; |
|---|
| 519 | 508 | |
|---|
| 520 | | - *timeout = cpu_to_be32(redrat3_us_to_len(timeoutns / 1000)); |
|---|
| 509 | + *timeout = cpu_to_be32(redrat3_us_to_len(timeoutus)); |
|---|
| 521 | 510 | ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RR3_SET_IR_PARAM, |
|---|
| 522 | 511 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, |
|---|
| 523 | 512 | RR3_IR_IO_SIG_TIMEOUT, 0, timeout, sizeof(*timeout), |
|---|
| .. | .. |
|---|
| 957 | 946 | rc->dev.parent = dev; |
|---|
| 958 | 947 | rc->priv = rr3; |
|---|
| 959 | 948 | rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER; |
|---|
| 960 | | - rc->min_timeout = MS_TO_NS(RR3_RX_MIN_TIMEOUT); |
|---|
| 961 | | - rc->max_timeout = MS_TO_NS(RR3_RX_MAX_TIMEOUT); |
|---|
| 962 | | - rc->timeout = US_TO_NS(redrat3_get_timeout(rr3)); |
|---|
| 949 | + rc->min_timeout = MS_TO_US(RR3_RX_MIN_TIMEOUT); |
|---|
| 950 | + rc->max_timeout = MS_TO_US(RR3_RX_MAX_TIMEOUT); |
|---|
| 951 | + rc->timeout = redrat3_get_timeout(rr3); |
|---|
| 963 | 952 | rc->s_timeout = redrat3_set_timeout; |
|---|
| 964 | 953 | rc->tx_ir = redrat3_transmit_ir; |
|---|
| 965 | 954 | rc->s_tx_carrier = redrat3_set_tx_carrier; |
|---|
| 966 | 955 | rc->s_carrier_report = redrat3_wideband_receiver; |
|---|
| 967 | 956 | rc->driver_name = DRIVER_NAME; |
|---|
| 968 | | - rc->rx_resolution = US_TO_NS(2); |
|---|
| 957 | + rc->rx_resolution = 2; |
|---|
| 969 | 958 | rc->map_name = RC_MAP_HAUPPAUGE; |
|---|
| 970 | 959 | |
|---|
| 971 | 960 | ret = rc_register_device(rc); |
|---|