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 3/3] ALSA: ctxfi: Precompute SRC allocation loop bound
Date: Wed, 1 Apr 2026 00:35:07 +0900 [thread overview]
Message-ID: <20260331153507.2934795-4-me@harin.net> (raw)
In-Reply-To: <20260331153507.2934795-1-me@harin.net>
Replace the capability checks in the SRC and SRCIMP allocation loops
with a precomputed loop bound. Cards with a dedicated mic input
(SB1270, OK0010) allocate all NUM_ATC_SRCS entries, otherwise stop
at 4.
Signed-off-by: Harin Lee <me@harin.net>
---
sound/pci/ctxfi/ctatc.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c
index 9a1f6cebaa32..d969b70431c9 100644
--- a/sound/pci/ctxfi/ctatc.c
+++ b/sound/pci/ctxfi/ctatc.c
@@ -1405,9 +1405,11 @@ static int atc_get_resources(struct ct_atc *atc)
struct sum_desc sum_dsc = {0};
struct sum_mgr *sum_mgr;
struct capabilities cap;
+ int atc_srcs_limit;
int err, i;
cap = atc->capabilities(atc);
+ atc_srcs_limit = cap.dedicated_mic ? NUM_ATC_SRCS : 4;
atc->daios = kcalloc(NUM_DAIOTYP, sizeof(void *), GFP_KERNEL);
if (!atc->daios)
@@ -1448,9 +1450,7 @@ static int atc_get_resources(struct ct_atc *atc)
src_dsc.multi = 1;
src_dsc.msr = atc->msr;
src_dsc.mode = ARCRW;
- for (i = 0; i < NUM_ATC_SRCS; i++) {
- if (((i > 3) && !cap.dedicated_mic))
- continue;
+ for (i = 0; i < atc_srcs_limit; i++) {
err = src_mgr->get_src(src_mgr, &src_dsc,
(struct src **)&atc->srcs[i]);
if (err)
@@ -1459,9 +1459,7 @@ static int atc_get_resources(struct ct_atc *atc)
srcimp_mgr = atc->rsc_mgrs[SRCIMP];
srcimp_dsc.msr = 8;
- for (i = 0; i < NUM_ATC_SRCS; i++) {
- if (((i > 3) && !cap.dedicated_mic))
- continue;
+ for (i = 0; i < atc_srcs_limit; i++) {
err = srcimp_mgr->get_srcimp(srcimp_mgr, &srcimp_dsc,
(struct srcimp **)&atc->srcimps[i]);
if (err)
--
2.53.0
prev parent reply other threads:[~2026-03-31 15:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 15:35 [PATCH 0/3] ALSA: ctxfi: Clean up DAIO resource allocation Harin Lee
2026-03-31 15:35 ` [PATCH 1/3] ALSA: ctxfi: Rename SPDIFI1 to SPDIFI_BAY Harin Lee
2026-03-31 15:35 ` [PATCH 2/3] ALSA: ctxfi: Use matching DAIO type for da_desc Harin Lee
2026-04-01 7:57 ` Takashi Iwai
2026-03-31 15:35 ` Harin Lee [this message]
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=20260331153507.2934795-4-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®