Skip to content

Commit 37c4fd0

Browse files
committed
ALSA: hda: Do disconnect jacks at codec unbind
The HD-audio codec driver remove may happen also at dynamically unbinding during operation, hence it needs manual triggers of snd_device_disconnect() calls, while it's missing for the jack objects that are associated with the codec. This patch adds the manual disconnection call for jacks when the remove happens without card->shutdown (i.e. not under the full removal). Link: https://lore.kernel.org/r/20211117133040.20272-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 2c95b92 commit 37c4fd0

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

sound/pci/hda/hda_bind.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <sound/core.h>
1515
#include <sound/hda_codec.h>
1616
#include "hda_local.h"
17+
#include "hda_jack.h"
1718

1819
/*
1920
* find a matching codec id
@@ -158,6 +159,7 @@ static int hda_codec_driver_remove(struct device *dev)
158159

159160
refcount_dec(&codec->pcm_ref);
160161
snd_hda_codec_disconnect_pcms(codec);
162+
snd_hda_jack_tbl_disconnect(codec);
161163
wait_event(codec->remove_sleep, !refcount_read(&codec->pcm_ref));
162164
snd_power_sync_ref(codec->bus->card);
163165

sound/pci/hda/hda_jack.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,17 @@ snd_hda_jack_tbl_new(struct hda_codec *codec, hda_nid_t nid, int dev_id)
158158
return jack;
159159
}
160160

161+
void snd_hda_jack_tbl_disconnect(struct hda_codec *codec)
162+
{
163+
struct hda_jack_tbl *jack = codec->jacktbl.list;
164+
int i;
165+
166+
for (i = 0; i < codec->jacktbl.used; i++, jack++) {
167+
if (!codec->bus->shutdown && jack->jack)
168+
snd_device_disconnect(codec->card, jack->jack);
169+
}
170+
}
171+
161172
void snd_hda_jack_tbl_clear(struct hda_codec *codec)
162173
{
163174
struct hda_jack_tbl *jack = codec->jacktbl.list;

sound/pci/hda/hda_jack.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ struct hda_jack_tbl *
6969
snd_hda_jack_tbl_get_from_tag(struct hda_codec *codec,
7070
unsigned char tag, int dev_id);
7171

72+
void snd_hda_jack_tbl_disconnect(struct hda_codec *codec);
7273
void snd_hda_jack_tbl_clear(struct hda_codec *codec);
7374

7475
void snd_hda_jack_set_dirty_all(struct hda_codec *codec);

0 commit comments

Comments
 (0)