Commit e06e5a29 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hda - Defer mixer element creation to the right time in patch_via.c

The jack-detect control should be created at the time of build_controls
callback instead of calling snd_hda_add_ctls() at the tree-parsing time.
For that, copy the control to the temporary array like other cases.

Also, fixed typos of vt1708_jack_detect in all places.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent a766d0d7
...@@ -159,7 +159,7 @@ struct via_spec { ...@@ -159,7 +159,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 vt1708_jack_detectect; int vt1708_jack_detect;
int vt1708_hp_present; int vt1708_hp_present;
void (*set_widgets_power_state)(struct hda_codec *codec); void (*set_widgets_power_state)(struct hda_codec *codec);
...@@ -264,7 +264,7 @@ static void vt1708_start_hp_work(struct via_spec *spec) ...@@ -264,7 +264,7 @@ static void vt1708_start_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, snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81,
!spec->vt1708_jack_detectect); !spec->vt1708_jack_detect);
if (!delayed_work_pending(&spec->vt1708_hp_work)) if (!delayed_work_pending(&spec->vt1708_hp_work))
schedule_delayed_work(&spec->vt1708_hp_work, schedule_delayed_work(&spec->vt1708_hp_work,
msecs_to_jiffies(100)); msecs_to_jiffies(100));
...@@ -278,7 +278,7 @@ static void vt1708_stop_hp_work(struct via_spec *spec) ...@@ -278,7 +278,7 @@ static void vt1708_stop_hp_work(struct via_spec *spec)
&& !is_aa_path_mute(spec->codec)) && !is_aa_path_mute(spec->codec))
return; return;
snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81, snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81,
!spec->vt1708_jack_detectect); !spec->vt1708_jack_detect);
cancel_delayed_work_sync(&spec->vt1708_hp_work); cancel_delayed_work_sync(&spec->vt1708_hp_work);
} }
...@@ -2133,7 +2133,7 @@ static void vt1708_set_pinconfig_connect(struct hda_codec *codec, hda_nid_t nid) ...@@ -2133,7 +2133,7 @@ static void vt1708_set_pinconfig_connect(struct hda_codec *codec, hda_nid_t nid)
return; return;
} }
static int vt1708_jack_detectect_get(struct snd_kcontrol *kcontrol, static int vt1708_jack_detect_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
...@@ -2141,13 +2141,13 @@ static int vt1708_jack_detectect_get(struct snd_kcontrol *kcontrol, ...@@ -2141,13 +2141,13 @@ static int vt1708_jack_detectect_get(struct snd_kcontrol *kcontrol,
if (spec->codec_type != VT1708) if (spec->codec_type != VT1708)
return 0; return 0;
spec->vt1708_jack_detectect = spec->vt1708_jack_detect =
!((snd_hda_codec_read(codec, 0x1, 0, 0xf84, 0) >> 8) & 0x1); !((snd_hda_codec_read(codec, 0x1, 0, 0xf84, 0) >> 8) & 0x1);
ucontrol->value.integer.value[0] = spec->vt1708_jack_detectect; ucontrol->value.integer.value[0] = spec->vt1708_jack_detect;
return 0; return 0;
} }
static int vt1708_jack_detectect_put(struct snd_kcontrol *kcontrol, static int vt1708_jack_detect_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
...@@ -2156,26 +2156,23 @@ static int vt1708_jack_detectect_put(struct snd_kcontrol *kcontrol, ...@@ -2156,26 +2156,23 @@ static int vt1708_jack_detectect_put(struct snd_kcontrol *kcontrol,
if (spec->codec_type != VT1708) if (spec->codec_type != VT1708)
return 0; return 0;
spec->vt1708_jack_detectect = ucontrol->value.integer.value[0]; spec->vt1708_jack_detect = ucontrol->value.integer.value[0];
change = (0x1 & (snd_hda_codec_read(codec, 0x1, 0, 0xf84, 0) >> 8)) change = (0x1 & (snd_hda_codec_read(codec, 0x1, 0, 0xf84, 0) >> 8))
== !spec->vt1708_jack_detectect; == !spec->vt1708_jack_detect;
if (spec->vt1708_jack_detectect) { if (spec->vt1708_jack_detect) {
mute_aa_path(codec, 1); mute_aa_path(codec, 1);
notify_aa_path_ctls(codec); notify_aa_path_ctls(codec);
} }
return change; return change;
} }
static const struct snd_kcontrol_new vt1708_jack_detectect[] = { static const struct snd_kcontrol_new vt1708_jack_detect_ctl = {
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Jack Detect",
.name = "Jack Detect", .count = 1,
.count = 1, .info = snd_ctl_boolean_mono_info,
.info = snd_ctl_boolean_mono_info, .get = vt1708_jack_detect_get,
.get = vt1708_jack_detectect_get, .put = vt1708_jack_detect_put,
.put = vt1708_jack_detectect_put,
},
{} /* end */
}; };
static int vt1708_parse_auto_config(struct hda_codec *codec) static int vt1708_parse_auto_config(struct hda_codec *codec)
...@@ -2206,9 +2203,8 @@ static int vt1708_parse_auto_config(struct hda_codec *codec) ...@@ -2206,9 +2203,8 @@ static int vt1708_parse_auto_config(struct hda_codec *codec)
if (err < 0) if (err < 0)
return err; return err;
/* add jack detect on/off control */ /* add jack detect on/off control */
err = snd_hda_add_new_ctls(codec, vt1708_jack_detectect); if (!via_clone_control(spec, &vt1708_jack_detect_ctl))
if (err < 0) return -ENOMEM;
return err;
spec->multiout.max_channels = spec->multiout.num_dacs * 2; spec->multiout.max_channels = spec->multiout.num_dacs * 2;
......
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