Skip to content

Commit 7796c97

Browse files
mohsRafibroonie
authored andcommitted
soundwire: qcom: Add set_channel_map api support
Added qcom_swrm_set_channel_map api to set the master channel mask for TX and RX paths based on the provided slots. Added a new field ch_mask to the qcom_swrm_port_config structure. This field is used to store the master channel mask, which allows more flexible to configure channel mask in runtime for specific active soundwire ports. Modified the qcom_swrm_port_enable function to configure master channel mask. If the ch_mask is set to SWR_INVALID_PARAM or is zero, the function will use the default channel mask. Signed-off-by: Mohammad Rafi Shaik <[email protected]> Acked-by: Vinod Koul <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent c06c4f7 commit 7796c97

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

drivers/soundwire/qcom.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ struct qcom_swrm_port_config {
156156
u8 word_length;
157157
u8 blk_group_count;
158158
u8 lane_control;
159+
u8 ch_mask;
159160
};
160161

161162
/*
@@ -1048,9 +1049,13 @@ static int qcom_swrm_port_enable(struct sdw_bus *bus,
10481049
{
10491050
u32 reg = SWRM_DP_PORT_CTRL_BANK(enable_ch->port_num, bank);
10501051
struct qcom_swrm_ctrl *ctrl = to_qcom_sdw(bus);
1052+
struct qcom_swrm_port_config *pcfg;
10511053
u32 val;
10521054

1055+
pcfg = &ctrl->pconfig[enable_ch->port_num];
10531056
ctrl->reg_read(ctrl, reg, &val);
1057+
if (pcfg->ch_mask != SWR_INVALID_PARAM && pcfg->ch_mask != 0)
1058+
enable_ch->ch_mask = pcfg->ch_mask;
10541059

10551060
if (enable_ch->enable)
10561061
val |= (enable_ch->ch_mask << SWRM_DP_PORT_CTRL_EN_CHAN_SHFT);
@@ -1270,6 +1275,26 @@ static void *qcom_swrm_get_sdw_stream(struct snd_soc_dai *dai, int direction)
12701275
return ctrl->sruntime[dai->id];
12711276
}
12721277

1278+
static int qcom_swrm_set_channel_map(struct snd_soc_dai *dai,
1279+
unsigned int tx_num, const unsigned int *tx_slot,
1280+
unsigned int rx_num, const unsigned int *rx_slot)
1281+
{
1282+
struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(dai->dev);
1283+
int i;
1284+
1285+
if (tx_slot) {
1286+
for (i = 0; i < tx_num; i++)
1287+
ctrl->pconfig[i].ch_mask = tx_slot[i];
1288+
}
1289+
1290+
if (rx_slot) {
1291+
for (i = 0; i < rx_num; i++)
1292+
ctrl->pconfig[i].ch_mask = rx_slot[i];
1293+
}
1294+
1295+
return 0;
1296+
}
1297+
12731298
static int qcom_swrm_startup(struct snd_pcm_substream *substream,
12741299
struct snd_soc_dai *dai)
12751300
{
@@ -1306,6 +1331,7 @@ static const struct snd_soc_dai_ops qcom_swrm_pdm_dai_ops = {
13061331
.shutdown = qcom_swrm_shutdown,
13071332
.set_stream = qcom_swrm_set_sdw_stream,
13081333
.get_stream = qcom_swrm_get_sdw_stream,
1334+
.set_channel_map = qcom_swrm_set_channel_map,
13091335
};
13101336

13111337
static const struct snd_soc_component_driver qcom_swrm_dai_component = {

0 commit comments

Comments
 (0)