Skip to content

Commit 2bae7be

Browse files
bijudasbroonie
authored andcommitted
ASoC: renesas: rz-ssi: Fix rz_ssi_priv::hw_params_cache::sample_width
The strm->sample_width is not filled during rz_ssi_dai_hw_params(). This wrong value is used for caching sample_width in struct hw_params_cache. Fix this issue by replacing 'strm->sample_width'->'params_width(params)' in rz_ssi_dai_hw_params(). After this drop the variable sample_width from struct rz_ssi_stream as it is unused. Cc: stable@kernel.org Fixes: 4f8cd05 ("ASoC: sh: rz-ssi: Add full duplex support") Reviewed-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Link: https://patch.msgid.link/20251114073709.4376-3-biju.das.jz@bp.renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 52a5250 commit 2bae7be

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

sound/soc/renesas/rz-ssi.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/module.h>
1414
#include <linux/pm_runtime.h>
1515
#include <linux/reset.h>
16+
#include <sound/pcm_params.h>
1617
#include <sound/soc.h>
1718

1819
/* REGISTER OFFSET */
@@ -87,7 +88,6 @@ struct rz_ssi_stream {
8788
int dma_buffer_pos; /* The address for the next DMA descriptor */
8889
int completed_dma_buf_pos; /* The address of the last completed DMA descriptor. */
8990
int period_counter; /* for keeping track of periods transferred */
90-
int sample_width;
9191
int buffer_pos; /* current frame position in the buffer */
9292
int running; /* 0=stopped, 1=running */
9393

@@ -217,10 +217,7 @@ static inline bool rz_ssi_is_stream_running(struct rz_ssi_stream *strm)
217217
static void rz_ssi_stream_init(struct rz_ssi_stream *strm,
218218
struct snd_pcm_substream *substream)
219219
{
220-
struct snd_pcm_runtime *runtime = substream->runtime;
221-
222220
rz_ssi_set_substream(strm, substream);
223-
strm->sample_width = samples_to_bytes(runtime, 1);
224221
strm->dma_buffer_pos = 0;
225222
strm->completed_dma_buf_pos = 0;
226223
strm->period_counter = 0;
@@ -978,9 +975,9 @@ static int rz_ssi_dai_hw_params(struct snd_pcm_substream *substream,
978975
struct snd_soc_dai *dai)
979976
{
980977
struct rz_ssi_priv *ssi = snd_soc_dai_get_drvdata(dai);
981-
struct rz_ssi_stream *strm = rz_ssi_stream_get(ssi, substream);
982978
unsigned int sample_bits = hw_param_interval(params,
983979
SNDRV_PCM_HW_PARAM_SAMPLE_BITS)->min;
980+
unsigned int sample_width = params_width(params);
984981
unsigned int channels = params_channels(params);
985982
unsigned int rate = params_rate(params);
986983
int ret;
@@ -999,16 +996,14 @@ static int rz_ssi_dai_hw_params(struct snd_pcm_substream *substream,
999996

1000997
if (rz_ssi_is_stream_running(&ssi->playback) ||
1001998
rz_ssi_is_stream_running(&ssi->capture)) {
1002-
if (rz_ssi_is_valid_hw_params(ssi, rate, channels,
1003-
strm->sample_width, sample_bits))
999+
if (rz_ssi_is_valid_hw_params(ssi, rate, channels, sample_width, sample_bits))
10041000
return 0;
10051001

10061002
dev_err(ssi->dev, "Full duplex needs same HW params\n");
10071003
return -EINVAL;
10081004
}
10091005

1010-
rz_ssi_cache_hw_params(ssi, rate, channels, strm->sample_width,
1011-
sample_bits);
1006+
rz_ssi_cache_hw_params(ssi, rate, channels, sample_width, sample_bits);
10121007

10131008
ret = rz_ssi_swreset(ssi);
10141009
if (ret)

0 commit comments

Comments
 (0)