ALSA: Add support for new HP G12 laptops
Subsystems (4)
v2 cover ALSA: Add support for new HP G12 laptops
Add support for HP G12 laptops that use CS35L54 or CS35L56 amplifiers with Realtek HDA codecs. Some of these use the same SSID for models with CS35L54 and models with CS35L56 so the ACPI entries are examined to determine which amp is present.
To avoid having to #ifdef around this code we've fixed the definitions of SPI and I2C functions that were not correctly supplying dummy functions when the real functions are not in the build.
Changes since V1:
Added I2C and SPI patches to provide dummy functions.
Richard Fitzgerald (2):
spi: Add empty versions of ACPI functions
i2c: Fix conditional for substituting empty ACPI functions
Simon Trimmer (1):
ALSA: hda/realtek: Add support for new HP G12 laptops
include/linux/i2c.h | 2 +- include/linux/spi/spi.h | 19 ++++++- sound/pci/hda/patch_realtek.c | 99 +++++++++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+), 2 deletions(-)
Signature · 1 line
2.39.2
PATCH v2 1/3 spi: Add empty versions of ACPI functions
Provide empty versions of acpi_spi_count_resources(), acpi_spi_device_alloc() and acpi_spi_find_controller_by_adev() if the real functions are not being built.
This commit fixes two problems with the original definitions:
1) There wasn't an empty version of these functions
2) The #if only depended on CONFIG_ACPI. But the functions are implemented in the core spi.c so CONFIG_SPI_MASTER must also be enabled for the real functions to exist.
---
Changes since V1:
- This patch is new in V2.
include/linux/spi/spi.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
include/linux/spi/spi.h +18 -1
@@ -902,12 +902,29 @@ extern int devm_spi_register_controller(struct device *dev, struct spi_controller *ctlr);extern void spi_unregister_controller (struct spi_controller *ctlr); -#if IS_ENABLED (CONFIG_ACPI ) +#if IS_ENABLED (CONFIG_ACPI ) &&IS_ENABLED (CONFIG_SPI_MASTER )extern struct spi_controller *acpi_spi_find_controller_by_adev (struct acpi_device *adev);extern struct spi_device *acpi_spi_device_alloc (struct spi_controller *ctlr,struct acpi_device *adev,int index);int acpi_spi_count_resources (struct acpi_device *adev); +#else +static inline struct spi_controller *acpi_spi_find_controller_by_adev (struct acpi_device *adev) +{ +return NULL ; +} + +static inline struct spi_device *acpi_spi_device_alloc (struct spi_controller *ctlr, +struct acpi_device *adev, +int index) +{ +return ERR_PTR (-ENODEV ); +} + +static inline int acpi_spi_count_resources (struct acpi_device *adev) +{ +return 0 ; +}#endif /*
Signature · 1 line
2.39.2
PATCH v2 2/3 i2c: Fix conditional for substituting empty ACPI functions
In reply to Richard FitzgeraldAdd IS_ENABLED(CONFIG_I2C) to the conditional around a bunch of ACPI functions.
The conditional around these functions depended only on CONFIG_ACPI. But the functions are implemented in I2C core, so are only present if CONFIG_I2C is enabled.
---
Changes since V1:
- This patch is new in V2.
include/linux/i2c.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/i2c.h +1 -1
@@ -1066,7 +1066,7 @@ static inline int of_i2c_get_board_info(struct device *dev,struct acpi_resource ;struct acpi_resource_i2c_serialbus ; -#if IS_ENABLED (CONFIG_ACPI ) +#if IS_ENABLED (CONFIG_ACPI ) &&IS_ENABLED (CONFIG_I2C )bool i2c_acpi_get_i2c_resource (struct acpi_resource *ares,struct acpi_resource_i2c_serialbus **i2c);int i2c_acpi_client_count (struct acpi_device *adev);
Signature · 1 line
2.39.2
Wolfram Sang
AppliedRe: [PATCH v2 2/3] i2c: Fix conditional for substituting empty ACPI functions
Quoted 8 lines · Richard Fitzgerald
Add
IS_ENABLED(CONFIG_I2C)to the conditional around a bunch of ACPI functions.The conditional around these functions depended only on
CONFIG_ACPI. But the functions are implemented in I2C core, so are only present ifCONFIG_I2Cis enabled.Signed-off-by Richard Fitzgerald <[email protected]>
Applied to for-current, thanks!
PATCH v2 3/3 ALSA: hda/realtek: Add support for new HP G12 laptops
In reply to Richard FitzgeraldFrom: Simon Trimmer <[email protected]>
Some of these laptop models have quirk IDs that are identical but have different amplifier parts fitted, this difference is described in the ACPI information.
The solution introduced for this product family can derive the required component binding information from ACPI instead of hardcoding it, supports the new variants of the CS35L56 being used and has generalized naming that makes it applicable to other ALC+amp combinations.
---
No changes since V1.
sound/pci/hda/patch_realtek.c | 99 +++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+)
sound/pci/hda/patch_realtek.c +99 -0
@@ -11,15 +11,18 @@*/ #include <linux/acpi.h> +#include <linux/cleanup.h> #include <linux/init.h> #include <linux/delay.h> #include <linux/slab.h> #include <linux/pci.h> #include <linux/dmi.h> #include <linux/module.h> +#include <linux/i2c.h> #include <linux/input.h> #include <linux/leds.h> #include <linux/ctype.h> +#include <linux/spi/spi.h> #include <sound/core.h> #include <sound/jack.h> #include <sound/hda_codec.h>
@@ -6856,6 +6859,86 @@ static void comp_generic_fixup(struct hda_codec *cdc, int action, const char *bu } } +static void cs35lxx_autodet_fixup (struct hda_codec *cdc, +const struct hda_fixup *fix, +int action) +{ +struct device *dev =hda_codec_dev (cdc); +struct acpi_device *adev; + struct fwnode_handle *fwnode __free(fwnode_handle) = NULL; +const char *bus =NULL ; +static const struct { +const char *hid; +const char *name; + } acpi_ids[] = {{"CSC3554" ,"cs35l54-hda" }, + {"CSC3556" ,"cs35l56-hda" }, + {"CSC3557" ,"cs35l57-hda" }}; +char *match; +int i, count =0 , count_devindex =0 ; + +switch (action) { +case HDA_FIXUP_ACT_PRE_PROBE : +for (i =0 ; i <ARRAY_SIZE (acpi_ids); ++i) { + adev =acpi_dev_get_first_match_dev (acpi_ids[i].hid,NULL ,-1 ); +if (adev) +break ; + } +if (!adev) { +dev_err (dev,"Failed to find ACPI entry for a Cirrus Amp\n" ); +return ; + } + + count =i2c_acpi_client_count (adev); +if (count >0 ) { + bus ="i2c" ; + }else { + count =acpi_spi_count_resources (adev); +if (count >0 ) + bus ="spi" ; + } + + fwnode =fwnode_handle_get (acpi_fwnode_handle (adev)); +acpi_dev_put (adev); + +if (!bus) { +dev_err (dev,"Did not find any buses for %s\n" , acpi_ids[i].hid); +return ; + } + +if (!fwnode) { +dev_err (dev,"Could not get fwnode for %s\n" , acpi_ids[i].hid); +return ; + } + +/* +* When available the cirrus,dev-index property is an accurate +* count of the amps in a system and is used in preference to +* the count of bus devices that can contain additional address +* alias entries. +*/ + count_devindex =fwnode_property_count_u32 (fwnode,"cirrus,dev-index" ); +if (count_devindex >0 ) + count = count_devindex; + + match =devm_kasprintf (dev,GFP_KERNEL ,"-%%s:00-%s.%%d" , acpi_ids[i].name); +if (!match) +return ; +dev_info (dev,"Found %d %s on %s (%s)\n" , count, acpi_ids[i].hid, bus, match); +comp_generic_fixup (cdc, action, bus, acpi_ids[i].hid, match, count); + +break ; +case HDA_FIXUP_ACT_FREE : +/* +* Pass the action on to comp_generic_fixup() so that +* hda_component_manager functions can be called in just once +* place. In this context the bus, hid, match_str or count +* values do not need to be calculated. +*/ +comp_generic_fixup (cdc, action,NULL ,NULL ,NULL ,0 ); +break ; + } +} +static void cs35l41_fixup_i2c_two (struct hda_codec *cdc,const struct hda_fixup *fix,int action) {comp_generic_fixup (cdc, action,"i2c" ,"CSC3551" ,"-%s:00-cs35l41-hda.%d" ,2 );
@@ -7528,6 +7611,7 @@ enum {ALC256_FIXUP_CHROME_BOOK ,ALC287_FIXUP_LENOVO_14ARP8_LEGION_IAH7 ,ALC287_FIXUP_LENOVO_SSID_17AA3820 , + ALCXXX_FIXUP_CS35LXX, };/* A special fixup for Lenovo C940 and Yoga Duet 7;
@@ -9857,6 +9941,10 @@ static const struct hda_fixup alc269_fixups[] = { .type = HDA_FIXUP_FUNC, .v.func = alc287_fixup_lenovo_ssid_17aa3820, }, + [ALCXXX_FIXUP_CS35LXX] = { + .type = HDA_FIXUP_FUNC, + .v.func = cs35lxx_autodet_fixup, + }, }; static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -10271,6 +10359,17 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x103c ,0x8cdf ,"HP SnowWhite" ,ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8ce0 ,"HP SnowWhite" ,ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8cf5 ,"HP ZBook Studio 16" ,ALC245_FIXUP_CS35L41_SPI_4_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8d01 ,"HP ZBook Power 14 G12" ,ALCXXX_FIXUP_CS35LXX ), +SND_PCI_QUIRK (0x103c ,0x8d08 ,"HP EliteBook 1045 14 G12" ,ALCXXX_FIXUP_CS35LXX ), +SND_PCI_QUIRK (0x103c ,0x8d85 ,"HP EliteBook 1040 14 G12" ,ALCXXX_FIXUP_CS35LXX ), +SND_PCI_QUIRK (0x103c ,0x8d86 ,"HP Elite x360 1040 14 G12" ,ALCXXX_FIXUP_CS35LXX ), +SND_PCI_QUIRK (0x103c ,0x8d8c ,"HP EliteBook 830 13 G12" ,ALCXXX_FIXUP_CS35LXX ), +SND_PCI_QUIRK (0x103c ,0x8d8d ,"HP Elite x360 830 13 G12" ,ALCXXX_FIXUP_CS35LXX ), +SND_PCI_QUIRK (0x103c ,0x8d8e ,"HP EliteBook 840 14 G12" ,ALCXXX_FIXUP_CS35LXX ), +SND_PCI_QUIRK (0x103c ,0x8d8f ,"HP EliteBook 840 14 G12" ,ALCXXX_FIXUP_CS35LXX ), +SND_PCI_QUIRK (0x103c ,0x8d90 ,"HP EliteBook 860 16 G12" ,ALCXXX_FIXUP_CS35LXX ), +SND_PCI_QUIRK (0x103c ,0x8d91 ,"HP ZBook Firefly 14 G12" ,ALCXXX_FIXUP_CS35LXX ), +SND_PCI_QUIRK (0x103c ,0x8d92 ,"HP ZBook Firefly 16 G12" ,ALCXXX_FIXUP_CS35LXX ),SND_PCI_QUIRK (0x1043 ,0x103e ,"ASUS X540SA" ,ALC256_FIXUP_ASUS_MIC ),SND_PCI_QUIRK (0x1043 ,0x103f ,"ASUS TX300" ,ALC282_FIXUP_ASUS_TX300 ), SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
Signature · 1 line
2.39.2
Mark Brown
maintainerRe: (subset) [PATCH v2 0/3] ALSA: Add support for new HP G12 laptops
In reply to Richard FitzgeraldQuoted 10 lines · Richard Fitzgerald
Add support for HP G12 laptops that use CS35L54 or CS35L56 amplifiers with Realtek HDA codecs. Some of these use the same SSID for models with CS35L54 and models with CS35L56 so the ACPI entries are examined to determine which amp is present.
To avoid having to #ifdef around this code we've fixed the definitions of SPI and I2C functions that were not correctly supplying dummy functions when the real functions are not in the build.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/3] spi: Add empty versions of ACPI functions
commit: 90ec3a8a7fd0d43026fcca979713e077d4883b56
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 13 lines · Richard Fitzgerald
Add support for HP G12 laptops that use CS35L54 or CS35L56 amplifiers with Realtek HDA codecs. Some of these use the same SSID for models with CS35L54 and models with CS35L56 so the ACPI entries are examined to determine which amp is present.
To avoid having to #ifdef around this code we've fixed the definitions of SPI and I2C functions that were not correctly supplying dummy functions when the real functions are not in the build.
Changes since V1:
Added I2C and SPI patches to provide dummy functions.
Quoted 6 lines
Richard Fitzgerald (2):
spi: Add empty versions of ACPI functions
i2c: Fix conditional for substituting empty ACPI functionsSimon Trimmer (1):
ALSA: hda/realtek: Add support for new HP G12 laptops
Hm, the 3rd patch requires both patch 1 and 2, and now those seem to have been applied to two different trees, which makes hard to apply the 3rd one.
Mark, Wolfram, will you guys submit PR for 6.11-rc3 including the patch 1 and 2? If so, I can apply the patch 3 later on top of 6.11-rc3.
Or, I'd need to pull from both of you and apply the patch 3.
thanks,
Takashi
Quoted 30 lines · Takashi Iwai
Quoted 13 lines · Richard Fitzgerald
Add support for HP G12 laptops that use CS35L54 or CS35L56 amplifiers with Realtek HDA codecs. Some of these use the same SSID for models with CS35L54 and models with CS35L56 so the ACPI entries are examined to determine which amp is present.
To avoid having to #ifdef around this code we've fixed the definitions of SPI and I2C functions that were not correctly supplying dummy functions when the real functions are not in the build.
Changes since V1:
Added I2C and SPI patches to provide dummy functions.Quoted 6 lines
Richard Fitzgerald (2):
spi: Add empty versions of ACPI functions
i2c: Fix conditional for substituting empty ACPI functionsSimon Trimmer (1):
ALSA: hda/realtek: Add support for new HP G12 laptopsHm, the 3rd patch requires both patch 1 and 2, and now those seem to have been applied to two different trees, which makes hard to apply the 3rd one.
Mark, Wolfram, will you guys submit PR for 6.11-rc3 including the patch 1 and 2? If so, I can apply the patch 3 later on top of 6.11-rc3.
Quoted 6 lines
Or, I'd need to pull from both of you and apply the patch 3.
thanks,
Takashi
We've just noticed that the SPI patches have gone into for-6.12. We really hoped that we could get the main patch (G12 support) into 6.11 (yes, I know, I didn't actually say that we were targeting 6.11 - sorry).
Quoted 35 lines · Richard Fitzgerald
Quoted 33 lines · Takashi Iwai
Quoted 13 lines · Richard Fitzgerald
Add support for HP G12 laptops that use CS35L54 or CS35L56 amplifiers with Realtek HDA codecs. Some of these use the same SSID for models with CS35L54 and models with CS35L56 so the ACPI entries are examined to determine which amp is present.
To avoid having to #ifdef around this code we've fixed the definitions of SPI and I2C functions that were not correctly supplying dummy functions when the real functions are not in the build.
Changes since V1:
Added I2C and SPI patches to provide dummy functions.Quoted 6 lines
Richard Fitzgerald (2):
spi: Add empty versions of ACPI functions
i2c: Fix conditional for substituting empty ACPI functionsSimon Trimmer (1):
ALSA: hda/realtek: Add support for new HP G12 laptopsHm, the 3rd patch requires both patch 1 and 2, and now those seem to have been applied to two different trees, which makes hard to apply the 3rd one.
Mark, Wolfram, will you guys submit PR for 6.11-rc3 including the patch 1 and 2? If so, I can apply the patch 3 later on top of 6.11-rc3.
Or, I'd need to pull from both of you and apply the patch 3.
Quoted 8 lines
Quoted 3 lines
thanks,
Takashi
We've just noticed that the SPI patches have gone into for-6.12. We really hoped that we could get the main patch (G12 support) into 6.11 (yes, I know, I didn't actually say that we were targeting 6.11 - sorry).
I also planned for 6.12, but fortunately didn't take it yet, so it's no problem :)
And, I see Mark's PR is based on Linus tree, so that's fine to take. The remaining question is about the i2c patch.
Wolfram, has the patch been merged for your branch for 6.11? If yes, can I pull your change, so that I can apply the patch 3 together with the SPI change?
thanks,
Takashi
Quoted 4 lines
Wolfram, has the patch been merged for your branch for 6.11? If yes, can I pull your change, so that I can apply the patch 3 together with the SPI change?
Yes, you can pull i2c/for-current. Maybe I can also retrofit an immutable branch for you. I'd think, though, that it is easiest to wait for 6.11-rc3 which will include the I2C part of this series. Or?
Quoted 9 lines · Wolfram Sang
Quoted 5 lines
Wolfram, has the patch been merged for your branch for 6.11? If yes, can I pull your change, so that I can apply the patch 3 together with the SPI change?
Yes, you can pull i2c/for-current. Maybe I can also retrofit an immutable branch for you. I'd think, though, that it is easiest to wait for 6.11-rc3 which will include the I2C part of this series. Or?
Yeah, it's fine, I can wait for 6.11-rc3.
thanks,
Takashi
Quoted 6 lines
Quoted 4 lines
Yes, you can pull i2c/for-current. Maybe I can also retrofit an immutable branch for you. I'd think, though, that it is easiest to wait for 6.11-rc3 which will include the I2C part of this series. Or?
Yeah, it's fine, I can wait for 6.11-rc3.
Done. Said commit is included in rc3 now. Thanks, guys!
Quoted 9 lines · Wolfram Sang
Quoted 7 lines
Quoted 5 lines
Yes, you can pull i2c/for-current. Maybe I can also retrofit an immutable branch for you. I'd think, though, that it is easiest to wait for 6.11-rc3 which will include the I2C part of this series. Or?
Yeah, it's fine, I can wait for 6.11-rc3.
Done. Said commit is included in rc3 now. Thanks, guys!
Thanks!
Takashi
Mark Brown
maintainerQuoted 4 lines · Richard Fitzgerald
Add support for HP G12 laptops that use CS35L54 or CS35L56 amplifiers with Realtek HDA codecs. Some of these use the same SSID for models with CS35L54 and models with CS35L56 so the ACPI entries are examined to determine which amp is present.
The following changes since commit a0c04bd55a467aee3eb647555343ad6971106e86:
Merge tag 'kbuild-fixes-v6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild (2024-07-28 14:02:48 -0700)
are available in the Git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git tags/spi-acpi-lookup-dummy
for you to fetch changes up to 90ec3a8a7fd0d43026fcca979713e077d4883b56:
spi: Add empty versions of ACPI functions (2024-08-02 18:51:59 +0100)
----------------------------------------------------------------
spi: Add empty versions of ACPI lookup functions
A patch from Richard Fitzgerald adding dummy versions of the ACPI lookup functions for SPI:
Provide empty versions of acpi_spi_count_resources(), acpi_spi_device_alloc() and acpi_spi_find_controller_by_adev() if the real functions are not being built.
This commit fixes two problems with the original definitions:
1) There wasn't an empty version of these functions
2) The #if only depended on CONFIG_ACPI. But the functions are implemented in the core spi.c so CONFIG_SPI_MASTER must also be enabled for the real functions to exist.
----------------------------------------------------------------
Richard Fitzgerald (1):
spi: Add empty versions of ACPI functions
include/linux/spi/spi.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
Quoted 29 lines · Mark Brown
Quoted 4 lines · Richard Fitzgerald
Add support for HP G12 laptops that use CS35L54 or CS35L56 amplifiers with Realtek HDA codecs. Some of these use the same SSID for models with CS35L54 and models with CS35L56 so the ACPI entries are examined to determine which amp is present.
The following changes since commit
a0c04bd55a467aee3eb647555343ad6971106e86:Merge tag 'kbuild-fixes-v6.11' of
git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild(2024-07-28 14:02:48 -0700)are available in the Git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git tags/spi-acpi-lookup-dummy
for you to fetch changes up to
90ec3a8a7fd0d43026fcca979713e077d4883b56:spi: Add empty versions of ACPI functions (2024-08-02 18:51:59 +0100)
----------------------------------------------------------------
spi: Add empty versions of ACPI lookup functionsA patch from Richard Fitzgerald adding dummy versions of the ACPI lookup functions for SPI:
Provide empty versions of
acpi_spi_count_resources(),acpi_spi_device_alloc()andacpi_spi_find_controller_by_adev()if the real functions are not being built.
Quoted 6 lines
This commit fixes two problems with the original definitions:
1) There wasn't an empty version of these functions
2) The #if only depended onCONFIG_ACPI. But the functions are implemented in the corespi.csoCONFIG_SPI_MASTERmust also be enabled for the real functions to exist.
Pulled now. Thanks.
Takashi
Quoted 13 lines · Richard Fitzgerald
Add support for HP G12 laptops that use CS35L54 or CS35L56 amplifiers with Realtek HDA codecs. Some of these use the same SSID for models with CS35L54 and models with CS35L56 so the ACPI entries are examined to determine which amp is present.
To avoid having to #ifdef around this code we've fixed the definitions of SPI and I2C functions that were not correctly supplying dummy functions when the real functions are not in the build.
Changes since V1:
Added I2C and SPI patches to provide dummy functions.
Quoted 6 lines
Richard Fitzgerald (2):
spi: Add empty versions of ACPI functions
i2c: Fix conditional for substituting empty ACPI functionsSimon Trimmer (1):
ALSA: hda/realtek: Add support for new HP G12 laptops
Now all changes are merged to sound git tree for-linus branch.
thanks,
Takashi