]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ASoC: SOF: remove const qualifier for 'struct snd_sof_dsp_ops'
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Thu, 14 Apr 2022 18:48:10 +0000 (13:48 -0500)
committerMark Brown <broonie@kernel.org>
Tue, 19 Apr 2022 11:03:39 +0000 (12:03 +0100)
Now that we start having multiple platforms with minor variants, the
use of the const qualifier for 'dsp_ops' is starting to be
sub-optimal: the structures are copied across platforms, with only a
couple of members that differ.

This patch removes the const qualifier without any functionality
changes, and adds an optional initialization callback. In follow-up
patches, the dsp_ops will revisited for Intel HDaudio platforms, with
the differences added programmatically over a common baseline.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20220414184817.362215-9-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 files changed:
include/sound/sof.h
sound/soc/sof/amd/acp.h
sound/soc/sof/amd/renoir.c
sound/soc/sof/core.c
sound/soc/sof/debug.c
sound/soc/sof/imx/imx8.c
sound/soc/sof/imx/imx8m.c
sound/soc/sof/intel/apl.c
sound/soc/sof/intel/bdw.c
sound/soc/sof/intel/byt.c
sound/soc/sof/intel/cnl.c
sound/soc/sof/intel/hda.h
sound/soc/sof/intel/icl.c
sound/soc/sof/intel/pci-tng.c
sound/soc/sof/intel/shim.h
sound/soc/sof/intel/tgl.c
sound/soc/sof/mediatek/mt8195/mt8195.c
sound/soc/sof/ops.h
sound/soc/sof/pcm.c

index 96997650be6513fa0aa52e54449260b19561c323..1a82a0db5e7f065baf833454f1b0b3be506928fe 100644 (file)
@@ -16,6 +16,7 @@
 #include <sound/soc-acpi.h>
 
 struct snd_sof_dsp_ops;
+struct snd_sof_dev;
 
 /**
  * enum sof_fw_state - DSP firmware state definitions
@@ -135,7 +136,8 @@ struct sof_dev_desc {
        /* default firmware name */
        const char *default_fw_filename[SOF_IPC_TYPE_COUNT];
 
-       const struct snd_sof_dsp_ops *ops;
+       struct snd_sof_dsp_ops *ops;
+       int (*ops_init)(struct snd_sof_dev *sdev);
 };
 
 int sof_dai_get_mclk(struct snd_soc_pcm_runtime *rtd);
index 35e46fe6676ab25c2ebfae4ad644ee04181686b3..ca69b4969ca22bc15c1b5137c7415c133a933804 100644 (file)
@@ -204,7 +204,7 @@ int acp_pcm_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_substream *substr
                      struct snd_pcm_hw_params *params,
                      struct snd_sof_platform_stream_params *platform_params);
 
-extern const struct snd_sof_dsp_ops sof_renoir_ops;
+extern struct snd_sof_dsp_ops sof_renoir_ops;
 
 /* Machine configuration */
 int snd_amd_acp_find_config(struct pci_dev *pci);
index 409fd57448b82b01dd166454ddedac569294026d..73f639fa16a4252649466f7131886df9fcf7a3d6 100644 (file)
@@ -123,7 +123,7 @@ static struct snd_soc_acpi_mach *amd_sof_machine_select(struct snd_sof_dev *sdev
 }
 
 /* AMD Renoir DSP ops */
-const struct snd_sof_dsp_ops sof_renoir_ops = {
+struct snd_sof_dsp_ops sof_renoir_ops = {
        /* probe and remove */
        .probe                  = amd_sof_acp_probe,
        .remove                 = amd_sof_acp_remove,
index e91631618bff38a3239d38db042618b66d8a3fef..27a98867f999df15133a34fd00c5bbdaab41db52 100644 (file)
@@ -357,6 +357,9 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data)
        sdev->first_boot = true;
        dev_set_drvdata(dev, sdev);
 
+       /* init ops, if necessary */
+       sof_ops_init(sdev);
+
        /* check all mandatory ops */
        if (!sof_ops(sdev) || !sof_ops(sdev)->probe || !sof_ops(sdev)->run ||
            !sof_ops(sdev)->block_read || !sof_ops(sdev)->block_write ||
index 8a77245b51825f1c3dcb33b748bca926ce05fed1..b59619ecfacfce6a61cd60fc8d115c205c497160 100644 (file)
@@ -331,7 +331,7 @@ EXPORT_SYMBOL_GPL(snd_sof_dbg_memory_info_init);
 
 int snd_sof_dbg_init(struct snd_sof_dev *sdev)
 {
-       const struct snd_sof_dsp_ops *ops = sof_ops(sdev);
+       struct snd_sof_dsp_ops *ops = sof_ops(sdev);
        const struct snd_sof_debugfs_map *map;
        int i;
        int err;
index db53be8253840056adc79af4fc4a03d7ca1214fd..d3a60c8e42cc269eb081bd2fca067a944008027b 100644 (file)
@@ -487,7 +487,7 @@ static int imx8_dsp_set_power_state(struct snd_sof_dev *sdev,
 }
 
 /* i.MX8 ops */
-static const struct snd_sof_dsp_ops sof_imx8_ops = {
+static struct snd_sof_dsp_ops sof_imx8_ops = {
        /* probe and remove */
        .probe          = imx8_probe,
        .remove         = imx8_remove,
@@ -550,7 +550,7 @@ static const struct snd_sof_dsp_ops sof_imx8_ops = {
 };
 
 /* i.MX8X ops */
-static const struct snd_sof_dsp_ops sof_imx8x_ops = {
+static struct snd_sof_dsp_ops sof_imx8x_ops = {
        /* probe and remove */
        .probe          = imx8_probe,
        .remove         = imx8_remove,
index 196ca7d7521fdcc89e5176afaa1571b6c4df9b7c..8e9ae08dc7b00dff954ed00be6f36153fd199b2e 100644 (file)
@@ -412,7 +412,7 @@ static int imx8m_dsp_suspend(struct snd_sof_dev *sdev, unsigned int target_state
 }
 
 /* i.MX8 ops */
-static const struct snd_sof_dsp_ops sof_imx8m_ops = {
+static struct snd_sof_dsp_ops sof_imx8m_ops = {
        /* probe and remove */
        .probe          = imx8m_probe,
        .remove         = imx8m_remove,
index 6721c8f95161b13de92ec9681109e244808a9bf4..518d543591b561cf6436d77b619fc67ae0450396 100644 (file)
@@ -26,7 +26,7 @@ static const struct snd_sof_debugfs_map apl_dsp_debugfs[] = {
 };
 
 /* apollolake ops */
-const struct snd_sof_dsp_ops sof_apl_ops = {
+struct snd_sof_dsp_ops sof_apl_ops = {
        /* probe/remove/shutdown */
        .probe          = hda_dsp_probe,
        .remove         = hda_dsp_remove,
index efdc9e6282f3c69756eae97ca87a696e2ec5f206..3449eeccd9e8ef4132217ddf210209c1f6cc2038 100644 (file)
@@ -567,7 +567,7 @@ static struct snd_soc_dai_driver bdw_dai[] = {
 };
 
 /* broadwell ops */
-static const struct snd_sof_dsp_ops sof_bdw_ops = {
+static struct snd_sof_dsp_ops sof_bdw_ops = {
        /*Device init */
        .probe          = bdw_probe,
 
index 748d1452d4d8fcbf20de71d682d0467de68aacc9..3db125d82a1e5abfb72d8ab4856316395c9a20da 100644 (file)
@@ -216,7 +216,7 @@ irq:
 }
 
 /* baytrail ops */
-static const struct snd_sof_dsp_ops sof_byt_ops = {
+static struct snd_sof_dsp_ops sof_byt_ops = {
        /* device init */
        .probe          = byt_acpi_probe,
        .remove         = byt_remove,
@@ -298,7 +298,7 @@ static const struct sof_intel_dsp_desc byt_chip_info = {
 };
 
 /* cherrytrail and braswell ops */
-static const struct snd_sof_dsp_ops sof_cht_ops = {
+static struct snd_sof_dsp_ops sof_cht_ops = {
        /* device init */
        .probe          = byt_acpi_probe,
        .remove         = byt_remove,
index 6a96470b967f5c57ea158f61c831e220407d717e..81fe490c7f77a21fe94e3154ce677b95fa0b05a6 100644 (file)
@@ -244,7 +244,7 @@ void cnl_ipc_dump(struct snd_sof_dev *sdev)
 }
 
 /* cannonlake ops */
-const struct snd_sof_dsp_ops sof_cnl_ops = {
+struct snd_sof_dsp_ops sof_cnl_ops = {
        /* probe/remove/shutdown */
        .probe          = hda_dsp_probe,
        .remove         = hda_dsp_remove,
index 05e5e158614a1ed6c0fbbb56de6c78d996e82df5..c7e2482805279b5eab9ada9932606d1f877fcbbe 100644 (file)
@@ -687,10 +687,10 @@ extern struct snd_soc_dai_driver skl_dai[];
 /*
  * Platform Specific HW abstraction Ops.
  */
-extern const struct snd_sof_dsp_ops sof_apl_ops;
-extern const struct snd_sof_dsp_ops sof_cnl_ops;
-extern const struct snd_sof_dsp_ops sof_tgl_ops;
-extern const struct snd_sof_dsp_ops sof_icl_ops;
+extern struct snd_sof_dsp_ops sof_apl_ops;
+extern struct snd_sof_dsp_ops sof_cnl_ops;
+extern struct snd_sof_dsp_ops sof_tgl_ops;
+extern struct snd_sof_dsp_ops sof_icl_ops;
 
 extern const struct sof_intel_dsp_desc apl_chip_info;
 extern const struct sof_intel_dsp_desc cnl_chip_info;
index b44a649bfc0b4fd881fe22b90fb9f7633805c763..da1e6dc4dc8514cb7832ddc3f41a7239b83ccd3b 100644 (file)
@@ -88,7 +88,7 @@ static int icl_dsp_post_fw_run(struct snd_sof_dev *sdev)
 }
 
 /* Icelake ops */
-const struct snd_sof_dsp_ops sof_icl_ops = {
+struct snd_sof_dsp_ops sof_icl_ops = {
        /* probe/remove/shutdown */
        .probe          = hda_dsp_probe,
        .remove         = hda_dsp_remove,
index 38ce6fd838b58dc56885faf82274b99d17521584..ca313c7db47ebee2e618eb9550907f158eb7f657 100644 (file)
@@ -136,7 +136,7 @@ irq:
        return ret;
 }
 
-const struct snd_sof_dsp_ops sof_tng_ops = {
+struct snd_sof_dsp_ops sof_tng_ops = {
        /* device init */
        .probe          = tangier_pci_probe,
 
index f36cd9d5eb946e640376a946e53d5a48b06dc9b4..80c61a7cedf6d693a14b23900ff106474e4de4b6 100644 (file)
@@ -173,7 +173,7 @@ struct sof_intel_dsp_desc {
        bool (*check_sdw_irq)(struct snd_sof_dev *sdev);
 };
 
-extern const struct snd_sof_dsp_ops sof_tng_ops;
+extern struct snd_sof_dsp_ops sof_tng_ops;
 
 extern const struct sof_intel_dsp_desc tng_chip_info;
 
index 72d92ff6cef5a8c3d7aa3625fec9ac9a2b1641ea..2bb32bbce426cb41a39828b07c528501d7948267 100644 (file)
@@ -59,7 +59,7 @@ static int tgl_dsp_core_put(struct snd_sof_dev *sdev, int core)
 }
 
 /* Tigerlake ops */
-const struct snd_sof_dsp_ops sof_tgl_ops = {
+struct snd_sof_dsp_ops sof_tgl_ops = {
        /* probe/remove/shutdown */
        .probe          = hda_dsp_probe,
        .remove         = hda_dsp_remove,
index 5085a3ac3da8d5849213d32878d9e39f7bd1804a..90ec7b14823bbd51151291443c8c15312b1f65f4 100644 (file)
@@ -393,7 +393,7 @@ static struct snd_soc_dai_driver mt8195_dai[] = {
 };
 
 /* mt8195 ops */
-static const struct snd_sof_dsp_ops sof_mt8195_ops = {
+static struct snd_sof_dsp_ops sof_mt8195_ops = {
        /* probe and remove */
        .probe          = mt8195_dsp_probe,
        .remove         = mt8195_dsp_remove,
index a194746637673b462d196925ab85b906eb9edbba..d866a96ba0d99245b8eea1609ef51fe28e64adf8 100644 (file)
 #define sof_ops(sdev) \
        ((sdev)->pdata->desc->ops)
 
+static inline void sof_ops_init(struct snd_sof_dev *sdev)
+{
+       if (sdev->pdata->desc->ops_init)
+               sdev->pdata->desc->ops_init(sdev);
+}
+
 /* Mandatory operations are verified during probing */
 
 /* init */
index b5cbc8b5c0ee1917ed81256d1d340beaed00e5e3..6242327e663e84b1372a2f8bcbbb194faf2bcaa0 100644 (file)
@@ -393,7 +393,7 @@ static int sof_pcm_open(struct snd_soc_component *component,
        struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
        struct snd_pcm_runtime *runtime = substream->runtime;
        struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
-       const struct snd_sof_dsp_ops *ops = sof_ops(sdev);
+       struct snd_sof_dsp_ops *ops = sof_ops(sdev);
        struct snd_sof_pcm *spcm;
        struct snd_soc_tplg_stream_caps *caps;
        int ret;