Commit 404e770a authored by Stefan Binding's avatar Stefan Binding Committed by Takashi Iwai

ALSA: hda/cs8409: Add Support to disable jack type detection for CS42L42

Some hardware configurations do not support jack type detection.
Instead, for those configurations, only tip detection is supported.
Signed-off-by: default avatarStefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: default avatarVitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-21-vitalyr@opensource.cirrus.comSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent c076e201
......@@ -246,6 +246,7 @@ struct sub_codec cs8409_cs42l42_codec = {
.mic_jack_in = 0,
.paged = 1,
.suspended = 1,
.no_type_dect = 0,
};
/******************************************************************************
......
......@@ -559,6 +559,39 @@ static void cs42l42_run_jack_detect(struct sub_codec *cs42l42)
usleep_range(10000, 25000);
}
static int cs42l42_handle_tip_sense(struct sub_codec *cs42l42, unsigned int reg_ts_status)
{
int status_changed = 0;
/* TIP_SENSE INSERT/REMOVE */
switch (reg_ts_status) {
case CS42L42_JACK_INSERTED:
if (!cs42l42->hp_jack_in) {
if (cs42l42->no_type_dect) {
status_changed = 1;
cs42l42->hp_jack_in = 1;
cs42l42->mic_jack_in = 0;
} else {
cs42l42_run_jack_detect(cs42l42);
}
}
break;
case CS42L42_JACK_REMOVED:
if (cs42l42->hp_jack_in || cs42l42->mic_jack_in) {
status_changed = 1;
cs42l42->hp_jack_in = 0;
cs42l42->mic_jack_in = 0;
}
break;
default:
/* jack in transition */
break;
}
return status_changed;
}
static int cs42l42_jack_unsol_event(struct sub_codec *cs42l42)
{
int status_changed = 0;
......@@ -583,10 +616,13 @@ static int cs42l42_jack_unsol_event(struct sub_codec *cs42l42)
cs8409_i2c_write(cs42l42, 0x131b, 0xFF);
type = ((reg_hs_status & CS42L42_HSTYPE_MASK) + 1);
/* CS42L42 reports optical jack as type 4
* We don't handle optical jack
*/
if (type != 4) {
if (cs42l42->no_type_dect) {
status_changed = cs42l42_handle_tip_sense(cs42l42, reg_ts_status);
} else if (type == 4) {
/* Type 4 not supported */
status_changed = cs42l42_handle_tip_sense(cs42l42, CS42L42_JACK_REMOVED);
} else {
if (!cs42l42->hp_jack_in) {
status_changed = 1;
cs42l42->hp_jack_in = 1;
......@@ -596,37 +632,11 @@ static int cs42l42_jack_unsol_event(struct sub_codec *cs42l42)
status_changed = 1;
cs42l42->mic_jack_in = 1;
}
} else {
if (cs42l42->hp_jack_in || cs42l42->mic_jack_in) {
status_changed = 1;
cs42l42->hp_jack_in = 0;
cs42l42->mic_jack_in = 0;
}
}
/* Re-Enable Tip Sense Interrupt */
cs8409_i2c_write(cs42l42, 0x1320, 0xF3);
} else {
/* TIP_SENSE INSERT/REMOVE */
switch (reg_ts_status) {
case CS42L42_JACK_INSERTED:
cs42l42_run_jack_detect(cs42l42);
break;
case CS42L42_JACK_REMOVED:
if (cs42l42->hp_jack_in || cs42l42->mic_jack_in) {
status_changed = 1;
cs42l42->hp_jack_in = 0;
cs42l42->mic_jack_in = 0;
}
break;
default:
/* jack in transition */
status_changed = 0;
break;
}
status_changed = cs42l42_handle_tip_sense(cs42l42, reg_ts_status);
}
return status_changed;
......
......@@ -285,6 +285,7 @@ struct sub_codec {
unsigned int last_page;
unsigned int hsbias_hiz;
unsigned int full_scale_vol:1;
unsigned int no_type_dect:1;
s8 vol[CS42L42_VOLUMES];
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment