From: Matt Flax <flatmax@flatmax.org>
To: alsa-devel@alsa-project.org,
Stephen Warren <swarren@wwwdotorg.org>,
Lee Jones <lee@kernel.org>, Eric Anholt <eric@anholt.net>,
linux-rpi-kernel@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
Florian Meier <florian.meier@koalo.de>,
broonie@kernel.org, phil@raspberrypi.org
Cc: Matt Flax <flatmax@flatmax.org>
Subject: [PATCH v1] ASoC: bcm2835: Remove redundant channel checking code in hw_params
Date: Wed, 1 Feb 2017 15:45:03 +1100 [thread overview]
Message-ID: <1485924303-30869-1-git-send-email-flatmax@flatmax.org> (raw)
In-Reply-To: <1484443043-13623-1-git-send-email-flatmax@flatmax.org>
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.
Signed-off-by: Matt Flax <flatmax@flatmax.org>
---
sound/soc/bcm/bcm2835-i2s.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/sound/soc/bcm/bcm2835-i2s.c b/sound/soc/bcm/bcm2835-i2s.c
index 6ba2049..1773b83 100644
--- a/sound/soc/bcm/bcm2835-i2s.c
+++ b/sound/soc/bcm/bcm2835-i2s.c
@@ -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.
--
2.7.4
next prev parent reply other threads:[~2017-02-01 4:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-15 1:17 [PATCH] ASoC: bcm2835: Remove redundant channel checking code in hw_params Matt Flax
2017-01-20 5:58 ` Matt Flax
2017-02-01 4:45 ` Matt Flax [this message]
2017-02-01 10:53 ` [PATCH v1] " Mark Brown
2017-02-01 11:05 ` Matt Flax
2017-02-01 11:14 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1485924303-30869-1-git-send-email-flatmax@flatmax.org \
--to=flatmax@flatmax.org \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=eric@anholt.net \
--cc=florian.meier@koalo.de \
--cc=lee@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=phil@raspberrypi.org \
--cc=swarren@wwwdotorg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).