Skip to content

Commit edf04f1

Browse files
wangdichengtiwai
authored andcommitted
ALSA: hda/senary: Fix beep error handling and optimize EAPD switching
This patch addresses a potential state inconsistency bug and optimizes runtime performance: 1. Fix error handling in set_beep_amp(): Previously, beep_nid was assigned before adding kcontrols. If kcontrol creation failed, the function returned error but left beep_nid set, causing inconsistent driver state. Moved the assignment to the end of the function. 2. Optimize senary_auto_turn_eapd(): Removed the redundant snd_hda_query_pin_caps() check inside the loop. The target pins are sourced from spec->eapds, which is strictly filtered during the initial parse phase. Checking capabilities again during every mute/unmute hook is unnecessary overhead. Signed-off-by: wangdicheng <wangdicheng@kylinos.cn> Link: https://patch.msgid.link/20260310023649.155858-1-wangdich9700@163.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent c4791ce commit edf04f1

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

sound/hda/codecs/senarytech.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,15 @@ static int set_beep_amp(struct senary_spec *spec, hda_nid_t nid,
7676
unsigned int beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir);
7777
int i;
7878

79-
spec->gen.beep_nid = nid;
8079
for (i = 0; i < ARRAY_SIZE(senary_beep_mixer); i++) {
8180
knew = snd_hda_gen_add_kctl(&spec->gen, NULL,
8281
&senary_beep_mixer[i]);
8382
if (!knew)
8483
return -ENOMEM;
8584
knew->private_value = beep_amp;
8685
}
86+
87+
spec->gen.beep_nid = nid;
8788
return 0;
8889
}
8990

@@ -138,10 +139,9 @@ static void senary_auto_turn_eapd(struct hda_codec *codec, int num_pins,
138139
int i;
139140

140141
for (i = 0; i < num_pins; i++) {
141-
if (snd_hda_query_pin_caps(codec, pins[i]) & AC_PINCAP_EAPD)
142-
snd_hda_codec_write(codec, pins[i], 0,
143-
AC_VERB_SET_EAPD_BTLENABLE,
144-
on ? 0x02 : 0);
142+
snd_hda_codec_write(codec, pins[i], 0,
143+
AC_VERB_SET_EAPD_BTLENABLE,
144+
on ? 0x02 : 0);
145145
}
146146
}
147147

0 commit comments

Comments
 (0)