diff options
author | Takashi Iwai <tiwai@suse.de> | 2011-06-17 09:46:13 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-06-20 10:23:56 -0400 |
commit | e06e5a297474c8027beffe10541981845ca0c98b (patch) | |
tree | ffbaad84cc2e0698e5a4c6731792c42e986dee0e | |
parent | a766d0d763bf9d64ff622db2c9c620d45a4ead96 (diff) |
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: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/pci/hda/patch_via.c | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 3a3df946661c..30d1273f3c3a 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c | |||
@@ -159,7 +159,7 @@ struct via_spec { | |||
159 | /* work to check hp jack state */ | 159 | /* work to check hp jack state */ |
160 | struct hda_codec *codec; | 160 | struct hda_codec *codec; |
161 | struct delayed_work vt1708_hp_work; | 161 | struct delayed_work vt1708_hp_work; |
162 | int vt1708_jack_detectect; | 162 | int vt1708_jack_detect; |
163 | int vt1708_hp_present; | 163 | int vt1708_hp_present; |
164 | 164 | ||
165 | void (*set_widgets_power_state)(struct hda_codec *codec); | 165 | void (*set_widgets_power_state)(struct hda_codec *codec); |
@@ -264,7 +264,7 @@ static void vt1708_start_hp_work(struct via_spec *spec) | |||
264 | if (spec->codec_type != VT1708 || spec->autocfg.hp_pins[0] == 0) | 264 | if (spec->codec_type != VT1708 || spec->autocfg.hp_pins[0] == 0) |
265 | return; | 265 | return; |
266 | snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81, | 266 | snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81, |
267 | !spec->vt1708_jack_detectect); | 267 | !spec->vt1708_jack_detect); |
268 | if (!delayed_work_pending(&spec->vt1708_hp_work)) | 268 | if (!delayed_work_pending(&spec->vt1708_hp_work)) |
269 | schedule_delayed_work(&spec->vt1708_hp_work, | 269 | schedule_delayed_work(&spec->vt1708_hp_work, |
270 | msecs_to_jiffies(100)); | 270 | msecs_to_jiffies(100)); |
@@ -278,7 +278,7 @@ static void vt1708_stop_hp_work(struct via_spec *spec) | |||
278 | && !is_aa_path_mute(spec->codec)) | 278 | && !is_aa_path_mute(spec->codec)) |
279 | return; | 279 | return; |
280 | snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81, | 280 | snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81, |
281 | !spec->vt1708_jack_detectect); | 281 | !spec->vt1708_jack_detect); |
282 | cancel_delayed_work_sync(&spec->vt1708_hp_work); | 282 | cancel_delayed_work_sync(&spec->vt1708_hp_work); |
283 | } | 283 | } |
284 | 284 | ||
@@ -2133,7 +2133,7 @@ static void vt1708_set_pinconfig_connect(struct hda_codec *codec, hda_nid_t nid) | |||
2133 | return; | 2133 | return; |
2134 | } | 2134 | } |
2135 | 2135 | ||
2136 | static int vt1708_jack_detectect_get(struct snd_kcontrol *kcontrol, | 2136 | static int vt1708_jack_detect_get(struct snd_kcontrol *kcontrol, |
2137 | struct snd_ctl_elem_value *ucontrol) | 2137 | struct snd_ctl_elem_value *ucontrol) |
2138 | { | 2138 | { |
2139 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 2139 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
@@ -2141,13 +2141,13 @@ static int vt1708_jack_detectect_get(struct snd_kcontrol *kcontrol, | |||
2141 | 2141 | ||
2142 | if (spec->codec_type != VT1708) | 2142 | if (spec->codec_type != VT1708) |
2143 | return 0; | 2143 | return 0; |
2144 | spec->vt1708_jack_detectect = | 2144 | spec->vt1708_jack_detect = |
2145 | !((snd_hda_codec_read(codec, 0x1, 0, 0xf84, 0) >> 8) & 0x1); | 2145 | !((snd_hda_codec_read(codec, 0x1, 0, 0xf84, 0) >> 8) & 0x1); |
2146 | ucontrol->value.integer.value[0] = spec->vt1708_jack_detectect; | 2146 | ucontrol->value.integer.value[0] = spec->vt1708_jack_detect; |
2147 | return 0; | 2147 | return 0; |
2148 | } | 2148 | } |
2149 | 2149 | ||
2150 | static int vt1708_jack_detectect_put(struct snd_kcontrol *kcontrol, | 2150 | static int vt1708_jack_detect_put(struct snd_kcontrol *kcontrol, |
2151 | struct snd_ctl_elem_value *ucontrol) | 2151 | struct snd_ctl_elem_value *ucontrol) |
2152 | { | 2152 | { |
2153 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 2153 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
@@ -2156,26 +2156,23 @@ static int vt1708_jack_detectect_put(struct snd_kcontrol *kcontrol, | |||
2156 | 2156 | ||
2157 | if (spec->codec_type != VT1708) | 2157 | if (spec->codec_type != VT1708) |
2158 | return 0; | 2158 | return 0; |
2159 | spec->vt1708_jack_detectect = ucontrol->value.integer.value[0]; | 2159 | spec->vt1708_jack_detect = ucontrol->value.integer.value[0]; |
2160 | change = (0x1 & (snd_hda_codec_read(codec, 0x1, 0, 0xf84, 0) >> 8)) | 2160 | change = (0x1 & (snd_hda_codec_read(codec, 0x1, 0, 0xf84, 0) >> 8)) |
2161 | == !spec->vt1708_jack_detectect; | 2161 | == !spec->vt1708_jack_detect; |
2162 | if (spec->vt1708_jack_detectect) { | 2162 | if (spec->vt1708_jack_detect) { |
2163 | mute_aa_path(codec, 1); | 2163 | mute_aa_path(codec, 1); |
2164 | notify_aa_path_ctls(codec); | 2164 | notify_aa_path_ctls(codec); |
2165 | } | 2165 | } |
2166 | return change; | 2166 | return change; |
2167 | } | 2167 | } |
2168 | 2168 | ||
2169 | static const struct snd_kcontrol_new vt1708_jack_detectect[] = { | 2169 | static const struct snd_kcontrol_new vt1708_jack_detect_ctl = { |
2170 | { | 2170 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
2171 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 2171 | .name = "Jack Detect", |
2172 | .name = "Jack Detect", | 2172 | .count = 1, |
2173 | .count = 1, | 2173 | .info = snd_ctl_boolean_mono_info, |
2174 | .info = snd_ctl_boolean_mono_info, | 2174 | .get = vt1708_jack_detect_get, |
2175 | .get = vt1708_jack_detectect_get, | 2175 | .put = vt1708_jack_detect_put, |
2176 | .put = vt1708_jack_detectect_put, | ||
2177 | }, | ||
2178 | {} /* end */ | ||
2179 | }; | 2176 | }; |
2180 | 2177 | ||
2181 | static int vt1708_parse_auto_config(struct hda_codec *codec) | 2178 | 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 | if (err < 0) | 2203 | if (err < 0) |
2207 | return err; | 2204 | return err; |
2208 | /* add jack detect on/off control */ | 2205 | /* add jack detect on/off control */ |
2209 | err = snd_hda_add_new_ctls(codec, vt1708_jack_detectect); | 2206 | if (!via_clone_control(spec, &vt1708_jack_detect_ctl)) |
2210 | if (err < 0) | 2207 | return -ENOMEM; |
2211 | return err; | ||
2212 | 2208 | ||
2213 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | 2209 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
2214 | 2210 | ||