From: Harin Lee <me@harin.net>
To: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
Harin Lee <me@harin.net>
Subject: [PATCH v3 2/6] ALSA: ctxfi: Add ADC helper functions for GPIO
Date: Tue, 25 Nov 2025 03:04:57 +0900 [thread overview]
Message-ID: <20251124180501.2760421-3-me@harin.net> (raw)
In-Reply-To: <20251124180501.2760421-1-me@harin.net>
Add helper functions hw_adc_stop(), hw_adc_start(), and hw_adc_reset()
to encapsulate ADC reset sequence operations. These functions reduce
duplication by centralizing the GPIO-based ADC control logic.
Signed-off-by: Harin Lee <me@harin.net>
---
sound/pci/ctxfi/cthw20k2.c | 37 ++++++++++++++++++++++++++++---------
1 file changed, 28 insertions(+), 9 deletions(-)
diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c
index 1a085e7e5786..5d39bc943648 100644
--- a/sound/pci/ctxfi/cthw20k2.c
+++ b/sound/pci/ctxfi/cthw20k2.c
@@ -1826,6 +1826,32 @@ static int hw_adc_input_select(struct hw *hw, enum ADCSRC type)
return 0;
}
+static void hw_adc_stop(struct hw *hw)
+{
+ u32 data;
+ /* Reset the ADC (reset is active low). */
+ data = hw_read_20kx(hw, GPIO_DATA);
+ data &= ~(0x1 << 15);
+ hw_write_20kx(hw, GPIO_DATA, data);
+ usleep_range(10000, 11000);
+}
+
+static void hw_adc_start(struct hw *hw)
+{
+ u32 data;
+ /* Return the ADC to normal operation. */
+ data = hw_read_20kx(hw, GPIO_DATA);
+ data |= (0x1 << 15);
+ hw_write_20kx(hw, GPIO_DATA, data);
+ msleep(50);
+}
+
+static void __maybe_unused hw_adc_reset(struct hw *hw)
+{
+ hw_adc_stop(hw);
+ hw_adc_start(hw);
+}
+
static int hw_adc_init(struct hw *hw, const struct adc_conf *info)
{
int err;
@@ -1843,10 +1869,7 @@ static int hw_adc_init(struct hw *hw, const struct adc_conf *info)
goto error;
}
- /* Reset the ADC (reset is active low). */
- data = hw_read_20kx(hw, GPIO_DATA);
- data &= ~(0x1 << 15);
- hw_write_20kx(hw, GPIO_DATA, data);
+ hw_adc_stop(hw);
if (hw->model == CTSB1270) {
/* Set up the PCM4220 ADC on Titanium HD */
@@ -1860,11 +1883,7 @@ static int hw_adc_init(struct hw *hw, const struct adc_conf *info)
hw_write_20kx(hw, GPIO_DATA, data);
}
- usleep_range(10000, 11000);
- /* Return the ADC to normal operation. */
- data |= (0x1 << 15);
- hw_write_20kx(hw, GPIO_DATA, data);
- msleep(50);
+ hw_adc_start(hw);
/* I2C write to register offset 0x0B to set ADC LRCLK polarity */
/* invert bit, interface format to I2S, word length to 24-bit, */
--
2.52.0
next prev parent reply other threads:[~2025-11-24 18:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-24 18:04 [PATCH v3 0/6] ALSA: ctxfi: Add support for Onkyo SE-300PCIE Harin Lee
2025-11-24 18:04 ` [PATCH v3 1/6] ALSA: ctxfi: Add hw parameter to daio_mgr_dao_init() Harin Lee
2025-11-24 18:04 ` Harin Lee [this message]
2025-11-24 18:04 ` [PATCH v3 3/6] ALSA: ctxfi: Use explicit output flag for DAIO resources Harin Lee
2025-11-24 18:04 ` [PATCH v3 4/6] ALSA: ctxfi: Refactor resource alloc for sparse mappings Harin Lee
2025-11-24 18:05 ` [PATCH v3 5/6] ALSA: ctxfi: Add support for dedicated RCA switching Harin Lee
2025-11-24 18:05 ` [PATCH v3 6/6] ALSA: ctxfi: Add support for Onkyo SE-300PCIE (OK0010) Harin Lee
2025-11-25 7:02 ` [PATCH v3 0/6] ALSA: ctxfi: Add support for Onkyo SE-300PCIE 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=20251124180501.2760421-3-me@harin.net \
--to=me@harin.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®