Commit 85a4bfd8 authored by Arnaud Pouliquen's avatar Arnaud Pouliquen Committed by Mark Brown

ASoC: simple card: Add mclk-fs property in dai-link

Add mclk-fs ratio property per dai-link sub node. This will
allow to manage several codecs with different ratio.
Signed-off-by: default avatarArnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent e0ae225b
...@@ -16,7 +16,8 @@ Optional properties: ...@@ -16,7 +16,8 @@ Optional properties:
connection's sink, the second being the connection's connection's sink, the second being the connection's
source. source.
- simple-audio-card,mclk-fs : Multiplication factor between stream rate and codec - simple-audio-card,mclk-fs : Multiplication factor between stream rate and codec
mclk. mclk. When defined, mclk-fs property defined in
dai-link sub nodes are ignored.
- simple-audio-card,hp-det-gpio : Reference to GPIO that signals when - simple-audio-card,hp-det-gpio : Reference to GPIO that signals when
headphones are attached. headphones are attached.
- simple-audio-card,mic-det-gpio : Reference to GPIO that signals when - simple-audio-card,mic-det-gpio : Reference to GPIO that signals when
...@@ -55,6 +56,9 @@ Optional dai-link subnode properties: ...@@ -55,6 +56,9 @@ Optional dai-link subnode properties:
dai-link uses bit clock inversion. dai-link uses bit clock inversion.
- frame-inversion : bool property. Add this if the - frame-inversion : bool property. Add this if the
dai-link uses frame clock inversion. dai-link uses frame clock inversion.
- mclk-fs : Multiplication factor between stream
rate and codec mclk, applied only for
the dai-link.
For backward compatibility the frame-master and bitclock-master For backward compatibility the frame-master and bitclock-master
properties can be used as booleans in codec subnode to indicate if the properties can be used as booleans in codec subnode to indicate if the
......
...@@ -26,6 +26,7 @@ struct simple_card_data { ...@@ -26,6 +26,7 @@ struct simple_card_data {
struct simple_dai_props { struct simple_dai_props {
struct asoc_simple_dai cpu_dai; struct asoc_simple_dai cpu_dai;
struct asoc_simple_dai codec_dai; struct asoc_simple_dai codec_dai;
unsigned int mclk_fs;
} *dai_props; } *dai_props;
unsigned int mclk_fs; unsigned int mclk_fs;
int gpio_hp_det; int gpio_hp_det;
...@@ -76,11 +77,18 @@ static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream, ...@@ -76,11 +77,18 @@ static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *codec_dai = rtd->codec_dai;
struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card); struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card);
unsigned int mclk; struct simple_dai_props *dai_props =
&priv->dai_props[rtd - rtd->card->rtd];
unsigned int mclk, mclk_fs = 0;
int ret = 0; int ret = 0;
if (priv->mclk_fs) { if (priv->mclk_fs)
mclk = params_rate(params) * priv->mclk_fs; mclk_fs = priv->mclk_fs;
else if (dai_props->mclk_fs)
mclk_fs = dai_props->mclk_fs;
if (mclk_fs) {
mclk = params_rate(params) * mclk_fs;
ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk, ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
SND_SOC_CLOCK_IN); SND_SOC_CLOCK_IN);
} }
...@@ -313,6 +321,7 @@ static int asoc_simple_card_dai_link_of(struct device_node *node, ...@@ -313,6 +321,7 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,
char prop[128]; char prop[128];
char *prefix = ""; char *prefix = "";
int ret, cpu_args; int ret, cpu_args;
u32 val;
/* For single DAI link & old style of DT node */ /* For single DAI link & old style of DT node */
if (is_top_level_node) if (is_top_level_node)
...@@ -338,6 +347,9 @@ static int asoc_simple_card_dai_link_of(struct device_node *node, ...@@ -338,6 +347,9 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,
if (ret < 0) if (ret < 0)
goto dai_link_of_err; goto dai_link_of_err;
if (!of_property_read_u32(node, "mclk-fs", &val))
dai_props->mclk_fs = val;
ret = asoc_simple_card_sub_parse_of(cpu, &dai_props->cpu_dai, ret = asoc_simple_card_sub_parse_of(cpu, &dai_props->cpu_dai,
&dai_link->cpu_of_node, &dai_link->cpu_of_node,
&dai_link->cpu_dai_name, &dai_link->cpu_dai_name,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment