diff mbox series

[v2,26/26] ALSA: hda: cs35l41: Add kernel config to disable firmware autoload

Message ID 20220509214703.4482-27-vitalyr@opensource.cirrus.com
State New
Headers show
Series *ALSA: hda: cirrus: Add initial DSP support and firmware loading | expand

Commit Message

Vitaly Rodionov May 9, 2022, 9:47 p.m. UTC
From: Stefan Binding <sbinding@opensource.cirrus.com>

By default, the driver will automatically load DSP firmware
for the amps, if available. Adding this option allows the
autoload to be optional, which allows for different configurations.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
---
 sound/pci/hda/Kconfig       |  7 +++++++
 sound/pci/hda/cs35l41_hda.c | 12 +++++++-----
 2 files changed, 14 insertions(+), 5 deletions(-)

Comments

Takashi Iwai May 11, 2022, 1:59 p.m. UTC | #1
On Mon, 09 May 2022 23:47:03 +0200,
Vitaly Rodionov wrote:
> 
> From: Stefan Binding <sbinding@opensource.cirrus.com>
> 
> By default, the driver will automatically load DSP firmware
> for the amps, if available. Adding this option allows the
> autoload to be optional, which allows for different configurations.

Shouldn't this be rather a runtime option instead of a build-time
kconfig?


thanks,

Takashi

> Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
> Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
> ---
>  sound/pci/hda/Kconfig       |  7 +++++++
>  sound/pci/hda/cs35l41_hda.c | 12 +++++++-----
>  2 files changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig
> index 1c378cca5dac..c4282dec4dd4 100644
> --- a/sound/pci/hda/Kconfig
> +++ b/sound/pci/hda/Kconfig
> @@ -94,6 +94,13 @@ config SND_HDA_PATCH_LOADER
>  config SND_HDA_SCODEC_CS35L41
>  	tristate
>  
> +config SND_HDA_SCODEC_CS35L41_DISABLE_FIRMWARE_AUTOSTART
> +	bool "Prevent CS35L41 from starting firmware on boot"
> +	depends on SND_HDA_SCODEC_CS35L41
> +	help
> +	  Say Y here to prevent the CS35L41 HDA driver from loading DSP
> +	  Firmware at boot
> +
>  config SND_HDA_CS_DSP_CONTROLS
>  	tristate
>  	depends on CS_DSP
> diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c
> index 70e5354e3950..8b9e966145b5 100644
> --- a/sound/pci/hda/cs35l41_hda.c
> +++ b/sound/pci/hda/cs35l41_hda.c
> @@ -773,11 +773,13 @@ static int cs35l41_hda_bind(struct device *dev, struct device *master, void *mas
>  
>  	cs35l41->firmware_type = HDA_CS_DSP_FW_SPK_PROT;
>  
> -	cs35l41->request_fw_load = true;
> -	mutex_lock(&cs35l41->fw_mutex);
> -	if (cs35l41_smart_amp(cs35l41) < 0)
> -		dev_warn(cs35l41->dev, "Cannot Run Firmware, reverting to dsp bypass...\n");
> -	mutex_unlock(&cs35l41->fw_mutex);
> +	if (!IS_ENABLED(CONFIG_SND_HDA_SCODEC_CS35L41_DISABLE_FIRMWARE_AUTOSTART)) {
> +		cs35l41->request_fw_load = true;
> +		mutex_lock(&cs35l41->fw_mutex);
> +		if (cs35l41_smart_amp(cs35l41) < 0)
> +			dev_warn(cs35l41->dev, "Cannot Run Firmware, reverting to dsp bypass...\n");
> +		mutex_unlock(&cs35l41->fw_mutex);
> +	}
>  
>  	cs35l41_create_controls(cs35l41);
>  
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig
index 1c378cca5dac..c4282dec4dd4 100644
--- a/sound/pci/hda/Kconfig
+++ b/sound/pci/hda/Kconfig
@@ -94,6 +94,13 @@  config SND_HDA_PATCH_LOADER
 config SND_HDA_SCODEC_CS35L41
 	tristate
 
+config SND_HDA_SCODEC_CS35L41_DISABLE_FIRMWARE_AUTOSTART
+	bool "Prevent CS35L41 from starting firmware on boot"
+	depends on SND_HDA_SCODEC_CS35L41
+	help
+	  Say Y here to prevent the CS35L41 HDA driver from loading DSP
+	  Firmware at boot
+
 config SND_HDA_CS_DSP_CONTROLS
 	tristate
 	depends on CS_DSP
diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c
index 70e5354e3950..8b9e966145b5 100644
--- a/sound/pci/hda/cs35l41_hda.c
+++ b/sound/pci/hda/cs35l41_hda.c
@@ -773,11 +773,13 @@  static int cs35l41_hda_bind(struct device *dev, struct device *master, void *mas
 
 	cs35l41->firmware_type = HDA_CS_DSP_FW_SPK_PROT;
 
-	cs35l41->request_fw_load = true;
-	mutex_lock(&cs35l41->fw_mutex);
-	if (cs35l41_smart_amp(cs35l41) < 0)
-		dev_warn(cs35l41->dev, "Cannot Run Firmware, reverting to dsp bypass...\n");
-	mutex_unlock(&cs35l41->fw_mutex);
+	if (!IS_ENABLED(CONFIG_SND_HDA_SCODEC_CS35L41_DISABLE_FIRMWARE_AUTOSTART)) {
+		cs35l41->request_fw_load = true;
+		mutex_lock(&cs35l41->fw_mutex);
+		if (cs35l41_smart_amp(cs35l41) < 0)
+			dev_warn(cs35l41->dev, "Cannot Run Firmware, reverting to dsp bypass...\n");
+		mutex_unlock(&cs35l41->fw_mutex);
+	}
 
 	cs35l41_create_controls(cs35l41);