Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 342634
b: refs/heads/master
c: 9b4ef97
h: refs/heads/master
v: v3
  • Loading branch information
David Henningsson authored and Takashi Iwai committed Nov 29, 2012
1 parent 0cb4190 commit 3d62703
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ca10a7ebdff1c862ca1ef1d7bd2c6810e3c87e17
refs/heads/master: 9b4ef97757953c6071563b7cbfc689e3dd771603
30 changes: 30 additions & 0 deletions trunk/sound/usb/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,32 @@ static size_t append_ctl_name(struct snd_kcontrol *kctl, const char *str)
return strlcat(kctl->id.name, str, sizeof(kctl->id.name));
}

/* A lot of headsets/headphones have a "Speaker" mixer. Make sure we
rename it to "Headphone". We determine if something is a headphone
similar to how udev determines form factor. */
static void check_no_speaker_on_headset(struct snd_kcontrol *kctl,
struct snd_card *card)
{
const char *names_to_check[] = {
"Headset", "headset", "Headphone", "headphone", NULL};
const char **s;
bool found = 0;

if (strcmp("Speaker", kctl->id.name))
return;

for (s = names_to_check; *s; s++)
if (strstr(card->shortname, *s)) {
found = 1;
break;
}

if (!found)
return;

strlcpy(kctl->id.name, "Headphone", sizeof(kctl->id.name));
}

static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
unsigned int ctl_mask, int control,
struct usb_audio_term *iterm, int unitid,
Expand Down Expand Up @@ -1222,6 +1248,10 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
len = snprintf(kctl->id.name, sizeof(kctl->id.name),
"Feature %d", unitid);
}

if (!mapped_name)
check_no_speaker_on_headset(kctl, state->mixer->chip->card);

/* determine the stream direction:
* if the connected output is USB stream, then it's likely a
* capture stream. otherwise it should be playback (hopefully :)
Expand Down

0 comments on commit 3d62703

Please sign in to comment.