ASoC: soc-pcm: Use format size instead physical for sample_bits symmetry
PATCH 1/1 ASoC: soc-pcm: Use format size instead physical for sample_bits symmetry
For DAIs the format size in bits matters when it comes to symmetry. The physical width is the in-memory format size which matters mostly for the platform drivers.
If for example a DAI requests symmetric_samplebits and the first stream is using S24_LE then the second stream would not be allowed to use S24_3LE despite both S24_LE and S24_3LE would need the same clocking on the bus. But S32_LE would be allowed (S24_LE and S32_LE is both physically 32 bits in memory) which would not be compatible with S24_LE on the bus.
--- sound/soc/soc-pcm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
sound/soc/soc-pcm.c +3 -4
@@ -243,7 +243,7 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream, rate =params_rate (params); channels =params_channels (params); - sample_bits =snd_pcm_format_physical_width (params_format (params)); + sample_bits =snd_pcm_format_width (params_format (params));/* reject unmatched parameters when applying symmetry */ symmetry = cpu_dai->driver->symmetric_rates ||
@@ -932,7 +932,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, codec_dai->rate =params_rate (&codec_params); codec_dai->channels =params_channels (&codec_params); - codec_dai->sample_bits =snd_pcm_format_physical_width ( + codec_dai->sample_bits =snd_pcm_format_width (params_format (&codec_params));snd_soc_dapm_update_dai (substream, &codec_params, codec_dai);
@@ -945,8 +945,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,/* store the parameters for each DAIs */ cpu_dai->rate =params_rate (params); cpu_dai->channels =params_channels (params); - cpu_dai->sample_bits = -snd_pcm_format_physical_width (params_format (params)); + cpu_dai->sample_bits =snd_pcm_format_width (params_format (params));snd_soc_dapm_update_dai (substream, params, cpu_dai);
Signature · 4 lines
Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Quoted 9 lines · Peter Ujfalusi
For DAIs the format size in bits matters when it comes to symmetry. The physical width is the in-memory format size which matters mostly for the platform drivers.
If for example a DAI requests
symmetric_samplebitsand the first stream is usingS24_LEthen the second stream would not be allowed to useS24_3LEdespite bothS24_LEandS24_3LEwould need the same clocking on the bus. ButS32_LEwould be allowed (S24_LEandS32_LEis both physically 32 bits in memory) which would not be compatible withS24_LEon the bus.
Well, this is not correct either as the
snd_pcm_hw_constraint_single(substream->runtime,
SNDRV_PCM_HW_PARAM_SAMPLE_BITS, soc_dai->sample_bits);
applies to physical width.
After S24_LE stream with this patch only S24_3LE is allowed opposed to S24_LE/S32_LE without it.
I don't see how this can be done correctly.
S24_LE should impose constraint S24_LE | S24_3LE and not allow S32_LE. In theory any format with less than 24bits could be allowed with slot_width = 24, but this might go too far.
- Péter
Quoted 30 lines
Signed-off-by Peter Ujfalusi <[email protected]>--- sound/soc/soc-pcm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)sound/soc/soc-pcm.c +2
-2@@ -243,7 +243,7 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream, rate =params_rate (params); channels =params_channels (params); - sample_bits =snd_pcm_format_physical_width (params_format (params)); + sample_bits =snd_pcm_format_width (params_format (params));/* reject unmatched parameters when applying symmetry */ symmetry = cpu_dai->driver->symmetric_rates ||@@ -932,7 +932,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, codec_dai->rate =params_rate (&codec_params); codec_dai->channels =params_channels (&codec_params); - codec_dai->sample_bits =snd_pcm_format_physical_width ( + codec_dai->sample_bits =snd_pcm_format_width (params_format (&codec_params));snd_soc_dapm_update_dai (substream, &codec_params, codec_dai);
sound/soc/soc-pcm.c static int soc_pcm_hw_params(struct snd_pcm_substream *substream, · line 951
Quoted 9 lines
sound/soc/soc-pcm.c +1
-2@@ -945,8 +945,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,/* store the parameters for each DAIs */ cpu_dai->rate =params_rate (params); cpu_dai->channels =params_channels (params); - cpu_dai->sample_bits = -snd_pcm_format_physical_width (params_format (params)); + cpu_dai->sample_bits =snd_pcm_format_width (params_format (params));snd_soc_dapm_update_dai (substream, params, cpu_dai);
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel