All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: snd_soc_dai_set_fmt add substream independence.
@ 2020-03-28  1:58 Matt Flax
  2020-03-28  3:31 ` kbuild test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Matt Flax @ 2020-03-28  1:58 UTC (permalink / raw)
  To: lgirdwood, broonie, lars, pierre-louis.bossart, alsa-devel; +Cc: Matt Flax

This patch is aims to start a stronger discussion on allowing both CPU
and Codec dais to set formats independently based on direction.

Currently it is very difficult to change stream formats because there
is no way to specify it independently.

A previous discussion w.r.t. a codec's stream dependent format setting
required a codec's dai to be split. See here :
https://mailman.alsa-project.org/pipermail/alsa-devel/2020-March/164492.html

A previous discussion w.r.t. changing format based on the stream direction
w.r.t. a CPU's dai showed the difficulty in setting fmt based on
direection in thw hw_params function. See here :
https://mailman.alsa-project.org/pipermail/alsa-devel/2020-March/165101.html

It seems that it may be necessary to allow the stream direction as an
input argument to snd_soc_dai_set_fmt.

This patch is not complete, as there are many codecs and cpus which would
require this change. However this patch is aimed as a discussion point.

One example of a sound card which requires independent stream formats is
an isolated sound card, such as the Audio Injector Isolated sound card.
The magnetic isolation chips on the sound card require stream fomats to
be different because of digital latency variations on the I2S lines.

Signed-off-by: Matt Flax <flatmax@flatmax.org>
---
 include/sound/soc-dai.h | 4 ++--
 sound/soc/soc-core.c    | 5 +++--
 sound/soc/soc-dai.c     | 4 ++--
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index eaaeb00e9e84..5071e006389b 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -123,7 +123,7 @@ int snd_soc_dai_set_pll(struct snd_soc_dai *dai,
 int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio);
 
 /* Digital Audio interface formatting */
-int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt);
+int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt, int stream);
 
 int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
 	unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width);
@@ -186,7 +186,7 @@ struct snd_soc_dai_ops {
 	 * DAI format configuration
 	 * Called by soc_card drivers, normally in their hw_params.
 	 */
-	int (*set_fmt)(struct snd_soc_dai *dai, unsigned int fmt);
+	int (*set_fmt)(struct snd_soc_dai *dai, unsigned int fmt, int stream);
 	int (*xlate_tdm_slot_mask)(unsigned int slots,
 		unsigned int *tx_mask, unsigned int *rx_mask);
 	int (*set_tdm_slot)(struct snd_soc_dai *dai,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 068d809c349a..27a6f01dc2d3 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1474,10 +1474,11 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_dai *codec_dai;
 	unsigned int i;
-	int ret;
+	int ret, stream;
 
 	for_each_rtd_codec_dai(rtd, i, codec_dai) {
-		ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt);
+		int stream = 0;
+		ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt, stream);
 		if (ret != 0 && ret != -ENOTSUPP) {
 			dev_warn(codec_dai->dev,
 				 "ASoC: Failed to set DAI format: %d\n", ret);
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 51031e330179..1f8ee7875656 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -94,11 +94,11 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_bclk_ratio);
  *
  * Configures the DAI hardware format and clocking.
  */
-int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
+int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt, int stream)
 {
 	if (dai->driver->ops->set_fmt == NULL)
 		return -ENOTSUPP;
-	return dai->driver->ops->set_fmt(dai, fmt);
+	return dai->driver->ops->set_fmt(dai, fmt, stream);
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_set_fmt);
 
-- 
2.20.1


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

* Re: [PATCH] ASoC: snd_soc_dai_set_fmt add substream independence.
  2020-03-28  1:58 [PATCH] ASoC: snd_soc_dai_set_fmt add substream independence Matt Flax
@ 2020-03-28  3:31 ` kbuild test robot
  2020-03-28  3:44 ` kbuild test robot
  2020-03-30 10:32 ` Mark Brown
  2 siblings, 0 replies; 9+ messages in thread
From: kbuild test robot @ 2020-03-28  3:31 UTC (permalink / raw)
  To: kbuild-all

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

Hi Matt,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on v5.6-rc7]
[cannot apply to asoc/for-next next-20200327]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Matt-Flax/ASoC-snd_soc_dai_set_fmt-add-substream-independence/20200328-102100
base:    16fbf79b0f83bc752cee8589279f1ebfe57b3b6e
config: openrisc-randconfig-a001-20200327 (attached as .config)
compiler: or1k-linux-gcc (GCC) 9.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
        GCC_VERSION=9.2.0 make.cross ARCH=openrisc 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> sound/soc/codecs/adau1701.c:632:13: error: initialization of 'int (*)(struct snd_soc_dai *, unsigned int,  int)' from incompatible pointer type 'int (*)(struct snd_soc_dai *, unsigned int)' [-Werror=incompatible-pointer-types]
     632 |  .set_fmt = adau1701_set_dai_fmt,
         |             ^~~~~~~~~~~~~~~~~~~~
   sound/soc/codecs/adau1701.c:632:13: note: (near initialization for 'adau1701_dai_ops.set_fmt')
   cc1: some warnings being treated as errors
--
>> sound/soc/codecs/adau17x1.c:762:13: error: initialization of 'int (*)(struct snd_soc_dai *, unsigned int,  int)' from incompatible pointer type 'int (*)(struct snd_soc_dai *, unsigned int)' [-Werror=incompatible-pointer-types]
     762 |  .set_fmt = adau17x1_set_dai_fmt,
         |             ^~~~~~~~~~~~~~~~~~~~
   sound/soc/codecs/adau17x1.c:762:13: note: (near initialization for 'adau17x1_dai_ops.set_fmt')
   cc1: some warnings being treated as errors
--
>> sound/soc/codecs/adau7118.c:417:13: error: initialization of 'int (*)(struct snd_soc_dai *, unsigned int,  int)' from incompatible pointer type 'int (*)(struct snd_soc_dai *, unsigned int)' [-Werror=incompatible-pointer-types]
     417 |  .set_fmt = adau7118_set_fmt,
         |             ^~~~~~~~~~~~~~~~
   sound/soc/codecs/adau7118.c:417:13: note: (near initialization for 'adau7118_ops.set_fmt')
   cc1: some warnings being treated as errors
--
>> sound/soc/codecs/ak4104.c:153:13: error: initialization of 'int (*)(struct snd_soc_dai *, unsigned int,  int)' from incompatible pointer type 'int (*)(struct snd_soc_dai *, unsigned int)' [-Werror=incompatible-pointer-types]
     153 |  .set_fmt = ak4104_set_dai_fmt,
         |             ^~~~~~~~~~~~~~~~~~
   sound/soc/codecs/ak4104.c:153:13: note: (near initialization for 'ak4101_dai_ops.set_fmt')
   cc1: some warnings being treated as errors
--
>> sound/soc/codecs/ak4458.c:497:13: error: initialization of 'int (*)(struct snd_soc_dai *, unsigned int,  int)' from incompatible pointer type 'int (*)(struct snd_soc_dai *, unsigned int)' [-Werror=incompatible-pointer-types]
     497 |  .set_fmt = ak4458_set_dai_fmt,
         |             ^~~~~~~~~~~~~~~~~~
   sound/soc/codecs/ak4458.c:497:13: note: (near initialization for 'ak4458_dai_ops.set_fmt')
   cc1: some warnings being treated as errors
--
>> sound/soc/codecs/ak4613.c:546:13: error: initialization of 'int (*)(struct snd_soc_dai *, unsigned int,  int)' from incompatible pointer type 'int (*)(struct snd_soc_dai *, unsigned int)' [-Werror=incompatible-pointer-types]
     546 |  .set_fmt = ak4613_dai_set_fmt,
         |             ^~~~~~~~~~~~~~~~~~
   sound/soc/codecs/ak4613.c:546:13: note: (near initialization for 'ak4613_dai_ops.set_fmt')
   cc1: some warnings being treated as errors
--
>> sound/soc/codecs/ak4642.c:500:13: error: initialization of 'int (*)(struct snd_soc_dai *, unsigned int,  int)' from incompatible pointer type 'int (*)(struct snd_soc_dai *, unsigned int)' [-Werror=incompatible-pointer-types]
     500 |  .set_fmt = ak4642_dai_set_fmt,
         |             ^~~~~~~~~~~~~~~~~~
   sound/soc/codecs/ak4642.c:500:13: note: (near initialization for 'ak4642_dai_ops.set_fmt')
   cc1: some warnings being treated as errors
--
>> sound/soc/codecs/alc5623.c:833:14: error: initialization of 'int (*)(struct snd_soc_dai *, unsigned int,  int)' from incompatible pointer type 'int (*)(struct snd_soc_dai *, unsigned int)' [-Werror=incompatible-pointer-types]
     833 |   .set_fmt = alc5623_set_dai_fmt,
         |              ^~~~~~~~~~~~~~~~~~~
   sound/soc/codecs/alc5623.c:833:14: note: (near initialization for 'alc5623_dai_ops.set_fmt')
   cc1: some warnings being treated as errors
--
>> sound/soc/codecs/cs35l33.c:671:13: error: initialization of 'int (*)(struct snd_soc_dai *, unsigned int,  int)' from incompatible pointer type 'int (*)(struct snd_soc_dai *, unsigned int)' [-Werror=incompatible-pointer-types]
     671 |  .set_fmt = cs35l33_set_dai_fmt,
         |             ^~~~~~~~~~~~~~~~~~~
   sound/soc/codecs/cs35l33.c:671:13: note: (near initialization for 'cs35l33_ops.set_fmt')
   cc1: some warnings being treated as errors
--
>> sound/soc/codecs/cs35l34.c:645:13: error: initialization of 'int (*)(struct snd_soc_dai *, unsigned int,  int)' from incompatible pointer type 'int (*)(struct snd_soc_dai *, unsigned int)' [-Werror=incompatible-pointer-types]
     645 |  .set_fmt = cs35l34_set_dai_fmt,
         |             ^~~~~~~~~~~~~~~~~~~
   sound/soc/codecs/cs35l34.c:645:13: note: (near initialization for 'cs35l34_ops.set_fmt')
   cc1: some warnings being treated as errors
--
>> sound/soc/codecs/cs42l42.c:910:13: error: initialization of 'int (*)(struct snd_soc_dai *, unsigned int,  int)' from incompatible pointer type 'int (*)(struct snd_soc_dai *, unsigned int)' [-Werror=incompatible-pointer-types]
     910 |  .set_fmt = cs42l42_set_dai_fmt,
         |             ^~~~~~~~~~~~~~~~~~~
   sound/soc/codecs/cs42l42.c:910:13: note: (near initialization for 'cs42l42_ops.set_fmt')
   cc1: some warnings being treated as errors
..

vim +632 sound/soc/codecs/adau1701.c

d48b088e3ec45e Lars-Peter Clausen 2014-11-19  624  
631ed8a2134dae Lars-Peter Clausen 2011-06-13  625  #define ADAU1701_RATES (SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 | \
631ed8a2134dae Lars-Peter Clausen 2011-06-13  626  	SNDRV_PCM_RATE_192000)
631ed8a2134dae Lars-Peter Clausen 2011-06-13  627  
631ed8a2134dae Lars-Peter Clausen 2011-06-13  628  #define ADAU1701_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
631ed8a2134dae Lars-Peter Clausen 2011-06-13  629  	SNDRV_PCM_FMTBIT_S24_LE)
631ed8a2134dae Lars-Peter Clausen 2011-06-13  630  
890754a878c887 Lars-Peter Clausen 2011-11-23  631  static const struct snd_soc_dai_ops adau1701_dai_ops = {
631ed8a2134dae Lars-Peter Clausen 2011-06-13 @632  	.set_fmt	= adau1701_set_dai_fmt,
631ed8a2134dae Lars-Peter Clausen 2011-06-13  633  	.hw_params	= adau1701_hw_params,
631ed8a2134dae Lars-Peter Clausen 2011-06-13  634  	.digital_mute	= adau1701_digital_mute,
d48b088e3ec45e Lars-Peter Clausen 2014-11-19  635  	.startup	= adau1701_startup,
631ed8a2134dae Lars-Peter Clausen 2011-06-13  636  };
631ed8a2134dae Lars-Peter Clausen 2011-06-13  637  

:::::: The code at line 632 was first introduced by commit
:::::: 631ed8a2134dae17d9e17f3c35c7290720f85199 ASoC: Add ADAU1701 codec driver

:::::: TO: Lars-Peter Clausen <lars@metafoo.de>
:::::: CC: Mark Brown <broonie@opensource.wolfsonmicro.com>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

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

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

