Skip to contentSkip to conversation

ASoC: pxa-ssp: Use 16-bit DMA for magician stereo

RFC PATCH Applied Philipp Zabel 6 participants 25 messages Mar 11, 2009 – Mar 12, 2009

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

RFC PATCH 1/3 ASoC: pxa-ssp: Use 16-bit DMA for magician stereo

Please advise how this behaviour could be made configurable. I guess the only machines that will ever need this are HTC Magician, Blueangel and Himalaya.

---
 sound/soc/pxa/pxa-ssp.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
sound/soc/pxa/pxa-ssp.c +9 -2
index 569c0a6..bc9d306 100644
@@ -22,6 +22,7 @@
 #include <linux/io.h>
 
 #include <asm/irq.h>
+#include <asm/mach-types.h>
 
 #include <sound/core.h>
 #include <sound/pcm.h>
@@ -634,8 +635,14 @@ static int pxa_ssp_hw_params(struct snd_pcm_substream *substream,
 	/* select correct DMA params */
 	if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
 		dma = 1; /* capture DMA offset is 1,3 */
-	if (chn == 2)
-		dma += 2; /* stereo DMA offset is 2, mono is 0 */
+	/* FIXME: Magician needs a way to configure 16-bit DMA for stereo */
+	if (machine_is_magician()) {
+		if (width == 32)
+			dma += 2; /* 32-bit DMA offset is 2, 16-bit is 0 */
+	} else {
+		if (chn == 2)
+			dma += 2; /* stereo DMA offset is 2, mono is 0 */
+	}
 	cpu_dai->dma_data = ssp_dma_params[cpu_dai->id][dma];
 
 	dev_dbg(&ssp->pdev->dev, "pxa_ssp_hw_params: dma %d\n", dma);
Signature · 1 line
1.6.2
#1 lore raw

RFC PATCH 2/3 ASoC: Add Magician machine support.

HTC Magician has a Philips UDA1380 codec connected via SSP1 (playback) and I2S (capture).
There is a flip-flop between the SSP frame clock output and the codec's word select input pin. To make the codec see proper I2S input, the SSP has to send two frames per sample.

---
 sound/soc/pxa/Kconfig    |   10 +
 sound/soc/pxa/Makefile   |    2 +
 sound/soc/pxa/magician.c |  563 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 575 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/pxa/magician.c
sound/soc/pxa/Kconfig +10 -0
index 5998ab3..ad8a10f 100644
@@ -116,6 +116,16 @@ config SND_SOC_ZYLONITE
 	  Say Y if you want to add support for SoC audio on the
 	  Marvell Zylonite reference platform.
 
+config SND_PXA2XX_SOC_MAGICIAN
+	tristate "SoC Audio support for HTC Magician"
+	depends on SND_PXA2XX_SOC && MACH_MAGICIAN
+	select SND_PXA2XX_SOC_I2S
+	select SND_PXA_SOC_SSP
+	select SND_SOC_UDA1380
+	help
+	  Say Y if you want to add support for SoC audio on the
+	  HTC Magician.
+
 config SND_PXA2XX_SOC_MIOA701
         tristate "SoC Audio support for MIO A701"
         depends on SND_PXA2XX_SOC && MACH_MIOA701
sound/soc/pxa/Makefile +2 -0
index 8ed881c..4b90c3c 100644
@@ -20,6 +20,7 @@ snd-soc-spitz-objs := spitz.o
 snd-soc-em-x270-objs := em-x270.o
 snd-soc-palm27x-objs := palm27x.o
 snd-soc-zylonite-objs := zylonite.o
+snd-soc-magician-objs := magician.o
 snd-soc-mioa701-objs := mioa701_wm9713.o
 
 obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o
@@ -31,5 +32,6 @@ obj-$(CONFIG_SND_PXA2XX_SOC_E800) += snd-soc-e800.o
 obj-$(CONFIG_SND_PXA2XX_SOC_SPITZ) += snd-soc-spitz.o
 obj-$(CONFIG_SND_PXA2XX_SOC_EM_X270) += snd-soc-em-x270.o
 obj-$(CONFIG_SND_PXA2XX_SOC_PALM27X) += snd-soc-palm27x.o
+obj-$(CONFIG_SND_PXA2XX_SOC_MAGICIAN) += snd-soc-magician.o
 obj-$(CONFIG_SND_PXA2XX_SOC_MIOA701) += snd-soc-mioa701.o
 obj-$(CONFIG_SND_SOC_ZYLONITE) += snd-soc-zylonite.o
sound/soc/pxa/magician.c new file +563 -0

563 lines not on this page · raw message

Signature · 1 line
1.6.2
#2 lore raw

Re: [PATCH 2/3][RFC] ASoC: Add Magician machine support.

Overall looks good. One very minor issue :-

Quoted 15 lines · Philipp Zabel

HTC Magician has a Philips UDA1380 codec connected via SSP1 (playback) and I2S (capture).
There is a flip-flop between the SSP frame clock output and the codec's word select input pin. To make the codec see proper I2S input, the SSP has to send two frames per sample.

---
 sound/soc/pxa/Kconfig    |   10 +
 sound/soc/pxa/Makefile   |    2 +
 sound/soc/pxa/magician.c |  563 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 575 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/pxa/magician.c

snip

sound/soc/pxa/magician.c line 7

Quoted 10 lines
sound/soc/pxa/magician.c new file +7 -0
@@ -0,0 +1,563 @@
+/*
+ * SoC audio for HTC Magician
+ *
+ * Copyright (c) 2006-2009 Philipp Zabel <[email protected]>
+ *
+ * based on spitz.c,
+ * Authors: Liam Girdwood <[email protected]>

This address is no longer valid. Could you change to the address I'm sending with.

Thanks

Liam

#3 lore raw

Re: [PATCH 2/3][RFC] ASoC: Add Magician machine support.

Quoted 21 lines · Liam Girdwood

Overall looks good. One very minor issue :-

Quoted 15 lines · Philipp Zabel

HTC Magician has a Philips UDA1380 codec connected via SSP1 (playback) and I2S (capture).
There is a flip-flop between the SSP frame clock output and the codec's word select input pin. To make the codec see proper I2S input, the SSP has to send two frames per sample.

---
 sound/soc/pxa/Kconfig    |   10 +
 sound/soc/pxa/Makefile   |    2 +
 sound/soc/pxa/magician.c |  563 ++++++++++++++++++++++++++++++++++++++++++++++

 3 files changed, 575 insertions(+), 0 deletions(-)

 create mode 100644 sound/soc/pxa/magician.c

snip

Quoted 13 lines

sound/soc/pxa/magician.c line 7

Quoted 10 lines
sound/soc/pxa/magician.c new file +7 -0
@@ -0,0 +1,563 @@
+/*
+ * SoC audio for HTC Magician
+ *
+ * Copyright (c) 2006-2009 Philipp Zabel <[email protected]>
+ *
+ * based on spitz.c,
+ * Authors: Liam Girdwood <[email protected]>

This address is no longer valid. Could you change to the address I'm sending with.

Of course, thanks. Will resend tomorrow with the address corrected.

regards
Philipp

#4 lore raw

Re: [PATCH 2/3][RFC] ASoC: Add Magician machine support.

In reply to Philipp Zabel

On Wed, Mar 11, 2009 at 07:16:59PM +0100, Philipp Zabel wrote:

This is all good except you're missing updates for a few new APIs:

sound/soc/pxa/magician.c line 401

Quoted 3 lines
sound/soc/pxa/magician.c new file +3 -0
+	/* NC codec pins */
+	snd_soc_dapm_disable_pin(codec, "VOUTLHP");
+	snd_soc_dapm_disable_pin(codec, "VOUTRHP");

snd_soc_dapm_nc_pin() (currently a synonym but hopefully in the future it will gain support for things like masking out controls for that path from the UI.

sound/soc/pxa/magician.c line 414

Quoted 8 lines
sound/soc/pxa/magician.c new file +8 -0
+	/* Add magician specific controls */
+	for (i = 0; i < ARRAY_SIZE(uda1380_magician_controls); i++) {
+		err = snd_ctl_add(codec->card,
+				  snd_soc_cnew(&uda1380_magician_controls[i],
+						codec, NULL));
+		if (err < 0)
+			return err;
+	}

snd_soc_add_controls()

sound/soc/pxa/magician.c line 481

Quoted 3 lines
sound/soc/pxa/magician.c new file +3 -0
+	ret = gpio_request(EGPIO_MAGICIAN_CODEC_RESET, "CODEC_RESET");
+	if (ret)
+		goto err_request_reset;

Someone needs to write a bulk GPIO request API... not an issue for merging this patch, though.

#5 lore raw

Re: [PATCH 2/3][RFC] ASoC: Add Magician machine support.

Quoted 12 lines · Mark Brown

On Wed, Mar 11, 2009 at 07:16:59PM +0100, Philipp Zabel wrote:

This is all good except you're missing updates for a few new APIs:

sound/soc/pxa/magician.c line 401

Quoted 3 lines
sound/soc/pxa/magician.c new file +3 -0
+	/* NC codec pins */
+	snd_soc_dapm_disable_pin(codec, "VOUTLHP");
+	snd_soc_dapm_disable_pin(codec, "VOUTRHP");

snd_soc_dapm_nc_pin() (currently a synonym but hopefully in the future it will gain support for things like masking out controls for that path from the UI.

Quoted 10 lines

sound/soc/pxa/magician.c line 414

Quoted 8 lines
sound/soc/pxa/magician.c new file +8 -0
+	/* Add magician specific controls */
+	for (i = 0; i < ARRAY_SIZE(uda1380_magician_controls); i++) {
+		err = snd_ctl_add(codec->card,
+				  snd_soc_cnew(&uda1380_magician_controls[i],
+						codec, NULL));
+		if (err < 0)
+			return err;
+	}

snd_soc_add_controls()

I'm thinking we should probably make snd_soc_cnew() static now. It's far more convenient to use snd_soc_add_controls().

Quoted 7 lines

sound/soc/pxa/magician.c line 481

Quoted 4 lines
sound/soc/pxa/magician.c new file +3 -0
+	ret = gpio_request(EGPIO_MAGICIAN_CODEC_RESET, "CODEC_RESET");
+	if (ret)
+		goto err_request_reset;

Someone needs to write a bulk GPIO request API... not an issue for merging this patch, though.

My thoughts exactly :)

Liam

#6 lore raw

Re: [PATCH 2/3][RFC] ASoC: Add Magician machine support.

Quoted 6 lines · Liam Girdwood
Quoted 1 line · Mark Brown

snd_soc_add_controls()

I'm thinking we should probably make snd_soc_cnew() static now. It's far more convenient to use snd_soc_add_controls().

Yup, I was intending to do that after the merge window - add_controls is new for .30 and there hasn't been too much API change this merge window so it seemed helpful to keep it around for the time being.

#7 lore raw

PATCH 3/5 ASoC: Replace remaining uses of snd_soc_cnew with snd_soc_add_controls.

The drivers are basically duplicating the same code over and over. As snd_soc_cnew is going to be made static some time after the next merge window, we might as well convert them now.

---
 sound/soc/codecs/cs4270.c          |   23 +++++------------------
 sound/soc/codecs/tlv320aic26.c     |   11 ++++-------
 sound/soc/codecs/wm8400.c          |   12 ++----------
 sound/soc/omap/n810.c              |   12 +++++-------
 sound/soc/pxa/corgi.c              |   12 +++++-------
 sound/soc/pxa/palm27x.c            |   13 +++++--------
 sound/soc/pxa/poodle.c             |   12 +++++-------
 sound/soc/pxa/spitz.c              |   12 +++++-------
 sound/soc/pxa/tosa.c               |   12 +++++-------
 sound/soc/s3c24xx/neo1973_wm8753.c |   13 +++++--------
 10 files changed, 46 insertions(+), 86 deletions(-)
sound/soc/codecs/cs4270.c +5 -18
index 0e0c23e..8e58c81 100644
@@ -538,7 +538,6 @@ static int cs4270_probe(struct platform_device *pdev)
 {
 	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
 	struct snd_soc_codec *codec = cs4270_codec;
-	unsigned int i;
 	int ret;
 
 	/* Connect the codec to the socdev.  snd_soc_new_pcms() needs this. */
@@ -552,23 +551,11 @@ static int cs4270_probe(struct platform_device *pdev)
 	}
 
 	/* Add the non-DAPM controls */
-	for (i = 0; i < ARRAY_SIZE(cs4270_snd_controls); i++) {
-		struct snd_kcontrol *kctrl;
-
-		kctrl = snd_soc_cnew(&cs4270_snd_controls[i], codec, NULL);
-		if (!kctrl) {
-			dev_err(codec->dev, "error creating control '%s'\n",
-			       cs4270_snd_controls[i].name);
-			ret = -ENOMEM;
-			goto error_free_pcms;
-		}
-
-		ret = snd_ctl_add(codec->card, kctrl);
-		if (ret < 0) {
-			dev_err(codec->dev, "error adding control '%s'\n",
-			       cs4270_snd_controls[i].name);
-			goto error_free_pcms;
-		}
+	ret = snd_soc_add_controls(codec, cs4270_snd_controls,
+				ARRAY_SIZE(cs4270_snd_controls));
+	if (ret < 0) {
+		dev_err(codec->dev, "failed to add controls\n");
+		goto error_free_pcms;
 	}
 
 	/* And finally, register the socdev */
sound/soc/codecs/tlv320aic26.c +4 -7
index 229e464..633bc4b 100644
@@ -322,9 +322,8 @@ static int aic26_probe(struct platform_device *pdev)
 {
 	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
 	struct snd_soc_codec *codec;
-	struct snd_kcontrol *kcontrol;
 	struct aic26 *aic26;
-	int i, ret, err;
+	int ret, err;
 
 	dev_info(&pdev->dev, "Probing AIC26 SoC CODEC driver\n");
 	dev_dbg(&pdev->dev, "socdev=%p\n", socdev);
@@ -351,11 +350,9 @@ static int aic26_probe(struct platform_device *pdev)
 
 	/* register controls */
 	dev_dbg(&pdev->dev, "Registering controls\n");
-	for (i = 0; i < ARRAY_SIZE(aic26_snd_controls); i++) {
-		kcontrol = snd_soc_cnew(&aic26_snd_controls[i], codec, NULL);
-		err = snd_ctl_add(codec->card, kcontrol);
-		WARN_ON(err < 0);
-	}
+	err = snd_soc_add_controls(codec, aic26_snd_controls,
+			ARRAY_SIZE(aic26_snd_controls));
+	WARN_ON(err < 0);
 
 	/* CODEC is setup, we can register the card now */
 	dev_dbg(&pdev->dev, "Registering card\n");
sound/soc/codecs/wm8400.c +2 -10
index 9cb73d9..3269121 100644
@@ -351,16 +351,8 @@ SOC_SINGLE("RIN34 Mute Switch", WM8400_RIGHT_LINE_INPUT_3_4_VOLUME,
 /* add non dapm controls */
 static int wm8400_add_controls(struct snd_soc_codec *codec)
 {
-	int err, i;
-
-	for (i = 0; i < ARRAY_SIZE(wm8400_snd_controls); i++) {
-		err = snd_ctl_add(codec->card,
-				snd_soc_cnew(&wm8400_snd_controls[i],codec,
-					NULL));
-		if (err < 0)
-			return err;
-	}
-	return 0;
+	return snd_soc_add_controls(codec, wm8400_snd_controls,
+				ARRAY_SIZE(wm8400_snd_controls));
 }
 
 /*
sound/soc/omap/n810.c +5 -7
index 9f037cd..86471fd 100644
@@ -248,7 +248,7 @@ static const struct snd_kcontrol_new aic33_n810_controls[] = {
 
 static int n810_aic33_init(struct snd_soc_codec *codec)
 {
-	int i, err;
+	int err;
 
 	/* Not connected */
 	snd_soc_dapm_nc_pin(codec, "MONO_LOUT");
@@ -256,12 +256,10 @@ static int n810_aic33_init(struct snd_soc_codec *codec)
 	snd_soc_dapm_nc_pin(codec, "HPRCOM");
 
 	/* Add N810 specific controls */
-	for (i = 0; i < ARRAY_SIZE(aic33_n810_controls); i++) {
-		err = snd_ctl_add(codec->card,
-			snd_soc_cnew(&aic33_n810_controls[i], codec, NULL));
-		if (err < 0)
-			return err;
-	}
+	err = snd_soc_add_controls(codec, aic33_n810_controls,
+				ARRAY_SIZE(aic33_n810_controls));
+	if (err < 0)
+		return err;
 
 	/* Add N810 specific widgets */
 	snd_soc_dapm_new_controls(codec, aic33_dapm_widgets,
sound/soc/pxa/corgi.c +5 -7
index 146973a..02263e5 100644
@@ -276,18 +276,16 @@ static const struct snd_kcontrol_new wm8731_corgi_controls[] = {
  */
 static int corgi_wm8731_init(struct snd_soc_codec *codec)
 {
-	int i, err;
+	int err;
 
 	snd_soc_dapm_nc_pin(codec, "LLINEIN");
 	snd_soc_dapm_nc_pin(codec, "RLINEIN");
 
 	/* Add corgi specific controls */
-	for (i = 0; i < ARRAY_SIZE(wm8731_corgi_controls); i++) {
-		err = snd_ctl_add(codec->card,
-			snd_soc_cnew(&wm8731_corgi_controls[i], codec, NULL));
-		if (err < 0)
-			return err;
-	}
+	err = snd_soc_add_controls(codec, wm8731_corgi_controls,
+				ARRAY_SIZE(wm8731_corgi_controls));
+	if (err < 0)
+		return err;
 
 	/* Add corgi specific widgets */
 	snd_soc_dapm_new_controls(codec, wm8731_dapm_widgets,
sound/soc/pxa/palm27x.c +5 -8
index 29958cd..48a73f6 100644
@@ -146,19 +146,16 @@ static const struct snd_kcontrol_new palm27x_controls[] = {
 
 static int palm27x_ac97_init(struct snd_soc_codec *codec)
 {
-	int i, err;
+	int err;
 
 	snd_soc_dapm_nc_pin(codec, "OUT3");
 	snd_soc_dapm_nc_pin(codec, "MONOOUT");
 
 	/* add palm27x specific controls */
-	for (i = 0; i < ARRAY_SIZE(palm27x_controls); i++) {
-		err = snd_ctl_add(codec->card,
-				snd_soc_cnew(&palm27x_controls[i],
-						codec, NULL));
-		if (err < 0)
-			return err;
-	}
+	err = snd_soc_add_controls(codec, palm27x_controls,
+				ARRAY_SIZE(palm27x_controls));
+	if (err < 0)
+		return err;
 
 	/* add palm27x specific widgets */
 	snd_soc_dapm_new_controls(codec, palm27x_dapm_widgets,
sound/soc/pxa/poodle.c +5 -7
index fb17a0a..ef7c6c8 100644
@@ -241,19 +241,17 @@ static const struct snd_kcontrol_new wm8731_poodle_controls[] = {
  */
 static int poodle_wm8731_init(struct snd_soc_codec *codec)
 {
-	int i, err;
+	int err;
 
 	snd_soc_dapm_nc_pin(codec, "LLINEIN");
 	snd_soc_dapm_nc_pin(codec, "RLINEIN");
 	snd_soc_dapm_enable_pin(codec, "MICIN");
 
 	/* Add poodle specific controls */
-	for (i = 0; i < ARRAY_SIZE(wm8731_poodle_controls); i++) {
-		err = snd_ctl_add(codec->card,
-			snd_soc_cnew(&wm8731_poodle_controls[i], codec, NULL));
-		if (err < 0)
-			return err;
-	}
+	err = snd_soc_add_controls(codec, wm8731_poodle_controls,
+				ARRAY_SIZE(wm8731_poodle_controls));
+	if (err < 0)
+		return err;
 
 	/* Add poodle specific widgets */
 	snd_soc_dapm_new_controls(codec, wm8731_dapm_widgets,
sound/soc/pxa/spitz.c +5 -7
index 1aafd8c..6ca9f53 100644
@@ -278,7 +278,7 @@ static const struct snd_kcontrol_new wm8750_spitz_controls[] = {
  */
 static int spitz_wm8750_init(struct snd_soc_codec *codec)
 {
-	int i, err;
+	int err;
 
 	/* NC codec pins */
 	snd_soc_dapm_nc_pin(codec, "RINPUT1");
@@ -290,12 +290,10 @@ static int spitz_wm8750_init(struct snd_soc_codec *codec)
 	snd_soc_dapm_nc_pin(codec, "MONO1");
 
 	/* Add spitz specific controls */
-	for (i = 0; i < ARRAY_SIZE(wm8750_spitz_controls); i++) {
-		err = snd_ctl_add(codec->card,
-			snd_soc_cnew(&wm8750_spitz_controls[i], codec, NULL));
-		if (err < 0)
-			return err;
-	}
+	err = snd_soc_add_controls(codec, wm8750_spitz_controls,
+				ARRAY_SIZE(wm8750_spitz_controls));
+	if (err < 0)
+		return err;
 
 	/* Add spitz specific widgets */
 	snd_soc_dapm_new_controls(codec, wm8750_dapm_widgets,
sound/soc/pxa/tosa.c +5 -7
index 09b5bad..fc78137 100644
@@ -188,18 +188,16 @@ static const struct snd_kcontrol_new tosa_controls[] = {
 
 static int tosa_ac97_init(struct snd_soc_codec *codec)
 {
-	int i, err;
+	int err;
 
 	snd_soc_dapm_nc_pin(codec, "OUT3");
 	snd_soc_dapm_nc_pin(codec, "MONOOUT");
 
 	/* add tosa specific controls */
-	for (i = 0; i < ARRAY_SIZE(tosa_controls); i++) {
-		err = snd_ctl_add(codec->card,
-				snd_soc_cnew(&tosa_controls[i],codec, NULL));
-		if (err < 0)
-			return err;
-	}
+	err = snd_soc_add_controls(codec, tosa_controls,
+				ARRAY_SIZE(tosa_controls));
+	if (err < 0)
+		return err;
 
 	/* add tosa specific widgets */
 	snd_soc_dapm_new_controls(codec, tosa_dapm_widgets,
sound/soc/s3c24xx/neo1973_wm8753.c +5 -8
index 5f6aeec..289fadf 100644
@@ -498,7 +498,7 @@ static const struct snd_kcontrol_new wm8753_neo1973_controls[] = {
  */
 static int neo1973_wm8753_init(struct snd_soc_codec *codec)
 {
-	int i, err;
+	int err;
 
 	pr_debug("Entered %s\n", __func__);
 
@@ -518,13 +518,10 @@ static int neo1973_wm8753_init(struct snd_soc_codec *codec)
 	set_scenario_endpoints(codec, NEO_AUDIO_OFF);
 
 	/* add neo1973 specific controls */
-	for (i = 0; i < ARRAY_SIZE(wm8753_neo1973_controls); i++) {
-		err = snd_ctl_add(codec->card,
-				snd_soc_cnew(&wm8753_neo1973_controls[i],
-				codec, NULL));
-		if (err < 0)
-			return err;
-	}
+	err = snd_soc_add_controls(codec, wm8753_neo1973_controls,
+				ARRAY_SIZE(8753_neo1973_controls));
+	if (err < 0)
+		return err;
 
 	/* set up neo1973 specific audio routes */
 	err = snd_soc_dapm_add_routes(codec, dapm_routes,
Signature · 1 line
1.6.2
Applied
#8 lore raw

Re: [PATCH 3/5] ASoC: Replace remaining uses of snd_soc_cnew with snd_soc_add_controls.

Quoted 5 lines · Philipp Zabel

The drivers are basically duplicating the same code over and over. As snd_soc_cnew is going to be made static some time after the next merge window, we might as well convert them now.

Applied, thanks.

#9 lore raw

PATCH 1/1 ASoC: Add Magician machine support.

In reply to Mark Brown

HTC Magician has a Philips UDA1380 codec connected via SSP1 (playback) and I2S (capture).
There is a flip-flop between the SSP frame clock output and the codec's word select input pin. To make the codec see proper I2S input, the SSP has to send two frames per sample.

---
 sound/soc/pxa/Kconfig    |   10 +
 sound/soc/pxa/Makefile   |    2 +
 sound/soc/pxa/magician.c |  560 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 572 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/pxa/magician.c
sound/soc/pxa/Kconfig +10 -0
index 5998ab3..ad8a10f 100644
@@ -116,6 +116,16 @@ config SND_SOC_ZYLONITE
 	  Say Y if you want to add support for SoC audio on the
 	  Marvell Zylonite reference platform.
 
+config SND_PXA2XX_SOC_MAGICIAN
+	tristate "SoC Audio support for HTC Magician"
+	depends on SND_PXA2XX_SOC && MACH_MAGICIAN
+	select SND_PXA2XX_SOC_I2S
+	select SND_PXA_SOC_SSP
+	select SND_SOC_UDA1380
+	help
+	  Say Y if you want to add support for SoC audio on the
+	  HTC Magician.
+
 config SND_PXA2XX_SOC_MIOA701
         tristate "SoC Audio support for MIO A701"
         depends on SND_PXA2XX_SOC && MACH_MIOA701
sound/soc/pxa/Makefile +2 -0
index 8ed881c..4b90c3c 100644
@@ -20,6 +20,7 @@ snd-soc-spitz-objs := spitz.o
 snd-soc-em-x270-objs := em-x270.o
 snd-soc-palm27x-objs := palm27x.o
 snd-soc-zylonite-objs := zylonite.o
+snd-soc-magician-objs := magician.o
 snd-soc-mioa701-objs := mioa701_wm9713.o
 
 obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o
@@ -31,5 +32,6 @@ obj-$(CONFIG_SND_PXA2XX_SOC_E800) += snd-soc-e800.o
 obj-$(CONFIG_SND_PXA2XX_SOC_SPITZ) += snd-soc-spitz.o
 obj-$(CONFIG_SND_PXA2XX_SOC_EM_X270) += snd-soc-em-x270.o
 obj-$(CONFIG_SND_PXA2XX_SOC_PALM27X) += snd-soc-palm27x.o
+obj-$(CONFIG_SND_PXA2XX_SOC_MAGICIAN) += snd-soc-magician.o
 obj-$(CONFIG_SND_PXA2XX_SOC_MIOA701) += snd-soc-mioa701.o
 obj-$(CONFIG_SND_SOC_ZYLONITE) += snd-soc-zylonite.o
sound/soc/pxa/magician.c new file +560 -0

560 lines not on this page · raw message

Signature · 1 line
1.6.2
#10 lore raw

Re: [PATCH] ASoC: Add Magician machine support.

Quoted 8 lines · Philipp Zabel

HTC Magician has a Philips UDA1380 codec connected via SSP1 (playback) and I2S (capture).
There is a flip-flop between the SSP frame clock output and the codec's word select input pin. To make the codec see proper I2S input, the SSP has to send two frames per sample.

This all looks good. I'll hold off on applying until we've got the SSP change resolved since it's needed for the driver to work properly.

#11 lore raw

RFC PATCH 3/3 ASoC: pxa-ssp: Don't use SSCR0_SerClkDiv and SSCR0_SCR

In reply to Philipp Zabel

As soon as CONFIG_PXA25x is enabled, those macros only handle the PXA25x_SSP case, which is wrong most of the time (and always wrong on >=PXA27x).

Conflicts:

sound/soc/pxa/pxa-ssp.c

---
 sound/soc/pxa/pxa-ssp.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
sound/soc/pxa/pxa-ssp.c +9 -2
index bc9d306..2a2c322 100644
@@ -287,10 +287,17 @@ static void ssp_set_scr(struct ssp_priv *priv, u32 div)
 {
 	struct ssp_dev *dev = &priv->dev;
 	struct ssp_device *ssp = dev->ssp;
-	u32 sscr0 = ssp_read_reg(dev->ssp, SSCR0) & ~SSCR0_SCR;
+	u32 sscr0 = ssp_read_reg(dev->ssp, SSCR0);
 
 	priv->scr_div = div;
-	ssp_write_reg(ssp, SSCR0, (sscr0 | SSCR0_SerClkDiv(div)));
+	if (ssp->type == PXA25x_SSP) {
+		sscr0 &= ~0x0000ff00;        /* SSCR0_SCR */
+		sscr0 |= ((div - 2)/2) << 8; /* SSCR0_SerClkDiv(div) */
+	} else {
+		sscr0 &= ~0x000fff00;        /* SSCR0_SCR */
+		sscr0 |= (div - 1) << 8;     /* SSCR0_SerClkDiv(div) */
+	}
+	ssp_write_reg(ssp, SSCR0, sscr0);
 }
 
 /*
Signature · 1 line
1.6.2
#12 lore raw

Re: [PATCH 3/3][RFC] ASoC: pxa-ssp: Don't use SSCR0_SerClkDiv and SSCR0_SCR

Quoted 2 lines · Philipp Zabel

As soon as CONFIG_PXA25x is enabled, those macros only handle the PXA25x_SSP case, which is wrong most of the time (and always wrong on >=PXA27x).

Ah, I just (while reading this header file) wondered how this is supposed to work :)

Quoted 8 lines
sound/soc/pxa/pxa-ssp.c +1 -1
@@ -287,10 +287,17 @@ static void ssp_set_scr(struct ssp_priv *priv, u32 div)
 {
 	struct ssp_dev *dev = &priv->dev;
 	struct ssp_device *ssp = dev->ssp;
-	u32 sscr0 = ssp_read_reg(dev->ssp, SSCR0) & ~SSCR0_SCR;
+	u32 sscr0 = ssp_read_reg(dev->ssp, SSCR0);
 
 	priv->scr_div = div;

sound/soc/pxa/pxa-ssp.c static void ssp_set_scr(struct ssp_priv *priv, u32 div) · line 301

Quoted 10 lines
sound/soc/pxa/pxa-ssp.c +8 -1
-	ssp_write_reg(ssp, SSCR0, (sscr0 | SSCR0_SerClkDiv(div)));
+	if (ssp->type == PXA25x_SSP) {
+		sscr0 &= ~0x0000ff00;        /* SSCR0_SCR */
+		sscr0 |= ((div - 2)/2) << 8; /* SSCR0_SerClkDiv(div) */
+	} else {
+		sscr0 &= ~0x000fff00;        /* SSCR0_SCR */
+		sscr0 |= (div - 1) << 8;     /* SSCR0_SerClkDiv(div) */
+	}
+	ssp_write_reg(ssp, SSCR0, sscr0);
 }

Then we need something like ssp_get_scr() as well to cover my special case which uses SSCR0_SCR and SSCR0_SerClkDiv() again as you proposed ;)

Daniel

#13 lore raw

Re: [PATCH 3/3][RFC] ASoC: pxa-ssp: Don't use SSCR0_SerClkDiv and SSCR0_SCR

Quoted 14 lines · Daniel Mack
Quoted 2 lines · Philipp Zabel

As soon as CONFIG_PXA25x is enabled, those macros only handle the PXA25x_SSP case, which is wrong most of the time (and always wrong on >=PXA27x).

Ah, I just (while reading this header file) wondered how this is supposed to work :)

Quoted 7 lines
(quoted diff) +1 -1
@@ -287,10 +287,17 @@ static void ssp_set_scr(struct ssp_priv *priv, u32 div)
  {
       struct ssp_dev *dev = &priv->dev;
       struct ssp_device *ssp = dev->ssp;
-     u32 sscr0 = ssp_read_reg(dev->ssp, SSCR0) & ~SSCR0_SCR;
+     u32 sscr0 = ssp_read_reg(dev->ssp, SSCR0);
 
Quoted 14 lines

Review static void ssp_set_scr(struct ssp_priv *priv, u32 div) · line 301

Quoted 11 lines
(quoted diff) +8 -1
       priv->scr_div = div;
-     ssp_write_reg(ssp, SSCR0, (sscr0 | SSCR0_SerClkDiv(div)));
+     if (ssp->type == PXA25x_SSP) {
+             sscr0 &= ~0x0000ff00;        /* SSCR0_SCR */
+             sscr0 |= ((div - 2)/2) << 8; /* SSCR0_SerClkDiv(div) */
+     } else {
+             sscr0 &= ~0x000fff00;        /* SSCR0_SCR */
+             sscr0 |= (div - 1) << 8;     /* SSCR0_SerClkDiv(div) */
+     }
+     ssp_write_reg(ssp, SSCR0, sscr0);
  }

Then we need something like ssp_get_scr() as well to cover my special case which uses SSCR0_SCR and SSCR0_SerClkDiv() again as you proposed ;)

Aren't I clever... How about something like this:

---
 sound/soc/pxa/pxa-ssp.c |   30 ++++++++++++++++++++++++++----
 1 files changed, 26 insertions(+), 4 deletions(-)
sound/soc/pxa/pxa-ssp.c +23 -2
index 3cde686..245063b 100644
@@ -284,9 +284,30 @@ static int pxa_ssp_resume(struct snd_soc_dai *cpu_dai)
 static void ssp_set_scr(struct ssp_dev *dev, u32 div)
 {
 	struct ssp_device *ssp = dev->ssp;
-	u32 sscr0 = ssp_read_reg(dev->ssp, SSCR0) & ~SSCR0_SCR;
+	u32 sscr0 = ssp_read_reg(ssp, SSCR0);
+
+	if (cpu_is_pxa25x() && ssp->type == PXA25x_SSP) {
+		sscr0 &= ~0x0000ff00;
+		sscr0 |= ((div - 2)/2) << 8;
+	} else {
+		sscr0 &= ~0x000fff00;
+		sscr0 |= (div - 1) << 8;
+	}
+	ssp_write_reg(ssp, SSCR0, sscr0);
+}
 
-	ssp_write_reg(ssp, SSCR0, (sscr0 | SSCR0_SerClkDiv(div)));
+/**
+ * ssp_get_clkdiv - get SSP clock divider
+ */
+static u32 ssp_get_scr(struct ssp_dev *dev)
+{
+	struct ssp_device *ssp = dev->ssp;
+	u32 sscr0 = ssp_read_reg(ssp, SSCR0);
+
+	if (cpu_is_pxa25x() && ssp->type == PXA25x_SSP)
+		return ((sscr0 >> 8) & 0xff) * 2 + 2;
+	else
+		return ((sscr0 >> 8) & 0xfff) + 1;
 }
 
 /*
@@ -668,8 +689,7 @@ static int pxa_ssp_hw_params(struct

snd_pcm_substream *substream,
case SND_SOC_DAIFMT_I2S:
sspsp = ssp_read_reg(ssp, SSPSP);

- if (((sscr0 & SSCR0_SCR) == SSCR0_SerClkDiv(4)) &&
- (width == 16)) {
+ if (ssp_get_scr(ssp) == 4) && (width == 16)) {
/* This is a special case where the bitclk is 64fs
* and we're not dealing with 2*32 bits of audio
* samples.

Signature · 1 line
1.6.2
#14 lore raw

Re: [PATCH 3/3][RFC] ASoC: pxa-ssp: Don't use SSCR0_SerClkDiv and SSCR0_SCR

Quoted 4 lines · pHilipp Zabel
Quoted 2 lines

Then we need something like ssp_get_scr() as well to cover my special case which uses SSCR0_SCR and SSCR0_SerClkDiv() again as you proposed ;)

Aren't I clever... How about something like this:

Jep, look good to me.

(Just for the reference - this one needs to be applied on top of my last
'network vs psp mode' patch, otherwise the second hunk won't apply).

Thanks,
Daniel

Quoted 54 lines
---
 sound/soc/pxa/pxa-ssp.c |   30 ++++++++++++++++++++++++++----
 1 files changed, 26 insertions(+), 4 deletions(-)
sound/soc/pxa/pxa-ssp.c +24 -4
index 3cde686..245063b 100644
@@ -284,9 +284,30 @@ static int pxa_ssp_resume(struct snd_soc_dai *cpu_dai)
 static void ssp_set_scr(struct ssp_dev *dev, u32 div)
 {
 	struct ssp_device *ssp = dev->ssp;
-	u32 sscr0 = ssp_read_reg(dev->ssp, SSCR0) & ~SSCR0_SCR;
+	u32 sscr0 = ssp_read_reg(ssp, SSCR0);
+
+	if (cpu_is_pxa25x() && ssp->type == PXA25x_SSP) {
+		sscr0 &= ~0x0000ff00;
+		sscr0 |= ((div - 2)/2) << 8;
+	} else {
+		sscr0 &= ~0x000fff00;
+		sscr0 |= (div - 1) << 8;
+	}
+	ssp_write_reg(ssp, SSCR0, sscr0);
+}
 
-	ssp_write_reg(ssp, SSCR0, (sscr0 | SSCR0_SerClkDiv(div)));
+/**
+ * ssp_get_clkdiv - get SSP clock divider
+ */
+static u32 ssp_get_scr(struct ssp_dev *dev)
+{
+	struct ssp_device *ssp = dev->ssp;
+	u32 sscr0 = ssp_read_reg(ssp, SSCR0);
+
+	if (cpu_is_pxa25x() && ssp->type == PXA25x_SSP)
+		return ((sscr0 >> 8) & 0xff) * 2 + 2;
+	else
+		return ((sscr0 >> 8) & 0xfff) + 1;
 }
 
 /*
@@ -668,8 +689,7 @@ static int pxa_ssp_hw_params(struct
 snd_pcm_substream *substream,
 	case SND_SOC_DAIFMT_I2S:
 	       sspsp = ssp_read_reg(ssp, SSPSP);
 
-		if (((sscr0 & SSCR0_SCR) == SSCR0_SerClkDiv(4)) &&
-		     (width == 16)) {
+		if (ssp_get_scr(ssp) == 4) && (width == 16)) {
 			/* This is a special case where the bitclk is 64fs
 			* and we're not dealing with 2*32 bits of audio

* samples.

Signature · 1 line
1.6.2
#15 lore raw

Re: [PATCH 3/3][RFC] ASoC: pxa-ssp: Don't use SSCR0_SerClkDiv and SSCR0_SCR

Quoted 2 lines · Daniel Mack

(Just for the reference - this one needs to be applied on top of my last
'network vs psp mode' patch, otherwise the second hunk won't apply).

Could you please resubmit the most current versions of your outstanding patches? There's too many versions of patches floating around in the middle of threads and I want to make sure I'm looking at the most current versions.

#16 lore raw

Re: [PATCH 3/3][RFC] ASoC: pxa-ssp: Don't use SSCR0_SerClkDiv and SSCR0_SCR

Quoted 9 lines · Mark Brown
Quoted 2 lines · Daniel Mack

(Just for the reference - this one needs to be applied on top of my last
'network vs psp mode' patch, otherwise the second hunk won't apply).

Could you please resubmit the most current versions of your outstanding patches? There's too many versions of patches floating around in the middle of threads and I want to make sure I'm looking at the most current versions.

Sorry. See below. There's only one left now and this one shrunk a lot.

Daniel

Quoted 1 line

From ad8734e93eed130a55482b0e937729578e6d93c8 Mon Sep 17 00:00:00 2001

From: Daniel Mack <[email protected]>
Date: Wed, 11 Mar 2009 19:38:15 +0100
Subject: [PATCH] pxa-ssp: switch from network mode to PSP

This switches the pxa ssp port usage from network mode to PSP mode. Removed some comments and checks for configured TDM channels. A special case is added to support configuration where BCLK = 64fs. We need to do some black magic in this case which doesn't look nice but there is unfortunately no other option than that.

---
 sound/soc/pxa/pxa-ssp.c |   44 +++++++++++++++++++++++++++++++++-----------
 1 files changed, 33 insertions(+), 11 deletions(-)
sound/soc/pxa/pxa-ssp.c +33 -11
index 52d97c4..3cde686 100644
@@ -558,18 +558,17 @@ static int pxa_ssp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
 
 	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
 	case SND_SOC_DAIFMT_I2S:
-		sscr0 |= SSCR0_MOD | SSCR0_PSP;
+		sscr0 |= SSCR0_PSP;
 		sscr1 |= SSCR1_RWOT | SSCR1_TRAIL;
 
 		switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
 		case SND_SOC_DAIFMT_NB_NF:
-			sspsp |= SSPSP_FSRT;
 			break;
 		case SND_SOC_DAIFMT_NB_IF:
-			sspsp |= SSPSP_SFRMP | SSPSP_FSRT;
+			sspsp |= SSPSP_SFRMP;
 			break;
 		case SND_SOC_DAIFMT_IB_IF:
-			sspsp |= SSPSP_SFRMP;
+			sspsp |= SSPSP_SFRMP | SSPSP_SCMODE(3);
 			break;
 		default:
 			return -EINVAL;
@@ -655,33 +654,56 @@ static int pxa_ssp_hw_params(struct snd_pcm_substream *substream,
 			sscr0 |= SSCR0_FPCKE;
 #endif
 		sscr0 |= SSCR0_DataSize(16);
-		/* use network mode (2 slots) for 16 bit stereo */
 		break;
 	case SNDRV_PCM_FORMAT_S24_LE:
 		sscr0 |= (SSCR0_EDSS | SSCR0_DataSize(8));
-		/* we must be in network mode (2 slots) for 24 bit stereo */
 		break;
 	case SNDRV_PCM_FORMAT_S32_LE:
 		sscr0 |= (SSCR0_EDSS | SSCR0_DataSize(16));
-		/* we must be in network mode (2 slots) for 32 bit stereo */
 		break;
 	}
 	ssp_write_reg(ssp, SSCR0, sscr0);
 
 	switch (priv->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
 	case SND_SOC_DAIFMT_I2S:
-		/* Cleared when the DAI format is set */
-		sspsp = ssp_read_reg(ssp, SSPSP) | SSPSP_SFRMWDTH(width);
+	       sspsp = ssp_read_reg(ssp, SSPSP);
+
+		if (((sscr0 & SSCR0_SCR) == SSCR0_SerClkDiv(4)) &&
+		     (width == 16)) {
+			/* This is a special case where the bitclk is 64fs
+			* and we're not dealing with 2*32 bits of audio
+			* samples.
+			*
+			* The SSP values used for that are all found out by
+			* trying and failing a lot; some of the registers
+			* needed for that mode are only available on PXA3xx.
+			*/
+
+#ifdef CONFIG_PXA3xx
+			if (!cpu_is_pxa3xx())
+				return -EINVAL;
+
+			sspsp |= SSPSP_SFRMWDTH(width * 2);
+			sspsp |= SSPSP_SFRMDLY(width * 4);
+			sspsp |= SSPSP_EDMYSTOP(3);
+			sspsp |= SSPSP_DMYSTOP(3);
+			sspsp |= SSPSP_DMYSTRT(1);
+#else
+			return -EINVAL;
+#endif
+		} else
+			sspsp |= SSPSP_SFRMWDTH(width);
+
 		ssp_write_reg(ssp, SSPSP, sspsp);
 		break;
 	default:
 		break;
 	}
 
-	/* We always use a network mode so we always require TDM slots
+	/* When we use a network mode, we always require TDM slots
 	 * - complain loudly and fail if they've not been set up yet.
 	 */
-	if (!(ssp_read_reg(ssp, SSTSA) & 0xf)) {
+	if ((sscr0 & SSCR0_MOD) && !(ssp_read_reg(ssp, SSTSA) & 0xf)) {
 		dev_err(&ssp->pdev->dev, "No TDM timeslot configured\n");
 		return -EINVAL;
 	}
Signature · 1 line
1.6.2
#17 lore raw

Re: [PATCH 3/3][RFC] ASoC: pxa-ssp: Don't use SSCR0_SerClkDiv and SSCR0_SCR

Quoted 1 line · Daniel Mack

Sorry. See below. There's only one left now and this one shrunk a lot.

Oh, thanks - I had that one, from what you wrote I thought there were more that I'd dropped on the floor. I'll review later today.

#18 lore raw

Re: [PATCH 3/3][RFC] ASoC: pxa-ssp: Don't use SSCR0_SerClkDiv and SSCR0_SCR

In reply to Daniel Mack
Quoted 6 lines · Daniel Mack
Quoted 5 lines · Mark Brown
Quoted 2 lines · Daniel Mack

(Just for the reference - this one needs to be applied on top of my last
'network vs psp mode' patch, otherwise the second hunk won't apply).

Quoted 6 lines
Quoted 4 lines

Could you please resubmit the most current versions of your outstanding patches? There's too many versions of patches floating around in the middle of threads and I want to make sure I'm looking at the most current versions.

Sorry. See below. There's only one left now and this one shrunk a lot.

Forgot one credit to this one.

Quoted 5 lines

From ad8734e93eed130a55482b0e937729578e6d93c8 Mon Sep 17 00:00:00 2001
From: Daniel Mack <[email protected]>
Date: Wed, 11 Mar 2009 19:38:15 +0100
Subject: [PATCH] pxa-ssp: switch from network mode to PSP

Quoted 7 lines

This switches the pxa ssp port usage from network mode to PSP mode. Removed some comments and checks for configured TDM channels. A special case is added to support configuration where BCLK = 64fs. We need to do some black magic in this case which doesn't look nice but there is unfortunately no other option than that.

#19 lore raw

Re: [PATCH 3/3][RFC] ASoC: pxa-ssp: Don't use SSCR0_SerClkDiv and SSCR0_SCR

In reply to Daniel Mack
Quoted 39 lines · Daniel Mack
Quoted 9 lines · Mark Brown
Quoted 2 lines · Daniel Mack

(Just for the reference - this one needs to be applied on top of my last 'network vs psp mode' patch, otherwise the second hunk won't apply).

Could you please resubmit the most current versions of your outstanding patches?  There's too many versions of patches floating around in the middle of threads and I want to make sure I'm looking at the most current versions.

Sorry. See below. There's only one left now and this one shrunk a lot.

Daniel

From ad8734e93eed130a55482b0e937729578e6d93c8 Mon Sep 17 00:00:00 2001
From: Daniel Mack <[email protected]>
Date: Wed, 11 Mar 2009 19:38:15 +0100
Subject: [PATCH] pxa-ssp: switch from network mode to PSP

This switches the pxa ssp port usage from network mode to PSP mode. Removed some comments and checks for configured TDM channels. A special case is added to support configuration where BCLK = 64fs. We need to do some black magic in this case which doesn't look nice but there is unfortunately no other option than that.

---
 sound/soc/pxa/pxa-ssp.c |   44 +++++++++++++++++++++++++++++++++-----------

 1 files changed, 33 insertions(+), 11 deletions(-)
sound/soc/pxa/pxa-ssp.c +0 -0
index 52d97c4..3cde686 100644
@@ -558,18 +558,17 @@ static int pxa_ssp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
 
        switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
Quoted 3 lines

       case SND_SOC_DAIFMT_I2S:
-               sscr0 |= SSCR0_MOD | SSCR0_PSP;
+               sscr0 |= SSCR0_PSP;

There is one more thing I didn't think about yet. Disabling network mode here unconditionally should break Zylonite as is, unless it can also be changed to use that special 64fs mode.
This code is found in zylonite_voice_hw_params right now:

        /* Use network mode for stereo, one slot per channel. */
        if (params_channels(params) > 1)
                ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0x3, 2);
        else
                ret = snd_soc_dai_set_tdm_slot(cpu_dai, 1, 1);
        if (ret < 0)
                return ret;

And I realize I don't quite understand why it handles the mono case at all - isn't I2S always stereo?

Quoted 84 lines

               sscr1 |= SSCR1_RWOT | SSCR1_TRAIL;

               switch (fmt & SND_SOC_DAIFMT_INV_MASK) { case SND_SOC_DAIFMT_NB_NF:
-                       sspsp |= SSPSP_FSRT;
                       break;
               case SND_SOC_DAIFMT_NB_IF:
-                       sspsp |= SSPSP_SFRMP | SSPSP_FSRT;
+                       sspsp |= SSPSP_SFRMP;
                       break;
               case SND_SOC_DAIFMT_IB_IF:
-                       sspsp |= SSPSP_SFRMP;
+                       sspsp |= SSPSP_SFRMP | SSPSP_SCMODE(3); break;
               default:
                       return -EINVAL;

sound/soc/pxa/pxa-ssp.c +0 -1
@@ -655,33 +654,56 @@ static int pxa_ssp_hw_params(struct snd_pcm_substream *substream,
                        sscr0 |= SSCR0_FPCKE;
  #endif
                sscr0 |= SSCR0_DataSize(16);
-               /* use network mode (2 slots) for 16 bit stereo */
                break;

       case SNDRV_PCM_FORMAT_S24_LE:
               sscr0 |= (SSCR0_EDSS | SSCR0_DataSize(8));
-               /* we must be in network mode (2 slots) for 24 bit stereo */ break;
       case SNDRV_PCM_FORMAT_S32_LE:
               sscr0 |= (SSCR0_EDSS | SSCR0_DataSize(16));
-               /* we must be in network mode (2 slots) for 32 bit stereo */ break;
       }
       ssp_write_reg(ssp, SSCR0, sscr0);

       switch (priv->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S:
-               /* Cleared when the DAI format is set */
-               sspsp = ssp_read_reg(ssp, SSPSP) | SSPSP_SFRMWDTH(width);
+              sspsp = ssp_read_reg(ssp, SSPSP);

sound/soc/pxa/pxa-ssp.c +27 -0
+
+               if (((sscr0 & SSCR0_SCR) == SSCR0_SerClkDiv(4)) &&
+                    (width == 16)) {
+                       /* This is a special case where the bitclk is 64fs
+                       * and we're not dealing with 2*32 bits of audio
+                       * samples.
+                       *
+                       * The SSP values used for that are all found out by
+                       * trying and failing a lot; some of the registers
+                       * needed for that mode are only available on PXA3xx.
+                       */
+
+#ifdef CONFIG_PXA3xx
+                       if (!cpu_is_pxa3xx())
+                               return -EINVAL;
+
+                       sspsp |= SSPSP_SFRMWDTH(width * 2);
+                       sspsp |= SSPSP_SFRMDLY(width * 4);
+                       sspsp |= SSPSP_EDMYSTOP(3);
+                       sspsp |= SSPSP_DMYSTOP(3);
+                       sspsp |= SSPSP_DMYSTRT(1);
+#else
+                       return -EINVAL;
+#endif
+               } else
+                       sspsp |= SSPSP_SFRMWDTH(width);
+

               ssp_write_reg(ssp, SSPSP, sspsp);
               break;
       default:
               break;
       }

-       /* We always use a network mode so we always require TDM slots
+       /* When we use a network mode, we always require TDM slots
        * - complain loudly and fail if they've not been set up yet. */
-       if (!(ssp_read_reg(ssp, SSTSA) & 0xf)) {
+       if ((sscr0 & SSCR0_MOD) && !(ssp_read_reg(ssp, SSTSA) & 0xf)) { dev_err(&ssp->pdev->dev, "No TDM timeslot configured\n"); return -EINVAL;
       }
--
1.6.2

#20 lore raw

Re: [PATCH 3/3][RFC] ASoC: pxa-ssp: Don't use SSCR0_SerClkDiv and SSCR0_SCR

Quoted 4 lines · pHilipp Zabel

There is one more thing I didn't think about yet. Disabling network mode here unconditionally should break Zylonite as is, unless it can also be changed to use that special 64fs mode.
This code is found in zylonite_voice_hw_params right now:

Yes, it completely hoses zylonite. I'm currently trying to come up with a non-networked configuration for Zylonite though.

Quoted 2 lines

And I realize I don't quite understand why it handles the mono case at all - isn't I2S always stereo?

It's moderately common to transmit mono data in one channel of the stereo I2S stream.

#21 lore raw

Re: [PATCH 3/3][RFC] ASoC: pxa-ssp: Don't use SSCR0_SerClkDiv and SSCR0_SCR

Quoted 7 lines · Mark Brown
Quoted 4 lines

There is one more thing I didn't think about yet. Disabling network mode here unconditionally should break Zylonite as is, unless it can also be changed to use that special 64fs mode.
This code is found in zylonite_voice_hw_params right now:

Yes, it completely hoses zylonite. I'm currently trying to come up with a non-networked configuration for Zylonite though.

Ok, thanks. However, if you're unable to get that running, I could also strip the patch down to explictly disable network mode for my special case. I hoped to get a straight approach working for everyone, but when we end up having more trouble fixing all the boards then, I would go the other way.

Daniel

Applied
#22 lore raw

Re: [PATCH 3/3][RFC] ASoC: pxa-ssp: Don't use SSCR0_SerClkDiv and SSCR0_SCR

In reply to Philipp Zabel
Quoted 4 lines · Philipp Zabel

As soon as CONFIG_PXA25x is enabled, those macros only handle the PXA25x_SSP case, which is wrong most of the time (and always wrong on >=PXA27x).

Applied, thanks.

#23 lore raw

Re: [PATCH 3/3][RFC] ASoC: pxa-ssp: Don't use SSCR0_SerClkDiv and SSCR0_SCR

Quoted 7 lines · Mark Brown
Quoted 4 lines · Philipp Zabel

As soon as CONFIG_PXA25x is enabled, those macros only handle the PXA25x_SSP case, which is wrong most of the time (and always wrong on >=PXA27x).

Applied, thanks.

Or not, sorry - wires crossed there.

#24 lore raw
In reply to Philipp Zabel
Quoted 3 lines · Philipp Zabel

Please advise how this behaviour could be made configurable. I guess the only machines that will ever need this are HTC Magician, Blueangel and Himalaya.

Mmm... fun. :/

For configurability I'd suggest using one of the ops that the DAI exports to allow you to flip a variable somewhere. That variable can then be checked instead of your machine_is_() check. Not terribly nice but as you say I don't see this being needed terribly often.