Skip to contentSkip to conversation

ep93xx: alsa pcm and ac97 support (fwd)

RFC PATCH In review Lennert Buytenhek 2 participants 4 messages Jan 7, 2007 – Jan 8, 2007 Sound

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 ep93xx: alsa pcm and ac97 support (fwd)

(Please CC on replies, not subscribed.)

I sent this to linux-arm-kernel@ some time ago, but didn't get any complaints, so I guess it's time I send it to the alsa list. This driver depends on the cirrus m2p dma driver that I also sent to the linux-arm-kernel@ list some time ago.

sound/arm/Kconfig +13 -0
Index: linux-2.6.19/sound/arm/Kconfig
===================================================================
@@ -20,6 +20,19 @@ config SND_ARMAACI
 	select SND_PCM
 	select SND_AC97_CODEC
 
+config SND_EP93XX_PCM
+	tristate
+	select SND_PCM
+
+config SND_EP93XX_AC97
+	tristate "AC97 driver for the Cirrus EP93xx chip"
+	depends on ARCH_EP93XX && SND
+	select SND_EP93XX_PCM
+	select SND_AC97_CODEC
+	help
+	  Say Y or M if you want to support any AC97 codec attached to
+	  the EP93xx AC97 interface.
+
 config SND_PXA2XX_PCM
 	tristate
 	select SND_PCM
sound/arm/Makefile +6 -0
Index: linux-2.6.19/sound/arm/Makefile
===================================================================
@@ -8,6 +8,12 @@ snd-sa11xx-uda1341-objs		:= sa11xx-uda13
 obj-$(CONFIG_SND_ARMAACI)	+= snd-aaci.o
 snd-aaci-objs			:= aaci.o devdma.o
 
+obj-$(CONFIG_SND_EP93XX_PCM)	+= snd-ep93xx-pcm.o
+snd-ep93xx-pcm-objs		:= ep93xx-pcm.o
+
+obj-$(CONFIG_SND_EP93XX_AC97)	+= snd-ep93xx-ac97.o
+snd-ep93xx-ac97-objs		:= ep93xx-ac97.o
+
 obj-$(CONFIG_SND_PXA2XX_PCM)	+= snd-pxa2xx-pcm.o
 snd-pxa2xx-pcm-objs		:= pxa2xx-pcm.o
 
sound/arm/ep93xx-ac97.c new file +301 -0

301 lines not on this page · raw message

sound/arm/ep93xx-pcm.c new file +324 -0

324 lines not on this page · raw message

