Пример #1
0
static enum hrtimer_restart pmic8058_volume_up_debounce(struct hrtimer *timer)
{
	int code = 0;
	struct pmic8xxx_kp *kp = container_of(timer, struct pmic8xxx_kp,
								volup_hrtimer);

	volup_level[1] = gpio_get_value_cansleep(PM8058_GPIO_PM_TO_SYS(
					PMIC_GPIO_VOLUME_UPKEY));

	if (volup_level[0] == volup_level[1] &&
			volup_pre_state != volup_level[1]){
		volup_pre_state = volup_level[1];

		code = MATRIX_SCAN_CODE((volup_matrix>>8),
				(volup_matrix&0xFF), PM8058_ROW_SHIFT);

#ifndef CONFIG_PRODUCT_SHIP
		printk(KERN_ERR "%s : keycode [%d] %s\n", __func__,
				kp->keycodes[code],
				!volup_level[1] ? "pressed" : "released");
#endif

		input_event(kp->input, EV_MSC, MSC_SCAN, code);
		input_report_key(kp->input, kp->keycodes[code],
					!volup_level[1]);
		input_sync(kp->input);

#if CONFIG_SEC_DEBUG
		sec_debug_check_crash_key(KEY_VOLUMEUP, !volup_level[1]);
#endif
	} else {
Пример #2
0
static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id)
{
	struct gpio_button_data *bdata = dev_id;
#ifdef CONFIG_SEC_DEBUG
	int state = (gpio_get_value(bdata->button->gpio) ? 1 : 0) ^ bdata->button->active_low;
	sec_debug_check_crash_key(bdata->button->code, state);
#endif

	BUG_ON(irq != bdata->irq);

	if (suspend_state) {
		irq_in_suspend = true;
		wakeup_reason = bdata->button->code;
		pr_info("%s before resume by %d\n", __func__, wakeup_reason);
	}

	if (bdata->button->wakeup)
		pm_stay_awake(bdata->input->dev.parent);
	if (bdata->timer_debounce)
		mod_timer(&bdata->timer,
			jiffies + msecs_to_jiffies(bdata->timer_debounce));
	else
		schedule_work(&bdata->work);

	return IRQ_HANDLED;
}
static void __pmic8xxx_kp_scan_matrix(struct pmic8xxx_kp *kp, u16 *new_state,
					 u16 *old_state)
{
	int row, col, code;

	for (row = 0; row < kp->pdata->num_rows; row++) {
		int bits_changed = new_state[row] ^ old_state[row];

		if (!bits_changed)
			continue;

		for (col = 0; col < kp->pdata->num_cols; col++) {
			if (!(bits_changed & (1 << col)))
				continue;

#ifndef CONFIG_PRODUCT_SHIP
			dev_warn(kp->dev, "key [%d:%d] %s\n", row, col,
					!(new_state[row] & (1 << col)) ?
					"pressed" : "released");
#endif
			code = MATRIX_SCAN_CODE(row, col, PM8XXX_ROW_SHIFT);

			input_event(kp->input, EV_MSC, MSC_SCAN, code);
			input_report_key(kp->input,
					kp->keycodes[code],
					!(new_state[row] & (1 << col)));

			input_sync(kp->input);
#if CONFIG_SEC_DEBUG
			sec_debug_check_crash_key(kp->keycodes[code],
					!(new_state[row] & (1 << col)));
#endif
		}
	}
}
Пример #4
0
static int
qpnp_pon_input_dispatch(struct qpnp_pon *pon, u32 pon_type)
{
	int rc;
	struct qpnp_pon_config *cfg = NULL;
	u8 pon_rt_sts = 0, pon_rt_bit = 0;

	cfg = qpnp_get_cfg(pon, pon_type);
	if (!cfg)
		return -EINVAL;

	/* Check if key reporting is supported */
	if (!cfg->key_code)
		return 0;

	/* check the RT status to get the current status of the line */
	rc = spmi_ext_register_readl(pon->spmi->ctrl, pon->spmi->sid,
				QPNP_PON_RT_STS(pon->base), &pon_rt_sts, 1);
	if (rc) {
		dev_err(&pon->spmi->dev, "Unable to read PON RT status\n");
		return rc;
	}

	switch (cfg->pon_type) {
	case PON_KPDPWR:
		pon_rt_bit = QPNP_PON_KPDPWR_N_SET;
		break;
	case PON_RESIN:
		pon_rt_bit = QPNP_PON_RESIN_N_SET;
		break;
	case PON_CBLPWR:
		pon_rt_bit = QPNP_PON_CBLPWR_N_SET;
		break;
	default:
		return -EINVAL;
	}

	input_report_key(pon->pon_input, cfg->key_code,
					(pon_rt_sts & pon_rt_bit));
	input_sync(pon->pon_input);

	if((cfg->key_code == 116) && (pon_rt_sts & pon_rt_bit)){
		pon->powerkey_state = 1;
	}else if((cfg->key_code == 116) && !(pon_rt_sts & pon_rt_bit)){
		pon->powerkey_state = 0;
	}
#if CONFIG_SEC_DEBUG
	sec_debug_check_crash_key(cfg->key_code, pon->powerkey_state);
#endif
#if defined(CONFIG_MACH_MONTBLANC)
	check_pkey_press=pon->powerkey_state;
#endif
	return 0;
}
static irqreturn_t pwrkey_release_irq(int irq, void *_pwrkey)
{
	struct pmic8xxx_pwrkey *pwrkey = _pwrkey;
	pwrkey->powerkey_state = 0;
	input_report_key(pwrkey->pwr, KEY_POWER, 0);
	input_sync(pwrkey->pwr);
#if CONFIG_SEC_DEBUG
	sec_debug_check_crash_key(KEY_POWER, 0);
#endif
	return IRQ_HANDLED;
}
Пример #6
0
static int __pmic8058_kp_scan_matrix(struct pmic8058_kp *kp, u16 *new_state,
					 u16 *old_state)
{
	int row, col, code;

	for (row = 0; row < kp->pdata->num_rows; row++) {
		int bits_changed = new_state[row] ^ old_state[row];

		if (!bits_changed)
			continue;

		for (col = 0; col < kp->pdata->num_cols; col++) {
			if (!(bits_changed & (1 << col)))
				continue;

			dev_dbg(kp->dev, "key [%d:%d] %s\n", row, col,
					!(new_state[row] & (1 << col)) ?
					"pressed" : "released");

			code = MATRIX_SCAN_CODE(row, col, PM8058_ROW_SHIFT);
			input_event(kp->input, EV_MSC, MSC_SCAN, code);
			input_report_key(kp->input,
					kp->keycodes[code],
					!(new_state[row] & (1 << col)));

			input_sync(kp->input);
#if defined (CONFIG_TARGET_LOCALE_USA)
			pr_info("key [%d:%d] %s\n", row, col,
					!(new_state[row] & (1 << col)) ?
					"pressed" : "released");
#else
			pr_info("key [%d:%d] %s keycode [%d]\n", row, col,
					!(new_state[row] & (1 << col)) ?
					"pressed" : "released", kp->keycodes[code]);
#endif

#if defined (CONFIG_TOUCHSCREEN_MELFAS)
#if defined (CONFIG_KOR_MODEL_SHV_E120L) || defined (CONFIG_KOR_MODEL_SHV_E120S) || defined (CONFIG_KOR_MODEL_SHV_E120K) || defined(CONFIG_KOR_MODEL_SHV_E160S) || defined(CONFIG_KOR_MODEL_SHV_E160K) || defined(CONFIG_KOR_MODEL_SHV_E160L)
			if(!(new_state[row] & (1 << col)) && (kp->keycodes[code] == KEY_HOME)){
				TSP_force_released();
			}
#endif
#endif 

#if defined(CONFIG_SEC_DEBUG)
			sec_debug_check_crash_key(kp->keycodes[code], !(new_state[row] & (1 << col)));
#endif
		}
	}

	return 0;
}
static irqreturn_t pwrkey_press_irq(int irq, void *_pwrkey)
{
	struct pmic8xxx_pwrkey *pwrkey = _pwrkey;
	pwrkey->powerkey_state = 1;

	pwrkey_status = true;
	input_report_key(pwrkey->pwr, KEY_POWER, 1);
	input_sync(pwrkey->pwr);
	#if defined(CONFIG_SEC_DEBUG)
	sec_debug_check_crash_key(KEY_POWER, 1);
	#endif

	return IRQ_HANDLED;
}
Пример #8
0
static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata)
{
	const struct gpio_keys_button *button = bdata->button;
	struct input_dev *input = bdata->input;
	unsigned int type = button->type ?: EV_KEY;
	int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low;

#ifdef CONFIG_SEC_DEBUG
	sec_debug_check_crash_key(button->code, state);
#endif
	if (type == EV_ABS) {
		if (state)
			input_event(input, type, button->code, button->value);
	} else {
		input_event(input, type, button->code, !!state);
	}
	input_sync(input);
}
Пример #9
0
static void gpio_keys_report_event(struct gpio_button_data *bdata)
{
	struct gpio_keys_button *button = bdata->button;
	struct input_dev *input = bdata->input;
	unsigned int type = button->type ?: EV_KEY;
	int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^
	button->active_low;
	static int count;

#if CONFIG_SEC_DEBUG
	sec_debug_check_crash_key(button->code, state);
#endif

	if (type == EV_ABS) {
		if (state)
			input_event(input, type, button->code, button->value);
	} else {
		if (button->code == KEY_HOMEPAGE && count == 1) {
			if (!!state) {
				input_event(input, type, button->code,
				!!state);
				button_pressed = 1;
			} else {
					if (button_pressed == 0) {
						button_pressed = 1;
						/*send home key press event to
						input subsytem if release event
						detected before press event */
						input_event(input, type,
						button->code, 1);
					}
					/*send home key release event to input
					subsystem */
					input_event(input, type,
					button->code, 0);
					}
		} else {
			input_event(input, type, button->code, !!state);
			if (button->code == KEY_HOMEPAGE)
				count = 1;
			}
		}
	input_sync(input);
}
static irqreturn_t pmic8058_volume_down_irq(int irq, void *data)
{

	struct pmic8xxx_kp *kp = data;
	static int pre_down_key_state = -1;
	int key_state = 1;
	int code;

	if (!gpio_get_value_cansleep(PM8058_GPIO_PM_TO_SYS(
					PMIC_GPIO_VOLUME_DOWNKEY)))
		key_state = 0;

	code = MATRIX_SCAN_CODE((voldown_matrix>>8),
				(voldown_matrix&0xFF), PM8058_ROW_SHIFT);


	if (pre_down_key_state == key_state && pre_down_key_state != -1 &&
			key_state == 0) {
		key_state = 1;

	#ifndef CONFIG_PRODUCT_SHIP
	printk(KERN_INFO "%s : Fix key state\n", __func__);
	#endif
	}

	pre_down_key_state = key_state;

    #ifndef CONFIG_PRODUCT_SHIP
	printk(KERN_ERR "%s : keycode [%d] %s\n", __func__, kp->keycodes[code],
			!key_state ? "pressed" : "released");
    #endif
	input_event(kp->input, EV_MSC, MSC_SCAN, code);
	input_report_key(kp->input, kp->keycodes[code], !key_state);
	input_sync(kp->input);

#if CONFIG_SEC_DEBUG
	sec_debug_check_crash_key(KEY_VOLUMEDOWN, !key_state);
#endif

	return IRQ_HANDLED;
}
static irqreturn_t pwrkey_press_irq(int irq, void *_pwrkey)
{
	struct pmic8xxx_pwrkey *pwrkey = _pwrkey;

	if (pwrkey->press == true) {
		pwrkey->press = false;
		return IRQ_HANDLED;
	} else {
		pwrkey->press = true;
	}

	pwrkey->powerkey_state = 1;
	if (poweroff_charging)
		wake_lock(&pwrkey->wake_lock);
	input_report_key(pwrkey->pwr, KEY_POWER, 1);
	input_sync(pwrkey->pwr);
#if defined(CONFIG_SEC_DEBUG)
	sec_debug_check_crash_key(KEY_POWER, 1);
#endif
	return IRQ_HANDLED;
}
Пример #12
0
static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id)
{
	struct gpio_button_data *bdata = dev_id;
#ifdef CONFIG_SEC_DEBUG_ISR_CRASH
	int state = (gpio_get_value(bdata->button->gpio) ? 1 : 0) ^ bdata->button->active_low;
#endif

	BUG_ON(irq != bdata->irq);

	if (bdata->button->wakeup)
		pm_stay_awake(bdata->input->dev.parent);
	if (bdata->timer_debounce)
		mod_timer(&bdata->timer,
			jiffies + msecs_to_jiffies(bdata->timer_debounce));
	else
		schedule_work(&bdata->work);

#ifdef CONFIG_SEC_DEBUG_ISR_CRASH
	sec_debug_check_crash_key(bdata->button->code, state);
#endif

	return IRQ_HANDLED;
}
Пример #13
0
static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata)
{
	const struct gpio_keys_button *button = bdata->button;
	struct input_dev *input = bdata->input;
	unsigned int type = button->type ?: EV_KEY;
	int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low;
	/* Workaround - QC code  drivers/platform/msm/qpnp-power-on.c
	   simulate press event in case release event occured
	 * without a press event
	 */
	static int home_old_state;


	if (button->code == KEY_HOMEPAGE) {
		if (!home_old_state && !state && key_irq_state ) {
			pr_info("[KEY] Force press home old state(%d), state(%d)\n", home_old_state, state);
			input_event(input, type, KEY_HOMEPAGE , 1);
			input_sync(input);
		}
		home_old_state = state;
	}
	key_irq_state = 0;
	
	pr_info("[KEY] code(0x%02X), value(%d)\n", button->code, state);
#ifdef CONFIG_SEC_DEBUG
	sec_debug_check_crash_key(button->code, state);
#endif
	
	if (type == EV_ABS) {
		if (state)
			input_event(input, type, button->code, button->value);
	} else {
		input_event(input, type, button->code, !!state);
	}
	input_sync(input);
}