Boards doesn't enable camera after 1 min suspend

Which system do you use? Android, Ubuntu, OOWOW or others?

Android

Which version of system do you use? Khadas official images, self built images, or others?

Khadas official images

Please describe your issue below:

I can’t use camera after moving to suspend mode.

How to reproduce:

  1. Open camera app
  2. Enable suspend mode for more then 60 seconds
  3. Disable suspend mode.
  4. Camera will show black screen.

Notes:
After enable suspend mode by pressing power button I’m waiting for 50-60 seconds. After moving to suspend mode my board have power 3.5W. After 50-60 seconds board power drops to 0.6W. When I’m moving out from suspend mode (when I got 0.6W) camera doesn’t turn on.

How can I use camera with board suspend mode?

@Y2Kot You can try to make the system never enter deep hibernation to see and feedback the results,Similar modifications are as follows:

common$ git log -p 
Date:   Sat Aug 1 09:46:09 2020 +0800

    Do not enter deep sleep

diff --git a/drivers/misc/khadas-mcu.c b/drivers/misc/khadas-mcu.c
index 33f95a6..45ff5dd 100755
--- a/drivers/misc/khadas-mcu.c
+++ b/drivers/misc/khadas-mcu.c
@@ -29,7 +29,7 @@
 #include <linux/of_gpio.h>
 #include <linux/amlogic/iomap.h>
 #include "../gpio/gpiolib.h"
-
+#include <linux/wakelock.h>
 
 
 /* Device registers */
@@ -127,6 +127,7 @@ int ageing_test_flag = 0;
 static int gpio_t112_bl_en;
 static int gpio_bl_fan_en;
 static int gpio_cpu_fan_en;
+static struct wake_lock wake_lock_always;
 
 extern void send_power_key(int state);
 extern void realtek_enable_wol(int enable, bool suspend);
@@ -958,6 +959,7 @@ static int mcu_probe(struct i2c_client *client, const struct i2c_device_id *id)
 
        create_mcu_attrs();
        printk("%s,wol enable=%d\n",__func__ ,g_mcu_data->wol_enable);
+       wake_lock_init(&wake_lock_always, WAKE_LOCK_SUSPEND, "wake_lock_always");
 
        if (is_support_wol()) {
                reg[0] = 0x01;
@@ -989,12 +991,14 @@ static int khadas_fan_suspend(struct device *dev)
 {
        cancel_delayed_work(&g_mcu_data->fan_data.work);
        khadas_fan_level_set(&g_mcu_data->fan_data, 0);
+       wake_lock(&wake_lock_always);
 
        return 0;
 }
 
 static int khadas_fan_resume(struct device *dev)
 {
+       wake_unlock(&wake_lock_always);
        khadas_fan_set(&g_mcu_data->fan_data);

@Y2Kot But I think your camera application applies for a lock to prevent the system from entering deep sleep. This method is better. You can refer to this linked document.
https://www.51sjk.com/b36b282198/

@goenjoy do you mean doze mode? I’ve tried to disable doze from system settings and it doesn’t work

@goenjoy I’ve tried this way but after it I got 0.6W after locking immediately

Can you post the modified code and have a look?

@goenjoy khadas-mcu.c · GitHub

@Y2Kot I’ll replace your code and take effect. The system has not entered deep sleep. That’s probably because your compilation didn’t take effect. So is it because you didn’t compile the kernel? Please post the complete compilation process.

@goenjoy yes, my fault. I just rebuild rom. I’ll try to rebuild rom with kernel

after rebuild kernel it works, thanks