From: Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org>
To: Jason Cooper <jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org>,
broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Cc: linux ARM
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org>
Subject: [PATCH 4/5] ASoC: simple-card: Support setting mclk via a fixed factor
Date: Thu, 17 Apr 2014 17:53:13 +0200 [thread overview]
Message-ID: <1397749994-24983-5-git-send-email-andrew@lunn.ch> (raw)
In-Reply-To: <1397749994-24983-1-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
Some platforms require that the codecs mclk is a fixed multiplication
factor of the audio stream rate. Add a optional property to the
binding to hold this factor and implement a hw_params() function to
make use of it.
Signed-off-by: Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org>
---
.../devicetree/bindings/sound/simple-card.txt | 2 ++
sound/soc/generic/simple-card.c | 28 ++++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt
index 131aa2ad7f1a..c4379c9f9f03 100644
--- a/Documentation/devicetree/bindings/sound/simple-card.txt
+++ b/Documentation/devicetree/bindings/sound/simple-card.txt
@@ -18,6 +18,8 @@ Optional properties:
Each entry is a pair of strings, the first being the
connection's sink, the second being the connection's
source.
+- simple-audio-card,mclk-factor : Multiplication factor between stream rate and codec
+ mclk.
- dai-tdm-slot-num : Please refer to tdm-slot.txt.
- dai-tdm-slot-width : Please refer to tdm-slot.txt.
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 21f1ccbdf582..5ecaf57ab712 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -24,6 +24,7 @@ struct simple_card_data {
struct asoc_simple_dai cpu_dai;
struct asoc_simple_dai codec_dai;
} *dai_props;
+ unsigned int mclk_factor;
struct snd_soc_dai_link dai_link[]; /* dynamically allocated */
};
@@ -151,6 +152,28 @@ asoc_simple_card_sub_parse_of(struct device_node *np,
return 0;
}
+static int simple_card_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params)
+{
+ struct snd_soc_pcm_runtime *rtd = substream->private_data;
+ struct snd_soc_dai *codec_dai = rtd->codec_dai;
+ struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card);
+ unsigned int mclk;
+ int ret = 0;
+
+ if (priv->mclk_factor) {
+ mclk = params_rate(params) * priv->mclk_factor;
+ ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
+ SND_SOC_CLOCK_IN);
+ }
+
+ return ret;
+}
+
+static struct snd_soc_ops simple_card_ops = {
+ .hw_params = simple_card_hw_params,
+};
+
static int simple_card_cpu_codec_of(struct device_node *node,
int daifmt,
struct snd_soc_dai_link *dai_link,
@@ -255,6 +278,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
sprintf(name, "%s-%s", dai_link->cpu_dai_name,
dai_link->codec_dai_name);
dai_link->name = dai_link->stream_name = name;
+ dai_link->ops = &simple_card_ops;
if (!multi)
break;
@@ -263,6 +287,10 @@ static int asoc_simple_card_parse_of(struct device_node *node,
dai_props++;
}
+ /* Factor to mclk, used in hw_params() */
+ of_property_read_u32(node, "simple-audio-card,mclk-factor",
+ &priv->mclk_factor);
+
/* card name is created from CPU/CODEC dai name */
dai_link = priv->snd_card.dai_link;
if (!priv->snd_card.name)
--
1.9.2
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-04-17 15:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-17 15:53 [PATCH 0/5] Simple-audio-card support for HP t5325 Andrew Lunn
[not found] ` <1397749994-24983-1-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
2014-04-17 15:53 ` [PATCH 1/5] ASoC: alc5623: Add device tree binding Andrew Lunn
2014-04-18 16:33 ` Mark Brown
[not found] ` <20140418163351.GI12304-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-04-18 18:17 ` Andrew Lunn
[not found] ` <20140418181735.GB32580-g2DYL2Zd6BY@public.gmane.org>
2014-04-18 18:44 ` Mark Brown
2014-04-28 7:01 ` Anil Kumar
2014-04-17 15:53 ` [PATCH 2/5] ARM: Kirkwood: Use DT to instansiate codec Andrew Lunn
[not found] ` <1397749994-24983-3-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
2014-04-17 21:37 ` Jason Cooper
2014-04-17 15:53 ` [PATCH 3/5] ARM: Kirkwood: DT: Add missing #sound-dai-cells property Andrew Lunn
2014-04-17 15:53 ` Andrew Lunn [this message]
[not found] ` <1397749994-24983-5-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
2014-04-18 16:38 ` [PATCH 4/5] ASoC: simple-card: Support setting mclk via a fixed factor Mark Brown
2014-04-17 15:53 ` [PATCH 5/5] ARM: Kirkwood: t5325: Use simple-card to instantiate audio Andrew Lunn
2014-04-18 0:15 ` [PATCH 0/5] Simple-audio-card support for HP t5325 Jason Cooper
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=1397749994-24983-5-git-send-email-andrew@lunn.ch \
--to=andrew-g2dyl2zd6by@public.gmane.org \
--cc=alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.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).