ASoC: bcm2835: Remove redundant channel checking code in hw_params
Subsystems (4)
PATCH 1/1 ASoC: bcm2835: Remove redundant channel checking code in hw_params
Due to channels_max and channels_min in the bcm2835_i2s_dai structure, the channel guard code in bcm2835_i2s_hw_params is redundant.
The bcm2835_i2s_hw_params function checks that the channel count is 2 before continuing. This code never gets executed because core soc checks prevent the execution (upon channel mismatch) of the bcm2835_i2s_hw_params function.
The redundancy has been tested and checked for the case when the bcm2835_i2s_dai structure has channels_max = 2 and a request for 8 channels has been made. The test has confirmed that the removed code is redundant as it never gets executed when a channel mismatch occurs.
This redundant channel count check may seem like it will not cause any problems however some sound cards (such as the 8 channel AudioInjector Octo sound card) require the execution of the bcm2835_i2s_hw_params function when channels_max in the bcm2835_i2s_dai structure has been increased to 8.
As the channel checking code in bcm2835_i2s_hw_params is redundant and stops certain cards from working it has been removed.
--- sound/soc/bcm/bcm2835-i2s.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
sound/soc/bcm/bcm2835-i2s.c +3 -9
@@ -310,15 +310,9 @@ static int bcm2835_i2s_hw_params(struct snd_pcm_substream *substream, ch1pos = data_delay; ch2pos = bclk_ratio /2 + data_delay; -switch (params_channels (params)) { -case 2 : - format =BCM2835_I2S_CH1 (format) |BCM2835_I2S_CH2 (format); - format |=BCM2835_I2S_CH1 (BCM2835_I2S_CHPOS (ch1pos)); - format |=BCM2835_I2S_CH2 (BCM2835_I2S_CHPOS (ch2pos)); -break ; -default : -return -EINVAL ; - } + format =BCM2835_I2S_CH1 (format) |BCM2835_I2S_CH2 (format); + format |=BCM2835_I2S_CH1 (BCM2835_I2S_CHPOS (ch1pos)); + format |=BCM2835_I2S_CH2 (BCM2835_I2S_CHPOS (ch2pos));/* * Set format for both streams.
Signature · 1 line
2.7.4
This hasn't had any airplay since posting 5 days ago.
Can anyone advise on the correct person to contact regarding the review of this patch ?
thanks
Matt
Quoted 51 lines · Matt Flax
Due to
channels_maxandchannels_minin thebcm2835_i2s_daistructure, the channel guard code inbcm2835_i2s_hw_paramsis redundant.The
bcm2835_i2s_hw_paramsfunction checks that the channel count is 2 before continuing. This code never gets executed because core soc checks prevent the execution (upon channel mismatch) of thebcm2835_i2s_hw_paramsfunction.The redundancy has been tested and checked for the case when the
bcm2835_i2s_daistructure haschannels_max= 2 and a request for 8 channels has been made. The test has confirmed that the removed code is redundant as it never gets executed when a channel mismatch occurs.This redundant channel count check may seem like it will not cause any problems however some sound cards (such as the 8 channel AudioInjector Octo sound card) require the execution of the
bcm2835_i2s_hw_paramsfunction whenchannels_maxin thebcm2835_i2s_daistructure has been increased to 8.As the channel checking code in
bcm2835_i2s_hw_paramsis redundant and stops certain cards from working it has been removed.Signed-off-by Matt Flax <[email protected]>--- sound/soc/bcm/bcm2835-i2s.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)sound/soc/bcm/bcm2835-i2s.c +3
-9@@ -310,15 +310,9 @@ static int bcm2835_i2s_hw_params(struct snd_pcm_substream *substream, ch1pos = data_delay; ch2pos = bclk_ratio /2 + data_delay; -switch (params_channels (params)) { -case 2 : - format =BCM2835_I2S_CH1 (format) |BCM2835_I2S_CH2 (format); - format |=BCM2835_I2S_CH1 (BCM2835_I2S_CHPOS (ch1pos)); - format |=BCM2835_I2S_CH2 (BCM2835_I2S_CHPOS (ch2pos)); -break ; -default : -return -EINVAL ; - } + format =BCM2835_I2S_CH1 (format) |BCM2835_I2S_CH2 (format); + format |=BCM2835_I2S_CH1 (BCM2835_I2S_CHPOS (ch1pos)); + format |=BCM2835_I2S_CH2 (BCM2835_I2S_CHPOS (ch2pos));/* * Set format for both streams.
PATCH 1/1 ASoC: bcm2835: Remove redundant channel checking code in hw_params
In reply to Matt FlaxDue to channels_max and channels_min in the bcm2835_i2s_dai structure, the channel guard code in bcm2835_i2s_hw_params is redundant.
The bcm2835_i2s_hw_params function checks that the channel count is 2 before continuing. This code never gets executed because core soc checks prevent the execution (upon channel mismatch) of the bcm2835_i2s_hw_params function.
The redundancy has been tested and checked for the case when the bcm2835_i2s_dai structure has channels_max = 2 and a request for 8 channels has been made. The test has confirmed that the removed code is redundant as it never gets executed when a channel mismatch occurs.
This redundant channel count check may seem like it will not cause any problems however some sound cards (such as the 8 channel AudioInjector Octo sound card) require the execution of the bcm2835_i2s_hw_params function when channels_max in the bcm2835_i2s_dai structure has been increased to 8.
As the channel checking code in bcm2835_i2s_hw_params is redundant and stops certain cards from working it has been removed.
--- sound/soc/bcm/bcm2835-i2s.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
sound/soc/bcm/bcm2835-i2s.c +3 -9
@@ -310,15 +310,9 @@ static int bcm2835_i2s_hw_params(struct snd_pcm_substream *substream, ch1pos = data_delay; ch2pos = bclk_ratio /2 + data_delay; -switch (params_channels (params)) { -case 2 : - format =BCM2835_I2S_CH1 (format) |BCM2835_I2S_CH2 (format); - format |=BCM2835_I2S_CH1 (BCM2835_I2S_CHPOS (ch1pos)); - format |=BCM2835_I2S_CH2 (BCM2835_I2S_CHPOS (ch2pos)); -break ; -default : -return -EINVAL ; - } + format =BCM2835_I2S_CH1 (format) |BCM2835_I2S_CH2 (format); + format |=BCM2835_I2S_CH1 (BCM2835_I2S_CHPOS (ch1pos)); + format |=BCM2835_I2S_CH2 (BCM2835_I2S_CHPOS (ch2pos));/* * Set format for both streams.
Signature · 1 line
2.7.4
Mark Brown
maintainerQuoted 8 lines · Matt Flax
This redundant channel count check may seem like it will not cause any problems however some sound cards (such as the 8 channel AudioInjector Octo sound card) require the execution of the
bcm2835_i2s_hw_paramsfunction whenchannels_maxin thebcm2835_i2s_daistructure has been increased to 8.As the channel checking code in
bcm2835_i2s_hw_paramsis redundant and stops certain cards from working it has been removed.
If those cards add support for higher channel counts they should be
adding real support for that in the driver, not just hacking out
defensive code. If the device can usefully do 8 channels then modify
the driver to do 8 channels. Otherwise people are going to need to
modify the driver anyway to remove the limits in the constraints.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170201/69b6d45f/attachment.sig>
Quoted 9 lines · Mark Brown
Quoted 7 lines · Matt Flax
This redundant channel count check may seem like it will not cause any problems however some sound cards (such as the 8 channel AudioInjector Octo sound card) require the execution of the
bcm2835_i2s_hw_paramsfunction whenchannels_maxin thebcm2835_i2s_daistructure has been increased to 8.
As the channel checking code inbcm2835_i2s_hw_paramsis redundant and stops certain cards from working it has been removed.
Quoted 6 lines
If those cards add support for higher channel counts they should be adding real support for that in the driver, not just hacking out defensive code. If the device can usefully do 8 channels then modify the driver to do 8 channels. Otherwise people are going to need to modify the driver anyway to remove the limits in the constraints.
Indeed the AudioInjector Octo sound card is currently operating @ 8 channels out on the bcm2835 silicon. It has been tested on both the Pi 2 and Pi 3.
Do you mean that I should increase bcm2835_i2s_dai.channels_max to 8 ?
I can do this. Does anyone have any objections to this approach ?
thanks
Matt
Quoted 5 lines
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Mark Brown
maintainerQuoted 8 lines · Matt Flax
Quoted 5 lines · Mark Brown
If those cards add support for higher channel counts they should be adding real support for that in the driver, not just hacking out defensive code. If the device can usefully do 8 channels then modify the driver to do 8 channels. Otherwise people are going to need to modify the driver anyway to remove the limits in the constraints.
Quoted 4 lines
Indeed the AudioInjector Octo sound card is currently operating @ 8 channels out on the bcm2835 silicon. It has been tested on both the Pi 2 and Pi 3.
Do you mean that I should increase bcm2835_i2s_dai.channels_max to 8 ?
Yes, implementing it properly is fine.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170201/2603fd0d/attachment.sig>