ASoC: rsnd: handle DPCM converted rate/chan under core

converted rate/chan are handled each rated module, but
it will be used other module too.
For examle, converted channel is currently used for CTU,
but, it will be used for TDM Split mode, too.

This patch move/merge SRC/CTU hw_param under core.c
and handles converted rate/chan under rsnd_dai_stream.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Kuninori Morimoto 2018-11-06 05:20:10 +00:00 committed by Mark Brown
parent beed78aeeb
commit c2aaaa57d4
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
4 changed files with 39 additions and 85 deletions

View File

@ -269,7 +269,7 @@ int rsnd_runtime_channel_after_ctu_with_params(struct rsnd_dai_stream *io,
struct rsnd_mod *ctu_mod = rsnd_io_to_mod_ctu(io); struct rsnd_mod *ctu_mod = rsnd_io_to_mod_ctu(io);
if (ctu_mod) { if (ctu_mod) {
u32 converted_chan = rsnd_ctu_converted_channel(ctu_mod); u32 converted_chan = rsnd_io_converted_chan(io);
if (converted_chan) if (converted_chan)
return converted_chan; return converted_chan;
@ -1225,8 +1225,40 @@ static int rsnd_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai = rsnd_substream_to_dai(substream); struct snd_soc_dai *dai = rsnd_substream_to_dai(substream);
struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai); struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream); struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream);
struct snd_soc_pcm_runtime *fe = substream->private_data;
int ret; int ret;
/*
* rsnd assumes that it might be used under DPCM if user want to use
* channel / rate convert. Then, rsnd should be FE.
* And then, this function will be called *after* BE settings.
* this means, each BE already has fixuped hw_params.
* see
* dpcm_fe_dai_hw_params()
* dpcm_be_dai_hw_params()
*/
io->converted_rate = 0;
io->converted_chan = 0;
if (fe->dai_link->dynamic) {
struct rsnd_priv *priv = rsnd_io_to_priv(io);
struct device *dev = rsnd_priv_to_dev(priv);
struct snd_soc_dpcm *dpcm;
struct snd_pcm_hw_params *be_params;
int stream = substream->stream;
for_each_dpcm_be(fe, stream, dpcm) {
be_params = &dpcm->hw_params;
if (params_channels(hw_params) != params_channels(be_params))
io->converted_chan = params_channels(be_params);
if (params_rate(hw_params) != params_rate(be_params))
io->converted_rate = params_rate(be_params);
}
if (io->converted_chan)
dev_dbg(dev, "convert channels = %d\n", io->converted_chan);
if (io->converted_rate)
dev_dbg(dev, "convert rate = %d\n", io->converted_rate);
}
ret = rsnd_dai_call(hw_params, io, substream, hw_params); ret = rsnd_dai_call(hw_params, io, substream, hw_params);
if (ret) if (ret)
return ret; return ret;

View File

