diff options
author | Matthew Ranostay <mranostay@embeddedalley.com> | 2008-07-18 12:20:52 -0400 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-07-20 13:17:49 -0400 |
commit | 1cd2224cd01898a13138f4ab476932cfb689839e (patch) | |
tree | b482e8f8e6e51fd5143ac9ef7edc88194b031d9c /sound/pci/hda/patch_sigmatel.c | |
parent | 68c072388d2339af504c033a51886ea7c6b8d806 (diff) |
ALSA: hda: digital pc-beep support hd-audio codecs
Added digital pc-beep support using linear tone generation for hd-codecs along
with initial support for several IDT codecs.
Signed-off-by: Matthew Ranostay <mranostay@embeddedalley.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci/hda/patch_sigmatel.c')
-rw-r--r-- | sound/pci/hda/patch_sigmatel.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index f3da621f25c5..6ee73ed23ddd 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include "hda_codec.h" | 33 | #include "hda_codec.h" |
34 | #include "hda_local.h" | 34 | #include "hda_local.h" |
35 | #include "hda_patch.h" | 35 | #include "hda_patch.h" |
36 | #include "hda_beep.h" | ||
36 | 37 | ||
37 | #define NUM_CONTROL_ALLOC 32 | 38 | #define NUM_CONTROL_ALLOC 32 |
38 | #define STAC_PWR_EVENT 0x20 | 39 | #define STAC_PWR_EVENT 0x20 |
@@ -164,6 +165,8 @@ struct sigmatel_spec { | |||
164 | unsigned int num_dmuxes; | 165 | unsigned int num_dmuxes; |
165 | hda_nid_t dig_in_nid; | 166 | hda_nid_t dig_in_nid; |
166 | hda_nid_t mono_nid; | 167 | hda_nid_t mono_nid; |
168 | hda_nid_t anabeep_nid; | ||
169 | hda_nid_t digbeep_nid; | ||
167 | 170 | ||
168 | /* pin widgets */ | 171 | /* pin widgets */ |
169 | hda_nid_t *pin_nids; | 172 | hda_nid_t *pin_nids; |
@@ -690,6 +693,8 @@ static struct hda_verb d965_core_init[] = { | |||
690 | static struct hda_verb stac927x_core_init[] = { | 693 | static struct hda_verb stac927x_core_init[] = { |
691 | /* set master volume and direct control */ | 694 | /* set master volume and direct control */ |
692 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | 695 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
696 | /* enable analog pc beep path */ | ||
697 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, | ||
693 | {} | 698 | {} |
694 | }; | 699 | }; |
695 | 700 | ||
@@ -829,8 +834,11 @@ static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = { | |||
829 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), | 834 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
830 | HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT), | 835 | HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT), |
831 | 836 | ||
837 | /* analog pc-beep replaced with digital beep support */ | ||
838 | /* | ||
832 | HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT), | 839 | HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT), |
833 | HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT), | 840 | HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT), |
841 | */ | ||
834 | 842 | ||
835 | HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT), | 843 | HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT), |
836 | HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT), | 844 | HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT), |
@@ -2609,6 +2617,34 @@ static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec) | |||
2609 | "Mono Mux", spec->mono_nid); | 2617 | "Mono Mux", spec->mono_nid); |
2610 | } | 2618 | } |
2611 | 2619 | ||
2620 | /* create PC beep volume controls */ | ||
2621 | static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, | ||
2622 | hda_nid_t nid) | ||
2623 | { | ||
2624 | struct sigmatel_spec *spec = codec->spec; | ||
2625 | u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT); | ||
2626 | int err; | ||
2627 | |||
2628 | /* check for mute support for the the amp */ | ||
2629 | if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) { | ||
2630 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, | ||
2631 | "PC Beep Playback Switch", | ||
2632 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); | ||
2633 | if (err < 0) | ||
2634 | return err; | ||
2635 | } | ||
2636 | |||
2637 | /* check to see if there is volume support for the amp */ | ||
2638 | if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) { | ||
2639 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, | ||
2640 | "PC Beep Playback Volume", | ||
2641 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); | ||
2642 | if (err < 0) | ||
2643 | return err; | ||
2644 | } | ||
2645 | return 0; | ||
2646 | } | ||
2647 | |||
2612 | /* labels for dmic mux inputs */ | 2648 | /* labels for dmic mux inputs */ |
2613 | static const char *stac92xx_dmic_labels[5] = { | 2649 | static const char *stac92xx_dmic_labels[5] = { |
2614 | "Analog Inputs", "Digital Mic 1", "Digital Mic 2", | 2650 | "Analog Inputs", "Digital Mic 1", "Digital Mic 2", |
@@ -2844,6 +2880,28 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
2844 | if (err < 0) | 2880 | if (err < 0) |
2845 | return err; | 2881 | return err; |
2846 | 2882 | ||
2883 | /* setup analog beep controls */ | ||
2884 | if (spec->anabeep_nid > 0) { | ||
2885 | err = stac92xx_auto_create_beep_ctls(codec, | ||
2886 | spec->anabeep_nid); | ||
2887 | if (err < 0) | ||
2888 | return err; | ||
2889 | } | ||
2890 | |||
2891 | /* setup digital beep controls and input device */ | ||
2892 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | ||
2893 | if (spec->digbeep_nid > 0) { | ||
2894 | hda_nid_t nid = spec->digbeep_nid; | ||
2895 | |||
2896 | err = stac92xx_auto_create_beep_ctls(codec, nid); | ||
2897 | if (err < 0) | ||
2898 | return err; | ||
2899 | err = snd_hda_attach_beep_device(codec, nid); | ||
2900 | if (err < 0) | ||
2901 | return err; | ||
2902 | } | ||
2903 | #endif | ||
2904 | |||
2847 | if (hp_speaker_swap == 1) { | 2905 | if (hp_speaker_swap == 1) { |
2848 | /* Restore the hp_outs and line_outs */ | 2906 | /* Restore the hp_outs and line_outs */ |
2849 | memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins, | 2907 | memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins, |
@@ -3158,6 +3216,7 @@ static void stac92xx_free(struct hda_codec *codec) | |||
3158 | kfree(spec->bios_pin_configs); | 3216 | kfree(spec->bios_pin_configs); |
3159 | 3217 | ||
3160 | kfree(spec); | 3218 | kfree(spec); |
3219 | snd_hda_detach_beep_device(codec); | ||
3161 | } | 3220 | } |
3162 | 3221 | ||
3163 | static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, | 3222 | static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, |
@@ -3546,6 +3605,7 @@ again: | |||
3546 | spec->aloopback_mask = 0x01; | 3605 | spec->aloopback_mask = 0x01; |
3547 | spec->aloopback_shift = 8; | 3606 | spec->aloopback_shift = 8; |
3548 | 3607 | ||
3608 | spec->digbeep_nid = 0x1c; | ||
3549 | spec->mux_nids = stac92hd73xx_mux_nids; | 3609 | spec->mux_nids = stac92hd73xx_mux_nids; |
3550 | spec->adc_nids = stac92hd73xx_adc_nids; | 3610 | spec->adc_nids = stac92hd73xx_adc_nids; |
3551 | spec->dmic_nids = stac92hd73xx_dmic_nids; | 3611 | spec->dmic_nids = stac92hd73xx_dmic_nids; |
@@ -3680,6 +3740,7 @@ again: | |||
3680 | spec->gpio_dir = 0x01; | 3740 | spec->gpio_dir = 0x01; |
3681 | spec->gpio_data = 0x01; | 3741 | spec->gpio_data = 0x01; |
3682 | 3742 | ||
3743 | spec->digbeep_nid = 0x26; | ||
3683 | spec->mux_nids = stac92hd71bxx_mux_nids; | 3744 | spec->mux_nids = stac92hd71bxx_mux_nids; |
3684 | spec->adc_nids = stac92hd71bxx_adc_nids; | 3745 | spec->adc_nids = stac92hd71bxx_adc_nids; |
3685 | spec->dmic_nids = stac92hd71bxx_dmic_nids; | 3746 | spec->dmic_nids = stac92hd71bxx_dmic_nids; |
@@ -3854,6 +3915,7 @@ static int patch_stac927x(struct hda_codec *codec) | |||
3854 | stac92xx_set_config_regs(codec); | 3915 | stac92xx_set_config_regs(codec); |
3855 | } | 3916 | } |
3856 | 3917 | ||
3918 | spec->digbeep_nid = 0x23; | ||
3857 | spec->adc_nids = stac927x_adc_nids; | 3919 | spec->adc_nids = stac927x_adc_nids; |
3858 | spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids); | 3920 | spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids); |
3859 | spec->mux_nids = stac927x_mux_nids; | 3921 | spec->mux_nids = stac927x_mux_nids; |
@@ -3974,6 +4036,7 @@ static int patch_stac9205(struct hda_codec *codec) | |||
3974 | stac92xx_set_config_regs(codec); | 4036 | stac92xx_set_config_regs(codec); |
3975 | } | 4037 | } |
3976 | 4038 | ||
4039 | spec->digbeep_nid = 0x23; | ||
3977 | spec->adc_nids = stac9205_adc_nids; | 4040 | spec->adc_nids = stac9205_adc_nids; |
3978 | spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids); | 4041 | spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids); |
3979 | spec->mux_nids = stac9205_mux_nids; | 4042 | spec->mux_nids = stac9205_mux_nids; |