All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: hda/generic: Use "Input Source" for the capture source selector
@ 2026-10-22  2:57 songxiebing
  2026-10-22  6:13 ` Takashi Iwai
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: songxiebing @ 2026-10-22  2:57 UTC (permalink / raw)
  To: tiwai, perex; +Cc: linux-sound, linux-kernel, songxiebing

From: Bob Song <songxiebing@kylinos.cn>

The generic parser names the capture-source selector "Capture Source" when a
single ADC is used, and "Input Source" when multiple ADCs are handled
(including the dynamic ADC switching case).  Commit 624d914d091a
("ALSA: hda - Use "Capture Source" for single sources") introduced this
split to keep the nicer name for the common single-ADC case, because
"Capture Source" doesn't work well with the alsa-lib simple-mixer
abstraction when multiple instances are present.

However, alsa-lib expands a control named "Capture Source" into one
simple-mixer element per enum item (an exclusive capture switch per input),
so there is no enumerated simple-mixer element named "Capture Source" for
userspace to look up.  PulseAudio's ALSA backend resolves its input-source
element by name via snd_mixer_find_selem() and therefore cannot find the
selector, leaving the capture source uncontrollable on such single-ADC
systems.

"Input Source" is mapped by alsa-lib to a single enumerated element and
works for both the single- and multi-ADC cases.  Use it unconditionally.

Signed-off-by: Bob Song <songxiebing@kylinos.cn>
---
 sound/hda/codecs/generic.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/sound/hda/codecs/generic.c b/sound/hda/codecs/generic.c
index 6120f797b45a..75b6e2749157 100644
--- a/sound/hda/codecs/generic.c
+++ b/sound/hda/codecs/generic.c
@@ -3748,9 +3748,7 @@ static int create_capture_mixers(struct hda_codec *codec)
 
 	if (!spec->auto_mic && imux->num_items > 1) {
 		struct snd_kcontrol_new *knew;
-		const char *name;
-		name = nums > 1 ? "Input Source" : "Capture Source";
-		knew = snd_hda_gen_add_kctl(spec, name, &cap_src_temp);
+		knew = snd_hda_gen_add_kctl(spec, "Input Source", &cap_src_temp);
 		if (!knew)
 			return -ENOMEM;
 		knew->count = nums;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] ALSA: hda/generic: Use "Input Source" for the capture source selector
  2026-10-22  2:57 [PATCH] ALSA: hda/generic: Use "Input Source" for the capture source selector songxiebing
@ 2026-10-22  6:13 ` Takashi Iwai
  2026-10-22  8:09 ` songxiebing
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Takashi Iwai @ 2026-10-22  6:13 UTC (permalink / raw)
  To: songxiebing; +Cc: tiwai, perex, linux-sound, linux-kernel

On Thu, 22 Oct 2026 04:57:43 +0200,
songxiebing wrote:
> 
> From: Bob Song <songxiebing@kylinos.cn>
> 
> The generic parser names the capture-source selector "Capture Source" when a
> single ADC is used, and "Input Source" when multiple ADCs are handled
> (including the dynamic ADC switching case).  Commit 624d914d091a
> ("ALSA: hda - Use "Capture Source" for single sources") introduced this
> split to keep the nicer name for the common single-ADC case, because
> "Capture Source" doesn't work well with the alsa-lib simple-mixer
> abstraction when multiple instances are present.
> 
> However, alsa-lib expands a control named "Capture Source" into one
> simple-mixer element per enum item (an exclusive capture switch per input),
> so there is no enumerated simple-mixer element named "Capture Source" for
> userspace to look up.  PulseAudio's ALSA backend resolves its input-source
> element by name via snd_mixer_find_selem() and therefore cannot find the
> selector, leaving the capture source uncontrollable on such single-ADC
> systems.
> 
> "Input Source" is mapped by alsa-lib to a single enumerated element and
> works for both the single- and multi-ADC cases.  Use it unconditionally.

It must be rather a problem of PulseAudio, and it should be able to
handle Capture Source, as it's been used for most of old AC97-based
cards.

Reverting this old behavior change (since 14 years ago!) is just
no-go.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ALSA: hda/generic: Use "Input Source" for the capture source selector
  2026-10-22  2:57 [PATCH] ALSA: hda/generic: Use "Input Source" for the capture source selector songxiebing
  2026-10-22  6:13 ` Takashi Iwai