@ -107,13 +107,6 @@ static void rsnd_ctu_halt(struct rsnd_mod *mod)
rsnd_mod_write(mod, CTU_SWRSR, 0); rsnd_mod_write(mod, CTU_SWRSR, 0);
} }
int rsnd_ctu_converted_channel(struct rsnd_mod *mod)
{
struct rsnd_ctu *ctu = rsnd_mod_to_ctu(mod);
return ctu->channels;
}
static int rsnd_ctu_probe_(struct rsnd_mod *mod, static int rsnd_ctu_probe_(struct rsnd_mod *mod,
struct rsnd_dai_stream *io, struct rsnd_dai_stream *io,
struct rsnd_priv *priv) struct rsnd_priv *priv)
@ -233,43 +226,6 @@ static int rsnd_ctu_quit(struct rsnd_mod *mod,
return 0; return 0;
} }
static int rsnd_ctu_hw_params(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *fe_params)
{
struct rsnd_ctu *ctu = rsnd_mod_to_ctu(mod);
struct snd_soc_pcm_runtime *fe = substream->private_data;
/*
* CTU assumes that it is used under DPCM if user want to use
* channel transfer. Then, CTU should be FE.
* And then, this function will be called *after* BE settings.
* this means, each BE already has fixuped hw_params.
* see
* dpcm_fe_dai_hw_params()
* dpcm_be_dai_hw_params()
*/
ctu->channels = 0;
if (fe->dai_link->dynamic) {
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
struct device *dev = rsnd_priv_to_dev(priv);
struct snd_soc_dpcm *dpcm;
struct snd_pcm_hw_params *be_params;
int stream = substream->stream;
for_each_dpcm_be(fe, stream, dpcm) {
be_params = &dpcm->hw_params;
if (params_channels(fe_params) != params_channels(be_params))
ctu->channels = params_channels(be_params);
}
dev_dbg(dev, "CTU convert channels %d\n", ctu->channels);
}
return 0;
}
static int rsnd_ctu_pcm_new(struct rsnd_mod *mod, static int rsnd_ctu_pcm_new(struct rsnd_mod *mod,
struct rsnd_dai_stream *io, struct rsnd_dai_stream *io,
struct snd_soc_pcm_runtime *rtd) struct snd_soc_pcm_runtime *rtd)
@ -357,7 +313,6 @@ static struct rsnd_mod_ops rsnd_ctu_ops = {
.probe = rsnd_ctu_probe_, .probe = rsnd_ctu_probe_,
.init = rsnd_ctu_init, .init = rsnd_ctu_init,
.quit = rsnd_ctu_quit, .quit = rsnd_ctu_quit,
.hw_params = rsnd_ctu_hw_params,
.pcm_new = rsnd_ctu_pcm_new, .pcm_new = rsnd_ctu_pcm_new,
.get_status = rsnd_mod_get_status, .get_status = rsnd_mod_get_status,
.id = rsnd_ctu_id, .id = rsnd_ctu_id,

View File

@ -457,6 +457,8 @@ struct rsnd_dai_stream {
struct rsnd_mod *dma; struct rsnd_mod *dma;
struct rsnd_dai *rdai; struct rsnd_dai *rdai;
struct device *dmac_dev; /* for IPMMU */ struct device *dmac_dev; /* for IPMMU */
u32 converted_rate; /* converted sampling rate */
int converted_chan; /* converted channels */
u32 parent_ssi_status; u32 parent_ssi_status;
u32 flags; u32 flags;
}; };
@ -479,6 +481,8 @@ struct rsnd_dai_stream {
#define rsnd_io_is_play(io) (&rsnd_io_to_rdai(io)->playback == io) #define rsnd_io_is_play(io) (&rsnd_io_to_rdai(io)->playback == io)
#define rsnd_io_to_runtime(io) ((io)->substream ? \ #define rsnd_io_to_runtime(io) ((io)->substream ? \
(io)->substream->runtime : NULL) (io)->substream->runtime : NULL)
#define rsnd_io_converted_rate(io) ((io)->converted_rate)
#define rsnd_io_converted_chan(io) ((io)->converted_chan)
int rsnd_io_is_working(struct rsnd_dai_stream *io); int rsnd_io_is_working(struct rsnd_dai_stream *io);
struct rsnd_dai { struct rsnd_dai {
@ -767,7 +771,6 @@ unsigned int rsnd_src_get_rate(struct rsnd_priv *priv,
*/ */
int rsnd_ctu_probe(struct rsnd_priv *priv); int rsnd_ctu_probe(struct rsnd_priv *priv);
void rsnd_ctu_remove(struct rsnd_priv *priv); void rsnd_ctu_remove(struct rsnd_priv *priv);
int rsnd_ctu_converted_channel(struct rsnd_mod *mod);
struct rsnd_mod *rsnd_ctu_mod_get(struct rsnd_priv *priv, int id); struct rsnd_mod *rsnd_ctu_mod_get(struct rsnd_priv *priv, int id);
#define rsnd_ctu_of_node(priv) rsnd_parse_of_node(priv, RSND_NODE_CTU) #define rsnd_ctu_of_node(priv) rsnd_parse_of_node(priv, RSND_NODE_CTU)
#define rsnd_parse_connect_ctu(rdai, playback, capture) \ #define rsnd_parse_connect_ctu(rdai, playback, capture) \

View File

@ -25,7 +25,6 @@ struct rsnd_src {
struct rsnd_mod *dma; struct rsnd_mod *dma;
struct rsnd_kctrl_cfg_s sen; /* sync convert enable */ struct rsnd_kctrl_cfg_s sen; /* sync convert enable */
struct rsnd_kctrl_cfg_s sync; /* sync convert */ struct rsnd_kctrl_cfg_s sync; /* sync convert */
u32 convert_rate; /* sampling rate convert */
int irq; int irq;
}; };
@ -89,12 +88,12 @@ static u32 rsnd_src_convert_rate(struct rsnd_dai_stream *io,
return 0; return 0;
if (!rsnd_src_sync_is_enabled(mod)) if (!rsnd_src_sync_is_enabled(mod))
return src->convert_rate; return rsnd_io_converted_rate(io);
convert_rate = src->sync.val; convert_rate = src->sync.val;
if (!convert_rate) if (!convert_rate)
convert_rate = src->convert_rate; convert_rate = rsnd_io_converted_rate(io);
if (!convert_rate) if (!convert_rate)
convert_rate = runtime->rate; convert_rate = runtime->rate;
@ -135,40 +134,6 @@ unsigned int rsnd_src_get_rate(struct rsnd_priv *priv,
return rate; return rate;
} }
static int rsnd_src_hw_params(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *fe_params)
{
struct rsnd_src *src = rsnd_mod_to_src(mod);
struct snd_soc_pcm_runtime *fe = substream->private_data;
/*
* SRC assumes that it is used under DPCM if user want to use
* sampling rate convert. Then, SRC should be FE.
* And then, this function will be called *after* BE settings.
* this means, each BE already has fixuped hw_params.
* see
* dpcm_fe_dai_hw_params()
* dpcm_be_dai_hw_params()
*/
src->convert_rate = 0;
if (fe->dai_link->dynamic) {
int stream = substream->stream;
struct snd_soc_dpcm *dpcm;
struct snd_pcm_hw_params *be_params;
for_each_dpcm_be(fe, stream, dpcm) {
be_params = &dpcm->hw_params;
if (params_rate(fe_params) != params_rate(be_params))
src->convert_rate = params_rate(be_params);
}
}
return 0;
}
static void rsnd_src_set_convert_rate(struct rsnd_dai_stream *io, static void rsnd_src_set_convert_rate(struct rsnd_dai_stream *io,
struct rsnd_mod *mod) struct rsnd_mod *mod)
{ {
@ -534,7 +499,6 @@ static struct rsnd_mod_ops rsnd_src_ops = {
.start = rsnd_src_start, .start = rsnd_src_start,
.stop = rsnd_src_stop, .stop = rsnd_src_stop,
.irq = rsnd_src_irq, .irq = rsnd_src_irq,
.hw_params = rsnd_src_hw_params,
.pcm_new = rsnd_src_pcm_new, .pcm_new = rsnd_src_pcm_new,
.get_status = rsnd_mod_get_status, .get_status = rsnd_mod_get_status,
}; };