diff options
author | Takashi Iwai <tiwai@suse.de> | 2013-03-18 06:25:51 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2013-03-18 07:58:42 -0400 |
commit | 7504b6cd220a3dd8104abe3d0f985c6957dc3e17 (patch) | |
tree | cc9375edcd24847cad943c0a5d141874f67e743f | |
parent | cf30f46acde1f84fbf603bba6540cbb40cc6c954 (diff) |
ALSA: hda - Move beep attach/detach calls in hda_generic.c
Instead of calling snd_hda_attach_beep_device() and
snd_hda_detach_beep_device() in each codec driver, move them to the
generic parser. The codec driver just needs to set spec->beep_nid for
activating the digital beep.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/pci/hda/hda_generic.c | 8 | ||||
-rw-r--r-- | sound/pci/hda/hda_generic.h | 3 | ||||
-rw-r--r-- | sound/pci/hda/patch_analog.c | 33 | ||||
-rw-r--r-- | sound/pci/hda/patch_conexant.c | 18 | ||||
-rw-r--r-- | sound/pci/hda/patch_realtek.c | 106 | ||||
-rw-r--r-- | sound/pci/hda/patch_sigmatel.c | 32 |
6 files changed, 72 insertions, 128 deletions
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index aae6b1023d69..d7fa1ee8302c 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include "hda_local.h" | 34 | #include "hda_local.h" |
35 | #include "hda_auto_parser.h" | 35 | #include "hda_auto_parser.h" |
36 | #include "hda_jack.h" | 36 | #include "hda_jack.h" |
37 | #include "hda_beep.h" | ||
37 | #include "hda_generic.h" | 38 | #include "hda_generic.h" |
38 | 39 | ||
39 | 40 | ||
@@ -4238,6 +4239,12 @@ int snd_hda_gen_parse_auto_config(struct hda_codec *codec, | |||
4238 | if (spec->power_down_unused) | 4239 | if (spec->power_down_unused) |
4239 | codec->power_filter = snd_hda_gen_path_power_filter; | 4240 | codec->power_filter = snd_hda_gen_path_power_filter; |
4240 | 4241 | ||
4242 | if (!spec->no_analog && spec->beep_nid) { | ||
4243 | err = snd_hda_attach_beep_device(codec, spec->beep_nid); | ||
4244 | if (err < 0) | ||
4245 | return err; | ||
4246 | } | ||
4247 | |||
4241 | return 1; | 4248 | return 1; |
4242 | } | 4249 | } |
4243 | EXPORT_SYMBOL_HDA(snd_hda_gen_parse_auto_config); | 4250 | EXPORT_SYMBOL_HDA(snd_hda_gen_parse_auto_config); |
@@ -5063,6 +5070,7 @@ EXPORT_SYMBOL_HDA(snd_hda_gen_init); | |||
5063 | */ | 5070 | */ |
5064 | void snd_hda_gen_free(struct hda_codec *codec) | 5071 | void snd_hda_gen_free(struct hda_codec *codec) |
5065 | { | 5072 | { |
5073 | snd_hda_detach_beep_device(codec); | ||
5066 | snd_hda_gen_spec_free(codec->spec); | 5074 | snd_hda_gen_spec_free(codec->spec); |
5067 | kfree(codec->spec); | 5075 | kfree(codec->spec); |
5068 | codec->spec = NULL; | 5076 | codec->spec = NULL; |
diff --git a/sound/pci/hda/hda_generic.h b/sound/pci/hda/hda_generic.h index 094e6af7a107..39d83943f25d 100644 --- a/sound/pci/hda/hda_generic.h +++ b/sound/pci/hda/hda_generic.h | |||
@@ -226,6 +226,9 @@ struct hda_gen_spec { | |||
226 | /* loopback mixing mode */ | 226 | /* loopback mixing mode */ |
227 | bool aamix_mode; | 227 | bool aamix_mode; |
228 | 228 | ||
229 | /* digital beep */ | ||
230 | hda_nid_t beep_nid; | ||
231 | |||
229 | /* for virtual master */ | 232 | /* for virtual master */ |
230 | hda_nid_t vmaster_nid; | 233 | hda_nid_t vmaster_nid; |
231 | unsigned int vmaster_tlv[4]; | 234 | unsigned int vmaster_tlv[4]; |
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index df8014b27596..977b0d878dae 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c | |||
@@ -43,7 +43,6 @@ struct ad198x_spec { | |||
43 | hda_nid_t eapd_nid; | 43 | hda_nid_t eapd_nid; |
44 | 44 | ||
45 | unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ | 45 | unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ |
46 | hda_nid_t beep_dev_nid; | ||
47 | 46 | ||
48 | #ifdef ENABLE_AD_STATIC_QUIRKS | 47 | #ifdef ENABLE_AD_STATIC_QUIRKS |
49 | const struct snd_kcontrol_new *mixers[6]; | 48 | const struct snd_kcontrol_new *mixers[6]; |
@@ -609,7 +608,7 @@ static const struct hda_codec_ops ad198x_auto_patch_ops = { | |||
609 | .build_controls = ad198x_auto_build_controls, | 608 | .build_controls = ad198x_auto_build_controls, |
610 | .build_pcms = snd_hda_gen_build_pcms, | 609 | .build_pcms = snd_hda_gen_build_pcms, |
611 | .init = snd_hda_gen_init, | 610 | .init = snd_hda_gen_init, |
612 | .free = ad198x_free, | 611 | .free = snd_hda_gen_free, |
613 | .unsol_event = snd_hda_jack_unsol_event, | 612 | .unsol_event = snd_hda_jack_unsol_event, |
614 | #ifdef CONFIG_PM | 613 | #ifdef CONFIG_PM |
615 | .check_power_status = snd_hda_gen_check_power_status, | 614 | .check_power_status = snd_hda_gen_check_power_status, |
@@ -638,12 +637,6 @@ static int ad198x_parse_auto_config(struct hda_codec *codec) | |||
638 | if (err < 0) | 637 | if (err < 0) |
639 | return err; | 638 | return err; |
640 | 639 | ||
641 | if (spec->beep_dev_nid) { | ||
642 | err = snd_hda_attach_beep_device(codec, spec->beep_dev_nid); | ||
643 | if (err < 0) | ||
644 | return err; | ||
645 | } | ||
646 | |||
647 | codec->patch_ops = ad198x_auto_patch_ops; | 640 | codec->patch_ops = ad198x_auto_patch_ops; |
648 | 641 | ||
649 | return 0; | 642 | return 0; |
@@ -1240,7 +1233,7 @@ static int ad1986a_parse_auto_config(struct hda_codec *codec) | |||
1240 | codec->inv_eapd = 1; | 1233 | codec->inv_eapd = 1; |
1241 | 1234 | ||
1242 | spec->gen.mixer_nid = 0x07; | 1235 | spec->gen.mixer_nid = 0x07; |
1243 | spec->beep_dev_nid = 0x19; | 1236 | spec->gen.beep_nid = 0x19; |
1244 | set_beep_amp(spec, 0x18, 0, HDA_OUTPUT); | 1237 | set_beep_amp(spec, 0x18, 0, HDA_OUTPUT); |
1245 | 1238 | ||
1246 | /* AD1986A has a hardware problem that it can't share a stream | 1239 | /* AD1986A has a hardware problem that it can't share a stream |
@@ -1256,7 +1249,7 @@ static int ad1986a_parse_auto_config(struct hda_codec *codec) | |||
1256 | 1249 | ||
1257 | err = ad198x_parse_auto_config(codec); | 1250 | err = ad198x_parse_auto_config(codec); |
1258 | if (err < 0) { | 1251 | if (err < 0) { |
1259 | ad198x_free(codec); | 1252 | snd_hda_gen_free(codec); |
1260 | return err; | 1253 | return err; |
1261 | } | 1254 | } |
1262 | 1255 | ||
@@ -1673,7 +1666,7 @@ static int ad1983_parse_auto_config(struct hda_codec *codec) | |||
1673 | return err; | 1666 | return err; |
1674 | spec = codec->spec; | 1667 | spec = codec->spec; |
1675 | 1668 | ||
1676 | spec->beep_dev_nid = 0x10; | 1669 | spec->gen.beep_nid = 0x10; |
1677 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); | 1670 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); |
1678 | err = ad198x_parse_auto_config(codec); | 1671 | err = ad198x_parse_auto_config(codec); |
1679 | if (err < 0) | 1672 | if (err < 0) |
@@ -1684,7 +1677,7 @@ static int ad1983_parse_auto_config(struct hda_codec *codec) | |||
1684 | return 0; | 1677 | return 0; |
1685 | 1678 | ||
1686 | error: | 1679 | error: |
1687 | ad198x_free(codec); | 1680 | snd_hda_gen_free(codec); |
1688 | return err; | 1681 | return err; |
1689 | } | 1682 | } |
1690 | 1683 | ||
@@ -2187,7 +2180,7 @@ static int ad1981_parse_auto_config(struct hda_codec *codec) | |||
2187 | spec = codec->spec; | 2180 | spec = codec->spec; |
2188 | 2181 | ||
2189 | spec->gen.mixer_nid = 0x0e; | 2182 | spec->gen.mixer_nid = 0x0e; |
2190 | spec->beep_dev_nid = 0x10; | 2183 | spec->gen.beep_nid = 0x10; |
2191 | set_beep_amp(spec, 0x0d, 0, HDA_OUTPUT); | 2184 | set_beep_amp(spec, 0x0d, 0, HDA_OUTPUT); |
2192 | 2185 | ||
2193 | snd_hda_pick_fixup(codec, NULL, ad1981_fixup_tbl, ad1981_fixups); | 2186 | snd_hda_pick_fixup(codec, NULL, ad1981_fixup_tbl, ad1981_fixups); |
@@ -2205,7 +2198,7 @@ static int ad1981_parse_auto_config(struct hda_codec *codec) | |||
2205 | return 0; | 2198 | return 0; |
2206 | 2199 | ||
2207 | error: | 2200 | error: |
2208 | ad198x_free(codec); | 2201 | snd_hda_gen_free(codec); |
2209 | return err; | 2202 | return err; |
2210 | } | 2203 | } |
2211 | 2204 | ||
@@ -3236,7 +3229,7 @@ static int ad1988_parse_auto_config(struct hda_codec *codec) | |||
3236 | 3229 | ||
3237 | spec->gen.mixer_nid = 0x20; | 3230 | spec->gen.mixer_nid = 0x20; |
3238 | spec->gen.mixer_merge_nid = 0x21; | 3231 | spec->gen.mixer_merge_nid = 0x21; |
3239 | spec->beep_dev_nid = 0x10; | 3232 | spec->gen.beep_nid = 0x10; |
3240 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); | 3233 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); |
3241 | err = ad198x_parse_auto_config(codec); | 3234 | err = ad198x_parse_auto_config(codec); |
3242 | if (err < 0) | 3235 | if (err < 0) |
@@ -3247,7 +3240,7 @@ static int ad1988_parse_auto_config(struct hda_codec *codec) | |||
3247 | return 0; | 3240 | return 0; |
3248 | 3241 | ||
3249 | error: | 3242 | error: |
3250 | ad198x_free(codec); | 3243 | snd_hda_gen_free(codec); |
3251 | return err; | 3244 | return err; |
3252 | } | 3245 | } |
3253 | 3246 | ||
@@ -3653,7 +3646,7 @@ static int ad1884_parse_auto_config(struct hda_codec *codec) | |||
3653 | spec = codec->spec; | 3646 | spec = codec->spec; |
3654 | 3647 | ||
3655 | spec->gen.mixer_nid = 0x20; | 3648 | spec->gen.mixer_nid = 0x20; |
3656 | spec->beep_dev_nid = 0x10; | 3649 | spec->gen.beep_nid = 0x10; |
3657 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); | 3650 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); |
3658 | 3651 | ||
3659 | snd_hda_pick_fixup(codec, NULL, ad1884_fixup_tbl, ad1884_fixups); | 3652 | snd_hda_pick_fixup(codec, NULL, ad1884_fixup_tbl, ad1884_fixups); |
@@ -3671,7 +3664,7 @@ static int ad1884_parse_auto_config(struct hda_codec *codec) | |||
3671 | return 0; | 3664 | return 0; |
3672 | 3665 | ||
3673 | error: | 3666 | error: |
3674 | ad198x_free(codec); | 3667 | snd_hda_gen_free(codec); |
3675 | return err; | 3668 | return err; |
3676 | } | 3669 | } |
3677 | 3670 | ||
@@ -5155,7 +5148,7 @@ static int ad1882_parse_auto_config(struct hda_codec *codec) | |||
5155 | 5148 | ||
5156 | spec->gen.mixer_nid = 0x20; | 5149 | spec->gen.mixer_nid = 0x20; |
5157 | spec->gen.mixer_merge_nid = 0x21; | 5150 | spec->gen.mixer_merge_nid = 0x21; |
5158 | spec->beep_dev_nid = 0x10; | 5151 | spec->gen.beep_nid = 0x10; |
5159 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); | 5152 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); |
5160 | err = ad198x_parse_auto_config(codec); | 5153 | err = ad198x_parse_auto_config(codec); |
5161 | if (err < 0) | 5154 | if (err < 0) |
@@ -5166,7 +5159,7 @@ static int ad1882_parse_auto_config(struct hda_codec *codec) | |||
5166 | return 0; | 5159 | return 0; |
5167 | 5160 | ||
5168 | error: | 5161 | error: |
5169 | ad198x_free(codec); | 5162 | snd_hda_gen_free(codec); |
5170 | return err; | 5163 | return err; |
5171 | } | 5164 | } |
5172 | 5165 | ||
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index d0100a85e189..549964395770 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c | |||
@@ -139,8 +139,12 @@ struct conexant_spec { | |||
139 | 139 | ||
140 | 140 | ||
141 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | 141 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
142 | #define set_beep_amp(spec, nid, idx, dir) \ | 142 | static inline void set_beep_amp(struct conexant_spec *spec, hda_nid_t nid, |
143 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) | 143 | int idx, int dir) |
144 | { | ||
145 | spec->gen.beep_nid = nid; | ||
146 | spec->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir); | ||
147 | } | ||
144 | /* additional beep mixers; the actual parameters are overwritten at build */ | 148 | /* additional beep mixers; the actual parameters are overwritten at build */ |
145 | static const struct snd_kcontrol_new cxt_beep_mixer[] = { | 149 | static const struct snd_kcontrol_new cxt_beep_mixer[] = { |
146 | HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT), | 150 | HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT), |
@@ -3191,17 +3195,11 @@ static int cx_auto_build_controls(struct hda_codec *codec) | |||
3191 | return 0; | 3195 | return 0; |
3192 | } | 3196 | } |
3193 | 3197 | ||
3194 | static void cx_auto_free(struct hda_codec *codec) | ||
3195 | { | ||
3196 | snd_hda_detach_beep_device(codec); | ||
3197 | snd_hda_gen_free(codec); | ||
3198 | } | ||
3199 | |||
3200 | static const struct hda_codec_ops cx_auto_patch_ops = { | 3198 | static const struct hda_codec_ops cx_auto_patch_ops = { |
3201 | .build_controls = cx_auto_build_controls, | 3199 | .build_controls = cx_auto_build_controls, |
3202 | .build_pcms = snd_hda_gen_build_pcms, | 3200 | .build_pcms = snd_hda_gen_build_pcms, |
3203 | .init = snd_hda_gen_init, | 3201 | .init = snd_hda_gen_init, |
3204 | .free = cx_auto_free, | 3202 | .free = snd_hda_gen_free, |
3205 | .unsol_event = snd_hda_jack_unsol_event, | 3203 | .unsol_event = snd_hda_jack_unsol_event, |
3206 | #ifdef CONFIG_PM | 3204 | #ifdef CONFIG_PM |
3207 | .check_power_status = snd_hda_gen_check_power_status, | 3205 | .check_power_status = snd_hda_gen_check_power_status, |
@@ -3395,8 +3393,6 @@ static int patch_conexant_auto(struct hda_codec *codec) | |||
3395 | goto error; | 3393 | goto error; |
3396 | 3394 | ||
3397 | codec->patch_ops = cx_auto_patch_ops; | 3395 | codec->patch_ops = cx_auto_patch_ops; |
3398 | if (spec->beep_amp) | ||
3399 | snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); | ||
3400 | 3396 | ||
3401 | /* Some laptops with Conexant chips show stalls in S3 resume, | 3397 | /* Some laptops with Conexant chips show stalls in S3 resume, |
3402 | * which falls into the single-cmd mode. | 3398 | * which falls into the single-cmd mode. |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index c0bf15554507..e7b59d3eaba8 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include "hda_codec.h" | 34 | #include "hda_codec.h" |
35 | #include "hda_local.h" | 35 | #include "hda_local.h" |
36 | #include "hda_auto_parser.h" | 36 | #include "hda_auto_parser.h" |
37 | #include "hda_beep.h" | ||
38 | #include "hda_jack.h" | 37 | #include "hda_jack.h" |
39 | #include "hda_generic.h" | 38 | #include "hda_generic.h" |
40 | 39 | ||
@@ -805,17 +804,7 @@ static inline void alc_shutup(struct hda_codec *codec) | |||
805 | snd_hda_shutup_pins(codec); | 804 | snd_hda_shutup_pins(codec); |
806 | } | 805 | } |
807 | 806 | ||
808 | static void alc_free(struct hda_codec *codec) | 807 | #define alc_free snd_hda_gen_free |
809 | { | ||
810 | struct alc_spec *spec = codec->spec; | ||
811 | |||
812 | if (!spec) | ||
813 | return; | ||
814 | |||
815 | snd_hda_gen_spec_free(&spec->gen); | ||
816 | snd_hda_detach_beep_device(codec); | ||
817 | kfree(spec); | ||
818 | } | ||
819 | 808 | ||
820 | #ifdef CONFIG_PM | 809 | #ifdef CONFIG_PM |
821 | static void alc_power_eapd(struct hda_codec *codec) | 810 | static void alc_power_eapd(struct hda_codec *codec) |
@@ -1401,6 +1390,7 @@ static int patch_alc880(struct hda_codec *codec) | |||
1401 | 1390 | ||
1402 | spec = codec->spec; | 1391 | spec = codec->spec; |
1403 | spec->gen.need_dac_fix = 1; | 1392 | spec->gen.need_dac_fix = 1; |
1393 | spec->gen.beep_nid = 0x01; | ||
1404 | 1394 | ||
1405 | snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl, | 1395 | snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl, |
1406 | alc880_fixups); | 1396 | alc880_fixups); |
@@ -1411,12 +1401,8 @@ static int patch_alc880(struct hda_codec *codec) | |||
1411 | if (err < 0) | 1401 | if (err < 0) |
1412 | goto error; | 1402 | goto error; |
1413 | 1403 | ||
1414 | if (!spec->gen.no_analog) { | 1404 | if (!spec->gen.no_analog) |
1415 | err = snd_hda_attach_beep_device(codec, 0x1); | ||
1416 | if (err < 0) | ||
1417 | goto error; | ||
1418 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 1405 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
1419 | } | ||
1420 | 1406 | ||
1421 | codec->patch_ops = alc_patch_ops; | 1407 | codec->patch_ops = alc_patch_ops; |
1422 | codec->patch_ops.unsol_event = alc880_unsol_event; | 1408 | codec->patch_ops.unsol_event = alc880_unsol_event; |
@@ -1637,6 +1623,7 @@ static int patch_alc260(struct hda_codec *codec) | |||
1637 | * it's almost harmless. | 1623 | * it's almost harmless. |
1638 | */ | 1624 | */ |
1639 | spec->gen.prefer_hp_amp = 1; | 1625 | spec->gen.prefer_hp_amp = 1; |
1626 | spec->gen.beep_nid = 0x01; | ||
1640 | 1627 | ||
1641 | snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl, | 1628 | snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl, |
1642 | alc260_fixups); | 1629 | alc260_fixups); |
@@ -1647,12 +1634,8 @@ static int patch_alc260(struct hda_codec *codec) | |||
1647 | if (err < 0) | 1634 | if (err < 0) |
1648 | goto error; | 1635 | goto error; |
1649 | 1636 | ||
1650 | if (!spec->gen.no_analog) { | 1637 | if (!spec->gen.no_analog) |
1651 | err = snd_hda_attach_beep_device(codec, 0x1); | ||
1652 | if (err < 0) | ||
1653 | goto error; | ||
1654 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); | 1638 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); |
1655 | } | ||
1656 | 1639 | ||
1657 | codec->patch_ops = alc_patch_ops; | 1640 | codec->patch_ops = alc_patch_ops; |
1658 | spec->shutup = alc_eapd_shutup; | 1641 | spec->shutup = alc_eapd_shutup; |
@@ -2151,17 +2134,16 @@ static int patch_alc882(struct hda_codec *codec) | |||
2151 | 2134 | ||
2152 | alc_auto_parse_customize_define(codec); | 2135 | alc_auto_parse_customize_define(codec); |
2153 | 2136 | ||
2137 | if (has_cdefine_beep(codec)) | ||
2138 | spec->gen.beep_nid = 0x01; | ||
2139 | |||
2154 | /* automatic parse from the BIOS config */ | 2140 | /* automatic parse from the BIOS config */ |
2155 | err = alc882_parse_auto_config(codec); | 2141 | err = alc882_parse_auto_config(codec); |
2156 | if (err < 0) | 2142 | if (err < 0) |
2157 | goto error; | 2143 | goto error; |
2158 | 2144 | ||
2159 | if (!spec->gen.no_analog && has_cdefine_beep(codec)) { | 2145 | if (!spec->gen.no_analog && spec->gen.beep_nid) |
2160 | err = snd_hda_attach_beep_device(codec, 0x1); | ||
2161 | if (err < 0) | ||
2162 | goto error; | ||
2163 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 2146 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
2164 | } | ||
2165 | 2147 | ||
2166 | codec->patch_ops = alc_patch_ops; | 2148 | codec->patch_ops = alc_patch_ops; |
2167 | 2149 | ||
@@ -2314,17 +2296,16 @@ static int patch_alc262(struct hda_codec *codec) | |||
2314 | 2296 | ||
2315 | alc_auto_parse_customize_define(codec); | 2297 | alc_auto_parse_customize_define(codec); |
2316 | 2298 | ||
2299 | if (has_cdefine_beep(codec)) | ||
2300 | spec->gen.beep_nid = 0x01; | ||
2301 | |||
2317 | /* automatic parse from the BIOS config */ | 2302 | /* automatic parse from the BIOS config */ |
2318 | err = alc262_parse_auto_config(codec); | 2303 | err = alc262_parse_auto_config(codec); |
2319 | if (err < 0) | 2304 | if (err < 0) |
2320 | goto error; | 2305 | goto error; |
2321 | 2306 | ||
2322 | if (!spec->gen.no_analog && has_cdefine_beep(codec)) { | 2307 | if (!spec->gen.no_analog && spec->gen.beep_nid) |
2323 | err = snd_hda_attach_beep_device(codec, 0x1); | ||
2324 | if (err < 0) | ||
2325 | goto error; | ||
2326 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 2308 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
2327 | } | ||
2328 | 2309 | ||
2329 | codec->patch_ops = alc_patch_ops; | 2310 | codec->patch_ops = alc_patch_ops; |
2330 | spec->shutup = alc_eapd_shutup; | 2311 | spec->shutup = alc_eapd_shutup; |
@@ -2405,16 +2386,7 @@ static const struct snd_pci_quirk alc268_fixup_tbl[] = { | |||
2405 | static int alc268_parse_auto_config(struct hda_codec *codec) | 2386 | static int alc268_parse_auto_config(struct hda_codec *codec) |
2406 | { | 2387 | { |
2407 | static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 }; | 2388 | static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
2408 | struct alc_spec *spec = codec->spec; | 2389 | return alc_parse_auto_config(codec, NULL, alc268_ssids); |
2409 | int err = alc_parse_auto_config(codec, NULL, alc268_ssids); | ||
2410 | if (err > 0) { | ||
2411 | if (!spec->gen.no_analog && | ||
2412 | spec->gen.autocfg.speaker_pins[0] != 0x1d) { | ||
2413 | add_mixer(spec, alc268_beep_mixer); | ||
2414 | snd_hda_add_verbs(codec, alc268_beep_init_verbs); | ||
2415 | } | ||
2416 | } | ||
2417 | return err; | ||
2418 | } | 2390 | } |
2419 | 2391 | ||
2420 | /* | 2392 | /* |
@@ -2422,7 +2394,7 @@ static int alc268_parse_auto_config(struct hda_codec *codec) | |||
2422 | static int patch_alc268(struct hda_codec *codec) | 2394 | static int patch_alc268(struct hda_codec *codec) |
2423 | { | 2395 | { |
2424 | struct alc_spec *spec; | 2396 | struct alc_spec *spec; |
2425 | int i, has_beep, err; | 2397 | int err; |
2426 | 2398 | ||
2427 | /* ALC268 has no aa-loopback mixer */ | 2399 | /* ALC268 has no aa-loopback mixer */ |
2428 | err = alc_alloc_spec(codec, 0); | 2400 | err = alc_alloc_spec(codec, 0); |
@@ -2430,6 +2402,7 @@ static int patch_alc268(struct hda_codec *codec) | |||
2430 | return err; | 2402 | return err; |
2431 | 2403 | ||
2432 | spec = codec->spec; | 2404 | spec = codec->spec; |
2405 | spec->gen.beep_nid = 0x01; | ||
2433 | 2406 | ||
2434 | snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups); | 2407 | snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups); |
2435 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); | 2408 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
@@ -2439,18 +2412,10 @@ static int patch_alc268(struct hda_codec *codec) | |||
2439 | if (err < 0) | 2412 | if (err < 0) |
2440 | goto error; | 2413 | goto error; |
2441 | 2414 | ||
2442 | has_beep = 0; | 2415 | if (err > 0 && !spec->gen.no_analog && |
2443 | for (i = 0; i < spec->num_mixers; i++) { | 2416 | spec->gen.autocfg.speaker_pins[0] != 0x1d) { |
2444 | if (spec->mixers[i] == alc268_beep_mixer) { | 2417 | add_mixer(spec, alc268_beep_mixer); |
2445 | has_beep = 1; | 2418 | snd_hda_add_verbs(codec, alc268_beep_init_verbs); |
2446 | break; | ||
2447 | } | ||
2448 | } | ||
2449 | |||
2450 | if (has_beep) { | ||
2451 | err = snd_hda_attach_beep_device(codec, 0x1); | ||
2452 | if (err < 0) | ||
2453 | goto error; | ||
2454 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) | 2419 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) |
2455 | /* override the amp caps for beep generator */ | 2420 | /* override the amp caps for beep generator */ |
2456 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, | 2421 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, |
@@ -3150,6 +3115,9 @@ static int patch_alc269(struct hda_codec *codec) | |||
3150 | 3115 | ||
3151 | alc_auto_parse_customize_define(codec); | 3116 | alc_auto_parse_customize_define(codec); |
3152 | 3117 | ||
3118 | if (has_cdefine_beep(codec)) | ||
3119 | spec->gen.beep_nid = 0x01; | ||
3120 | |||
3153 | switch (codec->vendor_id) { | 3121 | switch (codec->vendor_id) { |
3154 | case 0x10ec0269: | 3122 | case 0x10ec0269: |
3155 | spec->codec_variant = ALC269_TYPE_ALC269VA; | 3123 | spec->codec_variant = ALC269_TYPE_ALC269VA; |
@@ -3198,12 +3166,8 @@ static int patch_alc269(struct hda_codec *codec) | |||
3198 | if (err < 0) | 3166 | if (err < 0) |
3199 | goto error; | 3167 | goto error; |
3200 | 3168 | ||
3201 | if (!spec->gen.no_analog && has_cdefine_beep(codec)) { | 3169 | if (!spec->gen.no_analog && spec->gen.beep_nid) |
3202 | err = snd_hda_attach_beep_device(codec, 0x1); | ||
3203 | if (err < 0) | ||
3204 | goto error; | ||
3205 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); | 3170 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
3206 | } | ||
3207 | 3171 | ||
3208 | codec->patch_ops = alc_patch_ops; | 3172 | codec->patch_ops = alc_patch_ops; |
3209 | #ifdef CONFIG_PM | 3173 | #ifdef CONFIG_PM |
@@ -3311,6 +3275,7 @@ static int patch_alc861(struct hda_codec *codec) | |||
3311 | return err; | 3275 | return err; |
3312 | 3276 | ||
3313 | spec = codec->spec; | 3277 | spec = codec->spec; |
3278 | spec->gen.beep_nid = 0x23; | ||
3314 | 3279 | ||
3315 | snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); | 3280 | snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); |
3316 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); | 3281 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
@@ -3320,12 +3285,8 @@ static int patch_alc861(struct hda_codec *codec) | |||
3320 | if (err < 0) | 3285 | if (err < 0) |
3321 | goto error; | 3286 | goto error; |
3322 | 3287 | ||
3323 | if (!spec->gen.no_analog) { | 3288 | if (!spec->gen.no_analog) |
3324 | err = snd_hda_attach_beep_device(codec, 0x23); | ||
3325 | if (err < 0) | ||
3326 | goto error; | ||
3327 | set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); | 3289 | set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); |
3328 | } | ||
3329 | 3290 | ||
3330 | codec->patch_ops = alc_patch_ops; | 3291 | codec->patch_ops = alc_patch_ops; |
3331 | #ifdef CONFIG_PM | 3292 | #ifdef CONFIG_PM |
@@ -3406,6 +3367,7 @@ static int patch_alc861vd(struct hda_codec *codec) | |||
3406 | return err; | 3367 | return err; |
3407 | 3368 | ||
3408 | spec = codec->spec; | 3369 | spec = codec->spec; |
3370 | spec->gen.beep_nid = 0x23; | ||
3409 | 3371 | ||
3410 | snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); | 3372 | snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); |
3411 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); | 3373 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
@@ -3415,12 +3377,8 @@ static int patch_alc861vd(struct hda_codec *codec) | |||
3415 | if (err < 0) | 3377 | if (err < 0) |
3416 | goto error; | 3378 | goto error; |
3417 | 3379 | ||
3418 | if (!spec->gen.no_analog) { | 3380 | if (!spec->gen.no_analog) |
3419 | err = snd_hda_attach_beep_device(codec, 0x23); | ||
3420 | if (err < 0) | ||
3421 | goto error; | ||
3422 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 3381 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
3423 | } | ||
3424 | 3382 | ||
3425 | codec->patch_ops = alc_patch_ops; | 3383 | codec->patch_ops = alc_patch_ops; |
3426 | 3384 | ||
@@ -3802,6 +3760,9 @@ static int patch_alc662(struct hda_codec *codec) | |||
3802 | 3760 | ||
3803 | alc_auto_parse_customize_define(codec); | 3761 | alc_auto_parse_customize_define(codec); |
3804 | 3762 | ||
3763 | if (has_cdefine_beep(codec)) | ||
3764 | spec->gen.beep_nid = 0x01; | ||
3765 | |||
3805 | if ((alc_get_coef0(codec) & (1 << 14)) && | 3766 | if ((alc_get_coef0(codec) & (1 << 14)) && |
3806 | codec->bus->pci->subsystem_vendor == 0x1025 && | 3767 | codec->bus->pci->subsystem_vendor == 0x1025 && |
3807 | spec->cdefine.platform_type == 1) { | 3768 | spec->cdefine.platform_type == 1) { |
@@ -3814,10 +3775,7 @@ static int patch_alc662(struct hda_codec *codec) | |||
3814 | if (err < 0) | 3775 | if (err < 0) |
3815 | goto error; | 3776 | goto error; |
3816 | 3777 | ||
3817 | if (!spec->gen.no_analog && has_cdefine_beep(codec)) { | 3778 | if (!spec->gen.no_analog && spec->gen.beep_nid) { |
3818 | err = snd_hda_attach_beep_device(codec, 0x1); | ||
3819 | if (err < 0) | ||
3820 | goto error; | ||
3821 | switch (codec->vendor_id) { | 3779 | switch (codec->vendor_id) { |
3822 | case 0x10ec0662: | 3780 | case 0x10ec0662: |
3823 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 3781 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 356673106788..3be877bd8a92 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -211,7 +211,6 @@ struct sigmatel_spec { | |||
211 | 211 | ||
212 | /* beep widgets */ | 212 | /* beep widgets */ |
213 | hda_nid_t anabeep_nid; | 213 | hda_nid_t anabeep_nid; |
214 | hda_nid_t digbeep_nid; | ||
215 | 214 | ||
216 | /* SPDIF-out mux */ | 215 | /* SPDIF-out mux */ |
217 | const char * const *spdif_labels; | 216 | const char * const *spdif_labels; |
@@ -3560,16 +3559,13 @@ static int stac_parse_auto_config(struct hda_codec *codec) | |||
3560 | 3559 | ||
3561 | /* setup digital beep controls and input device */ | 3560 | /* setup digital beep controls and input device */ |
3562 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | 3561 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
3563 | if (spec->digbeep_nid > 0) { | 3562 | if (spec->gen.beep_nid) { |
3564 | hda_nid_t nid = spec->digbeep_nid; | 3563 | hda_nid_t nid = spec->gen.beep_nid; |
3565 | unsigned int caps; | 3564 | unsigned int caps; |
3566 | 3565 | ||
3567 | err = stac_auto_create_beep_ctls(codec, nid); | 3566 | err = stac_auto_create_beep_ctls(codec, nid); |
3568 | if (err < 0) | 3567 | if (err < 0) |
3569 | return err; | 3568 | return err; |
3570 | err = snd_hda_attach_beep_device(codec, nid); | ||
3571 | if (err < 0) | ||
3572 | return err; | ||
3573 | if (codec->beep) { | 3569 | if (codec->beep) { |
3574 | /* IDT/STAC codecs have linear beep tone parameter */ | 3570 | /* IDT/STAC codecs have linear beep tone parameter */ |
3575 | codec->beep->linear_tone = spec->linear_tone_beep; | 3571 | codec->beep->linear_tone = spec->linear_tone_beep; |
@@ -3657,17 +3653,7 @@ static void stac_shutup(struct hda_codec *codec) | |||
3657 | ~spec->eapd_mask); | 3653 | ~spec->eapd_mask); |
3658 | } | 3654 | } |
3659 | 3655 | ||
3660 | static void stac_free(struct hda_codec *codec) | 3656 | #define stac_free snd_hda_gen_free |
3661 | { | ||
3662 | struct sigmatel_spec *spec = codec->spec; | ||
3663 | |||
3664 | if (!spec) | ||
3665 | return; | ||
3666 | |||
3667 | snd_hda_gen_spec_free(&spec->gen); | ||
3668 | kfree(spec); | ||
3669 | snd_hda_detach_beep_device(codec); | ||
3670 | } | ||
3671 | 3657 | ||
3672 | #ifdef CONFIG_PROC_FS | 3658 | #ifdef CONFIG_PROC_FS |
3673 | static void stac92hd_proc_hook(struct snd_info_buffer *buffer, | 3659 | static void stac92hd_proc_hook(struct snd_info_buffer *buffer, |
@@ -3885,7 +3871,7 @@ static int patch_stac92hd73xx(struct hda_codec *codec) | |||
3885 | spec->aloopback_mask = 0x01; | 3871 | spec->aloopback_mask = 0x01; |
3886 | spec->aloopback_shift = 8; | 3872 | spec->aloopback_shift = 8; |
3887 | 3873 | ||
3888 | spec->digbeep_nid = 0x1c; | 3874 | spec->gen.beep_nid = 0x1c; /* digital beep */ |
3889 | 3875 | ||
3890 | /* GPIO0 High = Enable EAPD */ | 3876 | /* GPIO0 High = Enable EAPD */ |
3891 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; | 3877 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
@@ -3969,7 +3955,7 @@ static int patch_stac92hd83xxx(struct hda_codec *codec) | |||
3969 | spec->gen.power_down_unused = 1; | 3955 | spec->gen.power_down_unused = 1; |
3970 | spec->gen.mixer_nid = 0x1b; | 3956 | spec->gen.mixer_nid = 0x1b; |
3971 | 3957 | ||
3972 | spec->digbeep_nid = 0x21; | 3958 | spec->gen.beep_nid = 0x21; /* digital beep */ |
3973 | spec->pwr_nids = stac92hd83xxx_pwr_nids; | 3959 | spec->pwr_nids = stac92hd83xxx_pwr_nids; |
3974 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); | 3960 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); |
3975 | spec->default_polarity = -1; /* no default cfg */ | 3961 | spec->default_polarity = -1; /* no default cfg */ |
@@ -4017,7 +4003,7 @@ static int patch_stac92hd95(struct hda_codec *codec) | |||
4017 | spec->gen.own_eapd_ctl = 1; | 4003 | spec->gen.own_eapd_ctl = 1; |
4018 | spec->gen.power_down_unused = 1; | 4004 | spec->gen.power_down_unused = 1; |
4019 | 4005 | ||
4020 | spec->digbeep_nid = 0x19; | 4006 | spec->gen.beep_nid = 0x19; /* digital beep */ |
4021 | spec->pwr_nids = stac92hd95_pwr_nids; | 4007 | spec->pwr_nids = stac92hd95_pwr_nids; |
4022 | spec->num_pwrs = ARRAY_SIZE(stac92hd95_pwr_nids); | 4008 | spec->num_pwrs = ARRAY_SIZE(stac92hd95_pwr_nids); |
4023 | spec->default_polarity = -1; /* no default cfg */ | 4009 | spec->default_polarity = -1; /* no default cfg */ |
@@ -4092,7 +4078,7 @@ static int patch_stac92hd71bxx(struct hda_codec *codec) | |||
4092 | spec->aloopback_shift = 0; | 4078 | spec->aloopback_shift = 0; |
4093 | 4079 | ||
4094 | spec->powerdown_adcs = 1; | 4080 | spec->powerdown_adcs = 1; |
4095 | spec->digbeep_nid = 0x26; | 4081 | spec->gen.beep_nid = 0x26; /* digital beep */ |
4096 | spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids); | 4082 | spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids); |
4097 | spec->pwr_nids = stac92hd71bxx_pwr_nids; | 4083 | spec->pwr_nids = stac92hd71bxx_pwr_nids; |
4098 | 4084 | ||
@@ -4174,7 +4160,7 @@ static int patch_stac927x(struct hda_codec *codec) | |||
4174 | spec->have_spdif_mux = 1; | 4160 | spec->have_spdif_mux = 1; |
4175 | spec->spdif_labels = stac927x_spdif_labels; | 4161 | spec->spdif_labels = stac927x_spdif_labels; |
4176 | 4162 | ||
4177 | spec->digbeep_nid = 0x23; | 4163 | spec->gen.beep_nid = 0x23; /* digital beep */ |
4178 | 4164 | ||
4179 | /* GPIO0 High = Enable EAPD */ | 4165 | /* GPIO0 High = Enable EAPD */ |
4180 | spec->eapd_mask = spec->gpio_mask = 0x01; | 4166 | spec->eapd_mask = spec->gpio_mask = 0x01; |
@@ -4233,7 +4219,7 @@ static int patch_stac9205(struct hda_codec *codec) | |||
4233 | spec->gen.own_eapd_ctl = 1; | 4219 | spec->gen.own_eapd_ctl = 1; |
4234 | spec->have_spdif_mux = 1; | 4220 | spec->have_spdif_mux = 1; |
4235 | 4221 | ||
4236 | spec->digbeep_nid = 0x23; | 4222 | spec->gen.beep_nid = 0x23; /* digital beep */ |
4237 | 4223 | ||
4238 | snd_hda_add_verbs(codec, stac9205_core_init); | 4224 | snd_hda_add_verbs(codec, stac9205_core_init); |
4239 | spec->aloopback_ctl = &stac9205_loopback; | 4225 | spec->aloopback_ctl = &stac9205_loopback; |