Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 21634ca0 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ASoc: wcd: mbhc: Add key code assignment function"

parents c2390126 37444fc4
Loading
Loading
Loading
Loading
+62 −0
Original line number Diff line number Diff line
@@ -4544,6 +4544,64 @@ static void wcd9xxx_cleanup_debugfs(struct wcd9xxx_mbhc *mbhc)
}
#endif

int wcd9xxx_mbhc_set_keycode(struct wcd9xxx_mbhc *mbhc)
{
	enum snd_jack_types type;
	int i, ret, result = 0;
	int *btn_key_code;

	btn_key_code = mbhc->mbhc_cfg->key_code;

	for (i = 0 ; i < 8 ; i++) {
		if (btn_key_code[i] != 0) {
			switch (i) {
			case 0:
				type = SND_JACK_BTN_0;
				break;
			case 1:
				type = SND_JACK_BTN_1;
				break;
			case 2:
				type = SND_JACK_BTN_2;
				break;
			case 3:
				type = SND_JACK_BTN_3;
				break;
			case 4:
				type = SND_JACK_BTN_4;
				break;
			case 5:
				type = SND_JACK_BTN_5;
				break;
			case 6:
				type = SND_JACK_BTN_6;
				break;
			case 7:
				type = SND_JACK_BTN_7;
				break;
			default:
				WARN_ONCE(1, "Wrong button number:%d\n", i);
				result = -1;
				break;
			}
			ret = snd_jack_set_key(mbhc->button_jack.jack,
					       type,
					       btn_key_code[i]);
			if (ret) {
				pr_err("%s: Failed to set code for %d\n",
					__func__, btn_key_code[i]);
				result = -1;
			}
			input_set_capability(
				mbhc->button_jack.jack->input_dev,
				EV_KEY, btn_key_code[i]);
			pr_debug("%s: set btn%d key code:%d\n", __func__,
				i, btn_key_code[i]);
		}
	}
	return result;
}

int wcd9xxx_mbhc_start(struct wcd9xxx_mbhc *mbhc,
		       struct wcd9xxx_mbhc_config *mbhc_cfg)
{
@@ -4567,6 +4625,10 @@ int wcd9xxx_mbhc_start(struct wcd9xxx_mbhc *mbhc,
	/* Save mbhc config */
	mbhc->mbhc_cfg = mbhc_cfg;

	/* Set btn key code */
	if (wcd9xxx_mbhc_set_keycode(mbhc))
		pr_err("Set btn key code error!!!\n");

	/* Get HW specific mbhc registers' address */
	wcd9xxx_get_mbhc_micbias_regs(mbhc, MBHC_PRIMARY_MIC_MB);

+3 −1
Original line number Diff line number Diff line
/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -275,6 +275,7 @@ struct wcd9xxx_mbhc_config {
	bool use_vddio_meas;
	bool enable_anc_mic_detect;
	enum hw_jack_type hw_jack_type;
	int key_code[8];
};

struct wcd9xxx_cfilt_mode {
@@ -470,6 +471,7 @@ struct wcd9xxx_mbhc {
	    (cfg_ptr->_n_rload * \
	     (sizeof(cfg_ptr->_rload[0]) + sizeof(cfg_ptr->_alpha[0]))))

int wcd9xxx_mbhc_set_keycode(struct wcd9xxx_mbhc *mbhc);
int wcd9xxx_mbhc_start(struct wcd9xxx_mbhc *mbhc,
		       struct wcd9xxx_mbhc_config *mbhc_cfg);
void wcd9xxx_mbhc_stop(struct wcd9xxx_mbhc *mbhc);