| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Driver for the Conexant CX23885/7/8 PCIe bridge |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * CX23888 Integrated Consumer Infrared Controller |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * Copyright (C) 2009 Andy Walls <awalls@md.metrocast.net> |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is free software; you can redistribute it and/or |
|---|
| 9 | | - * modify it under the terms of the GNU General Public License |
|---|
| 10 | | - * as published by the Free Software Foundation; either version 2 |
|---|
| 11 | | - * of the License, or (at your option) any later version. |
|---|
| 12 | | - * |
|---|
| 13 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 14 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 16 | | - * GNU General Public License for more details. |
|---|
| 17 | 8 | */ |
|---|
| 18 | 9 | |
|---|
| 19 | 10 | #include "cx23885.h" |
|---|
| .. | .. |
|---|
| 184 | 175 | return (u16) d; |
|---|
| 185 | 176 | } |
|---|
| 186 | 177 | |
|---|
| 187 | | -static inline u16 ns_to_clock_divider(unsigned int ns) |
|---|
| 188 | | -{ |
|---|
| 189 | | - return count_to_clock_divider( |
|---|
| 190 | | - DIV_ROUND_CLOSEST(CX23888_IR_REFCLK_FREQ / 1000000 * ns, 1000)); |
|---|
| 191 | | -} |
|---|
| 192 | | - |
|---|
| 193 | | -static inline unsigned int clock_divider_to_ns(unsigned int divider) |
|---|
| 194 | | -{ |
|---|
| 195 | | - /* Period of the Rx or Tx clock in ns */ |
|---|
| 196 | | - return DIV_ROUND_CLOSEST((divider + 1) * 1000, |
|---|
| 197 | | - CX23888_IR_REFCLK_FREQ / 1000000); |
|---|
| 198 | | -} |
|---|
| 199 | | - |
|---|
| 200 | 178 | static inline u16 carrier_freq_to_clock_divider(unsigned int freq) |
|---|
| 201 | 179 | { |
|---|
| 202 | 180 | return count_to_clock_divider( |
|---|
| .. | .. |
|---|
| 206 | 184 | static inline unsigned int clock_divider_to_carrier_freq(unsigned int divider) |
|---|
| 207 | 185 | { |
|---|
| 208 | 186 | return DIV_ROUND_CLOSEST(CX23888_IR_REFCLK_FREQ, (divider + 1) * 16); |
|---|
| 209 | | -} |
|---|
| 210 | | - |
|---|
| 211 | | -static inline u16 freq_to_clock_divider(unsigned int freq, |
|---|
| 212 | | - unsigned int rollovers) |
|---|
| 213 | | -{ |
|---|
| 214 | | - return count_to_clock_divider( |
|---|
| 215 | | - DIV_ROUND_CLOSEST(CX23888_IR_REFCLK_FREQ, freq * rollovers)); |
|---|
| 216 | 187 | } |
|---|
| 217 | 188 | |
|---|
| 218 | 189 | static inline unsigned int clock_divider_to_freq(unsigned int divider, |
|---|
| .. | .. |
|---|
| 548 | 519 | ror = stats & STATS_ROR; /* Rx FIFO Over Run */ |
|---|
| 549 | 520 | |
|---|
| 550 | 521 | tse = irqen & IRQEN_TSE; /* Tx FIFO Service Request IRQ Enable */ |
|---|
| 551 | | - rse = irqen & IRQEN_RSE; /* Rx FIFO Service Reuqest IRQ Enable */ |
|---|
| 522 | + rse = irqen & IRQEN_RSE; /* Rx FIFO Service Request IRQ Enable */ |
|---|
| 552 | 523 | rte = irqen & IRQEN_RTE; /* Rx Pulse Width Timer Time Out IRQ Enable */ |
|---|
| 553 | 524 | roe = irqen & IRQEN_ROE; /* Rx FIFO Over Run IRQ Enable */ |
|---|
| 554 | 525 | |
|---|
| .. | .. |
|---|
| 638 | 609 | events |= V4L2_SUBDEV_IR_RX_END_OF_RX_DETECTED; |
|---|
| 639 | 610 | } |
|---|
| 640 | 611 | if (v) { |
|---|
| 641 | | - /* Clear STATS_ROR & STATS_RTO as needed by reseting hardware */ |
|---|
| 612 | + /* Clear STATS_ROR & STATS_RTO as needed by resetting hardware */ |
|---|
| 642 | 613 | cx23888_ir_write4(dev, CX23888_IR_CNTRL_REG, cntrl & ~v); |
|---|
| 643 | 614 | cx23888_ir_write4(dev, CX23888_IR_CNTRL_REG, cntrl); |
|---|
| 644 | 615 | *handled = true; |
|---|
| .. | .. |
|---|
| 692 | 663 | } |
|---|
| 693 | 664 | |
|---|
| 694 | 665 | v = (unsigned) pulse_width_count_to_ns( |
|---|
| 695 | | - (u16) (p->hw_fifo_data & FIFO_RXTX), divider); |
|---|
| 666 | + (u16)(p->hw_fifo_data & FIFO_RXTX), divider) / 1000; |
|---|
| 696 | 667 | if (v > IR_MAX_DURATION) |
|---|
| 697 | 668 | v = IR_MAX_DURATION; |
|---|
| 698 | 669 | |
|---|
| 699 | | - init_ir_raw_event(&p->ir_core_data); |
|---|
| 700 | | - p->ir_core_data.pulse = u; |
|---|
| 701 | | - p->ir_core_data.duration = v; |
|---|
| 702 | | - p->ir_core_data.timeout = w; |
|---|
| 670 | + p->ir_core_data = (struct ir_raw_event) |
|---|
| 671 | + { .pulse = u, .duration = v, .timeout = w }; |
|---|
| 703 | 672 | |
|---|
| 704 | 673 | v4l2_dbg(2, ir_888_debug, sd, "rx read: %10u ns %s %s\n", |
|---|
| 705 | 674 | v, u ? "mark" : "space", w ? "(timed out)" : ""); |
|---|