forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/drivers/media/rc/winbond-cir.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * winbond-cir.c - Driver for the Consumer IR functionality of Winbond
34 * SuperI/O chips.
....@@ -24,16 +25,6 @@
2425 * o IR Transmit
2526 * o Wake-On-CIR functionality
2627 * o Carrier detection
27
- *
28
- * This program is free software; you can redistribute it and/or modify
29
- * it under the terms of the GNU General Public License as published by
30
- * the Free Software Foundation; either version 2 of the License, or
31
- * (at your option) any later version.
32
- *
33
- * This program is distributed in the hope that it will be useful,
34
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
35
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36
- * GNU General Public License for more details.
3728 */
3829
3930 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
....@@ -322,11 +313,11 @@
322313 inb(data->ebase + WBCIR_REG_ECEIR_CNT_HI) << 8;
323314
324315 if (counter > 0 && counter < 0xffff) {
325
- DEFINE_IR_RAW_EVENT(ev);
326
-
327
- ev.carrier_report = 1;
328
- ev.carrier = DIV_ROUND_CLOSEST(counter * 1000000u,
329
- data->pulse_duration);
316
+ struct ir_raw_event ev = {
317
+ .carrier_report = 1,
318
+ .carrier = DIV_ROUND_CLOSEST(counter * 1000000u,
319
+ data->pulse_duration)
320
+ };
330321
331322 ir_raw_event_store(data->dev, &ev);
332323 }
....@@ -362,8 +353,7 @@
362353 wbcir_irq_rx(struct wbcir_data *data, struct pnp_dev *device)
363354 {
364355 u8 irdata;
365
- DEFINE_IR_RAW_EVENT(rawir);
366
- unsigned duration;
356
+ struct ir_raw_event rawir = {};
367357
368358 /* Since RXHDLEV is set, at least 8 bytes are in the FIFO */
369359 while (inb(data->sbase + WBCIR_REG_SP3_LSR) & WBCIR_RX_AVAIL) {
....@@ -371,13 +361,12 @@
371361 if (data->rxstate == WBCIR_RXSTATE_ERROR)
372362 continue;
373363
374
- duration = ((irdata & 0x7F) + 1) *
364
+ rawir.duration = ((irdata & 0x7F) + 1) *
375365 (data->carrier_report_enabled ? 2 : 10);
376366 rawir.pulse = irdata & 0x80 ? false : true;
377
- rawir.duration = US_TO_NS(duration);
378367
379368 if (rawir.pulse)
380
- data->pulse_duration += duration;
369
+ data->pulse_duration += rawir.duration;
381370
382371 ir_raw_event_store_with_filter(data->dev, &rawir);
383372 }
....@@ -528,7 +517,7 @@
528517
529518 /* Set a higher sampling resolution if carrier reports are enabled */
530519 wbcir_select_bank(data, WBCIR_BANK_2);
531
- data->dev->rx_resolution = US_TO_NS(enable ? 2 : 10);
520
+ data->dev->rx_resolution = enable ? 2 : 10;
532521 outb(enable ? 0x03 : 0x0f, data->sbase + WBCIR_REG_SP3_BGDL);
533522 outb(0x00, data->sbase + WBCIR_REG_SP3_BGDH);
534523
....@@ -1085,7 +1074,7 @@
10851074 data->dev->min_timeout = 1;
10861075 data->dev->timeout = IR_DEFAULT_TIMEOUT;
10871076 data->dev->max_timeout = 10 * IR_DEFAULT_TIMEOUT;
1088
- data->dev->rx_resolution = US_TO_NS(2);
1077
+ data->dev->rx_resolution = 2;
10891078 data->dev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
10901079 data->dev->allowed_wakeup_protocols = RC_PROTO_BIT_NEC |
10911080 RC_PROTO_BIT_NECX | RC_PROTO_BIT_NEC32 | RC_PROTO_BIT_RC5 |