alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Samuel Holland <samuel@sholland.org>
Cc: alsa-devel@alsa-project.org, Mark Brown <broonie@kernel.org>
Subject: Applied "ASoC: pcm: Export parameter intersection logic" to the asoc tree
Date: Fri, 06 Mar 2020 15:03:37 +0000	[thread overview]
Message-ID: 
Message-ID: <20200306150337.sEh3EwEx8OIsz-uMv9AG-xukqYoJqdU_6Ry3FLYqyxM@z> (raw)
In-Reply-To: 

The patch

   ASoC: pcm: Export parameter intersection logic

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From 5854a46486ad5b8d73766735fb0d77f05956b22c Mon Sep 17 00:00:00 2001
From: Samuel Holland <samuel@sholland.org>
Date: Wed, 4 Mar 2020 23:11:42 -0600
Subject: [PATCH] ASoC: pcm: Export parameter intersection logic

The logic to calculate the subset of stream parameters supported by all
DAIs associated with a PCM stream is nontrivial. Export a helper
function so it can be used to set up simple codec2codec DAI links.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/r/20200305051143.60691-3-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 include/sound/soc.h |  3 +++
 sound/soc/soc-pcm.c | 56 ++++++++++++++++++++++++++++++---------------
 2 files changed, 41 insertions(+), 18 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 81e5d17be935..9543d9246ca4 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -471,6 +471,9 @@ bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd);
 void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd, int stream);
 void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, int stream);
 
+int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd,
+			    struct snd_pcm_hardware *hw, int stream);
+
 int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
 	unsigned int dai_fmt);
 
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index e3a2c4f7757b..de4226357e2b 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -587,11 +587,18 @@ static void soc_pcm_apply_msb(struct snd_pcm_substream *substream)
 	soc_pcm_set_msb(substream, cpu_bits);
 }
 
-static void soc_pcm_init_runtime_hw(struct snd_pcm_substream *substream)
+/**
+ * snd_soc_runtime_calc_hw() - Calculate hw limits for a PCM stream
+ * @rtd: ASoC PCM runtime
+ * @hw: PCM hardware parameters (output)
+ * @stream: Direction of the PCM stream
+ *
+ * Calculates the subset of stream parameters supported by all DAIs
+ * associated with the PCM stream.
+ */
+int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd,
+			    struct snd_pcm_hardware *hw, int stream)
 {
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct snd_pcm_hardware *hw = &runtime->hw;
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_dai *codec_dai;
 	struct snd_soc_dai *cpu_dai;
 	struct snd_soc_pcm_stream *codec_stream;
@@ -602,7 +609,6 @@ static void soc_pcm_init_runtime_hw(struct snd_pcm_substream *substream)
 	unsigned int cpu_rate_min = 0, cpu_rate_max = UINT_MAX;
 	unsigned int rates = UINT_MAX, cpu_rates = UINT_MAX;
 	u64 formats = ULLONG_MAX;
-	int stream = substream->stream;
 	int i;
 
 	/* first calculate min/max only for CPUs in the DAI link */
@@ -613,12 +619,8 @@ static void soc_pcm_init_runtime_hw(struct snd_pcm_substream *substream)
 		 * Otherwise, since the rate, channel, and format values will
 		 * zero in that case, we would have no usable settings left,
 		 * causing the resulting setup to fail.
-		 * At least one CPU should match, otherwise we should have
-		 * bailed out on a higher level, since there would be no
-		 * CPU to support the transfer direction in that case.
 		 */
-		if (!snd_soc_dai_stream_valid(cpu_dai,
-					      substream->stream))
+		if (!snd_soc_dai_stream_valid(cpu_dai, stream))
 			continue;
 
 		cpu_stream = snd_soc_dai_get_pcm_stream(cpu_dai, stream);
@@ -640,9 +642,6 @@ static void soc_pcm_init_runtime_hw(struct snd_pcm_substream *substream)
 		 * Otherwise, since the rate, channel, and format values will
 		 * zero in that case, we would have no usable settings left,
 		 * causing the resulting setup to fail.
-		 * At least one CODEC should match, otherwise we should have
-		 * bailed out on a higher level, since there would be no
-		 * CODEC to support the transfer direction in that case.
 		 */
 		if (!snd_soc_dai_stream_valid(codec_dai, stream))
 			continue;
@@ -657,6 +656,10 @@ static void soc_pcm_init_runtime_hw(struct snd_pcm_substream *substream)
 		rates = snd_pcm_rate_mask_intersect(codec_stream->rates, rates);
 	}
 
+	/* Verify both a valid CPU DAI and a valid CODEC DAI were found */
+	if (!chan_min || !cpu_chan_min)
+		return -EINVAL;
+
 	/*
 	 * chan min/max cannot be enforced if there are multiple CODEC DAIs
 	 * connected to CPU DAI(s), use CPU DAI's directly and let
@@ -670,18 +673,35 @@ static void soc_pcm_init_runtime_hw(struct snd_pcm_substream *substream)
 	/* finally find a intersection between CODECs and CPUs */
 	hw->channels_min = max(chan_min, cpu_chan_min);
 	hw->channels_max = min(chan_max, cpu_chan_max);
-	if (hw->formats)
-		hw->formats &= formats;
-	else
-		hw->formats = formats;
+	hw->formats = formats;
 	hw->rates = snd_pcm_rate_mask_intersect(rates, cpu_rates);
 
-	snd_pcm_limit_hw_rates(runtime);
+	snd_pcm_hw_limit_rates(hw);
 
 	hw->rate_min = max(hw->rate_min, cpu_rate_min);
 	hw->rate_min = max(hw->rate_min, rate_min);
 	hw->rate_max = min_not_zero(hw->rate_max, cpu_rate_max);
 	hw->rate_max = min_not_zero(hw->rate_max, rate_max);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_runtime_calc_hw);
+
+static void soc_pcm_init_runtime_hw(struct snd_pcm_substream *substream)
+{
+	struct snd_pcm_hardware *hw = &substream->runtime->hw;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	u64 formats = hw->formats;
+
+	/*
+	 * At least one CPU and one CODEC should match. Otherwise, we should
+	 * have bailed out on a higher level, since there would be no CPU or
+	 * CODEC to support the transfer direction in that case.
+	 */
+	snd_soc_runtime_calc_hw(rtd, hw, substream->stream);
+
+	if (formats)
+		hw->formats &= formats;
 }
 
 static int soc_pcm_components_open(struct snd_pcm_substream *substream)
