Skip to contentSkip to conversation

Revised AT32 ASoC Patch

PATCH In review Geoffrey Wossum 3 participants 7 messages Jun 3, 2008 – Jun 4, 2008

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

PATCH 1/1 Revised AT32 ASoC Patch

Attached is a revised version of my patch to add AT32 to ASoC. This cleans up most of the style issues associated with the previous patch. Also fixes an issue with the playpaq_wm8510.c code depending on a non-released patch to the AT32 portmux support.

Patch is against 2.6.24.3.atmel.3 kernel, the latest AVR32 kernel Atmel has released, with the linux-2.6-asoc patches from when v2.6.24 was tagged also applied.

Will apply cleanly and compile to a vanilla 2.6.24, with the following exceptions:

- The sound/soc/Makefile patch is against the linux-2.6-asoc Makefile, not the vanilla Makefile
- playpaq_wm8510.c requires the WM8510 driver to compile which is only currently available in linux-2.6-asoc

---
Geoffrey

sound/soc/at32/at32-ssc.h new file +59 -0
@@ -0,0 +1,59 @@
+/* sound/soc/at32/at32-ssc.h
+ * ASoC SSC interface for Atmel AT32 SoC
+ *
+ * Copyright (C) 2008 Long Range Systems
+ *    Geoffrey Wossum <[email protected]>
+ *
+ * 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.
+ */
+
+#ifndef __SOUND_SOC_AT32_AT32_SSC_H
+#define __SOUND_SOC_AT32_AT32_SSC_H __FILE__
+
+#include <linux/types.h>
+#include <linux/atmel-ssc.h>
+
+#include "at32-pcm.h"
+
+
+
+struct at32_ssc_state {
+	u32 ssc_cmr;
+	u32 ssc_rcmr;
+	u32 ssc_rfmr;
+	u32 ssc_tcmr;
+	u32 ssc_tfmr;
+	u32 ssc_sr;
+	u32 ssc_imr;
+};
+
+
+
+struct at32_ssc_info {
+	char *name;
+	struct ssc_device *ssc;
+	spinlock_t lock;	/* lock for dir_mask */
+	unsigned short dir_mask;	/* 0=unused, 1=playback, 2=capture */
+	unsigned short initialized;	/* true if SSC has been initialized */
+	unsigned short daifmt;
+	unsigned short cmr_div;
+	unsigned short tcmr_period;
+	unsigned short rcmr_period;
+	struct at32_pcm_dma_params *dma_params[2];
+	struct at32_ssc_state ssc_state;
+};
+
+
+/* SSC divider ids */
+#define AT32_SSC_CMR_DIV        0	/* MCK divider for BCLK */
+#define AT32_SSC_TCMR_PERIOD    1	/* BCLK divider for transmit FS */
+#define AT32_SSC_RCMR_PERIOD    2	/* BCLK divider for receive FS */
+
+
+extern struct snd_soc_cpu_dai at32_ssc_dai[];
+
+
+
+#endif /* __SOUND_SOC_AT32_AT32_SSC_H */
sound/soc/at32/at32-ssc.c new file +852 -0

852 lines not on this page · raw message

sound/soc/at32/at32-pcm.h new file +79 -0

79 lines not on this page · raw message

sound/soc/at32/at32-pcm.c new file +492 -0

492 lines not on this page · raw message

sound/soc/at32/playpaq_wm8510.c new file +525 -0

525 lines not on this page · raw message

sound/soc/at32/Kconfig new file +34 -0
@@ -0,0 +1,34 @@
+config SND_AT32_SOC
+        tristate "SoC Audio for the Atmel AT32 System-on-a-Chip"
+        depends on AVR32 && SND_SOC
+        help
+          Say Y or M if you want to add support for codecs attached to 
+          the AT32 SSC interface.  You will also need to
+          to select the audio interfaces to support below.
+
+
+config SND_AT32_SOC_SSC
+        tristate
+
+
+
+config SND_AT32_SOC_PLAYPAQ
+        tristate "SoC Audio support for PlayPaq with WM8510"
+        depends on SND_AT32_SOC && BOARD_PLAYPAQ
+        select SND_AT32_SOC_SSC
+        select SND_SOC_WM8510
+        help
+          Say Y or M here if you want to add support for SoC audio
+          on the LRS PlayPaq.
+
+
+
+config SND_AT32_SOC_PLAYPAQ_SLAVE
+        bool "Run CODEC on PlayPaq in slave mode"
+        depends on SND_AT32_SOC_PLAYPAQ
+        default n
+        help
+          Say Y if you want to run with the AT32 SSC generating the BCLK
+          and FRAME signals on the PlayPaq.  Unless you want to play
+          with the AT32 as the SSC master, you probably want to say N here,
+          as this will give you better sound quality.

Patch Makefile's and Kconfig's for ASoC with AT32
Patch is against linux-2.6-asoc repository when v.2.6.24 was tagged

sound/soc/Kconfig +1 -0
Index: linux-2.6.24.3.atmel.3/sound/soc/Kconfig
===================================================================
@@ -25,6 +25,7 @@ config SND_SOC
 	  will be called snd-soc-core.
 
 # All the supported Soc's
+source "sound/soc/at32/Kconfig"
 source "sound/soc/at91/Kconfig"
 source "sound/soc/pxa/Kconfig"
 source "sound/soc/s3c24xx/Kconfig"
sound/soc/Makefile +1 -1
Index: linux-2.6.24.3.atmel.3/sound/soc/Makefile
===================================================================
@@ -1,4 +1,4 @@
 snd-soc-core-objs := soc-core.o soc-dapm.o
 
 obj-$(CONFIG_SND_SOC)	+= snd-soc-core.o
-obj-$(CONFIG_SND_SOC)	+= codecs/ at91/ pxa/ s3c24xx/ sh/ imx/ au1x/ blackfin/ fsl/
+obj-$(CONFIG_SND_SOC)	+= codecs/ at32/ at91/ pxa/ s3c24xx/ sh/ imx/ au1x/ blackfin/ fsl/
#1 lore raw
Quoted 1 line · Geoffrey Wossum

Attached is a revised version of my patch to add AT32 to ASoC. This cleans up

This looks good, thanks - I will push it out along with the WM8510 driver. There were a few checkpatch warnings remaining but I have fixed these up myself (patch below). I'll also remove the sound/driver.h includes before pushing out.

One nit with the formatting of your e-mail:

Quoted 4 lines

---
Geoffrey

You should place the Signed-off-by line in the body of the patch description rather than after the ---. Tools like git am will drop any text after there from the commit message, loosing your signoff.

sound/soc/at32/at32-pcm.c +1 -1
index a05cb8f..ad84c89 100644
@@ -108,7 +108,7 @@ static void at32_pcm_dma_irq(u32 ssc_sr, struct snd_pcm_substream *substream)
 	struct snd_pcm_runtime *rtd = substream->runtime;
 	struct at32_runtime_data *prtd = rtd->private_data;
 	struct at32_pcm_dma_params *params = prtd->params;
-	static int count = 0;
+	static int count;
 
 	count++;
 	if (ssc_sr & params->mask->ssc_endbuf) {
sound/soc/at32/at32-ssc.c +3 -5
index 61320c9..f984e76 100644
@@ -20,6 +20,7 @@
 #include <linux/device.h>
 #include <linux/delay.h>
 #include <linux/clk.h>
+#include <linux/io.h>
 #include <linux/atmel_pdc.h>
 #include <linux/atmel-ssc.h>
 
@@ -30,8 +31,6 @@
 #include <sound/initval.h>
 #include <sound/soc.h>
 
-#include <asm/io.h>
-
 #include "at32-pcm.h"
 #include "at32-ssc.h"
 
@@ -376,11 +375,10 @@ static int at32_ssc_set_dai_clkdiv(struct snd_soc_cpu_dai *cpu_dai,
 		 * transmit and receive, so if a value has already
 		 * been set, it must match this value
 		 */
-		if (ssc_p->cmr_div == 0) {
+		if (ssc_p->cmr_div == 0)
 			ssc_p->cmr_div = div;
-		} else if (div != ssc_p->cmr_div) {
+		else if (div != ssc_p->cmr_div)
 			return -EBUSY;
-		}
 		break;
 
 	case AT32_SSC_TCMR_PERIOD:
#2 lore raw
In reply to Geoffrey Wossum

At Tue, 3 Jun 2008 11:03:10 -0500,

sound/soc/at32/at32-ssc.h line 37

Quoted 5 lines · Geoffrey Wossum
sound/soc/at32/at32-ssc.h new file +4 -0
+struct at32_ssc_info {
+	char *name;
+	struct ssc_device *ssc;
+	spinlock_t lock;	/* lock for dir_mask */

Just wondering whether this lock is really needed. Is it really racy?

Takashi

#3 lore raw
Quoted 9 lines · Takashi Iwai

sound/soc/at32/at32-ssc.h line 37

Quoted 4 lines · Geoffrey Wossum
sound/soc/at32/at32-ssc.h new file +4 -0
+struct at32_ssc_info {
+	char *name;
+	struct ssc_device *ssc;
+	spinlock_t lock;	/* lock for dir_mask */

Just wondering whether this lock is really needed. Is it really racy?

Bidirectional ports could be in two PCMs and have configuration happening simultaneously.

#4 lore raw
Quoted 10 lines · Mark Brown
Quoted 8 lines · Takashi Iwai

sound/soc/at32/at32-ssc.h line 37

Quoted 4 lines · Geoffrey Wossum
sound/soc/at32/at32-ssc.h new file +4 -0
+struct at32_ssc_info {
+	char *name;
+	struct ssc_device *ssc;
+	spinlock_t lock;	/* lock for dir_mask */

Just wondering whether this lock is really needed. Is it really racy?

Quoted 2 lines

Bidirectional ports could be in two PCMs and have configuration happening simultaneously.

To be honest, the AT91 code I was porting to the AT32 had this lock. I think Mark is correct, so it's probably good I wasn't writing this code from scratch since I might have missed this detail on the first pass.

---
Geoffrey

#5 lore raw
In reply to Mark Brown

At Wed, 4 Jun 2008 14:28:07 +0100,

Quoted 12 lines · Mark Brown
Quoted 9 lines · Takashi Iwai

sound/soc/at32/at32-ssc.h line 37

Quoted 4 lines · Geoffrey Wossum
sound/soc/at32/at32-ssc.h new file +4 -0
+struct at32_ssc_info {
+	char *name;
+	struct ssc_device *ssc;
+	spinlock_t lock;	/* lock for dir_mask */

Just wondering whether this lock is really needed. Is it really racy?

Quoted 2 lines

Bidirectional ports could be in two PCMs and have configuration happening simultaneously.

Fair enough.

But, it's no fast code path, and maybe one global mutex would be enough for such a purpose, though.

Takashi

#6 lore raw
In reply to Geoffrey Wossum
Quoted 4 lines · Geoffrey Wossum

Attached is a revised version of my patch to add AT32 to ASoC. This cleans up most of the style issues associated with the previous patch. Also fixes an issue with the playpaq_wm8510.c code depending on a non-released patch to the AT32 portmux support.

Umm... On further examination, it looks like the sound/soc/at32 Makefile has been omitted - I've used the existing one.