Skip to contentSkip to conversation

Asoc: wm_adsp: Add support for loading firmware with prefix name

PATCH In review Jianhua Lu 4 participants 10 messages Mar 29, 2023

Subsystems (3)
lore
Share & tools
lore

Jianhua Lu

author
#0 lore raw

PATCH 1/1 Asoc: wm_adsp: Add support for loading firmware with prefix name

For platform using fdt, system_name is NULL, it doesn't provide a way to load firmware with prefix name, so add it.

---
 sound/soc/codecs/wm_adsp.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
sound/soc/codecs/wm_adsp.c +14 -0
index 216120b68b64..17481e42d440 100644
@@ -760,6 +760,10 @@ static int wm_adsp_request_firmware_file(struct wm_adsp *dsp,
 		*filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s.%s", dir, dsp->part,
 				      dsp->fwf_name, wm_adsp_fw[dsp->fw].file, system_name,
 				      filetype);
+	else if (asoc_component_prefix)
+		*filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s.%s", dir, dsp->part,
+				      dsp->fwf_name, wm_adsp_fw[dsp->fw].file, asoc_component_prefix,
+				      filetype);
 	else
 		*filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s.%s", dir, dsp->part, dsp->fwf_name,
 				      wm_adsp_fw[dsp->fw].file, filetype);
@@ -831,6 +835,16 @@ static int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
 							      NULL, "bin");
 			return 0;
 		}
+	} else if (asoc_component_prefix) {
+		if (!wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename,
+						   cirrus_dir, NULL,
+						   asoc_component_prefix, "wmfw")) {
+			adsp_dbg(dsp, "Found '%s'\n", *wmfw_filename);
+			wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename,
+							      cirrus_dir, NULL,
+							      asoc_component_prefix, "bin");
+			return 0;
+		}
 	}
 
 	if (!wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename,
Signature · 1 line
2.39.2
#1 lore raw
Quoted 28 lines · Jianhua Lu

For platform using fdt, system_name is NULL, it doesn't provide a way to load firmware with prefix name, so add it.

---
 sound/soc/codecs/wm_adsp.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
sound/soc/codecs/wm_adsp.c +5 -0
index 216120b68b64..17481e42d440 100644
@@ -760,6 +760,10 @@ static int wm_adsp_request_firmware_file(struct wm_adsp *dsp,
 		*filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s.%s", dir, dsp->part,
 				      dsp->fwf_name, wm_adsp_fw[dsp->fw].file, system_name,
 				      filetype);
+	else if (asoc_component_prefix)
+		*filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s.%s", dir, dsp->part,
+				      dsp->fwf_name, wm_adsp_fw[dsp->fw].file, asoc_component_prefix,
+				      filetype);
 	else
 		*filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s.%s", dir, dsp->part, dsp->fwf_name,
 				      wm_adsp_fw[dsp->fw].file, filetype);
@@ -831,6 +835,16 @@ static int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
 							      NULL, "bin");
 			return 0;
 		}
+	} else if (asoc_component_prefix) {

sound/soc/codecs/wm_adsp.c static int wm_adsp_request_firmware_files(struct wm_adsp *dsp, · line 848

Quoted 10 lines
sound/soc/codecs/wm_adsp.c +9 -0
+		if (!wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename,
+						   cirrus_dir, NULL,
+						   asoc_component_prefix, "wmfw")) {
+			adsp_dbg(dsp, "Found '%s'\n", *wmfw_filename);
+			wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename,
+							      cirrus_dir, NULL,
+							      asoc_component_prefix, "bin");
+			return 0;
+		}
 	}

This direction seems slightly problematic, especially in the context of amps (which I presume this relates to, please let know if that is wrong). It would probably be better to be fixing things up such that the amp in question sets system_name when registered through DT. Generally speaking the idea is the amp tuning is going to be specific to the enclosure/speaker involved, so a generic tuning for say left amps doesn't really make a lot of sense.

Thanks,
Charles

#2 lore raw
In reply to Jianhua Lu
Quoted 28 lines · Jianhua Lu

For platform using fdt, system_name is NULL, it doesn't provide a way to load firmware with prefix name, so add it.

---
 sound/soc/codecs/wm_adsp.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
sound/soc/codecs/wm_adsp.c +5 -0
index 216120b68b64..17481e42d440 100644
@@ -760,6 +760,10 @@ static int wm_adsp_request_firmware_file(struct wm_adsp *dsp,
 		*filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s.%s", dir, dsp->part,
 				      dsp->fwf_name, wm_adsp_fw[dsp->fw].file, system_name,
 				      filetype);
+	else if (asoc_component_prefix)
+		*filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s.%s", dir, dsp->part,
+				      dsp->fwf_name, wm_adsp_fw[dsp->fw].file, asoc_component_prefix,
+				      filetype);
 	else
 		*filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s.%s", dir, dsp->part, dsp->fwf_name,
 				      wm_adsp_fw[dsp->fw].file, filetype);
@@ -831,6 +835,16 @@ static int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
 							      NULL, "bin");
 			return 0;
 		}
+	} else if (asoc_component_prefix) {

sound/soc/codecs/wm_adsp.c static int wm_adsp_request_firmware_files(struct wm_adsp *dsp, · line 848

Quoted 10 lines
sound/soc/codecs/wm_adsp.c +9 -0
+		if (!wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename,
+						   cirrus_dir, NULL,
+						   asoc_component_prefix, "wmfw")) {
+			adsp_dbg(dsp, "Found '%s'\n", *wmfw_filename);
+			wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename,
+							      cirrus_dir, NULL,
+							      asoc_component_prefix, "bin");
+			return 0;
+		}
 	}

This direction seems slightly problematic, especially in the context of amps (which I presume this relates to, please let know if that is wrong). It would probably be better to be fixing things up such that the amp in question sets system_name when registered through DT. Generally speaking the idea is the amp tuning is going to be specific to the enclosure/speaker involved, so a generic tuning for say left amps doesn't really make a lot of sense.

Thanks,
Charles

author
#3 lore raw
Quoted 6 lines · Charles Keepax

This direction seems slightly problematic, especially in the context of amps (which I presume this relates to, please let know if that is wrong). It would probably be better to be fixing things up such that the amp in question sets system_name when registered through DT. Generally speaking the idea is the amp

I also consider setting system_name when registered by DT, but I don't known setting what name to it. Card name or something else?

Quoted 3 lines

tuning is going to be specific to the enclosure/speaker involved, so a generic tuning for say left amps doesn't really make a lot of sense.

I don't known about amp tuning much, my need just is loading firmware for more than 1 speaker amp at the platform using fdt.

One of the both way is good to me.

Quoted 3 lines

Thanks,
Charles

#4 lore raw
Quoted 9 lines · Jianhua Lu
Quoted 6 lines · Charles Keepax

This direction seems slightly problematic, especially in the context of amps (which I presume this relates to, please let know if that is wrong). It would probably be better to be fixing things up such that the amp in question sets system_name when registered through DT. Generally speaking the idea is the amp

I also consider setting system_name when registered by DT, but I don't known setting what name to it. Card name or something else?

It just has to be a unique string.
The normal process is that Cirrus would release the firmware with the correct name for the platform, so the system-name matches the string in those release firmware files.

Do you have an official firmware for your platform?

Quoted 10 lines
Quoted 3 lines

tuning is going to be specific to the enclosure/speaker involved, so a generic tuning for say left amps doesn't really make a lot of sense.

I don't known about amp tuning much, my need just is loading firmware for more than 1 speaker amp at the platform using fdt.

One of the both way is good to me.

Quoted 3 lines

Thanks,
Charles

author
#5 lore raw
Quoted 11 lines · Richard Fitzgerald
Quoted 9 lines · Jianhua Lu
Quoted 6 lines · Charles Keepax

This direction seems slightly problematic, especially in the context of amps (which I presume this relates to, please let know if that is wrong). It would probably be better to be fixing things up such that the amp in question sets system_name when registered through DT. Generally speaking the idea is the amp

I also consider setting system_name when registered by DT, but I don't known setting what name to it. Card name or something else?

Quoted 6 lines

It just has to be a unique string.
The normal process is that Cirrus would release the firmware with the correct name for the platform, so the system-name matches the string in those release firmware files.

Do you have an official firmware for your platform?

My device is Xiaomi Pad 5 Pro, vendor releases wmfw firmware with default name, coeff firmware with prefix name(TL, TR and BL, BR....), don't contain a unique string in firmware name.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Thanks,
Charles

#6 lore raw
In reply to Jianhua Lu
Quoted 9 lines · Jianhua Lu
Quoted 6 lines · Charles Keepax

This direction seems slightly problematic, especially in the context of amps (which I presume this relates to, please let know if that is wrong). It would probably be better to be fixing things up such that the amp in question sets system_name when registered through DT. Generally speaking the idea is the amp

I also consider setting system_name when registered by DT, but I don't known setting what name to it. Card name or something else?

