[Sound-open-firmware] [PATCH 0/4] Adapt imx implementation to multi client SOF
Hi Ranjani,
Patches with SQUASHME must be squashed into your corresponding commits.
RFC patch is just an idea on how to abstract ACPI / DT stuff. This adds a generic version of the machine driver descriptor snd_soc_fw_mach.
With the help of snd_soc_fw_mach we can make sof_audio_dev platform independent.
Also, I hope that we could also make sof_dev_desc platform independent in my next iteration of the patch.
So please take patches 1, 2 and 3 and squash them into your PR.
Daniel Baluta (4): [SQUASHME] ASoC: SOF: move machine driver selection to the audio client [SQUASHME]ASoC: SOF: Split DSP ops into core ops and audio ops [SQUASHME] ASoC: SOF: Introduce default_fw_filename member in sof_dev_desc [RFC] ASoC: SOF: Introduce snd_soc_fw_mach descriptor
include/sound/soc-of.h | 22 ++++++++++++++++++++++ include/sound/sof.h | 26 ++++++++++++++++++++++++++ sound/soc/sof/imx/imx8.c | 22 +++++++++++++++------- sound/soc/sof/pcm.c | 2 +- sound/soc/sof/sof-audio.h | 2 +- sound/soc/sof/sof-of-dev.c | 33 ++++----------------------------- 6 files changed, 69 insertions(+), 38 deletions(-) create mode 100644 include/sound/soc-of.h
Signed-off-by: Daniel Baluta daniel.baluta@nxp.com --- sound/soc/sof/sof-of-dev.c | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-)
diff --git a/sound/soc/sof/sof-of-dev.c b/sound/soc/sof/sof-of-dev.c index 28a9692974e5..b7b8f226217c 100644 --- a/sound/soc/sof/sof-of-dev.c +++ b/sound/soc/sof/sof-of-dev.c @@ -43,8 +43,6 @@ static int sof_of_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; const struct sof_dev_desc *desc; - /*TODO: create a generic snd_soc_xxx_mach */ - struct snd_soc_acpi_mach *mach; struct snd_sof_pdata *sof_pdata; const struct snd_sof_dsp_ops *ops; int ret; @@ -59,38 +57,12 @@ static int sof_of_probe(struct platform_device *pdev) if (!desc) return -ENODEV;
- /* get ops for platform */ - ops = desc->ops; - if (!ops) { - dev_err(dev, "error: no matching DT descriptor ops\n"); - return -ENODEV; - } - -#if IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE) - /* force nocodec mode */ - dev_warn(dev, "Force to use nocodec mode\n"); - mach = devm_kzalloc(dev, sizeof(*mach), GFP_KERNEL); - if (!mach) - return -ENOMEM; - ret = sof_nocodec_setup(dev, sof_pdata, mach, desc, ops); - if (ret < 0) - return ret; -#else - /* TODO: implement case where we actually have a codec */ - return -ENODEV; -#endif - - if (mach) - mach->mach_params.platform = dev_name(dev); - - sof_pdata->machine = mach; sof_pdata->desc = desc; sof_pdata->dev = &pdev->dev; - sof_pdata->platform = dev_name(dev); + sof_pdata->fw_filename = desc->default_fw_filename;
/* TODO: read alternate fw and tplg filenames from DT */ sof_pdata->fw_filename_prefix = sof_pdata->desc->default_fw_path; - sof_pdata->tplg_filename_prefix = sof_pdata->desc->default_tplg_path;
#if IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE) /* set callback to enable runtime_pm */
Signed-off-by: Daniel Baluta daniel.baluta@nxp.com --- sound/soc/sof/imx/imx8.c | 22 +++++++++++++++------- sound/soc/sof/sof-of-dev.c | 2 ++ 2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/sound/soc/sof/imx/imx8.c b/sound/soc/sof/imx/imx8.c index cfefcfd92798..363645389d1d 100644 --- a/sound/soc/sof/imx/imx8.c +++ b/sound/soc/sof/imx/imx8.c @@ -21,6 +21,7 @@ #include <linux/firmware/imx/svc/misc.h> #include <dt-bindings/firmware/imx/rsrc.h> #include "../ops.h" +#include "../sof-audio.h"
/* DSP memories */ #define IRAM_OFFSET 0x10000 @@ -345,7 +346,7 @@ static void imx8_ipc_msg_data(struct snd_sof_dev *sdev, sof_mailbox_read(sdev, sdev->dsp_box.offset, p, sz); }
-static int imx8_ipc_pcm_params(struct snd_sof_dev *sdev, +static int imx8_ipc_pcm_params(struct snd_soc_component *scomp, struct snd_pcm_substream *substream, const struct sof_ipc_pcm_params_reply *reply) { @@ -377,7 +378,6 @@ struct snd_sof_dsp_ops sof_imx8_ops = { .get_window_offset = imx8_get_window_offset,
.ipc_msg_data = imx8_ipc_msg_data, - .ipc_pcm_params = imx8_ipc_pcm_params,
/* module loading */ .load_module = snd_sof_parse_module_memcpy, @@ -385,17 +385,25 @@ struct snd_sof_dsp_ops sof_imx8_ops = { /* firmware loading */ .load_firmware = snd_sof_load_firmware_memcpy,
- /* DAI drivers */ - .drv = imx8_dai, - .num_drv = 1, /* we have only 1 ESAI interface on i.MX8 */ + +}; +EXPORT_SYMBOL(sof_imx8_ops); + +/* imx8 audio ops */ +const struct snd_sof_audio_ops sof_imx8_audio_ops = { + /* IPC */ + .ipc_pcm_params = imx8_ipc_pcm_params,
/* ALSA HW info flags */ .hw_info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE | - SNDRV_PCM_INFO_NO_PERIOD_WAKEUP + SNDRV_PCM_INFO_NO_PERIOD_WAKEUP, + /* DAI drivers */ + .drv = imx8_dai, + .num_drv = 1, /* we have only 1 ESAI interface on i.MX8 */ }; -EXPORT_SYMBOL(sof_imx8_ops); +EXPORT_SYMBOL(sof_imx8_audio_ops);
MODULE_LICENSE("Dual BSD/GPL"); diff --git a/sound/soc/sof/sof-of-dev.c b/sound/soc/sof/sof-of-dev.c index b7b8f226217c..6c268634baff 100644 --- a/sound/soc/sof/sof-of-dev.c +++ b/sound/soc/sof/sof-of-dev.c @@ -13,6 +13,7 @@ #include "ops.h"
extern struct snd_sof_dsp_ops sof_imx8_ops; +extern struct snd_sof_audio_ops sof_imx8_audio_ops;
/* platform specific devices */ #if IS_ENABLED(CONFIG_SND_SOC_SOF_IMX8) @@ -22,6 +23,7 @@ static struct sof_dev_desc sof_of_imx8qxp_desc = { .nocodec_fw_filename = "sof-imx8.ri", .nocodec_tplg_filename = "sof-imx8-nocodec.tplg", .ops = &sof_imx8_ops, + .audio_ops = &sof_imx8_audio_ops, }; #endif
Signed-off-by: Daniel Baluta daniel.baluta@nxp.com --- sound/soc/sof/sof-of-dev.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/sound/soc/sof/sof-of-dev.c b/sound/soc/sof/sof-of-dev.c index 6c268634baff..06f4c85fdd1f 100644 --- a/sound/soc/sof/sof-of-dev.c +++ b/sound/soc/sof/sof-of-dev.c @@ -20,6 +20,7 @@ extern struct snd_sof_audio_ops sof_imx8_audio_ops; static struct sof_dev_desc sof_of_imx8qxp_desc = { .default_fw_path = "imx/sof", .default_tplg_path = "imx/sof-tplg", + .default_fw_filename = "sof-imx8.ri", .nocodec_fw_filename = "sof-imx8.ri", .nocodec_tplg_filename = "sof-imx8-nocodec.tplg", .ops = &sof_imx8_ops,
This will unify machine driver descriptor between OF/ACPI.
Signed-off-by: Daniel Baluta daniel.baluta@nxp.com --- include/sound/soc-of.h | 22 ++++++++++++++++++++++ include/sound/sof.h | 26 ++++++++++++++++++++++++++ sound/soc/sof/pcm.c | 2 +- sound/soc/sof/sof-audio.h | 2 +- 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 include/sound/soc-of.h
diff --git a/include/sound/soc-of.h b/include/sound/soc-of.h new file mode 100644 index 000000000000..267c92c54188 --- /dev/null +++ b/include/sound/soc-of.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 + * + * Copyright 2019 NXP + */ + +#ifndef __LINUX_SND_SOC_OF_H +#define __LINUX_SND_SOC_OF_H + +#include <linux/of.h> + +/** + * snd_soc_of_mach: DT-based machine driver descriptor + * + * @drv_name: machine driver name + * @of: DT node providing machine driver description + */ +struct snd_soc_of_mach { + const char *drv_name; + struct device_node *of; +}; + +#endif diff --git a/include/sound/sof.h b/include/sound/sof.h index 4e151abecac8..60db0a73d337 100644 --- a/include/sound/sof.h +++ b/include/sound/sof.h @@ -14,10 +14,36 @@ #include <linux/pci.h> #include <sound/soc.h> #include <sound/soc-acpi.h> +#include <sound/soc-of.h>
struct snd_sof_dsp_ops; struct snd_sof_audio_ops;
+enum { + SND_SOC_FW_TYPE_ACPI = 0, + SND_SOC_FW_TYPE_OF, +}; + +struct snd_soc_fw_mach { + int type; + union { + struct snd_soc_acpi_mach *acpi; + struct snd_soc_of_mach *of; + }; +}; + +static inline +const char *sof_mach_get_drv_name(const struct snd_soc_fw_mach *mach) +{ + switch (mach->type) { + case SND_SOC_FW_TYPE_ACPI: + return mach->acpi->drv_name; + case SND_SOC_FW_TYPE_OF: + return mach->of->drv_name; + default: + return NULL; + } +} /* * SOF Platform data. */ diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index 8de566d7ee85..c0e8ecb287d7 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -795,7 +795,7 @@ void snd_sof_new_platform_drv(struct sof_audio_dev *sof_audio) struct snd_soc_component_driver *pd = &sof_audio->plat_drv; const char *drv_name;
- drv_name = sof_audio->machine->drv_name; + drv_name = sof_mach_get_drv_name(sof_audio->machine);
pd->name = "sof-audio-component"; pd->probe = sof_pcm_probe; diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h index 8b76b8b1709b..013e7e85d61d 100644 --- a/sound/soc/sof/sof-audio.h +++ b/sound/soc/sof/sof-audio.h @@ -160,7 +160,7 @@ struct sof_audio_dev {
/* machine */ struct platform_device *pdev_mach; - const struct snd_soc_acpi_mach *machine; + struct snd_soc_fw_mach *machine;
const char *tplg_filename_prefix; const char *tplg_filename;
On Wed, 2019-10-30 at 17:42 +0200, Daniel Baluta wrote:
This will unify machine driver descriptor between OF/ACPI.
Signed-off-by: Daniel Baluta daniel.baluta@nxp.com
include/sound/soc-of.h | 22 ++++++++++++++++++++++ include/sound/sof.h | 26 ++++++++++++++++++++++++++ sound/soc/sof/pcm.c | 2 +- sound/soc/sof/sof-audio.h | 2 +- 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 include/sound/soc-of.h
diff --git a/include/sound/soc-of.h b/include/sound/soc-of.h new file mode 100644 index 000000000000..267c92c54188 --- /dev/null +++ b/include/sound/soc-of.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0
- Copyright 2019 NXP
- */
+#ifndef __LINUX_SND_SOC_OF_H +#define __LINUX_SND_SOC_OF_H
+#include <linux/of.h>
+/**
- snd_soc_of_mach: DT-based machine driver descriptor
- @drv_name: machine driver name
- @of: DT node providing machine driver description
- */
+struct snd_soc_of_mach {
- const char *drv_name;
- struct device_node *of;
+};
+#endif diff --git a/include/sound/sof.h b/include/sound/sof.h index 4e151abecac8..60db0a73d337 100644 --- a/include/sound/sof.h +++ b/include/sound/sof.h @@ -14,10 +14,36 @@ #include <linux/pci.h> #include <sound/soc.h> #include <sound/soc-acpi.h> +#include <sound/soc-of.h>
struct snd_sof_dsp_ops; struct snd_sof_audio_ops;
+enum {
- SND_SOC_FW_TYPE_ACPI = 0,
- SND_SOC_FW_TYPE_OF,
+};
+struct snd_soc_fw_mach {
- int type;
Hi Daniel,
Thanks for this patch. I was struggling to understand where this type field could be set. But, the one difference I noticed between the sof_dev_desc for IMX vs Intel platforms was that the IMX desc lacks the "machines" field.
How about we use that to differentiate the 2 platforms? I am working on adding the part. I will update my PR with the changes soon.
Thanks, Ranjani
- union {
struct snd_soc_acpi_mach *acpi;
struct snd_soc_of_mach *of;
- };
+};
+static inline +const char *sof_mach_get_drv_name(const struct snd_soc_fw_mach *mach) +{
- switch (mach->type) {
- case SND_SOC_FW_TYPE_ACPI:
return mach->acpi->drv_name;
- case SND_SOC_FW_TYPE_OF:
return mach->of->drv_name;
- default:
return NULL;
- }
+} /*
- SOF Platform data.
*/ diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index 8de566d7ee85..c0e8ecb287d7 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -795,7 +795,7 @@ void snd_sof_new_platform_drv(struct sof_audio_dev *sof_audio) struct snd_soc_component_driver *pd = &sof_audio->plat_drv; const char *drv_name;
- drv_name = sof_audio->machine->drv_name;
drv_name = sof_mach_get_drv_name(sof_audio->machine);
pd->name = "sof-audio-component"; pd->probe = sof_pcm_probe;
diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h index 8b76b8b1709b..013e7e85d61d 100644 --- a/sound/soc/sof/sof-audio.h +++ b/sound/soc/sof/sof-audio.h @@ -160,7 +160,7 @@ struct sof_audio_dev {
/* machine */ struct platform_device *pdev_mach;
- const struct snd_soc_acpi_mach *machine;
struct snd_soc_fw_mach *machine;
const char *tplg_filename_prefix; const char *tplg_filename;
participants (2)
-
Daniel Baluta
-
Ranjani Sridharan