Nokia N900 >> Native Debian >> Kernel 5.3.0

解決Suspend被音量鍵喚醒的問題


drivers/input/misc/twl4030-pwrbutton.c

int twl4030_pwrbutton_lock=0;
EXPORT_SYMBOL(twl4030_pwrbutton_lock);

static irqreturn_t powerbutton_irq(int irq, void *_pwr)
{
  int err;
  u8 value;
  static u8 pre_value=0;
  struct input_dev *pwr = _pwr;

  err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &value, STS_HW_CONDITIONS);
  if (!err)  {
    pm_wakeup_event(pwr->dev.parent, 0);
    value&= PWR_PWRON_IRQ;
    if ((pre_value == 1) && (value == 0)) {
      twl4030_pwrbutton_lock = !twl4030_pwrbutton_lock;
    }
    pre_value = value;
    input_report_key(pwr, KEY_POWER, value);
    input_sync(pwr);
  } 
  else {
    dev_err(pwr->dev.parent, "twl4030: i2c error %d while reading TWL4030 PM_MASTER STS_HW_CONDITIONS register\n", err);
  }
  return IRQ_HANDLED;
}

drivers/input/keyboard/twl4030_keypad.c

extern int twl4030_pwrbutton_lock;

static irqreturn_t do_kp_irq(int irq, void *_kp)
{
  struct twl4030_keypad *kp = _kp;
  u8 reg;
  int ret;
  
  if (twl4030_pwrbutton_lock) {
    return IRQ_HANDLED;
  }
  
  /* Read & Clear TWL4030 pending interrupt */
  ret = twl4030_kpread(kp, &reg, KEYP_ISR1, 1);

  /*
   * Release all keys if I2C has gone bad or
   * the KEYP has gone to idle state.
   */
  if (ret >= 0 && (reg & KEYP_IMR1_KP))
    twl4030_kp_scan(kp, false);
  else
    twl4030_kp_scan(kp, true);

  return IRQ_HANDLED;
}


返回上一頁