sound/pci/ctxfi/ctmixer.c | 17 +++++++---------- sound/pci/ctxfi/ctmixer.h | 3 +++ 2 files changed, 10 insertions(+), 10 deletions(-)
ctxfi stores the Line Capture Switch and Mic Capture Switch controls in
a file-scope kctls[] array so do_line_mic_switch() can notify the
opposite control when the shared line/mic input selection changes.
That storage is shared by all ctxfi cards. If more than one X-Fi card is
present, a later card can overwrite the pointers saved by an earlier one.
A control update on one card can then use another card's kcontrol object
for snd_ctl_notify(). If that other card is removed, the saved pointer can
also become stale.
Store those notification targets in struct ct_mixer instead. The mixer is
per-card state and matches the lifetime of the controls created for that
card.
Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
---
sound/pci/ctxfi/ctmixer.c | 17 +++++++----------
sound/pci/ctxfi/ctmixer.h | 3 +++
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/sound/pci/ctxfi/ctmixer.c b/sound/pci/ctxfi/ctmixer.c
index 50ab69aca2fa..9abe1d53c3c5 100644
--- a/sound/pci/ctxfi/ctmixer.c
+++ b/sound/pci/ctxfi/ctmixer.c
@@ -221,10 +221,6 @@ ct_mixer_recording_select(struct ct_mixer *mixer, enum CT_AMIXER_CTL type);
static void
ct_mixer_recording_unselect(struct ct_mixer *mixer, enum CT_AMIXER_CTL type);
-/* FIXME: this static looks like it would fail if more than one card was */
-/* installed. */
-static struct snd_kcontrol *kctls[2] = {NULL};
-
static enum CT_AMIXER_CTL get_amixer_index(enum CTALSA_MIXER_CTL alsa_index)
{
switch (alsa_index) {
@@ -481,17 +477,18 @@ static struct snd_kcontrol_new mic_source_ctl = {
static void
do_line_mic_switch(struct ct_atc *atc, enum CTALSA_MIXER_CTL type)
{
+ struct ct_mixer *mixer = atc->mixer;
if (MIXER_LINEIN_C_S == type) {
atc->select_line_in(atc);
- set_switch_state(atc->mixer, MIXER_MIC_C_S, 0);
+ set_switch_state(mixer, MIXER_MIC_C_S, 0);
snd_ctl_notify(atc->card, SNDRV_CTL_EVENT_MASK_VALUE,
- &kctls[1]->id);
+ &mixer->line_mic_kctls[1]->id);
} else if (MIXER_MIC_C_S == type) {
atc->select_mic_in(atc);
- set_switch_state(atc->mixer, MIXER_LINEIN_C_S, 0);
+ set_switch_state(mixer, MIXER_LINEIN_C_S, 0);
snd_ctl_notify(atc->card, SNDRV_CTL_EVENT_MASK_VALUE,
- &kctls[0]->id);
+ &mixer->line_mic_kctls[0]->id);
}
}
@@ -778,9 +775,9 @@ ct_mixer_kcontrol_new(struct ct_mixer *mixer, struct snd_kcontrol_new *new)
switch (new->private_value) {
case MIXER_LINEIN_C_S:
- kctls[0] = kctl; break;
+ mixer->line_mic_kctls[0] = kctl; break;
case MIXER_MIC_C_S:
- kctls[1] = kctl; break;
+ mixer->line_mic_kctls[1] = kctl; break;
default:
break;
}
diff --git a/sound/pci/ctxfi/ctmixer.h b/sound/pci/ctxfi/ctmixer.h
index dd23d227aeb5..0c0963bba99c 100644
--- a/sound/pci/ctxfi/ctmixer.h
+++ b/sound/pci/ctxfi/ctmixer.h
@@ -17,6 +17,8 @@
#include "ctatc.h"
#include "ctresource.h"
+struct snd_kcontrol;
+
#define INIT_VOL 0x1c00
enum MIXER_PORT_T {
@@ -42,6 +44,7 @@ struct ct_mixer {
struct ct_atc *atc;
struct sum **sums; /* sum resources for signal collection */
+ struct snd_kcontrol *line_mic_kctls[2]; /* line/mic capture switch controls */
unsigned int switch_state; /* A bit-map to indicate state of switches */
int (*get_output_ports)(struct ct_mixer *mixer, enum MIXER_PORT_T type,
---
base-commit: 910e9f1bc3bc96e6d067c405ba30d69c4feff46e
change-id: 20260428-alsa-ctxfi-mixer-kctls-f0b7d1ad178f
Best regards,
--
Cássio Gabriel <cassiogabrielcontato@gmail.com>
On Mon, 18 May 2026 04:33:49 +0200, Cássio Gabriel wrote: > > ctxfi stores the Line Capture Switch and Mic Capture Switch controls in > a file-scope kctls[] array so do_line_mic_switch() can notify the > opposite control when the shared line/mic input selection changes. > > That storage is shared by all ctxfi cards. If more than one X-Fi card is > present, a later card can overwrite the pointers saved by an earlier one. > A control update on one card can then use another card's kcontrol object > for snd_ctl_notify(). If that other card is removed, the saved pointer can > also become stale. > > Store those notification targets in struct ct_mixer instead. The mixer is > per-card state and matches the lifetime of the controls created for that > card. > > Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com> Applied now. Thanks. Takashi
© 2016 - 2026 Red Hat, Inc.