[MTK] 在系统休眠的情况下添加按键(非power键)唤醒功能

文摘 Kernel MediaTek 2020-12-1 阅读:9855

1; /vendor/mediatek/proprietary/trustzone/atf/v1.6/plat/mediatek/mt6768/drivers/spm/mt_spm_sleep.c  

    #define WAKE_SRC_FOR_SUSPEND

    需要确认上面包含了::(WAKE_SRC_R12_KP_IRQ_B)这个唤醒源

2: /device/mediateksample/k68v1_64/mtk-kpd.kl

    key 115   VOLUME_UP //确定有自己的按键定义

3:/kernel-4.14/drivers/input/keyboard/mediatek/kpd.c

作如下修改:

static int kpd_pdrv_suspend(struct platform_device *pdev, pm_message_t state)

463  {

464  kpd_suspend = true;

465  //#ifdef MTK_KP_WAKESOURCE 

#if 1 //改为if 1,去掉call status才能唤醒的功能

466  if (call_status == 2) {

467  kpd_print("kpd_early_suspend wake up source enable!! (%d)\n",

468  kpd_suspend);

469  } else {

470  //kpd_wakeup_src_setting(0);

                 kpd_wakeup_src_setting(1);//改为1;设置1打开keypad唤醒系统的功能

471  kpd_print("kpd_early_suspend wake up source disable!! (%d)\n",

472  kpd_suspend);

473  }

474  #endif

475  kpd_print("suspend!! (%d)\n", kpd_suspend);

476  return 0;

477  }

4;/frameworks/base/core/java/android/view/KeyEvent.java

添加如下:

public static final boolean isWakeKey(int keyCode) {

1935          switch (keyCode) {

1936              case KeyEvent.KEYCODE_BACK:

1937              case KeyEvent.KEYCODE_MENU:

1938              case KeyEvent.KEYCODE_WAKEUP:

1939              case KeyEvent.KEYCODE_PAIRING:

1940              case KeyEvent.KEYCODE_STEM_1:

1941              case KeyEvent.KEYCODE_STEM_2:

1942              case KeyEvent.KEYCODE_STEM_3:

                   case KeyEvent.KEYCODE_VOLUME_UP://add this line 在这个地方有强制认定谁具有唤醒功能

1943                  return true;

1944          }

1945          return false;

1946      }

5:/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java

private boolean isWakeKeyWhenScreenOff(int keyCode) {

4165          switch (keyCode) {

4166              // ignore volume keys unless docked

4167              //case KeyEvent.KEYCODE_VOLUME_UP://删除这个,去掉对相应key的ignore

4168              case KeyEvent.KEYCODE_VOLUME_DOWN:

4169              case KeyEvent.KEYCODE_VOLUME_MUTE:

4170                  return mDefaultDisplayPolicy.getDockMode() != Intent.EXTRA_DOCK_STATE_UNDOCKED;

0条评论

© 2024 芯缘异码. Powered by Typecho