diff options
author | David Henningsson <david.henningsson@canonical.com> | 2012-11-23 07:48:55 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2012-11-29 07:59:47 -0500 |
commit | 9b4ef97757953c6071563b7cbfc689e3dd771603 (patch) | |
tree | 26e101a5305719041a09d5e3e96ebd79af845144 /sound/usb | |
parent | ca10a7ebdff1c862ca1ef1d7bd2c6810e3c87e17 (diff) |
ALSA: usb - Don't create "Speaker" mixer controls on headphones and headsets
A lot of headsets/headphones have a "Speaker" mixer control. This confuses
PulseAudio to think it is a speaker instead of a headphone/headset.
Therfore, we rename it to "Headphone".
We determine if something is a headphone similar to how udev determines
form factor (see 78-sound-card.rules).
BugLink: https://bugs.launchpad.net/bugs/1082357
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/mixer.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index feed500f943..ed4d89c8b52 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c | |||
@@ -1136,6 +1136,32 @@ static size_t append_ctl_name(struct snd_kcontrol *kctl, const char *str) | |||
1136 | return strlcat(kctl->id.name, str, sizeof(kctl->id.name)); | 1136 | return strlcat(kctl->id.name, str, sizeof(kctl->id.name)); |
1137 | } | 1137 | } |
1138 | 1138 | ||
1139 | /* A lot of headsets/headphones have a "Speaker" mixer. Make sure we | ||
1140 | rename it to "Headphone". We determine if something is a headphone | ||
1141 | similar to how udev determines form factor. */ | ||
1142 | static void check_no_speaker_on_headset(struct snd_kcontrol *kctl, | ||
1143 | struct snd_card *card) | ||
1144 | { | ||
1145 | const char *names_to_check[] = { | ||
1146 | "Headset", "headset", "Headphone", "headphone", NULL}; | ||
1147 | const char **s; | ||
1148 | bool found = 0; | ||
1149 | |||
1150 | if (strcmp("Speaker", kctl->id.name)) | ||
1151 | return; | ||
1152 | |||
1153 | for (s = names_to_check; *s; s++) | ||
1154 | if (strstr(card->shortname, *s)) { | ||
1155 | found = 1; | ||
1156 | break; | ||
1157 | } | ||
1158 | |||
1159 | if (!found) | ||
1160 | return; | ||
1161 | |||
1162 | strlcpy(kctl->id.name, "Headphone", sizeof(kctl->id.name)); | ||
1163 | } | ||
1164 | |||
1139 | static void build_feature_ctl(struct mixer_build *state, void *raw_desc, | 1165 | static void build_feature_ctl(struct mixer_build *state, void *raw_desc, |
1140 | unsigned int ctl_mask, int control, | 1166 | unsigned int ctl_mask, int control, |
1141 | struct usb_audio_term *iterm, int unitid, | 1167 | struct usb_audio_term *iterm, int unitid, |
@@ -1222,6 +1248,10 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc, | |||
1222 | len = snprintf(kctl->id.name, sizeof(kctl->id.name), | 1248 | len = snprintf(kctl->id.name, sizeof(kctl->id.name), |
1223 | "Feature %d", unitid); | 1249 | "Feature %d", unitid); |
1224 | } | 1250 | } |
1251 | |||
1252 | if (!mapped_name) | ||
1253 | check_no_speaker_on_headset(kctl, state->mixer->chip->card); | ||
1254 | |||
1225 | /* determine the stream direction: | 1255 | /* determine the stream direction: |
1226 | * if the connected output is USB stream, then it's likely a | 1256 | * if the connected output is USB stream, then it's likely a |
1227 | * capture stream. otherwise it should be playback (hopefully :) | 1257 | * capture stream. otherwise it should be playback (hopefully :) |