linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 2/2] ASoC: fsl_ssi: add 20-bit sample format for AC'97 and use it for capture
@ 2017-11-23 23:33 Maciej S. Szmigiero
  2017-11-25  1:06 ` kbuild test robot
  2017-11-25  1:07 ` kbuild test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Maciej S. Szmigiero @ 2017-11-23 23:33 UTC (permalink / raw)
  To: Timur Tabi, Nicolin Chen, Xiubo Li
  Cc: Fabio Estevam, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, alsa-devel, linuxppc-dev, linux-kernel

When testing AC'97 capture on UDOO board (currently the only user of
fsl_ssi driver in the AC'97 mode) it become obvious that there is a massive
distortion above certain, small input signal.

This problem has been traced to silicon errata ERR003778:
"In AC97, 16-bit mode, received data is shifted by 4-bit locations" that
has "No fix scheduled".
This errata suggests a workaround of doing a 4-bit shift back in SDMA
script for this specific operation mode, however our SDMA scripts are
shared between various SoC peripherals so we can't really modify them.

There is a simple way to avoid this problem, however, that is to disallow
recording in 16-bit mode and only support it in AC'97-native 20-bit mode.
We have to use a 4-byte format for this since SSI FIFOs do not allow 3-byte
accesses (and these aren't supported by imx-sdma driver anyway).
With this change the capture distortion is gone.

We can also add this format as an additional one supported for playback,
using this opportunity to make sure that we use CPU-endian-native formats
in AC'97 mode as we already do in I2S mode.

There is no problem in using different bit widths in playback and capture
in AC'97 mode so allow this, too.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
---
Changes from v1: Adapt format name to changes in the first patch from
this series.

 sound/soc/fsl/fsl_ssi.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 20ef09e1a395..c350117c8e31 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -1278,14 +1278,15 @@ static struct snd_soc_dai_driver fsl_ssi_ac97_dai = {
 		.channels_min = 2,
 		.channels_max = 2,
 		.rates = SNDRV_PCM_RATE_8000_48000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
+		.formats = SNDRV_PCM_FMTBIT_S16 | SNDRV_PCM_FMTBIT_S20,
 	},
 	.capture = {
 		.stream_name = "AC97 Capture",
 		.channels_min = 2,
 		.channels_max = 2,
 		.rates = SNDRV_PCM_RATE_48000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
+		/* 16-bit capture is broken (errata ERR003778) */
+		.formats = SNDRV_PCM_FMTBIT_S20,
 	},
 	.ops = &fsl_ssi_dai_ops,
 };
@@ -1557,11 +1558,12 @@ static int fsl_ssi_probe(struct platform_device *pdev)
 
 	/* Are the RX and the TX clocks locked? */
 	if (!of_find_property(np, "fsl,ssi-asynchronous", NULL)) {
-		if (!fsl_ssi_is_ac97(ssi_private))
+		if (!fsl_ssi_is_ac97(ssi_private)) {
 			ssi_private->cpu_dai_drv.symmetric_rates = 1;
+			ssi_private->cpu_dai_drv.symmetric_samplebits = 1;
+		}
 
 		ssi_private->cpu_dai_drv.symmetric_channels = 1;
-		ssi_private->cpu_dai_drv.symmetric_samplebits = 1;
 	}
 
 	/* Determine the FIFO depth. */

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 2/2] ASoC: fsl_ssi: add 20-bit sample format for AC'97 and use it for capture
  2017-11-23 23:33 [PATCH v2 2/2] ASoC: fsl_ssi: add 20-bit sample format for AC'97 and use it for capture Maciej S. Szmigiero
