Skip to content

Commit 5f9f982

Browse files
Stefan Bindingtiwai
authored andcommitted
ALSA: hda: cs35l41: Fix missing Speaker ID GPIO description in _DSD
Laptop 10431A63 contains valid _DSD, but missing Speaker ID description. Add this discription, but keep the rest of the _DSD to ensure the correct firmware and tuning is loaded for this laptop. Signed-off-by: Stefan Binding <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent d712c58 commit 5f9f982

File tree

3 files changed

+65
-37
lines changed

3 files changed

+65
-37
lines changed

sound/pci/hda/cs35l41_hda.c

Lines changed: 49 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,38 +1753,14 @@ int cs35l41_get_speaker_id(struct device *dev, int amp_index, int num_amps, int
17531753
return speaker_id;
17541754
}
17551755

1756-
static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, int id)
1756+
int cs35l41_hda_parse_acpi(struct cs35l41_hda *cs35l41, struct device *physdev, int id)
17571757
{
17581758
struct cs35l41_hw_cfg *hw_cfg = &cs35l41->hw_cfg;
17591759
u32 values[HDA_MAX_COMPONENTS];
1760-
struct acpi_device *adev;
1761-
struct device *physdev;
1762-
struct spi_device *spi;
1763-
const char *sub;
17641760
char *property;
17651761
size_t nval;
17661762
int i, ret;
17671763

1768-
adev = acpi_dev_get_first_match_dev(hid, NULL, -1);
1769-
if (!adev) {
1770-
dev_err(cs35l41->dev, "Failed to find an ACPI device for %s\n", hid);
1771-
return -ENODEV;
1772-
}
1773-
1774-
cs35l41->dacpi = adev;
1775-
physdev = get_device(acpi_get_first_physical_node(adev));
1776-
1777-
sub = acpi_get_subsystem_id(ACPI_HANDLE(physdev));
1778-
if (IS_ERR(sub))
1779-
sub = NULL;
1780-
cs35l41->acpi_subsystem_id = sub;
1781-
1782-
ret = cs35l41_add_dsd_properties(cs35l41, physdev, id, hid);
1783-
if (!ret) {
1784-
dev_info(cs35l41->dev, "Using extra _DSD properties, bypassing _DSD in ACPI\n");
1785-
goto out;
1786-
}
1787-
17881764
property = "cirrus,dev-index";
17891765
ret = device_property_count_u32(physdev, property);
17901766
if (ret <= 0)
@@ -1816,8 +1792,9 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i
18161792
/* To use the same release code for all laptop variants we can't use devm_ version of
18171793
* gpiod_get here, as CLSA010* don't have a fully functional bios with an _DSD node
18181794
*/
1819-
cs35l41->reset_gpio = fwnode_gpiod_get_index(acpi_fwnode_handle(adev), "reset", cs35l41->index,
1820-
GPIOD_OUT_LOW, "cs35l41-reset");
1795+
cs35l41->reset_gpio = fwnode_gpiod_get_index(acpi_fwnode_handle(cs35l41->dacpi), "reset",
1796+
cs35l41->index, GPIOD_OUT_LOW,
1797+
"cs35l41-reset");
18211798

18221799
property = "cirrus,speaker-position";
18231800
ret = device_property_read_u32_array(physdev, property, values, nval);
@@ -1873,6 +1850,51 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i
18731850
hw_cfg->bst_type = CS35L41_EXT_BOOST;
18741851

18751852
hw_cfg->valid = true;
1853+
1854+
return 0;
1855+
err:
1856+
dev_err(cs35l41->dev, "Failed property %s: %d\n", property, ret);
1857+
hw_cfg->valid = false;
1858+
hw_cfg->gpio1.valid = false;
1859+
hw_cfg->gpio2.valid = false;
1860+
acpi_dev_put(cs35l41->dacpi);
1861+
1862+
return ret;
1863+
}
1864+
1865+
static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, int id)
1866+
{
1867+
struct acpi_device *adev;
1868+
struct device *physdev;
1869+
struct spi_device *spi;
1870+
const char *sub;
1871+
int ret;
1872+
1873+
adev = acpi_dev_get_first_match_dev(hid, NULL, -1);
1874+
if (!adev) {
1875+
dev_err(cs35l41->dev, "Failed to find an ACPI device for %s\n", hid);
1876+
return -ENODEV;
1877+
}
1878+
1879+
cs35l41->dacpi = adev;
1880+
physdev = get_device(acpi_get_first_physical_node(adev));
1881+
1882+
sub = acpi_get_subsystem_id(ACPI_HANDLE(physdev));
1883+
if (IS_ERR(sub))
1884+
sub = NULL;
1885+
cs35l41->acpi_subsystem_id = sub;
1886+
1887+
ret = cs35l41_add_dsd_properties(cs35l41, physdev, id, hid);
1888+
if (!ret) {
1889+
dev_info(cs35l41->dev, "Using extra _DSD properties, bypassing _DSD in ACPI\n");
1890+
goto out;
1891+
}
1892+
1893+
ret = cs35l41_hda_parse_acpi(cs35l41, physdev, id);
1894+
if (ret) {
1895+
put_device(physdev);
1896+
return ret;
1897+
}
18761898
out:
18771899
put_device(physdev);
18781900

@@ -1888,16 +1910,6 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i
18881910
}
18891911

18901912
return 0;
1891-
1892-
err:
1893-
dev_err(cs35l41->dev, "Failed property %s: %d\n", property, ret);
1894-
hw_cfg->valid = false;
1895-
hw_cfg->gpio1.valid = false;
1896-
hw_cfg->gpio2.valid = false;
1897-
acpi_dev_put(cs35l41->dacpi);
1898-
put_device(physdev);
1899-
1900-
return ret;
19011913
}
19021914

19031915
int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int irq,

sound/pci/hda/cs35l41_hda.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,6 @@ int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int i
104104
struct regmap *regmap, enum control_bus control_bus);
105105
void cs35l41_hda_remove(struct device *dev);
106106
int cs35l41_get_speaker_id(struct device *dev, int amp_index, int num_amps, int fixed_gpio_id);
107+
int cs35l41_hda_parse_acpi(struct cs35l41_hda *cs35l41, struct device *physdev, int id);
107108

108109
#endif /*__CS35L41_HDA_H__*/

sound/pci/hda/cs35l41_hda_property.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,20 @@ static int lenovo_legion_no_acpi(struct cs35l41_hda *cs35l41, struct device *phy
428428
return 0;
429429
}
430430

431+
static int missing_speaker_id_gpio2(struct cs35l41_hda *cs35l41, struct device *physdev, int id,
432+
const char *hid)
433+
{
434+
int ret;
435+
436+
ret = cs35l41_add_gpios(cs35l41, physdev, -1, 2, -1, 2);
437+
if (ret) {
438+
dev_err(cs35l41->dev, "Error adding GPIO mapping: %d\n", ret);
439+
return ret;
440+
}
441+
442+
return cs35l41_hda_parse_acpi(cs35l41, physdev, id);
443+
}
444+
431445
struct cs35l41_prop_model {
432446
const char *hid;
433447
const char *ssid;
@@ -501,6 +515,7 @@ static const struct cs35l41_prop_model cs35l41_prop_model_table[] = {
501515
{ "CSC3551", "104317F3", generic_dsd_config },
502516
{ "CSC3551", "10431863", generic_dsd_config },
503517
{ "CSC3551", "104318D3", generic_dsd_config },
518+
{ "CSC3551", "10431A63", missing_speaker_id_gpio2 },
504519
{ "CSC3551", "10431A83", generic_dsd_config },
505520
{ "CSC3551", "10431B93", generic_dsd_config },
506521
{ "CSC3551", "10431C9F", generic_dsd_config },

0 commit comments

Comments
 (0)