RK3399 kernel driver to achieve a long press key to restore factory settings

Under normal circumstances restore factory settings in the upper Android is relatively simple, you can send broadcast or directly call the appropriate interface, such as write cache / recovery / command file after the restart. OTA upgrade is to write this document. But this also has drawbacks, that is, the system can not be turned into the upper or upper layer freezes can not handle this event.

That we can achieve in the kernel, so long as you can boot to the kernel can handle, RK platform will restore the factory settings at first boot time, the principle is misc That file has a boot-recovery recovery --wipe_all, restore factory after setting misc empty partition, the next boot will not enter the recovery. We can use this principle to achieve.

The first step to achieve long press function keys

GPIO and ADC are the key principles in the drive inside to do image stabilization (ie the period of delay), we use this principle to count, how long after the trigger is pressed to restore factory settings.

#define DEBOUNCE_JIFFIES	(10 / (MSEC_PER_SEC / HZ))	/* 10ms */
#define ADC_SAMPLE_JIFFIES	(100 / (MSEC_PER_SEC / HZ))	/* 100ms */
#define WAKE_LOCK_JIFFIES	(1 * HZ)			/* 1s */

+  #define LONG_PRESS_TIMES 1000 //10s = DEBOUNCE_JIFFIES*1000 ms
+  unsigned int resetKey_press = 0;


static void keys_timer(unsigned long _data)
{
	struct rk_keys_button *button = (struct rk_keys_button *)_data;
	struct rk_keys_drvdata *pdata = dev_get_drvdata(button->dev);
	struct input_dev *input = pdata->input;
	int state;
	//char *cmd_buf;
	
	if (button->ty

Guess you like

Origin blog.csdn.net/u013463707/article/details/102814479