Skip to content

Commit 80449e1

Browse files
harinworkstiwai
authored andcommitted
ALSA: ctxfi: Precompute SRC allocation loop bound
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> Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20260401090159.2404387-4-me@harin.net
1 parent 07b116b commit 80449e1

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

sound/pci/ctxfi/ctatc.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,9 +1409,11 @@ static int atc_get_resources(struct ct_atc *atc)
14091409
struct sum_desc sum_dsc = {0};
14101410
struct sum_mgr *sum_mgr;
14111411
struct capabilities cap;
1412+
int atc_srcs_limit;
14121413
int err, i;
14131414

14141415
cap = atc->capabilities(atc);
1416+
atc_srcs_limit = cap.dedicated_mic ? NUM_ATC_SRCS : 4;
14151417

14161418
atc->daios = kcalloc(NUM_DAIOTYP, sizeof(void *), GFP_KERNEL);
14171419
if (!atc->daios)
@@ -1453,9 +1455,7 @@ static int atc_get_resources(struct ct_atc *atc)
14531455
src_dsc.multi = 1;
14541456
src_dsc.msr = atc->msr;
14551457
src_dsc.mode = ARCRW;
1456-
for (i = 0; i < NUM_ATC_SRCS; i++) {
1457-
if (((i > 3) && !cap.dedicated_mic))
1458-
continue;
1458+
for (i = 0; i < atc_srcs_limit; i++) {
14591459
err = src_mgr->get_src(src_mgr, &src_dsc,
14601460
(struct src **)&atc->srcs[i]);
14611461
if (err)
@@ -1464,9 +1464,7 @@ static int atc_get_resources(struct ct_atc *atc)
14641464

14651465
srcimp_mgr = atc->rsc_mgrs[SRCIMP];
14661466
srcimp_dsc.msr = 8;
1467-
for (i = 0; i < NUM_ATC_SRCS; i++) {
1468-
if (((i > 3) && !cap.dedicated_mic))
1469-
continue;
1467+
for (i = 0; i < atc_srcs_limit; i++) {
14701468
err = srcimp_mgr->get_srcimp(srcimp_mgr, &srcimp_dsc,
14711469
(struct srcimp **)&atc->srcimps[i]);
14721470
if (err)

0 commit comments

Comments
 (0)