Skip to content

Commit 6ada9f1

Browse files
committed
ASoC: soc-pcm: Use conditional PCM hardware parameter initialization
Component drivers can prepare snd_pcm_hardware struct based on the hardware capabilities which information should not be discarded. Only touch the rates, channels_max and formats if they were left to 0, otherwise keep the provided configuration intact for the parameter cross checking decision. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent 30fdccc commit 6ada9f1

1 file changed

Lines changed: 26 additions & 13 deletions

File tree

sound/soc/soc-pcm.c

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -570,14 +570,31 @@ static void soc_pcm_apply_msb(struct snd_pcm_substream *substream)
570570
soc_pcm_set_msb(substream, cpu_bits);
571571
}
572572

573-
static void soc_pcm_hw_init(struct snd_pcm_hardware *hw)
573+
static void soc_pcm_hw_init(struct snd_pcm_hardware *hw, bool preserve_config)
574574
{
575-
hw->rates = UINT_MAX;
576-
hw->rate_min = 0;
577-
hw->rate_max = UINT_MAX;
578-
hw->channels_min = 0;
579-
hw->channels_max = UINT_MAX;
580-
hw->formats = ULLONG_MAX;
575+
if (preserve_config) {
576+
/*
577+
* preserve the configuration which might be done by components
578+
* Note: if the rates/rate_max/channels_max/formats are left to
579+
* 0 we still need to initialize them for the parameter updates
580+
* to work
581+
*/
582+
if (!hw->rates)
583+
hw->rates = UINT_MAX;
584+
if (!hw->rate_max)
585+
hw->rate_max = UINT_MAX;
586+
if (!hw->channels_max)
587+
hw->channels_max = UINT_MAX;
588+
if (!hw->formats)
589+
hw->formats = ULLONG_MAX;
590+
} else {
591+
hw->rates = UINT_MAX;
592+
hw->rate_min = 0;
593+
hw->rate_max = UINT_MAX;
594+
hw->channels_min = 0;
595+
hw->channels_max = UINT_MAX;
596+
hw->formats = ULLONG_MAX;
597+
}
581598
}
582599

583600
static void soc_pcm_hw_update_rate(struct snd_pcm_hardware *hw,
@@ -626,7 +643,7 @@ int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd,
626643
unsigned int cpu_chan_min = 0, cpu_chan_max = UINT_MAX;
627644
int i;
628645

629-
soc_pcm_hw_init(hw);
646+
soc_pcm_hw_init(hw, false);
630647

631648
/* first calculate min/max only for CPUs in the DAI link */
632649
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
@@ -1738,13 +1755,9 @@ static void dpcm_runtime_setup_fe(struct snd_pcm_substream *substream)
17381755
struct snd_pcm_hardware *hw = &runtime->hw;
17391756
struct snd_soc_dai *dai;
17401757
int stream = substream->stream;
1741-
u64 formats = hw->formats;
17421758
int i;
17431759

1744-
soc_pcm_hw_init(hw);
1745-
1746-
if (formats)
1747-
hw->formats &= formats;
1760+
soc_pcm_hw_init(hw, true);
17481761

17491762
for_each_rtd_cpu_dais(fe, i, dai) {
17501763
const struct snd_soc_pcm_stream *cpu_stream;

0 commit comments

Comments
 (0)