From 52a4903b87bfd8b526435e4370f233f168646375 Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Tue, 3 Dec 2024 22:52:47 +0000 Subject: [PATCH] ASoC: tegra: Fix build for Linux v6.13 In Linux v6.13, commit 1bd775da9ba9 ("ASoC: add symmetric_ prefix for dai->rate/channels/sample_bits") added a 'symmetric_' prefix to some member of the 'snd_soc_dai' structure. Use conftest to determine if these structure members have the 'symmetric_' prefix and update the Tegra Mixer Control driver accordingly. Bug 4991705 Change-Id: I366595f31932caaa447033c0d0e3b1d2b8dba6e3 Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3261697 GVS: buildbot_gerritrpt Reviewed-by: Sameer Pujar Tested-by: mobile promotions Reviewed-by: mobile promotions --- scripts/conftest/Makefile | 1 + scripts/conftest/conftest.sh | 18 ++++++++++ sound/soc/tegra/tegra_mixer_control.c | 51 +++++++++++++++++++++------ 3 files changed, 60 insertions(+), 10 deletions(-) diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index 7c7fec32..b9888a60 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -181,6 +181,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += snd_soc_card_jack_new_has_no_snd_soc_jack_ NV_CONFTEST_FUNCTION_COMPILE_TESTS += snd_soc_component_driver_struct_has_non_legacy_dai_naming NV_CONFTEST_FUNCTION_COMPILE_TESTS += snd_soc_dai_link_struct_has_c2c_params_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += snd_soc_dai_ops_struct_has_probe +NV_CONFTEST_FUNCTION_COMPILE_TESTS += snd_soc_dai_struct_has_symmetric_prefix NV_CONFTEST_FUNCTION_COMPILE_TESTS += snd_soc_of_get_dai_name_has_index_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += snd_soc_rtd_to_codec NV_CONFTEST_FUNCTION_COMPILE_TESTS += simple_util_dai_init diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index 6d9bb238..e6a5e8a7 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -8034,6 +8034,24 @@ compile_test() { compile_check_conftest "$CODE" "NV_SND_SOC_DAI_OPS_STRUCT_HAS_PROBE_PRESENT" "" "types" ;; + snd_soc_dai_struct_has_symmetric_prefix) + # + # Determine if the rate/channels/sample_bits members of the + # snd_soc_dai structure have a 'symmetric_' prefix. + # + # Commit 1bd775da9ba9 ("ASoC: add symmetric_ prefix for + # dai->rate/channels/sample_bits") added a 'symmetric_' prefix to + # members of the snd_soc_dai structure in Linux v6.13. + # + CODE=" + #include + unsigned int conftest_snd_soc_dai_struct_has_symmetric_prefix(struct snd_soc_dai *dai) { + return dai->symmetric_rate; + }" + + compile_check_conftest "$CODE" "NV_SND_SOC_DAI_STRUCT_HAS_SYMMETRIC_PREFIX" "" "types" + ;; + snd_soc_of_get_dai_name_has_index_arg) # # Determine if the function 'snd_soc_of_get_dai_name()' has an index argument. diff --git a/sound/soc/tegra/tegra_mixer_control.c b/sound/soc/tegra/tegra_mixer_control.c index 9ea0684d..3fe46fd8 100644 --- a/sound/soc/tegra/tegra_mixer_control.c +++ b/sound/soc/tegra/tegra_mixer_control.c @@ -55,7 +55,11 @@ static int dai_get_rate(struct snd_kcontrol *kcontrol, if (i++ != reg) continue; +#if defined(NV_SND_SOC_DAI_STRUCT_HAS_SYMMETRIC_PREFIX) /* Linux v6.13 */ + ucontrol->value.integer.value[0] = dai->symmetric_rate; +#else ucontrol->value.integer.value[0] = dai->rate; +#endif break; } @@ -78,7 +82,11 @@ static int dai_put_rate(struct snd_kcontrol *kcontrol, if (i++ != reg) continue; +#if defined(NV_SND_SOC_DAI_STRUCT_HAS_SYMMETRIC_PREFIX) /* Linux v6.13 */ + dai->symmetric_rate = value; +#else dai->rate = value; +#endif change = true; break; @@ -100,7 +108,11 @@ static int dai_get_channel(struct snd_kcontrol *kcontrol, if (i++ != reg) continue; +#if defined(NV_SND_SOC_DAI_STRUCT_HAS_SYMMETRIC_PREFIX) /* Linux v6.13 */ + ucontrol->value.integer.value[0] = dai->symmetric_channels; +#else ucontrol->value.integer.value[0] = dai->channels; +#endif break; } @@ -122,7 +134,11 @@ static int dai_put_channel(struct snd_kcontrol *kcontrol, if (i++ != reg) continue; +#if defined(NV_SND_SOC_DAI_STRUCT_HAS_SYMMETRIC_PREFIX) /* Linux v6.13 */ + dai->symmetric_channels = value; +#else dai->channels = value; +#endif change = true; break; @@ -144,7 +160,11 @@ static int dai_get_bits(struct snd_kcontrol *kcontrol, if (i++ != reg) continue; +#if defined(NV_SND_SOC_DAI_STRUCT_HAS_SYMMETRIC_PREFIX) /* Linux v6.13 */ + ucontrol->value.integer.value[0] = dai->symmetric_sample_bits; +#else ucontrol->value.integer.value[0] = dai->sample_bits; +#endif break; } @@ -166,7 +186,11 @@ static int dai_put_bits(struct snd_kcontrol *kcontrol, if (i++ != reg) continue; +#if defined(NV_SND_SOC_DAI_STRUCT_HAS_SYMMETRIC_PREFIX) /* Linux v6.13 */ + dai->symmetric_sample_bits = value; +#else dai->sample_bits = value; +#endif change = true; break; @@ -305,21 +329,28 @@ static void tegra_dai_fixup(struct snd_soc_dai *dai, SNDRV_PCM_HW_PARAM_CHANNELS); struct snd_mask *mask = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); + unsigned int d_rate, d_channels, d_sample_bits; - if (dai->rate) { - rate->min = - rate->max = dai->rate; - } +#if defined(NV_SND_SOC_DAI_STRUCT_HAS_SYMMETRIC_PREFIX) /* Linux v6.13 */ + d_rate = dai->symmetric_rate; + d_channels = dai->symmetric_channels; + d_sample_bits = dai->symmetric_sample_bits; +#else + d_rate = dai->rate; + d_channels = dai->channels; + d_sample_bits = dai->sample_bits; +#endif - if (dai->channels) { - channels->min = - channels->max = dai->channels; - } + if (d_rate) + rate->min = rate->max = d_rate; - if (dai->sample_bits) { + if (d_channels) + channels->min = channels->max = d_channels; + + if (d_sample_bits) { snd_mask_none(mask); - switch (dai->sample_bits) { + switch (d_sample_bits) { case 8: snd_mask_set(mask, SNDRV_PCM_FORMAT_S8); break;