Skip to content

Commit 9bb003a

Browse files
harinworkstiwai
authored andcommitted
ALSA: ctxfi: Use explicit output flag for DAIO resources
Replace the index-based type check with an explicit output flag in struct daio and struct daio_desc. This allows handling DAIO resource types correctly regardless of their index. This is necessary for hardware variants where resource types do not follow a sequential order. Signed-off-by: Harin Lee <me@harin.net> Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20251124180501.2760421-4-me@harin.net
1 parent 4b490e0 commit 9bb003a

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

sound/pci/ctxfi/ctatc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ static int atc_release_resources(struct ct_atc *atc)
11631163
daio_mgr = (struct daio_mgr *)atc->rsc_mgrs[DAIO];
11641164
for (i = 0; i < atc->n_daio; i++) {
11651165
daio = atc->daios[i];
1166-
if (daio->type < LINEIM) {
1166+
if (daio->output) {
11671167
dao = container_of(daio, struct dao, daio);
11681168
dao->ops->clear_left_input(dao);
11691169
dao->ops->clear_right_input(dao);
@@ -1393,6 +1393,7 @@ static int atc_get_resources(struct ct_atc *atc)
13931393
for (i = 0, atc->n_daio = 0; i < num_daios; i++) {
13941394
da_desc.type = (atc->model != CTSB073X) ? i :
13951395
((i == SPDIFIO) ? SPDIFI1 : i);
1396+
da_desc.output = i < LINEIM;
13961397
err = daio_mgr->get_daio(daio_mgr, &da_desc,
13971398
(struct daio **)&atc->daios[i]);
13981399
if (err) {

sound/pci/ctxfi/ctdaio.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
#include <linux/slab.h>
1919
#include <linux/kernel.h>
2020

21-
#define DAIO_OUT_MAX SPDIFOO
22-
2321
struct daio_usage {
2422
unsigned short data;
2523
};
@@ -329,7 +327,7 @@ static int daio_rsc_init(struct daio *daio,
329327
goto error1;
330328

331329
/* Set daio->rscl/r->ops to daio specific ones */
332-
if (desc->type <= DAIO_OUT_MAX) {
330+
if (desc->output) {
333331
daio->rscl.ops = daio->rscr.ops = &daio_out_rsc_ops;
334332
} else {
335333
switch (hw->chip_type) {
@@ -344,6 +342,7 @@ static int daio_rsc_init(struct daio *daio,
344342
}
345343
}
346344
daio->type = desc->type;
345+
daio->output = desc->output;
347346

348347
return 0;
349348

@@ -433,6 +432,7 @@ static int dao_rsc_reinit(struct dao *dao, const struct dao_desc *desc)
433432
dsc.type = dao->daio.type;
434433
dsc.msr = desc->msr;
435434
dsc.passthru = desc->passthru;
435+
dsc.output = dao->daio.output;
436436
dao_rsc_uninit(dao);
437437
return dao_rsc_init(dao, &dsc, mgr);
438438
}
@@ -518,7 +518,7 @@ static int get_daio_rsc(struct daio_mgr *mgr,
518518

519519
err = -ENOMEM;
520520
/* Allocate mem for daio resource */
521-
if (desc->type <= DAIO_OUT_MAX) {
521+
if (desc->output) {
522522
struct dao *dao = kzalloc(sizeof(*dao), GFP_KERNEL);
523523
if (!dao)
524524
goto error;
@@ -565,7 +565,7 @@ static int put_daio_rsc(struct daio_mgr *mgr, struct daio *daio)
565565
daio_mgr_put_rsc(&mgr->mgr, daio->type);
566566
}
567567

568-
if (daio->type <= DAIO_OUT_MAX) {
568+
if (daio->output) {
569569
dao_rsc_uninit(container_of(daio, struct dao, daio));
570570
kfree(container_of(daio, struct dao, daio));
571571
} else {
@@ -580,7 +580,7 @@ static int daio_mgr_enb_daio(struct daio_mgr *mgr, struct daio *daio)
580580
{
581581
struct hw *hw = mgr->mgr.hw;
582582

583-
if (DAIO_OUT_MAX >= daio->type) {
583+
if (daio->output) {
584584
hw->daio_mgr_enb_dao(mgr->mgr.ctrl_blk,
585585
daio_device_index(daio->type, hw));
586586
} else {
@@ -594,7 +594,7 @@ static int daio_mgr_dsb_daio(struct daio_mgr *mgr, struct daio *daio)
594594
{
595595
struct hw *hw = mgr->mgr.hw;
596596

597-
if (DAIO_OUT_MAX >= daio->type) {
597+
if (daio->output) {
598598
hw->daio_mgr_dsb_dao(mgr->mgr.ctrl_blk,
599599
daio_device_index(daio->type, hw));
600600
} else {

sound/pci/ctxfi/ctdaio.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ struct daio {
4343
struct rsc rscl; /* Basic resource info for left TX/RX */
4444
struct rsc rscr; /* Basic resource info for right TX/RX */
4545
enum DAIOTYP type;
46+
unsigned char output;
4647
};
4748

4849
struct dao {
@@ -91,6 +92,7 @@ struct daio_desc {
9192
unsigned int type:4;
9293
unsigned int msr:4;
9394
unsigned int passthru:1;
95+
unsigned int output:1;
9496
};
9597

9698
struct daio_mgr {

0 commit comments

Comments
 (0)