diff options
author | Takashi Iwai <tiwai@suse.de> | 2005-11-17 11:06:29 +0100 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-01-03 12:17:21 +0100 |
commit | d2a6d7dc757da6b57d77bd8b460cf4faa9fd152d (patch) | |
tree | b3edf27437b4be8ee23917b852d8e93376ac62da /sound/pci/hda/hda_codec.c | |
parent | 59de641ca37b88dd34d0e1d853800b488f642624 (diff) | |
download | blackbird-op-linux-d2a6d7dc757da6b57d77bd8b460cf4faa9fd152d.tar.gz blackbird-op-linux-d2a6d7dc757da6b57d77bd8b460cf4faa9fd152d.zip |
[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.c | 48 |
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) } + /* + * Channel mode helper + */ +int snd_hda_ch_mode_info(struct hda_codec *codec, snd_ctl_elem_info_t *uinfo, + const struct hda_channel_mode *chmode, int num_chmodes) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + uinfo->count = 1; + uinfo->value.enumerated.items = num_chmodes; + if (uinfo->value.enumerated.item >= num_chmodes) + uinfo->value.enumerated.item = num_chmodes - 1; + sprintf(uinfo->value.enumerated.name, "%dch", + chmode[uinfo->value.enumerated.item].channels); + return 0; +} + +int snd_hda_ch_mode_get(struct hda_codec *codec, snd_ctl_elem_value_t *ucontrol, + const struct hda_channel_mode *chmode, int num_chmodes, + int max_channels) +{ + int i; + + for (i = 0; i < num_chmodes; i++) { + if (max_channels == chmode[i].channels) { + ucontrol->value.enumerated.item[0] = i; + break; + } + } + return 0; +} + +int snd_hda_ch_mode_put(struct hda_codec *codec, snd_ctl_elem_value_t *ucontrol, + const struct hda_channel_mode *chmode, int num_chmodes, + int *max_channelsp) +{ + unsigned int mode; + + mode = ucontrol->value.enumerated.item[0]; + snd_assert(mode < num_chmodes, return -EINVAL); + if (*max_channelsp && ! codec->in_resume) + return 0; + /* change the current channel setting */ + *max_channelsp = chmode[mode].channels; + if (chmode[mode].sequence) + snd_hda_sequence_write(codec, chmode[mode].sequence); + return 1; +} + /* * input MUX helper */ |