mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
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>
This commit is contained in:
parent
83fbbcb793
commit
456ad3cdaf
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user