@ 2026-10-22  8:09 ` songxiebing
  2026-10-22  8:29   ` Takashi Iwai
  2026-10-22  9:29 ` songxiebing
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: songxiebing @ 2026-10-22  8:09 UTC (permalink / raw)
  To: tiwai, perex; +Cc: linux-sound, linux-kernel, songxiebing

>It must be rather a problem of PulseAudio, and it should be able to
>handle Capture Source, as it's been used for most of old AC97-based
>cards.
>
>Reverting this old behavior change (since 14 years ago!) is just
>no-go.
>
>
>thanks,
>
>Takashi

Thank you for reply.  You are right -- changing the name
unconditionally was not well thought out, and I agree that reverting the
long-standing behavior is not acceptable.

Would it be acceptable if I add a flag to hda_gen_spec (e.g.
use_input_source) that decides whether to use "Input Source" for the
capture source selector?  A codec driver could set it when needed, while
the default behavior stays unchanged.

Thanks,
Bob

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ALSA: hda/generic: Use "Input Source" for the capture source selector
  2026-10-22  8:09 ` songxiebing
@ 2026-10-22  8:29   ` Takashi Iwai
  0 siblings, 0 replies; 8+ messages in thread
From: Takashi Iwai @ 2026-10-22  8:29 UTC (permalink / raw)
  To: songxiebing; +Cc: tiwai, perex, linux-sound, linux-kernel

On Thu, 22 Oct 2026 10:09:04 +0200,
songxiebing wrote:
> 
> >It must be rather a problem of PulseAudio, and it should be able to
> >handle Capture Source, as it's been used for most of old AC97-based
> >cards.
> >
> >Reverting this old behavior change (since 14 years ago!) is just
> >no-go.
> >
> >
> >thanks,
> >
> >Takashi
> 
> Thank you for reply.  You are right -- changing the name
> unconditionally was not well thought out, and I agree that reverting the
> long-standing behavior is not acceptable.
> 
> Would it be acceptable if I add a flag to hda_gen_spec (e.g.
> use_input_source) that decides whether to use "Input Source" for the
> capture source selector?  A codec driver could set it when needed, while
> the default behavior stays unchanged.

That can work, but I'd rather check further why PA doesn't work with
Capture Source.  If it's something like an element that doesn't match
with the actual input, it's a driver's problem and we may work around
it somehow.  But before figuring it out, it's not wise to blindly
work around something just because it looks as if working.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ALSA: hda/generic: Use "Input Source" for the capture source selector
  2026-10-22  2:57 [PATCH] ALSA: hda/generic: Use "Input Source" for the capture source selector songxiebing
  2026-10-22  6:13 ` Takashi Iwai
  2026-10-22  8:09 ` songxiebing
@ 2026-10-22  9:29 ` songxiebing
  2026-10-22  9:36   ` Takashi Iwai
  2026-10-27  2:22 ` songxiebing
  2026-10-27  8:38 ` songxiebing
  4 siblings, 1 reply; 8+ messages in thread
From: songxiebing @ 2026-10-22  9:29 UTC (permalink / raw)
  To: tiwai, perex; +Cc: linux-sound, linux-kernel, songxiebing

>That can work, but I'd rather check further why PA doesn't work with
>Capture Source.  If it's something like an element that doesn't match
>with the actual input, it's a driver's problem and we may work around
>it somehow.  But before figuring it out, it's not wise to blindly
>work around something just because it looks as if working.
>
>
>thanks,
>
>Takashi

Thanks for reply.

What I found so far on the userspace side:

- alsa-lib's simple-mixer layer special-cases the exact name "Capture
  Source": it does *not* expose an enumerated element with that name, but
  instead creates one exclusive capture switch per enum item, named after
  the item (simple_none.c, simple_event_add()).
- PulseAudio's ALSA backend resolves its "Capture Source" element strictly
  by name (element_probe() -> snd_mixer_find_selem()), so it never finds
  an element and the mux is never switched.  PA also has no handling for
  snd_mixer_selem_has_capture_switch_exclusive(), so it can't consume the
  per-item switches either.

Thanks,
Bob

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ALSA: hda/generic: Use "Input Source" for the capture source selector
  2026-10-22  9:29 ` songxiebing
