diff options
author | Andres Salomon <dilinger@queued.net> | 2008-11-06 16:53:03 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2008-12-10 11:14:45 -0500 |
commit | bf1e5278354856ac0260d338961560e720147681 (patch) | |
tree | 30bdedbee576613e54f7b9f3ff7167effa7149d8 /sound/pci/cs5535audio/cs5535audio_olpc.c | |
parent | e463ae1d13ffe4943bb31f47cc6f24415e55a59a (diff) |
ALSA: cs5535audio: rename V_REFOUT control to MIC Bias
This drops the AD1888 V_REFOUT control, and replaces it with a MIC Bias
Enable control. It also moves the MIC bias enabling into a separate
function.
Signed-off-by: Andres Salomon <dilinger@debian.org>
Diffstat (limited to 'sound/pci/cs5535audio/cs5535audio_olpc.c')
-rw-r--r-- | sound/pci/cs5535audio/cs5535audio_olpc.c | 73 |
1 files changed, 69 insertions, 4 deletions
diff --git a/sound/pci/cs5535audio/cs5535audio_olpc.c b/sound/pci/cs5535audio/cs5535audio_olpc.c index 7f26cfbc8f52..73811e0e8ac7 100644 --- a/sound/pci/cs5535audio/cs5535audio_olpc.c +++ b/sound/pci/cs5535audio/cs5535audio_olpc.c | |||
@@ -31,6 +31,20 @@ void olpc_analog_input(struct snd_ac97 *ac97, int on) | |||
31 | geode_gpio_clear(OLPC_GPIO_MIC_AC, GPIO_OUTPUT_VAL); | 31 | geode_gpio_clear(OLPC_GPIO_MIC_AC, GPIO_OUTPUT_VAL); |
32 | } | 32 | } |
33 | 33 | ||
34 | /* | ||
35 | * OLPC XO-1's V_REFOUT is a mic bias enable. | ||
36 | */ | ||
37 | void olpc_mic_bias(struct snd_ac97 *ac97, int on) | ||
38 | { | ||
39 | int err; | ||
40 | |||
41 | on = on ? 0 : 1; | ||
42 | err = snd_ac97_update_bits(ac97, AC97_AD_MISC, | ||
43 | 1 << AC97_AD_VREFD_SHIFT, on << AC97_AD_VREFD_SHIFT); | ||
44 | if (err < 0) | ||
45 | snd_printk(KERN_ERR "setting MIC Bias - %d\n", err); | ||
46 | } | ||
47 | |||
34 | static int olpc_dc_info(struct snd_kcontrol *kctl, | 48 | static int olpc_dc_info(struct snd_kcontrol *kctl, |
35 | struct snd_ctl_elem_info *uinfo) | 49 | struct snd_ctl_elem_info *uinfo) |
36 | { | 50 | { |
@@ -56,7 +70,36 @@ static int olpc_dc_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v) | |||
56 | return 1; | 70 | return 1; |
57 | } | 71 | } |
58 | 72 | ||
59 | static struct snd_kcontrol_new snd_cs5535audio_controls __devinitdata = | 73 | static int olpc_mic_info(struct snd_kcontrol *kctl, |
74 | struct snd_ctl_elem_info *uinfo) | ||
75 | { | ||
76 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | ||
77 | uinfo->count = 1; | ||
78 | uinfo->value.integer.min = 0; | ||
79 | uinfo->value.integer.max = 1; | ||
80 | return 0; | ||
81 | } | ||
82 | |||
83 | static int olpc_mic_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v) | ||
84 | { | ||
85 | struct cs5535audio *cs5535au = snd_kcontrol_chip(kctl); | ||
86 | struct snd_ac97 *ac97 = cs5535au->ac97; | ||
87 | int i; | ||
88 | |||
89 | i = (snd_ac97_read(ac97, AC97_AD_MISC) >> AC97_AD_VREFD_SHIFT) & 0x1; | ||
90 | v->value.integer.value[0] = i ? 0 : 1; | ||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | static int olpc_mic_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v) | ||
95 | { | ||
96 | struct cs5535audio *cs5535au = snd_kcontrol_chip(kctl); | ||
97 | |||
98 | olpc_mic_bias(cs5535au->ac97, v->value.integer.value[0]); | ||
99 | return 1; | ||
100 | } | ||
101 | |||
102 | static struct snd_kcontrol_new olpc_cs5535audio_ctls[] __devinitdata = { | ||
60 | { | 103 | { |
61 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 104 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
62 | .name = "DC Mode Enable", | 105 | .name = "DC Mode Enable", |
@@ -64,6 +107,15 @@ static struct snd_kcontrol_new snd_cs5535audio_controls __devinitdata = | |||
64 | .get = olpc_dc_get, | 107 | .get = olpc_dc_get, |
65 | .put = olpc_dc_put, | 108 | .put = olpc_dc_put, |
66 | .private_value = 0 | 109 | .private_value = 0 |
110 | }, | ||
111 | { | ||
112 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
113 | .name = "MIC Bias Enable", | ||
114 | .info = olpc_mic_info, | ||
115 | .get = olpc_mic_get, | ||
116 | .put = olpc_mic_put, | ||
117 | .private_value = 0, | ||
118 | }, | ||
67 | }; | 119 | }; |
68 | 120 | ||
69 | void __devinit olpc_prequirks(struct snd_card *card, | 121 | void __devinit olpc_prequirks(struct snd_card *card, |
@@ -80,6 +132,7 @@ void __devinit olpc_prequirks(struct snd_card *card, | |||
80 | int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) | 132 | int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) |
81 | { | 133 | { |
82 | struct snd_ctl_elem_id elem; | 134 | struct snd_ctl_elem_id elem; |
135 | int i, err; | ||
83 | 136 | ||
84 | if (!machine_is_olpc()) | 137 | if (!machine_is_olpc()) |
85 | return 0; | 138 | return 0; |
@@ -90,8 +143,20 @@ int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) | |||
90 | strncpy(elem.name, "High Pass Filter Enable", sizeof(elem.name)); | 143 | strncpy(elem.name, "High Pass Filter Enable", sizeof(elem.name)); |
91 | snd_ctl_remove_id(card, &elem); | 144 | snd_ctl_remove_id(card, &elem); |
92 | 145 | ||
93 | /* add the override for OLPC's HPF */ | 146 | /* drop the original V_REFOUT control */ |
94 | return snd_ctl_add(card, snd_ctl_new1(&snd_cs5535audio_controls, | 147 | memset(&elem, 0, sizeof(elem)); |
95 | ac97->private_data)); | 148 | elem.iface = SNDRV_CTL_ELEM_IFACE_MIXER; |
149 | strncpy(elem.name, "V_REFOUT Enable", sizeof(elem.name)); | ||
150 | snd_ctl_remove_id(card, &elem); | ||
151 | |||
152 | /* add the OLPC-specific controls */ | ||
153 | for (i = 0; i < ARRAY_SIZE(olpc_cs5535audio_ctls); i++) { | ||
154 | err = snd_ctl_add(card, snd_ctl_new1(&olpc_cs5535audio_ctls[i], | ||
155 | ac97->private_data)); | ||
156 | if (err < 0) | ||
157 | return err; | ||
158 | } | ||
159 | |||
160 | return 0; | ||
96 | } | 161 | } |
97 | 162 | ||