Commit bb6eb621 authored by Stefan Binding's avatar Stefan Binding Committed by Takashi Iwai

ALSA: hda: cs35l41: Support multiple load paths for firmware

To be able to support different firmwares and tuning
for different models, the driver needs to be able to
load a different firmware and coefficient file based
on its Subsystem ID.

The driver attempts to load the firmware in the
following order:

/lib/firmware/cirrus/cs35l41-dsp1-<fw-type>-<ssid>-dev<#>.wmfw
/lib/firmware/cirrus/cs35l41-dsp1-<fw-type>-<ssid>.wmfw
/lib/firmware/cirrus/cs35l41-dsp1-<fw-type>.wmfw
Signed-off-by: default avatarStefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: default avatarVitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220630002335.366545-8-vitalyr@opensource.cirrus.comSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent eef37596
...@@ -85,14 +85,23 @@ static const struct cs_dsp_client_ops client_ops = { ...@@ -85,14 +85,23 @@ static const struct cs_dsp_client_ops client_ops = {
static int cs35l41_request_firmware_file(struct cs35l41_hda *cs35l41, static int cs35l41_request_firmware_file(struct cs35l41_hda *cs35l41,
const struct firmware **firmware, char **filename, const struct firmware **firmware, char **filename,
const char *dir, const char *filetype) const char *dir, const char *ssid, const char *amp_name,
const char *filetype)
{ {
const char * const dsp_name = cs35l41->cs_dsp.name; const char * const dsp_name = cs35l41->cs_dsp.name;
char *s, c; char *s, c;
int ret = 0; int ret = 0;
*filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s.%s", dir, CS35L41_PART, dsp_name, "spk-prot", if (ssid && amp_name)
filetype); *filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s-%s.%s", dir, CS35L41_PART,
dsp_name, "spk-prot", ssid, amp_name,
filetype);
else if (ssid)
*filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s.%s", dir, CS35L41_PART,
dsp_name, "spk-prot", ssid, filetype);
else
*filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s.%s", dir, CS35L41_PART,
dsp_name, "spk-prot", filetype);
if (*filename == NULL) if (*filename == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -129,12 +138,43 @@ static int cs35l41_request_firmware_files(struct cs35l41_hda *cs35l41, ...@@ -129,12 +138,43 @@ static int cs35l41_request_firmware_files(struct cs35l41_hda *cs35l41,
{ {
int ret; int ret;
/* cirrus/part-dspN-fwtype.wmfw */ /* try cirrus/part-dspN-fwtype-sub<-ampname>.wmfw */
ret = cs35l41_request_firmware_file(cs35l41, wmfw_firmware, wmfw_filename,
CS35L41_FIRMWARE_ROOT, cs35l41->acpi_subsystem_id,
cs35l41->amp_name, "wmfw");
if (!ret) {
/* try cirrus/part-dspN-fwtype-sub<-ampname>.bin */
cs35l41_request_firmware_file(cs35l41, coeff_firmware, coeff_filename,
CS35L41_FIRMWARE_ROOT, cs35l41->acpi_subsystem_id,
cs35l41->amp_name, "bin");
return 0;
}
/* try cirrus/part-dspN-fwtype-sub.wmfw */
ret = cs35l41_request_firmware_file(cs35l41, wmfw_firmware, wmfw_filename,
CS35L41_FIRMWARE_ROOT, cs35l41->acpi_subsystem_id,
NULL, "wmfw");
if (!ret) {
/* try cirrus/part-dspN-fwtype-sub<-ampname>.bin */
ret = cs35l41_request_firmware_file(cs35l41, coeff_firmware, coeff_filename,
CS35L41_FIRMWARE_ROOT,
cs35l41->acpi_subsystem_id,
cs35l41->amp_name, "bin");
if (ret)
/* try cirrus/part-dspN-fwtype-sub.bin */
cs35l41_request_firmware_file(cs35l41, coeff_firmware, coeff_filename,
CS35L41_FIRMWARE_ROOT,
cs35l41->acpi_subsystem_id, NULL, "bin");
return 0;
}
/* fallback try cirrus/part-dspN-fwtype.wmfw */
ret = cs35l41_request_firmware_file(cs35l41, wmfw_firmware, wmfw_filename, ret = cs35l41_request_firmware_file(cs35l41, wmfw_firmware, wmfw_filename,
CS35L41_FIRMWARE_ROOT, "wmfw"); CS35L41_FIRMWARE_ROOT, NULL, NULL, "wmfw");
if (!ret) { if (!ret) {
/* fallback try cirrus/part-dspN-fwtype.bin */
cs35l41_request_firmware_file(cs35l41, coeff_firmware, coeff_filename, cs35l41_request_firmware_file(cs35l41, coeff_firmware, coeff_filename,
CS35L41_FIRMWARE_ROOT, "bin"); CS35L41_FIRMWARE_ROOT, NULL, NULL, "bin");
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment