提交 f339240d 编写于 作者: T Takashi Iwai

Merge branch 'fix/hda' into for-linus

...@@ -1278,7 +1278,7 @@ static const char * const cs420x_models[CS420X_MODELS] = { ...@@ -1278,7 +1278,7 @@ static const char * const cs420x_models[CS420X_MODELS] = {
[CS420X_MBP53] = "mbp53", [CS420X_MBP53] = "mbp53",
[CS420X_MBP55] = "mbp55", [CS420X_MBP55] = "mbp55",
[CS420X_IMAC27] = "imac27", [CS420X_IMAC27] = "imac27",
[CS420X_IMAC27] = "apple", [CS420X_APPLE] = "apple",
[CS420X_AUTO] = "auto", [CS420X_AUTO] = "auto",
}; };
......
...@@ -277,6 +277,12 @@ static bool alc_dyn_adc_pcm_resetup(struct hda_codec *codec, int cur) ...@@ -277,6 +277,12 @@ static bool alc_dyn_adc_pcm_resetup(struct hda_codec *codec, int cur)
return false; return false;
} }
static inline hda_nid_t get_capsrc(struct alc_spec *spec, int idx)
{
return spec->capsrc_nids ?
spec->capsrc_nids[idx] : spec->adc_nids[idx];
}
/* select the given imux item; either unmute exclusively or select the route */ /* select the given imux item; either unmute exclusively or select the route */
static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx,
unsigned int idx, bool force) unsigned int idx, bool force)
...@@ -303,8 +309,7 @@ static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, ...@@ -303,8 +309,7 @@ static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx,
adc_idx = spec->dyn_adc_idx[idx]; adc_idx = spec->dyn_adc_idx[idx];
} }
nid = spec->capsrc_nids ? nid = get_capsrc(spec, adc_idx);
spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
/* no selection? */ /* no selection? */
num_conns = snd_hda_get_conn_list(codec, nid, NULL); num_conns = snd_hda_get_conn_list(codec, nid, NULL);
...@@ -1058,8 +1063,7 @@ static bool alc_rebuild_imux_for_auto_mic(struct hda_codec *codec) ...@@ -1058,8 +1063,7 @@ static bool alc_rebuild_imux_for_auto_mic(struct hda_codec *codec)
hda_nid_t pin = spec->imux_pins[i]; hda_nid_t pin = spec->imux_pins[i];
int c; int c;
for (c = 0; c < spec->num_adc_nids; c++) { for (c = 0; c < spec->num_adc_nids; c++) {
hda_nid_t cap = spec->capsrc_nids ? hda_nid_t cap = get_capsrc(spec, c);
spec->capsrc_nids[c] : spec->adc_nids[c];
int idx = get_connection_index(codec, cap, pin); int idx = get_connection_index(codec, cap, pin);
if (idx >= 0) { if (idx >= 0) {
imux->items[i].index = idx; imux->items[i].index = idx;
...@@ -1969,10 +1973,8 @@ static int alc_build_controls(struct hda_codec *codec) ...@@ -1969,10 +1973,8 @@ static int alc_build_controls(struct hda_codec *codec)
if (!kctl) if (!kctl)
kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
for (i = 0; kctl && i < kctl->count; i++) { for (i = 0; kctl && i < kctl->count; i++) {
const hda_nid_t *nids = spec->capsrc_nids; err = snd_hda_add_nid(codec, kctl, i,
if (!nids) get_capsrc(spec, i));
nids = spec->adc_nids;
err = snd_hda_add_nid(codec, kctl, i, nids[i]);
if (err < 0) if (err < 0)
return err; return err;
} }
...@@ -2759,8 +2761,7 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec) ...@@ -2759,8 +2761,7 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec)
} }
for (c = 0; c < num_adcs; c++) { for (c = 0; c < num_adcs; c++) {
hda_nid_t cap = spec->capsrc_nids ? hda_nid_t cap = get_capsrc(spec, c);
spec->capsrc_nids[c] : spec->adc_nids[c];
idx = get_connection_index(codec, cap, pin); idx = get_connection_index(codec, cap, pin);
if (idx >= 0) { if (idx >= 0) {
spec->imux_pins[imux->num_items] = pin; spec->imux_pins[imux->num_items] = pin;
...@@ -3706,8 +3707,7 @@ static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin) ...@@ -3706,8 +3707,7 @@ static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
if (!pin) if (!pin)
return 0; return 0;
for (i = 0; i < spec->num_adc_nids; i++) { for (i = 0; i < spec->num_adc_nids; i++) {
hda_nid_t cap = spec->capsrc_nids ? hda_nid_t cap = get_capsrc(spec, i);
spec->capsrc_nids[i] : spec->adc_nids[i];
int idx; int idx;
idx = get_connection_index(codec, cap, pin); idx = get_connection_index(codec, cap, pin);
......
...@@ -208,6 +208,7 @@ struct via_spec { ...@@ -208,6 +208,7 @@ struct via_spec {
/* work to check hp jack state */ /* work to check hp jack state */
struct hda_codec *codec; struct hda_codec *codec;
struct delayed_work vt1708_hp_work; struct delayed_work vt1708_hp_work;
int hp_work_active;
int vt1708_jack_detect; int vt1708_jack_detect;
int vt1708_hp_present; int vt1708_hp_present;
...@@ -305,27 +306,35 @@ enum { ...@@ -305,27 +306,35 @@ enum {
static void analog_low_current_mode(struct hda_codec *codec); static void analog_low_current_mode(struct hda_codec *codec);
static bool is_aa_path_mute(struct hda_codec *codec); static bool is_aa_path_mute(struct hda_codec *codec);
static void vt1708_start_hp_work(struct via_spec *spec) #define hp_detect_with_aa(codec) \
(snd_hda_get_bool_hint(codec, "analog_loopback_hp_detect") == 1 && \
!is_aa_path_mute(codec))
static void vt1708_stop_hp_work(struct via_spec *spec)
{ {
if (spec->codec_type != VT1708 || spec->autocfg.hp_pins[0] == 0) if (spec->codec_type != VT1708 || spec->autocfg.hp_pins[0] == 0)
return; return;
snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81, if (spec->hp_work_active) {
!spec->vt1708_jack_detect); snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81, 1);
if (!delayed_work_pending(&spec->vt1708_hp_work)) cancel_delayed_work_sync(&spec->vt1708_hp_work);
schedule_delayed_work(&spec->vt1708_hp_work, spec->hp_work_active = 0;
msecs_to_jiffies(100)); }
} }
static void vt1708_stop_hp_work(struct via_spec *spec) static void vt1708_update_hp_work(struct via_spec *spec)
{ {
if (spec->codec_type != VT1708 || spec->autocfg.hp_pins[0] == 0) if (spec->codec_type != VT1708 || spec->autocfg.hp_pins[0] == 0)
return; return;
if (snd_hda_get_bool_hint(spec->codec, "analog_loopback_hp_detect") == 1 if (spec->vt1708_jack_detect &&
&& !is_aa_path_mute(spec->codec)) (spec->active_streams || hp_detect_with_aa(spec->codec))) {
return; if (!spec->hp_work_active) {
snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81, snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81, 0);
!spec->vt1708_jack_detect); schedule_delayed_work(&spec->vt1708_hp_work,
cancel_delayed_work_sync(&spec->vt1708_hp_work); msecs_to_jiffies(100));
spec->hp_work_active = 1;
}
} else if (!hp_detect_with_aa(spec->codec))
vt1708_stop_hp_work(spec);
} }
static void set_widgets_power_state(struct hda_codec *codec) static void set_widgets_power_state(struct hda_codec *codec)
...@@ -343,12 +352,7 @@ static int analog_input_switch_put(struct snd_kcontrol *kcontrol, ...@@ -343,12 +352,7 @@ static int analog_input_switch_put(struct snd_kcontrol *kcontrol,
set_widgets_power_state(codec); set_widgets_power_state(codec);
analog_low_current_mode(snd_kcontrol_chip(kcontrol)); analog_low_current_mode(snd_kcontrol_chip(kcontrol));
if (snd_hda_get_bool_hint(codec, "analog_loopback_hp_detect") == 1) { vt1708_update_hp_work(codec->spec);
if (is_aa_path_mute(codec))
vt1708_start_hp_work(codec->spec);
else
vt1708_stop_hp_work(codec->spec);
}
return change; return change;
} }
...@@ -1154,7 +1158,7 @@ static int via_playback_multi_pcm_prepare(struct hda_pcm_stream *hinfo, ...@@ -1154,7 +1158,7 @@ static int via_playback_multi_pcm_prepare(struct hda_pcm_stream *hinfo,
spec->cur_dac_stream_tag = stream_tag; spec->cur_dac_stream_tag = stream_tag;
spec->cur_dac_format = format; spec->cur_dac_format = format;
mutex_unlock(&spec->config_mutex); mutex_unlock(&spec->config_mutex);
vt1708_start_hp_work(spec); vt1708_update_hp_work(spec);
return 0; return 0;
} }
...@@ -1174,7 +1178,7 @@ static int via_playback_hp_pcm_prepare(struct hda_pcm_stream *hinfo, ...@@ -1174,7 +1178,7 @@ static int via_playback_hp_pcm_prepare(struct hda_pcm_stream *hinfo,
spec->cur_hp_stream_tag = stream_tag; spec->cur_hp_stream_tag = stream_tag;
spec->cur_hp_format = format; spec->cur_hp_format = format;
mutex_unlock(&spec->config_mutex); mutex_unlock(&spec->config_mutex);
vt1708_start_hp_work(spec); vt1708_update_hp_work(spec);
return 0; return 0;
} }
...@@ -1188,7 +1192,7 @@ static int via_playback_multi_pcm_cleanup(struct hda_pcm_stream *hinfo, ...@@ -1188,7 +1192,7 @@ static int via_playback_multi_pcm_cleanup(struct hda_pcm_stream *hinfo,
snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
spec->active_streams &= ~STREAM_MULTI_OUT; spec->active_streams &= ~STREAM_MULTI_OUT;
mutex_unlock(&spec->config_mutex); mutex_unlock(&spec->config_mutex);
vt1708_stop_hp_work(spec); vt1708_update_hp_work(spec);
return 0; return 0;
} }
...@@ -1203,7 +1207,7 @@ static int via_playback_hp_pcm_cleanup(struct hda_pcm_stream *hinfo, ...@@ -1203,7 +1207,7 @@ static int via_playback_hp_pcm_cleanup(struct hda_pcm_stream *hinfo,
snd_hda_codec_setup_stream(codec, spec->hp_dac_nid, 0, 0, 0); snd_hda_codec_setup_stream(codec, spec->hp_dac_nid, 0, 0, 0);
spec->active_streams &= ~STREAM_INDEP_HP; spec->active_streams &= ~STREAM_INDEP_HP;
mutex_unlock(&spec->config_mutex); mutex_unlock(&spec->config_mutex);
vt1708_stop_hp_work(spec); vt1708_update_hp_work(spec);
return 0; return 0;
} }
...@@ -1645,7 +1649,8 @@ static void via_hp_automute(struct hda_codec *codec) ...@@ -1645,7 +1649,8 @@ static void via_hp_automute(struct hda_codec *codec)
int nums; int nums;
struct via_spec *spec = codec->spec; struct via_spec *spec = codec->spec;
if (!spec->hp_independent_mode && spec->autocfg.hp_pins[0]) if (!spec->hp_independent_mode && spec->autocfg.hp_pins[0] &&
(spec->codec_type != VT1708 || spec->vt1708_jack_detect))
present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]); present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]);
if (spec->smart51_enabled) if (spec->smart51_enabled)
...@@ -2612,8 +2617,6 @@ static int vt1708_jack_detect_get(struct snd_kcontrol *kcontrol, ...@@ -2612,8 +2617,6 @@ static int vt1708_jack_detect_get(struct snd_kcontrol *kcontrol,
if (spec->codec_type != VT1708) if (spec->codec_type != VT1708)
return 0; return 0;
spec->vt1708_jack_detect =
!((snd_hda_codec_read(codec, 0x1, 0, 0xf84, 0) >> 8) & 0x1);
ucontrol->value.integer.value[0] = spec->vt1708_jack_detect; ucontrol->value.integer.value[0] = spec->vt1708_jack_detect;
return 0; return 0;
} }
...@@ -2623,18 +2626,22 @@ static int vt1708_jack_detect_put(struct snd_kcontrol *kcontrol, ...@@ -2623,18 +2626,22 @@ static int vt1708_jack_detect_put(struct snd_kcontrol *kcontrol,
{ {
struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
struct via_spec *spec = codec->spec; struct via_spec *spec = codec->spec;
int change; int val;
if (spec->codec_type != VT1708) if (spec->codec_type != VT1708)
return 0; return 0;
spec->vt1708_jack_detect = ucontrol->value.integer.value[0]; val = !!ucontrol->value.integer.value[0];
change = (0x1 & (snd_hda_codec_read(codec, 0x1, 0, 0xf84, 0) >> 8)) if (spec->vt1708_jack_detect == val)
== !spec->vt1708_jack_detect; return 0;
if (spec->vt1708_jack_detect) { spec->vt1708_jack_detect = val;
if (spec->vt1708_jack_detect &&
snd_hda_get_bool_hint(codec, "analog_loopback_hp_detect") != 1) {
mute_aa_path(codec, 1); mute_aa_path(codec, 1);
notify_aa_path_ctls(codec); notify_aa_path_ctls(codec);
} }
return change; via_hp_automute(codec);
vt1708_update_hp_work(spec);
return 1;
} }
static const struct snd_kcontrol_new vt1708_jack_detect_ctl = { static const struct snd_kcontrol_new vt1708_jack_detect_ctl = {
...@@ -2771,6 +2778,7 @@ static int via_init(struct hda_codec *codec) ...@@ -2771,6 +2778,7 @@ static int via_init(struct hda_codec *codec)
via_auto_init_unsol_event(codec); via_auto_init_unsol_event(codec);
via_hp_automute(codec); via_hp_automute(codec);
vt1708_update_hp_work(spec);
return 0; return 0;
} }
...@@ -2787,7 +2795,9 @@ static void vt1708_update_hp_jack_state(struct work_struct *work) ...@@ -2787,7 +2795,9 @@ static void vt1708_update_hp_jack_state(struct work_struct *work)
spec->vt1708_hp_present ^= 1; spec->vt1708_hp_present ^= 1;
via_hp_automute(spec->codec); via_hp_automute(spec->codec);
} }
vt1708_start_hp_work(spec); if (spec->vt1708_jack_detect)
schedule_delayed_work(&spec->vt1708_hp_work,
msecs_to_jiffies(100));
} }
static int get_mux_nids(struct hda_codec *codec) static int get_mux_nids(struct hda_codec *codec)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册