* Re: [PATCH] ASoC: snd_soc_dai_set_fmt add substream independence.
  2020-03-28  1:58 [PATCH] ASoC: snd_soc_dai_set_fmt add substream independence Matt Flax
  2020-03-28  3:31 ` kbuild test robot
@ 2020-03-28  3:44 ` kbuild test robot
  2020-03-30 10:32 ` Mark Brown
  2 siblings, 0 replies; 9+ messages in thread
From: kbuild test robot @ 2020-03-28  3:44 UTC (permalink / raw)
  To: kbuild-all

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

Hi Matt,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on v5.6-rc7]
[cannot apply to asoc/for-next next-20200327]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Matt-Flax/ASoC-snd_soc_dai_set_fmt-add-substream-independence/20200328-102100
base:    16fbf79b0f83bc752cee8589279f1ebfe57b3b6e
config: i386-allyesconfig (attached as .config)
compiler: gcc-7 (Debian 7.5.0-5) 7.5.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> sound/soc/sh/fsi.c:1701:13: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     .set_fmt = fsi_dai_set_fmt,
                ^~~~~~~~~~~~~~~
   sound/soc/sh/fsi.c:1701:13: note: (near initialization for 'fsi_dai_ops.set_fmt')
   cc1: some warnings being treated as errors
--
>> sound/soc/sh/rcar/core.c:1051:13: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     .set_fmt = rsnd_soc_dai_set_fmt,
                ^~~~~~~~~~~~~~~~~~~~
   sound/soc/sh/rcar/core.c:1051:13: note: (near initialization for 'rsnd_soc_dai_ops.set_fmt')
   cc1: some warnings being treated as errors
--
>> sound/soc/sirf/sirf-usp.c:267:13: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     .set_fmt = sirf_usp_pcm_set_dai_fmt,
                ^~~~~~~~~~~~~~~~~~~~~~~~
   sound/soc/sirf/sirf-usp.c:267:13: note: (near initialization for 'sirf_usp_pcm_dai_ops.set_fmt')
   cc1: some warnings being treated as errors
--
>> sound/soc/sti/uniperif_player.c:1043:14: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
      .set_fmt = sti_uniperiph_dai_set_fmt,
                 ^~~~~~~~~~~~~~~~~~~~~~~~~
   sound/soc/sti/uniperif_player.c:1043:14: note: (near initialization for 'uni_player_dai_ops.set_fmt')
   cc1: some warnings being treated as errors
--
>> sound/soc/sti/uniperif_reader.c:406:14: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
      .set_fmt = sti_uniperiph_dai_set_fmt,
                 ^~~~~~~~~~~~~~~~~~~~~~~~~
   sound/soc/sti/uniperif_reader.c:406:14: note: (near initialization for 'uni_reader_dai_ops.set_fmt')
   cc1: some warnings being treated as errors
--
>> sound/soc/stm/stm32_sai_sub.c:1227:13: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     .set_fmt = stm32_sai_set_dai_fmt,
                ^~~~~~~~~~~~~~~~~~~~~
   sound/soc/stm/stm32_sai_sub.c:1227:13: note: (near initialization for 'stm32_sai_pcm_dai_ops.set_fmt')
   cc1: some warnings being treated as errors
--
>> sound/soc/stm/stm32_i2s.c:741:13: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     .set_fmt = stm32_i2s_set_dai_fmt,
                ^~~~~~~~~~~~~~~~~~~~~
   sound/soc/stm/stm32_i2s.c:741:13: note: (near initialization for 'stm32_i2s_pcm_dai_ops.set_fmt')
   cc1: some warnings being treated as errors
--
>> sound/soc/sunxi/sun4i-i2s.c:846:13: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     .set_fmt = sun4i_i2s_set_fmt,
                ^~~~~~~~~~~~~~~~~
   sound/soc/sunxi/sun4i-i2s.c:846:13: note: (near initialization for 'sun4i_i2s_dai_ops.set_fmt')
   cc1: some warnings being treated as errors
--
>> sound/soc/sunxi/sun8i-codec.c:489:13: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     .set_fmt = sun8i_set_fmt,
                ^~~~~~~~~~~~~
   sound/soc/sunxi/sun8i-codec.c:489:13: note: (near initialization for 'sun8i_codec_dai_ops.set_fmt')
   cc1: some warnings being treated as errors
--
>> sound/soc/tegra/tegra20_i2s.c:241:13: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     .set_fmt = tegra20_i2s_set_fmt,
                ^~~~~~~~~~~~~~~~~~~
   sound/soc/tegra/tegra20_i2s.c:241:13: note: (near initialization for 'tegra20_i2s_dai_ops.set_fmt')
   cc1: some warnings being treated as errors
--
>> sound/soc/tegra/tegra30_i2s.c:296:13: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     .set_fmt = tegra30_i2s_set_fmt,
                ^~~~~~~~~~~~~~~~~~~
   sound/soc/tegra/tegra30_i2s.c:296:13: note: (near initialization for 'tegra30_i2s_dai_ops.set_fmt')
   cc1: some warnings being treated as errors
..

vim +/snd_soc_dai_set_fmt +1515 sound/soc/soc-core.c

2eea392d0a28a0 Jarkko Nikula      2010-11-25  1457  
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1458  /**
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1459   * snd_soc_runtime_set_dai_fmt() - Change DAI link format for a ASoC runtime
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1460   * @rtd: The runtime for which the DAI link format should be changed
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1461   * @dai_fmt: The new DAI link format
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1462   *
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1463   * This function updates the DAI link format for all DAIs connected to the DAI
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1464   * link for the specified runtime.
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1465   *
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1466   * Note: For setups with a static format set the dai_fmt field in the
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1467   * corresponding snd_dai_link struct instead of using this function.
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1468   *
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1469   * Returns 0 on success, otherwise a negative error code.
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1470   */
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1471  int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1472  	unsigned int dai_fmt)
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1473  {
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1474  	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
0b7990e38971da Kuninori Morimoto  2018-09-03  1475  	struct snd_soc_dai *codec_dai;
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1476  	unsigned int i;
2e8b7dfc808873 Matt Flax          2020-03-28  1477  	int ret, stream;
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1478  
0b7990e38971da Kuninori Morimoto  2018-09-03  1479  	for_each_rtd_codec_dai(rtd, i, codec_dai) {
2e8b7dfc808873 Matt Flax          2020-03-28  1480  		int stream = 0;
2e8b7dfc808873 Matt Flax          2020-03-28  1481  		ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt, stream);
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1482  		if (ret != 0 && ret != -ENOTSUPP) {
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1483  			dev_warn(codec_dai->dev,
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1484  				 "ASoC: Failed to set DAI format: %d\n", ret);
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1485  			return ret;
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1486  		}
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1487  	}
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1488  
2c7b696a7589ab Marcel Ziswiler    2018-10-18  1489  	/*
2c7b696a7589ab Marcel Ziswiler    2018-10-18  1490  	 * Flip the polarity for the "CPU" end of a CODEC<->CODEC link
2c7b696a7589ab Marcel Ziswiler    2018-10-18  1491  	 * the component which has non_legacy_dai_naming is Codec
2c7b696a7589ab Marcel Ziswiler    2018-10-18  1492  	 */
999f7f5af8eb77 Kuninori Morimoto  2018-05-08  1493  	if (cpu_dai->component->driver->non_legacy_dai_naming) {
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1494  		unsigned int inv_dai_fmt;
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1495  
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1496  		inv_dai_fmt = dai_fmt & ~SND_SOC_DAIFMT_MASTER_MASK;
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1497  		switch (dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) {
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1498  		case SND_SOC_DAIFMT_CBM_CFM:
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1499  			inv_dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1500  			break;
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1501  		case SND_SOC_DAIFMT_CBM_CFS:
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1502  			inv_dai_fmt |= SND_SOC_DAIFMT_CBS_CFM;
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1503  			break;
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1504  		case SND_SOC_DAIFMT_CBS_CFM:
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1505  			inv_dai_fmt |= SND_SOC_DAIFMT_CBM_CFS;
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1506  			break;
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1507  		case SND_SOC_DAIFMT_CBS_CFS:
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1508  			inv_dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1509  			break;
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1510  		}
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1511  
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1512  		dai_fmt = inv_dai_fmt;
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1513  	}
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1514  
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06 @1515  	ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt);
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1516  	if (ret != 0 && ret != -ENOTSUPP) {
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1517  		dev_warn(cpu_dai->dev,
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1518  			 "ASoC: Failed to set DAI format: %d\n", ret);
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1519  		return ret;
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1520  	}
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1521  
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1522  	return 0;
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1523  }
ddaca25aa4dade Lars-Peter Clausen 2015-01-08  1524  EXPORT_SYMBOL_GPL(snd_soc_runtime_set_dai_fmt);
ce64c8b9cf5be2 Lars-Peter Clausen 2015-01-06  1525  

:::::: The code at line 1515 was first introduced by commit
:::::: ce64c8b9cf5be2a93508af4667110dbe90904557 ASoC: Add helper function for changing the DAI link format

:::::: TO: Lars-Peter Clausen <lars@metafoo.de>
:::::: CC: Mark Brown <broonie@kernel.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

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

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

* Re: [PATCH] ASoC: snd_soc_dai_set_fmt add substream independence.
  2020-03-28  1:58 [PATCH] ASoC: snd_soc_dai_set_fmt add substream independence Matt Flax
  2020-03-28  3:31 ` kbuild test robot
  2020-03-28  3:44 ` kbuild test robot
@ 2020-03-30 10:32 ` Mark Brown
  2020-03-30 12:28   ` Matt Flax
  2 siblings, 1 reply; 9+ messages in thread
From: Mark Brown @ 2020-03-30 10:32 UTC (permalink / raw)
  To: Matt Flax; +Cc: alsa-devel, lars, lgirdwood, pierre-louis.bossart

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

On Sat, Mar 28, 2020 at 12:58:31PM +1100, Matt Flax wrote:

> This patch is aims to start a stronger discussion on allowing both CPU
> and Codec dais to set formats independently based on direction.

If the DAIs support completely separate formats they're not a single DAI
and should be represented as two DAIs.

> One example of a sound card which requires independent stream formats is
> an isolated sound card, such as the Audio Injector Isolated sound card.
> The magnetic isolation chips on the sound card require stream fomats to
> be different because of digital latency variations on the I2S lines.

Honestly I'm not convinced this is ever going to work reliably - there
is in general an assumption in the code that the formats on both ends of
the link are the same, it seems you'll have to break that as well as
having an asymmetric configuration.  You probably need to represent
these isolators as a CODEC and do a CODEC to CODEC link and even then it
seems worrying.

>  /* Digital Audio interface formatting */
> -int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt);
> +int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt, int stream);

This will break the build.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] ASoC: snd_soc_dai_set_fmt add substream independence.
  2020-03-30 10:32 ` Mark Brown