sound/arm/ep93xx-pcm.h new file +26 -0
Index: linux-2.6.19/sound/arm/ep93xx-pcm.h
===================================================================
@@ -0,0 +1,26 @@
+/*
+ * linux/sound/arm/ep93xx-pcm.h - EP93xx ALSA PCM interface
+ *
+ * Copyright (C) 2006 Lennert Buytenhek <[email protected]>
+ * Copyright (C) 2006 Applied Data Systems
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+struct ep93xx_pcm_dma_params {
+	char	*name;
+	int	dma_port;
+};
+
+struct ep93xx_pcm_client {
+	struct ep93xx_pcm_dma_params *playback_params;
+	struct ep93xx_pcm_dma_params *capture_params;
+	int (*startup)(struct snd_pcm_substream *);
+	void (*shutdown)(struct snd_pcm_substream *);
+	int (*prepare)(struct snd_pcm_substream *);
+};
+
+int ep93xx_pcm_new(struct snd_card *, struct ep93xx_pcm_client *,
+		   struct snd_pcm **);
include/asm-arm/arch-ep93xx/platform.h +6 -0
Index: linux-2.6.19/include/asm-arm/arch-ep93xx/platform.h
===================================================================
@@ -10,6 +10,12 @@ void ep93xx_init_time(unsigned long);
 void ep93xx_init_devices(void);
 extern struct sys_timer ep93xx_timer;
 
+struct ep93xx_ac97_audio_ops
+{
+	void		(*amp_power)(int on);
+	void		(*codec_power)(int on);
+};
+
 struct ep93xx_eth_data
 {
 	unsigned char	dev_addr[6];

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#1 lore raw

At Sun, 7 Jan 2007 22:16:14 +0100,

Quoted 7 lines · Lennert Buytenhek

(Please CC on replies, not subscribed.)

I sent this to linux-arm-kernel@ some time ago, but didn't get any complaints, so I guess it's time I send it to the alsa list. This driver depends on the cirrus m2p dma driver that I also sent to the linux-arm-kernel@ list some time ago.

Thanks for the patch. Some notes through a quick review are below.

Quoted 2 lines
sound/arm/ep93xx-ac97.c new file +0 -0

(snip)

sound/arm/ep93xx-ac97.c line 75

Quoted 5 lines
sound/arm/ep93xx-ac97.c new file +5 -0
+static void ep93xx_ac97_bus_reset(struct snd_ac97 *ac97)
+{
+	int i;
+
+	printk(KERN_INFO "ep93xx-ac97: resetting bus.. ");

If these are nothing but debug messages, use snd_printd(), for example.

sound/arm/ep93xx-ac97.c line 188

Quoted 10 lines
sound/arm/ep93xx-ac97.c new file +10 -0
+/* AC'97 platform driver ****************************************************/
+static int ep93xx_ac97_probe(struct platform_device *dev)
+{
+	struct ep93xx_ac97_audio_ops *ops = dev->dev.platform_data;
+	struct snd_card *card;
+	struct snd_ac97_bus *ac97_bus;
+	struct snd_ac97_template ac97_template;
+	int ret;
+
+	// @@@ register resources

Avoid C++ style comments (ditto for some other places).

sound/arm/ep93xx-ac97.c line 243

Quoted 6 lines
sound/arm/ep93xx-ac97.c new file +6 -0
+
+err:
+	/* @@@ This causes hangs..
+	 * if (card != NULL)
+	 *	snd_card_free(card);
+	 */

Any clue how does it hang?

sound/arm/ep93xx-ac97.c line 264

Quoted 4 lines
sound/arm/ep93xx-ac97.c new file +4 -0
+#ifdef CONFIG_PM
+static int ep93xx_ac97_suspend(struct platform_device *dev, pm_message_t state)
+{
+	return 0;

Hm, don't you need any suspend action for PCM and AC97 registers?

Quoted 13 lines
sound/arm/ep93xx-pcm.c new file +11 -0
+static int ep93xx_pcm_open(struct snd_pcm_substream *substream)
+{
+	struct ep93xx_pcm_client *client = substream->private_data;
+	struct snd_pcm_runtime *runtime = substream->runtime;
+	struct ep93xx_runtime_data *rtd;
+	int ret;
+
+	runtime->hw = ep93xx_pcm_hardware;
+
+	rtd = kmalloc(sizeof(*rtd), GFP_KERNEL);
+	if (rtd == NULL) {

sound/arm/ep93xx-pcm.c line 103

Quoted 10 lines
sound/arm/ep93xx-pcm.c new file +10 -0
+		ret = -ENOMEM;
+		goto err;
+	}
+
+	rtd->params = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
+			client->playback_params : client->capture_params;
+
+	memset(&rtd->period_tasklet, 0, sizeof(rtd->period_tasklet));
+	rtd->period_tasklet.func = do_period_elapsed;
+	rtd->period_tasklet.data = (unsigned long)substream;

Use tasklet_init().

Quoted 1 line

+static u64 ep93xx_pcm_dmamask = 0xffffffff;

Use DMA_32BIT_MASK.

Quoted 10 lines
sound/arm/ep93xx-pcm.c new file +10 -0
+
+int ep93xx_pcm_new(struct snd_card *card, struct ep93xx_pcm_client *client,
+		   struct snd_pcm **rpcm)
+{
+	struct snd_pcm *pcm;
+	int play = client->playback_params ? 1 : 0;
+	int capt = client->capture_params ? 1 : 0;
+	int ret;
+
+	ret = snd_pcm_new(card, "EP93xx-PCM", 0, play, capt, &pcm);

sound/arm/ep93xx-pcm.c line 295

Quoted 10 lines
sound/arm/ep93xx-pcm.c new file +10 -0
+	if (ret)
+		goto out;
+
+	pcm->private_data = client;
+	pcm->private_free = ep93xx_pcm_free_dma_buffers;
+
+	if (!card->dev->dma_mask)
+		card->dev->dma_mask = &ep93xx_pcm_dmamask;
+	if (!card->dev->coherent_dma_mask)
+		card->dev->coherent_dma_mask = 0xffffffff;

Doesn't dma_set_mask() work?

sound/arm/ep93xx-pcm.c line 324

Quoted 5 lines
sound/arm/ep93xx-pcm.c new file +5 -0
+EXPORT_SYMBOL(ep93xx_pcm_new);
+
+MODULE_AUTHOR("Lennert Buytenhek <[email protected]>");
+MODULE_DESCRIPTION("EP93xx ALSA PCM interface");
+MODULE_LICENSE("GPL");

Could ep93xx-pcm be merged to ep93xx-ac97 as a single module? Since you have only one interface, it doesn't make much sense to split to two modules. With a single module, you can avoid unnecessary exported symbols.

Takashi

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#2 lore raw
Quoted 8 lines · Takashi Iwai
Quoted 6 lines

(Please CC on replies, not subscribed.)

I sent this to linux-arm-kernel@ some time ago, but didn't get any complaints, so I guess it's time I send it to the alsa list. This driver depends on the cirrus m2p dma driver that I also sent to the linux-arm-kernel@ list some time ago.

Thanks for the patch.

Thanks for the review!

Quoted 11 lines
Quoted 2 lines
sound/arm/ep93xx-ac97.c new file +0 -0

(snip)

sound/arm/ep93xx-ac97.c line 75

Quoted 5 lines
sound/arm/ep93xx-ac97.c new file +5 -0
+static void ep93xx_ac97_bus_reset(struct snd_ac97 *ac97)
+{
+	int i;
+
+	printk(KERN_INFO "ep93xx-ac97: resetting bus.. ");

If these are nothing but debug messages, use snd_printd(), for example.

OK.

Quoted 4 lines
Quoted 4 lines
sound/arm/ep93xx-ac97.c new file +4 -0
+/* AC'97 platform driver ****************************************************/
+static int ep93xx_ac97_probe(struct platform_device *dev)
+{
+	struct ep93xx_ac97_audio_ops *ops = dev->dev.platform_data;
Quoted 8 lines

sound/arm/ep93xx-ac97.c line 188

Quoted 6 lines
sound/arm/ep93xx-ac97.c new file +6 -0
+	struct snd_card *card;
+	struct snd_ac97_bus *ac97_bus;
+	struct snd_ac97_template ac97_template;
+	int ret;
+
+	// @@@ register resources

Avoid C++ style comments (ditto for some other places).

(I was going to nuke the // and @@@ comments before submitting a final version anyway.)

Quoted 7 lines

sound/arm/ep93xx-ac97.c line 243

Quoted 5 lines
sound/arm/ep93xx-ac97.c new file +5 -0
+err:
+	/* @@@ This causes hangs..
+	 * if (card != NULL)
+	 *	snd_card_free(card);
+	 */

Any clue how does it hang?

I remember making a backtrace, but I don't seem to have it anymore. I'll give it another try when I have a moment.

Quoted 6 lines

sound/arm/ep93xx-ac97.c line 264

Quoted 4 lines
sound/arm/ep93xx-ac97.c new file +4 -0
+#ifdef CONFIG_PM
+static int ep93xx_ac97_suspend(struct platform_device *dev, pm_message_t state)
+{
+	return 0;

Hm, don't you need any suspend action for PCM and AC97 registers?

At the least, I suppose we should deactivate the AC link, and perhaps we can also gate the DMA channel clock. I'll implement this.

Quoted 17 lines
Quoted 17 lines
sound/arm/ep93xx-pcm.c new file +15 -0
+static int ep93xx_pcm_open(struct snd_pcm_substream *substream)
+{
+	struct ep93xx_pcm_client *client = substream->private_data;
+	struct snd_pcm_runtime *runtime = substream->runtime;
+	struct ep93xx_runtime_data *rtd;
+	int ret;
+
+	runtime->hw = ep93xx_pcm_hardware;
+
+	rtd = kmalloc(sizeof(*rtd), GFP_KERNEL);
+	if (rtd == NULL) {
+		ret = -ENOMEM;
+		goto err;
+	}
+
Quoted 8 lines

sound/arm/ep93xx-pcm.c line 103

Quoted 6 lines
sound/arm/ep93xx-pcm.c new file +6 -0
+	rtd->params = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
+			client->playback_params : client->capture_params;
+
+	memset(&rtd->period_tasklet, 0, sizeof(rtd->period_tasklet));
+	rtd->period_tasklet.func = do_period_elapsed;
+	rtd->period_tasklet.data = (unsigned long)substream;

Use tasklet_init().

ACK.

Quoted 3 lines
Quoted 1 line

+static u64 ep93xx_pcm_dmamask = 0xffffffff;

Use DMA_32BIT_MASK.

OK. Note that pxa2xx-pcm has the same construct.

Quoted 9 lines

sound/arm/ep93xx-pcm.c line 295

Quoted 7 lines
sound/arm/ep93xx-pcm.c new file +7 -0
+	pcm->private_data = client;
+	pcm->private_free = ep93xx_pcm_free_dma_buffers;
+
+	if (!card->dev->dma_mask)
+		card->dev->dma_mask = &ep93xx_pcm_dmamask;
+	if (!card->dev->coherent_dma_mask)
+		card->dev->coherent_dma_mask = 0xffffffff;

Doesn't dma_set_mask() work?

Again, this was just copied from pxa2xx-pcm. I'll have a look.

Quoted 10 lines

sound/arm/ep93xx-pcm.c line 324

Quoted 5 lines
sound/arm/ep93xx-pcm.c new file +5 -0
+EXPORT_SYMBOL(ep93xx_pcm_new);
+
+MODULE_AUTHOR("Lennert Buytenhek <[email protected]>");
+MODULE_DESCRIPTION("EP93xx ALSA PCM interface");
+MODULE_LICENSE("GPL");

Could ep93xx-pcm be merged to ep93xx-ac97 as a single module? Since you have only one interface, it doesn't make much sense to split to two modules. With a single module, you can avoid unnecessary exported symbols.

The ep93xx CPU also has I2S/SSP, which I haven't yet written a driver for -- but someone else started work on an I2S driver:

	http://www.freelists.org/archives/linux-cirrus/01-2007/msg00018.html

Thanks again for the review.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#3 lore raw

At Mon, 8 Jan 2007 15:13:00 +0100,

Quoted 10 lines · Lennert Buytenhek
Quoted 7 lines

sound/arm/ep93xx-ac97.c line 264

Quoted 5 lines
sound/arm/ep93xx-ac97.c new file +4 -0
+#ifdef CONFIG_PM
+static int ep93xx_ac97_suspend(struct platform_device *dev, pm_message_t state)
+{
+	return 0;

Hm, don't you need any suspend action for PCM and AC97 registers?

At the least, I suppose we should deactivate the AC link, and perhaps we can also gate the DMA channel clock. I'll implement this.

OK, then I suppose that the PM isn't really tested with your driver?

Quoted 17 lines
Quoted 3 lines
Quoted 1 line

+static u64 ep93xx_pcm_dmamask = 0xffffffff;

Use DMA_32BIT_MASK.

OK. Note that pxa2xx-pcm has the same construct.

Quoted 9 lines

sound/arm/ep93xx-pcm.c line 295

Quoted 7 lines
sound/arm/ep93xx-pcm.c new file +7 -0
+	pcm->private_data = client;
+	pcm->private_free = ep93xx_pcm_free_dma_buffers;
+
+	if (!card->dev->dma_mask)
+		card->dev->dma_mask = &ep93xx_pcm_dmamask;
+	if (!card->dev->coherent_dma_mask)
+		card->dev->coherent_dma_mask = 0xffffffff;

Doesn't dma_set_mask() work?

Quoted 1 line

Again, this was just copied from pxa2xx-pcm. I'll have a look.

Care to create a fix patch for pxa2xx-pcm, too?

Quoted 11 lines
Quoted 10 lines

sound/arm/ep93xx-pcm.c line 324

Quoted 5 lines
sound/arm/ep93xx-pcm.c new file +5 -0
+EXPORT_SYMBOL(ep93xx_pcm_new);
+
+MODULE_AUTHOR("Lennert Buytenhek <[email protected]>");
+MODULE_DESCRIPTION("EP93xx ALSA PCM interface");
+MODULE_LICENSE("GPL");

Could ep93xx-pcm be merged to ep93xx-ac97 as a single module? Since you have only one interface, it doesn't make much sense to split to two modules. With a single module, you can avoid unnecessary exported symbols.

Quoted 4 lines

The ep93xx CPU also has I2S/SSP, which I haven't yet written a driver for -- but someone else started work on an I2S driver:

	http://www.freelists.org/archives/linux-cirrus/01-2007/msg00018.html

Fine, then let's keep them as individual modules.

thanks,

Takashi

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV