.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * TechnoTrend USB IR Receiver |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2012 Sean Young <sean@mess.org> |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License as published by |
---|
8 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
9 | | - * (at your option) any later version. |
---|
10 | | - * |
---|
11 | | - * This program is distributed in the hope that it will be useful, |
---|
12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | | - * GNU General Public License for more details. |
---|
15 | 6 | */ |
---|
16 | 7 | |
---|
17 | 8 | #include <linux/module.h> |
---|
.. | .. |
---|
29 | 20 | * messages per second (!), whether IR is idle or not. |
---|
30 | 21 | */ |
---|
31 | 22 | #define NUM_URBS 4 |
---|
32 | | -#define NS_PER_BYTE 62500 |
---|
33 | | -#define NS_PER_BIT (NS_PER_BYTE/8) |
---|
| 23 | +#define US_PER_BYTE 62 |
---|
| 24 | +#define US_PER_BIT (US_PER_BYTE / 8) |
---|
34 | 25 | |
---|
35 | 26 | struct ttusbir { |
---|
36 | 27 | struct rc_dev *rc; |
---|
.. | .. |
---|
117 | 108 | */ |
---|
118 | 109 | static void ttusbir_process_ir_data(struct ttusbir *tt, uint8_t *buf) |
---|
119 | 110 | { |
---|
120 | | - struct ir_raw_event rawir; |
---|
| 111 | + struct ir_raw_event rawir = {}; |
---|
121 | 112 | unsigned i, v, b; |
---|
122 | 113 | bool event = false; |
---|
123 | | - |
---|
124 | | - init_ir_raw_event(&rawir); |
---|
125 | 114 | |
---|
126 | 115 | for (i = 0; i < 128; i++) { |
---|
127 | 116 | v = buf[i] & 0xfe; |
---|
128 | 117 | switch (v) { |
---|
129 | 118 | case 0xfe: |
---|
130 | 119 | rawir.pulse = false; |
---|
131 | | - rawir.duration = NS_PER_BYTE; |
---|
| 120 | + rawir.duration = US_PER_BYTE; |
---|
132 | 121 | if (ir_raw_event_store_with_filter(tt->rc, &rawir)) |
---|
133 | 122 | event = true; |
---|
134 | 123 | break; |
---|
135 | 124 | case 0: |
---|
136 | 125 | rawir.pulse = true; |
---|
137 | | - rawir.duration = NS_PER_BYTE; |
---|
| 126 | + rawir.duration = US_PER_BYTE; |
---|
138 | 127 | if (ir_raw_event_store_with_filter(tt->rc, &rawir)) |
---|
139 | 128 | event = true; |
---|
140 | 129 | break; |
---|
.. | .. |
---|
148 | 137 | rawir.pulse = false; |
---|
149 | 138 | } |
---|
150 | 139 | |
---|
151 | | - rawir.duration = NS_PER_BIT * (8 - b); |
---|
| 140 | + rawir.duration = US_PER_BIT * (8 - b); |
---|
152 | 141 | if (ir_raw_event_store_with_filter(tt->rc, &rawir)) |
---|
153 | 142 | event = true; |
---|
154 | 143 | |
---|
155 | 144 | rawir.pulse = !rawir.pulse; |
---|
156 | | - rawir.duration = NS_PER_BIT * b; |
---|
| 145 | + rawir.duration = US_PER_BIT * b; |
---|
157 | 146 | if (ir_raw_event_store_with_filter(tt->rc, &rawir)) |
---|
158 | 147 | event = true; |
---|
159 | 148 | break; |
---|
.. | .. |
---|
322 | 311 | rc->max_timeout = 10 * IR_DEFAULT_TIMEOUT; |
---|
323 | 312 | |
---|
324 | 313 | /* |
---|
325 | | - * The precision is NS_PER_BIT, but since every 8th bit can be |
---|
326 | | - * overwritten with garbage the accuracy is at best 2 * NS_PER_BIT. |
---|
| 314 | + * The precision is US_PER_BIT, but since every 8th bit can be |
---|
| 315 | + * overwritten with garbage the accuracy is at best 2 * US_PER_BIT. |
---|
327 | 316 | */ |
---|
328 | | - rc->rx_resolution = NS_PER_BIT; |
---|
| 317 | + rc->rx_resolution = 2 * US_PER_BIT; |
---|
329 | 318 | |
---|
330 | 319 | ret = rc_register_device(rc); |
---|
331 | 320 | if (ret) { |
---|