@ 2020-03-30 12:28   ` Matt Flax
  2020-03-30 16:31     ` Mark Brown
  0 siblings, 1 reply; 9+ messages in thread
From: Matt Flax @ 2020-03-30 12:28 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, lars, lgirdwood, pierre-louis.bossart


On 30/3/20 9:32 pm, Mark Brown wrote:
> On Sat, Mar 28, 2020 at 12:58:31PM +1100, Matt Flax wrote:
>
>> This patch is aims to start a stronger discussion on allowing both CPU
>> and Codec dais to set formats independently based on direction.
> If the DAIs support completely separate formats they're not a single DAI
> and should be represented as two DAIs.


I understand, however having two DAIs produces subdevices and pushes the 
overhead of managing registers to the end user in the form of two sub 
devices.

Is everyone firm on the concept that a DAI's playback and capture stream 
has to have the same format in the same DAI ?

I can see a much better solution (then the one I posted here) which is 
also very simple to solve this problem in the same DAI.


>
>> One example of a sound card which requires independent stream formats is
>> an isolated sound card, such as the Audio Injector Isolated sound card.
>> The magnetic isolation chips on the sound card require stream fomats to
>> be different because of digital latency variations on the I2S lines.
> Honestly I'm not convinced this is ever going to work reliably - there
> is in general an assumption in the code that the formats on both ends of
> the link are the same, it seems you'll have to break that as well as
> having an asymmetric configuration.  You probably need to represent
> these isolators as a CODEC and do a CODEC to CODEC link and even then it
> seems worrying.

