hda-codec - kernel config for each codec

Create kernel configs to choose the codec support codes to build.

diff -r dbd0f41540fe pci/Kconfig
--- a/pci/Kconfig	Wed May 02 12:48:11 2007 +0200
+++ b/pci/Kconfig	Wed May 02 16:09:57 2007 +0200
@@ -498,6 +498,69 @@ config SND_HDA_HWDEP
 	  This interface can be used for out-of-bound communication
 	  with codesc for debugging purposes.
 
+config SND_HDA_CODEC_REALTEK
+	bool "Build Realtek HD-audio codec support"
+	depends on SND_HDA_INTEL
+	help
+	  Say Y here to include Realtek HD-audio codec support in
+	  snd-hda-intel driver, such as ALC880.
+
+config SND_HDA_CODEC_ANALOG
+	bool "Build Analog Device HD-audio codec support"
+	depends on SND_HDA_INTEL
+	help
+	  Say Y here to include Analog Device HD-audio codec support in
+	  snd-hda-intel driver, such as AD1986A.
+
+config SND_HDA_CODEC_SIGMATEL
+	bool "Build IDT/Sigmatel HD-audio codec support"
+	depends on SND_HDA_INTEL
+	help
+	  Say Y here to include IDT (Sigmatel) HD-audio codec support in
+	  snd-hda-intel driver, such as STAC9200.
+
+config SND_HDA_CODEC_VIA
+	bool "Build VIA HD-audio codec support"
+	depends on SND_HDA_INTEL
+	help
+	  Say Y here to include VIA HD-audio codec support in
+	  snd-hda-intel driver, such as VT1708.
+
+config SND_HDA_CODEC_ATIHDMI
+	bool "Build ATI HDMI HD-audio codec support"
+	depends on SND_HDA_INTEL
+	help
+	  Say Y here to include ATI HDMI HD-audio codec support in
+	  snd-hda-intel driver, such as ATI RS600 HDMI.
+
+config SND_HDA_CODEC_CONEXANT
+	bool "Build Conexant HD-audio codec support"
+	depends on SND_HDA_INTEL
+	help
+	  Say Y here to include Conexant HD-audio codec support in
+	  snd-hda-intel driver, such as CX20549.
+
+config SND_HDA_CODEC_CMEDIA
+	bool "Build C-Media HD-audio codec support"
+	depends on SND_HDA_INTEL
+	help
+	  Say Y here to include C-Media HD-audio codec support in
+	  snd-hda-intel driver, such as CMI9880.
+
+config SND_HDA_CODEC_SI3054
+	bool "Build Silicon Labs 3054 HD-modem codec support"
+	depends on SND_HDA_INTEL
+	help
+	  Say Y here to include Silicon Labs 3054 HD-modem codec
+	  (and compatibles) support in snd-hda-intel driver.
+
+config SND_HDA_GENERIC
+	bool "Enable generic HD-audio codec parser"
+	depends on SND_HDA_INTEL
+	help
+	  Say Y here to enable the generic HD-audio codec parser
+	  in snd-hda-intel driver.
+
 config SND_HDSP
 	tristate "RME Hammerfall DSP Audio"
 	depends on SND
diff -r dbd0f41540fe pci/hda/Makefile
--- a/pci/hda/Makefile	Wed May 02 12:48:11 2007 +0200
+++ b/pci/hda/Makefile	Wed May 02 16:09:57 2007 +0200
@@ -2,18 +2,36 @@ snd-hda-intel-objs := hda_intel.o
 # since snd-hda-intel is the only driver using hda-codec,
 # merge it into a single module although it was originally
 # designed to be individual modules
-snd-hda-intel-objs += hda_codec.o \
-	hda_generic.o \
-	patch_realtek.o \
-	patch_cmedia.o \
-	patch_analog.o \
-	patch_sigmatel.o \
-	patch_si3054.o \
-	patch_atihdmi.o \
-	patch_conexant.o \
-	patch_via.o
+snd-hda-intel-objs += hda_codec.o
 ifdef CONFIG_PROC_FS
 snd-hda-intel-objs += hda_proc.o
