Skip to content

Commit 51b0691

Browse files
rfvirgilbroonie
authored andcommitted
ASoC: cs35l56: Use vendor-specific qualifier in firmware file search
If cs_amp_devm_get_vendor_specific_variant_id() returns a string, use it as part of the firmware filename. If this firmware isn't found, fall back to the standard firmware name. This re-uses the fwf_suffix fallback mechanism that was introduced in commit e5d5b3a ("ASoC: cs35l56: Use SoundWire address as alternate firmware suffix on L56 B0"). This is for handling vendors that use the same PCI SSID on systems with various audio hardware and have a custom vendor-specific way to identify the hardware variant. This is currently used on Dell laptops. Dell create a UEFI variable that indicates varations to the base hardware. This variance can be any part of the hardware (not necessarily affecting the audio). It would be impractical to publish many aliases for the same firmware files to match every possible variance to that base hardware. Hence the fallback to the standard firmware name. This allows alternate firmware files to be published only for variants that need it. For all other variants the fallback will load the firmware for the base SSID. This is not done for CS35L56 B0 because the fallback mechanism is already used for a different purpose for these parts. None of the products with the older L56 B0 silicon revision need the additional vendor-specific descriptor. For SoundWire the resulting firmware searches with a variant descriptor will be: 1. cs35l??-dsp1-misc-SSID-VARIANT-l?u?.wmfw 2. cs35l??-dsp1-misc-SSID-VARIANT.wmfw 3. cs35l??-dsp1-misc-SSID-VARIANT-l?u?.bin 4. cs35l??-dsp1-misc-SSID-VARIANT.bin If this doesn't find a wmfw and bin file it will then fallback to: 5. cs35l??-dsp1-misc-SSID-l?u?.wmfw 6. cs35l??-dsp1-misc-SSID.wmfw 7. cs35l??-dsp1-misc-SSID-l?u?.bin 8. cs35l??-dsp1-misc-SSID.bin With the typical published firmware names and qualifiers (a single wmfw but amp-specific bin file) this will load either: cs35l??-dsp1-misc-SSID-VARIANT.wmfw and cs35l??-dsp1-misc-SSID-VARIANT-l?u?.bin or cs35l??-dsp1-misc-SSID.wmfw and cs35l??-dsp1-misc-SSID-l?u?.bin For non-Soundwire (I2S/TDM) systems the searches and fallbacks are as above except that the "l?u?" component of the name is instead the ALSA name prefix, usually of the form "AMPn". Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20260121132243.1256019-3-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 00fd40b commit 51b0691

1 file changed

Lines changed: 55 additions & 14 deletions

File tree

sound/soc/codecs/cs35l56.c

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,27 +1109,68 @@ static const struct snd_kcontrol_new cs35l56_cal_data_restore_controls[] = {
11091109

11101110
static int cs35l56_set_fw_suffix(struct cs35l56_private *cs35l56)
11111111
{
1112+
unsigned short vendor, device;
1113+
const char *vendor_id;
1114+
int ret;
1115+
11121116
if (cs35l56->dsp.fwf_suffix)
11131117
return 0;
11141118

1115-
if (!cs35l56->sdw_peripheral)
1116-
return 0;
1119+
if (cs35l56->sdw_peripheral) {
1120+
cs35l56->dsp.fwf_suffix = devm_kasprintf(cs35l56->base.dev, GFP_KERNEL,
1121+
"l%uu%u",
1122+
cs35l56->sdw_link_num,
1123+
cs35l56->sdw_unique_id);
1124+
if (!cs35l56->dsp.fwf_suffix)
1125+
return -ENOMEM;
11171126

1118-
cs35l56->dsp.fwf_suffix = devm_kasprintf(cs35l56->base.dev, GFP_KERNEL,
1119-
"l%uu%u",
1120-
cs35l56->sdw_link_num,
1121-
cs35l56->sdw_unique_id);
1122-
if (!cs35l56->dsp.fwf_suffix)
1123-
return -ENOMEM;
1127+
/*
1128+
* There are published firmware files for L56 B0 silicon using
1129+
* the ALSA prefix as the filename suffix. Default to trying these
1130+
* first, with the new SoundWire suffix as a fallback.
1131+
* None of these older systems use a vendor-specific ID.
1132+
*/
1133+
if ((cs35l56->base.type == 0x56) && (cs35l56->base.rev == 0xb0)) {
1134+
cs35l56->fallback_fw_suffix = cs35l56->dsp.fwf_suffix;
1135+
cs35l56->dsp.fwf_suffix = cs35l56->component->name_prefix;
1136+
1137+
return 0;
1138+
}
1139+
}
11241140

11251141
/*
1126-
* There are published firmware files for L56 B0 silicon using
1127-
* the ALSA prefix as the filename suffix. Default to trying these
1128-
* first, with the new name as an alternate.
1142+
* Some manufacturers use the same SSID on multiple products and have
1143+
* a vendor-specific qualifier to distinguish different models.
1144+
* Models with the same SSID but different qualifier might require
1145+
* different audio firmware, or they might all have the same audio
1146+
* firmware.
1147+
* Try searching for a firmware with this qualifier first, else
1148+
* fallback to standard naming.
11291149
*/
1130-
if ((cs35l56->base.type == 0x56) && (cs35l56->base.rev == 0xb0)) {
1131-
cs35l56->fallback_fw_suffix = cs35l56->dsp.fwf_suffix;
1132-
cs35l56->dsp.fwf_suffix = cs35l56->component->name_prefix;
1150+
if (snd_soc_card_get_pci_ssid(cs35l56->component->card, &vendor, &device) < 0) {
1151+
vendor_id = cs_amp_devm_get_vendor_specific_variant_id(cs35l56->base.dev, -1, -1);
1152+
} else {
1153+
vendor_id = cs_amp_devm_get_vendor_specific_variant_id(cs35l56->base.dev,
1154+
vendor, device);
1155+
}
1156+
ret = PTR_ERR_OR_ZERO(vendor_id);
1157+
if (ret == -ENOENT)
1158+
return 0;
1159+
else if (ret)
1160+
return ret;
1161+
1162+
if (vendor_id) {
1163+
if (cs35l56->dsp.fwf_suffix)
1164+
cs35l56->fallback_fw_suffix = cs35l56->dsp.fwf_suffix;
1165+
else
1166+
cs35l56->fallback_fw_suffix = cs35l56->component->name_prefix;
1167+
1168+
cs35l56->dsp.fwf_suffix = devm_kasprintf(cs35l56->base.dev, GFP_KERNEL,
1169+
"%s-%s",
1170+
vendor_id,
1171+
cs35l56->fallback_fw_suffix);
1172+
if (!cs35l56->dsp.fwf_suffix)
1173+
return -ENOMEM;
11331174
}
11341175

11351176
return 0;

0 commit comments

Comments
 (0)