Skip to content

Commit 00f87ec

Browse files
Stefan Bindingtiwai
authored andcommitted
ALSA: hda: cs35l41: Add Amp Name based on channel and index
This will be used to identify ALSA controls and firmware. The Amp Name will be a channel identifier (L or R), and an index, which identifies which amp for that channel. Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com> Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com> Link: https://lore.kernel.org/r/20220509214703.4482-10-vitalyr@opensource.cirrus.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 0db9957 commit 00f87ec

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

sound/pci/hda/cs35l41_hda.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,17 @@ static int cs35l41_hda_channel_map(struct device *dev, unsigned int tx_num, unsi
8888
unsigned int rx_num, unsigned int *rx_slot)
8989
{
9090
struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev);
91+
static const char * const channel_name[] = { "L", "R" };
92+
93+
if (!cs35l41->amp_name) {
94+
if (*rx_slot >= ARRAY_SIZE(channel_name))
95+
return -EINVAL;
96+
97+
cs35l41->amp_name = devm_kasprintf(cs35l41->dev, GFP_KERNEL, "%s%d",
98+
channel_name[*rx_slot], cs35l41->channel_index);
99+
if (!cs35l41->amp_name)
100+
return -ENOMEM;
101+
}
91102

92103
return cs35l41_set_channels(cs35l41->dev, cs35l41->regmap, tx_num, tx_slot, rx_num,
93104
rx_slot);
@@ -345,6 +356,11 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i
345356
goto err;
346357
hw_cfg->spk_pos = values[cs35l41->index];
347358

359+
cs35l41->channel_index = 0;
360+
for (i = 0; i < cs35l41->index; i++)
361+
if (values[i] == hw_cfg->spk_pos)
362+
cs35l41->channel_index++;
363+
348364
property = "cirrus,gpio1-func";
349365
ret = device_property_read_u32_array(physdev, property, values, nval);
350366
if (ret)
@@ -410,6 +426,7 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i
410426
/* check I2C address to assign the index */
411427
cs35l41->index = id == 0x40 ? 0 : 1;
412428
cs35l41->hw_cfg.spk_pos = cs35l41->index;
429+
cs35l41->channel_index = 0;
413430
cs35l41->reset_gpio = gpiod_get_index(physdev, NULL, 0, GPIOD_OUT_HIGH);
414431
cs35l41->hw_cfg.bst_type = CS35L41_EXT_BOOST_NO_VSPK_SWITCH;
415432
hw_cfg->gpio2.func = CS35L41_GPIO2_INT_OPEN_DRAIN;

sound/pci/hda/cs35l41_hda.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ struct cs35l41_hda {
3535

3636
int irq;
3737
int index;
38+
int channel_index;
3839
unsigned volatile long irq_errors;
40+
const char *amp_name;
3941
struct regmap_irq_chip_data *irq_data;
4042
};
4143

0 commit comments

Comments
 (0)