.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * serial_ir.c |
---|
3 | 4 | * |
---|
.. | .. |
---|
10 | 11 | * Copyright (C) 1999 Christoph Bartelmus <lirc@bartelmus.de> |
---|
11 | 12 | * Copyright (C) 2007 Andrei Tanas <andrei@tanas.ca> (suspend/resume support) |
---|
12 | 13 | * Copyright (C) 2016 Sean Young <sean@mess.org> (port to rc-core) |
---|
13 | | - * This program is free software; you can redistribute it and/or modify |
---|
14 | | - * it under the terms of the GNU General Public License as published by |
---|
15 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
16 | | - * (at your option) any later version. |
---|
17 | | - * |
---|
18 | | - * This program is distributed in the hope that it will be useful, |
---|
19 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
20 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
21 | | - * GNU General Public License for more details. |
---|
22 | 14 | */ |
---|
23 | 15 | |
---|
24 | 16 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
---|
.. | .. |
---|
273 | 265 | { |
---|
274 | 266 | /* simple noise filter */ |
---|
275 | 267 | static unsigned int ptr, pulse, space; |
---|
276 | | - DEFINE_IR_RAW_EVENT(ev); |
---|
| 268 | + struct ir_raw_event ev = {}; |
---|
277 | 269 | |
---|
278 | 270 | if (ptr > 0 && is_pulse) { |
---|
279 | 271 | pulse += l; |
---|
280 | | - if (pulse > 250000) { |
---|
| 272 | + if (pulse > 250) { |
---|
281 | 273 | ev.duration = space; |
---|
282 | 274 | ev.pulse = false; |
---|
283 | 275 | ir_raw_event_store_with_filter(serial_ir.rcdev, &ev); |
---|
.. | .. |
---|
291 | 283 | } |
---|
292 | 284 | if (!is_pulse) { |
---|
293 | 285 | if (ptr == 0) { |
---|
294 | | - if (l > 20000000) { |
---|
| 286 | + if (l > 20000) { |
---|
295 | 287 | space = l; |
---|
296 | 288 | ptr++; |
---|
297 | 289 | return; |
---|
298 | 290 | } |
---|
299 | 291 | } else { |
---|
300 | | - if (l > 20000000) { |
---|
| 292 | + if (l > 20000) { |
---|
301 | 293 | space += pulse; |
---|
302 | 294 | if (space > IR_MAX_DURATION) |
---|
303 | 295 | space = IR_MAX_DURATION; |
---|
.. | .. |
---|
361 | 353 | dcd = (status & hardware[type].signal_pin) ? 1 : 0; |
---|
362 | 354 | |
---|
363 | 355 | if (dcd == last_dcd) { |
---|
364 | | - dev_err(&serial_ir.pdev->dev, |
---|
| 356 | + dev_dbg(&serial_ir.pdev->dev, |
---|
365 | 357 | "ignoring spike: %d %d %lldns %lldns\n", |
---|
366 | 358 | dcd, sense, ktime_to_ns(kt), |
---|
367 | 359 | ktime_to_ns(serial_ir.lastkt)); |
---|
.. | .. |
---|
384 | 376 | sense = sense ? 0 : 1; |
---|
385 | 377 | } |
---|
386 | 378 | } else { |
---|
387 | | - data = ktime_to_ns(delkt); |
---|
| 379 | + data = ktime_to_us(delkt); |
---|
388 | 380 | } |
---|
389 | 381 | frbwrite(data, !(dcd ^ sense)); |
---|
390 | 382 | serial_ir.lastkt = kt; |
---|
.. | .. |
---|
393 | 385 | } while (!(sinp(UART_IIR) & UART_IIR_NO_INT)); /* still pending ? */ |
---|
394 | 386 | |
---|
395 | 387 | mod_timer(&serial_ir.timeout_timer, |
---|
396 | | - jiffies + nsecs_to_jiffies(serial_ir.rcdev->timeout)); |
---|
| 388 | + jiffies + usecs_to_jiffies(serial_ir.rcdev->timeout)); |
---|
397 | 389 | |
---|
398 | 390 | ir_raw_event_handle(serial_ir.rcdev); |
---|
399 | 391 | |
---|
.. | .. |
---|
472 | 464 | |
---|
473 | 465 | static void serial_ir_timeout(struct timer_list *unused) |
---|
474 | 466 | { |
---|
475 | | - DEFINE_IR_RAW_EVENT(ev); |
---|
476 | | - |
---|
477 | | - ev.timeout = true; |
---|
478 | | - ev.duration = serial_ir.rcdev->timeout; |
---|
| 467 | + struct ir_raw_event ev = { |
---|
| 468 | + .timeout = true, |
---|
| 469 | + .duration = serial_ir.rcdev->timeout |
---|
| 470 | + }; |
---|
479 | 471 | ir_raw_event_store_with_filter(serial_ir.rcdev, &ev); |
---|
480 | 472 | ir_raw_event_handle(serial_ir.rcdev); |
---|
481 | 473 | } |
---|
.. | .. |
---|
536 | 528 | rcdev->min_timeout = 1; |
---|
537 | 529 | rcdev->timeout = IR_DEFAULT_TIMEOUT; |
---|
538 | 530 | rcdev->max_timeout = 10 * IR_DEFAULT_TIMEOUT; |
---|
539 | | - rcdev->rx_resolution = 250000; |
---|
| 531 | + rcdev->rx_resolution = 250; |
---|
540 | 532 | |
---|
541 | 533 | serial_ir.rcdev = rcdev; |
---|
542 | 534 | |
---|
.. | .. |
---|
555 | 547 | |
---|
556 | 548 | /* Reserve io region. */ |
---|
557 | 549 | if ((iommap && |
---|
558 | | - (devm_request_mem_region(&dev->dev, iommap, 8 << ioshift, |
---|
| 550 | + (devm_request_mem_region(&dev->dev, iommap, 8UL << ioshift, |
---|
559 | 551 | KBUILD_MODNAME) == NULL)) || |
---|
560 | 552 | (!iommap && (devm_request_region(&dev->dev, io, 8, |
---|
561 | 553 | KBUILD_MODNAME) == NULL))) { |
---|