* [PATCH 1/3] ALSA: ctxfi: Rename SPDIFI1 to SPDIFI_BAY
2026-03-31 15:35 [PATCH 0/3] ALSA: ctxfi: Clean up DAIO resource allocation Harin Lee
@ 2026-03-31 15:35 ` Harin Lee
2026-03-31 15:35 ` [PATCH 2/3] ALSA: ctxfi: Use matching DAIO type for da_desc Harin Lee
2026-03-31 15:35 ` [PATCH 3/3] ALSA: ctxfi: Precompute SRC allocation loop bound Harin Lee
2 siblings, 0 replies; 5+ messages in thread
From: Harin Lee @ 2026-03-31 15:35 UTC (permalink / raw)
To: Jaroslav Kysela, Takashi Iwai; +Cc: linux-sound, linux-kernel, Harin Lee
Rename the SPDIFI1 enum value to SPDIFI_BAY to better reflect its
purpose as the S/PDIF input on the internal drive bay, as opposed to
the S/PDIF input via Flexijack or optical (SPDIFIO; not SPDIFI-zero).
Signed-off-by: Harin Lee <me@harin.net>
---
sound/pci/ctxfi/ctatc.c | 4 ++--
sound/pci/ctxfi/ctdaio.c | 6 +++---
sound/pci/ctxfi/ctdaio.h | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c
index da2667cb2489..9e0532fb33ff 100644
--- a/sound/pci/ctxfi/ctatc.c
+++ b/sound/pci/ctxfi/ctatc.c
@@ -1429,10 +1429,10 @@ static int atc_get_resources(struct ct_atc *atc)
for (i = 0; i < NUM_DAIOTYP; i++) {
if (((i == MIC) && !cap.dedicated_mic) ||
((i == RCA) && !cap.dedicated_rca) ||
- i == SPDIFI1)
+ i == SPDIFI_BAY)
continue;
if (atc->model == CTSB073X && i == SPDIFIO)
- da_desc.type = SPDIFI1;
+ da_desc.type = SPDIFI_BAY;
else
da_desc.type = i;
da_desc.output = (i < LINEIM) || (i == RCA);
diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c
index 4dbb1dd7af32..128cf2f69ac1 100644
--- a/sound/pci/ctxfi/ctdaio.c
+++ b/sound/pci/ctxfi/ctdaio.c
@@ -35,7 +35,7 @@ static const struct daio_rsc_idx idx_20k1[NUM_DAIOTYP] = {
[LINEIM] = {.left = 0x1b5, .right = 0x1bd},
[SPDIFOO] = {.left = 0x20, .right = 0x21},
[SPDIFIO] = {.left = 0x15, .right = 0x1d},
- [SPDIFI1] = {.left = 0x95, .right = 0x9d},
+ [SPDIFI_BAY] = {.left = 0x95, .right = 0x9d},
};
static const struct daio_rsc_idx idx_20k2[NUM_DAIOTYP] = {
@@ -106,7 +106,7 @@ static int daio_device_index(enum DAIOTYP type, struct hw *hw)
switch (type) {
case SPDIFOO: return 0;
case SPDIFIO: return 0;
- case SPDIFI1: return 1;
+ case SPDIFI_BAY: return 1;
case LINEO1: return 4;
case LINEO2: return 7;
case LINEO3: return 5;
@@ -120,7 +120,7 @@ static int daio_device_index(enum DAIOTYP type, struct hw *hw)
switch (type) {
case SPDIFOO: return 0;
case SPDIFIO: return 0;
- case SPDIFI1: return 1;
+ case SPDIFI_BAY: return 1;
case LINEO1: return 4;
case LINEO2: return 7;
case LINEO3: return 5;
diff --git a/sound/pci/ctxfi/ctdaio.h b/sound/pci/ctxfi/ctdaio.h
index ff77d55539a5..c9f6207fe92f 100644
--- a/sound/pci/ctxfi/ctdaio.h
+++ b/sound/pci/ctxfi/ctdaio.h
@@ -32,7 +32,7 @@ enum DAIOTYP {
SPDIFIO, /* S/PDIF In (Flexijack/Optical) on the card */
MIC, /* Dedicated mic on Titanium HD */
RCA, /* Dedicated RCA on SE-300PCIE */
- SPDIFI1, /* S/PDIF In on internal Drive Bay */
+ SPDIFI_BAY, /* S/PDIF In on internal drive bay */
NUM_DAIOTYP
};
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/3] ALSA: ctxfi: Use matching DAIO type for da_desc
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 ` Harin Lee
2026-04-01 7:57 ` Takashi Iwai
2026-03-31 15:35 ` [PATCH 3/3] ALSA: ctxfi: Precompute SRC allocation loop bound Harin Lee
2 siblings, 1 reply; 5+ messages in thread
From: Harin Lee @ 2026-03-31 15:35 UTC (permalink / raw)
To: Jaroslav Kysela, Takashi Iwai; +Cc: linux-sound, linux-kernel, Harin Lee
Skip the unused DAIO type per model (SPDIFIO on CTSB073X, SPDIFI_BAY
on all others) and use the matching DAIO type directly as da_desc
type. This removes the mismatch between the actual DAIO resource and
the da_desc type like SPDIFI_BAY (formerly SPDIFI1). Update related
functions accordingly, and drop the unreachable SPDIFI_BAY case from
the hw20k2 daio_device_index().
Signed-off-by: Harin Lee <me@harin.net>
---
sound/pci/ctxfi/ctatc.c | 17 ++++++++---------
sound/pci/ctxfi/ctdaio.c | 1 -
2 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c
index 9e0532fb33ff..9a1f6cebaa32 100644
--- a/sound/pci/ctxfi/ctatc.c
+++ b/sound/pci/ctxfi/ctatc.c
@@ -1121,7 +1121,8 @@ static int atc_spdif_out_unmute(struct ct_atc *atc, unsigned char state)
static int atc_spdif_in_unmute(struct ct_atc *atc, unsigned char state)
{
- return atc_daio_unmute(atc, state, SPDIFIO);
+ return atc_daio_unmute(atc, state, (atc->model == CTSB073X) ?
+ SPDIFI_BAY : SPDIFIO);
}
static int atc_spdif_out_get_status(struct ct_atc *atc, unsigned int *status)
@@ -1429,12 +1430,9 @@ static int atc_get_resources(struct ct_atc *atc)
for (i = 0; i < NUM_DAIOTYP; i++) {
if (((i == MIC) && !cap.dedicated_mic) ||
((i == RCA) && !cap.dedicated_rca) ||
- i == SPDIFI_BAY)
+ (i == ((atc->model == CTSB073X) ? SPDIFIO : SPDIFI_BAY)))
continue;
- if (atc->model == CTSB073X && i == SPDIFIO)
- da_desc.type = SPDIFI_BAY;
- else
- da_desc.type = i;
+ da_desc.type = i;
da_desc.output = (i < LINEIM) || (i == RCA);
err = daio_mgr->get_daio(daio_mgr, &da_desc,
(struct daio **)&atc->daios[i]);
@@ -1569,10 +1567,11 @@ static void atc_connect_resources(struct ct_atc *atc)
mixer->set_input_right(mixer, MIX_MIC_IN, &src->rsc);
}
- dai = container_of(atc->daios[SPDIFIO], struct dai, daio);
+ dai = container_of(atc->daios[(atc->model == CTSB073X) ?
+ SPDIFI_BAY : SPDIFIO], struct dai, daio);
atc_connect_dai(atc->rsc_mgrs[SRC], dai,
- (struct src **)&atc->srcs[0],
- (struct srcimp **)&atc->srcimps[0]);
+ (struct src **)&atc->srcs[0],
+ (struct srcimp **)&atc->srcimps[0]);
src = atc->srcs[0];
mixer->set_input_left(mixer, MIX_SPDIF_IN, &src->rsc);
diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c
index 128cf2f69ac1..69aacd06716c 100644
--- a/sound/pci/ctxfi/ctdaio.c
+++ b/sound/pci/ctxfi/ctdaio.c
@@ -120,7 +120,6 @@ static int daio_device_index(enum DAIOTYP type, struct hw *hw)
switch (type) {
case SPDIFOO: return 0;
case SPDIFIO: return 0;
- case SPDIFI_BAY: return 1;
case LINEO1: return 4;
case LINEO2: return 7;
case LINEO3: return 5;
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 2/3] ALSA: ctxfi: Use matching DAIO type for da_desc
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
0 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2026-04-01 7:57 UTC (permalink / raw)
To: Harin Lee; +Cc: Jaroslav Kysela, Takashi Iwai, linux-sound, linux-kernel
On Tue, 31 Mar 2026 17:35:06 +0200,
Harin Lee wrote:
> @@ -1121,7 +1121,8 @@ static int atc_spdif_out_unmute(struct ct_atc *atc, unsigned char state)
>
> static int atc_spdif_in_unmute(struct ct_atc *atc, unsigned char state)
> {
> - return atc_daio_unmute(atc, state, SPDIFIO);
> + return atc_daio_unmute(atc, state, (atc->model == CTSB073X) ?
> + SPDIFI_BAY : SPDIFIO);
It's error-prone to use ternary operators as open code in many places.
Better to define a function instead.
> }
>
> static int atc_spdif_out_get_status(struct ct_atc *atc, unsigned int *status)
> @@ -1429,12 +1430,9 @@ static int atc_get_resources(struct ct_atc *atc)
> for (i = 0; i < NUM_DAIOTYP; i++) {
> if (((i == MIC) && !cap.dedicated_mic) ||
> ((i == RCA) && !cap.dedicated_rca) ||
> - i == SPDIFI_BAY)
> + (i == ((atc->model == CTSB073X) ? SPDIFIO : SPDIFI_BAY)))
... and this is even reversed value assignment which is rather
confusing. Rather write with a simple if/else, such as:
if ((i == SPDFIO && atc->model == CTSB073X) ||
(i == SPDIFI_BAY && atc->model != CTSB073X))
continue;
> atc_connect_dai(atc->rsc_mgrs[SRC], dai,
> - (struct src **)&atc->srcs[0],
> - (struct srcimp **)&atc->srcimps[0]);
> + (struct src **)&atc->srcs[0],
> + (struct srcimp **)&atc->srcimps[0]);
Avoid unnecessary spacing changes. The previous code is fine about
indentation.
thanks,
Takashi
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/3] ALSA: ctxfi: Precompute SRC allocation loop bound
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-03-31 15:35 ` Harin Lee
2 siblings, 0 replies; 5+ messages in thread
From: Harin Lee @ 2026-03-31 15:35 UTC (permalink / raw)
To: Jaroslav Kysela, Takashi Iwai; +Cc: linux-sound, linux-kernel, Harin Lee
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
^ permalink raw reply related [flat|nested] 5+ messages in thread