I like to think of isolation as innovative, not worrying :)

However w.r.t. the codec to codec link approach, I will take your advice 
and not go down that route.


thanks

Matt


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

* Re: [PATCH] ASoC: snd_soc_dai_set_fmt add substream independence.
  2020-03-30 12:28   ` Matt Flax
@ 2020-03-30 16:31     ` Mark Brown
  2020-03-31  7:40       ` Matt Flax
  0 siblings, 1 reply; 9+ messages in thread
From: Mark Brown @ 2020-03-30 16:31 UTC (permalink / raw)
  To: Matt Flax; +Cc: alsa-devel, lars, lgirdwood, pierre-louis.bossart

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

On Mon, Mar 30, 2020 at 11:28:26PM +1100, Matt Flax wrote:
> On 30/3/20 9:32 pm, Mark Brown wrote:
> > On Sat, Mar 28, 2020 at 12:58:31PM +1100, Matt Flax wrote:

> > > This patch is aims to start a stronger discussion on allowing both CPU
> > > and Codec dais to set formats independently based on direction.

> > If the DAIs support completely separate formats they're not a single DAI
> > and should be represented as two DAIs.

> I understand, however having two DAIs produces subdevices and pushes the
> overhead of managing registers to the end user in the form of two sub
> devices.

I think that's a swings and roundabouts thing where it really depends on
your use case - for example if the DAIs can be organized however people
like then people can come up with creative ways to wire things that
don't pair things in the way that makes sense for userspace.  Ideally
we'd be able to match up any playback only stream with any capture only
stream which would help a much wider range of systems.

> Is everyone firm on the concept that a DAI's playback and capture stream has
> to have the same format in the same DAI ?

> I can see a much better solution (then the one I posted here) which is also
> very simple to solve this problem in the same DAI.

It does push a requirement for dealing with asymmetric setups including
validation that nobody did anything that can't be supported onto all
users to at least some extent, even if standard stuff were factored out
into the core (which didn't happen yet).  This is for a *very* unusual
requiremenet.

> > having an asymmetric configuration.  You probably need to represent
> > these isolators as a CODEC and do a CODEC to CODEC link and even then it
> > seems worrying.

> I like to think of isolation as innovative, not worrying :)

> However w.r.t. the codec to codec link approach, I will take your advice and
> not go down that route.

No, my advice is to go down that route if you are doing this.  I'm just
not convinced that it's going to work reliably since this all sounds
rather shaky.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] ASoC: snd_soc_dai_set_fmt add substream independence.
  2020-03-30 16:31     ` Mark Brown
@ 2020-03-31  7:40       ` Matt Flax
  2020-03-31 11:13         ` Mark Brown
  0 siblings, 1 reply; 9+ messages in thread
From: Matt Flax @ 2020-03-31  7:40 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, lars, lgirdwood, pierre-louis.bossart


On 31/3/20 3:31 am, Mark Brown wrote:
> On Mon, Mar 30, 2020 at 11:28:26PM +1100, Matt Flax wrote:
>> On 30/3/20 9:32 pm, Mark Brown wrote:
>>> On Sat, Mar 28, 2020 at 12:58:31PM +1100, Matt Flax wrote:
>>>> This patch is aims to start a stronger discussion on allowing both CPU
>>>> and Codec dais to set formats independently based on direction.
>>> If the DAIs support completely separate formats they're not a single DAI
>>> and should be represented as two DAIs.
>> I understand, however having two DAIs produces subdevices and pushes the
>> overhead of managing registers to the end user in the form of two sub
>> devices.
> I think that's a swings and roundabouts thing where it really depends on
> your use case - for example if the DAIs can be organized however people
> like then people can come up with creative ways to wire things that
> don't pair things in the way that makes sense for userspace.  Ideally
> we'd be able to match up any playback only stream with any capture only
> stream which would help a much wider range of systems.
>
>> Is everyone firm on the concept that a DAI's playback and capture stream has
>> to have the same format in the same DAI ?
> It does push a requirement for dealing with asymmetric setups including
> validation that nobody did anything that can't be supported onto all
> users to at least some extent, even if standard stuff were factored out
> into the core (which didn't happen yet).  This is for a *very* unusual
> requiremenet.


ok, I don't quite follow you, but I think what you are saying is that 
there is a trade off between simplifying things for the end user and 
core complexity leading to developer sloppiness ?

I believe you are saying that it is a rare case to require format 
asymmetry in the same DAI link. For that reason introducing extra 
functionality into the core may not be worth while ?


>>> having an asymmetric configuration.  You probably need to represent
>>> these isolators as a CODEC and do a CODEC to CODEC link and even then it
>>> seems worrying.
>> I like to think of isolation as innovative, not worrying :)
>> However w.r.t. the codec to codec link approach, I will take your advice and
>> not go down that route.
> No, my advice is to go down that route if you are doing this.  I'm just
> not convinced that it's going to work reliably since this all sounds
> rather shaky.

