From: Nicolin Chen <nicoleotsuka@gmail.com>
To: Shengjiu Wang <shengjiu.wang@nxp.com>
Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
timur@kernel.org, Xiubo.Lee@gmail.com, lgirdwood@gmail.com,
linuxppc-dev@lists.ozlabs.org, tiwai@suse.com,
robh+dt@kernel.org, perex@perex.cz, broonie@kernel.org,
festevam@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] ASoC: fsl-asoc-card: Add MQS support
Date: Tue, 16 Jun 2020 17:48:47 -0700 [thread overview]
Message-ID: <20200617004845.GB19896@Asurada-Nvidia> (raw)
In-Reply-To: <1592292637-25734-2-git-send-email-shengjiu.wang@nxp.com>
On Tue, Jun 16, 2020 at 03:30:37PM +0800, Shengjiu Wang wrote:
> The MQS codec isn't an i2c device, so add a new platform device for it.
>
> MQS only support playback, so add a new audio map.
>
> Add there maybe "model" property or no "audio-routing" property insertions
"Add" => "And"
> devicetree, so add some enhancement for these two property.
>
> Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
> ---
> sound/soc/fsl/fsl-asoc-card.c | 70 ++++++++++++++++++++++++++---------
> 1 file changed, 52 insertions(+), 18 deletions(-)
>
> diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
> index 00be73900888..2ac8cb9ddd10 100644
> --- a/sound/soc/fsl/fsl-asoc-card.c
> +++ b/sound/soc/fsl/fsl-asoc-card.c
> @@ -482,6 +489,7 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
> {
> struct device_node *cpu_np, *codec_np, *asrc_np;
> struct device_node *np = pdev->dev.of_node;
> + struct platform_device *codec_pdev = NULL; /* used for non i2c device*/
Having both codec_pdev and codec_dev duplicates things. Actually
only a couple of places really need "codec_dev" -- most of them
need codec_dev->dev pointer instead. So we could have a cleanup:
- struct i2c_client *codec_dev;
+ struct device *codec_dev = NULL;
> @@ -512,10 +520,13 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
> }
>
> codec_np = of_parse_phandle(np, "audio-codec", 0);
> - if (codec_np)
> + if (codec_np) {
> codec_dev = of_find_i2c_device_by_node(codec_np);
> - else
> + if (!codec_dev)
> + codec_pdev = of_find_device_by_node(codec_np);
> + } else {
> codec_dev = NULL;
> + }
Here can have something like (feel free to simplify):
if (codec_np) {
struct platform_device *codec_pdev;
struct i2c_client *codec_i2c;
codec_i2c = of_find_i2c_device_by_node(codec_np);
if (codec_i2c)
codec_dev = &codec_i2c->dev;
if (!codec_dev) {
codec_pdev = of_find_device_by_node(codec_np);
codec_dev = &codec_pdev->dev;
}
}
> asrc_np = of_parse_phandle(np, "audio-asrc", 0);
> if (asrc_np)
> @@ -525,6 +536,13 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
> if (codec_dev) {
> struct clk *codec_clk = clk_get(&codec_dev->dev, NULL);
Then here:
- struct clk *codec_clk = clk_get(&codec_dev->dev, NULL);
+ struct clk *codec_clk = clk_get(codec_dev, NULL);
> @@ -538,6 +556,11 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
> /* Assign a default DAI format, and allow each card to overwrite it */
> priv->dai_fmt = DAI_FMT_BASE;
>
> + memcpy(priv->dai_link, fsl_asoc_card_dai,
> + sizeof(struct snd_soc_dai_link) * ARRAY_SIZE(priv->dai_link));
> @@ -573,13 +596,25 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
> codec_dai_name = "ac97-hifi";
> priv->card.set_bias_level = NULL;
> priv->dai_fmt = SND_SOC_DAIFMT_AC97;
> + priv->card.dapm_routes = audio_map_ac97;
> + priv->card.num_dapm_routes = ARRAY_SIZE(audio_map_ac97);
> + } else if (of_device_is_compatible(np, "fsl,imx-audio-mqs")) {
> + codec_dai_name = "fsl-mqs-dai";
> + priv->card.set_bias_level = NULL;
> + priv->dai_fmt = SND_SOC_DAIFMT_LEFT_J |
> + SND_SOC_DAIFMT_CBS_CFS |
> + SND_SOC_DAIFMT_NB_NF;
> + priv->dai_link[1].dpcm_playback = 1;
> + priv->dai_link[2].dpcm_playback = 1;
dpcm_playback = 1? That's the default value in fsl_asoc_card_dai.
> @@ -601,19 +636,18 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
> priv->cpu_priv.sysclk_id[0] = FSL_SAI_CLK_MAST1;
> }
>
> - snprintf(priv->name, sizeof(priv->name), "%s-audio",
> - fsl_asoc_card_is_ac97(priv) ? "ac97" :
> - codec_dev->name);
> -
> /* Initialize sound card */
> priv->pdev = pdev;
> priv->card.dev = &pdev->dev;
> - priv->card.name = priv->name;
> + ret = snd_soc_of_parse_card_name(&priv->card, "model");
> + if (ret) {
> + snprintf(priv->name, sizeof(priv->name), "%s-audio",
> + fsl_asoc_card_is_ac97(priv) ? "ac97" :
> + (codec_dev ? codec_dev->name : codec_pdev->name));
We can just use dev_name() if codec_dev is struct device *
Or having a codec_dev_name to cache codec_pdev/i2c->name.
> - ret = snd_soc_of_parse_audio_routing(&priv->card, "audio-routing");
> - if (ret) {
> - dev_err(&pdev->dev, "failed to parse audio-routing: %d\n", ret);
> - goto asrc_fail;
> + if (of_property_read_bool(np, "audio-routing")) {
> + ret = snd_soc_of_parse_audio_routing(&priv->card, "audio-routing");
> + if (ret) {
> + dev_err(&pdev->dev, "failed to parse audio-routing: %d\n", ret);
> + goto asrc_fail;
Hmm...audio-routing is a required property in DT binding doc.
So you might need to update that too.
next prev parent reply other threads:[~2020-06-17 0:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-16 7:30 [PATCH 1/2] ASoC: bindings: fsl-asoc-card: Add compatible string for MQS Shengjiu Wang
2020-06-16 7:30 ` [PATCH 2/2] ASoC: fsl-asoc-card: Add MQS support Shengjiu Wang
2020-06-17 0:48 ` Nicolin Chen [this message]
2020-06-17 3:31 ` Shengjiu Wang
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=20200617004845.GB19896@Asurada-Nvidia \
--to=nicoleotsuka@gmail.com \
--cc=Xiubo.Lee@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=perex@perex.cz \
--cc=robh+dt@kernel.org \
--cc=shengjiu.wang@nxp.com \
--cc=timur@kernel.org \
--cc=tiwai@suse.com \
/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