+endif
+ifdef CONFIG_SND_HDA_CODEC_REALTEK
+snd-hda-intel-objs += patch_realtek.o
+endif
+ifdef CONFIG_SND_HDA_CODEC_CMEDIA
+snd-hda-intel-objs += patch_cmedia.o
+endif
+ifdef CONFIG_SND_HDA_CODEC_ANALOG
+snd-hda-intel-objs += patch_analog.o
+endif
+ifdef CONFIG_SND_HDA_CODEC_SIGMATEL
+snd-hda-intel-objs += patch_sigmatel.o
+endif
+ifdef CONFIG_SND_HDA_CODEC_SI3054
+snd-hda-intel-objs += patch_si3054.o
+endif
+ifdef CONFIG_SND_HDA_CODEC_ATIHDMI
+snd-hda-intel-objs += patch_atihdmi.o
+endif
+ifdef CONFIG_SND_HDA_CODEC_CONEXANT
+snd-hda-intel-objs += patch_conexant.o
+endif
+ifdef CONFIG_SND_HDA_CODEC_VIA
+snd-hda-intel-objs += patch_via.o
+endif
+ifdef CONFIG_SND_HDA_GENERIC
+snd-hda-intel-objs += hda_generic.o
 endif
 ifdef CONFIG_SND_HDA_HWDEP
 snd-hda-intel-objs += hda_hwdep.o
diff -r dbd0f41540fe pci/hda/hda_codec.c
--- a/pci/hda/hda_codec.c	Wed May 02 12:48:11 2007 +0200
+++ b/pci/hda/hda_codec.c	Wed May 02 16:09:57 2007 +0200
@@ -388,6 +388,13 @@ int __devinit snd_hda_bus_new(struct snd
 	return 0;
 }
 
+#ifdef CONFIG_SND_HDA_GENERIC
+#define is_generic_config(codec) \
+	(codec->bus->modelname && !strcmp(codec->bus->modelname, "generic"))
+#else
+#define is_generic_config(codec)	0
+#endif
+
 /*
  * find a matching codec preset
  */
@@ -396,7 +403,7 @@ find_codec_preset(struct hda_codec *code
 {
 	const struct hda_codec_preset **tbl, *preset;
 
-	if (codec->bus->modelname && !strcmp(codec->bus->modelname, "generic"))
+	if (is_generic_config(codec))
 		return NULL; /* use the generic parser */
 
 	for (tbl = hda_preset_tables; *tbl; tbl++) {
@@ -582,10 +589,26 @@ int __devinit snd_hda_codec_new(struct h
 		snd_hda_get_codec_name(codec, bus->card->mixername,
 				       sizeof(bus->card->mixername));
 
-	if (codec->preset && codec->preset->patch)
+#ifdef CONFIG_SND_HDA_GENERIC
+	if (is_generic_config(codec)) {
+		err = snd_hda_parse_generic_codec(codec);
+		goto patched;
+	}
+#endif
+	if (codec->preset && codec->preset->patch) {
 		err = codec->preset->patch(codec);
-	else
-		err = snd_hda_parse_generic_codec(codec);
+		goto patched;
+	}
+
+	/* call the default parser */
+#ifdef CONFIG_SND_HDA_GENERIC
+	err = snd_hda_parse_generic_codec(codec);
+#else
+	printk(KERN_ERR "hda-codec: No codec parser is available\n");
+	err = -ENODEV;
+#endif
+
+ patched:
 	if (err < 0) {
 		snd_hda_codec_free(codec);
 		return err;
diff -r dbd0f41540fe pci/hda/hda_patch.h
--- a/pci/hda/hda_patch.h	Wed May 02 12:48:11 2007 +0200
+++ b/pci/hda/hda_patch.h	Wed May 02 16:09:57 2007 +0200
@@ -20,13 +20,29 @@ extern struct hda_codec_preset snd_hda_p
 extern struct hda_codec_preset snd_hda_preset_via[];
 
 static const struct hda_codec_preset *hda_preset_tables[] = {
+#ifdef CONFIG_SND_HDA_CODEC_REALTEK
 	snd_hda_preset_realtek,
+#endif
+#ifdef CONFIG_SND_HDA_CODEC_CMEDIA
 	snd_hda_preset_cmedia,
+#endif
+#ifdef CONFIG_SND_HDA_CODEC_ANALOG
 	snd_hda_preset_analog,
+#endif
+#ifdef CONFIG_SND_HDA_CODEC_SIGMATEL
 	snd_hda_preset_sigmatel,
+#endif
+#ifdef CONFIG_SND_HDA_CODEC_SI3054
 	snd_hda_preset_si3054,
+#endif
+#ifdef CONFIG_SND_HDA_CODEC_ATIHDMI
 	snd_hda_preset_atihdmi,
+#endif
+#ifdef CONFIG_SND_HDA_CODEC_CONEXANT
 	snd_hda_preset_conexant,
+#endif
+#ifdef CONFIG_SND_HDA_CODEC_VIA
 	snd_hda_preset_via,
+#endif
 	NULL
 };
