aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_codec.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2005-11-17 05:06:29 -0500
committerJaroslav Kysela <perex@suse.cz>2006-01-03 06:17:21 -0500
commitd2a6d7dc757da6b57d77bd8b460cf4faa9fd152d (patch)
treeb3edf27437b4be8ee23917b852d8e93376ac62da /sound/pci/hda/hda_codec.c
parent59de641ca37b88dd34d0e1d853800b488f642624 (diff)
[ALSA] hda-codec - Add channel-mode helper
Modules: HDA Codec driver,HDA generic driver Add common channel-mode helper functions for all codec patches. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_codec.c')
-rw-r--r--sound/pci/hda/hda_codec.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index e7fb182f90ed..14a6f5463277 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -1662,6 +1662,54 @@ int snd_hda_add_new_ctls(struct hda_codec *codec, snd_kcontrol_new_t *knew)
1662} 1662}
1663 1663
1664 1664
1665 /*
1666 * Channel mode helper
1667 */
1668int snd_hda_ch_mode_info(struct hda_codec *codec, snd_ctl_elem_info_t *uinfo,
1669 const struct hda_channel_mode *chmode, int num_chmodes)
1670{
1671 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1672 uinfo->count = 1;
1673 uinfo->value.enumerated.items = num_chmodes;
1674 if (uinfo->value.enumerated.item >= num_chmodes)
1675 uinfo->value.enumerated.item = num_chmodes - 1;
1676 sprintf(uinfo->value.enumerated.name, "%dch",
1677 chmode[uinfo->value.enumerated.item].channels);
1678 return 0;
1679}
1680
1681int snd_hda_ch_mode_get(struct hda_codec *codec, snd_ctl_elem_value_t *ucontrol,
1682 const struct hda_channel_mode *chmode, int num_chmodes,
1683 int max_channels)
1684{
1685 int i;
1686
1687 for (i = 0; i < num_chmodes; i++) {
1688 if (max_channels == chmode[i].channels) {
1689 ucontrol->value.enumerated.item[0] = i;
1690 break;
1691 }
1692 }
1693 return 0;
1694}
1695
1696int snd_hda_ch_mode_put(struct hda_codec *codec, snd_ctl_elem_value_t *ucontrol,
1697 const struct hda_channel_mode *chmode, int num_chmodes,
1698 int *max_channelsp)
1699{
1700 unsigned int mode;
1701
1702 mode = ucontrol->value.enumerated.item[0];
1703 snd_assert(mode < num_chmodes, return -EINVAL);
1704 if (*max_channelsp && ! codec->in_resume)
1705 return 0;
1706 /* change the current channel setting */
1707 *max_channelsp = chmode[mode].channels;
1708 if (chmode[mode].sequence)
1709 snd_hda_sequence_write(codec, chmode[mode].sequence);
1710 return 1;
1711}
1712
1665/* 1713/*
1666 * input MUX helper 1714 * input MUX helper
1667 */ 1715 */