hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/media/rc/nuvoton-cir.c
....@@ -74,13 +74,6 @@
7474 nvt_cr_write(nvt, tmp, reg);
7575 }
7676
77
-/* clear config register bit without changing other bits */
78
-static inline void nvt_clear_reg_bit(struct nvt_dev *nvt, u8 val, u8 reg)
79
-{
80
- u8 tmp = nvt_cr_read(nvt, reg) & ~val;
81
- nvt_cr_write(nvt, tmp, reg);
82
-}
83
-
8477 /* enter extended function mode */
8578 static inline int nvt_efm_enable(struct nvt_dev *nvt)
8679 {
....@@ -230,10 +223,10 @@
230223 for (i = 0; i < fifo_len; i++) {
231224 duration = nvt_cir_wake_reg_read(nvt, CIR_WAKE_RD_FIFO_ONLY);
232225 duration = (duration & BUF_LEN_MASK) * SAMPLE_PERIOD;
233
- buf_len += snprintf(buf + buf_len, PAGE_SIZE - buf_len,
226
+ buf_len += scnprintf(buf + buf_len, PAGE_SIZE - buf_len,
234227 "%d ", duration);
235228 }
236
- buf_len += snprintf(buf + buf_len, PAGE_SIZE - buf_len, "\n");
229
+ buf_len += scnprintf(buf + buf_len, PAGE_SIZE - buf_len, "\n");
237230
238231 spin_unlock_irqrestore(&nvt->lock, flags);
239232
....@@ -631,30 +624,6 @@
631624 return carrier;
632625 }
633626 #endif
634
-/*
635
- * set carrier frequency
636
- *
637
- * set carrier on 2 registers: CP & CC
638
- * always set CP as 0x81
639
- * set CC by SPEC, CC = 3MHz/carrier - 1
640
- */
641
-static int nvt_set_tx_carrier(struct rc_dev *dev, u32 carrier)
642
-{
643
- struct nvt_dev *nvt = dev->priv;
644
- u16 val;
645
-
646
- if (carrier == 0)
647
- return -EINVAL;
648
-
649
- nvt_cir_reg_write(nvt, 1, CIR_CP);
650
- val = 3000000 / (carrier) - 1;
651
- nvt_cir_reg_write(nvt, val & 0xff, CIR_CC);
652
-
653
- nvt_dbg("cp: 0x%x cc: 0x%x\n",
654
- nvt_cir_reg_read(nvt, CIR_CP), nvt_cir_reg_read(nvt, CIR_CC));
655
-
656
- return 0;
657
-}
658627
659628 static int nvt_ir_raw_set_wakeup_filter(struct rc_dev *dev,
660629 struct rc_scancode_filter *sc_filter)
....@@ -684,8 +653,7 @@
684653
685654 /* Inspect the ir samples */
686655 for (i = 0, count = 0; i < ret && count < WAKEUP_MAX_SIZE; ++i) {
687
- /* NS to US */
688
- val = DIV_ROUND_UP(raw[i].duration, 1000L) / SAMPLE_PERIOD;
656
+ val = raw[i].duration / SAMPLE_PERIOD;
689657
690658 /* Split too large values into several smaller ones */
691659 while (val > 0 && count < WAKEUP_MAX_SIZE) {
....@@ -737,7 +705,7 @@
737705 */
738706 static void nvt_process_rx_ir_data(struct nvt_dev *nvt)
739707 {
740
- DEFINE_IR_RAW_EVENT(rawir);
708
+ struct ir_raw_event rawir = {};
741709 u8 sample;
742710 int i;
743711
....@@ -752,8 +720,7 @@
752720 sample = nvt->buf[i];
753721
754722 rawir.pulse = ((sample & BUF_PULSE_BIT) != 0);
755
- rawir.duration = US_TO_NS((sample & BUF_LEN_MASK)
756
- * SAMPLE_PERIOD);
723
+ rawir.duration = (sample & BUF_LEN_MASK) * SAMPLE_PERIOD;
757724
758725 nvt_dbg("Storing %s with duration %d",
759726 rawir.pulse ? "pulse" : "space", rawir.duration);
....@@ -1022,7 +989,6 @@
1022989 rdev->encode_wakeup = true;
1023990 rdev->open = nvt_open;
1024991 rdev->close = nvt_close;
1025
- rdev->s_tx_carrier = nvt_set_tx_carrier;
1026992 rdev->s_wakeup_filter = nvt_ir_raw_set_wakeup_filter;
1027993 rdev->device_name = "Nuvoton w836x7hg Infrared Remote Transceiver";
1028994 rdev->input_phys = "nuvoton/cir0";
....@@ -1032,9 +998,9 @@
1032998 rdev->input_id.version = nvt->chip_minor;
1033999 rdev->driver_name = NVT_DRIVER_NAME;
10341000 rdev->map_name = RC_MAP_RC6_MCE;
1035
- rdev->timeout = MS_TO_NS(100);
1001
+ rdev->timeout = MS_TO_US(100);
10361002 /* rx resolution is hardwired to 50us atm, 1, 25, 100 also possible */
1037
- rdev->rx_resolution = US_TO_NS(CIR_SAMPLE_PERIOD);
1003
+ rdev->rx_resolution = CIR_SAMPLE_PERIOD;
10381004 #if 0
10391005 rdev->min_timeout = XYZ;
10401006 rdev->max_timeout = XYZ;