ASoC: tegra: Avoid kernel version checks

Rather than using kernel version checks to determine which kernel APIs
to use, add the necessary tests to the conftest script to determine
which kernel APIs are present in the kernel.

Note that the function snd_soc_dai_init_dma_data() has been present
in the Linux kernel since v3.13 and so use this for all kernel versions.
In Linux v6.3, the 'playback_dma_data' and 'capture_dma_data' members of
the snd_soc_dai_driver structure were replaced and so these could no
longer be set directly. However, the arguments to
snd_soc_dai_init_dma_data() have not changed and so can be used for
older kernels and well has the current.

This is beneficial for working with 3rd party Linux kernels that may
have back-ported upstream changes into their kernel and so the kernel
version checks do not work.

Bug 4221847

Change-Id: Ibac0c6bab78e93f03981dfe3d1b2025ea19d4c92
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2993795
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Jon Hunter
2023-10-07 19:39:51 +01:00
committed by mobile promotions
parent 5ec164e7c3
commit 59b14ea0b8
19 changed files with 111 additions and 47 deletions

View File

@@ -3,7 +3,6 @@
* Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*/
#include <linux/version.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/of_platform.h>
@@ -237,13 +236,8 @@ static struct snd_soc_dai_ops tegra210_admaif_dai_ops = {
static int tegra210_admaif_dai_probe(struct snd_soc_dai *dai)
{
#if (KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE)
snd_soc_dai_init_dma_data(dai, &admaif->playback_dma_data[dai->id],
&admaif->capture_dma_data[dai->id]);
#else
dai->capture_dma_data = &admaif->capture_dma_data[dai->id];
dai->playback_dma_data = &admaif->playback_dma_data[dai->id];
#endif
return 0;
}

View File

@@ -4,6 +4,8 @@
//
// Copyright (c) 2015-2023, NVIDIA CORPORATION. All rights reserved.
#include <nvidia/conftest.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/device.h>
@@ -17,7 +19,6 @@
#ifdef CONFIG_TEGRA186_AHC
#include <linux/tegra186_ahc.h>
#endif
#include <linux/version.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@@ -536,7 +537,7 @@ static struct snd_soc_component_driver tegra186_arad_cmpnt = {
.num_dapm_routes = ARRAY_SIZE(tegra186_arad_routes),
.controls = tegra186_arad_controls,
.num_controls = ARRAY_SIZE(tegra186_arad_controls),
#if (KERNEL_VERSION(6, 0, 0) > LINUX_VERSION_CODE)
#if defined(NV_SND_SOC_COMPONENT_DRIVER_STRUCT_HAS_NON_LEGACY_DAI_NAMING) /* Linux v6.0 */
.non_legacy_dai_naming = 1,
#endif
};

View File

@@ -4,6 +4,8 @@
//
// Copyright (c) 2015-2023, NVIDIA CORPORATION. All rights reserved.
#include <nvidia/conftest.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/device.h>
@@ -17,7 +19,6 @@
#ifdef CONFIG_TEGRA186_AHC
#include <linux/tegra186_ahc.h>
#endif
#include <linux/version.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@@ -875,7 +876,7 @@ static struct snd_soc_component_driver tegra186_asrc_cmpnt = {
.num_dapm_routes = ARRAY_SIZE(tegra186_asrc_routes),
.controls = tegra186_asrc_controls,
.num_controls = ARRAY_SIZE(tegra186_asrc_controls),
#if (KERNEL_VERSION(6, 0, 0) > LINUX_VERSION_CODE)
#if defined(NV_SND_SOC_COMPONENT_DRIVER_STRUCT_HAS_NON_LEGACY_DAI_NAMING) /* Linux v6.0 */
.non_legacy_dai_naming = 1,
#endif
};

View File

@@ -4,6 +4,8 @@
//
// Copyright (c) 2020-2023 NVIDIA CORPORATION. All rights reserved.
#include <nvidia/conftest.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/module.h>
@@ -12,7 +14,6 @@
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/version.h>
#include <sound/core.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
@@ -564,7 +565,7 @@ static const struct snd_soc_component_driver tegra186_dspk_cmpnt = {
.num_dapm_routes = ARRAY_SIZE(tegra186_dspk_routes),
.controls = tegrat186_dspk_controls,
.num_controls = ARRAY_SIZE(tegrat186_dspk_controls),
#if (KERNEL_VERSION(6, 0, 0) > LINUX_VERSION_CODE)
#if defined(NV_SND_SOC_COMPONENT_DRIVER_STRUCT_HAS_NON_LEGACY_DAI_NAMING) /* Linux v6.0 */
.non_legacy_dai_naming = 1,
#endif
};

View File

@@ -4,7 +4,6 @@
//
// Copyright (c) 2020-2023 NVIDIA CORPORATION. All rights reserved.
#include <linux/version.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/module.h>
@@ -792,13 +791,9 @@ static int tegra_admaif_dai_probe(struct snd_soc_dai *dai)
{
struct tegra_admaif *admaif = snd_soc_dai_get_drvdata(dai);
#if (KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE)
snd_soc_dai_init_dma_data(dai, &admaif->playback_dma_data[dai->id],
&admaif->capture_dma_data[dai->id]);
#else
dai->capture_dma_data = &admaif->capture_dma_data[dai->id];
dai->playback_dma_data = &admaif->playback_dma_data[dai->id];
#endif
return 0;
}

View File

@@ -4,6 +4,8 @@
//
// Copyright (c) 2014-2023 NVIDIA CORPORATION. All rights reserved.
#include <nvidia/conftest.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/io.h>
@@ -13,7 +15,6 @@
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/version.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@@ -633,7 +634,7 @@ static struct snd_soc_component_driver tegra210_adx_cmpnt = {
.num_dapm_routes = ARRAY_SIZE(tegra210_adx_routes),
.controls = tegra210_adx_controls,
.num_controls = ARRAY_SIZE(tegra210_adx_controls),
#if (KERNEL_VERSION(6, 0, 0) > LINUX_VERSION_CODE)
#if defined(NV_SND_SOC_COMPONENT_DRIVER_STRUCT_HAS_NON_LEGACY_DAI_NAMING) /* Linux v6.0 */
.non_legacy_dai_naming = 1,
#endif
};

View File

@@ -4,6 +4,8 @@
//
// Copyright (c) 2014-2023 NVIDIA CORPORATION. All rights reserved.
#include <nvidia/conftest.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/io.h>
@@ -13,7 +15,6 @@
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/version.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@@ -396,7 +397,7 @@ static const struct snd_soc_component_driver tegra210_afc_cmpnt = {
.num_dapm_widgets = ARRAY_SIZE(tegra210_afc_widgets),
.dapm_routes = tegra210_afc_routes,
.num_dapm_routes = ARRAY_SIZE(tegra210_afc_routes),
#if (KERNEL_VERSION(6, 0, 0) > LINUX_VERSION_CODE)
#if defined(NV_SND_SOC_COMPONENT_DRIVER_STRUCT_HAS_NON_LEGACY_DAI_NAMING) /* Linux v6.0 */
.non_legacy_dai_naming = 1,
#endif
};
@@ -408,7 +409,7 @@ static const struct snd_soc_component_driver tegra186_afc_cmpnt = {
.num_dapm_routes = ARRAY_SIZE(tegra210_afc_routes),
.controls = tegra186_afc_controls,
.num_controls = ARRAY_SIZE(tegra186_afc_controls),
#if (KERNEL_VERSION(6, 0, 0) > LINUX_VERSION_CODE)
#if defined(NV_SND_SOC_COMPONENT_DRIVER_STRUCT_HAS_NON_LEGACY_DAI_NAMING) /* Linux v6.0 */
.non_legacy_dai_naming = 1,
#endif
};

View File

@@ -4,6 +4,8 @@
//
// Copyright (c) 2020-2023 NVIDIA CORPORATION. All rights reserved.
#include <nvidia/conftest.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/module.h>
@@ -11,7 +13,6 @@
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/version.h>
#include <sound/soc.h>
#include "tegra210_ahub.h"
@@ -1496,7 +1497,7 @@ static const struct snd_soc_component_driver tegra210_ahub_component = {
.num_dapm_widgets = ARRAY_SIZE(tegra210_ahub_widgets),
.dapm_routes = tegra210_ahub_routes,
.num_dapm_routes = ARRAY_SIZE(tegra210_ahub_routes),
#if (KERNEL_VERSION(6, 0, 0) > LINUX_VERSION_CODE)
#if defined(NV_SND_SOC_COMPONENT_DRIVER_STRUCT_HAS_NON_LEGACY_DAI_NAMING) /* Linux v6.0 */
.non_legacy_dai_naming = 1,
#endif
};
@@ -1506,7 +1507,7 @@ static const struct snd_soc_component_driver tegra186_ahub_component = {
.num_dapm_widgets = ARRAY_SIZE(tegra186_ahub_widgets),
.dapm_routes = tegra186_ahub_routes,
.num_dapm_routes = ARRAY_SIZE(tegra186_ahub_routes),
#if (KERNEL_VERSION(6, 0, 0) > LINUX_VERSION_CODE)
#if defined(NV_SND_SOC_COMPONENT_DRIVER_STRUCT_HAS_NON_LEGACY_DAI_NAMING) /* Linux v6.0 */
.non_legacy_dai_naming = 1,
#endif
};
@@ -1516,7 +1517,7 @@ static const struct snd_soc_component_driver tegra234_ahub_component = {
.num_dapm_widgets = ARRAY_SIZE(tegra234_ahub_widgets),
.dapm_routes = tegra186_ahub_routes,
.num_dapm_routes = ARRAY_SIZE(tegra186_ahub_routes),
#if (KERNEL_VERSION(6, 0, 0) > LINUX_VERSION_CODE)
#if defined(NV_SND_SOC_COMPONENT_DRIVER_STRUCT_HAS_NON_LEGACY_DAI_NAMING) /* Linux v6.0 */
.non_legacy_dai_naming = 1,
#endif
};

View File

@@ -4,6 +4,8 @@
//
// Copyright (c) 2014-2023 NVIDIA CORPORATION. All rights reserved.
#include <nvidia/conftest.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/io.h>
@@ -672,7 +674,7 @@ static struct snd_soc_component_driver tegra210_amx_cmpnt = {
.num_dapm_routes = ARRAY_SIZE(tegra210_amx_routes),
.controls = tegra210_amx_controls,
.num_controls = ARRAY_SIZE(tegra210_amx_controls),
#if (KERNEL_VERSION(6, 0, 0) > LINUX_VERSION_CODE)
#if defined(NV_SND_SOC_COMPONENT_DRIVER_STRUCT_HAS_NON_LEGACY_DAI_NAMING) /* Linux v6.0 */
.non_legacy_dai_naming = 1,
#endif
};

View File

@@ -4,6 +4,8 @@
//
// Copyright (c) 2020-2023 NVIDIA CORPORATION. All rights reserved.
#include <nvidia/conftest.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/math64.h>
@@ -12,7 +14,6 @@
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/version.h>
#include <sound/core.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
@@ -566,7 +567,7 @@ static const struct snd_soc_component_driver tegra210_dmic_compnt = {
.num_dapm_routes = ARRAY_SIZE(tegra210_dmic_routes),
.controls = tegra210_dmic_controls,
.num_controls = ARRAY_SIZE(tegra210_dmic_controls),
#if (KERNEL_VERSION(6, 0, 0) > LINUX_VERSION_CODE)
#if defined(NV_SND_SOC_COMPONENT_DRIVER_STRUCT_HAS_NON_LEGACY_DAI_NAMING) /* Linux v6.0 */
.non_legacy_dai_naming = 1,
#endif
};

View File

@@ -4,6 +4,8 @@
//
// Copyright (c) 2020-2023 NVIDIA CORPORATION. All rights reserved.
#include <nvidia/conftest.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/module.h>
@@ -11,7 +13,6 @@
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/version.h>
#include <sound/core.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
@@ -1127,7 +1128,7 @@ static const struct snd_soc_component_driver tegra210_i2s_cmpnt = {
.num_dapm_routes = ARRAY_SIZE(tegra210_i2s_routes),
.controls = tegra210_i2s_controls,
.num_controls = ARRAY_SIZE(tegra210_i2s_controls),
#if (KERNEL_VERSION(6, 0, 0) > LINUX_VERSION_CODE)
#if defined(NV_SND_SOC_COMPONENT_DRIVER_STRUCT_HAS_NON_LEGACY_DAI_NAMING) /* Linux v6.0 */
.non_legacy_dai_naming = 1,
#endif
};

View File

@@ -4,6 +4,8 @@
//
// Copyright (c) 2014-2023 NVIDIA CORPORATION. All rights reserved.
#include <nvidia/conftest.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/io.h>
@@ -13,7 +15,6 @@
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/version.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@@ -516,7 +517,7 @@ static struct snd_soc_component_driver tegra210_mixer_cmpnt = {
.num_dapm_routes = ARRAY_SIZE(tegra210_mixer_routes),
.controls = tegra210_mixer_gain_ctls,
.num_controls = ARRAY_SIZE(tegra210_mixer_gain_ctls),
#if (KERNEL_VERSION(6, 0, 0) > LINUX_VERSION_CODE)
#if defined(NV_SND_SOC_COMPONENT_DRIVER_STRUCT_HAS_NON_LEGACY_DAI_NAMING) /* Linux v6.0 */
.non_legacy_dai_naming = 1,
#endif
};

View File

