ASoC: SOF: Compile and runtime IPC version selection
authorPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Tue, 14 Jun 2022 07:56:17 +0000 (10:56 +0300)
committerMark Brown <broonie@kernel.org>
Tue, 14 Jun 2022 10:22:12 +0000 (11:22 +0100)
The new IPC4 version is only supported by Intel platforms, iMX, AMD and
MediaTek only uses the standard SOF IPC.
There is no need for these platforms to build kernel support for IPC4 as
it is just dead code for them.

SND_SOC_SOF_IPC3 and SND_SOC_SOF_INTEL_IPC4 is introduced to allow compile
time selection and exclusion of IPC implementations.

To avoid randconfig failures add also support for runtime selection of
the IPC ops in ipc.c based on sdev->pdata->ipc_type

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20220614075618.28605-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/Kconfig
sound/soc/sof/Makefile
sound/soc/sof/amd/Kconfig
sound/soc/sof/imx/Kconfig
sound/soc/sof/intel/Kconfig
sound/soc/sof/ipc.c
sound/soc/sof/mediatek/Kconfig

index 4542868..e90f173 100644 (file)
@@ -252,6 +252,13 @@ config SND_SOC_SOF_PROBE_WORK_QUEUE
          When selected, the probe is handled in two steps, for example to
          avoid lockdeps if request_module is used in the probe.
 
+# Supported IPC versions
+config SND_SOC_SOF_IPC3
+       bool
+
+config SND_SOC_SOF_INTEL_IPC4
+       bool
+
 source "sound/soc/sof/amd/Kconfig"
 source "sound/soc/sof/imx/Kconfig"
 source "sound/soc/sof/intel/Kconfig"
index 2fa8088..9a74ed1 100644 (file)
@@ -1,10 +1,18 @@
 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
 
 snd-sof-objs := core.o ops.o loader.o ipc.o pcm.o pm.o debug.o topology.o\
-               control.o trace.o iomem-utils.o sof-audio.o stream-ipc.o\
-               ipc3-topology.o ipc3-control.o ipc3.o ipc3-pcm.o ipc3-loader.o\
-               ipc3-dtrace.o\
-               ipc4.o ipc4-loader.o ipc4-topology.o ipc4-control.o ipc4-pcm.o
+               control.o trace.o iomem-utils.o sof-audio.o stream-ipc.o
+
+# IPC implementations
+ifneq ($(CONFIG_SND_SOC_SOF_IPC3),)
+snd-sof-objs +=        ipc3.o ipc3-loader.o ipc3-topology.o ipc3-control.o ipc3-pcm.o\
+               ipc3-dtrace.o
+endif
+ifneq ($(CONFIG_SND_SOC_SOF_INTEL_IPC4),)
+snd-sof-objs += ipc4.o ipc4-loader.o ipc4-topology.o ipc4-control.o ipc4-pcm.o
+endif
+
+# SOF client support
 ifneq ($(CONFIG_SND_SOC_SOF_CLIENT),)
 snd-sof-objs += sof-client.o
 endif
index 085232e..190c85d 100644 (file)
@@ -17,6 +17,7 @@ if SND_SOC_SOF_AMD_TOPLEVEL
 config SND_SOC_SOF_AMD_COMMON
        tristate
        select SND_SOC_SOF
+       select SND_SOC_SOF_IPC3
        select SND_SOC_SOF_PCI_DEV
        select SND_AMD_ACP_CONFIG
        select SND_SOC_ACPI if ACPI
index 9b8d5bb..cc6e695 100644 (file)
@@ -15,6 +15,7 @@ config SND_SOC_SOF_IMX_COMMON
        tristate
        select SND_SOC_SOF_OF_DEV
        select SND_SOC_SOF
+       select SND_SOC_SOF_IPC3
        select SND_SOC_SOF_XTENSA
        select SND_SOC_SOF_COMPRESS
        help
index 0def2aa..80cdc37 100644 (file)
@@ -40,6 +40,7 @@ if SND_SOC_SOF_ACPI
 config SND_SOC_SOF_BAYTRAIL
        tristate "SOF support for Baytrail, Braswell and Cherrytrail"
        default SND_SOC_SOF_ACPI
+       select SND_SOC_SOF_IPC3
        select SND_SOC_SOF_INTEL_COMMON
        select SND_SOC_SOF_INTEL_ATOM_HIFI_EP
        select SND_SOC_SOF_ACPI_DEV
@@ -60,6 +61,7 @@ config SND_SOC_SOF_BAYTRAIL
 config SND_SOC_SOF_BROADWELL
        tristate "SOF support for Broadwell"
        default SND_SOC_SOF_ACPI
+       select SND_SOC_SOF_IPC3
        select SND_SOC_SOF_INTEL_COMMON
        select SND_SOC_SOF_INTEL_HIFI_EP_IPC
        select SND_SOC_SOF_ACPI_DEV
@@ -85,6 +87,7 @@ config SND_SOC_SOF_MERRIFIELD
        tristate "SOF support for Tangier/Merrifield"
        default SND_SOC_SOF_PCI
        select SND_SOC_SOF_PCI_DEV
+       select SND_SOC_SOF_IPC3
        select SND_SOC_SOF_INTEL_ATOM_HIFI_EP
        help
          This adds support for Sound Open Firmware for Intel(R) platforms
@@ -95,6 +98,8 @@ config SND_SOC_SOF_MERRIFIELD
 config SND_SOC_SOF_INTEL_APL
        tristate
        select SND_SOC_SOF_HDA_COMMON
+       select SND_SOC_SOF_IPC3
+       select SND_SOC_SOF_INTEL_IPC4
 
 config SND_SOC_SOF_APOLLOLAKE
        tristate "SOF support for Apollolake"
@@ -120,6 +125,8 @@ config SND_SOC_SOF_INTEL_CNL
        tristate
        select SND_SOC_SOF_HDA_COMMON
        select SND_SOC_SOF_INTEL_SOUNDWIRE_LINK_BASELINE
+       select SND_SOC_SOF_IPC3
+       select SND_SOC_SOF_INTEL_IPC4
 
 config SND_SOC_SOF_CANNONLAKE
        tristate "SOF support for Cannonlake"
@@ -154,6 +161,8 @@ config SND_SOC_SOF_INTEL_ICL
        tristate
        select SND_SOC_SOF_HDA_COMMON
        select SND_SOC_SOF_INTEL_SOUNDWIRE_LINK_BASELINE
+       select SND_SOC_SOF_IPC3
+       select SND_SOC_SOF_INTEL_IPC4
 
 config SND_SOC_SOF_ICELAKE
        tristate "SOF support for Icelake"
@@ -179,6 +188,8 @@ config SND_SOC_SOF_INTEL_TGL
        tristate
        select SND_SOC_SOF_HDA_COMMON
        select SND_SOC_SOF_INTEL_SOUNDWIRE_LINK_BASELINE
+       select SND_SOC_SOF_IPC3
+       select SND_SOC_SOF_INTEL_IPC4
 
 config SND_SOC_SOF_TIGERLAKE
        tristate "SOF support for Tigerlake"
index c5aef5f..6ed3f9b 100644 (file)
@@ -155,12 +155,22 @@ struct snd_sof_ipc *snd_sof_ipc_init(struct snd_sof_dev *sdev)
 
        init_waitqueue_head(&msg->waitq);
 
-       /*
-        * Use IPC3 ops as it is the only available version now. With the addition of new IPC
-        * versions, this will need to be modified to use the selected version at runtime.
-        */
-       ipc->ops = &ipc3_ops;
-       ops = ipc->ops;
+       switch (sdev->pdata->ipc_type) {
+#if defined(CONFIG_SND_SOC_SOF_IPC3)
+       case SOF_IPC:
+               ops = &ipc3_ops;
+               break;
+#endif
+#if defined(CONFIG_SND_SOC_SOF_INTEL_IPC4)
+       case SOF_INTEL_IPC4:
+               ops = &ipc4_ops;
+               break;
+#endif
+       default:
+               dev_err(sdev->dev, "Not supported IPC version: %d\n",
+                       sdev->pdata->ipc_type);
+               return NULL;
+       }
 
        /* check for mandatory ops */
        if (!ops->tx_msg || !ops->rx_msg || !ops->set_get_data || !ops->get_reply) {
@@ -190,6 +200,8 @@ struct snd_sof_ipc *snd_sof_ipc_init(struct snd_sof_dev *sdev)
                return NULL;
        }
 
+       ipc->ops = ops;
+
        return ipc;
 }
 EXPORT_SYMBOL(snd_sof_ipc_init);
index a149dd1..4a2eddf 100644 (file)
@@ -15,6 +15,7 @@ config SND_SOC_SOF_MTK_COMMON
        tristate
        select SND_SOC_SOF_OF_DEV
        select SND_SOC_SOF
+       select SND_SOC_SOF_IPC3
        select SND_SOC_SOF_XTENSA
        select SND_SOC_SOF_COMPRESS
        help