int hs_notify_key_irq(void)
{
	int adc = 0;
	int key_code = HS_MGR_KEY_INVALID;

	if (hi->hs_35mm_type == HEADSET_INDICATOR) {
		HS_LOG("Not support remote control");
		return 1;
	}

	if (!hs_mgr_notifier.remote_adc || !hs_mgr_notifier.remote_keycode) {
		HS_LOG("Failed to get remote key code");
		return 1;
	}

	if (hs_hpin_stable()) {
		mdelay(40);
		hs_mgr_notifier.remote_adc(&adc);
		key_code = hs_mgr_notifier.remote_keycode(adc);
		hs_notify_key_event(key_code);
	} else if (hi->hs_35mm_type == HEADSET_NO_MIC ||
		   hi->hs_35mm_type == HEADSET_UNKNOWN_MIC) {
		HS_LOG("IGNORE key IRQ (Unstable HPIN)");
		update_mic_status(HS_DEF_MIC_DETECT_COUNT);
	}

	return 1;
}
int hs_notify_key_event(int key_code)
{
	struct button_work *work;

	HS_DBG();

	if (hi->hs_35mm_type == HEADSET_UNKNOWN_MIC ||
	    hi->hs_35mm_type == HEADSET_NO_MIC ||
	    hi->h2w_35mm_type == HEADSET_NO_MIC)
		update_mic_status(HS_DEF_MIC_DETECT_COUNT);
	else if (!hs_hpin_stable()) {
		HS_LOG("The HPIN is unstable, SKIP THE BUTTON EVENT.");
		return 1;
	} else {
		work = kzalloc(sizeof(struct button_work), GFP_KERNEL);
		if (!work) {
			HS_ERR("Failed to allocate button memory");
			return 1;
		}
		work->key_code = key_code;
		INIT_DELAYED_WORK(&work->key_work, button_35mm_work_func);
		queue_delayed_work(button_wq, &work->key_work,
				   HS_JIFFIES_BUTTON);
	}

	return 1;
}
void headset_button_event(int is_press, int type)
{
	HS_DBG();

	if (hi->hs_35mm_type == HEADSET_UNPLUG &&
	    hi->h2w_35mm_type == HEADSET_UNPLUG) {
		HS_LOG("IGNORE key %d (HEADSET_UNPLUG)", type);
		return;
	}

	if (!hs_hpin_stable()) {
		HS_LOG("IGNORE key %d (Unstable HPIN)", type);
		return;
	}

	if (!get_mic_state()) {
		HS_LOG("IGNORE key %d (Not support MIC)", type);
		return;
	}

	if (!is_press)
		button_released(type);
	else if (!atomic_read(&hi->btn_state))
		button_pressed(type);
}
示例#4
0
int hs_notify_key_event(int key_code)
{

	int uart_key;
	HS_DBG();

	if (hi->hs_35mm_type == HEADSET_UNKNOWN_MIC ||
	    hi->hs_35mm_type == HEADSET_NO_MIC ||
	    hi->h2w_35mm_type == HEADSET_NO_MIC)
		update_mic_status(HS_DEF_MIC_DETECT_COUNT);
	else if (hi->hs_35mm_type == HEADSET_UNSTABLE)
		update_mic_status(0);
	else if (!hs_hpin_stable()) {
		HS_LOG("The HPIN is unstable, SKIP THE BUTTON EVENT.");
		return 1;
	} else {
		/*run one-wire button work function if the project support one-wire detection*/
		if(hi->detect_type == HEADSET_1WIRE && hi->pdata.enable_1wire){
			uart_key = button_1wire_work_func();
			if(uart_key!=99)
				key_code = uart_key;	
		}

		if(key_event_flag == (HS_BUTTON_EVENT_QUEUE-1))
			key_event_flag = -1;
		key_event_flag++;
		HS_DBG("key_event_flag = %d",key_event_flag);
		key_event[key_event_flag]->key_code = key_code;
		INIT_DELAYED_WORK(&key_event[key_event_flag]->key_work, button_35mm_work_func);
		queue_delayed_work(button_wq, &key_event[key_event_flag]->key_work,
				   HS_JIFFIES_BUTTON);
	}

	return 1;
}
int hs_notify_key_event(int key_code)
{


	HS_DBG();

	if (hi->hs_35mm_type == HEADSET_UNKNOWN_MIC ||
	    hi->hs_35mm_type == HEADSET_NO_MIC ||
	    hi->h2w_35mm_type == HEADSET_NO_MIC)
		update_mic_status(HS_DEF_MIC_DETECT_COUNT);
	else if (hi->hs_35mm_type == HEADSET_UNSTABLE)
		update_mic_status(0);
	else if (!hs_hpin_stable()) {
		HS_LOG("The HPIN is unstable, SKIP THE BUTTON EVENT.");
		return 1;
	} else {
		if(key_event_flag == (HS_BUTTON_EVENT_QUEUE-1))
			key_event_flag = -1;
		key_event_flag++;
		HS_LOG("key_event_flag = %d",key_event_flag);
		key_event[key_event_flag]->key_code = key_code;
		INIT_DELAYED_WORK(&key_event[key_event_flag]->key_work, button_35mm_work_func);
		queue_delayed_work(button_wq, &key_event[key_event_flag]->key_work,
				   HS_JIFFIES_BUTTON);
	}

	return 1;
}
示例#6
0
int hs_notify_key_event(int key_code)
{
    struct button_work *work;

    HS_DBG();

    if (hi->ext_35mm_status == HTC_35MM_UNKNOWN_MIC ||
            hi->ext_35mm_status == HTC_35MM_NO_MIC ||
            hi->h2w_35mm_status == HTC_35MM_NO_MIC) {
        HS_LOG("MIC re-detection");
        cancel_delayed_work_sync(&mic_detect_work);
        hi->mic_detect_counter = HS_DEF_MIC_DETECT_COUNT;
        queue_delayed_work(detect_wq, &mic_detect_work,
                           HS_JIFFIES_MIC_DETECT);
    } else if (!hs_hpin_stable()) {
        HS_LOG("The HPIN is unstable, SKIP THE BUTTON EVENT.");
        return 1;
    } else {
        work = kzalloc(sizeof(struct button_work), GFP_KERNEL);
        if (!work) {
            HS_ERR("Failed to allocate button memory");
            return 1;
        }
        work->key_code = key_code;
        INIT_DELAYED_WORK(&work->key_work, button_35mm_work_func);
        queue_delayed_work(button_wq, &work->key_work,
                           HS_JIFFIES_BUTTON);
    }

    return 1;
}
void headset_button_event(int is_press, int type)
{
	HS_DBG();

	if (!hs_hpin_stable()) {
		HS_LOG("The HPIN is unstable, SKIP THE BUTTON EVENT.");
		return;
	}

	if (!is_press)
		button_released(type);
	else if (!atomic_read(&hi->btn_state))
		button_pressed(type);
}
示例#8
0
int hs_notify_key_event(int key_code)
{
	struct button_work *work;
	int ret;

	HS_DBG();

	if (pre_key_work) {
		ret = cancel_delayed_work_sync(pre_key_work);
		if (ret)
			HS_LOG("Previous key code cancelled");
	}
	if (hi->hs_35mm_type == HEADSET_INDICATOR) {
		HS_LOG("Not support remote control");
		return 1;
	}

	if (hi->hs_35mm_type == HEADSET_UNKNOWN_MIC ||
	    hi->hs_35mm_type == HEADSET_NO_MIC ||
	    hi->h2w_35mm_type == HEADSET_NO_MIC)
		update_mic_status(HS_DEF_MIC_DETECT_COUNT);
	else if (hi->hs_35mm_type == HEADSET_UNSTABLE)
		update_mic_status(0);
	else if (!hs_hpin_stable()) {
		HS_LOG("IGNORE key %d (Unstable HPIN)", key_code);
		return 1;
	} else if (hi->hs_35mm_type == HEADSET_UNPLUG && hi->is_ext_insert == 1) {
		HS_LOG("MIC status is changed from float, re-polling to decide accessory type");
		update_mic_status(HS_DEF_MIC_DETECT_COUNT);
		return 1;
	} else {
		work = kzalloc(sizeof(struct button_work), GFP_KERNEL);
		if (!work) {
			HS_ERR("Failed to allocate button memory");
			return 1;
		}
		work->key_code = key_code;
		INIT_DELAYED_WORK(&work->key_work, button_35mm_work_func);
		pre_key_work = &work->key_work;
		if (hi->pdata.driver_flag & DRIVER_HS_MGR_OLD_AJ) {
			queue_delayed_work(button_wq, &work->key_work,
					   HS_JIFFIES_BUTTON_LONG);
		} else {
			queue_delayed_work(button_wq, &work->key_work,
					   HS_JIFFIES_BUTTON);
		}
	}

	return 1;
}
示例#9
0
int hs_notify_key_irq(void)
{
	int adc = 0;
	int key_code = HS_MGR_KEY_INVALID;

	key_bounce++;

	if (hi->one_wire_mode == 1 && hs_hpin_stable()) {
		wake_lock_timeout(&hi->hs_wake_lock, HS_WAKE_LOCK_TIMEOUT);
		key_code = hs_mgr_notifier.hs_1wire_read_key();
		if (key_code >= 0)
			hs_notify_key_event(key_code);
		return 1;
	}

	if (hi->hs_35mm_type == HEADSET_INDICATOR) {
		HS_LOG("Not support remote control");
		return 1;
	}

	if (!hs_mgr_notifier.remote_adc || !hs_mgr_notifier.remote_keycode) {
		HS_LOG("Failed to get remote key code");
		return 1;
	}

	if (hs_hpin_stable()) {
		hs_mgr_notifier.remote_adc(&adc);
		key_code = hs_mgr_notifier.remote_keycode(adc);
		hs_notify_key_event(key_code);
	} else if (hi->hs_35mm_type == HEADSET_NO_MIC ||
		   hi->hs_35mm_type == HEADSET_UNKNOWN_MIC) {
		HS_LOG("IGNORE key IRQ (Unstable HPIN)");
		update_mic_status(HS_DEF_MIC_DETECT_COUNT);
	}

	return 1;
}
void headset_button_event(int is_press, int type)
{
    HS_DBG();

    if (hi->hs_35mm_type == HEADSET_UNPLUG &&
            hi->h2w_35mm_type == HEADSET_UNPLUG) {
        HS_LOG("IGNORE key %d (HEADSET_UNPLUG)", type);
        return;
    }

    if (!hs_hpin_stable()) {
        HS_LOG("The HPIN is unstable, SKIP THE BUTTON EVENT.");
        return;
    }

    if (!is_press)
        button_released(type);
    else if (!atomic_read(&hi->btn_state))
        button_pressed(type);
}