summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCássio Gabriel <cassiogabrielcontato@gmail.com>2026-05-17 23:33:49 -0300
committerTakashi Iwai <tiwai@suse.de>2026-05-18 15:43:17 +0200
commit456ad3cdaf04229fe5052eaeb5deb48936d7a917 (patch)
tree91eee21924216432a611cbd20b9c527398763ac8
parent83fbbcb7935ec6d2c8ba3bc133e8a0ead2ab0b2d (diff)
ALSA: ctxfi: Keep line/mic notification controls per mixer
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> Link: https://patch.msgid.link/20260517-alsa-ctxfi-mixer-kctls-v1-1-6e4f81f6b658@gmail.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/pci/ctxfi/ctmixer.c17
-rw-r--r--sound/pci/ctxfi/ctmixer.h3
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,