Skip to content

Commit 21ff8a2

Browse files
morimotoDinh Nguyen
authored andcommitted
ASoC: rsnd: make sure SSI parent/child uses same number of sound channel.
SSI parent/child need to use same number of sound data channel if these are sharing clock/ws pin. this patch makes it sure. Signed-off-by: Kuninori Morimoto <[email protected]> Signed-off-by: Mark Brown <[email protected]> (cherry picked from commit 919567d) Signed-off-by: Simon Horman <[email protected]>
1 parent c5e8ef7 commit 21ff8a2

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

sound/soc/sh/rcar/ssi.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ struct rsnd_ssi {
6666

6767
u32 cr_own;
6868
u32 cr_clk;
69+
int chan;
6970
int err;
7071
unsigned int usrcnt;
7172
};
@@ -264,6 +265,8 @@ static void rsnd_ssi_hw_stop(struct rsnd_ssi *ssi)
264265
}
265266

266267
rsnd_mod_hw_stop(&ssi->mod);
268+
269+
ssi->chan = 0;
267270
}
268271

269272
dev_dbg(dev, "%s[%d] hw stopped\n",
@@ -340,6 +343,35 @@ static int rsnd_ssi_quit(struct rsnd_mod *mod,
340343
return 0;
341344
}
342345

346+
static int rsnd_ssi_hw_params(struct rsnd_mod *mod,
347+
struct snd_pcm_substream *substream,
348+
struct snd_pcm_hw_params *params)
349+
{
350+
struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
351+
struct rsnd_ssi *ssi_parent = rsnd_ssi_parent(ssi);
352+
int chan = params_channels(params);
353+
354+
/*
355+
* Already working.
356+
* It will happen if SSI has parent/child connection.
357+
*/
358+
if (ssi->usrcnt) {
359+
/*
360+
* it is error if child <-> parent SSI uses
361+
* different channels.
362+
*/
363+
if (ssi->chan != chan)
364+
return -EIO;
365+
}
366+
367+
/* It will be removed on rsnd_ssi_hw_stop */
368+
ssi->chan = chan;
369+
if (ssi_parent)
370+
return rsnd_ssi_hw_params(&ssi_parent->mod, substream, params);
371+
372+
return 0;
373+
}
374+
343375
static void rsnd_ssi_record_error(struct rsnd_ssi *ssi, u32 status)
344376
{
345377
/* under/over flow error */
@@ -460,6 +492,7 @@ static struct rsnd_mod_ops rsnd_ssi_pio_ops = {
460492
.quit = rsnd_ssi_quit,
461493
.start = rsnd_ssi_start,
462494
.stop = rsnd_ssi_stop,
495+
.hw_params = rsnd_ssi_hw_params,
463496
};
464497

465498
static int rsnd_ssi_dma_probe(struct rsnd_mod *mod,
@@ -569,6 +602,7 @@ static struct rsnd_mod_ops rsnd_ssi_dma_ops = {
569602
.start = rsnd_ssi_dma_start,
570603
.stop = rsnd_ssi_dma_stop,
571604
.fallback = rsnd_ssi_fallback,
605+
.hw_params = rsnd_ssi_hw_params,
572606
};
573607

574608
int rsnd_ssi_is_dma_mode(struct rsnd_mod *mod)

0 commit comments

Comments
 (0)