Skip to contentSkip to conversation

ASoC: Blackfin updates

PATCH In review Bryan Wu 2 participants 9 messages Oct 23, 2008

Subsystems (3)
lore
Share & tools
lore

Bryan Wu

author
#0 lore raw

cover ASoC: Blackfin updates

Hi Mark and Takashi:

We updates the patchset:
- split out AD1980 change to a seperated patch
- coding style change

Thanks
-Bryan

author
#1 lore raw

PATCH 1/4 ASoC: Blackfin: updates Kconfig for SPORT

From: Mike Frysinger <[email protected]>

tweak SPORT range for non-BF54x so we get proper behavior for BF52x parts

---
 sound/soc/blackfin/Kconfig |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
sound/soc/blackfin/Kconfig +1 -1
index dc00620..3fce187 100644
@@ -80,7 +80,7 @@ config SND_BF5XX_SPORT_NUM
 	int "Set a SPORT for Sound chip"
 	depends on (SND_BF5XX_I2S || SND_BF5XX_AC97)
 	range 0 3 if BF54x
-	range 0 1 if (BF53x || BF561)
+	range 0 1 if !BF54x
 	default 0
 	help
 	  Set the correct SPORT for sound chip.
Signature · 1 line
1.5.6
author
#3 lore raw

PATCH 2/4 ASoC: AD1980 codec: add multi-channel function support

In reply to Bryan Wu

From: Cliff Cai <[email protected]>

We added multi-channel function to this codec driver and Blackfin ASoC driver as well. It was tested on Blackfin hardware.

---
 sound/soc/codecs/ad1980.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)
sound/soc/codecs/ad1980.c +15 -4
index 1397b8e..410fed9 100644
@@ -85,6 +85,9 @@ SOC_DOUBLE("Line HP Swap Switch", AC97_AD_MISC, 10, 5, 1, 0),
 SOC_DOUBLE("Surround Playback Volume", AC97_SURROUND_MASTER, 8, 0, 31, 1),
 SOC_DOUBLE("Surround Playback Switch", AC97_SURROUND_MASTER, 15, 7, 1, 1),
 
+SOC_DOUBLE("Center/LFE Playback Volume", AC97_CENTER_LFE_MASTER, 8, 0, 31, 1),
+SOC_DOUBLE("Center/LFE Playback Switch", AC97_CENTER_LFE_MASTER, 15, 7, 1, 1),
+
 SOC_ENUM("Capture Source", ad1980_cap_src),
 
 SOC_SINGLE("Mic Boost Switch", AC97_MIC, 6, 1, 0),
@@ -145,7 +148,7 @@ struct snd_soc_dai ad1980_dai = {
 	.playback = {
 		.stream_name = "Playback",
 		.channels_min = 2,
-		.channels_max = 2,
+		.channels_max = 6,
 		.rates = SNDRV_PCM_RATE_48000,
 		.formats = SNDRV_PCM_FMTBIT_S16_LE, },
 	.capture = {
@@ -192,6 +195,7 @@ static int ad1980_soc_probe(struct platform_device *pdev)
 	struct snd_soc_codec *codec;
 	int ret = 0;
 	u16 vendor_id2;
+	u16 ext_status;
 
 	printk(KERN_INFO "AD1980 SoC Audio Codec\n");
 
@@ -253,9 +257,16 @@ static int ad1980_soc_probe(struct platform_device *pdev)
 				"supported\n");
 	}
 
-	ac97_write(codec, AC97_MASTER, 0x0000); /* unmute line out volume */
-	ac97_write(codec, AC97_PCM, 0x0000);	/* unmute PCM out volume */
-	ac97_write(codec, AC97_REC_GAIN, 0x0000);/* unmute record volume */
+	/* unmute captures and playbacks volume */
+	ac97_write(codec, AC97_MASTER, 0x0000);
+	ac97_write(codec, AC97_PCM, 0x0000);
+	ac97_write(codec, AC97_REC_GAIN, 0x0000);
+	ac97_write(codec, AC97_CENTER_LFE_MASTER, 0x0000);
+	ac97_write(codec, AC97_SURROUND_MASTER, 0x0000);
+
+	/*power on LFE/CENTER/Surround DACs*/
+	ext_status = ac97_read(codec, AC97_EXTENDED_STATUS);
+	ac97_write(codec, AC97_EXTENDED_STATUS, ext_status&~0x3800);
 
 	ad1980_add_controls(codec);
 	ret = snd_soc_register_card(socdev);
Signature · 1 line
1.5.6
author
#5 lore raw

PATCH 3/4 ASoC: Blackfin: add multi-channel function support

In reply to Bryan Wu

From: Cliff Cai <[email protected]>

This patch provides a option for users to enable multi-channel function support in Blackfin ASoC driver. Because Blackfin is without MMU, it is easy for us and the user to enable this function at compiling stage not dynamically on the fly.

---
 sound/soc/blackfin/Kconfig          |   14 +++-
 sound/soc/blackfin/bf5xx-ac97-pcm.c |   80 +++++++++++-------
 sound/soc/blackfin/bf5xx-ac97.c     |  156 +++++++++++++++++++++--------------
 sound/soc/blackfin/bf5xx-ac97.h     |   35 +++++++-
 sound/soc/blackfin/bf5xx-sport.h    |    2 +-
 5 files changed, 184 insertions(+), 103 deletions(-)
sound/soc/blackfin/Kconfig +11 -3
index 3fce187..43d89fc 100644
@@ -47,7 +47,7 @@ config SND_BF5XX_AC97
 	  properly with this driver. This driver is known to work with the
 	  Analog Devices line of AC97 codecs.
 
-config SND_MMAP_SUPPORT
+config SND_BF5XX_MMAP_SUPPORT
 	bool "Enable MMAP Support"
 	depends on SND_BF5XX_AC97
 	default y
@@ -55,9 +55,17 @@ config SND_MMAP_SUPPORT
 	  Say y if you want AC97 driver to support mmap mode.
 	  We introduce an intermediate buffer to simulate mmap.
 
+config SND_BF5XX_MULTICHAN_SUPPORT
+	bool "Enable Multichannel Support"
+	depends on SND_BF5XX_AC97
+	default n
+	help
+	  Say y if you want AC97 driver to support up to 5.1 channel audio.
+	  this mode will consume much more memory for DMA.
+
 config SND_BF5XX_SOC_SPORT
 	tristate
-	
+
 config SND_BF5XX_SOC_I2S
 	tristate
 	select SND_BF5XX_SOC_SPORT
@@ -90,7 +98,7 @@ config SND_BF5XX_HAVE_COLD_RESET
 	depends on SND_BF5XX_AC97
 	default y if BFIN548_EZKIT
 	default n if !BFIN548_EZKIT
-	
+
 config SND_BF5XX_RESET_GPIO_NUM
 	int "Set a GPIO for cold reset"
 	depends on SND_BF5XX_HAVE_COLD_RESET
sound/soc/blackfin/bf5xx-ac97-pcm.c +49 -31

189 lines not on this page · raw message

sound/soc/blackfin/bf5xx-ac97.c +93 -63

258 lines not on this page · raw message

sound/soc/blackfin/bf5xx-ac97.h +30 -5
index 3f77cc5..3f2a911 100644
@@ -16,21 +16,46 @@ struct ac97_frame {
 	u16 ac97_tag;		/* slot 0 */
 	u16 ac97_addr;		/* slot 1 */
 	u16 ac97_data;		/* slot 2 */
-	u32 ac97_pcm;		/* slot 3 and 4: left and right pcm data */
+	u16 ac97_pcm_l;		/*slot 3:front left*/
+	u16 ac97_pcm_r;		/*slot 4:front left*/
+#if defined(CONFIG_SND_BF5XX_MULTICHAN_SUPPORT)
+	u16 ac97_mdm_l1;
+	u16 ac97_center;	/*slot 6:center*/
+	u16 ac97_sl;		/*slot 7:surround left*/
+	u16 ac97_sr;		/*slot 8:surround right*/
+	u16 ac97_lfe;		/*slot 9:lfe*/
+#endif
 } __attribute__ ((packed));
 
+/* Speaker location */
+#define SP_FL		0x0001
+#define SP_FR		0x0010
+#define SP_FC		0x0002
+#define SP_LFE		0x0020
+#define SP_SL		0x0004
+#define SP_SR		0x0040
+
+#define SP_STEREO	(SP_FL | SP_FR)
+#define SP_2DOT1	(SP_FL | SP_FR | SP_LFE)
+#define SP_QUAD		(SP_FL | SP_FR | SP_SL | SP_SR)
+#define SP_5DOT1	(SP_FL | SP_FR | SP_FC | SP_LFE | SP_SL | SP_SR)
+
 #define TAG_VALID		0x8000
 #define TAG_CMD			0x6000
 #define TAG_PCM_LEFT		0x1000
 #define TAG_PCM_RIGHT		0x0800
-#define TAG_PCM			(TAG_PCM_LEFT | TAG_PCM_RIGHT)
+#define TAG_PCM_MDM_L1		0x0400
+#define TAG_PCM_CENTER		0x0200
+#define TAG_PCM_SL		0x0100
+#define TAG_PCM_SR		0x0080
+#define TAG_PCM_LFE		0x0040
 
 extern struct snd_soc_dai bfin_ac97_dai;
 
-void bf5xx_pcm_to_ac97(struct ac97_frame *dst, const __u32 *src, \
-		size_t count);
+void bf5xx_pcm_to_ac97(struct ac97_frame *dst, const __u16 *src, \
+		size_t count, unsigned int chan_mask);
 
-void bf5xx_ac97_to_pcm(const struct ac97_frame *src, __u32 *dst, \
+void bf5xx_ac97_to_pcm(const struct ac97_frame *src, __u16 *dst, \
 		size_t count);
 
 #endif
sound/soc/blackfin/bf5xx-sport.h +1 -1
index fcadcc0..2e63dea 100644
@@ -116,7 +116,7 @@ struct sport_device {
 	void *err_data;
 	unsigned char *tx_dma_buf;
 	unsigned char *rx_dma_buf;
-#ifdef CONFIG_SND_MMAP_SUPPORT
+#ifdef CONFIG_SND_BF5XX_MMAP_SUPPORT
 	dma_addr_t tx_dma_phy;
 	dma_addr_t rx_dma_phy;
 	int tx_pos;/*pcm sample count*/
Signature · 1 line
1.5.6
author
#7 lore raw

PATCH 4/4 ASoC: Blackfin: update SPORT0 port selector of i2s driver

In reply to Bryan Wu

From: Cliff Cai <[email protected]>

- Setting the TFS pin selector for SPORT 0 based on whether the selected port id F or G. If the port is F then no conflict should exist for the TFS. When Port G is selected and EMAC then there is a conflict between the PHY interrupt line and TFS. Current settings prevent the conflict by ignoring the TFS pin when Port G is selected. This allows both ssm2602 using Port G and EMAC concurrently.

- some code cleanup

---
 sound/soc/blackfin/bf5xx-i2s.c |   36 ++++++++++++++++++++++++------------
 1 files changed, 24 insertions(+), 12 deletions(-)
sound/soc/blackfin/bf5xx-i2s.c +24 -12
index 827587f..390b299 100644
@@ -70,12 +70,26 @@ static struct sport_param sport_params[2] = {
 	}
 };
 
-static u16 sport_req[][7] = {
-		{ P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
-		  P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0},
-		{ P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
-		  P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0},
-};
+/*
+ * Setting the TFS pin selector for SPORT 0 based on whether the selected
+ * port id F or G. If the port is F then no conflict should exist for the
+ * TFS. When Port G is selected and EMAC then there is a conflict between
+ * the PHY interrupt line and TFS.  Current settings prevent the conflict
+ * by ignoring the TFS pin when Port G is selected. This allows both
+ * ssm2602 using Port G and EMAC concurrently.
+ */
+#ifdef CONFIG_BF527_SPORT0_PORTF
+#define LOCAL_SPORT0_TFS (P_SPORT0_TFS)
+#endif
+
+#ifndef CONFIG_BF527_SPORT0_PORTF
+#define LOCAL_SPORT0_TFS (0)
+#endif
+
+static u16 sport_req[][7] = { {P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
+		P_SPORT0_DRPRI, P_SPORT0_RSCLK, LOCAL_SPORT0_TFS, 0},
+		{P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS, P_SPORT1_DRPRI,
+		P_SPORT1_RSCLK, P_SPORT1_TFS, 0} };
 
 static int bf5xx_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai,
 		unsigned int fmt)
@@ -98,23 +112,21 @@ static int bf5xx_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai,
 		ret = -EINVAL;
 		break;
 	default:
+		printk(KERN_ERR "%s: Unknown DAI format type\n", __func__);
 		ret = -EINVAL;
 		break;
 	}
 
 	switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
-	case SND_SOC_DAIFMT_CBS_CFS:
-		ret = -EINVAL;
-		break;
-	case SND_SOC_DAIFMT_CBM_CFS:
-		ret = -EINVAL;
-		break;
 	case SND_SOC_DAIFMT_CBM_CFM:
 		break;
+	case SND_SOC_DAIFMT_CBS_CFS:
+	case SND_SOC_DAIFMT_CBM_CFS:
 	case SND_SOC_DAIFMT_CBS_CFM:
 		ret = -EINVAL;
 		break;
 	default:
+		printk(KERN_ERR "%s: Unknown DAI master type\n", __func__);
 		ret = -EINVAL;
 		break;
 	}
Signature · 1 line
1.5.6
Acked-by on v1 2/4
#4 lore raw

Re: [PATCH 2/4] ASoC: AD1980 codec: add multi-channel function support

In reply to Bryan Wu
Quoted 4 lines · Bryan Wu

From: Cliff Cai <[email protected]>

We added multi-channel function to this codec driver and Blackfin ASoC driver as well. It was tested on Blackfin hardware.

The changelog entry is now inaccurate since this was split out from the machine. This looks mostly OK but...

sound/soc/codecs/ad1980.c static int ad1980_soc_probe(struct platform_device *pdev) · line 269

Quoted 3 lines
sound/soc/codecs/ad1980.c +3 -0
+	/*power on LFE/CENTER/Surround DACs*/
+	ext_status = ac97_read(codec, AC97_EXTENDED_STATUS);
+	ac97_write(codec, AC97_EXTENDED_STATUS, ext_status&~0x3800);

...this should have spaces around the & - I'm rather surprised that checkpatch.pl doesn't pick that up (I just tested and it doesn't). Otherwise,

Acked-by on v1 3/4
#6 lore raw

Re: [PATCH 3/4] ASoC: Blackfin: add multi-channel function support

In reply to Bryan Wu
Quoted 6 lines · Bryan Wu

This patch provides a option for users to enable multi-channel function support in Blackfin ASoC driver. Because Blackfin is without MMU, it is easy for us and the user to enable this function at compiling stage not dynamically on the fly.

A few comments below, though.

As a general comment it'd be really helpful if you could split your changes into more patches than you tend to do - ideally, each patch should have a single logical change in it which is fully described by the commit message. Sometimes it's not worth splitting stuff out if the changes overlap but it does make review easier if you can.

For example, you've already split out the codec driver change but still well as the advertised change this patch also renames the mmap() support define and some coding style cleanups.

sound/soc/blackfin/Kconfig config SND_BF5XX_HAVE_COLD_RESET · line 101

Quoted 6 lines
sound/soc/blackfin/Kconfig +1 -1
@@ -90,7 +98,7 @@ config SND_BF5XX_HAVE_COLD_RESET
 	depends on SND_BF5XX_AC97
 	default y if BFIN548_EZKIT
 	default n if !BFIN548_EZKIT
-	
+

Random whitespace changes.

sound/soc/blackfin/bf5xx-ac97-pcm.c line 65

Quoted 6 lines
sound/soc/blackfin/bf5xx-ac97-pcm.c +3 -3
-		bf5xx_pcm_to_ac97(
-			(struct ac97_frame *)sport->tx_dma_buf + sport->tx_pos,
-			(__u32 *)runtime->dma_area + sport->tx_pos, count);
+		bf5xx_pcm_to_ac97((struct ac97_frame *)sport->tx_dma_buf +
+		sport->tx_pos, (__u16 *)runtime->dma_area + sport->tx_pos *
+		runtime->channels, count, chan_mask);

I'm not sure that the reindentation here is helpful but then the line is so long that it's hard to do anything. When revisiting this I'd suggest using temporary variables to calculate the pointers passed in - that should help a lot and I'd not expect worse code from the compiler since the value has to be calculated and stored for passing to the function anyway.

Quoted 1 line

+#if defined(CONFIG_SND_BF5XX_MULTICHAN_SUPPORT)

Normally just ifdef.

#8 lore raw

Re: [PATCH 4/4] ASoC: Blackfin: update SPORT0 port selector of i2s driver

In reply to Bryan Wu

sound/soc/blackfin/bf5xx-i2s.c static struct sport_param sport_params[2] = { · line 87

Quoted 7 lines · Bryan Wu
sound/soc/blackfin/bf5xx-i2s.c +7 -0
+#ifdef CONFIG_BF527_SPORT0_PORTF
+#define LOCAL_SPORT0_TFS (P_SPORT0_TFS)
+#endif
+
+#ifndef CONFIG_BF527_SPORT0_PORTF
+#define LOCAL_SPORT0_TFS (0)
+#endif

Perhaps I'm misreading this but shouldn't this just be:

#ifdef CONFIG_BF527_SPORT0_PORTF
#define LOCAL_SPORT0_TFS (P_SPORT0_TFS)
#else
#define LOCAL_SPORT0_TFS (0)
#endif