Skip to content

Commit

Permalink
i2s: read tx/rx route from ACPI
Browse files Browse the repository at this point in the history
  • Loading branch information
coolstar committed Jan 7, 2024
1 parent 103810d commit 749f0e0
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 25 deletions.
2 changes: 2 additions & 0 deletions drivers/audio/csaudiork3x/Source/Utilities/adsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ typedef struct _RK_TPLG {
UINT32 tx;
UINT32 rx;
char audio_tplg[32];
UINT32 i2s_tx_route;
UINT32 i2s_rx_route;
} RK_TPLG, *PRK_TPLG;

typedef struct _TPLG_INFO {
Expand Down
54 changes: 29 additions & 25 deletions drivers/audio/csaudiork3x/Source/Utilities/hw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,31 +191,35 @@ NTSTATUS CCsAudioRk3xHW::rk3x_init() {
I2S_RXCR_VDW(16));

//set path
i2s_update32(I2S_TXCR,
I2S_TXCR_PATH_MASK(0),
I2S_TXCR_PATH(0, 3));
i2s_update32(I2S_TXCR,
I2S_TXCR_PATH_MASK(1),
I2S_TXCR_PATH(1, 2));
i2s_update32(I2S_TXCR,
I2S_TXCR_PATH_MASK(2),
I2S_TXCR_PATH(2, 1));
i2s_update32(I2S_TXCR,
I2S_TXCR_PATH_MASK(3),
I2S_TXCR_PATH(3, 0));

i2s_update32(I2S_RXCR,
I2S_RXCR_PATH_MASK(0),
I2S_RXCR_PATH(0, 1));
i2s_update32(I2S_RXCR,
I2S_RXCR_PATH_MASK(1),
I2S_RXCR_PATH(1, 3));
i2s_update32(I2S_RXCR,
I2S_RXCR_PATH_MASK(2),
I2S_RXCR_PATH(2, 2));
i2s_update32(I2S_RXCR,
I2S_RXCR_PATH_MASK(3),
I2S_RXCR_PATH(3, 0));
if (this->rkTPLG.i2s_tx_route) {
i2s_update32(I2S_TXCR,
I2S_TXCR_PATH_MASK(0),
I2S_TXCR_PATH(0, (this->rkTPLG.i2s_tx_route >> 12) & 0xf));
i2s_update32(I2S_TXCR,
I2S_TXCR_PATH_MASK(1),
I2S_TXCR_PATH(1, (this->rkTPLG.i2s_tx_route >> 8) & 0xf));
i2s_update32(I2S_TXCR,
I2S_TXCR_PATH_MASK(2),
I2S_TXCR_PATH(2, (this->rkTPLG.i2s_tx_route >> 4) & 0xf));
i2s_update32(I2S_TXCR,
I2S_TXCR_PATH_MASK(3),
I2S_TXCR_PATH(3, (this->rkTPLG.i2s_tx_route >> 0) & 0xf));
}

if (this->rkTPLG.i2s_rx_route) {
i2s_update32(I2S_RXCR,
I2S_RXCR_PATH_MASK(0),
I2S_RXCR_PATH(0, (this->rkTPLG.i2s_rx_route >> 12) & 0xf));
i2s_update32(I2S_RXCR,
I2S_RXCR_PATH_MASK(1),
I2S_RXCR_PATH(1, (this->rkTPLG.i2s_rx_route >> 8) & 0xf));
i2s_update32(I2S_RXCR,
I2S_RXCR_PATH_MASK(2),
I2S_RXCR_PATH(2, (this->rkTPLG.i2s_rx_route >> 4) & 0xf));
i2s_update32(I2S_RXCR,
I2S_RXCR_PATH_MASK(3),
I2S_RXCR_PATH(3, (this->rkTPLG.i2s_rx_route >> 0) & 0xf));
}

return STATUS_SUCCESS;
#else
Expand Down
6 changes: 6 additions & 0 deletions drivers/audio/rk3xi2sbus/rk-tplg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ GetRKTplg(
else if (CHECK_STR(dsdParameterName, "rockchip,rx")) {
copyDSDParamNum(dsdParameterData, &rkTplg->rx);
}
else if (CHECK_STR(dsdParameterName, "rockchip,i2s-tx-route")) {
copyDSDParamNum(dsdParameterData, &rkTplg->i2s_tx_route);
}
else if (CHECK_STR(dsdParameterName, "rockchip,i2s-rx-route")) {
copyDSDParamNum(dsdParameterData, &rkTplg->i2s_rx_route);
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions drivers/audio/rk3xi2sbus/rk-tplg.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ typedef struct _RK_TPLG {
UINT32 tx;
UINT32 rx;
char audio_tplg[32];
UINT32 i2s_tx_route;
UINT32 i2s_rx_route;
} RK_TPLG, *PRK_TPLG;

NTSTATUS GetRKTplg(WDFDEVICE FxDevice, RK_TPLG *rkTplg);
Expand Down

0 comments on commit 749f0e0

Please sign in to comment.