Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@nxp.com>
To: Laurentiu Mihalcea <laurentiumihalcea111@gmail.com>
Cc: Bard Liao <yung-chuan.liao@linux.intel.com>,
	Daniel Baluta <daniel.baluta@nxp.com>,
	Iuliana Prodan <iuliana.prodan@nxp.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	Mark Brown <broonie@kernel.org>,
	linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org,
	imx@lists.linux.dev
Subject: Re: [PATCH v2 3/8] ASoC: SOF: imx8: use IMX_SOF_* macros
Date: Thu, 6 Feb 2025 11:13:28 -0500	[thread overview]
Message-ID: <Z6TfqBpITPugtGmf@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20250205203022.2754-4-laurentiumihalcea111@gmail.com>

On Wed, Feb 05, 2025 at 03:30:17PM -0500, Laurentiu Mihalcea wrote:
> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>
> The definition of 'struct sof_dev_desc' has the following properties
> for imx chips:
>
>   1) FW path is the same for all chips.
>   2) Topology path is the same for all chips.
>   3) FW name can be written as: "sof-${machine_name}.ri"
>   4) IPC3 is the only supported protocol
>
> The structure takes quite a few lines of code. Since the intention
> is to add support for more imx8 chips in the same driver, we need
> to try and reduce the number of lines taken by information that's
> not particularly useful. As such, we can use 'IMX_SOF_DEV_DESC()'
> to reduce the declaration of the structure to just one line. The
> only information that's particularly useful can be seen from the
> parameters of the macro.
>
> Of course, if any of the assumptions don't apply anymore, driver
> writers can simply declare the 'struct sof_dev_desc' the "old
> fashioned way". No reason to make the macro suit multiple needs.
>
> The same logic applies to the array of 'struct snd_soc_dai_driver'.
>
> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
> Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
> Reviewed-by: Iuliana Prodan <iuliana.prodan@nxp.com>

Reviewed-by: Frank Li <Frank.Li@nxp.com>
> ---
>  sound/soc/sof/imx/imx8.c | 71 +++++++---------------------------------
>  1 file changed, 11 insertions(+), 60 deletions(-)
>
> diff --git a/sound/soc/sof/imx/imx8.c b/sound/soc/sof/imx/imx8.c
> index 25e3296a1e5e..52dff369d9cf 100644
> --- a/sound/soc/sof/imx/imx8.c
> +++ b/sound/soc/sof/imx/imx8.c
> @@ -119,28 +119,8 @@ static int imx8_probe(struct snd_sof_dev *sdev)
>  }
>
>  static struct snd_soc_dai_driver imx8_dai[] = {
> -{
> -	.name = "esai0",
> -	.playback = {
> -		.channels_min = 1,
> -		.channels_max = 8,
> -	},
> -	.capture = {
> -		.channels_min = 1,
> -		.channels_max = 8,
> -	},
> -},
> -{
> -	.name = "sai1",
> -	.playback = {
> -		.channels_min = 1,
> -		.channels_max = 32,
> -	},
> -	.capture = {
> -		.channels_min = 1,
> -		.channels_max = 32,
> -	},
> -},
> +	IMX_SOF_DAI_DRV_ENTRY_BIDIR("esai0", 1, 8),
> +	IMX_SOF_DAI_DRV_ENTRY_BIDIR("sai1", 1, 32),
>  };
>
>  static struct snd_sof_dsp_ops sof_imx8_ops;
> @@ -238,47 +218,18 @@ static struct snd_sof_of_mach sof_imx8_machs[] = {
>  	{}
>  };
>
> -static struct sof_dev_desc sof_of_imx8qxp_desc = {
> -	.of_machines	= sof_imx8_machs,
> -	.chip_info	= &imx8x_chip_info,
> -	.ipc_supported_mask	= BIT(SOF_IPC_TYPE_3),
> -	.ipc_default		= SOF_IPC_TYPE_3,
> -	.default_fw_path = {
> -		[SOF_IPC_TYPE_3] = "imx/sof",
> -	},
> -	.default_tplg_path = {
> -		[SOF_IPC_TYPE_3] = "imx/sof-tplg",
> -	},
> -	.default_fw_filename = {
> -		[SOF_IPC_TYPE_3] = "sof-imx8x.ri",
> -	},
> -	.nocodec_tplg_filename = "sof-imx8-nocodec.tplg",
> -	.ops = &sof_imx8_ops,
> -	.ops_init = imx8_ops_init,
> -};
> +IMX_SOF_DEV_DESC(imx8, sof_imx8_machs, &imx8_chip_info, &sof_imx8_ops, imx8_ops_init);
> +IMX_SOF_DEV_DESC(imx8x, sof_imx8_machs, &imx8x_chip_info, &sof_imx8_ops, imx8_ops_init);
>
> -static struct sof_dev_desc sof_of_imx8qm_desc = {
> -	.of_machines	= sof_imx8_machs,
> -	.chip_info	= &imx8_chip_info,
> -	.ipc_supported_mask	= BIT(SOF_IPC_TYPE_3),
> -	.ipc_default		= SOF_IPC_TYPE_3,
> -	.default_fw_path = {
> -		[SOF_IPC_TYPE_3] = "imx/sof",
> -	},
> -	.default_tplg_path = {
> -		[SOF_IPC_TYPE_3] = "imx/sof-tplg",
> +static const struct of_device_id sof_of_imx8_ids[] = {
> +	{
> +		.compatible = "fsl,imx8qxp-dsp",
> +		.data = &IMX_SOF_DEV_DESC_NAME(imx8x),
>  	},
> -	.default_fw_filename = {
> -		[SOF_IPC_TYPE_3] = "sof-imx8.ri",
> +	{
> +		.compatible = "fsl,imx8qm-dsp",
> +		.data = &IMX_SOF_DEV_DESC_NAME(imx8),
>  	},
> -	.nocodec_tplg_filename = "sof-imx8-nocodec.tplg",
> -	.ops = &sof_imx8_ops,
> -	.ops_init = imx8_ops_init,
> -};
> -
> -static const struct of_device_id sof_of_imx8_ids[] = {
> -	{ .compatible = "fsl,imx8qxp-dsp", .data = &sof_of_imx8qxp_desc},
> -	{ .compatible = "fsl,imx8qm-dsp", .data = &sof_of_imx8qm_desc},
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(of, sof_of_imx8_ids);
> --
> 2.34.1
>

  reply	other threads:[~2025-02-06 16:13 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-05 20:30 [PATCH v2 0/8] Refactor imx drivers and introduce support for imx95 Laurentiu Mihalcea
2025-02-05 20:30 ` [PATCH v2 1/8] ASoC: SOF: imx: introduce more common structures and functions Laurentiu Mihalcea
2025-02-06 16:05   ` Frank Li
2025-02-05 20:30 ` [PATCH v2 2/8] ASoC: SOF: imx8: use common imx chip interface Laurentiu Mihalcea
2025-02-06 16:11   ` Frank Li
2025-02-05 20:30 ` [PATCH v2 3/8] ASoC: SOF: imx8: use IMX_SOF_* macros Laurentiu Mihalcea
2025-02-06 16:13   ` Frank Li [this message]
2025-02-05 20:30 ` [PATCH v2 4/8] ASoC: SOF: imx8: shuffle structure and function definitions Laurentiu Mihalcea
2025-02-06 16:18   ` Frank Li
2025-02-06 17:28     ` Mark Brown
2025-02-05 20:30 ` [PATCH v2 5/8] ASoC: SOF: imx8: drop unneeded/unused macros/header includes Laurentiu Mihalcea
2025-02-06 16:18   ` Frank Li
2025-02-05 20:30 ` [PATCH v2 6/8] ASoC: SOF: imx: merge imx8 and imx8m drivers Laurentiu Mihalcea
2025-02-06 16:26   ` Frank Li
2025-02-05 20:30 ` [PATCH v2 7/8] ASoC: SOF: imx: merge imx8 and imx8ulp drivers Laurentiu Mihalcea
2025-02-06 16:28   ` Frank Li
2025-02-05 20:30 ` [PATCH v2 8/8] ASoC: SOF: imx: add driver for the imx95 chip Laurentiu Mihalcea
2025-02-06 16:29   ` Frank Li
2025-02-10 16:30 ` (subset) [PATCH v2 0/8] Refactor imx drivers and introduce support for imx95 Mark Brown

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=Z6TfqBpITPugtGmf@lizhi-Precision-Tower-5810 \
    --to=frank.li@nxp.com \
    --cc=broonie@kernel.org \
    --cc=daniel.baluta@nxp.com \
    --cc=imx@lists.linux.dev \
    --cc=iuliana.prodan@nxp.com \
    --cc=laurentiumihalcea111@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    --cc=yung-chuan.liao@linux.intel.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