aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_codec.c
diff options
context:
space:
mode:
authorJaroslav Kysela <perex@perex.cz>2009-12-08 10:13:32 -0500
committerJaroslav Kysela <perex@perex.cz>2009-12-15 03:33:04 -0500
commit5b0cb1d850c26893b1468b3a519433a1b7a176be (patch)
treec6f4ab97db6de9230b02d6cfce8976b762f3b485 /sound/pci/hda/hda_codec.c
parentf40542532e96dda5506eb76badea322f2ae4731c (diff)
ALSA: hda - add more NID->Control mapping
This set of changes add missing NID values to some static control elemenents. Also, it handles all "Capture Source" or "Input Source" controls. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci/hda/hda_codec.c')
-rw-r--r--sound/pci/hda/hda_codec.c64
1 files changed, 62 insertions, 2 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 9cfdb771928c..20100b1548e1 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -931,6 +931,7 @@ static void snd_hda_codec_free(struct hda_codec *codec)
931#endif 931#endif
932 list_del(&codec->list); 932 list_del(&codec->list);
933 snd_array_free(&codec->mixers); 933 snd_array_free(&codec->mixers);
934 snd_array_free(&codec->nids);
934 codec->bus->caddr_tbl[codec->addr] = NULL; 935 codec->bus->caddr_tbl[codec->addr] = NULL;
935 if (codec->patch_ops.free) 936 if (codec->patch_ops.free)
936 codec->patch_ops.free(codec); 937 codec->patch_ops.free(codec);
@@ -985,7 +986,8 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr
985 mutex_init(&codec->control_mutex); 986 mutex_init(&codec->control_mutex);
986 init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info)); 987 init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info));
987 init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head)); 988 init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head));
988 snd_array_init(&codec->mixers, sizeof(struct hda_nid_item), 60); 989 snd_array_init(&codec->mixers, sizeof(struct hda_nid_item), 32);
990 snd_array_init(&codec->nids, sizeof(struct hda_nid_item), 32);
989 snd_array_init(&codec->init_pins, sizeof(struct hda_pincfg), 16); 991 snd_array_init(&codec->init_pins, sizeof(struct hda_pincfg), 16);
990 snd_array_init(&codec->driver_pins, sizeof(struct hda_pincfg), 16); 992 snd_array_init(&codec->driver_pins, sizeof(struct hda_pincfg), 16);
991 if (codec->bus->modelname) { 993 if (codec->bus->modelname) {
@@ -1706,7 +1708,7 @@ struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec,
1706EXPORT_SYMBOL_HDA(snd_hda_find_mixer_ctl); 1708EXPORT_SYMBOL_HDA(snd_hda_find_mixer_ctl);
1707 1709
1708/** 1710/**
1709 * snd_hda_ctl-add - Add a control element and assign to the codec 1711 * snd_hda_ctl_add - Add a control element and assign to the codec
1710 * @codec: HD-audio codec 1712 * @codec: HD-audio codec
1711 * @nid: corresponding NID (optional) 1713 * @nid: corresponding NID (optional)
1712 * @kctl: the control element to assign 1714 * @kctl: the control element to assign
@@ -1747,6 +1749,35 @@ int snd_hda_ctl_add(struct hda_codec *codec, hda_nid_t nid,
1747EXPORT_SYMBOL_HDA(snd_hda_ctl_add); 1749EXPORT_SYMBOL_HDA(snd_hda_ctl_add);
1748 1750
1749/** 1751/**
1752 * snd_hda_add_nid - Assign a NID to a control element
1753 * @codec: HD-audio codec
1754 * @nid: corresponding NID (optional)
1755 * @kctl: the control element to assign
1756 * @index: index to kctl
1757 *
1758 * Add the given control element to an array inside the codec instance.
1759 * This function is used when #snd_hda_ctl_add cannot be used for 1:1
1760 * NID:KCTL mapping - for example "Capture Source" selector.
1761 */
1762int snd_hda_add_nid(struct hda_codec *codec, struct snd_kcontrol *kctl,
1763 unsigned int index, hda_nid_t nid)
1764{
1765 struct hda_nid_item *item;
1766
1767 if (nid > 0) {
1768 item = snd_array_new(&codec->nids);
1769 if (!item)
1770 return -ENOMEM;
1771 item->kctl = kctl;
1772 item->index = index;
1773 item->nid = nid;
1774 return 0;
1775 }
1776 return -EINVAL;
1777}
1778EXPORT_SYMBOL_HDA(snd_hda_add_nid);
1779
1780/**
1750 * snd_hda_ctls_clear - Clear all controls assigned to the given codec 1781 * snd_hda_ctls_clear - Clear all controls assigned to the given codec
1751 * @codec: HD-audio codec 1782 * @codec: HD-audio codec
1752 */ 1783 */
@@ -1757,6 +1788,7 @@ void snd_hda_ctls_clear(struct hda_codec *codec)
1757 for (i = 0; i < codec->mixers.used; i++) 1788 for (i = 0; i < codec->mixers.used; i++)
1758 snd_ctl_remove(codec->bus->card, items[i].kctl); 1789 snd_ctl_remove(codec->bus->card, items[i].kctl);
1759 snd_array_free(&codec->mixers); 1790 snd_array_free(&codec->mixers);
1791 snd_array_free(&codec->nids);
1760} 1792}
1761 1793
1762/* pseudo device locking 1794/* pseudo device locking
@@ -3476,6 +3508,8 @@ int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew)
3476 3508
3477 for (; knew->name; knew++) { 3509 for (; knew->name; knew++) {
3478 struct snd_kcontrol *kctl; 3510 struct snd_kcontrol *kctl;
3511 if (knew->iface == -1) /* skip this codec private value */
3512 continue;
3479 kctl = snd_ctl_new1(knew, codec); 3513 kctl = snd_ctl_new1(knew, codec);
3480 if (!kctl) 3514 if (!kctl)
3481 return -ENOMEM; 3515 return -ENOMEM;
@@ -3496,6 +3530,32 @@ int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew)
3496} 3530}
3497EXPORT_SYMBOL_HDA(snd_hda_add_new_ctls); 3531EXPORT_SYMBOL_HDA(snd_hda_add_new_ctls);
3498 3532
3533/**
3534 * snd_hda_add_nids - assign nids to controls from the array
3535 * @codec: the HDA codec
3536 * @kctl: struct snd_kcontrol
3537 * @index: index to kctl
3538 * @nids: the array of hda_nid_t
3539 * @size: count of hda_nid_t items
3540 *
3541 * This helper function assigns NIDs in the given array to a control element.
3542 *
3543 * Returns 0 if successful, or a negative error code.
3544 */
3545int snd_hda_add_nids(struct hda_codec *codec, struct snd_kcontrol *kctl,
3546 unsigned int index, hda_nid_t *nids, unsigned int size)
3547{
3548 int err;
3549
3550 for ( ; size > 0; size--, nids++) {
3551 err = snd_hda_add_nid(codec, kctl, index, *nids);
3552 if (err < 0)
3553 return err;
3554 }
3555 return 0;
3556}
3557EXPORT_SYMBOL_HDA(snd_hda_add_nids);
3558
3499#ifdef CONFIG_SND_HDA_POWER_SAVE 3559#ifdef CONFIG_SND_HDA_POWER_SAVE
3500static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, 3560static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
3501 unsigned int power_state); 3561 unsigned int power_state);