Skip to contentSkip to conversation

ALSA: cs5535audio: OLPC Analog Input and MIC Bias support

PATCH Applied Andres Salomon 2 participants 2 messages Nov 5, 2008 – Nov 6, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 4/4 ALSA: cs5535audio: OLPC Analog Input and MIC Bias support

This adds support for the special cs5535audio features that OLPC XO-1s have. They support switching between analog and DC recording, and the MIC requires toggling V_REFOUT (which this patch renames to MIC Bias) to operate. There's also an EAPD tweak which is necessary for B3 and newer machines.

All of this is enabled by CONFIG_OLPC (and CONFIG_SND_CS5535AUDIO, obviously).

---
 sound/pci/cs5535audio/Makefile           |    1 +
 sound/pci/cs5535audio/cs5535audio.c      |    9 ++
 sound/pci/cs5535audio/cs5535audio.h      |   35 ++++++
 sound/pci/cs5535audio/cs5535audio_olpc.c |  173 ++++++++++++++++++++++++++++++
 sound/pci/cs5535audio/cs5535audio_pcm.c  |    3 +
 5 files changed, 221 insertions(+), 0 deletions(-)
 create mode 100644 sound/pci/cs5535audio/cs5535audio_olpc.c
sound/pci/cs5535audio/Makefile +1 -0
index bb3d57e..ccc6422 100644
@@ -4,6 +4,7 @@
 
 snd-cs5535audio-y := cs5535audio.o cs5535audio_pcm.o
 snd-cs5535audio-$(CONFIG_PM) += cs5535audio_pm.o
+snd-cs5535audio-$(CONFIG_OLPC) += cs5535audio_olpc.o
 
 # Toplevel Module Dependency
 obj-$(CONFIG_SND_CS5535AUDIO) += snd-cs5535audio.o
sound/pci/cs5535audio/cs5535audio.c +9 -0
index 6c886ed..826e6de 100644
@@ -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;
@@ -171,6 +174,12 @@ static int __devinit snd_cs5535audio_mixer(struct cs5535audio *cs5535au)
 
 	snd_ac97_tune_hardware(cs5535au->ac97, ac97_quirks, ac97_quirk);
 
+	err = olpc_quirks(card, cs5535au->ac97);
+	if (err < 0) {
+		snd_printk(KERN_ERR "olpc quirks failed\n");
+		return err;
+	}
+
 	return 0;
 }
 
sound/pci/cs5535audio/cs5535audio.h +35 -0
index 1aa1e2b..7777037 100644
@@ -99,6 +99,41 @@ int snd_cs5535audio_suspend(struct pci_dev *pci, pm_message_t state);
 int snd_cs5535audio_resume(struct pci_dev *pci);
 #endif
 
+#ifdef CONFIG_OLPC
+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)
+{
+	/* 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);
+}
+#else
+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;
+}
+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);
 
 #endif /* __SOUND_CS5535AUDIO_H */
sound/pci/cs5535audio/cs5535audio_olpc.c new file +173 -0

173 lines not on this page · raw message

sound/pci/cs5535audio/cs5535audio_pcm.c +3 -0
index 6aa0c19..0f48a87 100644
@@ -363,11 +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;
+	olpc_capture_open(cs5535au->ac97);
 	return 0;
 }
 
 static int snd_cs5535audio_capture_close(struct snd_pcm_substream *substream)
 {
+	struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream);
+	olpc_capture_close(cs5535au->ac97);
 	return 0;
 }
 
Signature · 1 line
1.5.6.5
maintainer
#1 lore raw
Quoted 9 lines · Andres Salomon

This adds support for the special cs5535audio features that OLPC XO-1s have. They support switching between analog and DC recording, and the MIC requires toggling V_REFOUT (which this patch renames to MIC Bias) to operate. There's also an EAPD tweak which is necessary for B3 and newer machines.

All of this is enabled by CONFIG_OLPC (and CONFIG_SND_CS5535AUDIO, obviously).

Andres,

Looks okay. But can you send this patch split into 2 patches? One, the original cs5535audio_olpc.c that I posted and your changes to it since then. That'll make it easier for me to review.

Thanks,
jaya