ASoC: tlv320aic3x: Correct S24_3LE support
Subsystems (3)
PATCH 1/1 ASoC: tlv320aic3x: Correct S24_3LE support
Correct the hw_params callback to configure the codec correctly in case of S24_3LE format.
--- sound/soc/codecs/tlv320aic3x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/tlv320aic3x.c +1 -1
@@ -879,7 +879,7 @@ static int aic3x_hw_params(struct snd_pcm_substream *substream,case SNDRV_PCM_FORMAT_S20_3LE : data |= (0x01 <<4 );break ; -case SNDRV_PCM_FORMAT_S24_LE : +case SNDRV_PCM_FORMAT_S24_3LE : data |= (0x02 <<4 );break ;case SNDRV_PCM_FORMAT_S32_LE :
Signature · 1 line
1.8.5.1
Mark Brown
maintainersound/soc/codecs/tlv320aic3x.c static int aic3x_hw_params(struct snd_pcm_substream *substream, · line 884
Quoted 4 lines · Peter Ujfalusi
sound/soc/codecs/tlv320aic3x.c +1
-1-case SNDRV_PCM_FORMAT_S24_LE : +case SNDRV_PCM_FORMAT_S24_3LE : data |= (0x02 <<4 );break ;
This should be adding the case for the new format rather than replacing the old one shouldn't it? They ought to turn out the same on the AIF so the CODECs shouldn't care about the difference, ideally the core would hide the difference from them.
Quoted 11 lines · Mark Brown
sound/soc/codecs/tlv320aic3x.c static int aic3x_hw_params(struct snd_pcm_substream *substream, · line 884
Quoted 4 lines · Peter Ujfalusi
sound/soc/codecs/tlv320aic3x.c +1
-1-case SNDRV_PCM_FORMAT_S24_LE : +case SNDRV_PCM_FORMAT_S24_3LE : data |= (0x02 <<4 );break ;This should be adding the case for the new format rather than replacing the old one shouldn't it? They ought to turn out the same on the AIF so the CODECs shouldn't care about the difference, ideally the core would hide the difference from them.
Not really since the codec has only field to specify the data format. The codec can not support S24_LE (S24_LE is basically S32_LE msbits==24) since we can not say to the codec to ignore the 8bit over the 24 bits of real data. In case of S24_3LE the I2S bus will have 24 clocks/per channel which can not be used to stream S24_LE either.
Signature · 1 line
Péter
Mark Brown
maintainerQuoted 7 lines · Peter Ujfalusi
Quoted 4 lines · Mark Brown
This should be adding the case for the new format rather than replacing the old one shouldn't it? They ought to turn out the same on the AIF so the CODECs shouldn't care about the difference, ideally the core would hide the difference from them.
Quoted 5 lines
Not really since the codec has only field to specify the data format. The codec can not support
S24_LE(S24_LEis basicallyS32_LEmsbits==24) since we can not say to the codec to ignore the 8bit over the 24 bits of real data. In case ofS24_3LEthe I2S bus will have 24 clocks/per channel which can not be used to streamS24_LEeither.
No, I'd expect the wire behaviour to be identical for any 24 bit samples (that's certainly what most drivers are written for). The memory layout differences shouldn't be visible to CODEC drivers.
Like I say we ought to be handling this stuff in the core :/
At Fri, 13 Dec 2013 13:34:44 +0000,
Quoted 15 lines · Mark Brown
Quoted 7 lines · Peter Ujfalusi
Quoted 4 lines · Mark Brown
This should be adding the case for the new format rather than replacing the old one shouldn't it? They ought to turn out the same on the AIF so the CODECs shouldn't care about the difference, ideally the core would hide the difference from them.
Quoted 5 lines
Not really since the codec has only field to specify the data format. The codec can not support
S24_LE(S24_LEis basicallyS32_LEmsbits==24) since we can not say to the codec to ignore the 8bit over the 24 bits of real data. In case ofS24_3LEthe I2S bus will have 24 clocks/per channel which can not be used to streamS24_LEeither.
Quoted 5 lines
No, I'd expect the wire behaviour to be identical for any 24 bit samples (that's certainly what most drivers are written for). The memory layout differences shouldn't be visible to CODEC drivers.
Like I say we ought to be handling this stuff in the core :/
But this codec driver declares the available formats as:
#define AIC3X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE)
so the fix for inconsistency is needed anyway.
Takashi
Mark Brown
maintainerQuoted 6 lines · Takashi Iwai
Quoted 3 lines · Mark Brown
No, I'd expect the wire behaviour to be identical for any 24 bit samples (that's certainly what most drivers are written for). The memory layout differences shouldn't be visible to CODEC drivers.
Quoted 8 lines
Quoted 1 line
Like I say we ought to be handling this stuff in the core :/
But this codec driver declares the available formats as:
#define AIC3X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE)so the fix for inconsistency is needed anyway.
Ah, indeed - and that one should go to stable. The changelog ought to be more accurate though.
Quoted 14 lines · Mark Brown
Quoted 7 lines · Peter Ujfalusi
Quoted 4 lines · Mark Brown
This should be adding the case for the new format rather than replacing the old one shouldn't it? They ought to turn out the same on the AIF so the CODECs shouldn't care about the difference, ideally the core would hide the difference from them.
Quoted 5 lines
Not really since the codec has only field to specify the data format. The codec can not support
S24_LE(S24_LEis basicallyS32_LEmsbits==24) since we can not say to the codec to ignore the 8bit over the 24 bits of real data. In case ofS24_3LEthe I2S bus will have 24 clocks/per channel which can not be used to streamS24_LEeither.
Quoted 3 lines
No, I'd expect the wire behaviour to be identical for any 24 bit samples (that's certainly what most drivers are written for). The memory layout differences shouldn't be visible to CODEC drivers.
We can not change the HW... for example:
twl4030/twl5030: 32 clock cycle/channel and 24 bits used out of that.
tlv320aic3106: 24 clock cycle/channel for 24 bit audio.
The wire behavior is different and this need to be known by the CPU side as well.
Signature · 1 line
Péter
Mark Brown
maintainerQuoted 7 lines · Peter Ujfalusi
Quoted 3 lines · Mark Brown
No, I'd expect the wire behaviour to be identical for any 24 bit samples (that's certainly what most drivers are written for). The memory layout differences shouldn't be visible to CODEC drivers.
We can not change the HW... for example:
This isn't a hardware issue, this is a software issue.
Quoted 1 line
twl4030/twl5030: 32 clock cycle/channel and 24 bits used out of that.
These shouldn't be advertising themselves as supporting 24 bit format for ASoC then since they need 32 bit samples on the bus - this is actually pretty standard for things that say they support 32 bits, they usually just discard some of the lower bits but can cope with 32 bit on the interface.
The reason everything says 24_LE right now is that we're being dumb about how we do the constraints and CPUs do care about the memory layout, not because the CODECs require the blank cycles. Of course this means that almost anything that does I2S should be able to advertise arbatrary sample size support which is one of the resons we ought to be doing stuff in the core to make this nicer.
Quoted 1 line
tlv320aic3106: 24 clock cycle/channel for 24 bit audio.
This is normal ASoC behaviour.
Quoted 1 line
The wire behavior is different and this need to be known by the CPU side as well.
This isn't the way to do it, though - if the TWL drivers were ever used with other CPUs (admittedly unlikely) they'd run into trouble.
Quoted 19 lines · Mark Brown
Quoted 7 lines · Peter Ujfalusi
Quoted 3 lines · Mark Brown
No, I'd expect the wire behaviour to be identical for any 24 bit samples (that's certainly what most drivers are written for). The memory layout differences shouldn't be visible to CODEC drivers.
We can not change the HW... for example:
This isn't a hardware issue, this is a software issue.
Quoted 1 line
twl4030/twl5030: 32 clock cycle/channel and 24 bits used out of that.
These shouldn't be advertising themselves as supporting 24 bit format for ASoC then since they need 32 bit samples on the bus - this is actually pretty standard for things that say they support 32 bits, they usually just discard some of the lower bits but can cope with 32 bit on the interface.
Quoted 6 lines
The reason everything says 24_LE right now is that we're being dumb about how we do the constraints and CPUs do care about the memory layout, not because the CODECs require the blank cycles. Of course this means that almost anything that does I2S should be able to advertise arbatrary sample size support which is one of the resons we ought to be doing stuff in the core to make this nicer.
Hrm, not sure about other SoCs but on OMAP most of the formats from memory ends up on the I2S bus without any bits added/removed so the format actually applies to the codec side as well since the data arriving to the codec will have the same layout as it had in the memory.
But, yes some level of logic in the core might help.
Quoted 8 lines
Quoted 1 line
tlv320aic3106: 24 clock cycle/channel for 24 bit audio.
This is normal ASoC behaviour.
Quoted 1 line
The wire behavior is different and this need to be known by the CPU side as well.
This isn't the way to do it, though - if the TWL drivers were ever used with other CPUs (admittedly unlikely) they'd run into trouble.
The twl drivers (and the dac33) is doing the correct thing IMHO: reporting S32_LE with set .sig_bits = 24. Just to let the user space know that thay should not use the whole 32bit range.
Signature · 1 line
Péter
Mark Brown
maintainerQuoted 5 lines · Peter Ujfalusi
Hrm, not sure about other SoCs but on OMAP most of the formats from memory ends up on the I2S bus without any bits added/removed so the format actually applies to the codec side as well since the data arriving to the codec will have the same layout as it had in the memory.
But, yes some level of logic in the core might help.
For every other CPU or CODEC where I know what it does the number of bits expected on the bus is the sample size.
Quoted 6 lines
Quoted 2 lines
This isn't the way to do it, though - if the TWL drivers were ever used with other CPUs (admittedly unlikely) they'd run into trouble.
The twl drivers (and the dac33) is doing the correct thing IMHO: reporting
S32_LEwith set .sig_bits = 24. Just to let the user space know that thay should not use the whole 32bit range.
Ah, OK - that's good and correct. Your mail made me think they were using one of the S24 formats.
Quoted 13 lines · Peter Ujfalusi
Quoted 11 lines · Mark Brown
sound/soc/codecs/tlv320aic3x.c static int aic3x_hw_params(struct snd_pcm_substream *substream, · line 884
Quoted 4 lines · Peter Ujfalusi
sound/soc/codecs/tlv320aic3x.c +1
-1-case SNDRV_PCM_FORMAT_S24_LE : +case SNDRV_PCM_FORMAT_S24_3LE : data |= (0x02 <<4 );break ;This should be adding the case for the new format rather than replacing the old one shouldn't it? They ought to turn out the same on the AIF so the CODECs shouldn't care about the difference, ideally the core would hide the difference from them.
Quoted 2 lines
Not really since the codec has only field to specify the data format. The codec can not support
S24_LE(S24_LEis basicallyS32_LEmsbits==24) since we
S24_LE is a 24 bit sample in a 32 bit word, but it is right aligned, so there are 8 bits of leading padding, while with S32_LE msbits=24 you'd have 8bits of trailing padding.
Quoted 4 lines
can not say to the codec to ignore the 8bit over the 24 bits of real data. In case of
S24_3LEthe I2S bus will have 24 clocks/per channel which can not be used to streamS24_LEeither.
Normally you'd expect the I2S core to only put the 24 bits of data onto the bus for both S24_3LE and S24_LE (it might add necessary trailing padding if the bit clocks per frame is > 24). A CODEC driver should really not have to care about the in memory layout of the data since all it will see is a serialized bit stream. I think ideally we wouldn't check for params_format() but rather for snd_pcm_format_width(params_format()).
- Lars
Mark Brown
maintainerQuoted 6 lines · Lars-Peter Clausen
Normally you'd expect the I2S core to only put the 24 bits of data onto the bus for both
S24_3LEandS24_LE(it might add necessary trailing padding if the bit clocks per frame is > 24). A CODEC driver should really not have to care about the in memory layout of the data since all it will see is a serialized bit stream. I think ideally we wouldn't check forparams_format()but rather for snd_pcm_format_width(params_format()).
Yes, that would be a much better approach. In fact, let me go attack that...