@@ -4,6 +4,8 @@
//
// Copyright (c) 2014-2023 NVIDIA CORPORATION. All rights reserved.
#include <nvidia/conftest.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/io.h>
@@ -13,7 +15,6 @@
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/version.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@@ -620,7 +621,7 @@ static struct snd_soc_component_driver tegra210_mvc_cmpnt = {
.num_dapm_routes = ARRAY_SIZE(tegra210_mvc_routes),
.controls = tegra210_mvc_vol_ctrl,
.num_controls = ARRAY_SIZE(tegra210_mvc_vol_ctrl),
#if (KERNEL_VERSION(6, 0, 0) > LINUX_VERSION_CODE)
#if defined(NV_SND_SOC_COMPONENT_DRIVER_STRUCT_HAS_NON_LEGACY_DAI_NAMING) /* Linux v6.0 */
.non_legacy_dai_naming = 1,
#endif
};

View File

@@ -4,6 +4,8 @@
//
// Copyright (c) 2014-2023, NVIDIA CORPORATION. All rights reserved.
#include <nvidia/conftest.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/io.h>
@@ -13,7 +15,6 @@
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/version.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@@ -209,7 +210,7 @@ static struct snd_soc_component_driver tegra210_ope_cmpnt = {
.num_dapm_routes = ARRAY_SIZE(tegra210_ope_routes),
.controls = tegra210_ope_controls,
.num_controls = ARRAY_SIZE(tegra210_ope_controls),
#if (KERNEL_VERSION(6, 0, 0) > LINUX_VERSION_CODE)
#if defined(NV_SND_SOC_COMPONENT_DRIVER_STRUCT_HAS_NON_LEGACY_DAI_NAMING) /* Linux v6.0 */
.non_legacy_dai_naming = 1,
#endif
};

View File

@@ -4,6 +4,8 @@
//
// Copyright (c) 2014-2023 NVIDIA CORPORATION. All rights reserved.
#include <nvidia/conftest.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/io.h>
@@ -13,7 +15,6 @@
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/version.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@@ -3367,7 +3368,7 @@ static struct snd_soc_component_driver tegra210_sfc_cmpnt = {
.num_dapm_routes = ARRAY_SIZE(tegra210_sfc_routes),
.controls = tegra210_sfc_controls,
.num_controls = ARRAY_SIZE(tegra210_sfc_controls),
#if (KERNEL_VERSION(6, 0, 0) > LINUX_VERSION_CODE)
#if defined(NV_SND_SOC_COMPONENT_DRIVER_STRUCT_HAS_NON_LEGACY_DAI_NAMING) /* Linux v6.0 */
.non_legacy_dai_naming = 1,
#endif
};

View File

@@ -8,7 +8,6 @@
#include <dt-bindings/sound/tas2552.h>
#include <linux/input.h>
#include <linux/version.h>
#include <sound/jack.h>
#include <sound/soc.h>
#include <sound/simple_card_utils.h>
@@ -44,12 +43,12 @@ static int tegra_machine_rt56xx_init(struct snd_soc_pcm_runtime *rtd)
if (!jack)
return -ENOMEM;
#if (KERNEL_VERSION(5, 19, 0) > LINUX_VERSION_CODE)
err = snd_soc_card_jack_new(card, "Headset Jack", SND_JACK_HEADSET,
jack, NULL, 0);
#else
#if defined(NV_SND_SOC_CARD_JACK_NEW_HAS_NO_SND_SOC_JACK_PINS) /* Linux v5.19 */
err = snd_soc_card_jack_new(card, "Headset Jack", SND_JACK_HEADSET,
jack);
#else
err = snd_soc_card_jack_new(card, "Headset Jack", SND_JACK_HEADSET,
jack, NULL, 0);
#endif
if (err) {
dev_err(card->dev, "Headset Jack creation failed %d\n", err);

View File

@@ -5,6 +5,8 @@
#define pr_fmt(msg) "Safety I2S: " msg
#include <nvidia/conftest.h>
#include <linux/module.h>
#include <sound/core.h>
#include <sound/dmaengine_pcm.h>
@@ -13,7 +15,6 @@
#include <linux/dmaengine.h>
#include <linux/clk.h>
#include <linux/reset.h>
#include <linux/version.h>
#include "tegra_i2s.h"
@@ -456,7 +457,7 @@ static int gpcdma_hw_params(struct snd_pcm_substream *substream,
slave_config.src_maxburst = 2;
}
#if (KERNEL_VERSION(5, 17, 0) > LINUX_VERSION_CODE)
#if defined(NV_DMA_SLAVE_CONFIG_STRUCT_HAS_SLAVE_ID) /* Linux v5.17 */
//TODO: Read from DT later on
slave_config.slave_id = dma_data->req_sel;
#endif