Bug on LED mode


#1

@terry
Hi!

Khadas has 4 mode LED:

private static final int INDEX_BREATHE = 0;
private static final int INDEX_HEARTBEAT = 1;
private static final int INDEX_ON = 2;
private static final int INDEX_OFF = 3;

In deep sleep mode LED is on if I use BREATHE or HEARTBEAT or ON. May be it is normal.
But if I use LED OFF mode, LED is off in deep sleep too - It is good, but LED is ON automatically after resuming from sleep, but LED OFF mode use on the settings!

How to fix it?


#2

You can refer to the following modifications.

diff --git a/drivers/amlogic/led/led_sys.c b/drivers/amlogic/led/led_sys.c
index 9475ef4..a8dcf2d 100644
--- a/drivers/amlogic/led/led_sys.c
+++ b/drivers/amlogic/led/led_sys.c
@@ -36,6 +36,7 @@
 #define AML_DEV_NAME           "sysled"
 #define AML_LED_NAME           "led-sys"
 
+extern int led_on_off_state;
 
 static void aml_sysled_output_setup(struct aml_sysled_dev *ldev,
                                enum led_brightness value)
@@ -191,7 +192,10 @@ static int aml_sysled_resume(struct platform_device *pdev)
 {
        struct aml_sysled_dev *ldev = platform_get_drvdata(pdev);
        /* set led on */
-       aml_sysled_output_setup(ldev, 1);
+       if (led_on_off_state == 1)
+               aml_sysled_output_setup(ldev, 1);
+       else
+               aml_sysled_output_setup(ldev, 0);
        pr_info("module resume ok\n");
        return 0;
 }
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index e387f41..8e2ceba 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -29,6 +29,8 @@
 static DECLARE_RWSEM(triggers_list_lock);
 static LIST_HEAD(trigger_list);
 
+int led_on_off_state = 0;
+
  /* Used by LED Class */
 
 ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr,
@@ -109,6 +111,10 @@ void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
        name = trig ? trig->name : "none";
        event = kasprintf(GFP_KERNEL, "TRIGGER=%s", name);
 
+       if (!strcmp(trig->name, "default-on"))
+               led_on_off_state = 1;
+       else
+               led_on_off_state = 0;
        /* Remove any existing trigger */
        if (led_cdev->trigger) {
                write_lock_irqsave(&led_cdev->trigger->leddev_list_lock, flags);
diff --git a/drivers/leds/trigger/ledtrig-off.c b/drivers/leds/trigger/ledtrig-off.c