mirror of
https://abf.rosa.ru/djam/kernel-5.15.git
synced 2025-02-23 18:42:55 +00:00
403 lines
14 KiB
Diff
403 lines
14 KiB
Diff
From 934a63001393268181d6ef91fa38b97d33cf319b Mon Sep 17 00:00:00 2001
|
|
From: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
|
|
Date: Thu, 16 Dec 2021 17:24:20 -0600
|
|
Subject: [PATCH 431/432] ASoC: SOF: avoid casting "const" attribute away
|
|
|
|
Casting "const" attribute away is dangerous, obtain a writable
|
|
pointer instead to avoid that.
|
|
|
|
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
|
|
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
|
|
Link: https://lore.kernel.org/r/20211216232422.345164-2-pierre-louis.bossart@linux.intel.com
|
|
Signed-off-by: Mark Brown <broonie@kernel.org>
|
|
|
|
[ mikhailnov:
|
|
dropped diff for sound/soc/sof/amd/renoir.c when backporting to 5.15
|
|
because that file does not exist ]
|
|
---
|
|
sound/soc/sof/intel/atom.c | 13 +++++----
|
|
sound/soc/sof/intel/atom.h | 4 +--
|
|
sound/soc/sof/intel/bdw.c | 11 +++----
|
|
sound/soc/sof/intel/hda.c | 60 ++++++++++++++++++--------------------
|
|
sound/soc/sof/intel/hda.h | 4 +--
|
|
sound/soc/sof/ops.h | 8 +++--
|
|
sound/soc/sof/sof-audio.c | 9 +++---
|
|
sound/soc/sof/sof-priv.h | 4 +--
|
|
8 files changed, 58 insertions(+), 55 deletions(-)
|
|
|
|
diff --git a/sound/soc/sof/intel/atom.c b/sound/soc/sof/intel/atom.c
|
|
index d8804efed..f2c1dcecb 100644
|
|
--- a/sound/soc/sof/intel/atom.c
|
|
+++ b/sound/soc/sof/intel/atom.c
|
|
@@ -337,7 +337,7 @@ static const char *fixup_tplg_name(struct snd_sof_dev *sdev,
|
|
return tplg_filename;
|
|
}
|
|
|
|
-void atom_machine_select(struct snd_sof_dev *sdev)
|
|
+struct snd_soc_acpi_mach *atom_machine_select(struct snd_sof_dev *sdev)
|
|
{
|
|
struct snd_sof_pdata *sof_pdata = sdev->pdata;
|
|
const struct sof_dev_desc *desc = sof_pdata->desc;
|
|
@@ -348,7 +348,7 @@ void atom_machine_select(struct snd_sof_dev *sdev)
|
|
mach = snd_soc_acpi_find_machine(desc->machines);
|
|
if (!mach) {
|
|
dev_warn(sdev->dev, "warning: No matching ASoC machine driver found\n");
|
|
- return;
|
|
+ return NULL;
|
|
}
|
|
|
|
pdev = to_platform_device(sdev->dev);
|
|
@@ -366,12 +366,13 @@ void atom_machine_select(struct snd_sof_dev *sdev)
|
|
if (!tplg_filename) {
|
|
dev_dbg(sdev->dev,
|
|
"error: no topology filename\n");
|
|
- return;
|
|
+ return NULL;
|
|
}
|
|
|
|
sof_pdata->tplg_filename = tplg_filename;
|
|
mach->mach_params.acpi_ipc_irq_index = desc->irqindex_host_ipc;
|
|
- sof_pdata->machine = mach;
|
|
+
|
|
+ return mach;
|
|
}
|
|
EXPORT_SYMBOL_NS(atom_machine_select, SND_SOC_SOF_INTEL_ATOM_HIFI_EP);
|
|
|
|
@@ -446,14 +447,14 @@ struct snd_soc_dai_driver atom_dai[] = {
|
|
};
|
|
EXPORT_SYMBOL_NS(atom_dai, SND_SOC_SOF_INTEL_ATOM_HIFI_EP);
|
|
|
|
-void atom_set_mach_params(const struct snd_soc_acpi_mach *mach,
|
|
+void atom_set_mach_params(struct snd_soc_acpi_mach *mach,
|
|
struct snd_sof_dev *sdev)
|
|
{
|
|
struct snd_sof_pdata *pdata = sdev->pdata;
|
|
const struct sof_dev_desc *desc = pdata->desc;
|
|
struct snd_soc_acpi_mach_params *mach_params;
|
|
|
|
- mach_params = (struct snd_soc_acpi_mach_params *)&mach->mach_params;
|
|
+ mach_params = &mach->mach_params;
|
|
mach_params->platform = dev_name(sdev->dev);
|
|
mach_params->num_dai_drivers = desc->ops->num_drv;
|
|
mach_params->dai_drivers = desc->ops->drv;
|
|
diff --git a/sound/soc/sof/intel/atom.h b/sound/soc/sof/intel/atom.h
|
|
index 96a462c7a..b965e5e08 100644
|
|
--- a/sound/soc/sof/intel/atom.h
|
|
+++ b/sound/soc/sof/intel/atom.h
|
|
@@ -65,8 +65,8 @@ int atom_run(struct snd_sof_dev *sdev);
|
|
int atom_reset(struct snd_sof_dev *sdev);
|
|
void atom_dump(struct snd_sof_dev *sdev, u32 flags);
|
|
|
|
-void atom_machine_select(struct snd_sof_dev *sdev);
|
|
-void atom_set_mach_params(const struct snd_soc_acpi_mach *mach,
|
|
+struct snd_soc_acpi_mach *atom_machine_select(struct snd_sof_dev *sdev);
|
|
+void atom_set_mach_params(struct snd_soc_acpi_mach *mach,
|
|
struct snd_sof_dev *sdev);
|
|
|
|
extern struct snd_soc_dai_driver atom_dai[];
|
|
diff --git a/sound/soc/sof/intel/bdw.c b/sound/soc/sof/intel/bdw.c
|
|
index 89a6c1f04..5e06a5876 100644
|
|
--- a/sound/soc/sof/intel/bdw.c
|
|
+++ b/sound/soc/sof/intel/bdw.c
|
|
@@ -541,7 +541,7 @@ static int bdw_probe(struct snd_sof_dev *sdev)
|
|
return ret;
|
|
}
|
|
|
|
-static void bdw_machine_select(struct snd_sof_dev *sdev)
|
|
+static struct snd_soc_acpi_mach *bdw_machine_select(struct snd_sof_dev *sdev)
|
|
{
|
|
struct snd_sof_pdata *sof_pdata = sdev->pdata;
|
|
const struct sof_dev_desc *desc = sof_pdata->desc;
|
|
@@ -550,22 +550,23 @@ static void bdw_machine_select(struct snd_sof_dev *sdev)
|
|
mach = snd_soc_acpi_find_machine(desc->machines);
|
|
if (!mach) {
|
|
dev_warn(sdev->dev, "warning: No matching ASoC machine driver found\n");
|
|
- return;
|
|
+ return NULL;
|
|
}
|
|
|
|
sof_pdata->tplg_filename = mach->sof_tplg_filename;
|
|
mach->mach_params.acpi_ipc_irq_index = desc->irqindex_host_ipc;
|
|
- sof_pdata->machine = mach;
|
|
+
|
|
+ return mach;
|
|
}
|
|
|
|
-static void bdw_set_mach_params(const struct snd_soc_acpi_mach *mach,
|
|
+static void bdw_set_mach_params(struct snd_soc_acpi_mach *mach,
|
|
struct snd_sof_dev *sdev)
|
|
{
|
|
struct snd_sof_pdata *pdata = sdev->pdata;
|
|
const struct sof_dev_desc *desc = pdata->desc;
|
|
struct snd_soc_acpi_mach_params *mach_params;
|
|
|
|
- mach_params = (struct snd_soc_acpi_mach_params *)&mach->mach_params;
|
|
+ mach_params = &mach->mach_params;
|
|
mach_params->platform = dev_name(sdev->dev);
|
|
mach_params->num_dai_drivers = desc->ops->num_drv;
|
|
mach_params->dai_drivers = desc->ops->drv;
|
|
diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c
|
|
index c2062d4d8..7efbe6125 100644
|
|
--- a/sound/soc/sof/intel/hda.c
|
|
+++ b/sound/soc/sof/intel/hda.c
|
|
@@ -1006,7 +1006,8 @@ int hda_dsp_remove(struct snd_sof_dev *sdev)
|
|
}
|
|
|
|
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
|
|
-static int hda_generic_machine_select(struct snd_sof_dev *sdev)
|
|
+static void hda_generic_machine_select(struct snd_sof_dev *sdev,
|
|
+ struct snd_soc_acpi_mach **mach)
|
|
{
|
|
struct hdac_bus *bus = sof_to_bus(sdev);
|
|
struct snd_soc_acpi_mach_params *mach_params;
|
|
@@ -1038,7 +1039,7 @@ static int hda_generic_machine_select(struct snd_sof_dev *sdev)
|
|
* - one HDMI codec, and/or
|
|
* - one external HDAudio codec
|
|
*/
|
|
- if (!pdata->machine && codec_num <= 2) {
|
|
+ if (!*mach && codec_num <= 2) {
|
|
hda_mach = snd_soc_acpi_intel_hda_machines;
|
|
|
|
dev_info(bus->dev, "using HDA machine driver %s now\n",
|
|
@@ -1053,10 +1054,9 @@ static int hda_generic_machine_select(struct snd_sof_dev *sdev)
|
|
tplg_filename = hda_mach->sof_tplg_filename;
|
|
ret = dmic_topology_fixup(sdev, &tplg_filename, idisp_str, &dmic_num);
|
|
if (ret < 0)
|
|
- return ret;
|
|
+ return;
|
|
|
|
hda_mach->mach_params.dmic_num = dmic_num;
|
|
- pdata->machine = hda_mach;
|
|
pdata->tplg_filename = tplg_filename;
|
|
|
|
if (codec_num == 2) {
|
|
@@ -1066,23 +1066,22 @@ static int hda_generic_machine_select(struct snd_sof_dev *sdev)
|
|
*/
|
|
hda_mach->mach_params.link_mask = 0;
|
|
}
|
|
+
|
|
+ *mach = hda_mach;
|
|
}
|
|
}
|
|
|
|
/* used by hda machine driver to create dai links */
|
|
- if (pdata->machine) {
|
|
- mach_params = (struct snd_soc_acpi_mach_params *)
|
|
- &pdata->machine->mach_params;
|
|
+ if (*mach) {
|
|
+ mach_params = &(*mach)->mach_params;
|
|
mach_params->codec_mask = bus->codec_mask;
|
|
mach_params->common_hdmi_codec_drv = hda_codec_use_common_hdmi;
|
|
}
|
|
-
|
|
- return 0;
|
|
}
|
|
#else
|
|
-static int hda_generic_machine_select(struct snd_sof_dev *sdev)
|
|
+static void hda_generic_machine_select(struct snd_sof_dev *sdev,
|
|
+ struct snd_soc_acpi_mach **mach)
|
|
{
|
|
- return 0;
|
|
}
|
|
#endif
|
|
|
|
@@ -1170,7 +1169,7 @@ static bool link_slaves_found(struct snd_sof_dev *sdev,
|
|
return true;
|
|
}
|
|
|
|
-static int hda_sdw_machine_select(struct snd_sof_dev *sdev)
|
|
+static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev)
|
|
{
|
|
struct snd_sof_pdata *pdata = sdev->pdata;
|
|
const struct snd_soc_acpi_link_adr *link;
|
|
@@ -1188,7 +1187,7 @@ static int hda_sdw_machine_select(struct snd_sof_dev *sdev)
|
|
* machines, for mixed cases with I2C/I2S the detection relies
|
|
* on the HID list.
|
|
*/
|
|
- if (link_mask && !pdata->machine) {
|
|
+ if (link_mask) {
|
|
for (mach = pdata->desc->alt_machines;
|
|
mach && mach->link_mask; mach++) {
|
|
/*
|
|
@@ -1223,7 +1222,6 @@ static int hda_sdw_machine_select(struct snd_sof_dev *sdev)
|
|
if (mach && mach->link_mask) {
|
|
int dmic_num = 0;
|
|
|
|
- pdata->machine = mach;
|
|
mach->mach_params.links = mach->links;
|
|
mach->mach_params.link_mask = mach->link_mask;
|
|
mach->mach_params.platform = dev_name(sdev->dev);
|
|
@@ -1245,9 +1243,8 @@ static int hda_sdw_machine_select(struct snd_sof_dev *sdev)
|
|
int ret;
|
|
|
|
ret = dmic_topology_fixup(sdev, &tplg_filename, "", &dmic_num);
|
|
-
|
|
if (ret < 0)
|
|
- return ret;
|
|
+ return NULL;
|
|
|
|
pdata->tplg_filename = tplg_filename;
|
|
}
|
|
@@ -1257,35 +1254,36 @@ static int hda_sdw_machine_select(struct snd_sof_dev *sdev)
|
|
"SoundWire machine driver %s topology %s\n",
|
|
mach->drv_name,
|
|
pdata->tplg_filename);
|
|
- } else {
|
|
- dev_info(sdev->dev,
|
|
- "No SoundWire machine driver found\n");
|
|
+
|
|
+ return mach;
|
|
}
|
|
+
|
|
+ dev_info(sdev->dev, "No SoundWire machine driver found\n");
|
|
}
|
|
|
|
- return 0;
|
|
+ return NULL;
|
|
}
|
|
#else
|
|
-static int hda_sdw_machine_select(struct snd_sof_dev *sdev)
|
|
+static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev)
|
|
{
|
|
- return 0;
|
|
+ return NULL;
|
|
}
|
|
#endif
|
|
|
|
-void hda_set_mach_params(const struct snd_soc_acpi_mach *mach,
|
|
+void hda_set_mach_params(struct snd_soc_acpi_mach *mach,
|
|
struct snd_sof_dev *sdev)
|
|
{
|
|
struct snd_sof_pdata *pdata = sdev->pdata;
|
|
const struct sof_dev_desc *desc = pdata->desc;
|
|
struct snd_soc_acpi_mach_params *mach_params;
|
|
|
|
- mach_params = (struct snd_soc_acpi_mach_params *)&mach->mach_params;
|
|
+ mach_params = &mach->mach_params;
|
|
mach_params->platform = dev_name(sdev->dev);
|
|
mach_params->num_dai_drivers = desc->ops->num_drv;
|
|
mach_params->dai_drivers = desc->ops->drv;
|
|
}
|
|
|
|
-void hda_machine_select(struct snd_sof_dev *sdev)
|
|
+struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev)
|
|
{
|
|
struct snd_sof_pdata *sof_pdata = sdev->pdata;
|
|
const struct sof_dev_desc *desc = sof_pdata->desc;
|
|
@@ -1303,8 +1301,6 @@ void hda_machine_select(struct snd_sof_dev *sdev)
|
|
if (!sof_pdata->tplg_filename)
|
|
sof_pdata->tplg_filename = mach->sof_tplg_filename;
|
|
|
|
- sof_pdata->machine = mach;
|
|
-
|
|
if (mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER &&
|
|
mach->mach_params.dmic_num) {
|
|
tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL,
|
|
@@ -1366,16 +1362,18 @@ void hda_machine_select(struct snd_sof_dev *sdev)
|
|
/*
|
|
* If I2S fails, try SoundWire
|
|
*/
|
|
- hda_sdw_machine_select(sdev);
|
|
+ if (!mach)
|
|
+ mach = hda_sdw_machine_select(sdev);
|
|
|
|
/*
|
|
* Choose HDA generic machine driver if mach is NULL.
|
|
* Otherwise, set certain mach params.
|
|
*/
|
|
- hda_generic_machine_select(sdev);
|
|
-
|
|
- if (!sof_pdata->machine)
|
|
+ hda_generic_machine_select(sdev, &mach);
|
|
+ if (!mach)
|
|
dev_warn(sdev->dev, "warning: No matching ASoC machine driver found\n");
|
|
+
|
|
+ return mach;
|
|
}
|
|
|
|
int hda_pci_intel_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
|
|
diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h
|
|
index 4fdfb1086..9091c7f38 100644
|
|
--- a/sound/soc/sof/intel/hda.h
|
|
+++ b/sound/soc/sof/intel/hda.h
|
|
@@ -767,8 +767,8 @@ extern const struct sof_intel_dsp_desc jsl_chip_info;
|
|
extern const struct sof_intel_dsp_desc adls_chip_info;
|
|
|
|
/* machine driver select */
|
|
-void hda_machine_select(struct snd_sof_dev *sdev);
|
|
-void hda_set_mach_params(const struct snd_soc_acpi_mach *mach,
|
|
+struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev);
|
|
+void hda_set_mach_params(struct snd_soc_acpi_mach *mach,
|
|
struct snd_sof_dev *sdev);
|
|
|
|
/* PCI driver selection and probe */
|
|
diff --git a/sound/soc/sof/ops.h b/sound/soc/sof/ops.h
|
|
index 4a5d6e497..96833cde0 100644
|
|
--- a/sound/soc/sof/ops.h
|
|
+++ b/sound/soc/sof/ops.h
|
|
@@ -488,15 +488,17 @@ snd_sof_machine_unregister(struct snd_sof_dev *sdev, void *pdata)
|
|
sof_ops(sdev)->machine_unregister(sdev, pdata);
|
|
}
|
|
|
|
-static inline void
|
|
+static inline struct snd_soc_acpi_mach *
|
|
snd_sof_machine_select(struct snd_sof_dev *sdev)
|
|
{
|
|
if (sof_ops(sdev) && sof_ops(sdev)->machine_select)
|
|
- sof_ops(sdev)->machine_select(sdev);
|
|
+ return sof_ops(sdev)->machine_select(sdev);
|
|
+
|
|
+ return NULL;
|
|
}
|
|
|
|
static inline void
|
|
-snd_sof_set_mach_params(const struct snd_soc_acpi_mach *mach,
|
|
+snd_sof_set_mach_params(struct snd_soc_acpi_mach *mach,
|
|
struct snd_sof_dev *sdev)
|
|
{
|
|
if (sof_ops(sdev) && sof_ops(sdev)->set_mach_params)
|
|
diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c
|
|
index 989912f2b..10e39777d 100644
|
|
--- a/sound/soc/sof/sof-audio.c
|
|
+++ b/sound/soc/sof/sof-audio.c
|
|
@@ -500,9 +500,10 @@ int sof_machine_check(struct snd_sof_dev *sdev)
|
|
if (!IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE)) {
|
|
|
|
/* find machine */
|
|
- snd_sof_machine_select(sdev);
|
|
- if (sof_pdata->machine) {
|
|
- snd_sof_set_mach_params(sof_pdata->machine, sdev);
|
|
+ mach = snd_sof_machine_select(sdev);
|
|
+ if (mach) {
|
|
+ sof_pdata->machine = mach;
|
|
+ snd_sof_set_mach_params(mach, sdev);
|
|
return 0;
|
|
}
|
|
|
|
@@ -524,7 +525,7 @@ int sof_machine_check(struct snd_sof_dev *sdev)
|
|
sof_pdata->tplg_filename = desc->nocodec_tplg_filename;
|
|
|
|
sof_pdata->machine = mach;
|
|
- snd_sof_set_mach_params(sof_pdata->machine, sdev);
|
|
+ snd_sof_set_mach_params(mach, sdev);
|
|
|
|
return 0;
|
|
}
|
|
diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h
|
|
index fd8423172..eb67a9b46 100644
|
|
--- a/sound/soc/sof/sof-priv.h
|
|
+++ b/sound/soc/sof/sof-priv.h
|
|
@@ -257,8 +257,8 @@ struct snd_sof_dsp_ops {
|
|
void *pdata); /* optional */
|
|
void (*machine_unregister)(struct snd_sof_dev *sdev,
|
|
void *pdata); /* optional */
|
|
- void (*machine_select)(struct snd_sof_dev *sdev); /* optional */
|
|
- void (*set_mach_params)(const struct snd_soc_acpi_mach *mach,
|
|
+ struct snd_soc_acpi_mach * (*machine_select)(struct snd_sof_dev *sdev); /* optional */
|
|
+ void (*set_mach_params)(struct snd_soc_acpi_mach *mach,
|
|
struct snd_sof_dev *sdev); /* optional */
|
|
|
|
/* DAI ops */
|
|
--
|
|
2.35.2
|
|
|