Android GPIO方式解码红外数据

1 红外遥控协议
1)NEC协议,采用PWM方式调制。38KHz载波,一般是由引导码+地址码+地址反码+数据+数据反码构成。
2)Philips RC-5协议,采用PPM方式调制

2 设备树配置
Add gpio-ir-recv platform device dts and pinctrl as shown below:
ir: ir-receiver {
        compatible = "gpio-ir-receiver";
        gpios = <&msmgpio 52 1>;
        linux,rc-map-name = "rc-YOUR_DEVICE-nec";
        pinctrl-names = "default";
        pinctrl-0 = <&oem_gpio_ir_pu>;
        oem,disable_ipc;
};

oem_gpio_ir {
       qcom,pins = <&gp 52>;
       qcom,num-grp-pins = <1>;
       qcom,pin-func = <1>;
       label = "oem_gpio_ir";
       oem_gpio_ir_pu: default {
               drive-strength = <16>;
               bias-pull-up;
       };
};

3 Kernel Config
CONFIG_RC_CORE=y
CONFIG_IR_NEC_DECODER=y
CONFIG_MEDIA_RC_SUPPORT=y
CONFIG_IR_GPIO_CIR=y

4 Keys Timeout
4.1  Kernel Hardcode
diff --git a/drivers/media/rc/ir-raw.c b/drivers/media/rc/ir-raw.c
index 5c42750..1be6592 100644
--- a/drivers/media/rc/ir-raw.c
+++ b/drivers/media/rc/ir-raw.c
@@ -116,7 +116,8 @@ int ir_raw_event_store_edge(struct rc_dev *dev, enum raw_eve

        now = ktime_get();
        delta = ktime_to_ns(ktime_sub(now, dev->raw->last_event));
-       delay = MS_TO_NS(dev->input_dev->rep[REP_DELAY]);
+       //delay = MS_TO_NS(dev->input_dev->rep[REP_DELAY]);
+       delay = MS_TO_NS(250); // 500

4.2 Disable Framework Reset Timeout
diff --git
services/inputflinger/EventHub.cpp b/services/inputflinger/EventHub.cpp
index dfe5d3d..c40bd8f 100644
--- a/services/inputflinger/EventHub.cpp
+++ b/services/inputflinger/EventHub.cpp
@@ -1050,6 +1050,7 @@ static const int32_t GAMEPAD_KEYCODES[] = {
 
 status_t EventHub::openDeviceLocked(const char *devicePath) {
     char buffer[80];
+     char oem_cache_devname[80];
 
     ALOGV("Opening device: %s", devicePath);
 
@@ -1067,6 +1068,7 @@ status_t EventHub::openDeviceLocked(const char *devicePath) {
     } else {
         buffer[sizeof(buffer) - 1] = '\0';
         identifier.name.setTo(buffer);
+         strcpy(oem_cache_devname, buffer);
     }
 
     // Check to see if the device is on our excluded list
@@ -1270,9 +1272,11 @@ status_t EventHub::openDeviceLocked(const char *devicePath) {
 
         // Disable kernel key repeat since we handle it ourselves
         unsigned int repeatRate[] = {0,0};
-        if (ioctl(fd, EVIOCSREP, repeatRate)) {
-            ALOGW("Unable to disable kernel key repeat for %s: %s",
-                devicePath, strerror(errno));
-        }
+        if (0 != strcmp(oem_cache_devname, "gpio_ir_recv")) {
+                if (ioctl(fd, EVIOCSREP, repeatRate)) {
+            ALOGW("Unable to disable kernel key repeat for %s: %s",
+                        devicePath, strerror(errno));
+                }
+        }
     }

你可能感兴趣的:(System)