From: Takashi Iwai <tiwai@suse.de>
To: Zhang Heng <zhangheng@kylinos.cn>
Cc: Takashi Iwai <tiwai@suse.de>,
tiwai@suse.com, perex@perex.cz, linux-sound@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ALSA: hda/realtek: Add quirk for CSL Unity BF24B
Date: Thu, 09 Apr 2026 09:24:29 +0200 [thread overview]
Message-ID: <87mrzck34i.wl-tiwai@suse.de> (raw)
In-Reply-To: <f72b3ebd-a7f3-4a1a-a48e-bbbbb67b18de@kylinos.cn>
On Thu, 09 Apr 2026 09:00:59 +0200,
Zhang Heng wrote:
>
>
> >> + alc_update_gpio_data(codec, 0x03, true);
> >> + msleep(100);
> >> + alc_update_gpio_data(codec, 0x03, false);
>
> Is it possible to make these lines into another auxiliary function? I think so.
I had something like below in mind. This can be applied to clean up
many existing code.
With that change, the fixup becomes
snd_hda_codec_set_gpio(codec, 0x03, 0x03, 0x03, 0);
msleep(100);
snd_hda_codec_set_gpio(codec, 0x03, 0x03, 0x00, 0);
without setting spec->gpio_* fields.
Takashi
-- 8< --
diff --git a/include/sound/hda_codec.h b/include/sound/hda_codec.h
index 5d9f0ef228af..cb1755d535f9 100644
--- a/include/sound/hda_codec.h
+++ b/include/sound/hda_codec.h
@@ -470,6 +470,10 @@ void snd_hda_unlock_devices(struct hda_bus *bus);
void snd_hda_bus_reset(struct hda_bus *bus);
void snd_hda_bus_reset_codecs(struct hda_bus *bus);
+void snd_hda_codec_set_gpio(struct hda_codec *codec, unsigned int mask,
+ unsigned int dir, unsigned int data,
+ unsigned int delay);
+
int snd_hda_codec_set_name(struct hda_codec *codec, const char *name);
/*
diff --git a/sound/hda/common/codec.c b/sound/hda/common/codec.c
index 5123df32ad89..6eb11e933606 100644
--- a/sound/hda/common/codec.c
+++ b/sound/hda/common/codec.c
@@ -4053,6 +4053,29 @@ void snd_hda_bus_reset_codecs(struct hda_bus *bus)
}
}
+/**
+ * snd_hda_codec_set_gpio - Set up GPIO bits for AFG
+ * @codec: the HDA codec
+ * @mask: GPIO bitmask
+ * @dir: GPIO direction bits
+ * @data: GPIO data bits
+ * @delay: the delay in msec before writing GPIO data bits
+ */
+void snd_hda_codec_set_gpio(struct hda_codec *codec, unsigned int mask,
+ unsigned int dir, unsigned int data,
+ unsigned int delay)
+{
+ snd_hda_codec_write(codec, codec->core.afg, 0,
+ AC_VERB_SET_GPIO_MASK, mask);
+ snd_hda_codec_write(codec, codec->core.afg, 0,
+ AC_VERB_SET_GPIO_DIRECTION, dir);
+ if (delay)
+ msleep(delay);
+ snd_hda_codec_write(codec, codec->core.afg, 0,
+ AC_VERB_SET_GPIO_DATA, data);
+}
+EXPORT_SYMBOL_GPL(snd_hda_codec_set_gpio);
+
/**
* snd_print_pcm_bits - Print the supported PCM fmt bits to the string buffer
* @pcm: PCM caps bits
next prev parent reply other threads:[~2026-04-09 7:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 2:40 [PATCH] ALSA: hda/realtek: Add quirk for CSL Unity BF24B Zhang Heng
2026-04-09 5:09 ` Takashi Iwai
2026-04-09 5:58 ` Zhang Heng
2026-04-09 6:28 ` Takashi Iwai
2026-04-09 6:30 ` Takashi Iwai
2026-04-09 6:33 ` Zhang Heng
2026-04-09 6:47 ` Takashi Iwai
2026-04-09 7:00 ` Zhang Heng
2026-04-09 7:24 ` Takashi Iwai [this message]
2026-04-09 7:51 ` Zhang Heng
2026-04-09 7:59 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mrzck34i.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=zhangheng@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.