@ 2017-11-25  1:06 ` kbuild test robot
  2017-11-25  1:07 ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2017-11-25  1:06 UTC (permalink / raw)
  To: Maciej S. Szmigiero
  Cc: kbuild-all, Timur Tabi, Nicolin Chen, Xiubo Li, Fabio Estevam,
	Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linuxppc-dev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1848 bytes --]

Hi Maciej,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on sound/for-next]
[also build test ERROR on v4.14 next-20171124]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Maciej-S-Szmigiero/ALSA-pcm-add-SNDRV_PCM_FORMAT_-S-U-20_4/20171125-082039
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
config: x86_64-randconfig-x012-201747 (attached as .config)
compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> sound/soc//fsl/fsl_ssi.c:1237:37: error: 'SNDRV_PCM_FMTBIT_S20' undeclared here (not in a function)
      .formats = SNDRV_PCM_FMTBIT_S16 | SNDRV_PCM_FMTBIT_S20,
                                        ^~~~~~~~~~~~~~~~~~~~

vim +/SNDRV_PCM_FMTBIT_S20 +1237 sound/soc//fsl/fsl_ssi.c

  1228	
  1229	static struct snd_soc_dai_driver fsl_ssi_ac97_dai = {
  1230		.bus_control = true,
  1231		.probe = fsl_ssi_dai_probe,
  1232		.playback = {
  1233			.stream_name = "AC97 Playback",
  1234			.channels_min = 2,
  1235			.channels_max = 2,
  1236			.rates = SNDRV_PCM_RATE_8000_48000,
> 1237			.formats = SNDRV_PCM_FMTBIT_S16 | SNDRV_PCM_FMTBIT_S20,
  1238		},
  1239		.capture = {
  1240			.stream_name = "AC97 Capture",
  1241			.channels_min = 2,
  1242			.channels_max = 2,
  1243			.rates = SNDRV_PCM_RATE_48000,
  1244			/* 16-bit capture is broken (errata ERR003778) */
  1245			.formats = SNDRV_PCM_FMTBIT_S20,
  1246		},
  1247		.ops = &fsl_ssi_dai_ops,
  1248	};
  1249	
  1250	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 26525 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 2/2] ASoC: fsl_ssi: add 20-bit sample format for AC'97 and use it for capture
  2017-11-23 23:33 [PATCH v2 2/2] ASoC: fsl_ssi: add 20-bit sample format for AC'97 and use it for capture Maciej S. Szmigiero
  2017-11-25  1:06 ` kbuild test robot
@ 2017-11-25  1:07 ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2017-11-25  1:07 UTC (permalink / raw)
  To: Maciej S. Szmigiero
  Cc: kbuild-all, Timur Tabi, Nicolin Chen, Xiubo Li, Fabio Estevam,
	Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linuxppc-dev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2068 bytes --]

Hi Maciej,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on sound/for-next]
[also build test ERROR on v4.14 next-20171124]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Maciej-S-Szmigiero/ALSA-pcm-add-SNDRV_PCM_FORMAT_-S-U-20_4/20171125-082039
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
config: sparc64-allmodconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=sparc64 

All errors (new ones prefixed by >>):

>> sound/soc/fsl/fsl_ssi.c:1237:37: error: 'SNDRV_PCM_FMTBIT_S20' undeclared here (not in a function); did you mean 'SNDRV_PCM_FMTBIT_S24'?
      .formats = SNDRV_PCM_FMTBIT_S16 | SNDRV_PCM_FMTBIT_S20,
                                        ^~~~~~~~~~~~~~~~~~~~
                                        SNDRV_PCM_FMTBIT_S24

vim +1237 sound/soc/fsl/fsl_ssi.c

  1228	
  1229	static struct snd_soc_dai_driver fsl_ssi_ac97_dai = {
  1230		.bus_control = true,
  1231		.probe = fsl_ssi_dai_probe,
  1232		.playback = {
  1233			.stream_name = "AC97 Playback",
  1234			.channels_min = 2,
  1235			.channels_max = 2,
  1236			.rates = SNDRV_PCM_RATE_8000_48000,
> 1237			.formats = SNDRV_PCM_FMTBIT_S16 | SNDRV_PCM_FMTBIT_S20,
  1238		},
  1239		.capture = {
  1240			.stream_name = "AC97 Capture",
  1241			.channels_min = 2,
  1242			.channels_max = 2,
  1243			.rates = SNDRV_PCM_RATE_48000,
  1244			/* 16-bit capture is broken (errata ERR003778) */
  1245			.formats = SNDRV_PCM_FMTBIT_S20,
  1246		},
  1247		.ops = &fsl_ssi_dai_ops,
  1248	};
  1249	
  1250	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 51919 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-11-25  1:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-23 23:33 [PATCH v2 2/2] ASoC: fsl_ssi: add 20-bit sample format for AC'97 and use it for capture Maciej S. Szmigiero
2017-11-25  1:06 ` kbuild test robot
2017-11-25  1:07 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).