-- 
2.20.1


             reply	other threads:[~2020-03-06 15:09 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-06 15:03 Applied "ASoC: pcm: Export parameter intersection logic" to the asoc tree Mark Brown
  -- strict thread matches above, loose matches on Subject: below --
2020-04-14 14:48 Applied "ASoC: soc: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer" " Mark Brown
2020-04-14 14:48 Applied "ASoC: soc-core: set rtd->num_cpu/codec at soc_new_pcm_runtime()" " Mark Brown
2020-04-14 14:48 Applied "ASoC: soc-core: tidyup soc_new_pcm_runtime() rtd setups" " Mark Brown
2020-04-14 14:48 Applied "ASoC: soc-core: remove cpu_dai/codec_dai/cpu_dais/codec_dais" " Mark Brown
2020-04-14 14:46 Applied "ASoC: rockchip-spdif: add #sound-dai-cells property" " Mark Brown
2020-04-14 14:46 Applied "ASoC: rockchip-spdif: add power-domains " Mark Brown
2020-04-14 14:46 Applied "ASoC: wsa881x: mark read_only_wordlength flag" " Mark Brown
2020-04-14 11:59 Applied "ASoC: tas571x: disable regulators on failed probe" " Mark Brown
2020-03-27 15:34 Applied "ASoC: SOF: Intel: add SoundWire configuration interface" " Mark Brown
2020-03-27 15:34 Applied "ASoC: SOF: IPC: dai-intel: move ALH declarations in header file" " Mark Brown
2020-03-27 15:34 Applied "ASoC: SOF: Intel: hda: add SoundWire stream config/free callbacks" " Mark Brown
2020-03-27 15:33 Applied "ASoC: SOF: Intel: hda: disable SoundWire interrupts on suspend" " Mark Brown
2020-03-27 15:33 Applied "ASoC: SOF: Intel: hda: merge IPC, stream and SoundWire interrupt handlers" " Mark Brown
2020-03-27 15:33 Applied "ASoC: SOF: Intel: hda: add parameter to control SoundWire clock stop quirks" " Mark Brown
2020-03-27 15:33 Applied "ASoC: SOF: Intel: hda: add WAKEEN interrupt support for SoundWire" " Mark Brown
2020-03-27 15:33 Applied "Asoc: SOF: Intel: hda: check SoundWire wakeen interrupt in irq thread" " Mark Brown
2020-03-26 19:05 Applied "ASoC: SOF: (cosmetic) use for_each_pcm_streams() in sof_dai_load()" " Mark Brown
2020-03-26 19:05 Applied "ASoC: SOF: fix uninitialised "work" with VirtIO" " Mark Brown
2020-03-25 21:33 Applied "ASoC: Intel: broadwell: Revert back SSP0 link to use dummy components" " Mark Brown
2020-03-24 17:16 Applied "dt-bindings: sound: convert rockchip i2s bindings to yaml" " Mark Brown
2020-03-24 17:16 Applied "dt-bindings: sound: rockchip-i2s: add #sound-dai-cells property" " Mark Brown
2020-03-20 20:45 Applied "ASoC: soc-core: Merge CPU/Codec DAIs" " Mark Brown
2020-03-20 20:45 Applied "ASoC: soc-core: Merge for_each_rtd_cpu/codec_dais()" " Mark Brown
2020-03-20 20:45 Applied "ASoC: soc-dapm: " Mark Brown
2020-03-20 20:45 Applied "ASoC: soc-core: Merge CPU/Codec for soc_dai_pcm_new()" " Mark Brown
2020-03-18 21:41 Applied "ASoC: codecs: wsa881x: remove soundwire stream handling" " Mark Brown
2020-03-16 18:08 Applied "ALSA: compress: add wma codec profiles" " Mark Brown
2020-03-16 18:08 Applied "ALSA: compress: Add wma decoder params" " Mark Brown
2020-03-16 18:08 Applied "ASoC: qcom: q6asm: pass codec profile to q6asm_open_write" " Mark Brown
2020-03-16 18:08 Applied "ASoC: qcom: q6asm: add support to wma config" " Mark Brown
2020-03-16 18:08 Applied "ASoC: qcom: q6asm-dai: add support to wma decoder" " Mark Brown
2020-03-16 18:08 Applied "ALSA: compress: add alac & ape decoder params" " Mark Brown
2020-03-16 18:08 Applied "ASoC: qcom: q6asm: add support for alac and ape configs" " Mark Brown
2020-03-16 18:07 Applied "ALSA: compress: bump the version" " Mark Brown
2020-03-13 16:18 Applied "ASoC: Intel: boards: drop reverse deps for SND_HDA_CODEC_HDMI" " Mark Brown
2020-03-13 16:17 Applied "ASoC: Intel: sof_pcm512x: " Mark Brown
2020-03-13 16:17 Applied "ASoC: Intel: sof_pcm512x: make HDMI optional for all platforms" " Mark Brown
2020-03-13 16:17 Applied "ASoC: SOF: Intel: hda: remove SND_SOC_SOF_HDA_COMMON_HDMI_CODEC" " Mark Brown
2020-03-13 16:17 Applied "ASoC: codecs: hdac_hdmi: (cosmetic) remove redundant variable initialisations" " Mark Brown
2020-03-13 16:17 Applied "ASoC: Intel: skylake: " Mark Brown
2020-03-13 16:17 Applied "ASoC: Intel: (cosmetic) simplify structure member access" " Mark Brown
2020-03-13 16:17 Applied "ASoC: Intel: sof_da7219_max98373: Add support for max98360a speaker amp" " Mark Brown
2020-03-12 13:12 Applied "ASoC: SOF: Intel: Fix stream cleanup on hw free" " Mark Brown
2020-03-11 18:00 Applied "ASoC: zte: zx-tdm: remove redundant variables dev" " Mark Brown
2020-03-09 14:03 Applied "ASoC: jz4740-i2s: Fix divider written at incorrect offset in register" " Mark Brown
2020-03-06 15:03 Applied "ALSA: pcm: Add a standalone version of snd_pcm_limit_hw_rates" " Mark Brown
2020-03-06 15:03 Applied "ASoC: soc-pcm: move dpcm_fe_dai_close()" " Mark Brown
2020-03-06 15:03 Applied "ASoC: soc-pcm: add dpcm_fe_dai_cleanup()" " Mark Brown
2020-03-06 15:03 Applied "ASoC: soc-pcm: use snd_soc_dai_get_pcm_stream() at dpcm_set_fe_runtime()" " Mark Brown
2020-03-06 15:03 Applied "ASoC: soc-pcm: tidyup dulicate handing at dpcm_fe_dai_startup()" " Mark Brown
2020-03-05 13:15 Applied "ASoC: soc-pcm: use defined stream" " Mark Brown
2020-03-05 13:15 Applied "ASoC: soc-pcm: remove duplicate be check from dpcm_add_paths()" " Mark Brown
2020-03-04 13:39 Applied "ASoC: stm32: sai: manage rebind issue" " Mark Brown
2020-03-03 17:07 Applied "ASoC: amd: Fix compile warning of argument type" " Mark Brown
2020-03-02 14:36 Applied "ASoC: rt1015: set snd_soc_dai_ops in rt1015_dai driver" " Mark Brown
2020-02-26 18:48 Applied "ASoC: tas2562: Fix sample rate error message" " Mark Brown
2020-02-26 18:47 Applied "ASoC: Add dapm_add_valid_dai_widget helper" " Mark Brown
2020-02-26 18:47 Applied "ASoC: Add multiple CPU DAI support in DAPM" " Mark Brown
2020-02-26 18:47 Applied "ASoC: dt-bindings: Add TAS2563 compatible to the TAS2562 binding" " Mark Brown
2020-02-26 18:47 Applied "ASoC: tas2562: Add entries for the TAS2563 audio amplifier" " Mark Brown
2020-02-20 22:18 Applied "dt-bindings: sound: Add TLV320ADCx140 dt bindings" " Mark Brown
2020-02-19 20:57 Applied "ASoC: soundwaire: qcom: use for_each_rtd_codec_dai() macro" " Mark Brown
2020-02-19 20:57 Applied "ASoC: qcom: sdm845: " Mark Brown
2020-02-19 20:57 Applied "ASoC: qcom: apq8016_sbc: " Mark Brown
2020-02-19 20:57 Applied "ASoC: intel: cml_rt1011_rt5682: " Mark Brown
2020-02-19 20:57 Applied "ASoC: intel: kbl_da7219_max98927: " Mark Brown
2020-02-19 20:57 Applied "ASoC: mediatek: mt8183-da7219-max98357: " Mark Brown
2020-02-19 20:57 Applied "ASoC: dt-bindings: Make RK3328 codec GPIO explicit" " Mark Brown
2020-02-19 20:56 Applied "ASoC: meson: add t9015 internal codec binding documentation" " Mark Brown
2020-02-19  0:11 Applied "ASoC: tas2562: Return invalid for when bitwidth is invalid" " Mark Brown
2020-02-19  0:11 Applied "ALSA: core: Expand DMA buffer information" " Mark Brown
2020-02-19  0:11 Applied "ALSA: core: Implement compress page allocation and free routines" " Mark Brown
2020-02-19  0:10 Applied "ASoC: SOF: Implement Probe IPC API" " Mark Brown
2020-02-19  0:10 Applied "ASoC: SOF: Generic probe compress operations" " Mark Brown
2020-02-19  0:10 Applied "ASoC: SOF: Provide probe debugfs support" " Mark Brown
2020-02-19  0:10 Applied "ASoC: SOF: Intel: Add Probe compress CPU DAIs" " Mark Brown
2020-02-19  0:10 Applied "ASoC: rt5682: Add DAI clock binding info for WCLK/BCLK CCF usage" " Mark Brown
2020-02-19  0:10 Applied "ASoC: soc-pcm: move dai_get_widget()" " Mark Brown
2020-02-19  0:10 Applied "ASoC: soc-pcm: use dai_get_widget() at dpcm_get_be()" " Mark Brown
2020-02-19  0:10 Applied "ASoC: soc-pcm: use dai_get_widget() at dpcm_end_walk_at_be()" " Mark Brown
2020-02-19  0:10 Applied "ASoC: soc-pcm: use dpcm_get_be() " Mark Brown
2020-02-19  0:10 Applied "ASoC: soc-pcm: remove soc_dpcm_be_digital_mute()" " Mark Brown
2020-02-19  0:09 Applied "ASoC: soc-pcm: remove snd_soc_dpcm_be_get/set_state()" " Mark Brown
2020-02-19  0:09 Applied "ASoC: soc-pcm: add snd_soc_dpcm_can_be() and remove duplicate code" " Mark Brown
2020-02-19  0:09 Applied "ASoC: soc-pcm: use goto and remove multi return" " Mark Brown
2020-02-19  0:09 Applied "ASoC: soc-pcm: merge playback/cature_active into stream_active" " Mark Brown
2020-02-19  0:09 Applied "ALSA: pcm.h: add for_each_pcm_streams()" " Mark Brown
2020-02-19  0:09 Applied "ASoC: soc-core: use for_each_pcm_streams() macro" " Mark Brown
2020-02-19  0:09 Applied "ASoC: soc-pcm: " Mark Brown
2020-02-19  0:09 Applied "ASoC: soc-generic-dmaengine-pcm: " Mark Brown
2020-02-19  0:09 Applied "ASoC: dwc: dwc-i2s: " Mark Brown
2020-02-19  0:09 Applied "ASoC: fsl: fsl_asrc_dma: " Mark Brown
2020-02-19  0:09 Applied "ASoC: qcom: lpass-platform: " Mark Brown
2020-02-19  0:09 Applied "ASoC: sof: sof-audio: " Mark Brown
2020-02-19  0:09 Applied "ALSA: usx2y: " Mark Brown
2020-02-13 13:32 [alsa-devel] Applied "ASoC: mediatek: mt8183-da7219: change supported formats of DL2 and UL1" " Mark Brown
2020-02-13 13:32 [alsa-devel] Applied "ASoC: mediatek: mt8183-da7219: pull TDM GPIO pins down when probed" " Mark Brown
2020-02-13 13:32 [alsa-devel] Applied "ASoC: mediatek: mt8183-da7219: support TDM out and 8ch I2S out" " Mark Brown
2020-02-13 13:32 [alsa-devel] Applied "ASoC: mediatek: mt8183-da7219: apply some refactors" " Mark Brown
2020-01-15 14:12 [alsa-devel] Applied "regulator fix for "regulator: core: Add regulator_is_equal() helper"" " Mark Brown
2020-01-13 16:11 [alsa-devel] Applied "ASoC: atmel: fix build error with CONFIG_SND_ATMEL_SOC_DMA=m" " Mark Brown
2020-01-13 16:11 [alsa-devel] Applied "ASoC: rt1308-sdw: add rt1308 SdW amplifier driver" " Mark Brown
2020-01-13 15:13 [alsa-devel] Applied "ASoC: SOF: Intel: fix HDA codec driver probe with multiple controllers" " Mark Brown
2020-01-13 15:13 [alsa-devel] Applied "ASoC: sti: fix possible sleep-in-atomic" " Mark Brown
2020-01-10 13:38 [alsa-devel] Applied "ASoC: max98090: Drop incorrectly applied duplicate commit" " Mark Brown
2019-12-27  1:08 [alsa-devel] Applied "ASoC: amd: Create multiple I2S platform device endpoint" " Mark Brown
2019-12-25 18:21 [alsa-devel] Applied "ASoC: dt-bindings: add dt bindings for WCD9340/WCD9341 audio codec" " Mark Brown
2019-12-25 18:21 [alsa-devel] Applied "ASoC: wcd934x: add basic controls" " Mark Brown
2019-12-25 18:21 [alsa-devel] Applied "ASoC: wcd934x: add playback dapm widgets" " Mark Brown
2019-12-25 18:21 [alsa-devel] Applied "ASoC: wcd934x: add capture " Mark Brown
2019-12-25 18:21 [alsa-devel] Applied "ASoC: wcd934x: add audio routings" " Mark Brown
2019-12-25 18:21 [alsa-devel] Applied "ASoC: qcom: dt-bindings: Add compatible for DB845c and Lenovo Yoga" " Mark Brown
2019-12-25 18:21 [alsa-devel] Applied "ASoC: qcom: sdm845: add support to " Mark Brown
2019-12-25  0:09 [alsa-devel] Applied "ASoC: fsl_audmix: add missed pm_runtime_disable" " Mark Brown
2019-11-18 17:48 [alsa-devel] Applied "ASoC: SOF: Intel: Fix build break" " Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to= \
    --to=broonie@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=samuel@sholland.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).