ASoC: soc-pcm: add soc_pcm_hw_update_chan()
We have soc_pcm_hw_update_rate() now. This patch creates same function for chan. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Link: https://lore.kernel.org/r/87r1lw90oo.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
f6c04af5dc
commit
6cb56a4549
|
@ -478,6 +478,8 @@ static void soc_pcm_hw_init(struct snd_pcm_hardware *hw)
|
||||||
hw->rates = UINT_MAX;
|
hw->rates = UINT_MAX;
|
||||||
hw->rate_min = 0;
|
hw->rate_min = 0;
|
||||||
hw->rate_max = UINT_MAX;
|
hw->rate_max = UINT_MAX;
|
||||||
|
hw->channels_min = 0;
|
||||||
|
hw->channels_max = UINT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void soc_pcm_hw_update_rate(struct snd_pcm_hardware *hw,
|
static void soc_pcm_hw_update_rate(struct snd_pcm_hardware *hw,
|
||||||
|
@ -493,6 +495,13 @@ static void soc_pcm_hw_update_rate(struct snd_pcm_hardware *hw,
|
||||||
hw->rate_max = min_not_zero(hw->rate_max, p->rate_max);
|
hw->rate_max = min_not_zero(hw->rate_max, p->rate_max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void soc_pcm_hw_update_chan(struct snd_pcm_hardware *hw,
|
||||||
|
struct snd_soc_pcm_stream *p)
|
||||||
|
{
|
||||||
|
hw->channels_min = max(hw->channels_min, p->channels_min);
|
||||||
|
hw->channels_max = min(hw->channels_max, p->channels_max);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* snd_soc_runtime_calc_hw() - Calculate hw limits for a PCM stream
|
* snd_soc_runtime_calc_hw() - Calculate hw limits for a PCM stream
|
||||||
* @rtd: ASoC PCM runtime
|
* @rtd: ASoC PCM runtime
|
||||||
|
@ -509,7 +518,6 @@ int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd,
|
||||||
struct snd_soc_dai *cpu_dai;
|
struct snd_soc_dai *cpu_dai;
|
||||||
struct snd_soc_pcm_stream *codec_stream;
|
struct snd_soc_pcm_stream *codec_stream;
|
||||||
struct snd_soc_pcm_stream *cpu_stream;
|
struct snd_soc_pcm_stream *cpu_stream;
|
||||||
unsigned int chan_min = 0, chan_max = UINT_MAX;
|
|
||||||
unsigned int cpu_chan_min = 0, cpu_chan_max = UINT_MAX;
|
unsigned int cpu_chan_min = 0, cpu_chan_max = UINT_MAX;
|
||||||
u64 formats = ULLONG_MAX;
|
u64 formats = ULLONG_MAX;
|
||||||
int i;
|
int i;
|
||||||
|
@ -530,11 +538,12 @@ int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd,
|
||||||
|
|
||||||
cpu_stream = snd_soc_dai_get_pcm_stream(cpu_dai, stream);
|
cpu_stream = snd_soc_dai_get_pcm_stream(cpu_dai, stream);
|
||||||
|
|
||||||
cpu_chan_min = max(cpu_chan_min, cpu_stream->channels_min);
|
soc_pcm_hw_update_chan(hw, cpu_stream);
|
||||||
cpu_chan_max = min(cpu_chan_max, cpu_stream->channels_max);
|
|
||||||
soc_pcm_hw_update_rate(hw, cpu_stream);
|
soc_pcm_hw_update_rate(hw, cpu_stream);
|
||||||
formats &= cpu_stream->formats;
|
formats &= cpu_stream->formats;
|
||||||
}
|
}
|
||||||
|
cpu_chan_min = hw->channels_min;
|
||||||
|
cpu_chan_max = hw->channels_max;
|
||||||
|
|
||||||
/* second calculate min/max only for CODECs in the DAI link */
|
/* second calculate min/max only for CODECs in the DAI link */
|
||||||
for_each_rtd_codec_dais(rtd, i, codec_dai) {
|
for_each_rtd_codec_dais(rtd, i, codec_dai) {
|
||||||
|
@ -550,14 +559,13 @@ int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd,
|
||||||
|
|
||||||
codec_stream = snd_soc_dai_get_pcm_stream(codec_dai, stream);
|
codec_stream = snd_soc_dai_get_pcm_stream(codec_dai, stream);
|
||||||
|
|
||||||
chan_min = max(chan_min, codec_stream->channels_min);
|
soc_pcm_hw_update_chan(hw, codec_stream);
|
||||||
chan_max = min(chan_max, codec_stream->channels_max);
|
|
||||||
soc_pcm_hw_update_rate(hw, codec_stream);
|
soc_pcm_hw_update_rate(hw, codec_stream);
|
||||||
formats &= codec_stream->formats;
|
formats &= codec_stream->formats;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Verify both a valid CPU DAI and a valid CODEC DAI were found */
|
/* Verify both a valid CPU DAI and a valid CODEC DAI were found */
|
||||||
if (!chan_min || !cpu_chan_min)
|
if (!hw->channels_min)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -566,13 +574,11 @@ int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd,
|
||||||
* channel allocation be fixed up later
|
* channel allocation be fixed up later
|
||||||
*/
|
*/
|
||||||
if (rtd->num_codecs > 1) {
|
if (rtd->num_codecs > 1) {
|
||||||
chan_min = cpu_chan_min;
|
hw->channels_min = cpu_chan_min;
|
||||||
chan_max = cpu_chan_max;
|
hw->channels_max = cpu_chan_max;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* finally find a intersection between CODECs and CPUs */
|
/* 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);
|
|
||||||
hw->formats = formats;
|
hw->formats = formats;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1523,8 +1529,7 @@ static void dpcm_init_runtime_hw(struct snd_pcm_runtime *runtime,
|
||||||
struct snd_pcm_hardware *hw = &runtime->hw;
|
struct snd_pcm_hardware *hw = &runtime->hw;
|
||||||
|
|
||||||
soc_pcm_hw_update_rate(hw, stream);
|
soc_pcm_hw_update_rate(hw, stream);
|
||||||
runtime->hw.channels_min = stream->channels_min;
|
soc_pcm_hw_update_chan(hw, stream);
|
||||||
runtime->hw.channels_max = stream->channels_max;
|
|
||||||
if (runtime->hw.formats)
|
if (runtime->hw.formats)
|
||||||
runtime->hw.formats &= stream->formats;
|
runtime->hw.formats &= stream->formats;
|
||||||
else
|
else
|
||||||
|
@ -1601,10 +1606,7 @@ static void dpcm_runtime_merge_chan(struct snd_pcm_substream *substream,
|
||||||
|
|
||||||
cpu_stream = snd_soc_dai_get_pcm_stream(dai, stream);
|
cpu_stream = snd_soc_dai_get_pcm_stream(dai, stream);
|
||||||
|
|
||||||
hw->channels_min = max(hw->channels_min,
|
soc_pcm_hw_update_chan(hw, cpu_stream);
|
||||||
cpu_stream->channels_min);
|
|
||||||
hw->channels_max = min(hw->channels_max,
|
|
||||||
cpu_stream->channels_max);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1614,10 +1616,7 @@ static void dpcm_runtime_merge_chan(struct snd_pcm_substream *substream,
|
||||||
if (be->num_codecs == 1) {
|
if (be->num_codecs == 1) {
|
||||||
codec_stream = snd_soc_dai_get_pcm_stream(asoc_rtd_to_codec(be, 0), stream);
|
codec_stream = snd_soc_dai_get_pcm_stream(asoc_rtd_to_codec(be, 0), stream);
|
||||||
|
|
||||||
hw->channels_min = max(hw->channels_min,
|
soc_pcm_hw_update_chan(hw, codec_stream);
|
||||||
codec_stream->channels_min);
|
|
||||||
hw->channels_max = min(hw->channels_max,
|
|
||||||
codec_stream->channels_max);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue