[PATCH 0/8] ALSA: hda: Add model option to codec drivers, too
Hi,
this is a trivial patch set to add the "model" option to each HD-audio codec driver that works equivalently with snd-hda-intel or SOF driver's model option. It makes it easer for users to specify the quirk to the right target.
Takashi
===
Takashi Iwai (8): ALSA: hda/realtek: Add model option to codec driver, too ALSA: hda/cirrus: Add model option to codec driver, too ALSA: hda/conexant: Add model option to codec driver, too ALSA: hda/cs8409: Add model option to codec driver, too ALSA: hda/analog: Add model option to codec driver, too ALSA: hda/sigmatel: Add model option to codec driver, too ALSA: hda/via: Add model option to codec driver, too ALSA: doc: Explain more about model option
Documentation/sound/hd-audio/notes.rst | 16 ++++++++++++++++ sound/pci/hda/patch_analog.c | 10 ++++++++++ sound/pci/hda/patch_cirrus.c | 10 ++++++++++ sound/pci/hda/patch_conexant.c | 10 ++++++++++ sound/pci/hda/patch_cs8409.c | 10 ++++++++++ sound/pci/hda/patch_realtek.c | 11 +++++++++++ sound/pci/hda/patch_sigmatel.c | 11 +++++++++++ sound/pci/hda/patch_via.c | 11 +++++++++++ 8 files changed, 89 insertions(+)
The model option of snd-hda-intel or SOF driver is useful for testing / debugging quirks. Since many devices have multiple codecs and the quirk is rather codec-specific, it's often difficult to pass the model to the proper target.
This patch adds the equivalent model option to Realek codec driver, so that user can optionally specify the option for the codec instead of snd-hda-intel or SOF drivers.
That is, you can pass the boot option like snd_hda_codec_realtek.model=foobar or snd_hda_codec_realtek.model=103c:89c6 for applying a quirk.
The model option of snd-hda-intel or SOF is still effective. When the option is given for both, the option for the controller driver wins.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/hda/patch_realtek.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 3dc19174670e..351eb582ad8c 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -16,6 +16,7 @@ #include <linux/pci.h> #include <linux/dmi.h> #include <linux/module.h> +#include <linux/moduleparam.h> #include <linux/input.h> #include <linux/leds.h> #include <sound/core.h> @@ -27,6 +28,11 @@ #include "hda_generic.h" #include "hda_component.h"
+/* codec-specific model option -- equivalent with snd-hda-intel.model option */ +static char *codec_model; +module_param_named(model, codec_model, charp, 0444); +MODULE_PARM_DESC(model, "Use the given board model."); + /* keep halting ALC5505 DSP, for power saving */ #define HALT_REALTEK_ALC5505
@@ -1207,6 +1213,11 @@ static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid) kfree(spec); return err; } + + /* assign optional modelname; freed at snd_hda_codec_dev_release() */ + if (!codec->modelname && codec_model) + codec->modelname = kstrdup(codec_model, GFP_KERNEL); + return 0; }
The model option of snd-hda-intel or SOF driver is useful for testing / debugging quirks. Since many devices have multiple codecs and the quirk is rather codec-specific, it's often difficult to pass the model to the proper target.
This patch adds the equivalent model option to Cirrus codec driver, so that user can optionally specify the option for the codec instead of snd-hda-intel or SOF drivers.
That is, you can pass the boot option like snd_hda_codec_cirrus.model=foobar or snd_hda_codec_cirrus.model=106b:5e00 for applying a quirk.
The model option of snd-hda-intel or SOF is still effective. When the option is given for both, the option for the controller driver wins.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/hda/patch_cirrus.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index 6807b4708a17..c70c72c85831 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c @@ -8,6 +8,7 @@ #include <linux/init.h> #include <linux/slab.h> #include <linux/module.h> +#include <linux/moduleparam.h> #include <sound/core.h> #include <linux/pci.h> #include <sound/tlv.h> @@ -17,6 +18,11 @@ #include "hda_jack.h" #include "hda_generic.h"
+/* codec-specific model option -- equivalent with snd-hda-intel.model option */ +static char *codec_model; +module_param_named(model, codec_model, charp, 0444); +MODULE_PARM_DESC(model, "Use the given board model."); + /* */
@@ -581,6 +587,10 @@ static struct cs_spec *cs_alloc_spec(struct hda_codec *codec, int vendor_nid) codec->power_save_node = 1; snd_hda_gen_spec_init(&spec->gen);
+ /* assign optional modelname; freed at snd_hda_codec_dev_release() */ + if (!codec->modelname && codec_model) + codec->modelname = kstrdup(codec_model, GFP_KERNEL); + return spec; }
The model option of snd-hda-intel or SOF driver is useful for testing / debugging quirks. Since many devices have multiple codecs and the quirk is rather codec-specific, it's often difficult to pass the model to the proper target.
This patch adds the equivalent model option to Conexant codec driver, so that user can optionally specify the option for the codec instead of snd-hda-intel or SOF drivers.
That is, you can pass the boot option like snd_hda_codec_conexant.model=foobar or snd_hda_codec_conexant.model=17aa:3905 for applying a quirk no matter whether you use snd-hda-intel or SOF.
The model option of snd-hda-intel or SOF is still effective. When the option is given for both, the option for the controller driver wins.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/hda/patch_conexant.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 7b1a30a551f6..8a4a793740f3 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -11,6 +11,7 @@ #include <linux/delay.h> #include <linux/slab.h> #include <linux/module.h> +#include <linux/moduleparam.h> #include <sound/core.h> #include <sound/jack.h>
@@ -21,6 +22,11 @@ #include "hda_jack.h" #include "hda_generic.h"
+/* codec-specific model option -- equivalent with snd-hda-intel.model option */ +static char *codec_model; +module_param_named(model, codec_model, charp, 0444); +MODULE_PARM_DESC(model, "Use the given board model."); + struct conexant_spec { struct hda_gen_spec gen;
@@ -1038,6 +1044,10 @@ static int patch_conexant_auto(struct hda_codec *codec) codec->spec = spec; codec->patch_ops = cx_auto_patch_ops;
+ /* assign optional modelname; freed at snd_hda_codec_dev_release() */ + if (!codec->modelname && codec_model) + codec->modelname = kstrdup(codec_model, GFP_KERNEL); + cx_auto_parse_eapd(codec); spec->gen.own_eapd_ctl = 1;
The model option of snd-hda-intel or SOF driver is useful for testing / debugging quirks. Since many devices have multiple codecs and the quirk is rather codec-specific, it's often difficult to pass the model to the proper target.
This patch adds the equivalent model option to CS8409 codec driver, so that user can optionally specify the option for the codec instead of snd-hda-intel or SOF drivers.
That is, you can pass the boot option like snd_hda_codec_cs8409.model=foobar or snd_hda_codec_cs8409.model=1028:0c43 for applying a quirk no matter whether you use snd-hda-intel or SOF.
The model option of snd-hda-intel or SOF is still effective. When the option is given for both, the option for the controller driver wins.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/hda/patch_cs8409.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/sound/pci/hda/patch_cs8409.c b/sound/pci/hda/patch_cs8409.c index 754aa8ddd2e4..13aef05383a4 100644 --- a/sound/pci/hda/patch_cs8409.c +++ b/sound/pci/hda/patch_cs8409.c @@ -9,10 +9,16 @@ #include <linux/init.h> #include <linux/slab.h> #include <linux/module.h> +#include <linux/moduleparam.h> #include <sound/core.h> #include <linux/mutex.h> #include <linux/iopoll.h>
+/* codec-specific model option -- equivalent with snd-hda-intel.model option */ +static char *codec_model; +module_param_named(model, codec_model, charp, 0444); +MODULE_PARM_DESC(model, "Use the given board model."); + #include "patch_cs8409.h"
/****************************************************************************** @@ -66,6 +72,10 @@ static struct cs8409_spec *cs8409_alloc_spec(struct hda_codec *codec) INIT_DELAYED_WORK(&spec->i2c_clk_work, cs8409_disable_i2c_clock_worker); snd_hda_gen_spec_init(&spec->gen);
+ /* assign optional modelname; freed at snd_hda_codec_dev_release() */ + if (!codec->modelname && codec_model) + codec->modelname = kstrdup(codec_model, GFP_KERNEL); + return spec; }
The model option of snd-hda-intel or SOF driver is useful for testing / debugging quirks. Since many devices have multiple codecs and the quirk is rather codec-specific, it's often difficult to pass the model to the proper target.
This patch adds the equivalent model option to Analog codec driver, so that user can optionally specify the option for the codec instead of snd-hda-intel or SOF drivers.
That is, you can pass the boot option like snd_hda_codec_analog.model=foobar or snd_hda_codec_analog.model=103c:2a82 for applying a quirk no matter whether you use snd-hda-intel or SOF.
The model option of snd-hda-intel or SOF is still effective. When the option is given for both, the option for the controller driver wins.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/hda/patch_analog.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 8afe6000f7da..1a6efa79309f 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -9,6 +9,7 @@ #include <linux/init.h> #include <linux/slab.h> #include <linux/module.h> +#include <linux/moduleparam.h>
#include <sound/core.h> #include <sound/hda_codec.h> @@ -18,6 +19,10 @@ #include "hda_jack.h" #include "hda_generic.h"
+/* codec-specific model option -- equivalent with snd-hda-intel.model option */ +static char *codec_model; +module_param_named(model, codec_model, charp, 0444); +MODULE_PARM_DESC(model, "Use the given board model.");
struct ad198x_spec { struct hda_gen_spec gen; @@ -203,6 +208,11 @@ static int alloc_ad_spec(struct hda_codec *codec) codec->spec = spec; snd_hda_gen_spec_init(&spec->gen); codec->patch_ops = ad198x_auto_patch_ops; + + /* assign optional modelname; freed at snd_hda_codec_dev_release() */ + if (!codec->modelname && codec_model) + codec->modelname = kstrdup(codec_model, GFP_KERNEL); + return 0; }
The model option of snd-hda-intel or SOF driver is useful for testing / debugging quirks. Since many devices have multiple codecs and the quirk is rather codec-specific, it's often difficult to pass the model to the proper target.
This patch adds the equivalent model option to IDT/Sigmatel codec driver, so that user can optionally specify the option for the codec instead of snd-hda-intel or SOF drivers.
That is, you can pass the boot option like snd_hda_codec_idt.model=foobar or snd_hda_codec_idt.model=103c:3610 for applying a quirk no matter whether you use snd-hda-intel or SOF.
The model option of snd-hda-intel or SOF is still effective. When the option is given for both, the option for the controller driver wins.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/hda/patch_sigmatel.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 7f340f18599c..f3143f8b59f0 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -17,6 +17,7 @@ #include <linux/pci.h> #include <linux/dmi.h> #include <linux/module.h> +#include <linux/moduleparam.h> #include <sound/core.h> #include <sound/jack.h> #include <sound/hda_codec.h> @@ -26,6 +27,11 @@ #include "hda_jack.h" #include "hda_generic.h"
+/* codec-specific model option -- equivalent with snd-hda-intel.model option */ +static char *codec_model; +module_param_named(model, codec_model, charp, 0444); +MODULE_PARM_DESC(model, "Use the given board model."); + enum { STAC_REF, STAC_9200_OQO, @@ -4494,6 +4500,11 @@ static int alloc_stac_spec(struct hda_codec *codec) codec->no_trigger_sense = 1; /* seems common with STAC/IDT codecs */ spec->gen.dac_min_mute = true; codec->patch_ops = stac_patch_ops; + + /* assign optional modelname; freed at snd_hda_codec_dev_release() */ + if (!codec->modelname && codec_model) + codec->modelname = kstrdup(codec_model, GFP_KERNEL); + return 0; }
The model option of snd-hda-intel or SOF driver is useful for testing / debugging quirks. Since many devices have multiple codecs and the quirk is rather codec-specific, it's often difficult to pass the model to the proper target.
This patch adds the equivalent model option to VIA codec driver, so that user can optionally specify the option for the codec instead of snd-hda-intel or SOF drivers.
That is, you can pass the boot option like snd_hda_codec_via.model=foobar or snd_hda_codec_via.model=1043:13f7 for applying a quirk no matter whether you use snd-hda-intel or SOF.
The model option of snd-hda-intel or SOF is still effective. When the option is given for both, the option for the controller driver wins.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/hda/patch_via.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index aea7fae2ca4b..a60900525d8c 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -37,6 +37,7 @@ #include <linux/delay.h> #include <linux/slab.h> #include <linux/module.h> +#include <linux/moduleparam.h> #include <sound/core.h> #include <sound/asoundef.h> #include <sound/hda_codec.h> @@ -45,6 +46,11 @@ #include "hda_jack.h" #include "hda_generic.h"
+/* codec-specific model option -- equivalent with snd-hda-intel.model option */ +static char *codec_model; +module_param_named(model, codec_model, charp, 0444); +MODULE_PARM_DESC(model, "Use the given board model."); + /* Pin Widget NID */ #define VT1708_HP_PIN_NID 0x20 #define VT1708_CD_PIN_NID 0x24 @@ -119,6 +125,11 @@ static struct via_spec *via_new_spec(struct hda_codec *codec) codec->power_save_node = 1; spec->gen.power_down_unused = 1; codec->patch_ops = via_patch_ops; + + /* assign optional modelname; freed at snd_hda_codec_dev_release() */ + if (!codec->modelname && codec_model) + codec->modelname = kstrdup(codec_model, GFP_KERNEL); + return spec; }
Add a bit more explanation about passing the snd-hda-intel model option at the right place. Also, a brief description about the new codec model option is added along with it.
Signed-off-by: Takashi Iwai tiwai@suse.de --- Documentation/sound/hd-audio/notes.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
diff --git a/Documentation/sound/hd-audio/notes.rst b/Documentation/sound/hd-audio/notes.rst index d118b6fe269b..dc84be14273b 100644 --- a/Documentation/sound/hd-audio/notes.rst +++ b/Documentation/sound/hd-audio/notes.rst @@ -226,6 +226,22 @@ model=103c:8862 will apply the quirk for HP ProBook 445 G8 (which isn't found in the model table as of writing) as long as the device is handled equivalently by the same driver.
+The ``model`` option of snd-hda-intel takes an array of strings, +applied one per PCI device. When there are multiple HD-audio +controllers and you want to apply a quirk for a certain one, you have +to pass the option carefully at the right position. +For example, when an on-board analog audio with a Realtek codec is +found at the secondary PCI slot while the first slot is for HDMI/DP +controller, you'll need to pass the option like ``model=,foobar`` +(note the comma before ``foobar``), so that the first entry is +skipped. + +For making this complexity a bit easier, since 6.1 kernel, codec +drivers may take also ``model`` option, too. It works equivalently as +the model option of the controller driver. +In the example case above, you can pass the option to Realtek codec +driver directly; e.g. ``snd_hda_codec_realtek.model=foobar`` on +command line.
Speaker and Headphone Output ----------------------------
On 29. 09. 22 9:35, Takashi Iwai wrote:
Hi,
this is a trivial patch set to add the "model" option to each HD-audio codec driver that works equivalently with snd-hda-intel or SOF driver's model option. It makes it easer for users to specify the quirk to the right target.
I am not convinced, if it's "easier" for users. Perhaps, it will make more sense to add this option to the snd_intel_dspcfg module (so the model can be controlled in the one place). I admit that users are a bit confused with the snd-hda-intel and SOF differences.
Jaroslav
On Thu, 29 Sep 2022 09:46:47 +0200, Jaroslav Kysela wrote:
On 29. 09. 22 9:35, Takashi Iwai wrote:
Hi,
this is a trivial patch set to add the "model" option to each HD-audio codec driver that works equivalently with snd-hda-intel or SOF driver's model option. It makes it easer for users to specify the quirk to the right target.
I am not convinced, if it's "easier" for users. Perhaps, it will make more sense to add this option to the snd_intel_dspcfg module (so the model can be controlled in the one place). I admit that users are a bit confused with the snd-hda-intel and SOF differences.
Yes, and that's another reason for moving this rather to codec. By applying directly the option to the codec driver, it works no matter which control driver is used.
And, snd_intel_dspcfg is no better choice, IMO. If you have multiple controllers, you'll hit the same problem as snd-hda-intel. (And SOF ignores that use case completely, but it's fine, as SOF is more or less bound only with the onboard controller.)
Takashi
participants (2)
-
Jaroslav Kysela
-
Takashi Iwai