OK - I can try to go down that route. However I would like to confirm 
that having a codec to codec link doesn't require the original codec or 
CPU drivers to have separate DAIs for playback and capture ? In my case 
both the CPU and Codec drivers have single DAIs for both streams.

For example, my virtual codec DAI would have symmetric formats with the 
original CPU and asymmetric formats with the target codec. However the 
target codec only has one DAI defined, and thus I can't understand how 
to setup the virtual codec DAI to have an asymmetric link with the 
actual single codec DAI !


Matt


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

* Re: [PATCH] ASoC: snd_soc_dai_set_fmt add substream independence.
  2020-03-31  7:40       ` Matt Flax
@ 2020-03-31 11:13         ` Mark Brown
  2020-03-31 11:52           ` Matt Flax
  0 siblings, 1 reply; 9+ messages in thread
From: Mark Brown @ 2020-03-31 11:13 UTC (permalink / raw)
  To: Matt Flax; +Cc: alsa-devel, lars, lgirdwood, pierre-louis.bossart

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

On Tue, Mar 31, 2020 at 06:40:26PM +1100, Matt Flax wrote:

> ok, I don't quite follow you, but I think what you are saying is that there
> is a trade off between simplifying things for the end user and core
> complexity leading to developer sloppiness ?

> I believe you are saying that it is a rare case to require format asymmetry
> in the same DAI link. For that reason introducing extra functionality into
> the core may not be worth while ?

What I am saying is that we already have a perfectly good way of
representing separate TX and RX DAIs which is far more flexible than
your bodge and that if there is something to be improved on the
userspace interface we should improve that rather than add this which
seems like a bodge.

> > No, my advice is to go down that route if you are doing this.  I'm just
> > not convinced that it's going to work reliably since this all sounds
> > rather shaky.

> OK - I can try to go down that route. However I would like to confirm that
> having a codec to codec link doesn't require the original codec or CPU
> drivers to have separate DAIs for playback and capture ? In my case both the
> CPU and Codec drivers have single DAIs for both streams.

OK, that probably won't help then :/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] ASoC: snd_soc_dai_set_fmt add substream independence.
  2020-03-31 11:13         ` Mark Brown
@ 2020-03-31 11:52           ` Matt Flax
  0 siblings, 0 replies; 9+ messages in thread
From: Matt Flax @ 2020-03-31 11:52 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, lars, lgirdwood, pierre-louis.bossart


On 31/3/20 10:13 pm, Mark Brown wrote:
> On Tue, Mar 31, 2020 at 06:40:26PM +1100, Matt Flax wrote:

>>> No, my advice is to go down that route if you are doing this.  I'm just
>>> not convinced that it's going to work reliably since this all sounds
>>> rather shaky.
>> OK - I can try to go down that route. However I would like to confirm that
>> having a codec to codec link doesn't require the original codec or CPU
>> drivers to have separate DAIs for playback and capture ? In my case both the
>> CPU and Codec drivers have single DAIs for both streams.
> OK, that probably won't help then :/


OK - well, the codec approach was worth a try. My concerns with the 
codec API is that it chews resources and clock cycles - if it is 
possible to work around it, then it is a good idea.

I feel that the best way to reduce resource consumption, complexity and 
overhead is to allow link formats to be defined based on the stream 
direction.

I can see why we would want different DAIs if the sample rate is 
asymmetric, however for word alignment perhaps we should let the stream 
direction seep into the snd_soc_dai opertions. These days CPU and Codec 
designers seem to treat both streams independently, which is why their 
registers can be independently configured.


thanks for the discussion

Matt


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

end of thread, other threads:[~2020-03-31 11:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-28  1:58 [PATCH] ASoC: snd_soc_dai_set_fmt add substream independence Matt Flax
2020-03-28  3:31 ` kbuild test robot
2020-03-28  3:44 ` kbuild test robot
2020-03-30 10:32 ` Mark Brown
2020-03-30 12:28   ` Matt Flax
2020-03-30 16:31     ` Mark Brown
2020-03-31  7:40       ` Matt Flax
2020-03-31 11:13         ` Mark Brown
2020-03-31 11:52           ` Matt Flax

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.