| .. | .. |
|---|
| 74 | 74 | nvt_cr_write(nvt, tmp, reg); |
|---|
| 75 | 75 | } |
|---|
| 76 | 76 | |
|---|
| 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 | | - |
|---|
| 84 | 77 | /* enter extended function mode */ |
|---|
| 85 | 78 | static inline int nvt_efm_enable(struct nvt_dev *nvt) |
|---|
| 86 | 79 | { |
|---|
| .. | .. |
|---|
| 230 | 223 | for (i = 0; i < fifo_len; i++) { |
|---|
| 231 | 224 | duration = nvt_cir_wake_reg_read(nvt, CIR_WAKE_RD_FIFO_ONLY); |
|---|
| 232 | 225 | 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, |
|---|
| 234 | 227 | "%d ", duration); |
|---|
| 235 | 228 | } |
|---|
| 236 | | - buf_len += snprintf(buf + buf_len, PAGE_SIZE - buf_len, "\n"); |
|---|
| 229 | + buf_len += scnprintf(buf + buf_len, PAGE_SIZE - buf_len, "\n"); |
|---|
| 237 | 230 | |
|---|
| 238 | 231 | spin_unlock_irqrestore(&nvt->lock, flags); |
|---|
| 239 | 232 | |
|---|
| .. | .. |
|---|
| 631 | 624 | return carrier; |
|---|
| 632 | 625 | } |
|---|
| 633 | 626 | #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 | | -} |
|---|
| 658 | 627 | |
|---|
| 659 | 628 | static int nvt_ir_raw_set_wakeup_filter(struct rc_dev *dev, |
|---|
| 660 | 629 | struct rc_scancode_filter *sc_filter) |
|---|
| .. | .. |
|---|
| 684 | 653 | |
|---|
| 685 | 654 | /* Inspect the ir samples */ |
|---|
| 686 | 655 | 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; |
|---|
| 689 | 657 | |
|---|
| 690 | 658 | /* Split too large values into several smaller ones */ |
|---|
| 691 | 659 | while (val > 0 && count < WAKEUP_MAX_SIZE) { |
|---|
| .. | .. |
|---|
| 737 | 705 | */ |
|---|
| 738 | 706 | static void nvt_process_rx_ir_data(struct nvt_dev *nvt) |
|---|
| 739 | 707 | { |
|---|
| 740 | | - DEFINE_IR_RAW_EVENT(rawir); |
|---|
| 708 | + struct ir_raw_event rawir = {}; |
|---|
| 741 | 709 | u8 sample; |
|---|
| 742 | 710 | int i; |
|---|
| 743 | 711 | |
|---|
| .. | .. |
|---|
| 752 | 720 | sample = nvt->buf[i]; |
|---|
| 753 | 721 | |
|---|
| 754 | 722 | 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; |
|---|
| 757 | 724 | |
|---|
| 758 | 725 | nvt_dbg("Storing %s with duration %d", |
|---|
| 759 | 726 | rawir.pulse ? "pulse" : "space", rawir.duration); |
|---|
| .. | .. |
|---|
| 1022 | 989 | rdev->encode_wakeup = true; |
|---|
| 1023 | 990 | rdev->open = nvt_open; |
|---|
| 1024 | 991 | rdev->close = nvt_close; |
|---|
| 1025 | | - rdev->s_tx_carrier = nvt_set_tx_carrier; |
|---|
| 1026 | 992 | rdev->s_wakeup_filter = nvt_ir_raw_set_wakeup_filter; |
|---|
| 1027 | 993 | rdev->device_name = "Nuvoton w836x7hg Infrared Remote Transceiver"; |
|---|
| 1028 | 994 | rdev->input_phys = "nuvoton/cir0"; |
|---|
| .. | .. |
|---|
| 1032 | 998 | rdev->input_id.version = nvt->chip_minor; |
|---|
| 1033 | 999 | rdev->driver_name = NVT_DRIVER_NAME; |
|---|
| 1034 | 1000 | rdev->map_name = RC_MAP_RC6_MCE; |
|---|
| 1035 | | - rdev->timeout = MS_TO_NS(100); |
|---|
| 1001 | + rdev->timeout = MS_TO_US(100); |
|---|
| 1036 | 1002 | /* 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; |
|---|
| 1038 | 1004 | #if 0 |
|---|
| 1039 | 1005 | rdev->min_timeout = XYZ; |
|---|
| 1040 | 1006 | rdev->max_timeout = XYZ; |
|---|