From 0bed7b292d68f82316bfb8cd521e16c867689efe Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Wed, 5 Nov 2008 17:29:53 -0500 Subject: ALSA: cs5535audio: stick AD1888 bitshift values into a header file We'd like to use the High Pass Filter and V_REFOUT bitshift values elsewhere, so stick them into a ac97_codec.h. Signed-off-by: Andres Salomon Signed-off-by: Takashi Iwai --- sound/pci/ac97/ac97_patch.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c index 6e831aff1bd0..7ad25f439b50 100644 --- a/sound/pci/ac97/ac97_patch.c +++ b/sound/pci/ac97/ac97_patch.c @@ -2054,8 +2054,9 @@ static const struct snd_kcontrol_new snd_ac97_ad1888_controls[] = { .get = snd_ac97_ad1888_lohpsel_get, .put = snd_ac97_ad1888_lohpsel_put }, - AC97_SINGLE("V_REFOUT Enable", AC97_AD_MISC, 2, 1, 1), - AC97_SINGLE("High Pass Filter Enable", AC97_AD_TEST2, 12, 1, 1), + AC97_SINGLE("V_REFOUT Enable", AC97_AD_MISC, AC97_AD_VREFD_SHIFT, 1, 1), + AC97_SINGLE("High Pass Filter Enable", AC97_AD_TEST2, + AC97_AD_HPFD_SHIFT, 1, 1), AC97_SINGLE("Spread Front to Surround and Center/LFE", AC97_AD_MISC, 7, 1, 0), { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, -- cgit v1.2.3-59-g8ed1b From b035ce0f26812292d067fbe2fc9e9d88d5dfcdb4 Mon Sep 17 00:00:00 2001 From: Jaya Kumar Date: Wed, 5 Nov 2008 17:30:08 -0500 Subject: ALSA: cs5535audio: turn off PCM properly if closing the audio device As per , we need to properly turn off the PCM if we're closing the device in order to save power. This also causes the MIC led to turn off properly. Signed-off-by: Jaya Kumar Signed-off-by: Andres Salomon Signed-off-by: Takashi Iwai --- sound/pci/cs5535audio/cs5535audio.c | 3 ++- sound/pci/cs5535audio/cs5535audio.h | 1 + sound/pci/cs5535audio/cs5535audio_pcm.c | 12 ++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c index 1d8b16052535..6c886edd06db 100644 --- a/sound/pci/cs5535audio/cs5535audio.c +++ b/sound/pci/cs5535audio/cs5535audio.c @@ -159,7 +159,8 @@ static int __devinit snd_cs5535audio_mixer(struct cs5535audio *cs5535au) return err; memset(&ac97, 0, sizeof(ac97)); - ac97.scaps = AC97_SCAP_AUDIO|AC97_SCAP_SKIP_MODEM; + ac97.scaps = AC97_SCAP_AUDIO | AC97_SCAP_SKIP_MODEM + | AC97_SCAP_POWER_SAVE; ac97.private_data = cs5535au; ac97.pci = cs5535au->pci; diff --git a/sound/pci/cs5535audio/cs5535audio.h b/sound/pci/cs5535audio/cs5535audio.h index 66bae7664193..57e9c65e6854 100644 --- a/sound/pci/cs5535audio/cs5535audio.h +++ b/sound/pci/cs5535audio/cs5535audio.h @@ -78,6 +78,7 @@ struct cs5535audio_dma { unsigned int buf_addr, buf_bytes; unsigned int period_bytes, periods; u32 saved_prd; + int pcm_open_flag; }; struct cs5535audio { diff --git a/sound/pci/cs5535audio/cs5535audio_pcm.c b/sound/pci/cs5535audio/cs5535audio_pcm.c index cdcda87116c3..6aa0c19390d7 100644 --- a/sound/pci/cs5535audio/cs5535audio_pcm.c +++ b/sound/pci/cs5535audio/cs5535audio_pcm.c @@ -260,6 +260,9 @@ static int snd_cs5535audio_hw_params(struct snd_pcm_substream *substream, err = cs5535audio_build_dma_packets(cs5535au, dma, substream, params_periods(hw_params), params_period_bytes(hw_params)); + if (!err) + dma->pcm_open_flag = 1; + return err; } @@ -268,6 +271,15 @@ static int snd_cs5535audio_hw_free(struct snd_pcm_substream *substream) struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream); struct cs5535audio_dma *dma = substream->runtime->private_data; + if (dma->pcm_open_flag) { + if (substream == cs5535au->playback_substream) + snd_ac97_update_power(cs5535au->ac97, + AC97_PCM_FRONT_DAC_RATE, 0); + else + snd_ac97_update_power(cs5535au->ac97, + AC97_PCM_LR_ADC_RATE, 0); + dma->pcm_open_flag = 0; + } cs5535audio_clear_dma_packets(cs5535au, dma, substream); return snd_pcm_lib_free_pages(substream); } -- cgit v1.2.3-59-g8ed1b From b6c52a2cdb58fca918eef9ada5ef3a6cd17a9240 Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Wed, 5 Nov 2008 17:30:30 -0500 Subject: ALSA: cs5535audio: suspend/resume callbacks are only defined with CONFIG_PM snd_cs5535audio_suspend and snd_cs5535audio_resume are only defined when CONFIG_PM is set; make that clear in the header file. Signed-off-by: Andres Salomon Signed-off-by: Takashi Iwai --- sound/pci/cs5535audio/cs5535audio.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sound') diff --git a/sound/pci/cs5535audio/cs5535audio.h b/sound/pci/cs5535audio/cs5535audio.h index 57e9c65e6854..1aa1e2bbdf74 100644 --- a/sound/pci/cs5535audio/cs5535audio.h +++ b/sound/pci/cs5535audio/cs5535audio.h @@ -94,8 +94,11 @@ struct cs5535audio { struct cs5535audio_dma dmas[NUM_CS5535AUDIO_DMAS]; }; +#ifdef CONFIG_PM int snd_cs5535audio_suspend(struct pci_dev *pci, pm_message_t state); int snd_cs5535audio_resume(struct pci_dev *pci); +#endif + int __devinit snd_cs5535audio_pcm(struct cs5535audio *cs5535audio); #endif /* __SOUND_CS5535AUDIO_H */ -- cgit v1.2.3-59-g8ed1b From 57d4bf6d8e965404b82b105ae44ddf137bb7b8e6 Mon Sep 17 00:00:00 2001 From: Jaya Kumar Date: Thu, 6 Nov 2008 16:43:34 -0500 Subject: ALSA: cs5535audio: OLPC analog input support This is a 2nd cut at adding support for OLPC analog input. Signed-off-by: Jaya Kumar Signed-off-by: Andres Salomon --- sound/pci/cs5535audio/Makefile | 4 ++ sound/pci/cs5535audio/cs5535audio.c | 7 ++ sound/pci/cs5535audio/cs5535audio.h | 9 +++ sound/pci/cs5535audio/cs5535audio_olpc.c | 113 +++++++++++++++++++++++++++++++ 4 files changed, 133 insertions(+) create mode 100644 sound/pci/cs5535audio/cs5535audio_olpc.c (limited to 'sound') diff --git a/sound/pci/cs5535audio/Makefile b/sound/pci/cs5535audio/Makefile index bb3d57e6a3cb..3e41fd39780d 100644 --- a/sound/pci/cs5535audio/Makefile +++ b/sound/pci/cs5535audio/Makefile @@ -5,5 +5,9 @@ snd-cs5535audio-y := cs5535audio.o cs5535audio_pcm.o snd-cs5535audio-$(CONFIG_PM) += cs5535audio_pm.o +ifdef CONFIG_OLPC +snd-cs5535audio-objs += cs5535audio_olpc.o +endif + # Toplevel Module Dependency obj-$(CONFIG_SND_CS5535AUDIO) += snd-cs5535audio.o diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c index 6c886edd06db..50333bb9242c 100644 --- a/sound/pci/cs5535audio/cs5535audio.c +++ b/sound/pci/cs5535audio/cs5535audio.c @@ -171,6 +171,13 @@ static int __devinit snd_cs5535audio_mixer(struct cs5535audio *cs5535au) snd_ac97_tune_hardware(cs5535au->ac97, ac97_quirks, ac97_quirk); + /* olpc_quirks is dummied out if not olpc */ + err = olpc_quirks(card, cs5535au->ac97); + if (err < 0) { + snd_printk(KERN_ERR "olpc quirks failed\n"); + return err; + } + return 0; } diff --git a/sound/pci/cs5535audio/cs5535audio.h b/sound/pci/cs5535audio/cs5535audio.h index 1aa1e2bbdf74..adcb213eb276 100644 --- a/sound/pci/cs5535audio/cs5535audio.h +++ b/sound/pci/cs5535audio/cs5535audio.h @@ -92,6 +92,9 @@ struct cs5535audio { struct snd_pcm_substream *playback_substream; struct snd_pcm_substream *capture_substream; struct cs5535audio_dma dmas[NUM_CS5535AUDIO_DMAS]; +#ifdef CONFIG_OLPC + int ec_analog_input_mode; +#endif }; #ifdef CONFIG_PM @@ -99,6 +102,12 @@ int snd_cs5535audio_suspend(struct pci_dev *pci, pm_message_t state); int snd_cs5535audio_resume(struct pci_dev *pci); #endif +#ifdef CONFIG_OLPC +int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97); +#else +#define olpc_quirks(arg, arg2) (0) +#endif + int __devinit snd_cs5535audio_pcm(struct cs5535audio *cs5535audio); #endif /* __SOUND_CS5535AUDIO_H */ diff --git a/sound/pci/cs5535audio/cs5535audio_olpc.c b/sound/pci/cs5535audio/cs5535audio_olpc.c new file mode 100644 index 000000000000..4b72d8662ec9 --- /dev/null +++ b/sound/pci/cs5535audio/cs5535audio_olpc.c @@ -0,0 +1,113 @@ +#include +#include +#include +#include +#include +#include +#include "cs5535audio.h" + +/* OLPC has an additional feature on top of regular AD1888 codec +features. This is support for an analog input mode. This is a +2 step process. First, to turn off the AD1888 codec bias voltage +and high pass filter. Second, to tell the embedded controller to +reroute from a capacitive trace to a direct trace using an analog +switch. The *_ec()s are what talk to that controller */ + +static int snd_cs5535audio_ctl_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; + uinfo->count = 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 1; + return 0; +} + +#define AD1888_VREFOUT_EN_BIT (1 << 2) +#define AD1888_HPF_EN_BIT (1 << 12) +static int snd_cs5535audio_ctl_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct cs5535audio *cs5535au = snd_kcontrol_chip(kcontrol); + u16 reg1, reg2; + + /* if either AD1888 VRef Bias and High Pass Filter are enabled + or the EC is not in analog mode then flag as not in analog mode. + No EC command to read current analog state so we cache that. */ + reg1 = snd_ac97_read(cs5535au->ac97, AC97_AD_MISC); + reg2 = snd_ac97_read(cs5535au->ac97, AC97_AD_TEST2); + + if ((reg1 & AD1888_VREFOUT_EN_BIT) && (reg2 & AD1888_HPF_EN_BIT) && + cs5535au->ec_analog_input_mode) + ucontrol->value.integer.value[0] = 1; + else + ucontrol->value.integer.value[0] = 0; + + return 0; +} + +static int snd_cs5535audio_ctl_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + int err; + struct cs5535audio *cs5535au = snd_kcontrol_chip(kcontrol); + u8 value; + struct snd_ac97 *ac97 = cs5535au->ac97; + + /* value is 1 if analog input is desired */ + value = ucontrol->value.integer.value[0]; + + /* use ec mode as flag to determine if any change needed */ + if (cs5535au->ec_analog_input_mode == value) + return 0; + + /* sets High Z on VREF Bias if 1 */ + if (value) + err = snd_ac97_update_bits(ac97, AC97_AD_MISC, + AD1888_VREFOUT_EN_BIT, AD1888_VREFOUT_EN_BIT); + else + err = snd_ac97_update_bits(ac97, AC97_AD_MISC, + AD1888_VREFOUT_EN_BIT, 0); + if (err < 0) + snd_printk(KERN_ERR "Error updating AD_MISC %d\n", err); + + /* turns off High Pass Filter if 1 */ + if (value) + err = snd_ac97_update_bits(ac97, AC97_AD_TEST2, + AD1888_HPF_EN_BIT, AD1888_HPF_EN_BIT); + else + err = snd_ac97_update_bits(ac97, AC97_AD_TEST2, + AD1888_HPF_EN_BIT, 0); + if (err < 0) + snd_printk(KERN_ERR "Error updating AD_TEST2 %d\n", err); + + if (value) + err = write_ec_command(0x01); /* activate MIC_AC_OFF */ + else + err = write_ec_command(0x02); /* deactivates MIC_AC_OFF */ + + if (err < 0) + snd_printk(KERN_ERR "Error talking to EC %d\n", err); + + cs5535au->ec_analog_input_mode = value; + + return 1; +} + +static struct snd_kcontrol_new snd_cs5535audio_controls __devinitdata = +{ + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Analog Input Switch", + .info = snd_cs5535audio_ctl_info, + .get = snd_cs5535audio_ctl_get, + .put = snd_cs5535audio_ctl_put, + .private_value = 0 +}; + +int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) +{ + /* setup callback for mixer control that does analog input mode */ + return snd_ctl_add(card, snd_ctl_new1(&snd_cs5535audio_controls, + ac97->private_data)); +} + -- cgit v1.2.3-59-g8ed1b From c8974be5465b87414fa542cf9cca1a1ba21b8d60 Mon Sep 17 00:00:00 2001 From: Jordan Crouse Date: Thu, 6 Nov 2008 16:43:53 -0500 Subject: ALSA: cs5535audio: Use OLPC/Geode basic infrastructure Use basic infrastructure code; geode_gpio* (rather than indexed i/o EC access), and do an OLPC machine check in olpc_quirk. [dilinger@debian.org: don't return failure in olpc_quirks if !OLPC] [dilinger@debian.org: drop the Signed-off-by: Andres Salomon --- sound/pci/cs5535audio/cs5535audio_olpc.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/pci/cs5535audio/cs5535audio_olpc.c b/sound/pci/cs5535audio/cs5535audio_olpc.c index 4b72d8662ec9..9073fb353f0e 100644 --- a/sound/pci/cs5535audio/cs5535audio_olpc.c +++ b/sound/pci/cs5535audio/cs5535audio_olpc.c @@ -1,9 +1,10 @@ -#include #include #include #include #include #include + +#include #include "cs5535audio.h" /* OLPC has an additional feature on top of regular AD1888 codec @@ -81,13 +82,11 @@ static int snd_cs5535audio_ctl_put(struct snd_kcontrol *kcontrol, if (err < 0) snd_printk(KERN_ERR "Error updating AD_TEST2 %d\n", err); + /* B2 and newer writes directly to a GPIO pin */ if (value) - err = write_ec_command(0x01); /* activate MIC_AC_OFF */ + geode_gpio_set(OLPC_GPIO_MIC_AC, GPIO_OUTPUT_VAL); else - err = write_ec_command(0x02); /* deactivates MIC_AC_OFF */ - - if (err < 0) - snd_printk(KERN_ERR "Error talking to EC %d\n", err); + geode_gpio_clear(OLPC_GPIO_MIC_AC, GPIO_OUTPUT_VAL); cs5535au->ec_analog_input_mode = value; @@ -106,6 +105,9 @@ static struct snd_kcontrol_new snd_cs5535audio_controls __devinitdata = int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) { + if (!machine_is_olpc()) + return 0; + /* setup callback for mixer control that does analog input mode */ return snd_ctl_add(card, snd_ctl_new1(&snd_cs5535audio_controls, ac97->private_data)); -- cgit v1.2.3-59-g8ed1b From 3556d18465c6e67c7a8f436428b95671add02f57 Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Thu, 6 Nov 2008 16:44:08 -0500 Subject: ALSA: cs5535audio: invert EAPD for OLPC (newer than B3) Fix an audible pop described in . Originally based upon fixes by Mitch Bradley and Chris Ball. Signed-off-by: Andres Salomon --- sound/pci/cs5535audio/cs5535audio.c | 3 +++ sound/pci/cs5535audio/cs5535audio.h | 11 +++++++++-- sound/pci/cs5535audio/cs5535audio_olpc.c | 11 +++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c index 50333bb9242c..130f10a8d524 100644 --- a/sound/pci/cs5535audio/cs5535audio.c +++ b/sound/pci/cs5535audio/cs5535audio.c @@ -164,6 +164,9 @@ static int __devinit snd_cs5535audio_mixer(struct cs5535audio *cs5535au) ac97.private_data = cs5535au; ac97.pci = cs5535au->pci; + /* set any OLPC-specific scaps */ + olpc_prequirks(card, &ac97); + if ((err = snd_ac97_mixer(pbus, &ac97, &cs5535au->ac97)) < 0) { snd_printk(KERN_ERR "mixer failed\n"); return err; diff --git a/sound/pci/cs5535audio/cs5535audio.h b/sound/pci/cs5535audio/cs5535audio.h index adcb213eb276..93602cf2858a 100644 --- a/sound/pci/cs5535audio/cs5535audio.h +++ b/sound/pci/cs5535audio/cs5535audio.h @@ -103,9 +103,16 @@ int snd_cs5535audio_resume(struct pci_dev *pci); #endif #ifdef CONFIG_OLPC -int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97); +void __devinit olpc_prequirks(struct snd_card *card, + struct snd_ac97_template *ac97); +int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97); #else -#define olpc_quirks(arg, arg2) (0) +static inline void olpc_prequirks(struct snd_card *card, + struct snd_ac97_template *ac97) { } +static inline int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) +{ + return 0; +} #endif 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 9073fb353f0e..ff7b68ba6179 100644 --- a/sound/pci/cs5535audio/cs5535audio_olpc.c +++ b/sound/pci/cs5535audio/cs5535audio_olpc.c @@ -103,6 +103,17 @@ static struct snd_kcontrol_new snd_cs5535audio_controls __devinitdata = .private_value = 0 }; +void __devinit olpc_prequirks(struct snd_card *card, + struct snd_ac97_template *ac97) +{ + if (!machine_is_olpc()) + return; + + /* invert EAPD if on an OLPC B3 or higher */ + if (olpc_board_at_least(olpc_board_pre(0xb3))) + ac97->scaps |= AC97_SCAP_INV_EAPD; +} + int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) { if (!machine_is_olpc()) -- cgit v1.2.3-59-g8ed1b From b91254e75c3ec4f371ce1849672a95a929d99861 Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Thu, 6 Nov 2008 16:46:31 -0500 Subject: ALSA: cs5535audio: drop ec_analog_input flag for OLPC stuff This is no longer necessary, as we're no longer doing indexed i/o commands. Signed-off-by: Andres Salomon --- sound/pci/cs5535audio/cs5535audio.h | 3 --- sound/pci/cs5535audio/cs5535audio_olpc.c | 9 +-------- 2 files changed, 1 insertion(+), 11 deletions(-) (limited to 'sound') diff --git a/sound/pci/cs5535audio/cs5535audio.h b/sound/pci/cs5535audio/cs5535audio.h index 93602cf2858a..31ecb33ffff9 100644 --- a/sound/pci/cs5535audio/cs5535audio.h +++ b/sound/pci/cs5535audio/cs5535audio.h @@ -92,9 +92,6 @@ struct cs5535audio { struct snd_pcm_substream *playback_substream; struct snd_pcm_substream *capture_substream; struct cs5535audio_dma dmas[NUM_CS5535AUDIO_DMAS]; -#ifdef CONFIG_OLPC - int ec_analog_input_mode; -#endif }; #ifdef CONFIG_PM diff --git a/sound/pci/cs5535audio/cs5535audio_olpc.c b/sound/pci/cs5535audio/cs5535audio_olpc.c index ff7b68ba6179..2bd6588b4353 100644 --- a/sound/pci/cs5535audio/cs5535audio_olpc.c +++ b/sound/pci/cs5535audio/cs5535audio_olpc.c @@ -38,8 +38,7 @@ static int snd_cs5535audio_ctl_get(struct snd_kcontrol *kcontrol, reg1 = snd_ac97_read(cs5535au->ac97, AC97_AD_MISC); reg2 = snd_ac97_read(cs5535au->ac97, AC97_AD_TEST2); - if ((reg1 & AD1888_VREFOUT_EN_BIT) && (reg2 & AD1888_HPF_EN_BIT) && - cs5535au->ec_analog_input_mode) + if ((reg1 & AD1888_VREFOUT_EN_BIT) && (reg2 & AD1888_HPF_EN_BIT)) ucontrol->value.integer.value[0] = 1; else ucontrol->value.integer.value[0] = 0; @@ -58,10 +57,6 @@ static int snd_cs5535audio_ctl_put(struct snd_kcontrol *kcontrol, /* value is 1 if analog input is desired */ value = ucontrol->value.integer.value[0]; - /* use ec mode as flag to determine if any change needed */ - if (cs5535au->ec_analog_input_mode == value) - return 0; - /* sets High Z on VREF Bias if 1 */ if (value) err = snd_ac97_update_bits(ac97, AC97_AD_MISC, @@ -88,8 +83,6 @@ static int snd_cs5535audio_ctl_put(struct snd_kcontrol *kcontrol, else geode_gpio_clear(OLPC_GPIO_MIC_AC, GPIO_OUTPUT_VAL); - cs5535au->ec_analog_input_mode = value; - return 1; } -- cgit v1.2.3-59-g8ed1b From 1e2232bc70b32f90109d678d1faccf6f50ebba80 Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Thu, 6 Nov 2008 16:47:05 -0500 Subject: ALSA: cs5535audio: decouple HPF from V_REFOUT in OLPC code We shouldn't be touching V_REFOUT when we toggle HPF/analog input, so just drop that code. Signed-off-by: Andres Salomon Signed-off-by: Takashi Iwai --- sound/pci/cs5535audio/cs5535audio_olpc.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) (limited to 'sound') diff --git a/sound/pci/cs5535audio/cs5535audio_olpc.c b/sound/pci/cs5535audio/cs5535audio_olpc.c index 2bd6588b4353..f20e74182725 100644 --- a/sound/pci/cs5535audio/cs5535audio_olpc.c +++ b/sound/pci/cs5535audio/cs5535audio_olpc.c @@ -30,18 +30,11 @@ static int snd_cs5535audio_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct cs5535audio *cs5535au = snd_kcontrol_chip(kcontrol); - u16 reg1, reg2; + u8 val; - /* if either AD1888 VRef Bias and High Pass Filter are enabled - or the EC is not in analog mode then flag as not in analog mode. - No EC command to read current analog state so we cache that. */ - reg1 = snd_ac97_read(cs5535au->ac97, AC97_AD_MISC); - reg2 = snd_ac97_read(cs5535au->ac97, AC97_AD_TEST2); - - if ((reg1 & AD1888_VREFOUT_EN_BIT) && (reg2 & AD1888_HPF_EN_BIT)) - ucontrol->value.integer.value[0] = 1; - else - ucontrol->value.integer.value[0] = 0; + val = snd_ac97_read(cs5535au->ac97, AC97_AD_TEST2); + val >>= AC97_AD_HPFD_SHIFT; + ucontrol->value.integer.value[0] = val & 0x1; return 0; } @@ -57,16 +50,6 @@ static int snd_cs5535audio_ctl_put(struct snd_kcontrol *kcontrol, /* value is 1 if analog input is desired */ value = ucontrol->value.integer.value[0]; - /* sets High Z on VREF Bias if 1 */ - if (value) - err = snd_ac97_update_bits(ac97, AC97_AD_MISC, - AD1888_VREFOUT_EN_BIT, AD1888_VREFOUT_EN_BIT); - else - err = snd_ac97_update_bits(ac97, AC97_AD_MISC, - AD1888_VREFOUT_EN_BIT, 0); - if (err < 0) - snd_printk(KERN_ERR "Error updating AD_MISC %d\n", err); - /* turns off High Pass Filter if 1 */ if (value) err = snd_ac97_update_bits(ac97, AC97_AD_TEST2, -- cgit v1.2.3-59-g8ed1b From d6276b78028dfab944dd4a58124aefcc9aa580da Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Thu, 6 Nov 2008 16:49:38 -0500 Subject: ALSA: cs5535audio: create function for setting OLPC's Analog Input mode Clean this stuff up a bit.. Signed-off-by: Andres Salomon Signed-off-by: Takashi Iwai --- sound/pci/cs5535audio/cs5535audio.h | 2 ++ sound/pci/cs5535audio/cs5535audio_olpc.c | 54 ++++++++++++++------------------ 2 files changed, 26 insertions(+), 30 deletions(-) (limited to 'sound') diff --git a/sound/pci/cs5535audio/cs5535audio.h b/sound/pci/cs5535audio/cs5535audio.h index 31ecb33ffff9..22737fc9ed03 100644 --- a/sound/pci/cs5535audio/cs5535audio.h +++ b/sound/pci/cs5535audio/cs5535audio.h @@ -103,6 +103,7 @@ int snd_cs5535audio_resume(struct pci_dev *pci); void __devinit olpc_prequirks(struct snd_card *card, struct snd_ac97_template *ac97); int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97); +void olpc_analog_input(struct snd_ac97 *ac97, int on); #else static inline void olpc_prequirks(struct snd_card *card, struct snd_ac97_template *ac97) { } @@ -110,6 +111,7 @@ static inline int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) { return 0; } +static inline void olpc_analog_input(struct snd_ac97 *ac97, int on) { } #endif 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 f20e74182725..597395e6e358 100644 --- a/sound/pci/cs5535audio/cs5535audio_olpc.c +++ b/sound/pci/cs5535audio/cs5535audio_olpc.c @@ -7,12 +7,29 @@ #include #include "cs5535audio.h" -/* OLPC has an additional feature on top of regular AD1888 codec -features. This is support for an analog input mode. This is a -2 step process. First, to turn off the AD1888 codec bias voltage -and high pass filter. Second, to tell the embedded controller to -reroute from a capacitive trace to a direct trace using an analog -switch. The *_ec()s are what talk to that controller */ +/* + * OLPC has an additional feature on top of the regular AD1888 codec features. + * It has an Analog Input mode that is switched into (after disabling the + * High Pass Filter) via GPIO. It is supported on B2 and later models. + */ +void olpc_analog_input(struct snd_ac97 *ac97, int on) +{ + int err; + + /* update the High Pass Filter (via AC97_AD_TEST2) */ + err = snd_ac97_update_bits(ac97, AC97_AD_TEST2, + 1 << AC97_AD_HPFD_SHIFT, on << AC97_AD_HPFD_SHIFT); + if (err < 0) { + snd_printk(KERN_ERR "setting High Pass Filter - %d\n", err); + return; + } + + /* set Analog Input through GPIO */ + if (on) + geode_gpio_set(OLPC_GPIO_MIC_AC, GPIO_OUTPUT_VAL); + else + geode_gpio_clear(OLPC_GPIO_MIC_AC, GPIO_OUTPUT_VAL); +} static int snd_cs5535audio_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) @@ -24,8 +41,6 @@ static int snd_cs5535audio_ctl_info(struct snd_kcontrol *kcontrol, return 0; } -#define AD1888_VREFOUT_EN_BIT (1 << 2) -#define AD1888_HPF_EN_BIT (1 << 12) static int snd_cs5535audio_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { @@ -42,30 +57,9 @@ static int snd_cs5535audio_ctl_get(struct snd_kcontrol *kcontrol, static int snd_cs5535audio_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - int err; struct cs5535audio *cs5535au = snd_kcontrol_chip(kcontrol); - u8 value; - struct snd_ac97 *ac97 = cs5535au->ac97; - - /* value is 1 if analog input is desired */ - value = ucontrol->value.integer.value[0]; - - /* turns off High Pass Filter if 1 */ - if (value) - err = snd_ac97_update_bits(ac97, AC97_AD_TEST2, - AD1888_HPF_EN_BIT, AD1888_HPF_EN_BIT); - else - err = snd_ac97_update_bits(ac97, AC97_AD_TEST2, - AD1888_HPF_EN_BIT, 0); - if (err < 0) - snd_printk(KERN_ERR "Error updating AD_TEST2 %d\n", err); - - /* B2 and newer writes directly to a GPIO pin */ - if (value) - geode_gpio_set(OLPC_GPIO_MIC_AC, GPIO_OUTPUT_VAL); - else - geode_gpio_clear(OLPC_GPIO_MIC_AC, GPIO_OUTPUT_VAL); + olpc_analog_input(cs5535au->ac97, ucontrol->value.integer.value[0]); return 1; } -- cgit v1.2.3-59-g8ed1b From 466ae3055be8665525a5613456fcb387ffef4cb7 Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Thu, 6 Nov 2008 16:49:46 -0500 Subject: ALSA: cs5535audio: rename OLPC's analog input control && drop AD1888's HPF Previously, we had two separate controls; there's no need to have AD1888's HPF control, so drop it if we're on an OLPC machine. Also, as per Arjun's request, rename OLPC's Analog Input Switch control to "DC Mode Enable". Signed-off-by: Andres Salomon Signed-off-by: Takashi Iwai --- sound/pci/cs5535audio/cs5535audio_olpc.c | 36 +++++++++++++++++++------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'sound') diff --git a/sound/pci/cs5535audio/cs5535audio_olpc.c b/sound/pci/cs5535audio/cs5535audio_olpc.c index 597395e6e358..6c0c0dbeb218 100644 --- a/sound/pci/cs5535audio/cs5535audio_olpc.c +++ b/sound/pci/cs5535audio/cs5535audio_olpc.c @@ -31,8 +31,8 @@ void olpc_analog_input(struct snd_ac97 *ac97, int on) geode_gpio_clear(OLPC_GPIO_MIC_AC, GPIO_OUTPUT_VAL); } -static int snd_cs5535audio_ctl_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) +static int olpc_dc_info(struct snd_kcontrol *kctl, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -41,35 +41,33 @@ static int snd_cs5535audio_ctl_info(struct snd_kcontrol *kcontrol, return 0; } -static int snd_cs5535audio_ctl_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) +static int olpc_dc_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v) { - struct cs5535audio *cs5535au = snd_kcontrol_chip(kcontrol); + struct cs5535audio *cs5535au = snd_kcontrol_chip(kctl); u8 val; val = snd_ac97_read(cs5535au->ac97, AC97_AD_TEST2); val >>= AC97_AD_HPFD_SHIFT; - ucontrol->value.integer.value[0] = val & 0x1; + v->value.integer.value[0] = val & 0x1; return 0; } -static int snd_cs5535audio_ctl_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) +static int olpc_dc_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v) { - struct cs5535audio *cs5535au = snd_kcontrol_chip(kcontrol); + struct cs5535audio *cs5535au = snd_kcontrol_chip(kctl); - olpc_analog_input(cs5535au->ac97, ucontrol->value.integer.value[0]); + olpc_analog_input(cs5535au->ac97, v->value.integer.value[0]); return 1; } static struct snd_kcontrol_new snd_cs5535audio_controls __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "Analog Input Switch", - .info = snd_cs5535audio_ctl_info, - .get = snd_cs5535audio_ctl_get, - .put = snd_cs5535audio_ctl_put, + .name = "DC Mode Enable", + .info = olpc_dc_info, + .get = olpc_dc_get, + .put = olpc_dc_put, .private_value = 0 }; @@ -86,10 +84,18 @@ void __devinit olpc_prequirks(struct snd_card *card, int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) { + struct snd_ctl_elem_id elem; + if (!machine_is_olpc()) return 0; - /* setup callback for mixer control that does analog input mode */ + /* drop the original AD1888 HPF control */ + memset(&elem, 0, sizeof(elem)); + elem.iface = SNDRV_CTL_ELEM_IFACE_MIXER; + strncpy(elem.name, "High Pass Filter Enable", sizeof(elem.name)); + snd_ctl_remove_id(card, &elem); + + /* add the override for OLPC's HPF */ return snd_ctl_add(card, snd_ctl_new1(&snd_cs5535audio_controls, ac97->private_data)); } -- cgit v1.2.3-59-g8ed1b From 189d34e747e9540b70227f6682bd680868d90b10 Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Thu, 6 Nov 2008 16:49:55 -0500 Subject: ALSA: cs5535audio: check OLPC's Analog Input status vis GPIO Checking the HPF register is irrelevant; HPF is secondary to the AI mode. Instead, check for Analog Input mode via GPIO. Signed-off-by: Andres Salomon Signed-off-by: Takashi Iwai --- sound/pci/cs5535audio/cs5535audio_olpc.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/pci/cs5535audio/cs5535audio_olpc.c b/sound/pci/cs5535audio/cs5535audio_olpc.c index 6c0c0dbeb218..7f26cfbc8f52 100644 --- a/sound/pci/cs5535audio/cs5535audio_olpc.c +++ b/sound/pci/cs5535audio/cs5535audio_olpc.c @@ -43,13 +43,8 @@ static int olpc_dc_info(struct snd_kcontrol *kctl, static int olpc_dc_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v) { - struct cs5535audio *cs5535au = snd_kcontrol_chip(kctl); - u8 val; - - val = snd_ac97_read(cs5535au->ac97, AC97_AD_TEST2); - val >>= AC97_AD_HPFD_SHIFT; - v->value.integer.value[0] = val & 0x1; - + v->value.integer.value[0] = geode_gpio_isset(OLPC_GPIO_MIC_AC, + GPIO_OUTPUT_VAL); return 0; } -- cgit v1.2.3-59-g8ed1b From e463ae1d13ffe4943bb31f47cc6f24415e55a59a Mon Sep 17 00:00:00 2001 From: Chris Ball Date: Thu, 6 Nov 2008 16:50:09 -0500 Subject: ALSA: cs5535audio: enable OLPC's V_REFOUT bias when recording The OLPC has a privacy light hooked up in series with the microphone's V_Ref bias. We want to activate the bias while we are capturing audio. Signed-off-by: Chris Ball Signed-off-by: Andres Salomon Signed-off-by: Takashi Iwai --- sound/pci/cs5535audio/cs5535audio_pcm.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'sound') diff --git a/sound/pci/cs5535audio/cs5535audio_pcm.c b/sound/pci/cs5535audio/cs5535audio_pcm.c index 6aa0c19390d7..fa2a6b1b81a6 100644 --- a/sound/pci/cs5535audio/cs5535audio_pcm.c +++ b/sound/pci/cs5535audio/cs5535audio_pcm.c @@ -363,11 +363,27 @@ static int snd_cs5535audio_capture_open(struct snd_pcm_substream *substream) if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) return err; + +#ifdef CONFIG_OLPC + /* Enable the V_ref bias only while recording. */ + err = snd_ac97_update_bits(cs5535au->ac97, AC97_AD_MISC, + 1 << AC97_AD_VREFD_SHIFT, 0); + if (err < 0) + snd_printk(KERN_ERR "Error updating AD_MISC %d\n", err); +#endif return 0; } static int snd_cs5535audio_capture_close(struct snd_pcm_substream *substream) { + int err; + struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream); + +#ifdef CONFIG_OLPC + /* Disable V_ref bias. */ + err = snd_ac97_update_bits(cs5535au->ac97, AC97_AD_MISC, + 1 << AC97_AD_VREFD_SHIFT, 1 << AC97_AD_VREFD_SHIFT); +#endif return 0; } -- cgit v1.2.3-59-g8ed1b From bf1e5278354856ac0260d338961560e720147681 Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Thu, 6 Nov 2008 16:53:03 -0500 Subject: 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 --- sound/pci/cs5535audio/cs5535audio.h | 16 +++++++ sound/pci/cs5535audio/cs5535audio_olpc.c | 73 ++++++++++++++++++++++++++++++-- sound/pci/cs5535audio/cs5535audio_pcm.c | 17 +------- 3 files changed, 87 insertions(+), 19 deletions(-) (limited to 'sound') 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, struct snd_ac97_template *ac97); int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97); void olpc_analog_input(struct snd_ac97 *ac97, int on); +void olpc_mic_bias(struct snd_ac97 *ac97, int on); + +static inline void olpc_capture_open(struct snd_ac97 *ac97) +{ + /* enable MIC Bias for recording */ + olpc_mic_bias(ac97, 1); +} + +static inline void olpc_capture_close(struct snd_ac97 *ac97) +{ + /* disable the MIC Bias (so the recording LED turns off) */ + olpc_mic_bias(ac97, 0); +} #else static inline void olpc_prequirks(struct snd_card *card, struct snd_ac97_template *ac97) { } @@ -112,6 +125,9 @@ static inline int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) return 0; } static inline void olpc_analog_input(struct snd_ac97 *ac97, int on) { } +static inline void olpc_mic_bias(struct snd_ac97 *ac97, int on) { } +static inline void olpc_capture_open(struct snd_ac97 *ac97) { } +static inline void olpc_capture_close(struct snd_ac97 *ac97) { } #endif 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) geode_gpio_clear(OLPC_GPIO_MIC_AC, GPIO_OUTPUT_VAL); } +/* + * OLPC XO-1's V_REFOUT is a mic bias enable. + */ +void olpc_mic_bias(struct snd_ac97 *ac97, int on) +{ + int err; + + on = on ? 0 : 1; + err = snd_ac97_update_bits(ac97, AC97_AD_MISC, + 1 << AC97_AD_VREFD_SHIFT, on << AC97_AD_VREFD_SHIFT); + if (err < 0) + snd_printk(KERN_ERR "setting MIC Bias - %d\n", err); +} + static int olpc_dc_info(struct snd_kcontrol *kctl, struct snd_ctl_elem_info *uinfo) { @@ -56,7 +70,36 @@ static int olpc_dc_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v) return 1; } -static struct snd_kcontrol_new snd_cs5535audio_controls __devinitdata = +static int olpc_mic_info(struct snd_kcontrol *kctl, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; + uinfo->count = 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 1; + return 0; +} + +static int olpc_mic_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v) +{ + struct cs5535audio *cs5535au = snd_kcontrol_chip(kctl); + struct snd_ac97 *ac97 = cs5535au->ac97; + int i; + + i = (snd_ac97_read(ac97, AC97_AD_MISC) >> AC97_AD_VREFD_SHIFT) & 0x1; + v->value.integer.value[0] = i ? 0 : 1; + return 0; +} + +static int olpc_mic_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v) +{ + struct cs5535audio *cs5535au = snd_kcontrol_chip(kctl); + + olpc_mic_bias(cs5535au->ac97, v->value.integer.value[0]); + return 1; +} + +static struct snd_kcontrol_new olpc_cs5535audio_ctls[] __devinitdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "DC Mode Enable", @@ -64,6 +107,15 @@ static struct snd_kcontrol_new snd_cs5535audio_controls __devinitdata = .get = olpc_dc_get, .put = olpc_dc_put, .private_value = 0 +}, +{ + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "MIC Bias Enable", + .info = olpc_mic_info, + .get = olpc_mic_get, + .put = olpc_mic_put, + .private_value = 0, +}, }; void __devinit olpc_prequirks(struct snd_card *card, @@ -80,6 +132,7 @@ void __devinit olpc_prequirks(struct snd_card *card, int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) { struct snd_ctl_elem_id elem; + int i, err; if (!machine_is_olpc()) return 0; @@ -90,8 +143,20 @@ int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) strncpy(elem.name, "High Pass Filter Enable", sizeof(elem.name)); snd_ctl_remove_id(card, &elem); - /* add the override for OLPC's HPF */ - return snd_ctl_add(card, snd_ctl_new1(&snd_cs5535audio_controls, - ac97->private_data)); + /* drop the original V_REFOUT control */ + memset(&elem, 0, sizeof(elem)); + elem.iface = SNDRV_CTL_ELEM_IFACE_MIXER; + strncpy(elem.name, "V_REFOUT Enable", sizeof(elem.name)); + snd_ctl_remove_id(card, &elem); + + /* add the OLPC-specific controls */ + for (i = 0; i < ARRAY_SIZE(olpc_cs5535audio_ctls); i++) { + err = snd_ctl_add(card, snd_ctl_new1(&olpc_cs5535audio_ctls[i], + ac97->private_data)); + if (err < 0) + return err; + } + + return 0; } 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) if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) return err; - -#ifdef CONFIG_OLPC - /* Enable the V_ref bias only while recording. */ - err = snd_ac97_update_bits(cs5535au->ac97, AC97_AD_MISC, - 1 << AC97_AD_VREFD_SHIFT, 0); - if (err < 0) - snd_printk(KERN_ERR "Error updating AD_MISC %d\n", err); -#endif + olpc_capture_open(cs5535au->ac97); return 0; } static int snd_cs5535audio_capture_close(struct snd_pcm_substream *substream) { - int err; struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream); - -#ifdef CONFIG_OLPC - /* Disable V_ref bias. */ - err = snd_ac97_update_bits(cs5535au->ac97, AC97_AD_MISC, - 1 << AC97_AD_VREFD_SHIFT, 1 << AC97_AD_VREFD_SHIFT); -#endif + olpc_capture_close(cs5535au->ac97); return 0; } -- cgit v1.2.3-59-g8ed1b From 01da02419da827742acd5235467f493206e83574 Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Thu, 6 Nov 2008 16:53:11 -0500 Subject: ALSA: cs5535audio: for OLPC, default to Analog Input being off Signed-off-by: Andres Salomon Signed-off-by: Takashi Iwai --- sound/pci/cs5535audio/cs5535audio.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sound') diff --git a/sound/pci/cs5535audio/cs5535audio.h b/sound/pci/cs5535audio/cs5535audio.h index 63190cd723c6..777703717a70 100644 --- a/sound/pci/cs5535audio/cs5535audio.h +++ b/sound/pci/cs5535audio/cs5535audio.h @@ -108,12 +108,16 @@ void olpc_mic_bias(struct snd_ac97 *ac97, int on); static inline void olpc_capture_open(struct snd_ac97 *ac97) { + /* default to Analog Input off */ + olpc_analog_input(ac97, 0); /* enable MIC Bias for recording */ olpc_mic_bias(ac97, 1); } static inline void olpc_capture_close(struct snd_ac97 *ac97) { + /* disable Analog Input */ + olpc_analog_input(ac97, 0); /* disable the MIC Bias (so the recording LED turns off) */ olpc_mic_bias(ac97, 0); } -- cgit v1.2.3-59-g8ed1b From c8f0eeebc119c401202bc2794bec026d6cfd062e Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Thu, 6 Nov 2008 16:53:19 -0500 Subject: ALSA: cs5535audio: turn off mic bias on OLPCs by default Always turn off mic bias; the MIC LED should never come on when the driver is first loaded. Signed-off-by: Andres Salomon Signed-off-by: Takashi Iwai --- sound/pci/cs5535audio/cs5535audio_olpc.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sound') diff --git a/sound/pci/cs5535audio/cs5535audio_olpc.c b/sound/pci/cs5535audio/cs5535audio_olpc.c index 73811e0e8ac7..45b24f718d62 100644 --- a/sound/pci/cs5535audio/cs5535audio_olpc.c +++ b/sound/pci/cs5535audio/cs5535audio_olpc.c @@ -157,6 +157,8 @@ int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) return err; } + /* turn off the mic by default */ + olpc_mic_bias(ac97, 0); return 0; } -- cgit v1.2.3-59-g8ed1b From b5ccc57b06b54058879ab3ea548625d9bf88c7fc Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Thu, 6 Nov 2008 16:53:26 -0500 Subject: ALSA: cs5535audio: clean up OLPC code - add copyright info to _olpc.c - minor layout fixes - make Makefile more concise - silence a warning Signed-off-by: Andres Salomon Signed-off-by: Takashi Iwai --- sound/pci/cs5535audio/Makefile | 5 +---- sound/pci/cs5535audio/cs5535audio.c | 1 - sound/pci/cs5535audio/cs5535audio_olpc.c | 15 ++++++++++++--- 3 files changed, 13 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/pci/cs5535audio/Makefile b/sound/pci/cs5535audio/Makefile index 3e41fd39780d..ccc642269b9e 100644 --- a/sound/pci/cs5535audio/Makefile +++ b/sound/pci/cs5535audio/Makefile @@ -4,10 +4,7 @@ snd-cs5535audio-y := cs5535audio.o cs5535audio_pcm.o snd-cs5535audio-$(CONFIG_PM) += cs5535audio_pm.o - -ifdef CONFIG_OLPC -snd-cs5535audio-objs += cs5535audio_olpc.o -endif +snd-cs5535audio-$(CONFIG_OLPC) += cs5535audio_olpc.o # Toplevel Module Dependency obj-$(CONFIG_SND_CS5535AUDIO) += snd-cs5535audio.o diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c index 130f10a8d524..826e6dec2e97 100644 --- a/sound/pci/cs5535audio/cs5535audio.c +++ b/sound/pci/cs5535audio/cs5535audio.c @@ -174,7 +174,6 @@ static int __devinit snd_cs5535audio_mixer(struct cs5535audio *cs5535au) snd_ac97_tune_hardware(cs5535au->ac97, ac97_quirks, ac97_quirk); - /* olpc_quirks is dummied out if not olpc */ err = olpc_quirks(card, cs5535au->ac97); if (err < 0) { snd_printk(KERN_ERR "olpc quirks failed\n"); diff --git a/sound/pci/cs5535audio/cs5535audio_olpc.c b/sound/pci/cs5535audio/cs5535audio_olpc.c index 45b24f718d62..164f6bdab991 100644 --- a/sound/pci/cs5535audio/cs5535audio_olpc.c +++ b/sound/pci/cs5535audio/cs5535audio_olpc.c @@ -1,4 +1,14 @@ -#include +/* + * OLPC XO-1 additional sound features + * + * Copyright © 2006 Jaya Kumar + * Copyright © 2007-2008 Andres Salomon + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ #include #include #include @@ -106,7 +116,7 @@ static struct snd_kcontrol_new olpc_cs5535audio_ctls[] __devinitdata = { .info = olpc_dc_info, .get = olpc_dc_get, .put = olpc_dc_put, - .private_value = 0 + .private_value = 0, }, { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, @@ -161,4 +171,3 @@ int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) olpc_mic_bias(ac97, 0); return 0; } - -- cgit v1.2.3-59-g8ed1b From 0fb497f5b6ff8da1e9e60afb39835f40d7f043ec Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Thu, 6 Nov 2008 16:53:34 -0500 Subject: ALSA: cs5535audio: ensure MIC Bias/Analog Input bail if not on an OLPC machine Signed-off-by: Andres Salomon Signed-off-by: Takashi Iwai --- sound/pci/cs5535audio/cs5535audio_olpc.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sound') diff --git a/sound/pci/cs5535audio/cs5535audio_olpc.c b/sound/pci/cs5535audio/cs5535audio_olpc.c index 164f6bdab991..5c6814335cd7 100644 --- a/sound/pci/cs5535audio/cs5535audio_olpc.c +++ b/sound/pci/cs5535audio/cs5535audio_olpc.c @@ -26,6 +26,9 @@ void olpc_analog_input(struct snd_ac97 *ac97, int on) { int err; + if (!machine_is_olpc()) + return; + /* update the High Pass Filter (via AC97_AD_TEST2) */ err = snd_ac97_update_bits(ac97, AC97_AD_TEST2, 1 << AC97_AD_HPFD_SHIFT, on << AC97_AD_HPFD_SHIFT); @@ -48,6 +51,9 @@ void olpc_mic_bias(struct snd_ac97 *ac97, int on) { int err; + if (!machine_is_olpc()) + return; + on = on ? 0 : 1; err = snd_ac97_update_bits(ac97, AC97_AD_MISC, 1 << AC97_AD_VREFD_SHIFT, on << AC97_AD_VREFD_SHIFT); -- cgit v1.2.3-59-g8ed1b From f144b7f6679d9833bd3b94b91e452592b6d0e502 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 10 Dec 2008 17:23:24 +0100 Subject: ALSA: cs5535 - Make OLPC-stuff depending on MGEODE_LX The GPIO stuff for OLPC in cs5535audio_olpc.c is implemented only for Geode-LX, and enabled only when CONFIG_MGEODE_LX=y. Without this config option, the driver gets build errors. This patch adds a workaround to make it dependent on CONFIG_MGEODE_LX. Ideally, the OLPC-GPIO stuff should be implemented in a way independent from CPU type selection... Signed-off-by: Takashi Iwai --- sound/pci/cs5535audio/Makefile | 2 ++ sound/pci/cs5535audio/cs5535audio.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/cs5535audio/Makefile b/sound/pci/cs5535audio/Makefile index ccc642269b9e..fda7a94c992f 100644 --- a/sound/pci/cs5535audio/Makefile +++ b/sound/pci/cs5535audio/Makefile @@ -4,7 +4,9 @@ snd-cs5535audio-y := cs5535audio.o cs5535audio_pcm.o snd-cs5535audio-$(CONFIG_PM) += cs5535audio_pm.o +ifdef CONFIG_MGEODE_LX snd-cs5535audio-$(CONFIG_OLPC) += cs5535audio_olpc.o +endif # Toplevel Module Dependency obj-$(CONFIG_SND_CS5535AUDIO) += snd-cs5535audio.o diff --git a/sound/pci/cs5535audio/cs5535audio.h b/sound/pci/cs5535audio/cs5535audio.h index 777703717a70..7a298ac662e3 100644 --- a/sound/pci/cs5535audio/cs5535audio.h +++ b/sound/pci/cs5535audio/cs5535audio.h @@ -99,7 +99,7 @@ int snd_cs5535audio_suspend(struct pci_dev *pci, pm_message_t state); int snd_cs5535audio_resume(struct pci_dev *pci); #endif -#ifdef CONFIG_OLPC +#if defined(CONFIG_OLPC) && defined(CONFIG_MGEODE_LX) void __devinit olpc_prequirks(struct snd_card *card, struct snd_ac97_template *ac97); int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97); -- cgit v1.2.3-59-g8ed1b