diff options
Diffstat (limited to 'sound/pci/cs5535audio')
-rw-r--r-- | sound/pci/cs5535audio/cs5535audio.h | 16 | ||||
-rw-r--r-- | sound/pci/cs5535audio/cs5535audio_olpc.c | 73 | ||||
-rw-r--r-- | sound/pci/cs5535audio/cs5535audio_pcm.c | 17 |
3 files changed, 87 insertions, 19 deletions
diff --git a/sound/pci/cs5535audio/cs5535audio.h b/sound/pci/cs5535audio/cs5535audio.h index 22737fc9ed03..63190cd723c6 100644 --- a/sound/pci/cs5535audio/cs5535audio.h +++ b/sound/pci/cs5535audio/cs5535audio.h | |||
@@ -104,6 +104,19 @@ void __devinit olpc_prequirks(struct snd_card *card, | |||
104 | struct snd_ac97_template *ac97); | 104 | struct snd_ac97_template *ac97); |
105 | int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97); | 105 | int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97); |
106 | void olpc_analog_input(struct snd_ac97 *ac97, int on); | 106 | void olpc_analog_input(struct snd_ac97 *ac97, int on); |
107 | void olpc_mic_bias(struct snd_ac97 *ac97, int on); | ||
108 | |||
109 | static inline void olpc_capture_open(struct snd_ac97 *ac97) | ||
110 | { | ||
111 | /* enable MIC Bias for recording */ | ||
112 | olpc_mic_bias(ac97, 1); | ||
113 | } | ||
114 | |||
115 | static inline void olpc_capture_close(struct snd_ac97 *ac97) | ||
116 | { | ||
117 | /* disable the MIC Bias (so the recording LED turns off) */ | ||
118 | olpc_mic_bias(ac97, 0); | ||
119 | } | ||
107 | #else | 120 | #else |
108 | static inline void olpc_prequirks(struct snd_card *card, | 121 | static inline void olpc_prequirks(struct snd_card *card, |
109 | struct snd_ac97_template *ac97) { } | 122 | struct snd_ac97_template *ac97) { } |
@@ -112,6 +125,9 @@ static inline int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) | |||
112 | return 0; | 125 | return 0; |
113 | } | 126 | } |
114 | static inline void olpc_analog_input(struct snd_ac97 *ac97, int on) { } | 127 | static inline void olpc_analog_input(struct snd_ac97 *ac97, int on) { } |
128 | static inline void olpc_mic_bias(struct snd_ac97 *ac97, int on) { } | ||
129 | static inline void olpc_capture_open(struct snd_ac97 *ac97) { } | ||
130 | static inline void olpc_capture_close(struct snd_ac97 *ac97) { } | ||
115 | #endif | 131 | #endif |
116 | 132 | ||
117 | int __devinit snd_cs5535audio_pcm(struct cs5535audio *cs5535audio); | 133 | int __devinit snd_cs5535audio_pcm(struct cs5535audio *cs5535audio); |
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 | ||
diff --git a/sound/pci/cs5535audio/cs5535audio_pcm.c b/sound/pci/cs5535audio/cs5535audio_pcm.c index fa2a6b1b81a6..0f48a871f17b 100644 --- a/sound/pci/cs5535audio/cs5535audio_pcm.c +++ b/sound/pci/cs5535audio/cs5535audio_pcm.c | |||
@@ -363,27 +363,14 @@ static int snd_cs5535audio_capture_open(struct snd_pcm_substream *substream) | |||
363 | if ((err = snd_pcm_hw_constraint_integer(runtime, | 363 | if ((err = snd_pcm_hw_constraint_integer(runtime, |
364 | SNDRV_PCM_HW_PARAM_PERIODS)) < 0) | 364 | SNDRV_PCM_HW_PARAM_PERIODS)) < 0) |
365 | return err; | 365 | return err; |
366 | 366 | olpc_capture_open(cs5535au->ac97); | |
367 | #ifdef CONFIG_OLPC | ||
368 | /* Enable the V_ref bias only while recording. */ | ||
369 | err = snd_ac97_update_bits(cs5535au->ac97, AC97_AD_MISC, | ||
370 | 1 << AC97_AD_VREFD_SHIFT, 0); | ||
371 | if (err < 0) | ||
372 | snd_printk(KERN_ERR "Error updating AD_MISC %d\n", err); | ||
373 | #endif | ||
374 | return 0; | 367 | return 0; |
375 | } | 368 | } |
376 | 369 | ||
377 | static int snd_cs5535audio_capture_close(struct snd_pcm_substream *substream) | 370 | static int snd_cs5535audio_capture_close(struct snd_pcm_substream *substream) |
378 | { | 371 | { |
379 | int err; | ||
380 | struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream); | 372 | struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream); |
381 | 373 | olpc_capture_close(cs5535au->ac97); | |
382 | #ifdef CONFIG_OLPC | ||
383 | /* Disable V_ref bias. */ | ||
384 | err = snd_ac97_update_bits(cs5535au->ac97, AC97_AD_MISC, | ||
385 | 1 << AC97_AD_VREFD_SHIFT, 1 << AC97_AD_VREFD_SHIFT); | ||
386 | #endif | ||
387 | return 0; | 374 | return 0; |
388 | } | 375 | } |
389 | 376 | ||