ASoC: snd_soc_dai_set_fmt add substream independence.
PATCH 1/1 ASoC: snd_soc_dai_set_fmt add substream independence.
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.
--- 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(-)
include/sound/soc-dai.h +2 -2
@@ -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,
sound/soc/soc-core.c +3 -2
@@ -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);
sound/soc/soc-dai.c +2 -2
@@ -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);
Signature · 1 line
2.20.1
kbuild test robot
build botThank you for the patch! Yet something to improve:
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
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 <[email protected]> :::::: CC: Mark Brown <[email protected]>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kbuild test robot
build botThank you for the patch! Yet something to improve:
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
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 <[email protected]>
:::::: CC: Mark Brown <[email protected]>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Mark Brown
maintainerQuoted 2 lines · 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.
If the DAIs support completely separate formats they're not a single DAI and should be represented as two DAIs.
Quoted 4 lines
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.
include/sound/soc-dai.h int snd_soc_dai_set_pll(struct snd_soc_dai *dai, · line 126
Quoted 3 lines
/* Digital Audio interface formatting */
include/sound/soc-dai.h +1
-1-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.
Quoted 6 lines · Mark Brown
Quoted 2 lines · 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.
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.
Quoted 11 lines
Quoted 5 lines
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
Mark Brown
maintainerQuoted 6 lines · Matt Flax
Quoted 4 lines · Mark Brown
Quoted 2 lines · 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.
Quoted 6 lines
Quoted 2 lines
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.
Quoted 5 lines
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.
Quoted 8 lines
Quoted 3 lines
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.
Quoted 17 lines · Mark Brown
Quoted 9 lines · Matt Flax
Quoted 5 lines · Mark Brown
Quoted 2 lines · 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.
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.
Quoted 7 lines
Quoted 2 lines
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 ?
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
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
Mark Brown
maintainerQuoted 7 lines · Matt Flax
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.
Quoted 8 lines
Quoted 3 lines
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 :/
Quoted 10 lines · Mark Brown
Quoted 7 lines · Matt Flax
Quoted 3 lines
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