mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-11-01 02:21:16 +00:00
ASoc: wcd: mbhc: Add key code assignment function
Add key code assignment function in mbhc driver. Need to assign keycode from machine driver if required. CRs-Fixed: 847625 Change-Id: Ifcc433532c9b99132c7627205d6a9af4e144a30b Signed-off-by: Walter Yang <yandongy@codeaurora.org>
This commit is contained in:
parent
bafa8ed2c0
commit
f6b07a45c7
2 changed files with 65 additions and 1 deletions
|
@ -4536,6 +4536,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)
|
||||
{
|
||||
|
@ -4559,6 +4617,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);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* 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);
|
||||
|
|
Loading…
Reference in a new issue