.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* ir-xmp-decoder.c - handle XMP IR Pulse/Space protocol |
---|
2 | 3 | * |
---|
3 | 4 | * Copyright (C) 2014 by Marcel Mol |
---|
4 | | - * |
---|
5 | | - * This program is free software; you can redistribute it and/or modify |
---|
6 | | - * it under the terms of the GNU General Public License as published by |
---|
7 | | - * the Free Software Foundation version 2 of the License. |
---|
8 | | - * |
---|
9 | | - * This program is distributed in the hope that it will be useful, |
---|
10 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 | | - * GNU General Public License for more details. |
---|
13 | 5 | * |
---|
14 | 6 | * - Based on info from http://www.hifi-remote.com |
---|
15 | 7 | * - Ignore Toggle=9 frames |
---|
.. | .. |
---|
20 | 12 | #include <linux/module.h> |
---|
21 | 13 | #include "rc-core-priv.h" |
---|
22 | 14 | |
---|
23 | | -#define XMP_UNIT 136000 /* ns */ |
---|
24 | | -#define XMP_LEADER 210000 /* ns */ |
---|
25 | | -#define XMP_NIBBLE_PREFIX 760000 /* ns */ |
---|
26 | | -#define XMP_HALFFRAME_SPACE 13800000 /* ns */ |
---|
27 | | -#define XMP_TRAILER_SPACE 20000000 /* should be 80ms but not all dureation supliers can go that high */ |
---|
| 15 | +#define XMP_UNIT 136 /* us */ |
---|
| 16 | +#define XMP_LEADER 210 /* us */ |
---|
| 17 | +#define XMP_NIBBLE_PREFIX 760 /* us */ |
---|
| 18 | +#define XMP_HALFFRAME_SPACE 13800 /* us */ |
---|
| 19 | +/* should be 80ms but not all duration supliers can go that high */ |
---|
| 20 | +#define XMP_TRAILER_SPACE 20000 |
---|
28 | 21 | |
---|
29 | 22 | enum xmp_state { |
---|
30 | 23 | STATE_INACTIVE, |
---|
.. | .. |
---|
50 | 43 | } |
---|
51 | 44 | |
---|
52 | 45 | dev_dbg(&dev->dev, "XMP decode started at state %d %d (%uus %s)\n", |
---|
53 | | - data->state, data->count, TO_US(ev.duration), TO_STR(ev.pulse)); |
---|
| 46 | + data->state, data->count, ev.duration, TO_STR(ev.pulse)); |
---|
54 | 47 | |
---|
55 | 48 | switch (data->state) { |
---|
56 | 49 | |
---|
.. | .. |
---|
94 | 87 | n = data->durations; |
---|
95 | 88 | /* |
---|
96 | 89 | * the 4th nibble should be 15 so base the divider on this |
---|
97 | | - * to transform durations into nibbles. Substract 2000 from |
---|
| 90 | + * to transform durations into nibbles. Subtract 2000 from |
---|
98 | 91 | * the divider to compensate for fluctuations in the signal |
---|
99 | 92 | */ |
---|
100 | 93 | divider = (n[3] - XMP_NIBBLE_PREFIX) / 15 - 2000; |
---|
.. | .. |
---|
174 | 167 | } else if (geq_margin(ev.duration, XMP_NIBBLE_PREFIX, XMP_UNIT)) { |
---|
175 | 168 | /* store nibble raw data, decode after trailer */ |
---|
176 | 169 | if (data->count == 16) { |
---|
177 | | - dev_dbg(&dev->dev, "to many pulses (%d) ignoring: %u\n", |
---|
| 170 | + dev_dbg(&dev->dev, "too many pulses (%d) ignoring: %u\n", |
---|
178 | 171 | data->count, ev.duration); |
---|
179 | 172 | data->state = STATE_INACTIVE; |
---|
180 | 173 | return -EINVAL; |
---|
.. | .. |
---|
191 | 184 | } |
---|
192 | 185 | |
---|
193 | 186 | dev_dbg(&dev->dev, "XMP decode failed at count %d state %d (%uus %s)\n", |
---|
194 | | - data->count, data->state, TO_US(ev.duration), TO_STR(ev.pulse)); |
---|
| 187 | + data->count, data->state, ev.duration, TO_STR(ev.pulse)); |
---|
195 | 188 | data->state = STATE_INACTIVE; |
---|
196 | 189 | return -EINVAL; |
---|
197 | 190 | } |
---|