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>
This commit is contained in:
parent
0db99577c4
commit
00f87ec74c
|
@ -88,6 +88,17 @@ static int cs35l41_hda_channel_map(struct device *dev, unsigned int tx_num, unsi
|
|||
unsigned int rx_num, unsigned int *rx_slot)
|
||||
{
|
||||
struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev);
|
||||
static const char * const channel_name[] = { "L", "R" };
|
||||
|
||||
if (!cs35l41->amp_name) {
|
||||
if (*rx_slot >= ARRAY_SIZE(channel_name))
|
||||
return -EINVAL;
|
||||
|
||||
cs35l41->amp_name = devm_kasprintf(cs35l41->dev, GFP_KERNEL, "%s%d",
|
||||
channel_name[*rx_slot], cs35l41->channel_index);
|
||||
if (!cs35l41->amp_name)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
return cs35l41_set_channels(cs35l41->dev, cs35l41->regmap, tx_num, tx_slot, rx_num,
|
||||
rx_slot);
|
||||
|
@ -345,6 +356,11 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i
|
|||
goto err;
|
||||
hw_cfg->spk_pos = values[cs35l41->index];
|
||||
|
||||
cs35l41->channel_index = 0;
|
||||
for (i = 0; i < cs35l41->index; i++)
|
||||
if (values[i] == hw_cfg->spk_pos)
|
||||
cs35l41->channel_index++;
|
||||
|
||||
property = "cirrus,gpio1-func";
|
||||
ret = device_property_read_u32_array(physdev, property, values, nval);
|
||||
if (ret)
|
||||
|
@ -410,6 +426,7 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i
|
|||
/* check I2C address to assign the index */
|
||||
cs35l41->index = id == 0x40 ? 0 : 1;
|
||||
cs35l41->hw_cfg.spk_pos = cs35l41->index;
|
||||
cs35l41->channel_index = 0;
|
||||
cs35l41->reset_gpio = gpiod_get_index(physdev, NULL, 0, GPIOD_OUT_HIGH);
|
||||
cs35l41->hw_cfg.bst_type = CS35L41_EXT_BOOST_NO_VSPK_SWITCH;
|
||||
hw_cfg->gpio2.func = CS35L41_GPIO2_INT_OPEN_DRAIN;
|
||||
|
|
|
@ -35,7 +35,9 @@ struct cs35l41_hda {
|
|||
|
||||
int irq;
|
||||
int index;
|
||||
int channel_index;
|
||||
unsigned volatile long irq_errors;
|
||||
const char *amp_name;
|
||||
struct regmap_irq_chip_data *irq_data;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue