devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Jiaxin Yu <jiaxin.yu@mediatek.com>
Cc: broonie@kernel.org, robh+dt@kernel.org, matthias.bgg@gmail.com,
	trevor.wu@mediatek.com, alsa-devel@alsa-project.org,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
	Project_Global_Chrome_Upstream_Group@mediatek.com,
	Jiaxin Yu <jiaxin.yu@mediatek.corp-partner.google.com>
Subject: Re: [PATCH 2/2] ASoC: mediatek: mt8192: support rt1015p_rt5682s
Date: Tue, 1 Mar 2022 17:03:45 +0800	[thread overview]
Message-ID: <Yh3hcQpLngg8Pnd4@google.com> (raw)
In-Reply-To: <20220301072924.24814-3-jiaxin.yu@mediatek.com>

On Tue, Mar 01, 2022 at 03:29:24PM +0800, Jiaxin Yu wrote:
> From: Jiaxin Yu <jiaxin.yu@mediatek.corp-partner.google.com>

The environment didn't configure properly so that the header showed up.
See [1].

[1]: https://git-scm.com/docs/git-send-email#Documentation/git-send-email.txt---fromltaddressgt

> diff --git a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
[...]
> +static struct snd_soc_card mt8192_mt6359_rt1015p_rt5682s_card = {
> +	.name = "mt8192_mt6359_rt1015p_rt5682s",
> +	.owner = THIS_MODULE,
> +	.dai_link = mt8192_mt6359_dai_links,
> +	.num_links = ARRAY_SIZE(mt8192_mt6359_dai_links),
> +	.controls = mt8192_mt6359_rt1015p_rt5682_controls,
> +	.num_controls = ARRAY_SIZE(mt8192_mt6359_rt1015p_rt5682_controls),
> +	.dapm_widgets = mt8192_mt6359_rt1015p_rt5682_widgets,
> +	.num_dapm_widgets = ARRAY_SIZE(mt8192_mt6359_rt1015p_rt5682_widgets),
> +	.dapm_routes = mt8192_mt6359_rt1015p_rt5682_routes,
> +	.num_dapm_routes = ARRAY_SIZE(mt8192_mt6359_rt1015p_rt5682_routes),
> +};

Are the two cards only different from names
(mt8192_mt6359_rt1015p_rt5682_card vs. mt8192_mt6359_rt1015p_rt5682s_card)?

> @@ -1150,6 +1177,52 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev)
>  				dai_link->num_platforms =
>  					ARRAY_SIZE(i2s3_rt1015p_platforms);
>  			}
> +		} else if (strcmp(dai_link->name, "I2S8") == 0) {
> +			if (card == &mt8192_mt6359_rt1015_rt5682_card ||
> +			    card == &mt8192_mt6359_rt1015p_rt5682_card) {
> +				dai_link->cpus = i2s8_rt5682_cpus;
> +				dai_link->num_cpus =
> +					ARRAY_SIZE(i2s8_rt5682_cpus);
> +				dai_link->codecs = i2s8_rt5682_codecs;
> +				dai_link->num_codecs =
> +					ARRAY_SIZE(i2s8_rt5682_codecs);
> +				dai_link->platforms = i2s8_rt5682_platforms;
> +				dai_link->num_platforms =
> +					ARRAY_SIZE(i2s8_rt5682_platforms);
> +			} else if (card == &mt8192_mt6359_rt1015p_rt5682s_card) {
> +				dai_link->cpus = i2s8_rt5682s_cpus;
> +				dai_link->num_cpus =
> +					ARRAY_SIZE(i2s8_rt5682s_cpus);
> +				dai_link->codecs = i2s8_rt5682s_codecs;
> +				dai_link->num_codecs =
> +					ARRAY_SIZE(i2s8_rt5682s_codecs);
> +				dai_link->platforms = i2s8_rt5682s_platforms;
> +				dai_link->num_platforms =
> +					ARRAY_SIZE(i2s8_rt5682s_platforms);
> +			}
> +		} else if (strcmp(dai_link->name, "I2S9") == 0) {
> +			if (card == &mt8192_mt6359_rt1015_rt5682_card ||
> +			    card == &mt8192_mt6359_rt1015p_rt5682_card) {
> +				dai_link->cpus = i2s9_rt5682_cpus;
> +				dai_link->num_cpus =
> +					ARRAY_SIZE(i2s9_rt5682_cpus);
> +				dai_link->codecs = i2s9_rt5682_codecs;
> +				dai_link->num_codecs =
> +					ARRAY_SIZE(i2s9_rt5682_codecs);
> +				dai_link->platforms = i2s9_rt5682_platforms;
> +				dai_link->num_platforms =
> +					ARRAY_SIZE(i2s9_rt5682_platforms);
> +			} else if (card == &mt8192_mt6359_rt1015p_rt5682s_card) {
> +				dai_link->cpus = i2s9_rt5682s_cpus;
> +				dai_link->num_cpus =
> +					ARRAY_SIZE(i2s9_rt5682s_cpus);
> +				dai_link->codecs = i2s9_rt5682s_codecs;
> +				dai_link->num_codecs =
> +					ARRAY_SIZE(i2s9_rt5682s_codecs);
> +				dai_link->platforms = i2s9_rt5682s_platforms;
> +				dai_link->num_platforms =
> +					ARRAY_SIZE(i2s9_rt5682s_platforms);
> +			}

After seeing the code, I am starting to wonder if the reuse is overkill.  If
they (RT5682 vs. RT5682S) only have some minor differences, probably it could
reuse more by:

SND_SOC_DAILINK_DEFS(i2s8, ...
SND_SOC_DAILINK_DEFS(i2s9, ...

...

if (card == &mt8192_mt6359_rt1015p_rt5682s_card) {
        i2s8_codecs.name = RT5682S_DEV0_NAME;
        i2s8_codecs.dai_name = RT5682S_CODEC_DAI;
        ...
}

Or even uses of_device_is_compatible() if it would like to reuse the struct
snd_soc_card.

  reply	other threads:[~2022-03-01  9:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-01  7:29 [PATCH 0/2] ASoC: mediatek: mt8192-mt6359: support machine Jiaxin Yu
2022-03-01  7:29 ` [PATCH 1/2] ASoC: dt-bindings: mt8192-mt6359: add new compatible for using rt1015p and rt5682 Jiaxin Yu
2022-03-01  7:29 ` [PATCH 2/2] ASoC: mediatek: mt8192: support rt1015p_rt5682s Jiaxin Yu
2022-03-01  9:03   ` Tzung-Bi Shih [this message]
2022-03-02  4:07     ` Jiaxin Yu
2022-03-03  5:16       ` Tzung-Bi Shih

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=Yh3hcQpLngg8Pnd4@google.com \
    --to=tzungbi@kernel.org \
    --cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jiaxin.yu@mediatek.com \
    --cc=jiaxin.yu@mediatek.corp-partner.google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=trevor.wu@mediatek.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;
as well as URLs for NNTP newsgroup(s).