@ 2026-10-22  9:36   ` Takashi Iwai
  0 siblings, 0 replies; 8+ messages in thread
From: Takashi Iwai @ 2026-10-22  9:36 UTC (permalink / raw)
  To: songxiebing; +Cc: tiwai, perex, linux-sound, linux-kernel

On Thu, 22 Oct 2026 11:29:21 +0200,
songxiebing wrote:
> 
> >That can work, but I'd rather check further why PA doesn't work with
> >Capture Source.  If it's something like an element that doesn't match
> >with the actual input, it's a driver's problem and we may work around
> >it somehow.  But before figuring it out, it's not wise to blindly
> >work around something just because it looks as if working.
> >
> >
> >thanks,
> >
> >Takashi
> 
> Thanks for reply.
> 
> What I found so far on the userspace side:
> 
> - alsa-lib's simple-mixer layer special-cases the exact name "Capture
>   Source": it does *not* expose an enumerated element with that name, but
>   instead creates one exclusive capture switch per enum item, named after
>   the item (simple_none.c, simple_event_add()).
> - PulseAudio's ALSA backend resolves its "Capture Source" element strictly
>   by name (element_probe() -> snd_mixer_find_selem()), so it never finds
>   an element and the mux is never switched.  PA also has no handling for
>   snd_mixer_selem_has_capture_switch_exclusive(), so it can't consume the
>   per-item switches either.

If that's true, PA is broken for all other AC97-based PCI cards?
Let's verify the PA behavior more at first.


Takashi

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ALSA: hda/generic: Use "Input Source" for the capture source selector
  2026-10-22  2:57 [PATCH] ALSA: hda/generic: Use "Input Source" for the capture source selector songxiebing
                   ` (2 preceding siblings ...)
  2026-10-22  9:29 ` songxiebing
@ 2026-10-27  2:22 ` songxiebing
  2026-10-27  8:38 ` songxiebing
  4 siblings, 0 replies; 8+ messages in thread
From: songxiebing @ 2026-10-27  2:22 UTC (permalink / raw)
  To: tiwai, perex; +Cc: linux-sound, linux-kernel, songxiebing

>If that's true, PA is broken for all other AC97-based PCI cards?
>Let's verify the PA behavior more at first.
>
>
>Takashi

Ok,i will take me quite a while to verify this.

Thanks,
Bob

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ALSA: hda/generic: Use "Input Source" for the capture source selector
  2026-10-22  2:57 [PATCH] ALSA: hda/generic: Use "Input Source" for the capture source selector songxiebing
                   ` (3 preceding siblings ...)
  2026-10-27  2:22 ` songxiebing
@ 2026-10-27  8:38 ` songxiebing
  4 siblings, 0 replies; 8+ messages in thread
From: songxiebing @ 2026-10-27  8:38 UTC (permalink / raw)
  To: tiwai, perex; +Cc: linux-sound, linux-kernel, songxiebing

>>If that's true, PA is broken for all other AC97-based PCI cards?
>>Let's verify the PA behavior more at first.
>>
>>
>>Takashi
>
>Ok,i will take me quite a while to verify this.
>
>Thanks,
>Bob

Hi Takashi,

We verified the PulseAudio behavior, and you are right -- PulseAudio does
handle the split "Capture Source" control.  My earlier claim was wrong, so
please disregard that part (and the patch).

What actually happens:

- alsa-lib exposes a control named "Capture Source" as one exclusive
  capture switch per enum item, named after the item (Mic, Line, ...).
- PulseAudio's input paths match those per-item elements directly, e.g.
  [Element Line] with "switch = mute" on the line-in path and
  "switch = off" on the other paths (analog-input-*.conf).  So the split
  control is usable as-is; PulseAudio does not need
  snd_mixer_selem_has_capture_switch_exclusive(), because writing such a
  switch makes alsa-lib update the underlying "Capture Source" enum.

The reason it did not switch to Line on our machine was simply the mute
state of the source:

- PulseAudio restored the source's mute state as "muted"
  (module-device-restore).
- pa_alsa_path_set_mute() then writes the per-item switches with !muted,
  i.e. it sets [Element Line] to off.
- Turning an exclusive capture switch off does not write the enum
  (alsa-lib only writes the enumerated value for channels whose switch
  bit is set), so "Capture Source" keeps its previous value.
- As soon as the source is unmuted, PulseAudio sets [Element Line] to on
  and the source switches to Line as expected.

So this is not a kernel/driver naming problem; it's a userspace
mute-state issue, and we will handle it on the userspace side.

Thanks,
Bob

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-10-27  8:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-22  2:57 [PATCH] ALSA: hda/generic: Use "Input Source" for the capture source selector songxiebing
2026-10-22  6:13 ` Takashi Iwai
2026-10-22  8:09 ` songxiebing
2026-10-22  8:29   ` Takashi Iwai
2026-10-22  9:29 ` songxiebing
2026-10-22  9:36   ` Takashi Iwai
2026-10-27  2:22 ` songxiebing
2026-10-27  8:38 ` songxiebing

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.