aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/pci/hda/hda_codec.c28
-rw-r--r--sound/pci/hda/hda_local.h9
-rw-r--r--sound/pci/hda/patch_conexant.c21
-rw-r--r--sound/pci/hda/patch_realtek.c21
-rw-r--r--sound/pci/hda/patch_via.c13
5 files changed, 44 insertions, 48 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 3634bfebc008..d05bcbb61077 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -4792,6 +4792,34 @@ EXPORT_SYMBOL_HDA(snd_hda_input_mux_put);
4792 4792
4793 4793
4794/* 4794/*
4795 * process kcontrol info callback of a simple string enum array
4796 * when @num_items is 0 or @texts is NULL, assume a boolean enum array
4797 */
4798int snd_hda_enum_helper_info(struct snd_kcontrol *kcontrol,
4799 struct snd_ctl_elem_info *uinfo,
4800 int num_items, const char * const *texts)
4801{
4802 static const char * const texts_default[] = {
4803 "Disabled", "Enabled"
4804 };
4805
4806 if (!texts || !num_items) {
4807 num_items = 2;
4808 texts = texts_default;
4809 }
4810
4811 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4812 uinfo->count = 1;
4813 uinfo->value.enumerated.items = num_items;
4814 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
4815 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
4816 strcpy(uinfo->value.enumerated.name,
4817 texts[uinfo->value.enumerated.item]);
4818 return 0;
4819}
4820EXPORT_SYMBOL_HDA(snd_hda_enum_helper_info);
4821
4822/*
4795 * Multi-channel / digital-out PCM helper functions 4823 * Multi-channel / digital-out PCM helper functions
4796 */ 4824 */
4797 4825
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index 8c43198b7f56..4b40a5e7a8f5 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -601,6 +601,15 @@ int snd_hda_check_amp_list_power(struct hda_codec *codec,
601#define get_amp_min_mute(kc) (((kc)->private_value >> 29) & 0x1) 601#define get_amp_min_mute(kc) (((kc)->private_value >> 29) & 0x1)
602 602
603/* 603/*
604 * enum control helper
605 */
606int snd_hda_enum_helper_info(struct snd_kcontrol *kcontrol,
607 struct snd_ctl_elem_info *uinfo,
608 int num_entries, const char * const *texts);
609#define snd_hda_enum_bool_helper_info(kcontrol, uinfo) \
610 snd_hda_enum_helper_info(kcontrol, uinfo, 0, NULL)
611
612/*
604 * CEA Short Audio Descriptor data 613 * CEA Short Audio Descriptor data
605 */ 614 */
606struct cea_sad { 615struct cea_sad {
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 3401a087de80..a3a2263d3b37 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -3435,28 +3435,13 @@ static int cx_automute_mode_info(struct snd_kcontrol *kcontrol,
3435{ 3435{
3436 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 3436 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3437 struct conexant_spec *spec = codec->spec; 3437 struct conexant_spec *spec = codec->spec;
3438 static const char * const texts2[] = {
3439 "Disabled", "Enabled"
3440 };
3441 static const char * const texts3[] = { 3438 static const char * const texts3[] = {
3442 "Disabled", "Speaker Only", "Line Out+Speaker" 3439 "Disabled", "Speaker Only", "Line Out+Speaker"
3443 }; 3440 };
3444 const char * const *texts;
3445 3441
3446 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 3442 if (spec->automute_hp_lo)
3447 uinfo->count = 1; 3443 return snd_hda_enum_helper_info(kcontrol, uinfo, 3, texts3);
3448 if (spec->automute_hp_lo) { 3444 return snd_hda_enum_bool_helper_info(kcontrol, uinfo);
3449 uinfo->value.enumerated.items = 3;
3450 texts = texts3;
3451 } else {
3452 uinfo->value.enumerated.items = 2;
3453 texts = texts2;
3454 }
3455 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
3456 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
3457 strcpy(uinfo->value.enumerated.name,
3458 texts[uinfo->value.enumerated.item]);
3459 return 0;
3460} 3445}
3461 3446
3462static int cx_automute_mode_get(struct snd_kcontrol *kcontrol, 3447static int cx_automute_mode_get(struct snd_kcontrol *kcontrol,
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 0062c9f401c3..5d8044d4dc52 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -815,28 +815,13 @@ static int alc_automute_mode_info(struct snd_kcontrol *kcontrol,
815{ 815{
816 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 816 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
817 struct alc_spec *spec = codec->spec; 817 struct alc_spec *spec = codec->spec;
818 static const char * const texts2[] = {
819 "Disabled", "Enabled"
820 };
821 static const char * const texts3[] = { 818 static const char * const texts3[] = {
822 "Disabled", "Speaker Only", "Line Out+Speaker" 819 "Disabled", "Speaker Only", "Line Out+Speaker"
823 }; 820 };
824 const char * const *texts;
825 821
826 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 822 if (spec->automute_speaker_possible && spec->automute_lo_possible)
827 uinfo->count = 1; 823 return snd_hda_enum_helper_info(kcontrol, uinfo, 3, texts3);
828 if (spec->automute_speaker_possible && spec->automute_lo_possible) { 824 return snd_hda_enum_bool_helper_info(kcontrol, uinfo);
829 uinfo->value.enumerated.items = 3;
830 texts = texts3;
831 } else {
832 uinfo->value.enumerated.items = 2;
833 texts = texts2;
834 }
835 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
836 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
837 strcpy(uinfo->value.enumerated.name,
838 texts[uinfo->value.enumerated.item]);
839 return 0;
840} 825}
841 826
842static int alc_automute_mode_get(struct snd_kcontrol *kcontrol, 827static int alc_automute_mode_get(struct snd_kcontrol *kcontrol,
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 274644f6bd48..dd8cd6af5d66 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -739,18 +739,7 @@ static void set_pin_power_state(struct hda_codec *codec, hda_nid_t nid,
739static int via_pin_power_ctl_info(struct snd_kcontrol *kcontrol, 739static int via_pin_power_ctl_info(struct snd_kcontrol *kcontrol,
740 struct snd_ctl_elem_info *uinfo) 740 struct snd_ctl_elem_info *uinfo)
741{ 741{
742 static const char * const texts[] = { 742 return snd_hda_enum_bool_helper_info(kcontrol, uinfo);
743 "Disabled", "Enabled"
744 };
745
746 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
747 uinfo->count = 1;
748 uinfo->value.enumerated.items = 2;
749 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
750 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
751 strcpy(uinfo->value.enumerated.name,
752 texts[uinfo->value.enumerated.item]);
753 return 0;
754} 743}
755 744
756static int via_pin_power_ctl_get(struct snd_kcontrol *kcontrol, 745static int via_pin_power_ctl_get(struct snd_kcontrol *kcontrol,