diff --git a/Patchlist.changelog b/Patchlist.changelog index bc320476e..ba47a9dee 100644 --- a/Patchlist.changelog +++ b/Patchlist.changelog @@ -1,3 +1,6 @@ +"https://gitlab.com/cki-project/kernel-ark/-/commit"/2fa4b6a18ce384be968eda55c9cb12a6bb5cb4ca + 2fa4b6a18ce384be968eda55c9cb12a6bb5cb4ca ALSA: hda: cs35l41: Support mute notifications for CS35L41 HDA + "https://gitlab.com/cki-project/kernel-ark/-/commit"/0181cc27d637d9f2606dbf33fac4ddf5a64162ca 0181cc27d637d9f2606dbf33fac4ddf5a64162ca Add support for various laptops using CS35L41 HDA without _DSD diff --git a/kernel.spec b/kernel.spec index 956398398..aac941a1a 100644 --- a/kernel.spec +++ b/kernel.spec @@ -3709,6 +3709,9 @@ fi\ # # %changelog +* Wed Dec 20 2023 Justin M. Forbes [6.6.8-200] +- ALSA: hda: cs35l41: Support mute notifications for CS35L41 HDA (Stefan Binding) + * Wed Dec 20 2023 Augusto Caringi [6.6.8-0] - Add BugsFixed entries for rhbz#2254797 and #rhbz2254704 (Justin M. Forbes) - Add support for various laptops using CS35L41 HDA without _DSD (Stefan Binding) diff --git a/patch-6.6-redhat.patch b/patch-6.6-redhat.patch index df2bace2d..9303a25cf 100644 --- a/patch-6.6-redhat.patch +++ b/patch-6.6-redhat.patch @@ -35,11 +35,11 @@ security/lockdown/Kconfig | 13 + security/lockdown/lockdown.c | 1 + security/security.c | 12 + - sound/pci/hda/cs35l41_hda.c | 2 + - sound/pci/hda/cs35l41_hda.h | 5 +- + sound/pci/hda/cs35l41_hda.c | 106 +++++- + sound/pci/hda/cs35l41_hda.h | 8 +- sound/pci/hda/cs35l41_hda_property.c | 355 +++++++++++++++++++-- sound/pci/hda/patch_realtek.c | 38 ++- - 41 files changed, 1034 insertions(+), 228 deletions(-) + 41 files changed, 1128 insertions(+), 241 deletions(-) diff --git a/Makefile b/Makefile index 891ef640396c..9ecd654b31bf 100644 @@ -1562,18 +1562,191 @@ index 23b129d482a7..55d0fe0d121b 100644 /** * security_perf_event_open() - Check if a perf event open is allowed diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c -index 3c157b006a5a..a942fe807e12 100644 +index 3c157b006a5a..257f71e9ec07 100644 --- a/sound/pci/hda/cs35l41_hda.c +++ b/sound/pci/hda/cs35l41_hda.c -@@ -1684,6 +1684,7 @@ int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int i +@@ -33,6 +33,9 @@ + #define CAL_AMBIENT_DSP_CTL_NAME "CAL_AMBIENT" + #define CAL_DSP_CTL_TYPE 5 + #define CAL_DSP_CTL_ALG 205 ++#define CS35L41_UUID "50d90cdc-3de4-4f18-b528-c7fe3b71f40d" ++#define CS35L41_DSM_GET_MUTE 5 ++#define CS35L41_NOTIFY_EVENT 0x91 + + static bool firmware_autostart = 1; + module_param(firmware_autostart, bool, 0444); +@@ -563,6 +566,31 @@ static void cs35l41_hda_play_start(struct device *dev) + + } + ++static void cs35l41_mute(struct device *dev, bool mute) ++{ ++ struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); ++ struct regmap *reg = cs35l41->regmap; ++ ++ dev_dbg(dev, "Mute(%d:%d) Playback Started: %d\n", mute, cs35l41->mute_override, ++ cs35l41->playback_started); ++ ++ if (cs35l41->playback_started) { ++ if (mute || cs35l41->mute_override) { ++ dev_dbg(dev, "Muting\n"); ++ regmap_multi_reg_write(reg, cs35l41_hda_mute, ARRAY_SIZE(cs35l41_hda_mute)); ++ } else { ++ dev_dbg(dev, "Unmuting\n"); ++ if (cs35l41->firmware_running) { ++ regmap_multi_reg_write(reg, cs35l41_hda_unmute_dsp, ++ ARRAY_SIZE(cs35l41_hda_unmute_dsp)); ++ } else { ++ regmap_multi_reg_write(reg, cs35l41_hda_unmute, ++ ARRAY_SIZE(cs35l41_hda_unmute)); ++ } ++ } ++ } ++} ++ + static void cs35l41_hda_play_done(struct device *dev) + { + struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); +@@ -572,13 +600,7 @@ static void cs35l41_hda_play_done(struct device *dev) + + cs35l41_global_enable(dev, reg, cs35l41->hw_cfg.bst_type, 1, + cs35l41->firmware_running); +- if (cs35l41->firmware_running) { +- regmap_multi_reg_write(reg, cs35l41_hda_unmute_dsp, +- ARRAY_SIZE(cs35l41_hda_unmute_dsp)); +- } else { +- regmap_multi_reg_write(reg, cs35l41_hda_unmute, +- ARRAY_SIZE(cs35l41_hda_unmute)); +- } ++ cs35l41_mute(dev, false); + } + + static void cs35l41_hda_pause_start(struct device *dev) +@@ -588,7 +610,7 @@ static void cs35l41_hda_pause_start(struct device *dev) + + dev_dbg(dev, "Pause (Start)\n"); + +- regmap_multi_reg_write(reg, cs35l41_hda_mute, ARRAY_SIZE(cs35l41_hda_mute)); ++ cs35l41_mute(dev, true); + cs35l41_global_enable(dev, reg, cs35l41->hw_cfg.bst_type, 0, + cs35l41->firmware_running); + } +@@ -1116,6 +1138,53 @@ static int cs35l41_create_controls(struct cs35l41_hda *cs35l41) + return 0; + } + ++static bool cs35l41_dsm_supported(acpi_handle handle, unsigned int commands) ++{ ++ guid_t guid; ++ ++ guid_parse(CS35L41_UUID, &guid); ++ ++ return acpi_check_dsm(handle, &guid, 0, BIT(commands)); ++} ++ ++static int cs35l41_get_acpi_mute_state(struct cs35l41_hda *cs35l41, acpi_handle handle) ++{ ++ guid_t guid; ++ union acpi_object *ret; ++ int mute = -ENODEV; ++ ++ guid_parse(CS35L41_UUID, &guid); ++ ++ if (cs35l41_dsm_supported(handle, CS35L41_DSM_GET_MUTE)) { ++ ret = acpi_evaluate_dsm(handle, &guid, 0, CS35L41_DSM_GET_MUTE, NULL); ++ mute = *ret->buffer.pointer; ++ dev_dbg(cs35l41->dev, "CS35L41_DSM_GET_MUTE: %d\n", mute); ++ } ++ ++ dev_dbg(cs35l41->dev, "%s: %d\n", __func__, mute); ++ ++ return mute; ++} ++ ++static void cs35l41_acpi_device_notify(acpi_handle handle, u32 event, struct device *dev) ++{ ++ struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); ++ int mute; ++ ++ if (event != CS35L41_NOTIFY_EVENT) ++ return; ++ ++ mute = cs35l41_get_acpi_mute_state(cs35l41, handle); ++ if (mute < 0) { ++ dev_warn(cs35l41->dev, "Unable to retrieve mute state: %d\n", mute); ++ return; ++ } ++ ++ dev_dbg(cs35l41->dev, "Requesting mute value: %d\n", mute); ++ cs35l41->mute_override = (mute > 0); ++ cs35l41_mute(cs35l41->dev, cs35l41->mute_override); ++} ++ + static int cs35l41_hda_bind(struct device *dev, struct device *master, void *master_data) + { + struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); +@@ -1157,6 +1226,14 @@ static int cs35l41_hda_bind(struct device *dev, struct device *master, void *mas + comps->playback_hook = cs35l41_hda_playback_hook; + comps->pre_playback_hook = cs35l41_hda_pre_playback_hook; + comps->post_playback_hook = cs35l41_hda_post_playback_hook; ++ comps->acpi_notify = cs35l41_acpi_device_notify; ++ comps->adev = cs35l41->dacpi; ++ ++ comps->acpi_notifications_supported = cs35l41_dsm_supported(acpi_device_handle(comps->adev), ++ CS35L41_DSM_GET_MUTE); ++ ++ cs35l41->mute_override = cs35l41_get_acpi_mute_state(cs35l41, ++ acpi_device_handle(cs35l41->dacpi)) > 0; + + mutex_unlock(&cs35l41->fw_mutex); + +@@ -1430,8 +1507,8 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i + return -ENODEV; + } + ++ cs35l41->dacpi = adev; + physdev = get_device(acpi_get_first_physical_node(adev)); +- acpi_dev_put(adev); + + sub = acpi_get_subsystem_id(ACPI_HANDLE(physdev)); + if (IS_ERR(sub)) +@@ -1541,6 +1618,7 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i + hw_cfg->valid = false; + hw_cfg->gpio1.valid = false; + hw_cfg->gpio2.valid = false; ++ acpi_dev_put(cs35l41->dacpi); + put_physdev: + put_device(physdev); + +@@ -1644,10 +1722,7 @@ int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int i + if (ret) + goto err; + +- ret = regmap_multi_reg_write(cs35l41->regmap, cs35l41_hda_mute, +- ARRAY_SIZE(cs35l41_hda_mute)); +- if (ret) +- goto err; ++ cs35l41_mute(cs35l41->dev, true); + + INIT_WORK(&cs35l41->fw_load_work, cs35l41_fw_load_work); + mutex_init(&cs35l41->fw_mutex); +@@ -1684,6 +1759,8 @@ int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int i if (cs35l41_safe_reset(cs35l41->regmap, cs35l41->hw_cfg.bst_type)) gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); gpiod_put(cs35l41->reset_gpio); + gpiod_put(cs35l41->cs_gpio); ++ acpi_dev_put(cs35l41->dacpi); kfree(cs35l41->acpi_subsystem_id); return ret; -@@ -1708,6 +1709,7 @@ void cs35l41_hda_remove(struct device *dev) +@@ -1703,11 +1780,14 @@ void cs35l41_hda_remove(struct device *dev) + + component_del(cs35l41->dev, &cs35l41_hda_comp_ops); + ++ acpi_dev_put(cs35l41->dacpi); ++ + pm_runtime_put_noidle(cs35l41->dev); + if (cs35l41_safe_reset(cs35l41->regmap, cs35l41->hw_cfg.bst_type)) gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); gpiod_put(cs35l41->reset_gpio); @@ -1582,10 +1755,18 @@ index 3c157b006a5a..a942fe807e12 100644 } EXPORT_SYMBOL_NS_GPL(cs35l41_hda_remove, SND_HDA_SCODEC_CS35L41); diff --git a/sound/pci/hda/cs35l41_hda.h b/sound/pci/hda/cs35l41_hda.h -index b93bf762976e..2251027c2cf8 100644 +index b93bf762976e..3d925d677213 100644 --- a/sound/pci/hda/cs35l41_hda.h +++ b/sound/pci/hda/cs35l41_hda.h -@@ -34,8 +34,8 @@ struct cs35l41_amp_efi_data { +@@ -10,6 +10,7 @@ + #ifndef __CS35L41_HDA_H__ + #define __CS35L41_HDA_H__ + ++#include + #include + #include + #include +@@ -34,8 +35,8 @@ struct cs35l41_amp_efi_data { } __packed; enum cs35l41_hda_spk_pos { @@ -1596,7 +1777,7 @@ index b93bf762976e..2251027c2cf8 100644 }; enum cs35l41_hda_gpio_function { -@@ -49,6 +49,7 @@ struct cs35l41_hda { +@@ -49,6 +50,7 @@ struct cs35l41_hda { struct device *dev; struct regmap *regmap; struct gpio_desc *reset_gpio; @@ -1604,6 +1785,15 @@ index b93bf762976e..2251027c2cf8 100644 struct cs35l41_hw_cfg hw_cfg; struct hda_codec *codec; +@@ -70,6 +72,8 @@ struct cs35l41_hda { + bool halo_initialized; + bool playback_started; + struct cs_dsp cs_dsp; ++ struct acpi_device *dacpi; ++ bool mute_override; + }; + + enum halo_state { diff --git a/sound/pci/hda/cs35l41_hda_property.c b/sound/pci/hda/cs35l41_hda_property.c index b62a4e6968e2..c9eb70290973 100644 --- a/sound/pci/hda/cs35l41_hda_property.c diff --git a/sources b/sources index d69738d42..d662586a3 100644 --- a/sources +++ b/sources @@ -1,5 +1,5 @@ SHA512 (kernel-abi-stablelists-6.5.12.tar.bz2) = 7130ba0d72e398ae63bd0192e5e765885d8b932ff10c22f214821387588c358a21c8460561993baab0e5cd48afbad08db822cc49e5e3ae2d927b328de2072e7a SHA512 (kernel-kabi-dw-6.5.12.tar.bz2) = 7fc7372de576d1f3602abe70483edf30cf635a6d4175261bb44e1b7d4b413bc045b1e2affc0dbe6bf710a7c10b4a5c26c7fd47d8b8e7fe4bee2a25e2fd80b13a SHA512 (linux-6.6.8.tar.xz) = 7257f6784fb03fd341fa3d11430eb2427d2a873f5ce2e7bb489598f3f517a679eb0af41cb49f536fc9db8030ffca9f42d4c83b98c36d8f5d383b428eadbc3023 -SHA512 (kernel-abi-stablelists-6.6.8.tar.xz) = df15b5b7ddb46d1352260f1493f9ed6593bf140c6a0a4256928068b62ab33c2357f4f81bcba084617517d29c90076b1dcc30bccf4b656df9fca4fa18e333f745 -SHA512 (kernel-kabi-dw-6.6.8.tar.xz) = 5a92059ecae5240bd899db91ad3a1215e1b166c7cbcf51e1b01035e0e3942bcd2bcb1f5568cdac4950fb002f1ac34564204409102ef5da351024301f3e48a2d8 +SHA512 (kernel-abi-stablelists-6.6.8.tar.xz) = 68a6663ba0c94a74b534a4eb7c4595a5413868520aa8b0579aeee9763d12f0fce95da38509c6fa7471866845d78faf31c4265a610d11557d4dc78f665bfc8527 +SHA512 (kernel-kabi-dw-6.6.8.tar.xz) = a9eff532caf703ace81b5c0ff1ca0944824fd83385e8cce99719d1a673e4e57a8aed02dfaa42dfc50117f4409bffc4a5736225791ac12338f28a92d2cf68c1f8