aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_codec.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2006-11-24 11:07:44 -0500
committerJaroslav Kysela <perex@suse.cz>2007-02-09 03:02:04 -0500
commitf5fcc13c2fc62da6f75d80189a51c2492afb39c0 (patch)
treea08340173113cd5f64653b81b656f58ecb27a091 /sound/pci/hda/hda_codec.c
parent0b830bac35dd6e3996bee675c3893857da8a4d0a (diff)
[ALSA] hda-codec - Use snd_pci_quirk_lookup() for board config lookup
Use snd_pci_quirk_lookup() for looking up a board config table. The config table is sorted in numerical order of PCI SSIDs. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/pci/hda/hda_codec.c')
-rw-r--r--sound/pci/hda/hda_codec.c57
1 files changed, 35 insertions, 22 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 18bbc87e376f..c07d5db6b050 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -1714,6 +1714,8 @@ EXPORT_SYMBOL(snd_hda_build_pcms);
1714/** 1714/**
1715 * snd_hda_check_board_config - compare the current codec with the config table 1715 * snd_hda_check_board_config - compare the current codec with the config table
1716 * @codec: the HDA codec 1716 * @codec: the HDA codec
1717 * @num_configs: number of config enums
1718 * @models: array of model name strings
1717 * @tbl: configuration table, terminated by null entries 1719 * @tbl: configuration table, terminated by null entries
1718 * 1720 *
1719 * Compares the modelname or PCI subsystem id of the current codec with the 1721 * Compares the modelname or PCI subsystem id of the current codec with the
@@ -1722,33 +1724,44 @@ EXPORT_SYMBOL(snd_hda_build_pcms);
1722 * 1724 *
1723 * If no entries are matching, the function returns a negative value. 1725 * If no entries are matching, the function returns a negative value.
1724 */ 1726 */
1725int snd_hda_check_board_config(struct hda_codec *codec, const struct hda_board_config *tbl) 1727int snd_hda_check_board_config(struct hda_codec *codec,
1726{ 1728 int num_configs, const char **models,
1727 const struct hda_board_config *c; 1729 const struct snd_pci_quirk *tbl)
1728 1730{
1729 if (codec->bus->modelname) { 1731 if (codec->bus->modelname && models) {
1730 for (c = tbl; c->modelname || c->pci_subvendor; c++) { 1732 int i;
1731 if (c->modelname && 1733 for (i = 0; i < num_configs; i++) {
1732 ! strcmp(codec->bus->modelname, c->modelname)) { 1734 if (models[i] &&
1733 snd_printd(KERN_INFO "hda_codec: model '%s' is selected\n", c->modelname); 1735 !strcmp(codec->bus->modelname, models[i])) {
1734 return c->config; 1736 snd_printd(KERN_INFO "hda_codec: model '%s' is "
1737 "selected\n", models[i]);
1738 return i;
1735 } 1739 }
1736 } 1740 }
1737 } 1741 }
1738 1742
1739 if (codec->bus->pci) { 1743 if (!codec->bus->pci || !tbl)
1740 u16 subsystem_vendor, subsystem_device; 1744 return -1;
1741 pci_read_config_word(codec->bus->pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor); 1745
1742 pci_read_config_word(codec->bus->pci, PCI_SUBSYSTEM_ID, &subsystem_device); 1746 tbl = snd_pci_quirk_lookup(codec->bus->pci, tbl);
1743 for (c = tbl; c->modelname || c->pci_subvendor; c++) { 1747 if (!tbl)
1744 if (c->pci_subvendor == subsystem_vendor && 1748 return -1;
1745 (! c->pci_subdevice /* all match */|| 1749 if (tbl->value >= 0 && tbl->value < num_configs) {
1746 (c->pci_subdevice == subsystem_device))) { 1750#ifdef CONFIG_SND_DEBUG_DETECT
1747 snd_printdd(KERN_INFO "hda_codec: PCI %x:%x, codec config %d is selected\n", 1751 char tmp[10];
1748 subsystem_vendor, subsystem_device, c->config); 1752 const char *model = NULL;
1749 return c->config; 1753 if (models)
1750 } 1754 model = models[tbl->value];
1755 if (!model) {
1756 sprintf(tmp, "#%d", tbl->value);
1757 model = tmp;
1751 } 1758 }
1759 snd_printdd(KERN_INFO "hda_codec: model '%s' is selected "
1760 "for config %x:%x (%s)\n",
1761 model, tbl->subvendor, tbl->subdevice,
1762 (tbl->name ? tbl->name : "Unknown device"));
1763#endif
1764 return tbl->value;
1752 } 1765 }
1753 return -1; 1766 return -1;
1754} 1767}