IR Sensor Data Access for Khadas VIM3

Hello everyone,

For research porposes, I’m trying to access raw data originated from the IR receiver (as Android app). I’ve reviewed the documentation but couldn’t find a way to access raw IR sensor data through the provided APIs.
Has anyone done this? Do you think this is possible on this device or does it require API adjustments?

Thank you for your time and assistance.

There are two ways to read raw data on IR Receiver on VIM3:

  1. Turn on the debug switch of ir
echo 1 > /sys/class/remote/amremote/debug_enable

After turning on debug, the serial port using the infrared receiver will print as shown below:

receive scancode=0x1d That israw data

2.Add receive_scancode node for easy reading

xiong@server:/users/xiong/work/amlogic/vim3/vim3_64bit/common$ git show 
commit d0f1f4fb62e0cb9b210897b6816e68b2f78e673d (HEAD -> khadas-vim3-p-64bit)
Author: Xiong Zhang <>
Date:   2023-09-12 14:23:22 +0800

    IR: Add receive_scancode node to obtain raw data on IR Receiver
    Signed-off-by: Xiong Zhang <>

diff --git a/drivers/amlogic/input/remote/remote_meson.c b/drivers/amlogic/input/remote/remote_meson.c
index 9cc0492cddf0..95c1b5f628fa 100644
--- a/drivers/amlogic/input/remote/remote_meson.c
+++ b/drivers/amlogic/input/remote/remote_meson.c
@@ -344,6 +344,7 @@ static void amlremote_tasklet(unsigned long data)
        if (chip->ir_contr[chip->ir_work].get_decode_status)
                status = chip->ir_contr[chip->ir_work].get_decode_status(chip);
        if (status == REMOTE_NORMAL) {
+               chip->receive_scancode = scancode;  //Assign scancode to the new node variable
                remote_dbg(chip->dev, "receive scancode=0x%x\n", scancode);
                remote_keydown(chip->r_dev, scancode, status);
        } else if (status & REMOTE_REPEAT) {
diff --git a/drivers/amlogic/input/remote/remote_meson.h b/drivers/amlogic/input/remote/remote_meson.h
index aa7538a74582..26aff7f4dc8b 100644
--- a/drivers/amlogic/input/remote/remote_meson.h
+++ b/drivers/amlogic/input/remote/remote_meson.h
@@ -117,6 +117,7 @@ struct remote_chip {
        struct cdev chrdev;
        struct mutex  file_lock;
        spinlock_t slock;
+       int receive_scancode;
        bool debug_enable;
        bool repeat_enable;
diff --git a/drivers/amlogic/input/remote/sysfs.c b/drivers/amlogic/input/remote/sysfs.c
index 03e8b887b4a2..4d33bb085bd2 100644
--- a/drivers/amlogic/input/remote/sysfs.c
+++ b/drivers/amlogic/input/remote/sysfs.c
@@ -481,6 +481,13 @@ static ssize_t use_fifo_store(struct device *dev, struct device_attribute *attr,
        return count;
+static ssize_t receive_scancode_show(struct device *dev,
+                               struct device_attribute *attr, char *buf)
+       struct remote_chip *chip = dev_get_drvdata(dev);
+       return sprintf(buf, "0x%x\n", chip->receive_scancode);
@@ -494,6 +501,7 @@ DEVICE_ATTR_RW(keymap);
 static struct attribute *remote_attrs[] = {
@@ -509,6 +517,7 @@ static struct attribute *remote_attrs[] = {
+       &dev_attr_receive_scancode.attr,

Follow the code provided above and rebuild the Android firmware, add the receive_scancode node, and use the following adb command to read it

cat /sys/class/remote/amremote/receive_scancode

as the picture shows:

The displayed 0x1d is raw data


Thank you @xiong.zhang , it’s very helpful.