It just has to be a unique string.
The normal process is that Cirrus would release the firmware with the correct name for the platform, so the system-name matches the string in those release firmware files.

Do you have an official firmware for your platform?

Quoted 10 lines
Quoted 3 lines

tuning is going to be specific to the enclosure/speaker involved, so a generic tuning for say left amps doesn't really make a lot of sense.

I don't known about amp tuning much, my need just is loading firmware for more than 1 speaker amp at the platform using fdt.

One of the both way is good to me.

Quoted 3 lines

Thanks,
Charles

#7 lore raw
In reply to Jianhua Lu
Quoted 2 lines · Jianhua Lu

For platform using fdt, system_name is NULL, it doesn't provide a way to load firmware with prefix name, so add it.

This is intended behavior.

To load per-amp tuning you must know the function of each amp. You only know that if you know what hardware platform you are running on.

So if system_name is NULL it should fall back to generic firmware.

Quoted 38 lines
---
  sound/soc/codecs/wm_adsp.c | 14 ++++++++++++++
  1 file changed, 14 insertions(+)
sound/soc/codecs/wm_adsp.c +14 -0
index 216120b68b64..17481e42d440 100644
@@ -760,6 +760,10 @@ static int wm_adsp_request_firmware_file(struct wm_adsp *dsp,
  		*filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s.%s", dir, dsp->part,
  				      dsp->fwf_name, wm_adsp_fw[dsp->fw].file, system_name,
  				      filetype);
+	else if (asoc_component_prefix)
+		*filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s.%s", dir, dsp->part,
+				      dsp->fwf_name, wm_adsp_fw[dsp->fw].file, asoc_component_prefix,
+				      filetype);
  	else
  		*filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s.%s", dir, dsp->part, dsp->fwf_name,
  				      wm_adsp_fw[dsp->fw].file, filetype);
@@ -831,6 +835,16 @@ static int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
  							      NULL, "bin");
  			return 0;
  		}
+	} else if (asoc_component_prefix) {
+		if (!wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename,
+						   cirrus_dir, NULL,
+						   asoc_component_prefix, "wmfw")) {
+			adsp_dbg(dsp, "Found '%s'\n", *wmfw_filename);
+			wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename,
+							      cirrus_dir, NULL,
+							      asoc_component_prefix, "bin");
+			return 0;
+		}
  	}
 
  	if (!wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename,
author
#8 lore raw
Quoted 11 lines · Richard Fitzgerald
Quoted 2 lines · Jianhua Lu

For platform using fdt, system_name is NULL, it doesn't provide a way to load firmware with prefix name, so add it.

This is intended behavior.

To load per-amp tuning you must know the function of each amp. You only know that if you know what hardware platform you are running on.

So if system_name is NULL it should fall back to generic firmware.

Make sense

#9 lore raw
In reply to Jianhua Lu
Quoted 2 lines · Jianhua Lu

For platform using fdt, system_name is NULL, it doesn't provide a way to load firmware with prefix name, so add it.

This is intended behavior.

To load per-amp tuning you must know the function of each amp. You only know that if you know what hardware platform you are running on.

So if system_name is NULL it should fall back to generic firmware.

Quoted 38 lines
---
  sound/soc/codecs/wm_adsp.c | 14 ++++++++++++++
  1 file changed, 14 insertions(+)
sound/soc/codecs/wm_adsp.c +14 -0
index 216120b68b64..17481e42d440 100644
@@ -760,6 +760,10 @@ static int wm_adsp_request_firmware_file(struct wm_adsp *dsp,
  		*filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s.%s", dir, dsp->part,
  				      dsp->fwf_name, wm_adsp_fw[dsp->fw].file, system_name,
  				      filetype);
+	else if (asoc_component_prefix)
+		*filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s.%s", dir, dsp->part,
+				      dsp->fwf_name, wm_adsp_fw[dsp->fw].file, asoc_component_prefix,
+				      filetype);
  	else
  		*filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s.%s", dir, dsp->part, dsp->fwf_name,
  				      wm_adsp_fw[dsp->fw].file, filetype);
@@ -831,6 +835,16 @@ static int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
  							      NULL, "bin");
  			return 0;
  		}
+	} else if (asoc_component_prefix) {
+		if (!wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename,
+						   cirrus_dir, NULL,
+						   asoc_component_prefix, "wmfw")) {
+			adsp_dbg(dsp, "Found '%s'\n", *wmfw_filename);
+			wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename,
+							      cirrus_dir, NULL,
+							      asoc_component_prefix, "bin");
+			return 0;
+		}
  	}
 
  	if (!wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename,