From 382ff806bbaf1a8ac87ee1b2eb83d48d73e6e1a1 Mon Sep 17 00:00:00 2001 From: Vatsal Bucha Date: Wed, 14 Jul 2021 09:54:35 +0530 Subject: [PATCH 01/82] ASoC: msm-dai-q6-v2: Add separate cpu dais for mi2s rx and tx MI2S capture fails on gki build as there are no separate cpu dais for rx and tx. This is due to afe port start opening rx port on capture. Add separate dais for mi2s rx and tx to resolve issue. Change-Id: I37cc1132039ee1525c4f16f8b10b0a9344989d75 Signed-off-by: Vatsal Bucha --- asoc/msm-dai-q6-v2.c | 406 +++++++++++++++++++++++-------------------- asoc/msm-dai-q6-v2.h | 50 ++++-- 2 files changed, 246 insertions(+), 210 deletions(-) diff --git a/asoc/msm-dai-q6-v2.c b/asoc/msm-dai-q6-v2.c index 43f67953d10c..0acf2c52e346 100755 --- a/asoc/msm-dai-q6-v2.c +++ b/asoc/msm-dai-q6-v2.c @@ -341,8 +341,7 @@ struct msm_dai_q6_mi2s_dai_config { struct msm_dai_q6_mi2s_dai_data { u32 is_island_dai; - struct msm_dai_q6_mi2s_dai_config tx_dai; - struct msm_dai_q6_mi2s_dai_config rx_dai; + struct msm_dai_q6_mi2s_dai_config mi2s_dai; }; struct msm_dai_q6_meta_mi2s_dai_data { @@ -5813,71 +5812,55 @@ static int msm_dai_q6_dai_mi2s_probe(struct snd_soc_dai *dai) u16 dai_id = 0; dai->id = mi2s_pdata->intf_id; - - if (mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode) { - if (dai->id == MSM_PRIM_MI2S) + if (mi2s_dai_data->mi2s_dai.mi2s_dai_data.port_config.i2s.channel_mode) { + if (dai->id == MSM_PRIM_MI2S_RX) ctrl = &mi2s_config_controls[0]; - if (dai->id == MSM_SEC_MI2S) + if (dai->id == MSM_SEC_MI2S_RX) ctrl = &mi2s_config_controls[1]; - if (dai->id == MSM_TERT_MI2S) + if (dai->id == MSM_TERT_MI2S_RX) ctrl = &mi2s_config_controls[2]; - if (dai->id == MSM_QUAT_MI2S) + if (dai->id == MSM_QUAT_MI2S_RX) ctrl = &mi2s_config_controls[3]; - if (dai->id == MSM_QUIN_MI2S) + if (dai->id == MSM_QUIN_MI2S_RX) ctrl = &mi2s_config_controls[4]; - if (dai->id == MSM_SENARY_MI2S) + if (dai->id == MSM_SENARY_MI2S_RX) ctrl = &mi2s_config_controls[5]; - } - - if (ctrl) { - kcontrol = snd_ctl_new1(ctrl, - &mi2s_dai_data->rx_dai.mi2s_dai_data); - rc = snd_ctl_add(dai->component->card->snd_card, kcontrol); - if (rc < 0) { - dev_err(dai->dev, "%s: err add RX fmt ctl DAI = %s\n", - __func__, dai->name); - goto rtn; - } - } - - ctrl = NULL; - if (mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode) { - if (dai->id == MSM_PRIM_MI2S) + if (dai->id == MSM_PRIM_MI2S_TX) ctrl = &mi2s_config_controls[6]; - if (dai->id == MSM_SEC_MI2S) + if (dai->id == MSM_SEC_MI2S_TX) ctrl = &mi2s_config_controls[7]; - if (dai->id == MSM_TERT_MI2S) + if (dai->id == MSM_TERT_MI2S_TX) ctrl = &mi2s_config_controls[8]; - if (dai->id == MSM_QUAT_MI2S) + if (dai->id == MSM_QUAT_MI2S_TX) ctrl = &mi2s_config_controls[9]; - if (dai->id == MSM_QUIN_MI2S) + if (dai->id == MSM_QUIN_MI2S_TX) ctrl = &mi2s_config_controls[10]; - if (dai->id == MSM_SENARY_MI2S) + if (dai->id == MSM_SENARY_MI2S_TX) ctrl = &mi2s_config_controls[11]; - if (dai->id == MSM_INT5_MI2S) + if (dai->id == MSM_INT5_MI2S_TX) ctrl = &mi2s_config_controls[12]; } if (ctrl) { rc = snd_ctl_add(dai->component->card->snd_card, snd_ctl_new1(ctrl, - &mi2s_dai_data->tx_dai.mi2s_dai_data)); + &mi2s_dai_data->mi2s_dai.mi2s_dai_data)); if (rc < 0) { if (kcontrol) snd_ctl_remove(dai->component->card->snd_card, kcontrol); - dev_err(dai->dev, "%s: err add TX fmt ctl DAI = %s\n", + dev_err(dai->dev, "%s: err add MI2S fmt ctl DAI = %s\n", __func__, dai->name); } } - if (dai->id == MSM_INT5_MI2S) + if (dai->id == MSM_INT5_MI2S_TX) vi_feed_ctrl = &mi2s_vi_feed_controls[0]; if (vi_feed_ctrl) { rc = snd_ctl_add(dai->component->card->snd_card, snd_ctl_new1(vi_feed_ctrl, - &mi2s_dai_data->tx_dai.mi2s_dai_data)); + &mi2s_dai_data->mi2s_dai.mi2s_dai_data)); if (rc < 0) { dev_err(dai->dev, "%s: err add TX vi feed channel ctl DAI = %s\n", @@ -5895,7 +5878,6 @@ static int msm_dai_q6_dai_mi2s_probe(struct snd_soc_dai *dai) } rc = msm_dai_q6_dai_add_route(dai); -rtn: return rc; } @@ -5905,23 +5887,22 @@ static int msm_dai_q6_dai_mi2s_remove(struct snd_soc_dai *dai) struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data = dev_get_drvdata(dai->dev); int rc; + bool rx_port_en = false; /* If AFE port is still up, close it */ + if (strnstr(dev_name(dai->dev), "rx", strlen(dev_name(dai->dev))) + != NULL) + rx_port_en = true; if (test_bit(STATUS_PORT_STARTED, - mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask)) { - rc = afe_close(MI2S_RX); /* can block */ + mi2s_dai_data->mi2s_dai.mi2s_dai_data.status_mask)) { + if (rx_port_en) + rc = afe_close(MI2S_RX); /* can block */ + else + rc = afe_close(MI2S_TX); /* can block */ if (rc < 0) dev_err(dai->dev, "fail to close MI2S_RX port\n"); clear_bit(STATUS_PORT_STARTED, - mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask); - } - if (test_bit(STATUS_PORT_STARTED, - mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) { - rc = afe_close(MI2S_TX); /* can block */ - if (rc < 0) - dev_err(dai->dev, "fail to close MI2S_TX port\n"); - clear_bit(STATUS_PORT_STARTED, - mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask); + mi2s_dai_data->mi2s_dai.mi2s_dai_data.status_mask); } return 0; } @@ -5940,46 +5921,46 @@ static int msm_mi2s_get_port_id(u32 mi2s_id, int stream, u16 *port_id) switch (stream) { case SNDRV_PCM_STREAM_PLAYBACK: switch (mi2s_id) { - case MSM_PRIM_MI2S: + case MSM_PRIM_MI2S_RX: *port_id = AFE_PORT_ID_PRIMARY_MI2S_RX; break; - case MSM_SEC_MI2S: + case MSM_SEC_MI2S_RX: *port_id = AFE_PORT_ID_SECONDARY_MI2S_RX; break; - case MSM_TERT_MI2S: + case MSM_TERT_MI2S_RX: *port_id = AFE_PORT_ID_TERTIARY_MI2S_RX; break; - case MSM_QUAT_MI2S: + case MSM_QUAT_MI2S_RX: *port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX; break; case MSM_SEC_MI2S_SD1: *port_id = AFE_PORT_ID_SECONDARY_MI2S_RX_SD1; break; - case MSM_QUIN_MI2S: + case MSM_QUIN_MI2S_RX: *port_id = AFE_PORT_ID_QUINARY_MI2S_RX; break; - case MSM_SENARY_MI2S: + case MSM_SENARY_MI2S_RX: *port_id = AFE_PORT_ID_SENARY_MI2S_RX; break; - case MSM_INT0_MI2S: + case MSM_INT0_MI2S_RX: *port_id = AFE_PORT_ID_INT0_MI2S_RX; break; - case MSM_INT1_MI2S: + case MSM_INT1_MI2S_RX: *port_id = AFE_PORT_ID_INT1_MI2S_RX; break; - case MSM_INT2_MI2S: + case MSM_INT2_MI2S_RX: *port_id = AFE_PORT_ID_INT2_MI2S_RX; break; - case MSM_INT3_MI2S: + case MSM_INT3_MI2S_RX: *port_id = AFE_PORT_ID_INT3_MI2S_RX; break; - case MSM_INT4_MI2S: + case MSM_INT4_MI2S_RX: *port_id = AFE_PORT_ID_INT4_MI2S_RX; break; - case MSM_INT5_MI2S: + case MSM_INT5_MI2S_RX: *port_id = AFE_PORT_ID_INT5_MI2S_RX; break; - case MSM_INT6_MI2S: + case MSM_INT6_MI2S_RX: *port_id = AFE_PORT_ID_INT6_MI2S_RX; break; default: @@ -5991,43 +5972,43 @@ static int msm_mi2s_get_port_id(u32 mi2s_id, int stream, u16 *port_id) break; case SNDRV_PCM_STREAM_CAPTURE: switch (mi2s_id) { - case MSM_PRIM_MI2S: + case MSM_PRIM_MI2S_TX: *port_id = AFE_PORT_ID_PRIMARY_MI2S_TX; break; - case MSM_SEC_MI2S: + case MSM_SEC_MI2S_TX: *port_id = AFE_PORT_ID_SECONDARY_MI2S_TX; break; - case MSM_TERT_MI2S: + case MSM_TERT_MI2S_TX: *port_id = AFE_PORT_ID_TERTIARY_MI2S_TX; break; - case MSM_QUAT_MI2S: + case MSM_QUAT_MI2S_TX: *port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX; break; - case MSM_QUIN_MI2S: + case MSM_QUIN_MI2S_TX: *port_id = AFE_PORT_ID_QUINARY_MI2S_TX; break; - case MSM_SENARY_MI2S: + case MSM_SENARY_MI2S_TX: *port_id = AFE_PORT_ID_SENARY_MI2S_TX; break; - case MSM_INT0_MI2S: + case MSM_INT0_MI2S_TX: *port_id = AFE_PORT_ID_INT0_MI2S_TX; break; - case MSM_INT1_MI2S: + case MSM_INT1_MI2S_TX: *port_id = AFE_PORT_ID_INT1_MI2S_TX; break; - case MSM_INT2_MI2S: + case MSM_INT2_MI2S_TX: *port_id = AFE_PORT_ID_INT2_MI2S_TX; break; - case MSM_INT3_MI2S: + case MSM_INT3_MI2S_TX: *port_id = AFE_PORT_ID_INT3_MI2S_TX; break; - case MSM_INT4_MI2S: + case MSM_INT4_MI2S_TX: *port_id = AFE_PORT_ID_INT4_MI2S_TX; break; - case MSM_INT5_MI2S: + case MSM_INT5_MI2S_TX: *port_id = AFE_PORT_ID_INT5_MI2S_TX; break; - case MSM_INT6_MI2S: + case MSM_INT6_MI2S_TX: *port_id = AFE_PORT_ID_INT6_MI2S_TX; break; default: @@ -6051,9 +6032,7 @@ static int msm_dai_q6_mi2s_prepare(struct snd_pcm_substream *substream, struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data = dev_get_drvdata(dai->dev); struct msm_dai_q6_dai_data *dai_data = - (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? - &mi2s_dai_data->rx_dai.mi2s_dai_data : - &mi2s_dai_data->tx_dai.mi2s_dai_data); + &mi2s_dai_data->mi2s_dai.mi2s_dai_data; u16 port_id = 0; int rc = 0; @@ -6096,8 +6075,7 @@ static int msm_dai_q6_mi2s_hw_params(struct snd_pcm_substream *substream, struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data = dev_get_drvdata(dai->dev); struct msm_dai_q6_mi2s_dai_config *mi2s_dai_config = - (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? - &mi2s_dai_data->rx_dai : &mi2s_dai_data->tx_dai); + &mi2s_dai_data->mi2s_dai; struct msm_dai_q6_dai_data *dai_data = &mi2s_dai_config->mi2s_dai_data; struct afe_param_id_i2s_cfg *i2s = &dai_data->port_config.i2s; @@ -6282,29 +6260,7 @@ static int msm_dai_q6_mi2s_hw_params(struct snd_pcm_substream *substream, dai_data->port_config.i2s.i2s_cfg_minor_version = AFE_API_VERSION_I2S_CONFIG; dai_data->port_config.i2s.sample_rate = dai_data->rate; - if ((test_bit(STATUS_PORT_STARTED, - mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) && - test_bit(STATUS_PORT_STARTED, - mi2s_dai_data->rx_dai.mi2s_dai_data.hwfree_status)) || - (test_bit(STATUS_PORT_STARTED, - mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask) && - test_bit(STATUS_PORT_STARTED, - mi2s_dai_data->tx_dai.mi2s_dai_data.hwfree_status))) { - if ((mi2s_dai_data->tx_dai.mi2s_dai_data.rate != - mi2s_dai_data->rx_dai.mi2s_dai_data.rate) || - (mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth != - mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth)) { - dev_err(dai->dev, "%s: Error mismatch in HW params\n" - "Tx sample_rate = %u bit_width = %hu\n" - "Rx sample_rate = %u bit_width = %hu\n" - , __func__, - mi2s_dai_data->tx_dai.mi2s_dai_data.rate, - mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth, - mi2s_dai_data->rx_dai.mi2s_dai_data.rate, - mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth); - return -EINVAL; - } - } + dev_dbg(dai->dev, "%s: dai id %d dai_data->channels = %d\n" "sample_rate = %u i2s_cfg_minor_version = 0x%x\n" "bit_width = %hu channel_mode = 0x%x mono_stereo = %#x\n" @@ -6329,9 +6285,7 @@ static int msm_dai_q6_mi2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) dev_get_drvdata(dai->dev); if (test_bit(STATUS_PORT_STARTED, - mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) || - test_bit(STATUS_PORT_STARTED, - mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) { + mi2s_dai_data->mi2s_dai.mi2s_dai_data.status_mask)) { dev_err(dai->dev, "%s: err chg i2s mode while dai running", __func__); return -EPERM; @@ -6340,12 +6294,10 @@ static int msm_dai_q6_mi2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: case SND_SOC_DAIFMT_CBM_CFS: - mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1; - mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1; + mi2s_dai_data->mi2s_dai.mi2s_dai_data.port_config.i2s.ws_src = 1; break; case SND_SOC_DAIFMT_CBM_CFM: - mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0; - mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0; + mi2s_dai_data->mi2s_dai.mi2s_dai_data.port_config.i2s.ws_src = 0; break; default: pr_err("%s: fmt %d\n", @@ -6362,9 +6314,7 @@ static int msm_dai_q6_mi2s_hw_free(struct snd_pcm_substream *substream, struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data = dev_get_drvdata(dai->dev); struct msm_dai_q6_dai_data *dai_data = - (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? - &mi2s_dai_data->rx_dai.mi2s_dai_data : - &mi2s_dai_data->tx_dai.mi2s_dai_data); + &mi2s_dai_data->mi2s_dai.mi2s_dai_data; if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status)) { clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status); @@ -6379,9 +6329,7 @@ static void msm_dai_q6_mi2s_shutdown(struct snd_pcm_substream *substream, struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data = dev_get_drvdata(dai->dev); struct msm_dai_q6_dai_data *dai_data = - (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? - &mi2s_dai_data->rx_dai.mi2s_dai_data : - &mi2s_dai_data->tx_dai.mi2s_dai_data); + &mi2s_dai_data->mi2s_dai.mi2s_dai_data; u16 port_id = 0; int rc = 0; @@ -6432,6 +6380,13 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_min = 8000, .rate_max = 384000, }, + .ops = &msm_dai_q6_mi2s_ops, + .name = "Primary MI2S_RX", + .id = MSM_PRIM_MI2S_RX, + .probe = msm_dai_q6_dai_mi2s_probe, + .remove = msm_dai_q6_dai_mi2s_remove, + }, + { .capture = { .stream_name = "Primary MI2S Capture", .aif_name = "PRI_MI2S_TX", @@ -6445,8 +6400,8 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_max = 192000, }, .ops = &msm_dai_q6_mi2s_ops, - .name = "Primary MI2S", - .id = MSM_PRIM_MI2S, + .name = "Primary MI2S_TX", + .id = MSM_PRIM_MI2S_TX, .probe = msm_dai_q6_dai_mi2s_probe, .remove = msm_dai_q6_dai_mi2s_remove, }, @@ -6463,6 +6418,13 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_min = 8000, .rate_max = 192000, }, + .ops = &msm_dai_q6_mi2s_ops, + .name = "Secondary MI2S_RX", + .id = MSM_SEC_MI2S_RX, + .probe = msm_dai_q6_dai_mi2s_probe, + .remove = msm_dai_q6_dai_mi2s_remove, + }, + { .capture = { .stream_name = "Secondary MI2S Capture", .aif_name = "SEC_MI2S_TX", @@ -6476,8 +6438,8 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_max = 192000, }, .ops = &msm_dai_q6_mi2s_ops, - .name = "Secondary MI2S", - .id = MSM_SEC_MI2S, + .name = "Secondary MI2S_TX", + .id = MSM_SEC_MI2S_TX, .probe = msm_dai_q6_dai_mi2s_probe, .remove = msm_dai_q6_dai_mi2s_remove, }, @@ -6494,6 +6456,13 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_min = 8000, .rate_max = 192000, }, + .ops = &msm_dai_q6_mi2s_ops, + .name = "Tertiary MI2S_RX", + .id = MSM_TERT_MI2S_RX, + .probe = msm_dai_q6_dai_mi2s_probe, + .remove = msm_dai_q6_dai_mi2s_remove, + }, + { .capture = { .stream_name = "Tertiary MI2S Capture", .aif_name = "TERT_MI2S_TX", @@ -6507,8 +6476,8 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_max = 192000, }, .ops = &msm_dai_q6_mi2s_ops, - .name = "Tertiary MI2S", - .id = MSM_TERT_MI2S, + .name = "Tertiary MI2S_TX", + .id = MSM_TERT_MI2S_TX, .probe = msm_dai_q6_dai_mi2s_probe, .remove = msm_dai_q6_dai_mi2s_remove, }, @@ -6525,6 +6494,13 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_min = 8000, .rate_max = 192000, }, + .ops = &msm_dai_q6_mi2s_ops, + .name = "Quaternary MI2S_RX", + .id = MSM_QUAT_MI2S_RX, + .probe = msm_dai_q6_dai_mi2s_probe, + .remove = msm_dai_q6_dai_mi2s_remove, + }, + { .capture = { .stream_name = "Quaternary MI2S Capture", .aif_name = "QUAT_MI2S_TX", @@ -6538,8 +6514,8 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_max = 192000, }, .ops = &msm_dai_q6_mi2s_ops, - .name = "Quaternary MI2S", - .id = MSM_QUAT_MI2S, + .name = "Quaternary MI2S_TX", + .id = MSM_QUAT_MI2S_TX, .probe = msm_dai_q6_dai_mi2s_probe, .remove = msm_dai_q6_dai_mi2s_remove, }, @@ -6554,6 +6530,13 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_min = 8000, .rate_max = 192000, }, + .ops = &msm_dai_q6_mi2s_ops, + .name = "Quinary MI2S_RX", + .id = MSM_QUIN_MI2S_RX, + .probe = msm_dai_q6_dai_mi2s_probe, + .remove = msm_dai_q6_dai_mi2s_remove, + }, + { .capture = { .stream_name = "Quinary MI2S Capture", .aif_name = "QUIN_MI2S_TX", @@ -6564,8 +6547,8 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_max = 48000, }, .ops = &msm_dai_q6_mi2s_ops, - .name = "Quinary MI2S", - .id = MSM_QUIN_MI2S, + .name = "Quinary MI2S_TX", + .id = MSM_QUIN_MI2S_TX, .probe = msm_dai_q6_dai_mi2s_probe, .remove = msm_dai_q6_dai_mi2s_remove, }, @@ -6579,6 +6562,13 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_min = 8000, .rate_max = 48000, }, + .ops = &msm_dai_q6_mi2s_ops, + .name = "Senary MI2S_RX", + .id = MSM_SENARY_MI2S_RX, + .probe = msm_dai_q6_dai_mi2s_probe, + .remove = msm_dai_q6_dai_mi2s_remove, + }, + { .capture = { .stream_name = "Senary MI2S Capture", .aif_name = "SENARY_MI2S_TX", @@ -6589,8 +6579,8 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_max = 48000, }, .ops = &msm_dai_q6_mi2s_ops, - .name = "Senary MI2S", - .id = MSM_SENARY_MI2S, + .name = "Senary MI2S_TX", + .id = MSM_SENARY_MI2S_TX, .probe = msm_dai_q6_dai_mi2s_probe, .remove = msm_dai_q6_dai_mi2s_remove, }, @@ -6619,6 +6609,13 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_min = 8000, .rate_max = 192000, }, + .ops = &msm_dai_q6_mi2s_ops, + .name = "INT0 MI2S_RX", + .id = MSM_INT0_MI2S_RX, + .probe = msm_dai_q6_dai_mi2s_probe, + .remove = msm_dai_q6_dai_mi2s_remove, + }, + { .capture = { .stream_name = "INT0 MI2S Capture", .aif_name = "INT0_MI2S_TX", @@ -6629,8 +6626,8 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_max = 48000, }, .ops = &msm_dai_q6_mi2s_ops, - .name = "INT0 MI2S", - .id = MSM_INT0_MI2S, + .name = "INT0 MI2S_TX", + .id = MSM_INT0_MI2S_TX, .probe = msm_dai_q6_dai_mi2s_probe, .remove = msm_dai_q6_dai_mi2s_remove, }, @@ -6646,6 +6643,13 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_min = 8000, .rate_max = 48000, }, + .ops = &msm_dai_q6_mi2s_ops, + .name = "INT1 MI2S_RX", + .id = MSM_INT1_MI2S_RX, + .probe = msm_dai_q6_dai_mi2s_probe, + .remove = msm_dai_q6_dai_mi2s_remove, + }, + { .capture = { .stream_name = "INT1 MI2S Capture", .aif_name = "INT1_MI2S_TX", @@ -6656,8 +6660,8 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_max = 48000, }, .ops = &msm_dai_q6_mi2s_ops, - .name = "INT1 MI2S", - .id = MSM_INT1_MI2S, + .name = "INT1 MI2S_TX", + .id = MSM_INT1_MI2S_TX, .probe = msm_dai_q6_dai_mi2s_probe, .remove = msm_dai_q6_dai_mi2s_remove, }, @@ -6673,6 +6677,13 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_min = 8000, .rate_max = 48000, }, + .ops = &msm_dai_q6_mi2s_ops, + .name = "INT2 MI2S_RX", + .id = MSM_INT2_MI2S_RX, + .probe = msm_dai_q6_dai_mi2s_probe, + .remove = msm_dai_q6_dai_mi2s_remove, + }, + { .capture = { .stream_name = "INT2 MI2S Capture", .aif_name = "INT2_MI2S_TX", @@ -6683,8 +6694,8 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_max = 48000, }, .ops = &msm_dai_q6_mi2s_ops, - .name = "INT2 MI2S", - .id = MSM_INT2_MI2S, + .name = "INT2 MI2S_TX", + .id = MSM_INT2_MI2S_TX, .probe = msm_dai_q6_dai_mi2s_probe, .remove = msm_dai_q6_dai_mi2s_remove, }, @@ -6700,6 +6711,13 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_min = 8000, .rate_max = 48000, }, + .ops = &msm_dai_q6_mi2s_ops, + .name = "INT3 MI2S_RX", + .id = MSM_INT3_MI2S_RX, + .probe = msm_dai_q6_dai_mi2s_probe, + .remove = msm_dai_q6_dai_mi2s_remove, + }, + { .capture = { .stream_name = "INT3 MI2S Capture", .aif_name = "INT3_MI2S_TX", @@ -6710,8 +6728,8 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_max = 48000, }, .ops = &msm_dai_q6_mi2s_ops, - .name = "INT3 MI2S", - .id = MSM_INT3_MI2S, + .name = "INT3 MI2S_TX", + .id = MSM_INT3_MI2S_TX, .probe = msm_dai_q6_dai_mi2s_probe, .remove = msm_dai_q6_dai_mi2s_remove, }, @@ -6728,6 +6746,13 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_min = 8000, .rate_max = 192000, }, + .ops = &msm_dai_q6_mi2s_ops, + .name = "INT4 MI2S_RX", + .id = MSM_INT4_MI2S_RX, + .probe = msm_dai_q6_dai_mi2s_probe, + .remove = msm_dai_q6_dai_mi2s_remove, + }, + { .capture = { .stream_name = "INT4 MI2S Capture", .aif_name = "INT4_MI2S_TX", @@ -6738,8 +6763,8 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_max = 48000, }, .ops = &msm_dai_q6_mi2s_ops, - .name = "INT4 MI2S", - .id = MSM_INT4_MI2S, + .name = "INT4 MI2S_TX", + .id = MSM_INT4_MI2S_TX, .probe = msm_dai_q6_dai_mi2s_probe, .remove = msm_dai_q6_dai_mi2s_remove, }, @@ -6755,6 +6780,13 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_min = 8000, .rate_max = 48000, }, + .ops = &msm_dai_q6_mi2s_ops, + .name = "INT5 MI2S_RX", + .id = MSM_INT5_MI2S_RX, + .probe = msm_dai_q6_dai_mi2s_probe, + .remove = msm_dai_q6_dai_mi2s_remove, + }, + { .capture = { .stream_name = "INT5 MI2S Capture", .aif_name = "INT5_MI2S_TX", @@ -6765,8 +6797,8 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_max = 48000, }, .ops = &msm_dai_q6_mi2s_ops, - .name = "INT5 MI2S", - .id = MSM_INT5_MI2S, + .name = "INT5 MI2S_TX", + .id = MSM_INT5_MI2S_TX, .probe = msm_dai_q6_dai_mi2s_probe, .remove = msm_dai_q6_dai_mi2s_remove, }, @@ -6782,6 +6814,13 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_min = 8000, .rate_max = 48000, }, + .ops = &msm_dai_q6_mi2s_ops, + .name = "INT6 MI2S_RX", + .id = MSM_INT6_MI2S_RX, + .probe = msm_dai_q6_dai_mi2s_probe, + .remove = msm_dai_q6_dai_mi2s_remove, + }, + { .capture = { .stream_name = "INT6 MI2S Capture", .aif_name = "INT6_MI2S_TX", @@ -6792,8 +6831,8 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rate_max = 48000, }, .ops = &msm_dai_q6_mi2s_ops, - .name = "INT6 MI2S", - .id = MSM_INT6_MI2S, + .name = "INT6 MI2S_TX", + .id = MSM_INT6_MI2S_TX, .probe = msm_dai_q6_dai_mi2s_probe, .remove = msm_dai_q6_dai_mi2s_remove, }, @@ -6998,44 +7037,39 @@ static int msm_dai_q6_mi2s_platform_data_validation( return -EINVAL; } - rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->rx_sd_lines, - &sd_line, &ch_cnt); + rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->sd_lines, + &sd_line, &ch_cnt); if (rc < 0) { dev_err(&pdev->dev, "invalid MI2S RX sd line config\n"); goto rtn; } - if (ch_cnt) { - dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode = - sd_line; - dai_data->rx_dai.pdata_mi2s_lines = sd_line; - dai_driver->playback.channels_min = 1; - dai_driver->playback.channels_max = ch_cnt << 1; + if (strnstr(dev_name(&pdev->dev), "rx", strlen(dev_name(&pdev->dev))) + != NULL) { + if (ch_cnt) { + dai_data->mi2s_dai.mi2s_dai_data.port_config.i2s.channel_mode = + sd_line; + dai_data->mi2s_dai.pdata_mi2s_lines = sd_line; + dai_driver->playback.channels_min = 1; + dai_driver->playback.channels_max = ch_cnt << 1; + } else { + dai_driver->playback.channels_min = 0; + dai_driver->playback.channels_max = 0; + } } else { - dai_driver->playback.channels_min = 0; - dai_driver->playback.channels_max = 0; + if (ch_cnt) { + dai_data->mi2s_dai.mi2s_dai_data.port_config.i2s.channel_mode = + sd_line; + dai_data->mi2s_dai.pdata_mi2s_lines = sd_line; + dai_driver->capture.channels_min = 1; + dai_driver->capture.channels_max = ch_cnt << 1; + } else { + dai_driver->capture.channels_min = 0; + dai_driver->capture.channels_max = 0; + } } - rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->tx_sd_lines, - &sd_line, &ch_cnt); - if (rc < 0) { - dev_err(&pdev->dev, "invalid MI2S TX sd line config\n"); - goto rtn; - } - - if (ch_cnt) { - dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode = - sd_line; - dai_data->tx_dai.pdata_mi2s_lines = sd_line; - dai_driver->capture.channels_min = 1; - dai_driver->capture.channels_max = ch_cnt << 1; - } else { - dai_driver->capture.channels_min = 0; - dai_driver->capture.channels_max = 0; - } - - dev_dbg(&pdev->dev, "%s: playback sdline 0x%x capture sdline 0x%x\n", - __func__, dai_data->rx_dai.pdata_mi2s_lines, - dai_data->tx_dai.pdata_mi2s_lines); + dev_dbg(&pdev->dev, "%s: sdlines 0x%x\n", + __func__, dai_data->mi2s_dai.pdata_mi2s_lines); dev_dbg(&pdev->dev, "%s: playback ch_max %d capture ch_mx %d\n", __func__, dai_driver->playback.channels_max, dai_driver->capture.channels_max); @@ -7050,8 +7084,7 @@ static int msm_dai_q6_mi2s_dev_probe(struct platform_device *pdev) { struct msm_dai_q6_mi2s_dai_data *dai_data; const char *q6_mi2s_dev_id = "qcom,msm-dai-q6-mi2s-dev-id"; - u32 tx_line = 0; - u32 rx_line = 0; + u32 mi2s_intf_line = 0; u32 mi2s_intf = 0; struct msm_mi2s_pdata *mi2s_pdata; int rc; @@ -7064,8 +7097,8 @@ static int msm_dai_q6_mi2s_dev_probe(struct platform_device *pdev) goto rtn; } - dev_dbg(&pdev->dev, "dev name %s dev id 0x%x\n", dev_name(&pdev->dev), - mi2s_intf); + dev_dbg(&pdev->dev, "dev name %s dev id 0x%x\n", + dev_name(&pdev->dev), mi2s_intf); if ((mi2s_intf < MSM_MI2S_MIN || mi2s_intf > MSM_MI2S_MAX) || (mi2s_intf >= ARRAY_SIZE(msm_dai_q6_mi2s_dai))) { @@ -7084,25 +7117,16 @@ static int msm_dai_q6_mi2s_dev_probe(struct platform_device *pdev) goto rtn; } - rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-rx-lines", - &rx_line); + rc = of_property_read_u32(pdev->dev.of_node, + "qcom,msm-mi2s-lines", &mi2s_intf_line); if (rc) { - dev_err(&pdev->dev, "%s: Rx line from DT file %s\n", __func__, - "qcom,msm-mi2s-rx-lines"); + dev_err(&pdev->dev, + "%s: Mi2s line from DT file %s\n", __func__, + "qcom,msm-mi2s-lines"); goto free_pdata; } - rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-tx-lines", - &tx_line); - if (rc) { - dev_err(&pdev->dev, "%s: Tx line from DT file %s\n", __func__, - "qcom,msm-mi2s-tx-lines"); - goto free_pdata; - } - dev_dbg(&pdev->dev, "dev name %s Rx line 0x%x , Tx ine 0x%x\n", - dev_name(&pdev->dev), rx_line, tx_line); - mi2s_pdata->rx_sd_lines = rx_line; - mi2s_pdata->tx_sd_lines = tx_line; + mi2s_pdata->sd_lines = mi2s_intf_line; mi2s_pdata->intf_id = mi2s_intf; dai_data = kzalloc(sizeof(struct msm_dai_q6_mi2s_dai_data), diff --git a/asoc/msm-dai-q6-v2.h b/asoc/msm-dai-q6-v2.h index 3ad049d96185..9a43ec7c98ae 100644 --- a/asoc/msm-dai-q6-v2.h +++ b/asoc/msm-dai-q6-v2.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0-only */ -/* Copyright (c) 2012-2017, 2019 The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2017, 2019, 2021 The Linux Foundation. All rights reserved. */ #ifndef __MSM_DAI_Q6_PDATA_H__ @@ -18,22 +18,35 @@ #define MSM_MI2S_CAP_RX 0 #define MSM_MI2S_CAP_TX 1 -#define MSM_PRIM_MI2S 0 -#define MSM_SEC_MI2S 1 -#define MSM_TERT_MI2S 2 -#define MSM_QUAT_MI2S 3 -#define MSM_QUIN_MI2S 4 -#define MSM_SENARY_MI2S 5 -#define MSM_SEC_MI2S_SD1 6 -#define MSM_INT0_MI2S 7 -#define MSM_INT1_MI2S 8 -#define MSM_INT2_MI2S 9 -#define MSM_INT3_MI2S 10 -#define MSM_INT4_MI2S 11 -#define MSM_INT5_MI2S 12 -#define MSM_INT6_MI2S 13 -#define MSM_MI2S_MIN MSM_PRIM_MI2S -#define MSM_MI2S_MAX MSM_INT6_MI2S +#define MSM_PRIM_MI2S_RX 0 +#define MSM_PRIM_MI2S_TX 1 +#define MSM_SEC_MI2S_RX 2 +#define MSM_SEC_MI2S_TX 3 +#define MSM_TERT_MI2S_RX 4 +#define MSM_TERT_MI2S_TX 5 +#define MSM_QUAT_MI2S_RX 6 +#define MSM_QUAT_MI2S_TX 7 +#define MSM_QUIN_MI2S_RX 8 +#define MSM_QUIN_MI2S_TX 9 +#define MSM_SENARY_MI2S_RX 10 +#define MSM_SENARY_MI2S_TX 11 +#define MSM_SEC_MI2S_SD1 12 +#define MSM_INT0_MI2S_RX 13 +#define MSM_INT0_MI2S_TX 14 +#define MSM_INT1_MI2S_RX 15 +#define MSM_INT1_MI2S_TX 16 +#define MSM_INT2_MI2S_RX 17 +#define MSM_INT2_MI2S_TX 18 +#define MSM_INT3_MI2S_RX 19 +#define MSM_INT3_MI2S_TX 20 +#define MSM_INT4_MI2S_RX 21 +#define MSM_INT4_MI2S_TX 22 +#define MSM_INT5_MI2S_RX 23 +#define MSM_INT5_MI2S_TX 24 +#define MSM_INT6_MI2S_RX 25 +#define MSM_INT6_MI2S_TX 26 +#define MSM_MI2S_MIN MSM_PRIM_MI2S_RX +#define MSM_MI2S_MAX MSM_INT6_MI2S_TX #define MSM_DISPLAY_PORT 0 #define MSM_DISPLAY_PORT1 1 @@ -60,8 +73,7 @@ struct msm_dai_auxpcm_pdata { }; struct msm_mi2s_pdata { - u16 rx_sd_lines; - u16 tx_sd_lines; + u16 sd_lines; u16 intf_id; }; From 4da866e6de7e7d9d9aefa17dcb6037db89d3c1d8 Mon Sep 17 00:00:00 2001 From: Aditya Bavanari Date: Thu, 15 Jul 2021 12:18:19 +0530 Subject: [PATCH 02/82] asoc: Update the dai link IDs for MI2S dai links DAI IDs are updated for MI2S dai links to use separate cpu dai IDs for Rx and Tx dais. Make respective changes in the machine driver and dai link header files. Change-Id: I9bb114f1dabb954720316dd7b0522c282361e4d5 Signed-off-by: Aditya Bavanari --- asoc/bengal.c | 31 +++++++++++++++++-------------- asoc/holi.c | 36 ++++++++++++++++++++---------------- asoc/kona.c | 36 ++++++++++++++++++++---------------- asoc/lahaina.c | 36 ++++++++++++++++++++---------------- asoc/msm_dailink.h | 22 +++++++++++----------- asoc/msm_holi_dailink.h | 16 ++++++++-------- asoc/qcs405.c | 34 +++++++++++++++++----------------- asoc/sa6155.c | 32 +++++++++++++++++--------------- asoc/sa8155.c | 32 +++++++++++++++++--------------- asoc/sm6150.c | 33 ++++++++++++++++++--------------- asoc/sm8150.c | 33 ++++++++++++++++++--------------- 11 files changed, 183 insertions(+), 158 deletions(-) diff --git a/asoc/bengal.c b/asoc/bengal.c index 42eeade28882..70dfc9251bd2 100644 --- a/asoc/bengal.c +++ b/asoc/bengal.c @@ -2098,7 +2098,8 @@ static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int port_id = 0; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; port_id = msm_get_port_id(rtd->dai_link->id); if (port_id < 0) { @@ -3931,7 +3932,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); @@ -3955,11 +3957,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) */ mutex_lock(&mi2s_intf_conf[index].lock); if (++mi2s_intf_conf[index].ref_cnt == 1) { - /* Check if msm needs to provide the clock to the interface */ - if (!mi2s_intf_conf[index].msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; - fmt = SND_SOC_DAIFMT_CBM_CFM; - } ret = msm_mi2s_set_sclk(substream, true); if (ret < 0) { dev_err(rtd->card->dev, @@ -3968,12 +3965,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) goto clean_up; } - ret = snd_soc_dai_set_fmt(cpu_dai, fmt); - if (ret < 0) { - pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", - __func__, index, ret); - goto clk_off; - } if (pdata->mi2s_gpio_p[index]) { if (atomic_read(&(pdata->mi2s_gpio_ref_count[index])) == 0) { @@ -3988,6 +3979,17 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) atomic_inc(&(pdata->mi2s_gpio_ref_count[index])); } } + /* Check if msm needs to provide the clock to the interface */ + if (!mi2s_intf_conf[index].msm_is_mi2s_master) { + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + fmt = SND_SOC_DAIFMT_CBM_CFM; + } + ret = snd_soc_dai_set_fmt(cpu_dai, fmt); + if (ret < 0) { + pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", + __func__, index, ret); + goto clk_off; + } clk_off: if (ret < 0) msm_mi2s_set_sclk(substream, false); @@ -4003,7 +4005,8 @@ static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream) { int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; - int index = rtd->cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (rtd->cpu_dai->id) / 2; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); diff --git a/asoc/holi.c b/asoc/holi.c index a12c74dbbff5..c364512af581 100644 --- a/asoc/holi.c +++ b/asoc/holi.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. */ #include @@ -2432,7 +2432,8 @@ static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int port_id = 0; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; port_id = msm_get_port_id(rtd->dai_link->id); if (port_id < 0) { @@ -4369,7 +4370,8 @@ void mi2s_disable_audio_vote(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); int sample_rate = 0; @@ -4403,7 +4405,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); @@ -4456,11 +4459,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) } if (++mi2s_intf_conf[index].ref_cnt == 1) { - /* Check if msm needs to provide the clock to the interface */ - if (!mi2s_intf_conf[index].msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; - fmt = SND_SOC_DAIFMT_CBM_CFM; - } ret = msm_mi2s_set_sclk(substream, true); if (ret < 0) { dev_err(rtd->card->dev, @@ -4469,12 +4467,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) goto clean_up; } - ret = snd_soc_dai_set_fmt(cpu_dai, fmt); - if (ret < 0) { - pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", - __func__, index, ret); - goto clk_off; - } if (pdata->mi2s_gpio_p[index]) { if (atomic_read(&(pdata->mi2s_gpio_ref_count[index])) == 0) { @@ -4489,6 +4481,17 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) atomic_inc(&(pdata->mi2s_gpio_ref_count[index])); } } + /* Check if msm needs to provide the clock to the interface */ + if (!mi2s_intf_conf[index].msm_is_mi2s_master) { + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + fmt = SND_SOC_DAIFMT_CBM_CFM; + } + ret = snd_soc_dai_set_fmt(cpu_dai, fmt); + if (ret < 0) { + pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", + __func__, index, ret); + goto clk_off; + } clk_off: if (ret < 0) msm_mi2s_set_sclk(substream, false); @@ -4507,7 +4510,8 @@ static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream) { int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; - int index = rtd->cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (rtd->cpu_dai->id) / 2; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); diff --git a/asoc/kona.c b/asoc/kona.c index f89a9e39b7e3..67deb67b15c7 100644 --- a/asoc/kona.c +++ b/asoc/kona.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. */ #include @@ -2750,7 +2750,8 @@ static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int port_id = 0; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; port_id = msm_get_port_id(rtd->dai_link->id); if (port_id < 0) { @@ -5010,7 +5011,8 @@ void mi2s_disable_audio_vote(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); int sample_rate = 0; @@ -5044,7 +5046,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); @@ -5097,11 +5100,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) } if (++mi2s_intf_conf[index].ref_cnt == 1) { - /* Check if msm needs to provide the clock to the interface */ - if (!mi2s_intf_conf[index].msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; - fmt = SND_SOC_DAIFMT_CBM_CFM; - } ret = msm_mi2s_set_sclk(substream, true); if (ret < 0) { dev_err(rtd->card->dev, @@ -5110,12 +5108,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) goto clean_up; } - ret = snd_soc_dai_set_fmt(cpu_dai, fmt); - if (ret < 0) { - pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", - __func__, index, ret); - goto clk_off; - } if (pdata->mi2s_gpio_p[index]) { if (atomic_read(&(pdata->mi2s_gpio_ref_count[index])) == 0) { @@ -5130,6 +5122,17 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) atomic_inc(&(pdata->mi2s_gpio_ref_count[index])); } } + /* Check if msm needs to provide the clock to the interface */ + if (!mi2s_intf_conf[index].msm_is_mi2s_master) { + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + fmt = SND_SOC_DAIFMT_CBM_CFM; + } + ret = snd_soc_dai_set_fmt(cpu_dai, fmt); + if (ret < 0) { + pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", + __func__, index, ret); + goto clk_off; + } clk_off: if (ret < 0) msm_mi2s_set_sclk(substream, false); @@ -5148,7 +5151,8 @@ static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream) { int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; - int index = rtd->cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (rtd->cpu_dai->id) / 2; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); diff --git a/asoc/lahaina.c b/asoc/lahaina.c index fe823e5e5a3f..5805f93ea2dc 100644 --- a/asoc/lahaina.c +++ b/asoc/lahaina.c @@ -2874,7 +2874,8 @@ static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int port_id = 0; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; port_id = msm_get_port_id(rtd->dai_link->id); if (port_id < 0) { @@ -5323,7 +5324,8 @@ void mi2s_disable_audio_vote(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); int sample_rate = 0; @@ -5359,7 +5361,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); @@ -5418,12 +5421,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) mi2s_intf_conf[index].audio_core_vote = true; } - /* Check if msm needs to provide the clock to the interface */ - if (!mi2s_intf_conf[index].msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; - fmt = SND_SOC_DAIFMT_CBM_CFM; - } - mi2s_clk[index].clk_freq_in_hz = (sample_rate * MI2S_NUM_CHANNELS * bit_per_sample); dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__, @@ -5437,12 +5434,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) goto clean_up; } - ret = snd_soc_dai_set_fmt(cpu_dai, fmt); - if (ret < 0) { - pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", - __func__, index, ret); - goto clk_off; - } if (pdata->mi2s_gpio_p[index]) { if (atomic_read(&(pdata->mi2s_gpio_ref_count[index])) == 0) { @@ -5457,6 +5448,18 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) atomic_inc(&(pdata->mi2s_gpio_ref_count[index])); } } + /* Check if msm needs to provide the clock to the interface */ + if (!mi2s_intf_conf[index].msm_is_mi2s_master) { + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + fmt = SND_SOC_DAIFMT_CBM_CFM; + } + ret = snd_soc_dai_set_fmt(cpu_dai, fmt); + if (ret < 0) { + pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", + __func__, index, ret); + goto clk_off; + } + clk_off: if (ret < 0) msm_mi2s_set_sclk(substream, false); @@ -5475,7 +5478,8 @@ static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream) { int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; - int index = rtd->cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (rtd->cpu_dai->id) / 2; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); diff --git a/asoc/msm_dailink.h b/asoc/msm_dailink.h index 2bf34161946d..1b0b365592c5 100644 --- a/asoc/msm_dailink.h +++ b/asoc/msm_dailink.h @@ -920,57 +920,57 @@ SND_SOC_DAILINK_DEFS(pri_mi2s_rx, DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(pri_mi2s_tx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.0")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.1")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(sec_mi2s_rx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.1")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.2")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(sec_mi2s_tx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.1")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.3")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(tert_mi2s_rx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.2")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.4")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(tert_mi2s_tx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.2")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.5")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(quat_mi2s_rx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.3")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.6")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(quat_mi2s_tx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.3")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.7")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(quin_mi2s_rx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.4")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.8")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(quin_mi2s_tx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.4")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.9")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(sen_mi2s_rx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.5")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.10")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(sen_mi2s_tx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.5")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.11")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); diff --git a/asoc/msm_holi_dailink.h b/asoc/msm_holi_dailink.h index 513a745f259d..b4707283c052 100644 --- a/asoc/msm_holi_dailink.h +++ b/asoc/msm_holi_dailink.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. */ #include @@ -322,37 +322,37 @@ SND_SOC_DAILINK_DEFS(pri_mi2s_rx, DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(pri_mi2s_tx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.0")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.1")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(sec_mi2s_rx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.1")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.2")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(sec_mi2s_tx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.1")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.3")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(tert_mi2s_rx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.2")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.4")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(tert_mi2s_tx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.2")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.5")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(quat_mi2s_rx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.3")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.6")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(quat_mi2s_tx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.3")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.7")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); diff --git a/asoc/qcs405.c b/asoc/qcs405.c index b43d9a21295f..ce8540bd15b7 100644 --- a/asoc/qcs405.c +++ b/asoc/qcs405.c @@ -6607,7 +6607,8 @@ static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int port_id = 0; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; port_id = msm_get_port_id(rtd->dai_link->id); if (port_id < 0) { @@ -7031,7 +7032,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai_link *dai_link = rtd->dai_link; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); @@ -7061,12 +7063,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) */ mutex_lock(&mi2s_intf_conf[index].lock); if (++mi2s_intf_conf[index].ref_cnt == 1) { - /* Check if msm needs to provide the clock to the interface */ - if (!mi2s_intf_conf[index].msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; - fmt = SND_SOC_DAIFMT_CBM_CFM; - } - if (data_format == AFE_DSD_DATA) fmt = SND_SOC_DAIFMT_CBM_CFS; ret = msm_mi2s_set_sclk(substream, true); @@ -7077,13 +7073,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) goto clean_up; } - ret = snd_soc_dai_set_fmt(cpu_dai, fmt); - if (ret < 0) { - pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", - __func__, index, ret); - goto clk_off; - } - if (pdata->mi2s_gpio_p[index]) { if ((data_format == AFE_DSD_DATA) && ((index == QUAT_MI2S) || @@ -7112,7 +7101,17 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) } } } - + /* Check if msm needs to provide the clock to the interface */ + if (!mi2s_intf_conf[index].msm_is_mi2s_master) { + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + fmt = SND_SOC_DAIFMT_CBM_CFM; + } + ret = snd_soc_dai_set_fmt(cpu_dai, fmt); + if (ret < 0) { + pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", + __func__, index, ret); + goto clk_off; + } ret = qcs405_send_island_vad_config(dai_link->id); if (ret) { pr_err("%s: send island/vad cfg failed, err = %d\n", @@ -7167,7 +7166,8 @@ static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream) int val; int data_format; struct snd_soc_pcm_runtime *rtd = substream->private_data; - int index = rtd->cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (rtd->cpu_dai->id) / 2; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); diff --git a/asoc/sa6155.c b/asoc/sa6155.c index 2d182ff52e5c..3d4b04017cda 100755 --- a/asoc/sa6155.c +++ b/asoc/sa6155.c @@ -3769,7 +3769,8 @@ static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int port_id = 0; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; port_id = msm_get_port_id(rtd->dai_link->id); if (port_id < 0) { @@ -4999,7 +5000,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); @@ -5027,11 +5029,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) intf_conf = &pdata->mi2s_intf_conf[index]; mutex_lock(&intf_conf->lock); if (++intf_conf->ref_cnt == 1) { - /* Check if msm needs to provide the clock to the interface */ - if (!intf_conf->msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; - fmt = SND_SOC_DAIFMT_CBM_CFM; - } ret = msm_mi2s_set_sclk(substream, true); if (ret < 0) { dev_err(rtd->card->dev, @@ -5040,13 +5037,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) goto clean_up; } - ret = snd_soc_dai_set_fmt(cpu_dai, fmt); - if (ret < 0) { - pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", - __func__, index, ret); - goto clk_off; - } - pinctrl_info = &pdata->pinctrl_info[index]; if (pinctrl_info->pinctrl) { ret_pinctrl = msm_set_pinctrl(pinctrl_info, @@ -5056,6 +5046,17 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) __func__, ret_pinctrl); } } + /* Check if msm needs to provide the clock to the interface */ + if (!intf_conf->msm_is_mi2s_master) { + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + fmt = SND_SOC_DAIFMT_CBM_CFM; + } + ret = snd_soc_dai_set_fmt(cpu_dai, fmt); + if (ret < 0) { + pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", + __func__, index, ret); + goto clk_off; + } clk_off: if (ret < 0) msm_mi2s_set_sclk(substream, false); @@ -5071,7 +5072,8 @@ static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream) { int ret; struct snd_soc_pcm_runtime *rtd = substream->private_data; - int index = rtd->cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (rtd->cpu_dai->id) / 2; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); struct msm_pinctrl_info *pinctrl_info = NULL; diff --git a/asoc/sa8155.c b/asoc/sa8155.c index c28fe737d5b0..ab3e2ae84c10 100644 --- a/asoc/sa8155.c +++ b/asoc/sa8155.c @@ -5008,7 +5008,8 @@ static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int port_id = 0; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; port_id = msm_get_port_id(rtd->dai_link->id); if (port_id < 0) { @@ -7290,7 +7291,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); @@ -7318,11 +7320,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) intf_conf = &pdata->mi2s_intf_conf[index]; mutex_lock(&intf_conf->lock); if (++intf_conf->ref_cnt == 1) { - /* Check if msm needs to provide the clock to the interface */ - if (!intf_conf->msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; - fmt = SND_SOC_DAIFMT_CBM_CFM; - } ret = msm_mi2s_set_sclk(substream, true); if (ret < 0) { dev_err(rtd->card->dev, @@ -7331,13 +7328,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) goto clean_up; } - ret = snd_soc_dai_set_fmt(cpu_dai, fmt); - if (ret < 0) { - pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", - __func__, index, ret); - goto clk_off; - } - pinctrl_info = &pdata->pinctrl_info[index]; if (pinctrl_info->pinctrl) { ret_pinctrl = msm_set_pinctrl(pinctrl_info, @@ -7347,6 +7337,17 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) __func__, ret_pinctrl); } } + /* Check if msm needs to provide the clock to the interface */ + if (!intf_conf->msm_is_mi2s_master) { + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + fmt = SND_SOC_DAIFMT_CBM_CFM; + } + ret = snd_soc_dai_set_fmt(cpu_dai, fmt); + if (ret < 0) { + pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", + __func__, index, ret); + goto clk_off; + } clk_off: if (ret < 0) msm_mi2s_set_sclk(substream, false); @@ -7362,7 +7363,8 @@ static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream) { int ret; struct snd_soc_pcm_runtime *rtd = substream->private_data; - int index = rtd->cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (rtd->cpu_dai->id) / 2; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); struct msm_pinctrl_info *pinctrl_info = NULL; diff --git a/asoc/sm6150.c b/asoc/sm6150.c index d9c0eae55590..e4763d81f099 100644 --- a/asoc/sm6150.c +++ b/asoc/sm6150.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2018-2019, 2021 The Linux Foundation. All rights reserved. */ #include @@ -5622,7 +5622,8 @@ static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int port_id = 0; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; port_id = msm_get_port_id(rtd->dai_link->id); if (port_id < 0) { @@ -5875,7 +5876,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; int port_id = msm_get_port_id(rtd->dai_link->id); unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS; struct snd_soc_card *card = rtd->card; @@ -5906,11 +5908,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) */ mutex_lock(&mi2s_intf_conf[index].lock); if (++mi2s_intf_conf[index].ref_cnt == 1) { - /* Check if msm needs to provide the clock to the interface */ - if (!mi2s_intf_conf[index].msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; - fmt = SND_SOC_DAIFMT_CBM_CFM; - } ret = msm_mi2s_set_sclk(substream, true); if (ret < 0) { dev_err(rtd->card->dev, @@ -5919,12 +5916,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) goto clean_up; } - ret = snd_soc_dai_set_fmt(cpu_dai, fmt); - if (ret < 0) { - pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", - __func__, index, ret); - goto clk_off; - } if (mi2s_intf_conf[index].msm_is_ext_mclk) { pr_debug("%s: Enabling mclk, clk_freq_in_hz = %u\n", __func__, mi2s_mclk[index].clk_freq_in_hz); @@ -5941,6 +5932,17 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) msm_cdc_pinctrl_select_active_state( pdata->mi2s_gpio_p[index]); } + /* Check if msm needs to provide the clock to the interface */ + if (!mi2s_intf_conf[index].msm_is_mi2s_master) { + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + fmt = SND_SOC_DAIFMT_CBM_CFM; + } + ret = snd_soc_dai_set_fmt(cpu_dai, fmt); + if (ret < 0) { + pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", + __func__, index, ret); + goto clk_off; + } clk_off: if (ret < 0) msm_mi2s_set_sclk(substream, false); @@ -5956,7 +5958,8 @@ static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream) { int ret; struct snd_soc_pcm_runtime *rtd = substream->private_data; - int index = rtd->cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (rtd->cpu_dai->id) / 2; int port_id = msm_get_port_id(rtd->dai_link->id); struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); diff --git a/asoc/sm8150.c b/asoc/sm8150.c index 3b95ce553233..ccfe38cdf042 100644 --- a/asoc/sm8150.c +++ b/asoc/sm8150.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. +/* Copyright (c) 2016-2019, 2021, The Linux Foundation. All rights reserved. */ #include @@ -4404,7 +4404,8 @@ static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int port_id = 0; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; port_id = msm_get_port_id(rtd->dai_link->id); if (port_id < 0) { @@ -4824,7 +4825,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); @@ -4850,11 +4852,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) */ mutex_lock(&mi2s_intf_conf[index].lock); if (++mi2s_intf_conf[index].ref_cnt == 1) { - /* Check if msm needs to provide the clock to the interface */ - if (!mi2s_intf_conf[index].msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; - fmt = SND_SOC_DAIFMT_CBM_CFM; - } ret = msm_mi2s_set_sclk(substream, true); if (ret < 0) { dev_err(rtd->card->dev, @@ -4863,12 +4860,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) goto clean_up; } - ret = snd_soc_dai_set_fmt(cpu_dai, fmt); - if (ret < 0) { - pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", - __func__, index, ret); - goto clk_off; - } if (index == QUAT_MI2S) { ret_pinctrl = msm_set_pinctrl(pinctrl_info, STATE_MI2S_ACTIVE); @@ -4877,6 +4868,17 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) __func__, ret_pinctrl); } } + /* Check if msm needs to provide the clock to the interface */ + if (!mi2s_intf_conf[index].msm_is_mi2s_master) { + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + fmt = SND_SOC_DAIFMT_CBM_CFM; + } + ret = snd_soc_dai_set_fmt(cpu_dai, fmt); + if (ret < 0) { + pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", + __func__, index, ret); + goto clk_off; + } clk_off: if (ret < 0) msm_mi2s_set_sclk(substream, false); @@ -4892,7 +4894,8 @@ static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream) { int ret; struct snd_soc_pcm_runtime *rtd = substream->private_data; - int index = rtd->cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (rtd->cpu_dai->id) / 2; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); struct msm_pinctrl_info *pinctrl_info = &pdata->pinctrl_info; From 5a27b32cb634613225c78038dc4cce0452ac9fa5 Mon Sep 17 00:00:00 2001 From: Hexuan Zhu Date: Tue, 14 Sep 2021 11:34:11 +0800 Subject: [PATCH 03/82] config: fix compile issue We need to make autogvm-gki-llvm-64 compile well for scan. Change in gvmauto.conf is to fix compile issue by skipping some files. Change in sa6155conf in to fix compile issue after move to techpack. Change-Id: I9d30b0e3160dcf87d8d455e7e2a812f03537bcab Signed-off-by: Hexuan Zhu --- config/gvmauto.conf | 5 +++++ include/soc/internal.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) mode change 100755 => 100644 config/gvmauto.conf diff --git a/config/gvmauto.conf b/config/gvmauto.conf old mode 100755 new mode 100644 index a29d2538cbcb..1cdc7b30eddb --- a/config/gvmauto.conf +++ b/config/gvmauto.conf @@ -1,3 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (c) 2021, The Linux Foundation. All rights reserved. + +ifeq ($(CONFIG_QGKI), y) export CONFIG_SND_SOC_GVM_AUTO_SPF=m export CONFIG_MSM_QDSP6_APRV2_VM=m export CONFIG_MSM_QDSP6_SSR=m @@ -15,3 +19,4 @@ export CONFIG_SND_SOC_MSM_HDMI_CODEC_RX=m export CONFIG_MSM_QDSP6V2_CODECS=m export CONFIG_SND_EVENT=m export CONFIG_SND_SOC_SA8155=m +endif \ No newline at end of file diff --git a/include/soc/internal.h b/include/soc/internal.h index 4b7332cb9758..2bc065526db0 120000 --- a/include/soc/internal.h +++ b/include/soc/internal.h @@ -1 +1 @@ -../../../../../../kernel/msm-5.4/drivers/base/regmap/internal.h \ No newline at end of file +../../../../drivers/base/regmap/internal.h \ No newline at end of file From ff8d8d42701126cf776de2a011e84dc75787bbb9 Mon Sep 17 00:00:00 2001 From: Jinjuan Qiu Date: Thu, 9 Sep 2021 16:27:06 +0800 Subject: [PATCH 04/82] dsp: bugfix for memory leak in error handling path Add extra goto label in order to free memory in case program failed to acquire memory through callback_node. With the original code, there might be a situation where the memory acquired by client_info_node will not be freed, thus causing possible memory leak. Change-Id: If5c8a4bdfbed4ada57a7563e9e212dc9aa7caab0 Signed-off-by: Jinjuan Qiu --- dsp/audio_calibration.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) mode change 100755 => 100644 dsp/audio_calibration.c diff --git a/dsp/audio_calibration.c b/dsp/audio_calibration.c old mode 100755 new mode 100644 index c2fb702fbde3..c4ab399a38af --- a/dsp/audio_calibration.c +++ b/dsp/audio_calibration.c @@ -148,7 +148,7 @@ int audio_cal_register(int num_cal_types, GFP_KERNEL); if (callback_node == NULL) { ret = -ENOMEM; - goto err; + goto err_callback_node; } memcpy(callback_node, ®_data[i].callbacks, @@ -160,10 +160,13 @@ int audio_cal_register(int num_cal_types, &audio_cal.client_info[reg_data[i].cal_type]); mutex_unlock(&audio_cal.cal_mutex[reg_data[i].cal_type]); } -done: - return ret; + goto done; + +err_callback_node: + kfree(client_info_node); err: audio_cal_deregister(num_cal_types, reg_data); +done: return ret; } From 117a5dd6ad8b95a0c8639c9b656eb0ef6eb5c086 Mon Sep 17 00:00:00 2001 From: Deru Wang Date: Fri, 30 Oct 2020 19:23:31 +0800 Subject: [PATCH 05/82] asoc: set min period size of capture/playback to 120 sound card open failed for capture with 128 16-bit samples at 24 kHz because min period size of cupture is set to 320. Change-Id: Ida818ef133e6ac6e282c798559a753618b1d1e28 Signed-off-by: Deru Wang --- asoc/msm-pcm-q6-v2.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/asoc/msm-pcm-q6-v2.h b/asoc/msm-pcm-q6-v2.h index 979b36000aa7..3acb3b2df87e 100644 --- a/asoc/msm-pcm-q6-v2.h +++ b/asoc/msm-pcm-q6-v2.h @@ -49,11 +49,11 @@ struct msm_audio_in_frame_info { #define PLAYBACK_MIN_NUM_PERIODS 2 #define PLAYBACK_MAX_NUM_PERIODS 8 #define PLAYBACK_MAX_PERIOD_SIZE 122880 -#define PLAYBACK_MIN_PERIOD_SIZE 128 +#define PLAYBACK_MIN_PERIOD_SIZE 120 #define CAPTURE_MIN_NUM_PERIODS 2 #define CAPTURE_MAX_NUM_PERIODS 8 #define CAPTURE_MAX_PERIOD_SIZE 122880 -#define CAPTURE_MIN_PERIOD_SIZE 320 +#define CAPTURE_MIN_PERIOD_SIZE 120 struct msm_audio { struct snd_pcm_substream *substream; From 5d529a275197b88c80a6bb656de04d5c50161dd2 Mon Sep 17 00:00:00 2001 From: Vatsal Bucha Date: Thu, 23 Sep 2021 17:31:27 +0530 Subject: [PATCH 06/82] ASoC: Add proper routing for vi ch and cdc dma format widgets Add proper routing for vi ch and cdc dma format widgets when speaker protection is enabled. Change-Id: I7d6643dc8737bf6de3c14843ab6994ac8ccaf831 Signed-off-by: Vatsal Bucha --- asoc/msm-dai-q6-v2.c | 9 +++++++-- asoc/msm-pcm-routing-v2.c | 41 +++++++++++++++++++++------------------ 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/asoc/msm-dai-q6-v2.c b/asoc/msm-dai-q6-v2.c index 43f67953d10c..53c2164accf3 100755 --- a/asoc/msm-dai-q6-v2.c +++ b/asoc/msm-dai-q6-v2.c @@ -427,11 +427,16 @@ static const struct soc_enum mi2s_config_enum[] = { static const char *const cdc_dma_format[] = { "UNPACKED", - "PACKED_16B", + "UNPACKED_NON_LINEAR", + "PACKED_LINEAR_60958", + "PACKED_NON_LINEAR_60958", + "NULL", + "NULL", + "PACKED_16B", }; static const struct soc_enum cdc_dma_config_enum[] = { - SOC_ENUM_SINGLE_EXT(2, cdc_dma_format), + SOC_ENUM_SINGLE_EXT(7, cdc_dma_format), }; static const char *const sb_format[] = { diff --git a/asoc/msm-pcm-routing-v2.c b/asoc/msm-pcm-routing-v2.c index 11e9d742cf85..f20d9124fb6e 100755 --- a/asoc/msm-pcm-routing-v2.c +++ b/asoc/msm-pcm-routing-v2.c @@ -83,6 +83,8 @@ static uint16_t msm_ec_ref_ch_weights[PCM_FORMAT_MAX_NUM_CHANNEL_V8] [PCM_FORMAT_MAX_NUM_CHANNEL_V8]; static uint32_t voc_session_id = ALL_SESSION_VSID; +static int vi_lch_port; +static int vi_rch_port; static int msm_route_ext_ec_ref; static bool is_custom_stereo_on; static bool is_ds2_on; @@ -32454,33 +32456,33 @@ static int spkr_prot_put_vi_lch_port(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int ret = 0; - int item; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; pr_debug("%s item is %d\n", __func__, ucontrol->value.enumerated.item[0]); mutex_lock(&routing_lock); - item = ucontrol->value.enumerated.item[0]; - if (item < e->items) { + vi_lch_port = ucontrol->value.enumerated.item[0]; + if (vi_lch_port < e->items) { pr_debug("%s RX DAI ID %d TX DAI id %d\n", - __func__, e->shift_l, e->values[item]); + __func__, e->shift_l, e->values[vi_lch_port]); if (e->shift_l < MSM_BACKEND_DAI_MAX && - e->values[item] < MSM_BACKEND_DAI_MAX) + e->values[vi_lch_port] < MSM_BACKEND_DAI_MAX) /* Enable feedback TX path */ ret = afe_spk_prot_feed_back_cfg( - msm_bedais[e->values[item]].port_id, + msm_bedais[e->values[vi_lch_port]].port_id, msm_bedais[e->shift_l].port_id, 1, 0, 1); else { pr_debug("%s values are out of range item %d\n", - __func__, e->values[item]); + __func__, e->values[vi_lch_port]); /* Disable feedback TX path */ - if (e->values[item] == MSM_BACKEND_DAI_MAX) + if (e->values[vi_lch_port] == MSM_BACKEND_DAI_MAX) ret = afe_spk_prot_feed_back_cfg(0, 0, 0, 0, 0); else ret = -EINVAL; } } else { - pr_err("%s item value is out of range item\n", __func__); + pr_err("%s item value is out of range items = %d\n", __func__, + vi_lch_port); ret = -EINVAL; } mutex_unlock(&routing_lock); @@ -32491,35 +32493,35 @@ static int spkr_prot_put_vi_rch_port(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int ret = 0; - int item; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; pr_debug("%s item is %d\n", __func__, ucontrol->value.enumerated.item[0]); mutex_lock(&routing_lock); - item = ucontrol->value.enumerated.item[0]; - if (item < e->items) { + vi_rch_port = ucontrol->value.enumerated.item[0]; + if (vi_rch_port < e->items) { pr_debug("%s RX DAI ID %d TX DAI id %d\n", - __func__, e->shift_l, e->values[item]); + __func__, e->shift_l, e->values[vi_rch_port]); if (e->shift_l < MSM_BACKEND_DAI_MAX && - e->values[item] < MSM_BACKEND_DAI_MAX) + e->values[vi_rch_port] < MSM_BACKEND_DAI_MAX) /* Enable feedback TX path */ ret = afe_spk_prot_feed_back_cfg( - msm_bedais[e->values[item]].port_id, + msm_bedais[e->values[vi_rch_port]].port_id, msm_bedais[e->shift_l].port_id, 1, 1, 1); else { pr_debug("%s values are out of range item %d\n", - __func__, e->values[item]); + __func__, e->values[vi_rch_port]); /* Disable feedback TX path */ - if (e->values[item] == MSM_BACKEND_DAI_MAX) + if (e->values[vi_rch_port] == MSM_BACKEND_DAI_MAX) ret = afe_spk_prot_feed_back_cfg(0, 0, 0, 0, 0); else ret = -EINVAL; } } else { - pr_err("%s item value is out of range item\n", __func__); + pr_err("%s item value is out of range items = %d\n", __func__, + vi_rch_port); ret = -EINVAL; } mutex_unlock(&routing_lock); @@ -32529,6 +32531,7 @@ static int spkr_prot_put_vi_rch_port(struct snd_kcontrol *kcontrol, static int spkr_prot_get_vi_lch_port(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { + ucontrol->value.enumerated.item[0] = vi_lch_port; pr_debug("%s\n", __func__); return 0; } @@ -32537,7 +32540,7 @@ static int spkr_prot_get_vi_rch_port(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { pr_debug("%s\n", __func__); - ucontrol->value.enumerated.item[0] = 0; + ucontrol->value.enumerated.item[0] = vi_rch_port; return 0; } From c9488733602d0174ec608241b080468bd5ee0578 Mon Sep 17 00:00:00 2001 From: Vatsal Bucha Date: Sun, 26 Sep 2021 22:28:21 -0700 Subject: [PATCH 07/82] Revert "ASoC: wsa883x: Add check before enable/disable PDM WD irq" This reverts commit 8553f349c094349a7b2f7577aac6885c0feaee21. With check to enable/disable PDM WD, watchdog irq was never enabled. Thus remove the check. Change-Id: I6845b9aef5fe6c06afe2a2928b4071dd6c71ca00 Signed-off-by: Vatsal Bucha --- asoc/codecs/wsa883x/wsa883x.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/asoc/codecs/wsa883x/wsa883x.c b/asoc/codecs/wsa883x/wsa883x.c index 13874ca50421..f68eee190533 100644 --- a/asoc/codecs/wsa883x/wsa883x.c +++ b/asoc/codecs/wsa883x/wsa883x.c @@ -1076,7 +1076,6 @@ static int wsa883x_spkr_event(struct snd_soc_dapm_widget *w, struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); struct wsa883x_priv *wsa883x = snd_soc_component_get_drvdata(component); - struct irq_data *irq_data = NULL; dev_dbg(component->dev, "%s: %s %d\n", __func__, w->name, event); switch (event) { @@ -1140,12 +1139,9 @@ static int wsa883x_spkr_event(struct snd_soc_dapm_widget *w, WSA883X_PA_FSM_CTL, 0x01, 0x01); break; case SND_SOC_DAPM_PRE_PMD: - if (!test_bit(SPKR_ADIE_LB, &wsa883x->status_mask)) { - irq_data = irq_get_irq_data(WSA883X_IRQ_INT_PDM_WD); - if (irq_data && !irqd_irq_disabled(irq_data)) - wcd_disable_irq(&wsa883x->irq_info, - WSA883X_IRQ_INT_PDM_WD); - } + if (!test_bit(SPKR_ADIE_LB, &wsa883x->status_mask)) + wcd_disable_irq(&wsa883x->irq_info, + WSA883X_IRQ_INT_PDM_WD); snd_soc_component_update_bits(component, WSA883X_VBAT_ADC_FLT_CTL, 0x01, 0x00); @@ -1517,7 +1513,6 @@ static int wsa883x_event_notify(struct notifier_block *nb, u16 event = (val & 0xffff); struct wsa883x_priv *wsa883x = container_of(nb, struct wsa883x_priv, parent_nblock); - struct irq_data *irq_data = NULL; if (!wsa883x) return -EINVAL; @@ -1546,10 +1541,8 @@ static int wsa883x_event_notify(struct notifier_block *nb, snd_soc_component_update_bits(wsa883x->component, WSA883X_PA_FSM_CTL, 0x01, 0x01); - irq_data = irq_get_irq_data(WSA883X_IRQ_INT_PDM_WD); - if (irq_data && irqd_irq_disabled(irq_data)) - wcd_enable_irq(&wsa883x->irq_info, - WSA883X_IRQ_INT_PDM_WD); + wcd_enable_irq(&wsa883x->irq_info, + WSA883X_IRQ_INT_PDM_WD); /* Added delay as per HW sequence */ usleep_range(3000, 3100); snd_soc_component_update_bits(wsa883x->component, From 09029330103e9e116c063c48dd14916102103ff6 Mon Sep 17 00:00:00 2001 From: Vatsal Bucha Date: Thu, 23 Sep 2021 16:54:44 +0530 Subject: [PATCH 08/82] ASoC: wcd937x: Add change to micbias reg for new tanggu fab id Add change to micbias reg for new tanggu fab id. Change-Id: I9bfa54c6ee3b87db56e72c1fefb4d4f0db461f14 Signed-off-by: Vatsal Bucha --- asoc/codecs/wcd937x/wcd937x.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/asoc/codecs/wcd937x/wcd937x.c b/asoc/codecs/wcd937x/wcd937x.c index 37cf1fd9c64f..34738d74c212 100644 --- a/asoc/codecs/wcd937x/wcd937x.c +++ b/asoc/codecs/wcd937x/wcd937x.c @@ -178,6 +178,12 @@ static int wcd937x_init_reg(struct snd_soc_component *component) 0xFF, 0xFA); snd_soc_component_update_bits(component, WCD937X_MICB3_TEST_CTL_1, 0xFF, 0xFA); + snd_soc_component_update_bits(component, WCD937X_MICB1_TEST_CTL_2, + 0x38, 0x00); + snd_soc_component_update_bits(component, WCD937X_MICB2_TEST_CTL_2, + 0x38, 0x00); + snd_soc_component_update_bits(component, WCD937X_MICB3_TEST_CTL_2, + 0x38, 0x00); /* Set Bandgap Fine Adjustment to +5mV for Tanggu SMIC part */ if (snd_soc_component_read32(component, WCD937X_DIGITAL_EFUSE_REG_16) == 0x01) { From 7ebd7201308af4518b9ecc24ca6f7d9019f93313 Mon Sep 17 00:00:00 2001 From: Vatsal Bucha Date: Wed, 15 Sep 2021 12:13:44 +0530 Subject: [PATCH 09/82] ASoC: wcd937x: Update register value for new fab id for tanggu Improve HPH ULP mode SNDR stability for new tanggu fab id. Change-Id: I13594dbd311bbeab115753e0bec1a748158f8100 Signed-off-by: Vatsal Bucha --- asoc/codecs/wcd937x/wcd937x.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/asoc/codecs/wcd937x/wcd937x.c b/asoc/codecs/wcd937x/wcd937x.c index 34738d74c212..98b5d3d11e89 100644 --- a/asoc/codecs/wcd937x/wcd937x.c +++ b/asoc/codecs/wcd937x/wcd937x.c @@ -178,12 +178,6 @@ static int wcd937x_init_reg(struct snd_soc_component *component) 0xFF, 0xFA); snd_soc_component_update_bits(component, WCD937X_MICB3_TEST_CTL_1, 0xFF, 0xFA); - snd_soc_component_update_bits(component, WCD937X_MICB1_TEST_CTL_2, - 0x38, 0x00); - snd_soc_component_update_bits(component, WCD937X_MICB2_TEST_CTL_2, - 0x38, 0x00); - snd_soc_component_update_bits(component, WCD937X_MICB3_TEST_CTL_2, - 0x38, 0x00); /* Set Bandgap Fine Adjustment to +5mV for Tanggu SMIC part */ if (snd_soc_component_read32(component, WCD937X_DIGITAL_EFUSE_REG_16) == 0x01) { @@ -195,6 +189,10 @@ static int wcd937x_init_reg(struct snd_soc_component *component) WCD937X_HPH_NEW_INT_RDAC_HD2_CTL_L, 0x1F, 0x04); snd_soc_component_update_bits(component, WCD937X_HPH_NEW_INT_RDAC_HD2_CTL_R, 0x1F, 0x04); + snd_soc_component_update_bits(component, + WCD937X_BIAS_VBG_FINE_ADJ, 0xF0, 0xB0); + snd_soc_component_update_bits(component, + WCD937X_RX_BIAS_HPH_LOWPOWER, 0xF0, 0x90); } return 0; } From 8989993edf35acb5b040bfbef6bb86db7196dc90 Mon Sep 17 00:00:00 2001 From: Vatsal Bucha Date: Fri, 17 Sep 2021 15:24:28 +0530 Subject: [PATCH 10/82] ASoC: wcd937x: Add change for LDOL VOUT accuracy calibration ATE stores the calibration result in EFUSE register. This has to be copied to sleep bandgap voltage for accurate calibration. Change-Id: I118c5c3b42ba4cfd42185d8da6d468f44e31b88f Signed-off-by: Vatsal Bucha --- asoc/codecs/wcd937x/wcd937x.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/asoc/codecs/wcd937x/wcd937x.c b/asoc/codecs/wcd937x/wcd937x.c index 37cf1fd9c64f..30338cb77ecc 100644 --- a/asoc/codecs/wcd937x/wcd937x.c +++ b/asoc/codecs/wcd937x/wcd937x.c @@ -150,8 +150,18 @@ static int wcd937x_handle_post_irq(void *data) static int wcd937x_init_reg(struct snd_soc_component *component) { - snd_soc_component_update_bits(component, WCD937X_SLEEP_CTL, + u32 val =0; + val = snd_soc_component_read32(component, WCD937X_DIGITAL_EFUSE_REG_29) + & 0x0F; + if (snd_soc_component_read32(component, WCD937X_DIGITAL_EFUSE_REG_16) + == 0x02 || snd_soc_component_read32(component, + WCD937X_DIGITAL_EFUSE_REG_17) > 0x09) { + snd_soc_component_update_bits(component, WCD937X_SLEEP_CTL, + 0x0E, val); + } else { + snd_soc_component_update_bits(component, WCD937X_SLEEP_CTL, 0x0E, 0x0E); + } snd_soc_component_update_bits(component, WCD937X_SLEEP_CTL, 0x80, 0x80); usleep_range(1000, 1010); From d153bc1d480d71ab2230536dc4cf2d9243c29495 Mon Sep 17 00:00:00 2001 From: "Vangala, Amarnath" Date: Fri, 8 Oct 2021 18:22:27 +0530 Subject: [PATCH 11/82] ASoC: Lahaina: correction to CPS payload CPS Threshold values to be written to the slave device were not properly packed. Code change to correct the payload as per the specification. Change-Id: Ie5bbfca0875d16467160f96d20219c4946f81a72 Signed-off-by: Vangala, Amarnath --- asoc/lahaina.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/asoc/lahaina.c b/asoc/lahaina.c index 5805f93ea2dc..32880abbbc3c 100644 --- a/asoc/lahaina.c +++ b/asoc/lahaina.c @@ -5109,7 +5109,7 @@ static int msm_snd_cdc_dma_startup(struct snd_pcm_substream *substream) static void set_cps_config(struct snd_soc_pcm_runtime *rtd, u32 num_ch, u32 ch_mask) { - int i = 0; + int i = 0, j = 0; int val = 0; u8 dev_num = 0; int ch_configured = 0; @@ -5118,6 +5118,7 @@ static void set_cps_config(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai_link *dai_link = rtd->dai_link; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(rtd->card); + struct lpass_swr_spkr_dep_cfg_t *spkr_dep_cfg_ptr; if (!pdata) { pr_err("%s: pdata is NULL\n", __func__); @@ -5176,9 +5177,11 @@ static void set_cps_config(struct snd_soc_pcm_runtime *rtd, return; } + spkr_dep_cfg_ptr = &(pdata->cps_config.spkr_dep_cfg[i]); + /* Clear stale dev num info */ - pdata->cps_config.spkr_dep_cfg[i].vbatt_pkd_reg_addr &= 0xFFFF; - pdata->cps_config.spkr_dep_cfg[i].temp_pkd_reg_addr &= 0xFFFF; + spkr_dep_cfg_ptr->vbatt_pkd_reg_addr &= 0xFFFF; + spkr_dep_cfg_ptr->temp_pkd_reg_addr &= 0xFFFF; val = 0; @@ -5192,11 +5195,22 @@ static void set_cps_config(struct snd_soc_pcm_runtime *rtd, val |= (i*2) << 16; /* Update dev num in packed reg addr */ - pdata->cps_config.spkr_dep_cfg[i].vbatt_pkd_reg_addr |= val; + spkr_dep_cfg_ptr->vbatt_pkd_reg_addr |= val; val &= 0xFF0FFFF; val |= ((i*2)+1) << 16; - pdata->cps_config.spkr_dep_cfg[i].temp_pkd_reg_addr |= val; + spkr_dep_cfg_ptr->temp_pkd_reg_addr |= val; + + /* Retain dev_num from val */ + val &= 0x00F00000; + for (j = 0; j < MAX_CPS_LEVELS; j++) + { + val &= 0xFFF0FFFF; + val |= ((i * 3) + j) << 16; + spkr_dep_cfg_ptr->value_normal_thrsd[j] |= val; + spkr_dep_cfg_ptr->value_low1_thrsd[j] |= val; + spkr_dep_cfg_ptr->value_low2_thrsd[j] |= val; + } i++; ch_configured++; } From 8f1926c5ea394676bf5a8d7a49eab0132c589c88 Mon Sep 17 00:00:00 2001 From: Vatsal Bucha Date: Wed, 29 Sep 2021 13:42:35 +0530 Subject: [PATCH 12/82] ASoC: mbhc-adc: Prevent lineout from being reported two times Sometimes lineout is reported twice, first during initial detection and then during loop due to output mic voltage not being measured correctly. Prevent cable from being reported as headphone during second time if it was reported as lineout in initial detection. Change-Id: If828917cb2acbb0ed5b2de9bf1431d0fbb4a9d10 Signed-off-by: Vatsal Bucha --- asoc/codecs/wcd-mbhc-adc.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/asoc/codecs/wcd-mbhc-adc.c b/asoc/codecs/wcd-mbhc-adc.c index ebcedb9ae059..4ebfb2be65b5 100644 --- a/asoc/codecs/wcd-mbhc-adc.c +++ b/asoc/codecs/wcd-mbhc-adc.c @@ -453,7 +453,8 @@ static bool wcd_mbhc_adc_check_for_spl_headset(struct wcd_mbhc *mbhc, adc_hph_threshold = wcd_mbhc_adc_get_hph_thres(mbhc); if (output_mv > adc_threshold || output_mv < adc_hph_threshold) { - spl_hs = false; + if (mbhc->force_linein == true) + spl_hs = false; } else { spl_hs = true; if (spl_hs_cnt) @@ -515,9 +516,12 @@ static bool wcd_is_special_headset(struct wcd_mbhc *mbhc) msleep(50); output_mv = wcd_measure_adc_once(mbhc, MUX_CTL_IN2P); if (output_mv <= adc_threshold) { - pr_debug("%s: Special headset detected in %d msecs\n", - __func__, delay); - is_spl_hs = true; + if (mbhc->force_linein != true) { + pr_debug( + "%s: Special headset detected in %d msecs\n", + __func__, delay); + is_spl_hs = true; + } } if (delay == SPECIAL_HS_DETECT_TIME_MS) { @@ -831,7 +835,7 @@ correct_plug_type: } } - if (output_mv > hs_threshold) { + if (output_mv > hs_threshold || mbhc->force_linein == true) { pr_debug("%s: cable is extension cable\n", __func__); plug_type = MBHC_PLUG_TYPE_HIGH_HPH; wrk_complete = true; From fc80e4f28a06a3fe2cc5ab217ae083a3b0544ea4 Mon Sep 17 00:00:00 2001 From: Meng Wang Date: Mon, 25 Oct 2021 09:17:19 +0800 Subject: [PATCH 13/82] asoc: wsa883x: update irq_drv_data per wsa device regmap_irq_chip->irq_drv_data is shared by all attached wsa devices and pointed to last probbed wsa device. This will cause interrupt handle issue. Update irq_drv_data per wsa deviece to resolve this issue. Change-Id: Ib22629340d895c3c56d4987949c253589165b579 Signed-off-by: Meng Wang --- asoc/codecs/wsa883x/wsa883x.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/asoc/codecs/wsa883x/wsa883x.c b/asoc/codecs/wsa883x/wsa883x.c index f68eee190533..2c1a5cf30fc6 100644 --- a/asoc/codecs/wsa883x/wsa883x.c +++ b/asoc/codecs/wsa883x/wsa883x.c @@ -1622,12 +1622,20 @@ static int wsa883x_swr_probe(struct swr_device *pdev) const char *wsa883x_name_prefix_of = NULL; char buffer[MAX_NAME_LEN]; int dev_index = 0; + struct regmap_irq_chip *wsa883x_sub_regmap_irq_chip = NULL; wsa883x = devm_kzalloc(&pdev->dev, sizeof(struct wsa883x_priv), GFP_KERNEL); if (!wsa883x) return -ENOMEM; + wsa883x_sub_regmap_irq_chip = devm_kzalloc(&pdev->dev, sizeof(struct regmap_irq_chip), + GFP_KERNEL); + if (!wsa883x_sub_regmap_irq_chip) + return -ENOMEM; + memcpy(wsa883x_sub_regmap_irq_chip, &wsa883x_regmap_irq_chip, + sizeof(struct regmap_irq_chip)); + ret = wsa883x_enable_supplies(&pdev->dev, wsa883x); if (ret) { ret = -EPROBE_DEFER; @@ -1670,11 +1678,11 @@ static int wsa883x_swr_probe(struct swr_device *pdev) } /* Set all interrupts as edge triggered */ - for (i = 0; i < wsa883x_regmap_irq_chip.num_regs; i++) + for (i = 0; i < wsa883x_sub_regmap_irq_chip->num_regs; i++) regmap_write(wsa883x->regmap, (WSA883X_INTR_LEVEL0 + i), 0); - wsa883x_regmap_irq_chip.irq_drv_data = wsa883x; - wsa883x->irq_info.wcd_regmap_irq_chip = &wsa883x_regmap_irq_chip; + wsa883x_sub_regmap_irq_chip->irq_drv_data = wsa883x; + wsa883x->irq_info.wcd_regmap_irq_chip = wsa883x_sub_regmap_irq_chip; wsa883x->irq_info.codec_name = "WSA883X"; wsa883x->irq_info.regmap = wsa883x->regmap; wsa883x->irq_info.dev = &pdev->dev; From c59cdc295b618c1f0d55b905dff89d9b43469b07 Mon Sep 17 00:00:00 2001 From: Meng Wang Date: Tue, 28 Sep 2021 10:17:11 +0800 Subject: [PATCH 14/82] asoc: wsa883x: add slave_irq for wsa883x Interrupts from wsa883x are not handled because slave_irq is not set. Add slave_irq for wsa883x to address this issue. Change-Id: I1d9cb39bfe99b2b27a98cfe4876a233567c636cd Signed-off-by: Meng Wang --- asoc/codecs/wsa883x/wsa883x.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/asoc/codecs/wsa883x/wsa883x.c b/asoc/codecs/wsa883x/wsa883x.c index f68eee190533..9dca8cc950d8 100644 --- a/asoc/codecs/wsa883x/wsa883x.c +++ b/asoc/codecs/wsa883x/wsa883x.c @@ -1686,6 +1686,8 @@ static int wsa883x_swr_probe(struct swr_device *pdev) goto dev_err; } + wsa883x->swr_slave->slave_irq = wsa883x->virq; + wcd_request_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_SAF2WAR, "WSA SAF2WAR", wsa883x_saf2war_handle_irq, NULL); From 61e7e8b1088dc2f8465b91b57a7f31233f05d0a1 Mon Sep 17 00:00:00 2001 From: Meng Wang Date: Mon, 27 Sep 2021 11:44:50 +0800 Subject: [PATCH 15/82] ASoC: wsa883x: Enable all WSA interrupts Only UVLO_irq, PA_ON_ERR_IRQ and PDM_WD_IRQ are enabled on wsa883x. Enable all other IRQs to monitor if WSA is in bad state. Change-Id: I768c7f2c0fe64cc008ed63459b583e665e1ee013 Signed-off-by: Meng Wang --- asoc/codecs/wsa883x/wsa883x.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/asoc/codecs/wsa883x/wsa883x.c b/asoc/codecs/wsa883x/wsa883x.c index f68eee190533..4bf102ff0dbc 100644 --- a/asoc/codecs/wsa883x/wsa883x.c +++ b/asoc/codecs/wsa883x/wsa883x.c @@ -1125,6 +1125,11 @@ static int wsa883x_spkr_event(struct snd_soc_dapm_widget *w, usleep_range(250, 300); wcd_enable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_PA_ON_ERR); wcd_enable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_UVLO); + wcd_enable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_SAF2WAR); + wcd_enable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_WAR2SAF); + wcd_enable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_DISABLE); + wcd_enable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_OCP); + wcd_enable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_CLK_WD); /* Force remove group */ swr_remove_from_group(wsa883x->swr_slave, wsa883x->swr_slave->dev_num); @@ -1158,6 +1163,11 @@ static int wsa883x_spkr_event(struct snd_soc_dapm_widget *w, 0x10, 0x00); snd_soc_component_update_bits(component, WSA883X_PDM_WD_CTL, 0x01, 0x00); + wcd_disable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_CLK_WD); + wcd_disable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_OCP); + wcd_disable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_DISABLE); + wcd_disable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_WAR2SAF); + wcd_disable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_SAF2WAR); wcd_disable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_UVLO); wcd_disable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_PA_ON_ERR); clear_bit(SPKR_STATUS, &wsa883x->status_mask); @@ -1642,6 +1652,7 @@ static int wsa883x_swr_probe(struct swr_device *pdev) } swr_set_dev_data(pdev, wsa883x); wsa883x->swr_slave = pdev; + wsa883x->dev = &pdev->dev; pin_state_current = msm_cdc_pinctrl_get_state(wsa883x->wsa_rst_np); wsa883x_gpio_ctrl(wsa883x, true); /* @@ -1687,48 +1698,48 @@ static int wsa883x_swr_probe(struct swr_device *pdev) } wcd_request_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_SAF2WAR, - "WSA SAF2WAR", wsa883x_saf2war_handle_irq, NULL); + "WSA SAF2WAR", wsa883x_saf2war_handle_irq, wsa883x); wcd_disable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_SAF2WAR); wcd_request_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_WAR2SAF, - "WSA WAR2SAF", wsa883x_war2saf_handle_irq, NULL); + "WSA WAR2SAF", wsa883x_war2saf_handle_irq, wsa883x); wcd_disable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_WAR2SAF); wcd_request_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_DISABLE, - "WSA OTP", wsa883x_otp_handle_irq, NULL); + "WSA OTP", wsa883x_otp_handle_irq, wsa883x); wcd_disable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_DISABLE); wcd_request_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_OCP, - "WSA OCP", wsa883x_ocp_handle_irq, NULL); + "WSA OCP", wsa883x_ocp_handle_irq, wsa883x); wcd_disable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_OCP); wcd_request_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_CLIP, - "WSA CLIP", wsa883x_clip_handle_irq, NULL); + "WSA CLIP", wsa883x_clip_handle_irq, wsa883x); wcd_disable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_CLIP); wcd_request_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_PDM_WD, - "WSA PDM WD", wsa883x_pdm_wd_handle_irq, NULL); + "WSA PDM WD", wsa883x_pdm_wd_handle_irq, wsa883x); wcd_disable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_PDM_WD); wcd_request_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_CLK_WD, - "WSA CLK WD", wsa883x_clk_wd_handle_irq, NULL); + "WSA CLK WD", wsa883x_clk_wd_handle_irq, wsa883x); wcd_disable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_CLK_WD); wcd_request_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_INTR_PIN, - "WSA EXT INT", wsa883x_ext_int_handle_irq, NULL); + "WSA EXT INT", wsa883x_ext_int_handle_irq, wsa883x); wcd_disable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_INTR_PIN); /* Under Voltage Lock out (UVLO) interrupt handle */ wcd_request_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_UVLO, - "WSA UVLO", wsa883x_uvlo_handle_irq, NULL); + "WSA UVLO", wsa883x_uvlo_handle_irq, wsa883x); wcd_disable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_UVLO); From 3387b369d664b95a82f69d6a70e3e35682ab3a6d Mon Sep 17 00:00:00 2001 From: jinwen Date: Fri, 3 Sep 2021 15:12:17 +0800 Subject: [PATCH 16/82] asoc: enable mclk1 for audio bring up enable mclk1 for audio bring up on sa8295 platform Change-Id: Iafd2d42e65f8f51c4ad80cb1980faea6f3c0535c Signed-off-by: jinwen --- asoc/sa8155.c | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) diff --git a/asoc/sa8155.c b/asoc/sa8155.c index fbd96ecca74b..3d8b4605abb0 100644 --- a/asoc/sa8155.c +++ b/asoc/sa8155.c @@ -148,6 +148,10 @@ static const char *const tdm_gpio_phandle[] = {"qcom,pri-tdm-gpios", "qcom,hsif2-tdm-gpios", }; +static const char *const mclk_gpio_phandle[] = { "qcom,internal-mclk1-gpios" }; + +static bool mclk_enable_status = false; + enum { TDM_0 = 0, TDM_1, @@ -176,6 +180,11 @@ enum { TDM_INTERFACE_MAX, }; +enum { + MCLK1 = 0, + MCLK_MAX, +}; + struct tdm_port { u32 mode; u32 channel; @@ -937,6 +946,17 @@ static SOC_ENUM_SINGLE_EXT_DECL(mi2s_tx_format, bit_format_text); static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_rx_format, bit_format_text); static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_tx_format, bit_format_text); +static struct afe_clk_set internal_mclk[MCLK_MAX] = { + { + AFE_API_VERSION_CLOCK_SET_V2, + Q6AFE_LPASS_CLK_ID_MCLK_1, + Q6AFE_LPASS_IBIT_CLK_12_P288_MHZ, + Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO, + Q6AFE_LPASS_CLK_ROOT_DEFAULT, + 1, + } +}; + static struct afe_clk_set mi2s_clk[MI2S_MAX] = { { AFE_API_VERSION_I2S_CONFIG, @@ -983,6 +1003,7 @@ static struct afe_clk_set mi2s_clk[MI2S_MAX] = { struct msm_asoc_mach_data { struct msm_pinctrl_info pinctrl_info[TDM_INTERFACE_MAX]; + struct msm_pinctrl_info mclk_pinctrl_info[MCLK_MAX]; struct mi2s_conf mi2s_intf_conf[MI2S_MAX]; struct tdm_conf tdm_intf_conf[TDM_INTERFACE_MAX]; }; @@ -5201,6 +5222,92 @@ err: return -EINVAL; } +static int msm_pinctrl_mclk_enable(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); + struct msm_pinctrl_info *pinctrl_info = NULL; + struct pinctrl *pinctrl = NULL; + int pinctrl_num; + int i, j; + struct device_node *np = NULL; + struct platform_device *pdev_np = NULL; + int ret = 0; + + pinctrl_num = MCLK_MAX; + for (i = 0; i < pinctrl_num; i++) { + + np = of_parse_phandle(pdev->dev.of_node, mclk_gpio_phandle[i], 0); + if (!np) { + pr_err("%s: device node %s is null\n", __func__, mclk_gpio_phandle[i]); + continue; + } + pdev_np = of_find_device_by_node(np); + if (!pdev_np) { + pr_err("%s: platform device not found\n", __func__); + continue; + } + + pinctrl_info = &pdata->mclk_pinctrl_info[i]; + if (pinctrl_info == NULL) { + pr_err("%s: pinctrl info is null\n", __func__); + continue; + } + + pinctrl = devm_pinctrl_get(&pdev_np->dev); + if (IS_ERR_OR_NULL(pinctrl)) { + pr_err("%s: fail to get pinctrl handle\n", __func__); + goto err; + } + pinctrl_info->pinctrl = pinctrl; + /* get all the states handles from Device Tree */ + pinctrl_info->sleep = pinctrl_lookup_state(pinctrl, + "sleep"); + if (IS_ERR(pinctrl_info->sleep)) { + pr_err("%s: could not get sleep pin state\n", __func__); + goto err; + } + pinctrl_info->active = pinctrl_lookup_state(pinctrl, + "default"); + if (IS_ERR(pinctrl_info->active)) { + pr_err("%s: could not get active pin state\n", __func__); + goto err; + } + + /* Reset the mclk pins to a active state */ + ret = afe_set_lpass_clock_v2(AFE_PORT_ID_TDM_PORT_RANGE_START, + &internal_mclk[i]); + if (ret < 0) { + pr_err("%s: afe lpass clock failed to enable clock, err:%d\n", + __func__, ret); + ret = -EIO; + goto err; + } + mclk_enable_status = true; + ret = pinctrl_select_state(pinctrl_info->pinctrl, pinctrl_info->active); + if (ret != 0) { + pr_err("%s: set pin state to active failed with %d\n", + __func__, ret); + ret = -EIO; + goto err; + } + pinctrl_info->curr_state = STATE_ACTIVE; + } + return 0; + +err: + for (j = i; j >= 0; j--) { + pinctrl_info = &pdata->mclk_pinctrl_info[i]; + if (pinctrl_info == NULL) + continue; + if (pinctrl_info->pinctrl) { + devm_pinctrl_put(pinctrl_info->pinctrl); + pinctrl_info->pinctrl = NULL; + } + } + return -EINVAL; +} + static int msm_tdm_get_intf_idx(u16 id) { switch (id) { @@ -10568,6 +10675,7 @@ static int sa8155_ssr_enable(struct device *dev, void *data) struct platform_device *pdev = to_platform_device(dev); struct snd_soc_card *card = platform_get_drvdata(pdev); int ret = 0; + int i; if (!card) { dev_err(dev, "%s: card is NULL\n", __func__); @@ -10575,6 +10683,19 @@ static int sa8155_ssr_enable(struct device *dev, void *data) goto err; } + if (mclk_enable_status == true) { + for (i = 0; i < MCLK_MAX; i++) { + ret = afe_set_lpass_clock_v2(AFE_PORT_ID_TDM_PORT_RANGE_START, + &internal_mclk[i]); + if (ret < 0) { + pr_err("%s: afe lpass clock failed to enable clock, err:%d\n", + __func__, ret); + ret = -EIO; + goto err; + } + } + } + dev_info(dev, "%s: setting snd_card to ONLINE\n", __func__); #if IS_ENABLED(CONFIG_AUDIO_QGKI) snd_soc_card_change_online_state(card, 1); @@ -10644,6 +10765,7 @@ static int msm_asoc_machine_probe(struct platform_device *pdev) int ret; enum apr_subsys_state q6_state; static int first_probe = 1; + const struct of_device_id *match; if (first_probe) { place_marker("M - DRIVER Audio Init"); @@ -10725,6 +10847,24 @@ static int msm_asoc_machine_probe(struct platform_device *pdev) ret = 0; } + match = of_match_node(sa8155_asoc_machine_of_match, pdev->dev.of_node); + if (!match) { + dev_err(&pdev->dev, "%s: No DT match found for sound card\n", __func__); + return -EINVAL; + } + if (strstr(match->compatible, "sa8295")) { + /* enable mclk pinctrl info from devicetree */ + ret = msm_pinctrl_mclk_enable(pdev); + if (!ret) { + pr_debug("%s: pinctrl mclk parsing successful\n", __func__); + } else { + dev_err(&pdev->dev, + "%s: pinctrl mclk parsing failed with %d\n", + __func__, ret); + ret = 0; + } + } + msm_i2s_auxpcm_init(pdev); ret = msm_audio_ssr_register(&pdev->dev); From f58fd5003402e4d93c5768db49e79d1d36e73e73 Mon Sep 17 00:00:00 2001 From: jinwen Date: Fri, 3 Sep 2021 11:12:53 +0800 Subject: [PATCH 17/82] ASoC: add LXC audio config for auto sa8295 platform Bring up LXC audio module for automotive sa8295 platform. Change-Id: If7bd4707c9c7624062f3922e557c5c97e39cb5c1 Signed-off-by: jinwen --- Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) mode change 100755 => 100644 Makefile.am diff --git a/Makefile.am b/Makefile.am old mode 100755 new mode 100644 index 25c1e0e83d2a..2b135ca2fefd --- a/Makefile.am +++ b/Makefile.am @@ -43,14 +43,14 @@ obj-m += asoc/codecs/bolero/ obj-m += asoc/codecs/wcd937x/ endif -ifeq ($(TARGET_SUPPORT), $(filter $(TARGET_SUPPORT), sa8155 sa8155ivi sa6155 sa8195 qtiquingvm qtiquingvm8295)) +ifeq ($(TARGET_SUPPORT), $(filter $(TARGET_SUPPORT), sa8155 sa8155ivi sa6155 sa8195 qtiquingvm qtiquingvm8295 sa8295)) KBUILD_OPTIONS += CONFIG_SND_SOC_AUTO=y obj-m := ipc/ obj-m += dsp/ obj-m += asoc/ obj-m += asoc/codecs/ obj-m += soc/ -ifeq ($(TARGET_SUPPORT), $(filter $(TARGET_SUPPORT), sa8155 sa8155ivi sa8195)) +ifeq ($(TARGET_SUPPORT), $(filter $(TARGET_SUPPORT), sa8155 sa8155ivi sa8195 sa8295)) KBUILD_OPTIONS += CONFIG_SND_SOC_SA8155=m endif ifeq ($(TARGET_SUPPORT), $(filter $(TARGET_SUPPORT), sa6155)) From dfa4b18061b19e1173d2e6fde007a71e010d9bf0 Mon Sep 17 00:00:00 2001 From: ftong Date: Mon, 25 Oct 2021 18:37:28 +0800 Subject: [PATCH 18/82] asoc: add drift support for mi2s interface add support for mi2s interface for drift value Change-Id: I02579f2dbb43593dec5e44000728470d5fe2a1c4 Signed-off-by: ftong --- asoc/msm-pcm-routing-v2.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/asoc/msm-pcm-routing-v2.c b/asoc/msm-pcm-routing-v2.c index f20d9124fb6e..b1e4e355af32 100755 --- a/asoc/msm-pcm-routing-v2.c +++ b/asoc/msm-pcm-routing-v2.c @@ -42218,20 +42218,30 @@ static int get_drift_src_idx(int drift_src) { if (drift_src == DRIFT_SRC_SW) return DRIFT_SRC_SW; - else if ((drift_src >= AFE_PORT_ID_PRIMARY_TDM_RX) + else if (((drift_src >= AFE_PORT_ID_PRIMARY_TDM_RX) && (drift_src <= AFE_PORT_ID_PRIMARY_TDM_TX_7)) + || (drift_src == AFE_PORT_ID_PRIMARY_MI2S_RX) + || (drift_src == AFE_PORT_ID_PRIMARY_MI2S_TX)) return DRIFT_SRC_AFE_PRI; - else if ((drift_src >= AFE_PORT_ID_SECONDARY_TDM_RX) + else if (((drift_src >= AFE_PORT_ID_SECONDARY_TDM_RX) && (drift_src <= AFE_PORT_ID_SECONDARY_TDM_TX_7)) + || (drift_src == AFE_PORT_ID_SECONDARY_MI2S_RX) + || (drift_src == AFE_PORT_ID_SECONDARY_MI2S_TX)) return DRIFT_SRC_AFE_SEC; - else if ((drift_src >= AFE_PORT_ID_TERTIARY_TDM_RX) + else if (((drift_src >= AFE_PORT_ID_TERTIARY_TDM_RX) && (drift_src <= AFE_PORT_ID_TERTIARY_TDM_TX_7)) + || (drift_src == AFE_PORT_ID_TERTIARY_MI2S_RX) + || (drift_src == AFE_PORT_ID_TERTIARY_MI2S_TX)) return DRIFT_SRC_AFE_TERT; - else if ((drift_src >= AFE_PORT_ID_QUATERNARY_TDM_RX) + else if (((drift_src >= AFE_PORT_ID_QUATERNARY_TDM_RX) && (drift_src <= AFE_PORT_ID_QUATERNARY_TDM_TX_7)) + || (drift_src == AFE_PORT_ID_QUATERNARY_MI2S_RX) + || (drift_src == AFE_PORT_ID_QUATERNARY_MI2S_TX)) return DRIFT_SRC_AFE_QUAT; - else if ((drift_src >= AFE_PORT_ID_QUINARY_TDM_RX) + else if (((drift_src >= AFE_PORT_ID_QUINARY_TDM_RX) && (drift_src <= AFE_PORT_ID_QUINARY_TDM_TX_7)) + || (drift_src == AFE_PORT_ID_QUINARY_MI2S_RX) + || (drift_src == AFE_PORT_ID_QUINARY_MI2S_TX)) return DRIFT_SRC_AFE_QUIN; else return -EINVAL; From 65bd6329c39bc00034622b5ea456254e271b541f Mon Sep 17 00:00:00 2001 From: Jing Wang Date: Tue, 12 Oct 2021 11:24:57 +0530 Subject: [PATCH 19/82] asoc: Reslove audiodlkm error & warn & issues Fix potential deadlock by creating another goto-label Fix potential memory-leak (free space for each error after space was allocated) Change order of destroy for mutexes in init-fucnction (last created mutex should be destroyed first) Change-Id: I9ad8849a166af247eed6e7667da73d537ca7d2a2 Signed-off-by: Jing Wang --- asoc/bengal.c | 4 +- asoc/codecs/wcd934x/wcd934x-regmap.c | 4 +- asoc/codecs/wcd9xxx-core.c | 4 +- asoc/codecs/wcd_cpe_core.c | 62 ++++++++++++++-------------- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/asoc/bengal.c b/asoc/bengal.c index 70dfc9251bd2..f0b9e840f2ca 100644 --- a/asoc/bengal.c +++ b/asoc/bengal.c @@ -930,8 +930,6 @@ static int usb_audio_tx_format_get(struct snd_kcontrol *kcontrol, static int usb_audio_tx_format_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - int rc = 0; - switch (ucontrol->value.integer.value[0]) { case 3: usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE; @@ -951,7 +949,7 @@ static int usb_audio_tx_format_put(struct snd_kcontrol *kcontrol, __func__, usb_tx_cfg.bit_format, ucontrol->value.integer.value[0]); - return rc; + return 0; } static int usb_audio_rx_ch_get(struct snd_kcontrol *kcontrol, diff --git a/asoc/codecs/wcd934x/wcd934x-regmap.c b/asoc/codecs/wcd934x/wcd934x-regmap.c index a9642091a66e..5741c6b946c9 100644 --- a/asoc/codecs/wcd934x/wcd934x-regmap.c +++ b/asoc/codecs/wcd934x/wcd934x-regmap.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2018, 2021, The Linux Foundation. All rights reserved. */ #include @@ -1832,6 +1832,8 @@ int wcd934x_regmap_register_patch(struct regmap *regmap, int revision) ARRAY_SIZE(wcd934x_1_1_defaults)); regcache_cache_only(regmap, false); break; + default: + break; } return rc; diff --git a/asoc/codecs/wcd9xxx-core.c b/asoc/codecs/wcd9xxx-core.c index 7462cc4532dc..7479accde75d 100644 --- a/asoc/codecs/wcd9xxx-core.c +++ b/asoc/codecs/wcd9xxx-core.c @@ -638,9 +638,9 @@ err: wcd9xxx_bringdown(wcd9xxx->dev); wcd9xxx_core_res_deinit(&wcd9xxx->core_res); err_bring_up: - mutex_destroy(&wcd9xxx->io_lock); - mutex_destroy(&wcd9xxx->xfer_lock); mutex_destroy(&wcd9xxx->reset_lock); + mutex_destroy(&wcd9xxx->xfer_lock); + mutex_destroy(&wcd9xxx->io_lock); return ret; } diff --git a/asoc/codecs/wcd_cpe_core.c b/asoc/codecs/wcd_cpe_core.c index fa6d0f0e39e0..68abc3e7b24e 100644 --- a/asoc/codecs/wcd_cpe_core.c +++ b/asoc/codecs/wcd_cpe_core.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2014-2020, The Linux Foundation. All rights reserved. +/* Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. */ #include @@ -756,7 +756,7 @@ static unsigned int wcd_cpe_state_poll(struct snd_info_entry *entry, */ static bool wcd_cpe_is_online_state(void *core_handle) { - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; if (core_handle) { return !core->ssr_entry.offline; @@ -1098,7 +1098,7 @@ err_ret: int wcd_cpe_ssr_event(void *core_handle, enum wcd_cpe_ssr_state_event event) { - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; if (!core) { pr_err("%s: Invalid handle to core\n", @@ -2169,7 +2169,7 @@ static int wcd_cpe_cmi_send_lsm_msg( void *message) { int ret = 0; - struct cmi_hdr *hdr = message; + struct cmi_hdr *hdr = (struct cmi_hdr *)message; pr_debug("%s: sending message with opcode 0x%x\n", __func__, hdr->opcode); @@ -2413,7 +2413,7 @@ static int wcd_cpe_cmd_lsm_open_tx(void *core_handle, u16 app_id, u16 sample_rate) { struct cpe_lsm_cmd_open_tx cmd_open_tx; - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; int ret = 0; ret = wcd_cpe_is_valid_lsm_session(core, session, @@ -2462,7 +2462,7 @@ static int wcd_cpe_cmd_lsm_close_tx(void *core_handle, struct cpe_lsm_session *session) { struct cmi_hdr cmd_close_tx; - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; int ret = 0; ret = wcd_cpe_is_valid_lsm_session(core, session, @@ -2503,7 +2503,7 @@ static int wcd_cpe_cmd_lsm_shmem_alloc(void *core_handle, u32 size) { struct cpe_cmd_shmem_alloc cmd_shmem_alloc; - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; int ret = 0; ret = wcd_cpe_is_valid_lsm_session(core, session, @@ -2542,7 +2542,7 @@ static int wcd_cpe_cmd_lsm_shmem_dealloc(void *core_handle, struct cpe_lsm_session *session) { struct cpe_cmd_shmem_dealloc cmd_dealloc; - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; int ret = 0; ret = wcd_cpe_is_valid_lsm_session(core, session, @@ -3021,7 +3021,7 @@ static int wcd_cpe_set_one_param(void *core_handle, struct cpe_lsm_session *session, struct lsm_params_info *p_info, void *data, uint32_t param_type) { - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; int rc = 0; struct cpe_lsm_ids ids; @@ -3111,7 +3111,7 @@ static int wcd_cpe_lsm_set_data(void *core_handle, enum lsm_detection_mode detect_mode, bool detect_failure) { - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; struct cpe_lsm_ids ids; int ret = 0; @@ -3160,7 +3160,7 @@ static int wcd_cpe_lsm_reg_snd_model(void *core_handle, { int ret = 0; struct cmi_obm_msg obm_msg; - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; ret = wcd_cpe_is_valid_lsm_session(core, session, __func__); @@ -3213,7 +3213,7 @@ static int wcd_cpe_lsm_dereg_snd_model(void *core_handle, struct cpe_lsm_session *session) { struct cmi_hdr cmd_dereg_snd_model; - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; int ret = 0; ret = wcd_cpe_is_valid_lsm_session(core, session, @@ -3248,7 +3248,7 @@ end_ret: static int wcd_cpe_lsm_get_afe_out_port_id(void *core_handle, struct cpe_lsm_session *session) { - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; struct snd_soc_component *component; int rc = 0; @@ -3302,7 +3302,7 @@ static int wcd_cpe_cmd_lsm_start(void *core_handle, struct cpe_lsm_session *session) { struct cmi_hdr cmd_lsm_start; - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; int ret = 0; ret = wcd_cpe_is_valid_lsm_session(core, session, @@ -3337,7 +3337,7 @@ static int wcd_cpe_cmd_lsm_stop(void *core_handle, struct cpe_lsm_session *session) { struct cmi_hdr cmd_lsm_stop; - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; int ret = 0; ret = wcd_cpe_is_valid_lsm_session(core, session, @@ -3376,7 +3376,7 @@ static struct cpe_lsm_session *wcd_cpe_alloc_lsm_session( { struct cpe_lsm_session *session; int i, session_id = -1; - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; bool afe_register_service = false; int ret = 0; @@ -3537,7 +3537,7 @@ static int wcd_cpe_lsm_lab_control( struct cpe_lsm_session *session, bool enable) { - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; int ret = 0, pld_size = CPE_PARAM_SIZE_LSM_LAB_CONTROL; struct cpe_lsm_control_lab cpe_lab_enable; struct cpe_lsm_lab_enable *lab_enable = &cpe_lab_enable.lab_enable; @@ -3620,7 +3620,7 @@ static int wcd_cpe_lsm_eob( static int wcd_cpe_dealloc_lsm_session(void *core_handle, struct cpe_lsm_session *session) { - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; int ret = 0; WCD_CPE_GRAB_LOCK(&core->session_lock, "session_lock"); @@ -3667,7 +3667,7 @@ static int wcd_cpe_lab_ch_setup(void *core_handle, struct cpe_lsm_session *session, enum wcd_cpe_event event) { - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; struct snd_soc_component *component; int rc = 0; u8 cpe_intr_bits; @@ -3791,7 +3791,7 @@ static int wcd_cpe_lsm_set_fmt_cfg(void *core_handle, { int ret; struct cpe_lsm_output_format_cfg out_fmt_cfg; - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; ret = wcd_cpe_is_valid_lsm_session(core, session, __func__); if (ret) @@ -3835,7 +3835,7 @@ static int wcd_cpe_lsm_set_media_fmt_params(void *core_handle, { struct cpe_lsm_media_fmt_param media_fmt; struct cmi_hdr *msg_hdr = &media_fmt.hdr; - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; struct cpe_param_data *param_d = &media_fmt.param; struct cpe_lsm_ids ids; int ret; @@ -3878,7 +3878,7 @@ static int wcd_cpe_lsm_set_port(void *core_handle, u32 port_id; int ret; struct cpe_lsm_ids ids; - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; ret = wcd_cpe_is_valid_lsm_session(core, session, __func__); if (ret) @@ -3972,7 +3972,7 @@ static int wcd_cpe_cmi_send_afe_msg( void *message) { int ret = 0; - struct cmi_hdr *hdr = message; + struct cmi_hdr *hdr = (struct cmi_hdr *)message; pr_debug("%s: sending message with opcode 0x%x\n", __func__, hdr->opcode); @@ -4116,7 +4116,7 @@ static int wcd_cpe_send_afe_cal(void *core_handle, { struct cal_block_data *afe_cal = NULL; - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; struct cmi_obm_msg obm_msg; void *inb_msg = NULL; void *msg; @@ -4270,7 +4270,7 @@ static int wcd_cpe_afe_svc_cmd_mode(void *core_handle, u8 mode) { struct cpe_afe_svc_cmd_mode afe_mode; - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; struct wcd_cmi_afe_port_data *afe_port_d; int ret; @@ -4309,7 +4309,7 @@ static int wcd_cpe_afe_cmd_port_cfg(void *core_handle, struct wcd_cpe_afe_port_cfg *afe_cfg) { struct cpe_afe_cmd_port_cfg port_cfg_cmd; - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; struct wcd_cmi_afe_port_data *afe_port_d; int ret; @@ -4364,7 +4364,7 @@ static int wcd_cpe_afe_set_params(void *core_handle, struct cpe_afe_params afe_params; struct cpe_afe_hw_mad_ctrl *hw_mad_ctrl = &afe_params.hw_mad_ctrl; struct cpe_afe_port_cfg *port_cfg = &afe_params.port_cfg; - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; struct wcd_cmi_afe_port_data *afe_port_d; int ret = 0, pld_size = 0; @@ -4434,7 +4434,7 @@ static int wcd_cpe_afe_port_start(void *core_handle, { struct cmi_hdr hdr; - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; struct wcd_cmi_afe_port_data *afe_port_d; int ret = 0; @@ -4470,7 +4470,7 @@ static int wcd_cpe_afe_port_stop(void *core_handle, struct wcd_cpe_afe_port_cfg *port_cfg) { struct cmi_hdr hdr; - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; struct wcd_cmi_afe_port_data *afe_port_d; int ret = 0; @@ -4507,7 +4507,7 @@ static int wcd_cpe_afe_port_suspend(void *core_handle, struct wcd_cpe_afe_port_cfg *port_cfg) { struct cmi_hdr hdr; - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; struct wcd_cmi_afe_port_data *afe_port_d; int ret = 0; @@ -4543,7 +4543,7 @@ static int wcd_cpe_afe_port_resume(void *core_handle, struct wcd_cpe_afe_port_cfg *port_cfg) { struct cmi_hdr hdr; - struct wcd_cpe_core *core = core_handle; + struct wcd_cpe_core *core = (struct wcd_cpe_core *)core_handle; struct wcd_cmi_afe_port_data *afe_port_d; int ret = 0; From 25c2fa7eb0386a3a6b5c67d0236fde6d5c4fb16e Mon Sep 17 00:00:00 2001 From: Jing Wang Date: Tue, 12 Oct 2021 08:26:45 +0530 Subject: [PATCH 20/82] dsp: Reslove audiodlkm code warning q6afe: sanitize variables, fill proper error codes/messages q6voice: modify func return value type Initialized mutex while probing was not destroyed while removing the module Change-Id: I951e957bd8f15fa300e867472fb38755a7a80dec Signed-off-by: Jing Wang --- dsp/audio_calibration.c | 2 ++ dsp/q6adm.c | 11 ++++---- dsp/q6afe.c | 58 ++++++++++++++++++++++++++++++++++------- dsp/q6asm.c | 8 ++++++ dsp/q6lsm.c | 4 +++ dsp/q6voice.c | 12 ++++++--- dsp/rtac.c | 7 +++++ 7 files changed, 84 insertions(+), 18 deletions(-) diff --git a/dsp/audio_calibration.c b/dsp/audio_calibration.c index c4ab399a38af..a77be946a231 100644 --- a/dsp/audio_calibration.c +++ b/dsp/audio_calibration.c @@ -622,7 +622,9 @@ void audio_cal_exit(void) kfree(client_info_node); client_info_node = NULL; } + mutex_destroy(&audio_cal.cal_mutex[i]); } + mutex_destroy(&audio_cal.common_lock); misc_deregister(&audio_cal_misc); } diff --git a/dsp/q6adm.c b/dsp/q6adm.c index cfc983e8683f..53a70d396ab2 100755 --- a/dsp/q6adm.c +++ b/dsp/q6adm.c @@ -4312,7 +4312,6 @@ EXPORT_SYMBOL(adm_close); int send_rtac_audvol_cal(void) { int ret = 0; - int ret2 = 0; int i = 0; int copp_idx, port_idx, acdb_id, app_id, path; struct cal_block_data *cal_block = NULL; @@ -4358,7 +4357,7 @@ int send_rtac_audvol_cal(void) continue; } - ret2 = adm_remap_and_send_cal_block(ADM_RTAC_AUDVOL_CAL, + ret = adm_remap_and_send_cal_block(ADM_RTAC_AUDVOL_CAL, rtac_adm_data.device[i].afe_port, copp_idx, cal_block, atomic_read(&this_adm.copp. @@ -4367,13 +4366,12 @@ int send_rtac_audvol_cal(void) audvol_cal_info->acdb_id, atomic_read(&this_adm.copp. rate[port_idx][copp_idx])); - if (ret2 < 0) { + if (ret < 0) { pr_debug("%s: remap and send failed for copp Id %d, acdb id %d, app type %d, path %d\n", __func__, rtac_adm_data.device[i].copp, audvol_cal_info->acdb_id, audvol_cal_info->app_type, audvol_cal_info->path); - ret = ret2; } } } @@ -5215,6 +5213,7 @@ int adm_wait_timeout(int port_id, int copp_idx, int wait_time) pr_debug("%s: return %d\n", __func__, ret); if (ret != 0) ret = -EINTR; + end: pr_debug("%s: return %d--\n", __func__, ret); return ret; @@ -5275,8 +5274,10 @@ int adm_store_cal_data(int port_id, int copp_idx, int path, int perf_mode, mutex_lock(&this_adm.cal_data[cal_index]->lock); cal_block = adm_find_cal(cal_index, get_cal_path(path), app_type, acdb_id, sample_rate); - if (cal_block == NULL) + if (cal_block == NULL) { + pr_err("%s: can't find cal block!\n", __func__); goto unlock; + } if (cal_block->cal_data.size <= 0) { pr_debug("%s: No ADM cal send for port_id = 0x%x!\n", diff --git a/dsp/q6afe.c b/dsp/q6afe.c index f900a3cd70b5..81c783b84e73 100755 --- a/dsp/q6afe.c +++ b/dsp/q6afe.c @@ -3460,6 +3460,11 @@ int afe_send_port_vad_cfg_params(u16 port_id) return 0; } + ret = afe_validate_port(port_id); + if (ret < 0) { + pr_err("%s: Not a valid port id = 0x%x ret %d\n", __func__, + port_id, ret); + } port_index = afe_get_port_index(port_id); if (this_afe.vad_cfg[port_index].is_enable) { @@ -4686,9 +4691,16 @@ EXPORT_SYMBOL(afe_tdm_port_start); void afe_set_cal_mode(u16 port_id, enum afe_cal_mode afe_cal_mode) { uint16_t port_index; + int ret = 0; - port_index = afe_get_port_index(port_id); - this_afe.afe_cal_mode[port_index] = afe_cal_mode; + ret = afe_validate_port(port_id); + if (ret < 0) { + pr_err("%s: Not a valid port id = 0x%x ret %d\n", __func__, + port_id, ret); + } else { + port_index = afe_get_port_index(port_id); + this_afe.afe_cal_mode[port_index] = afe_cal_mode; + } } EXPORT_SYMBOL(afe_set_cal_mode); @@ -4723,10 +4735,17 @@ EXPORT_SYMBOL(afe_set_vad_cfg); void afe_get_island_mode_cfg(u16 port_id, u32 *enable_flag) { uint16_t port_index; + int ret = 0; - if (enable_flag) { - port_index = afe_get_port_index(port_id); - *enable_flag = this_afe.island_mode[port_index]; + ret = afe_validate_port(port_id); + if (ret < 0) { + pr_err("%s: Not a valid port id = 0x%x ret %d\n", __func__, + port_id, ret); + } else { + if (enable_flag) { + port_index = afe_get_port_index(port_id); + *enable_flag = this_afe.island_mode[port_index]; + } } } EXPORT_SYMBOL(afe_get_island_mode_cfg); @@ -4742,12 +4761,19 @@ EXPORT_SYMBOL(afe_get_island_mode_cfg); void afe_set_island_mode_cfg(u16 port_id, u32 enable_flag) { uint16_t port_index; + int ret = 0; - port_index = afe_get_port_index(port_id); - this_afe.island_mode[port_index] = enable_flag; + ret = afe_validate_port(port_id); + if (ret < 0) { + pr_err("%s: Not a valid port id = 0x%x ret %d\n", __func__, + port_id, ret); + } else { + port_index = afe_get_port_index(port_id); + this_afe.island_mode[port_index] = enable_flag; - trace_printk("%s: set island mode cfg 0x%x for port 0x%x\n", - __func__, this_afe.island_mode[port_index], port_id); + trace_printk("%s: set island mode cfg 0x%x for port 0x%x\n", + __func__, this_afe.island_mode[port_index], port_id); + } } EXPORT_SYMBOL(afe_set_island_mode_cfg); @@ -8031,6 +8057,8 @@ int afe_register_get_events(u16 port_id, pr_debug("%s: port_id: 0x%x\n", __func__, port_id); + memset(&rtproxy, 0, sizeof(rtproxy)); + if (this_afe.apr == NULL) { this_afe.apr = apr_register("ADSP", "AFE", afe_callback, 0xFFFFFFFF, &this_afe); @@ -8094,6 +8122,8 @@ int afe_unregister_get_events(u16 port_id) pr_debug("%s:\n", __func__); + memset(&rtproxy, 0, sizeof(rtproxy)); + if (this_afe.apr == NULL) { this_afe.apr = apr_register("ADSP", "AFE", afe_callback, 0xFFFFFFFF, &this_afe); @@ -8178,6 +8208,8 @@ int afe_rt_proxy_port_write(phys_addr_t buf_addr_p, int ret = 0; struct afe_port_data_cmd_rt_proxy_port_write_v2 afecmd_wr; + memset(&afecmd_wr, 0, sizeof(afecmd_wr)); + if (this_afe.apr == NULL) { pr_err("%s: register to AFE is not done\n", __func__); ret = -ENODEV; @@ -8237,6 +8269,8 @@ int afe_rt_proxy_port_read(phys_addr_t buf_addr_p, struct afe_port_data_cmd_rt_proxy_port_read_v2 afecmd_rd; int port_id = VIRTUAL_ID_TO_PORTID(id); + memset(&afecmd_rd, 0, sizeof(afecmd_rd)); + if (this_afe.apr == NULL) { pr_err("%s: register to AFE is not done\n", __func__); ret = -ENODEV; @@ -8477,6 +8511,8 @@ int afe_dtmf_generate_rx(int64_t duration_in_ms, pr_debug("%s: DTMF AFE Gen\n", __func__); + memset(&cmd_dtmf, 0, sizeof(cmd_dtmf)); + if (afe_validate_port(this_afe.dtmf_gen_rx_portid) < 0) { pr_err("%s: Failed : Invalid Port id = 0x%x\n", __func__, this_afe.dtmf_gen_rx_portid); @@ -9223,6 +9259,8 @@ int afe_port_stop_nowait(int port_id) struct afe_port_cmd_device_stop stop; int ret = 0; + memset(&stop, 0, sizeof(stop)); + if (this_afe.apr == NULL) { pr_err("%s: AFE is already closed\n", __func__); ret = -EINVAL; @@ -9266,6 +9304,8 @@ int afe_close(int port_id) int index = 0; uint16_t port_index; + memset(&stop, 0, sizeof(stop)); + if (this_afe.apr == NULL) { pr_err("%s: AFE is already closed\n", __func__); diff --git a/dsp/q6asm.c b/dsp/q6asm.c index abb1c5e28437..d39ec0f94478 100755 --- a/dsp/q6asm.c +++ b/dsp/q6asm.c @@ -11691,5 +11691,13 @@ int __init q6asm_init(void) void q6asm_exit(void) { + int lcnt; q6asm_delete_cal_data(); + for (lcnt = 0; lcnt <= OUT; lcnt++) + mutex_destroy(&common_client.port[lcnt].lock); + + mutex_destroy(&common_client.cmd_lock); + + for (lcnt = 0; lcnt <= ASM_ACTIVE_STREAMS_ALLOWED; lcnt++) + mutex_destroy(&(session[lcnt].mutex_lock_per_session)); } diff --git a/dsp/q6lsm.c b/dsp/q6lsm.c index 78d3539da1c3..4f1776dd221d 100644 --- a/dsp/q6lsm.c +++ b/dsp/q6lsm.c @@ -3100,8 +3100,12 @@ int __init q6lsm_init(void) void q6lsm_exit(void) { + int i = 0; lsm_delete_cal_data(); + for (; i <= LSM_MAX_SESSION_ID; i++) + mutex_destroy(&lsm_common.common_client[i].cmd_lock); + mutex_destroy(&lsm_common.apr_lock); #ifdef CONFIG_DEBUG_FS debugfs_remove_recursive(lsm_common.entry); lsm_common.entry = NULL; diff --git a/dsp/q6voice.c b/dsp/q6voice.c index 05ed9bccedba..45753c0381e7 100644 --- a/dsp/q6voice.c +++ b/dsp/q6voice.c @@ -118,7 +118,7 @@ static int voice_send_cvp_ecns_enable_cmd(struct voice_data *v, static int is_cal_memory_allocated(void); static bool is_cvd_version_queried(void); -static int is_voip_memory_allocated(void); +static bool is_voip_memory_allocated(void); static int voice_get_cvd_int_version(char *cvd_ver_string); static int voice_alloc_cal_mem_map_table(void); static int voice_alloc_rtac_mem_map_table(void); @@ -134,7 +134,7 @@ static int remap_cal_data(struct cal_block_data *cal_block, static int voice_unmap_cal_memory(int32_t cal_type, struct cal_block_data *cal_block); -static int is_source_tracking_shared_memomry_allocated(void); +static bool is_source_tracking_shared_memomry_allocated(void); static int voice_alloc_source_tracking_shared_memory(void); static int voice_alloc_and_map_source_tracking_shared_memory( struct voice_data *v); @@ -2222,7 +2222,7 @@ done: } -static int is_voip_memory_allocated(void) +static bool is_voip_memory_allocated(void) { bool ret; struct voice_data *v = voice_get_session( @@ -9693,7 +9693,7 @@ int voc_get_sound_focus(struct sound_focus_param *soundFocusData) } EXPORT_SYMBOL(voc_get_sound_focus); -static int is_source_tracking_shared_memomry_allocated(void) +static bool is_source_tracking_shared_memomry_allocated(void) { bool ret; @@ -10351,7 +10351,11 @@ int __init voice_init(void) void voice_exit(void) { + int i; q6core_destroy_uevent_data(common.uevent_data); voice_delete_cal_data(); free_cal_map_table(); + mutex_destroy(&common.common_lock); + for (i = 0; i < MAX_VOC_SESSIONS; i++) + mutex_destroy(&common.voice[i].lock); } diff --git a/dsp/rtac.c b/dsp/rtac.c index 16a405a8509b..6864970651f6 100644 --- a/dsp/rtac.c +++ b/dsp/rtac.c @@ -2068,6 +2068,13 @@ void rtac_exit(void) kzfree(rtac_asm_buffer); kzfree(rtac_afe_buffer); kzfree(rtac_voice_buffer); + mutex_destroy(&rtac_voice_apr_mutex); + mutex_destroy(&rtac_voice_mutex); + mutex_destroy(&rtac_afe_apr_mutex); + mutex_destroy(&rtac_asm_apr_mutex); + mutex_destroy(&rtac_adm_apr_mutex); + mutex_destroy(&rtac_adm_mutex); + mutex_destroy(&rtac_common.rtac_fops_mutex); } MODULE_DESCRIPTION("SoC QDSP6v2 Real-Time Audio Calibration driver"); From cf8bb8429e27d817b9b62bf4005984d996ea6bc3 Mon Sep 17 00:00:00 2001 From: E V Ravi Date: Mon, 11 Oct 2021 11:13:16 +0530 Subject: [PATCH 21/82] asoc: get and put for TERT_TDM_TX_0 ADM channels - Enables get/put for TERT_TDM_TX_0 ADM channels - Allows for 3 and 4 ADM channels for TERT_TDM - Motivated by concurrency of GAS and HFP Change-Id: Iea44929014e0f97ca238ccffa11f228a19d5a6eb Signed-off-by: E V Ravi --- asoc/msm-pcm-routing-v2.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/asoc/msm-pcm-routing-v2.c b/asoc/msm-pcm-routing-v2.c index f20d9124fb6e..84df3903b124 100755 --- a/asoc/msm-pcm-routing-v2.c +++ b/asoc/msm-pcm-routing-v2.c @@ -3780,7 +3780,7 @@ static int msm_routing_lsm_func_put(struct snd_kcontrol *kcontrol, return afe_port_set_mad_type(port_id, mad_type); } -static const char *const adm_override_chs_text[] = {"Zero", "One", "Two"}; +static const char *const adm_override_chs_text[] = {"Zero", "One", "Two", "Three", "Four"}; static SOC_ENUM_SINGLE_EXT_DECL(adm_override_chs, adm_override_chs_text); @@ -3795,6 +3795,8 @@ static int msm_routing_adm_get_backend_idx(struct snd_kcontrol *kcontrol) backend_id = MSM_BACKEND_DAI_SLIMBUS_9_TX; } else if (strnstr(kcontrol->id.name, "SLIM7_TX", sizeof("SLIM7_TX"))) { backend_id = MSM_BACKEND_DAI_SLIMBUS_7_TX; + } else if (strnstr(kcontrol->id.name, "TERT_TDM_TX_0", sizeof("TERT_TDM_TX_0"))) { + backend_id = MSM_BACKEND_DAI_TERT_TDM_TX_0; } else { pr_err("%s: unsupported backend id: %s", __func__, kcontrol->id.name); @@ -3851,6 +3853,9 @@ static const struct snd_kcontrol_new adm_channel_config_controls[] = { SOC_ENUM_EXT("SLIM7_TX ADM Channels", adm_override_chs, msm_routing_adm_channel_config_get, msm_routing_adm_channel_config_put), + SOC_ENUM_EXT("TERT_TDM_TX_0 ADM Channels", adm_override_chs, + msm_routing_adm_channel_config_get, + msm_routing_adm_channel_config_put), }; static int msm_routing_slim_0_rx_aanc_mux_get(struct snd_kcontrol *kcontrol, From 862d75d7fa2279bb502e4559663962036c117162 Mon Sep 17 00:00:00 2001 From: Hongtao Peng Date: Wed, 29 Sep 2021 15:51:35 +0800 Subject: [PATCH 22/82] ipc: apr_vm: change the priority of apr_vm_cb_threa When the CPU is very busy, the APR message may timeout due to other high-priority threads blocking. Increase the priority of apr_vm_cb_thread from 1 to 3 to unblock. Change-Id: I11be527b270e55dccafa67ed4c7b8b25799b8542 Signed-off-by: Hongtao Peng --- ipc/apr_vm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/apr_vm.c b/ipc/apr_vm.c index 31c384b113e8..6f4d4580d79a 100644 --- a/ipc/apr_vm.c +++ b/ipc/apr_vm.c @@ -585,7 +585,7 @@ static int apr_vm_cb_thread(void *data) unsigned long delay = jiffies + (HZ / 2); int status = 0; int ret = 0; - struct sched_param param = {.sched_priority = 1}; + struct sched_param param = {.sched_priority = 3}; sched_setscheduler(current, SCHED_FIFO, ¶m); From e92fbc265e2ed6a02cc7212ab615e63257235f71 Mon Sep 17 00:00:00 2001 From: Meng Wang Date: Mon, 27 Sep 2021 17:06:49 +0800 Subject: [PATCH 23/82] soc: swr-mstr-ctrl: Move to CPU-1 FIFO for swr register read/write Both APSS and ADSP are accessing CPU-0 FIFO when CPS is enabled during speaker playback. This causes underflow issue when accessing wsa register from APSS. Move APSS to CPU-1 FIFO to resolve underflow issue. Change-Id: I5ed9143bc78757468fbe4bcc686196149ca521f2 Signed-off-by: Meng Wang --- config/lahainaautoconf.h | 3 ++- soc/swr-mstr-ctrl.c | 1 - soc/swr-mstr-registers.h | 45 +++++++++++++++++++++++++++------------- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/config/lahainaautoconf.h b/config/lahainaautoconf.h index 30876cd1a8c2..504fa3036bb7 100644 --- a/config/lahainaautoconf.h +++ b/config/lahainaautoconf.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0-only */ -/* Copyright (c) 2020, The Linux Foundation. All rights reserved. +/* Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. */ #define CONFIG_PINCTRL_LPI 1 @@ -43,3 +43,4 @@ #define CONFIG_SND_SWR_HAPTICS 1 #define CONFIG_DIGITAL_CDC_RSC_MGR 1 #define CONFIG_AUXPCM_DISABLE 1 +#define CONFIG_SWRM_VER_1P6 1 diff --git a/soc/swr-mstr-ctrl.c b/soc/swr-mstr-ctrl.c index 936ddc03825b..f0a9e94f8ffb 100644 --- a/soc/swr-mstr-ctrl.c +++ b/soc/swr-mstr-ctrl.c @@ -54,7 +54,6 @@ #define ERR_AUTO_SUSPEND_TIMER_VAL 0x1 -#define SWRM_INTERRUPT_STATUS_MASK 0x1FDFD #define SWRM_LINK_STATUS_RETRY_CNT 100 #define SWRM_ROW_48 48 diff --git a/soc/swr-mstr-registers.h b/soc/swr-mstr-registers.h index 9cb0e5f638b3..365a81405fe3 100644 --- a/soc/swr-mstr-registers.h +++ b/soc/swr-mstr-registers.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2015, 2018-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2015, 2018-2021 The Linux Foundation. All rights reserved. */ #ifndef _SWRM_REGISTERS_H @@ -18,24 +18,46 @@ #define MM_SYNC_CONFIG (SWRM_BASE+0x0108) #define SWRM_COMP_NPL_PARAMS (SWRM_BASE+0x0120) #define SWRM_INTERRUPT_STATUS (SWRM_BASE+0x0200) -#define SWRM_INTERRUPT_EN (SWRM_BASE+0x0204) #define SWRM_INTERRUPT_CLEAR (SWRM_BASE+0x0208) #define SWRM_INTERRUPT_STATUS_1 (SWRM_BASE+0x0220) -#define SWRM_INTERRUPT_EN_1 (SWRM_BASE+0x0224) #define SWRM_INTERRUPT_CLEAR_1 (SWRM_BASE+0x0228) #define SWRM_CPU1_INTERRUPT_EN (SWRM_BASE+0x0210) #define SWRM_CPU1_INTERRUPT_EN_1 (SWRM_BASE+0x0230) #define SWRM_CPU0_CMD_RESPONSE (SWRM_BASE+0x0250) -#define SWRM_CMD_FIFO_WR_CMD (SWRM_BASE+0x0300) -#define SWRM_CMD_FIFO_RD_CMD (SWRM_BASE+0x0304) -#define SWRM_CMD_FIFO_CMD (SWRM_BASE+0x0308) -#define SWRM_CMD_FIFO_STATUS (SWRM_BASE+0x030C) -#define SWRM_CMD_FIFO_CFG (SWRM_BASE+0x0314) -#define SWRM_CMD_FIFO_RD_FIFO (SWRM_BASE+0x0318) + #define SWRM_CPU1_CMD_FIFO_WR_CMD (SWRM_BASE+0x031C) #define SWRM_CPU1_CMD_FIFO_RD_CMD (SWRM_BASE+0x0320) #define SWRM_CPU1_CMD_FIFO_STATUS (SWRM_BASE+0x0328) #define SWRM_CPU1_CMD_FIFO_RD_FIFO (SWRM_BASE+0x0334) + +#ifdef CONFIG_SWRM_VER_1P6 +#define SWRM_INTERRUPT_EN SWRM_CPU1_INTERRUPT_EN +#define SWRM_INTERRUPT_EN_1 SWRM_CPU1_INTERRUPT_EN_1 +#define SWRM_CMD_FIFO_WR_CMD SWRM_CPU1_CMD_FIFO_WR_CMD +#define SWRM_CMD_FIFO_RD_CMD SWRM_CPU1_CMD_FIFO_RD_CMD +#define SWRM_CMD_FIFO_STATUS SWRM_CPU1_CMD_FIFO_STATUS +#define SWRM_CMD_FIFO_RD_FIFO SWRM_CPU1_CMD_FIFO_RD_FIFO +#define SWRM_INTERRUPT_STATUS_MASK 0x1FFDFD +#define SWRM_INTERRUPT_STATUS_RD_FIFO_OVERFLOW 0x40000 +#define SWRM_INTERRUPT_STATUS_RD_FIFO_UNDERFLOW 0x80000 +#define SWRM_INTERRUPT_STATUS_SPECIAL_CMD_ID_FINISHED 0x100000 +#define SWRM_INTERRUPT_MAX 0x20 +#else +#define SWRM_INTERRUPT_EN (SWRM_BASE+0x0204) +#define SWRM_INTERRUPT_EN_1 (SWRM_BASE+0x0224) +#define SWRM_CMD_FIFO_WR_CMD (SWRM_BASE+0x0300) +#define SWRM_CMD_FIFO_RD_CMD (SWRM_BASE+0x0304) +#define SWRM_CMD_FIFO_STATUS (SWRM_BASE+0x030C) +#define SWRM_CMD_FIFO_RD_FIFO (SWRM_BASE+0x0318) +#define SWRM_INTERRUPT_STATUS_MASK 0x1FDFD +#define SWRM_INTERRUPT_STATUS_RD_FIFO_OVERFLOW 0x10 +#define SWRM_INTERRUPT_STATUS_RD_FIFO_UNDERFLOW 0x20 +#define SWRM_INTERRUPT_STATUS_SPECIAL_CMD_ID_FINISHED 0x400 +#define SWRM_INTERRUPT_MAX 0x11 +#endif /* CONFIG_SWRM_VER_1P6 */ + +#define SWRM_CMD_FIFO_CMD (SWRM_BASE+0x0308) +#define SWRM_CMD_FIFO_CFG (SWRM_BASE+0x0314) #define SWRM_CPU_NUM_ENTRIES_WR_CMD_FIFO (SWRM_BASE+0x0370) #define SWRM_CPU0_SW_INTERRUPT_SET (SWRM_BASE+0x0374) #define SWRM_CPU0_SW_MESSAGE0 (SWRM_BASE+0x0384) @@ -82,13 +104,10 @@ #define SWRM_INTERRUPT_STATUS_NEW_SLAVE_ATTACHED 0x2 #define SWRM_INTERRUPT_STATUS_CHANGE_ENUM_SLAVE_STATUS 0x4 #define SWRM_INTERRUPT_STATUS_MASTER_CLASH_DET 0x8 -#define SWRM_INTERRUPT_STATUS_RD_FIFO_OVERFLOW 0x10 -#define SWRM_INTERRUPT_STATUS_RD_FIFO_UNDERFLOW 0x20 #define SWRM_INTERRUPT_STATUS_WR_CMD_FIFO_OVERFLOW 0x40 #define SWRM_INTERRUPT_STATUS_CMD_ERROR 0x80 #define SWRM_INTERRUPT_STATUS_DOUT_PORT_COLLISION 0x100 #define SWRM_INTERRUPT_STATUS_READ_EN_RD_VALID_MISMATCH 0x200 -#define SWRM_INTERRUPT_STATUS_SPECIAL_CMD_ID_FINISHED 0x400 #ifdef CONFIG_SWRM_VER_1P1 #define SWRM_INTERRUPT_STATUS_NEW_SLAVE_AUTO_ENUM_FINISHED 0x800 @@ -107,8 +126,6 @@ #define SWRM_INTERRUPT_STATUS_EXT_CLK_STOP_WAKEUP 0x10000 -#define SWRM_INTERRUPT_MAX 0x11 - #define SWRM_COMP_PARAMS_WR_FIFO_DEPTH 0x00007C00 #define SWRM_COMP_PARAMS_RD_FIFO_DEPTH 0x000F8000 #endif /* _SWRM_REGISTERS_H */ From 367bb7f3d52232b78e9d3947cd0d56fa7e9fa35d Mon Sep 17 00:00:00 2001 From: Hongtao Peng Date: Wed, 3 Nov 2021 19:42:41 +0800 Subject: [PATCH 24/82] asoc: fix compile warning of format-extra-args Delete the wrong, redundant log info Change-Id: Ifc20514d6e7342be7e67239a2f2f74b895de6c5c Signed-off-by: Hongtao Peng --- asoc/gvm_auto_spf_dummy.c | 1 - 1 file changed, 1 deletion(-) diff --git a/asoc/gvm_auto_spf_dummy.c b/asoc/gvm_auto_spf_dummy.c index fc3caba9b82e..dee97dcd5d62 100644 --- a/asoc/gvm_auto_spf_dummy.c +++ b/asoc/gvm_auto_spf_dummy.c @@ -518,7 +518,6 @@ static int msm_asoc_machine_probe(struct platform_device *pdev) if (ret) { dev_err(&pdev->dev, "parse card name failed, err:%d\n", ret); - pr_err("parse card name failed, err:%d\n", __func__, ret); goto err; } From 219d95722373d4908284a22561be0670336c2d0a Mon Sep 17 00:00:00 2001 From: Susan Wang Date: Tue, 28 Sep 2021 15:33:18 -0400 Subject: [PATCH 25/82] config: sa8155/sa6155/gvmq: remove unused config vars - Removes CONFIG variables for DTS Eagle and Dolby that are no longer used. Change-Id: I401d10d16040413bf0d170aafb15f547de1ba3ad Signed-off-by: Susan Wang --- config/gvmauto.conf | 3 --- config/gvmautoconf.h | 5 +---- config/sa6155auto.conf | 3 --- config/sa6155autoconf.h | 3 --- config/sa8155auto.conf | 3 --- config/sa8155autoconf.h | 5 +---- 6 files changed, 2 insertions(+), 20 deletions(-) diff --git a/config/gvmauto.conf b/config/gvmauto.conf index 1cdc7b30eddb..36eb6be8a26f 100644 --- a/config/gvmauto.conf +++ b/config/gvmauto.conf @@ -11,9 +11,6 @@ export CONFIG_SND_SOC_MSM_QDSP6V2_VM=m export CONFIG_SND_SOC_QDSP6V2=m export CONFIG_QTI_PP=m export CONFIG_SND_HWDEP_ROUTING=m -export CONFIG_DTS_EAGLE=m -export CONFIG_DOLBY_DS2=m -export CONFIG_DOLBY_LICENSE=m export CONFIG_SND_SOC_MSM_STUB=m export CONFIG_SND_SOC_MSM_HDMI_CODEC_RX=m export CONFIG_MSM_QDSP6V2_CODECS=m diff --git a/config/gvmautoconf.h b/config/gvmautoconf.h index fb47aecd21cb..6e28cae199ca 100644 --- a/config/gvmautoconf.h +++ b/config/gvmautoconf.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. +/* Copyright (c) 2018-2019, 2021 The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -19,9 +19,6 @@ #define CONFIG_SND_SOC_QDSP6V2 1 #define CONFIG_QTI_PP 1 #define CONFIG_SND_HWDEP_ROUTING 1 -#define CONFIG_DTS_EAGLE 1 -#define CONFIG_DOLBY_DS2 1 -#define CONFIG_DOLBY_LICENSE 1 #define CONFIG_SND_SOC_MSM_STUB 1 #define CONFIG_SND_SOC_MSM_HDMI_CODEC_RX 1 #define CONFIG_MSM_QDSP6V2_CODECS 1 diff --git a/config/sa6155auto.conf b/config/sa6155auto.conf index 8ffbf3a70c09..70c8f3c7e777 100644 --- a/config/sa6155auto.conf +++ b/config/sa6155auto.conf @@ -5,9 +5,6 @@ export CONFIG_MSM_QDSP6_NOTIFIER=m export CONFIG_SND_SOC_MSM_QDSP6V2_INTF=m export CONFIG_QTI_PP=m export CONFIG_SND_HWDEP_ROUTING=m -export CONFIG_DTS_EAGLE=m -export CONFIG_DOLBY_DS2=m -export CONFIG_DOLBY_LICENSE=m export CONFIG_SND_SOC_MSM_STUB=m export CONFIG_SND_SOC_MSM_HDMI_CODEC_RX=m export CONFIG_MSM_QDSP6V2_CODECS=m diff --git a/config/sa6155autoconf.h b/config/sa6155autoconf.h index 67799e17fdc7..26730c6064c9 100644 --- a/config/sa6155autoconf.h +++ b/config/sa6155autoconf.h @@ -17,9 +17,6 @@ #define CONFIG_SND_SOC_MSM_QDSP6V2_INTF 1 #define CONFIG_QTI_PP 1 #define CONFIG_SND_HWDEP_ROUTING 1 -#define CONFIG_DTS_EAGLE 1 -#define CONFIG_DOLBY_DS2 1 -#define CONFIG_DOLBY_LICENSE 1 #define CONFIG_SND_SOC_MSM_STUB 1 #define CONFIG_SND_SOC_MSM_HDMI_CODEC_RX 1 #define CONFIG_MSM_QDSP6V2_CODECS 1 diff --git a/config/sa8155auto.conf b/config/sa8155auto.conf index fc7057eb6c64..f11ce881c3b2 100644 --- a/config/sa8155auto.conf +++ b/config/sa8155auto.conf @@ -6,9 +6,6 @@ export CONFIG_SND_SOC_MSM_QDSP6V2_INTF=m export CONFIG_SND_SOC_QDSP6V2=m export CONFIG_QTI_PP=m export CONFIG_SND_HWDEP_ROUTING=m -export CONFIG_DTS_EAGLE=m -export CONFIG_DOLBY_DS2=m -export CONFIG_DOLBY_LICENSE=m export CONFIG_SND_SOC_MSM_STUB=m export CONFIG_SND_SOC_MSM_HDMI_CODEC_RX=m export CONFIG_MSM_QDSP6V2_CODECS=m diff --git a/config/sa8155autoconf.h b/config/sa8155autoconf.h index 7470fc6b5cd2..8557d8bd8644 100644 --- a/config/sa8155autoconf.h +++ b/config/sa8155autoconf.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0-only */ -/* Copyright (c) 2019, The Linux Foundation. All rights reserved. +/* Copyright (c) 2019, 2021 The Linux Foundation. All rights reserved. */ #define CONFIG_MSM_QDSP6_APRV2_RPMSG 1 @@ -10,9 +10,6 @@ #define CONFIG_SND_SOC_QDSP6V2 1 #define CONFIG_QTI_PP 1 #define CONFIG_SND_HWDEP_ROUTING 1 -#define CONFIG_DTS_EAGLE 1 -#define CONFIG_DOLBY_DS2 1 -#define CONFIG_DOLBY_LICENSE 1 #define CONFIG_SND_SOC_MSM_STUB 1 #define CONFIG_SND_SOC_MSM_HDMI_CODEC_RX 1 #define CONFIG_MSM_QDSP6V2_CODECS 1 From 4506302e7dddc7406d2faf2a85503524f4f68985 Mon Sep 17 00:00:00 2001 From: Meng Wang Date: Thu, 28 Oct 2021 13:16:56 +0800 Subject: [PATCH 26/82] asoc: codec: enable use_single_read for wsa and wcd regmap When interrupts are triggered on the second or third interrupt status register, current logic cannot clear that interrupt status after handling it. Enable use_single_read for wsa and wcd regmap to resolve the issue. Change-Id: I31b301e70fc51c86302f80baeec82c865e9a25cd Signed-off-by: Meng Wang --- asoc/codecs/wcd937x/wcd937x-regmap.c | 3 ++- asoc/codecs/wcd938x/wcd938x-regmap.c | 3 ++- asoc/codecs/wsa883x/wsa883x-regmap.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/asoc/codecs/wcd937x/wcd937x-regmap.c b/asoc/codecs/wcd937x/wcd937x-regmap.c index ec29826d58cc..0bbc4b8a8a96 100644 --- a/asoc/codecs/wcd937x/wcd937x-regmap.c +++ b/asoc/codecs/wcd937x/wcd937x-regmap.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2018-2019, 2021, The Linux Foundation. All rights reserved. */ #include @@ -461,4 +461,5 @@ struct regmap_config wcd937x_regmap_config = { .writeable_reg = wcd937x_writeable_register, .volatile_reg = wcd937x_volatile_register, .can_multi_write = true, + .use_single_read = true, }; diff --git a/asoc/codecs/wcd938x/wcd938x-regmap.c b/asoc/codecs/wcd938x/wcd938x-regmap.c index 6f59258331a0..bfa38b4527e9 100644 --- a/asoc/codecs/wcd938x/wcd938x-regmap.c +++ b/asoc/codecs/wcd938x/wcd938x-regmap.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2018-2019, 2021, The Linux Foundation. All rights reserved. */ #include @@ -512,4 +512,5 @@ struct regmap_config wcd938x_regmap_config = { .writeable_reg = wcd938x_writeable_register, .volatile_reg = wcd938x_volatile_register, .can_multi_write = true, + .use_single_read = true, }; diff --git a/asoc/codecs/wsa883x/wsa883x-regmap.c b/asoc/codecs/wsa883x/wsa883x-regmap.c index a7e1e81add20..ea7e3a857b5b 100644 --- a/asoc/codecs/wsa883x/wsa883x-regmap.c +++ b/asoc/codecs/wsa883x/wsa883x-regmap.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2015-2016, 2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2015-2016, 2019, 2021, The Linux Foundation. All rights reserved. */ #include @@ -400,4 +400,5 @@ struct regmap_config wsa883x_regmap_config = { .reg_format_endian = REGMAP_ENDIAN_NATIVE, .val_format_endian = REGMAP_ENDIAN_NATIVE, .can_multi_write = true, + .use_single_read = true, }; From 26309ed1722d01dd24c933364e3fc87737b1ff86 Mon Sep 17 00:00:00 2001 From: Zun Qiao Date: Mon, 15 Nov 2021 13:39:51 +0530 Subject: [PATCH 27/82] asoc: fix error for VA_CDC_DMA_TX_0 for bengal - Fix msm_int_audrx_init API called repeatedly during the sound card registration stage. Change-Id: I71828fe6b026432a77b46b383d8c9e97371fb814 Signed-off-by: Zun Qiao --- asoc/bengal.c | 1 - 1 file changed, 1 deletion(-) diff --git a/asoc/bengal.c b/asoc/bengal.c index f0b9e840f2ca..14db00a17016 100644 --- a/asoc/bengal.c +++ b/asoc/bengal.c @@ -5392,7 +5392,6 @@ static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = { .ignore_suspend = 1, .ops = &msm_cdc_dma_be_ops, SND_SOC_DAILINK_REG(rx_dma_rx0), - .init = &msm_int_audrx_init, }, { .name = LPASS_BE_RX_CDC_DMA_RX_1, From 55fdf543d29a7c2ac8a2ec1e57bcadfc0f13ecf9 Mon Sep 17 00:00:00 2001 From: Soumya Managoli Date: Tue, 19 Oct 2021 14:17:05 +0530 Subject: [PATCH 28/82] ASoC: wcd937x: Update EAR PA CnP FSM sequence EAR PA short switch is not released after PA is turned on and off. Address this hardware issue by updating the EAR PA CnP FSM while EAR power down sequence. Change-Id: If4269c30c13572db1b252f223368d444b9250901 Signed-off-by: Soumya Managoli --- asoc/codecs/wcd937x/wcd937x.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/asoc/codecs/wcd937x/wcd937x.c b/asoc/codecs/wcd937x/wcd937x.c index c1b6c898203e..7dbc9e9d93b2 100644 --- a/asoc/codecs/wcd937x/wcd937x.c +++ b/asoc/codecs/wcd937x/wcd937x.c @@ -1055,6 +1055,22 @@ static int wcd937x_codec_enable_ear_pa(struct snd_soc_dapm_widget *w, snd_soc_component_update_bits(component, WCD937X_DIGITAL_PDM_WD_CTL0, 0x17, 0x00); + usleep_range(10000, 10010); + /* disable EAR CnP FSM */ + snd_soc_component_update_bits(component, + WCD937X_EAR_EAR_EN_REG, + 0x02, 0x00); + /* toggle EAR PA to let PA control registers take effect */ + snd_soc_component_update_bits(component, + WCD937X_ANA_EAR, + 0x80, 0x80); + snd_soc_component_update_bits(component, + WCD937X_ANA_EAR, + 0x80, 0x00); + /* enable EAR CnP FSM */ + snd_soc_component_update_bits(component, + WCD937X_EAR_EAR_EN_REG, + 0x02, 0x02); break; }; return ret; From 8985f86c676121fd4771275837f63a2a152278b7 Mon Sep 17 00:00:00 2001 From: Hongtao Peng Date: Thu, 25 Nov 2021 11:46:33 +0800 Subject: [PATCH 29/82] soc: add snd_event_init func for mark audio KPI snd_event_dlkm is loaded as the first module. Add init function and place mark in it to indicate the start time of audio driver initialization. Change-Id: Ie0c85b9166686d91f71ff773224eca59d85a36e5 Signed-off-by: Hongtao Peng --- soc/snd_event.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/soc/snd_event.c b/soc/snd_event.c index ace76b2e85a7..abc450405fe1 100644 --- a/soc/snd_event.c +++ b/soc/snd_event.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2018, 2021 The Linux Foundation. All rights reserved. */ #include @@ -8,6 +8,7 @@ #include #include #include +#include struct snd_event_client { struct list_head node; @@ -490,5 +491,17 @@ exit: } EXPORT_SYMBOL(snd_event_notify); +static int __init snd_event_init(void) +{ + place_marker("M - Driver Sound Event Init"); + return 0; +} +module_init(snd_event_init); + +static void __exit snd_event_exit(void) +{ +} +module_exit(snd_event_exit); + MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("SND event module"); From 0a9ad4c3a95810dd318c6463a948a01f03cb087a Mon Sep 17 00:00:00 2001 From: ftong Date: Thu, 25 Nov 2021 12:02:14 +0800 Subject: [PATCH 30/82] ASoC: msm: Fix ASRC port type mismatch Dir is empty when assign value to TX path port type Fix port type assignment. Change-Id: If6c3f7d2cb5785e02a5cde1538b1e394c0e8e8e5 Signed-off-by: ftong --- asoc/msm-pcm-routing-v2.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/asoc/msm-pcm-routing-v2.c b/asoc/msm-pcm-routing-v2.c index 84df3903b124..b82ce44cb7af 100755 --- a/asoc/msm-pcm-routing-v2.c +++ b/asoc/msm-pcm-routing-v2.c @@ -42365,8 +42365,7 @@ static int asrc_get_module_location(struct asrc_module_config_params *params, unsigned long copp = -1; bool copp_is_found = false; struct msm_pcm_routing_bdai_data *bedai = NULL; - int port_type = (dir == SESSION_TYPE_RX) ? MSM_AFE_PORT_TYPE_RX : - MSM_AFE_PORT_TYPE_TX; + int port_type = -1; mutex_lock(&routing_lock); @@ -42380,6 +42379,10 @@ static int asrc_get_module_location(struct asrc_module_config_params *params, dir = params->dir; be_id = params->be_id; bedai = &msm_bedais[be_id]; + + port_type = (dir == SESSION_TYPE_RX) ? MSM_AFE_PORT_TYPE_RX : + MSM_AFE_PORT_TYPE_TX; + if (afe_get_port_type(bedai->port_id) != port_type) { pr_err("%s: port_type not match: be_dai %d type %d\n", __func__, be_id, port_type); From f19f6fe7ded1dde9296c13e00a746566b4861613 Mon Sep 17 00:00:00 2001 From: Subhadra Jagadeesan Date: Fri, 3 Dec 2021 12:36:48 +0530 Subject: [PATCH 31/82] dsp:q6afe: Fix avcs load module failure for aptx Fix for the avcs load module failure for ASM_MEDIA_FMT_APTX_ADAPTIVE codec format as it uses incorrect AVS_MODULE_ID_DEPACKETIZER_COP_V2. Added seperate condition and just call goto load_unload, so that it uses AVS_MODULE_ID_DEPACKETIZER_COP_V1 assigned before. Change-Id: I07176da41491cabdd3ad4df23b409d11b95a2764 Signed-off-by: Subhadra Jagadeesan --- dsp/q6afe.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dsp/q6afe.c b/dsp/q6afe.c index 81c783b84e73..50edc164f72b 100755 --- a/dsp/q6afe.c +++ b/dsp/q6afe.c @@ -443,12 +443,14 @@ static int q6afe_load_avcs_modules(int num_modules, u16 port_id, AVS_MODULE_ID_DEPACKETIZER_COP; goto load_unload; } - if (format_id == ASM_MEDIA_FMT_LC3 || - format_id == ASM_MEDIA_FMT_APTX_ADAPTIVE) { + if (format_id == ASM_MEDIA_FMT_LC3) { pm[i]->payload->load_unload_info[0].id1 = AVS_MODULE_ID_DEPACKETIZER_COP_V2; goto load_unload; } + if (format_id == ASM_MEDIA_FMT_APTX_ADAPTIVE) { + goto load_unload; + } pm[i]->payload->load_unload_info[1].module_type = AMDB_MODULE_TYPE_DECODER; From 3bc09aab6e2e0c0734df736e6cc2c0d2d94d8b92 Mon Sep 17 00:00:00 2001 From: Sujin Panicker Date: Wed, 8 Dec 2021 15:50:27 +0530 Subject: [PATCH 32/82] dsp: Make synchronous call to unmap afe cal data On multiple async unmap_cal calls there are chances hlos releases the ion memory while adsp is still under going the unmap process, in such cases there could be smmu fault due to dsp accessing memory region which is already released by the hlos. Fix this by making synchronous unmap calls to adsp. Change-Id: I88082e989884446546de846097ad7b031496830e Signed-off-by: Sujin Panicker --- dsp/q6afe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dsp/q6afe.c b/dsp/q6afe.c index 81c783b84e73..5ebf3e77c185 100755 --- a/dsp/q6afe.c +++ b/dsp/q6afe.c @@ -11582,7 +11582,7 @@ static int afe_unmap_cal_data(int32_t cal_type, atomic_set(&this_afe.mem_map_cal_handles[cal_index], cal_block->map_data.q6map_handle); atomic_set(&this_afe.mem_map_cal_index, cal_index); - ret = afe_cmd_memory_unmap_nowait( + ret = afe_cmd_memory_unmap( cal_block->map_data.q6map_handle); atomic_set(&this_afe.mem_map_cal_index, -1); if (ret < 0) { From ffc848f7bf2df3827804687445c16d6729fe5f7b Mon Sep 17 00:00:00 2001 From: Hugh Guan Date: Tue, 7 Dec 2021 11:43:50 -0800 Subject: [PATCH 33/82] asoc: QUAT TDM support for dummy machine driver Adding QUAT TDM DAI links for dummy machine driver. Signed-off-by: Hugh Guan Change-Id: I0388374cb2f4b84bdacf8e40828d1e48e42bc442 --- asoc/gvm_auto_spf_dummy.c | 200 +++++++++++++++++++++++--------------- asoc/msm_dailink.h | 12 ++- 2 files changed, 131 insertions(+), 81 deletions(-) diff --git a/asoc/gvm_auto_spf_dummy.c b/asoc/gvm_auto_spf_dummy.c index dee97dcd5d62..aeb6184d47c6 100644 --- a/asoc/gvm_auto_spf_dummy.c +++ b/asoc/gvm_auto_spf_dummy.c @@ -218,90 +218,130 @@ static const struct snd_soc_dapm_widget msm_dapm_widgets[] = { /* Digital audio interface glue - connects codec <---> CPU */ static struct snd_soc_dai_link msm_common_dai_links[] = { /* BackEnd DAI Links */ - { - .name = "TERT_TDM_RX_0_DUMMY", - .stream_name = "TDM-LPAIF-RX-TERTIARY", - .dpcm_playback = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, - SND_SOC_DAILINK_REG(tert_tdm_rx_0_dummy), - }, - { - .name = "TERT_TDM_TX_0_DUMMY", - .stream_name = "TDM-LPAIF-TX-TERTIARY", - .dpcm_capture = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, - SND_SOC_DAILINK_REG(tert_tdm_tx_0_dummy), - }, - { - .name = "LPASS_BE_AUXPCM_RX_DUMMY", - .stream_name = "AUXPCM-LPAIF-RX-PRIMARY", - .dpcm_playback = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, - SND_SOC_DAILINK_REG(lpass_be_auxpcm_rx_dummy), - }, - { - .name = "LPASS_BE_AUXPCM_TX_DUMMY", - .stream_name = "AUXPCM-LPAIF-TX-PRIMARY", - .dpcm_capture = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, - SND_SOC_DAILINK_REG(lpass_be_auxpcm_tx_dummy), - }, + { + .name = "TERT_TDM_RX_0_DUMMY", + .stream_name = "TDM-LPAIF-RX-TERTIARY", + .dpcm_playback = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(tert_tdm_rx_0_dummy), + }, + { + .name = "TERT_TDM_TX_0_DUMMY", + .stream_name = "TDM-LPAIF-TX-TERTIARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(tert_tdm_tx_0_dummy), + }, + { + .name = "LPASS_BE_AUXPCM_RX_DUMMY", + .stream_name = "AUXPCM-LPAIF-RX-PRIMARY", + .dpcm_playback = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(lpass_be_auxpcm_rx_dummy), + }, + { + .name = "LPASS_BE_AUXPCM_TX_DUMMY", + .stream_name = "AUXPCM-LPAIF-TX-PRIMARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(lpass_be_auxpcm_tx_dummy), + }, + { + .name = "QUAT_TDM_RX_0_DUMMY", + .stream_name = "TDM-LPAIF-RX-QUATERNARY", + .dpcm_playback = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(quat_tdm_rx_0_dummy), + }, + { + .name = "QUAT_TDM_TX_0_DUMMY", + .stream_name = "TDM-LPAIF-TX-QUATERNARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(quat_tdm_tx_0_dummy), + }, }; static struct snd_soc_dai_link msm_talos_dai_links[] = { /* BackEnd DAI Links */ - { - .name = "PRIMARY_TDM_RX_0_DUMMY", - .stream_name = "TDM-LPAIF_WSA-RX-PRIMARY", - .dpcm_playback = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, - SND_SOC_DAILINK_REG(primary_tdm_rx_0_dummy), - }, - { - .name = "PRIMARY_TDM_TX_0_DUMMY", - .stream_name = "TDM-LPAIF_WSA-TX-PRIMARY", - .dpcm_capture = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, - SND_SOC_DAILINK_REG(primary_tdm_tx_0_dummy), - }, - { - .name = "LPASS_BE_AUXPCM_RX_DUMMY", - .stream_name = "AUXPCM-LPAIF-RX-PRIMARY", - .dpcm_playback = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, - SND_SOC_DAILINK_REG(lpass_be_auxpcm_rx_dummy), - }, - { - .name = "LPASS_BE_AUXPCM_TX_DUMMY", - .stream_name = "AUXPCM-LPAIF-TX-PRIMARY", - .dpcm_capture = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, - SND_SOC_DAILINK_REG(lpass_be_auxpcm_tx_dummy), - }, + { + .name = "PRIMARY_TDM_RX_0_DUMMY", + .stream_name = "TDM-LPAIF_WSA-RX-PRIMARY", + .dpcm_playback = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(primary_tdm_rx_0_dummy), + }, + { + .name = "PRIMARY_TDM_TX_0_DUMMY", + .stream_name = "TDM-LPAIF_WSA-TX-PRIMARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(primary_tdm_tx_0_dummy), + }, + { + .name = "LPASS_BE_AUXPCM_RX_DUMMY", + .stream_name = "AUXPCM-LPAIF-RX-PRIMARY", + .dpcm_playback = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(lpass_be_auxpcm_rx_dummy), + }, + { + .name = "LPASS_BE_AUXPCM_TX_DUMMY", + .stream_name = "AUXPCM-LPAIF-TX-PRIMARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(lpass_be_auxpcm_tx_dummy), + }, + { + .name = "QUAT_TDM_RX_0_DUMMY", + .stream_name = "TDM-LPAIF-RX-QUATERNARY", + .dpcm_playback = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(quat_tdm_rx_0_dummy), + }, + { + .name = "QUAT_TDM_TX_0_DUMMY", + .stream_name = "TDM-LPAIF-TX-QUATERNARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(quat_tdm_tx_0_dummy), + }, }; struct snd_soc_card snd_soc_card_auto_hana_dummy_msm = { diff --git a/asoc/msm_dailink.h b/asoc/msm_dailink.h index 1b0b365592c5..e68ef77e2d74 100644 --- a/asoc/msm_dailink.h +++ b/asoc/msm_dailink.h @@ -1315,6 +1315,16 @@ SND_SOC_DAILINK_DEFS(tert_tdm_tx_0_dummy, DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); +SND_SOC_DAILINK_DEFS(quat_tdm_rx_0_dummy, + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + +SND_SOC_DAILINK_DEFS(quat_tdm_tx_0_dummy, + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + SND_SOC_DAILINK_DEFS(lpass_be_auxpcm_rx_dummy, DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), @@ -1333,4 +1343,4 @@ SND_SOC_DAILINK_DEFS(primary_tdm_rx_0_dummy, SND_SOC_DAILINK_DEFS(primary_tdm_tx_0_dummy, DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), - DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); \ No newline at end of file + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); From a414026224a1edc34476d79e5af758e949ee9dd6 Mon Sep 17 00:00:00 2001 From: Hugh Guan Date: Tue, 14 Dec 2021 10:00:32 -0800 Subject: [PATCH 34/82] asoc: msm_stub: increase the max ch to 32 Increase the max ch to 32 for TDM interface. Signed-off-by: Hugh Guan Change-Id: I85bfaa68525668b8ffc9d929bdcf38126cb06c9f --- asoc/codecs/msm_stub.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/asoc/codecs/msm_stub.c b/asoc/codecs/msm_stub.c index cf91f2a6de1b..69fa6bf62b5e 100644 --- a/asoc/codecs/msm_stub.c +++ b/asoc/codecs/msm_stub.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2011-2014, 2017-2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved. */ #include #include @@ -18,7 +19,7 @@ static struct snd_soc_dai_driver msm_stub_dais[] = { .playback = { /* Support maximum range */ .stream_name = "Playback", .channels_min = 1, - .channels_max = 8, + .channels_max = 32, .rates = SNDRV_PCM_RATE_8000_48000, .formats = SNDRV_PCM_FMTBIT_S16_LE, }, @@ -28,7 +29,7 @@ static struct snd_soc_dai_driver msm_stub_dais[] = { .capture = { /* Support maximum range */ .stream_name = "Record", .channels_min = 1, - .channels_max = 8, + .channels_max = 32, .rates = SNDRV_PCM_RATE_8000_48000, .formats = (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE), From 2bd9cc0f5ef78f3704eaff31f92a1d00871a7e22 Mon Sep 17 00:00:00 2001 From: Zun Qiao Date: Mon, 22 Nov 2021 19:51:22 +0530 Subject: [PATCH 35/82] asoc: bengal: fix dailink init error -Fix the problem that the API snd_soc_rtdcom_lookup that wcd937x component is empty during the call of VA_CDC_DMA_TX_0 dai-link .init . -Put the call of API snd_soc_rtdcom_lookup to find wcd937x component into RX_CDC_DMA_RX_0 .init . Change-Id: Ic0565742e462a78cd4ac90fb9e1a788b2ed15ab7 Signed-off-by: Zun Qiao Signed-off-by: Dechen Chai --- asoc/bengal.c | 55 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/asoc/bengal.c b/asoc/bengal.c index 14db00a17016..2fff3ff5d19b 100644 --- a/asoc/bengal.c +++ b/asoc/bengal.c @@ -557,6 +557,7 @@ static void *def_wcd_mbhc_cal(void); static void *def_rouleur_mbhc_cal(void); static int msm_int_audrx_init(struct snd_soc_pcm_runtime*); +static int msm_aux_codec_init(struct snd_soc_pcm_runtime*); /* * Need to report LINEIN @@ -4260,25 +4261,19 @@ static void msm_add_auxpcm_snd_controls(struct snd_soc_component *component) static int msm_int_audrx_init(struct snd_soc_pcm_runtime *rtd) { - int ret = -EINVAL; - struct snd_soc_component *component; - struct snd_soc_component *bolero_component = NULL; - struct snd_soc_dapm_context *dapm; - struct snd_card *card; - struct snd_info_entry *entry; - struct platform_device *pdev = NULL; - int i = 0; - char *data = NULL; + struct snd_soc_component *component = NULL; + struct snd_soc_dapm_context *dapm = NULL; + struct snd_card *card = NULL; + struct snd_info_entry *entry = NULL; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(rtd->card); + int ret = -EINVAL; component = snd_soc_rtdcom_lookup(rtd, "bolero_codec"); if (!component) { pr_err("%s: could not find component for bolero_codec\n", __func__); return ret; - } else { - bolero_component = component; } dapm = snd_soc_component_get_dapm(component); @@ -4333,6 +4328,29 @@ static int msm_int_audrx_init(struct snd_soc_pcm_runtime *rtd) bolero_info_create_codec_entry(pdata->codec_root, component); bolero_register_wake_irq(component, false); +err: + return ret; +} + +static int msm_aux_codec_init(struct snd_soc_pcm_runtime *rtd) +{ + int ret = -EINVAL; + struct snd_soc_component *component = NULL; + struct snd_soc_component *bolero_component = NULL; + struct snd_soc_dapm_context *dapm = NULL; + struct snd_card *card = NULL; + struct snd_info_entry *entry; + char *data = NULL; + struct msm_asoc_mach_data *pdata = + snd_soc_card_get_drvdata(rtd->card); + + bolero_component = snd_soc_rtdcom_lookup(rtd, "bolero_codec"); + if (!bolero_component) { + pr_err("%s: could not find component for bolero_codec\n", + __func__); + return -EINVAL; + } + component = snd_soc_rtdcom_lookup(rtd, ROULEUR_DRV_NAME); if (!component) component = snd_soc_rtdcom_lookup(rtd, WCD937X_DRV_NAME); @@ -4356,6 +4374,18 @@ static int msm_int_audrx_init(struct snd_soc_pcm_runtime *rtd) snd_soc_dapm_ignore_suspend(dapm, "AMIC4"); snd_soc_dapm_sync(dapm); + if (!pdata->codec_root) { + entry = msm_snd_info_create_subdir(card->module, "codecs", + card->proc_root); + if (!entry) { + dev_dbg(component->dev, "%s: Cannot create codecs module entry\n", + __func__); + ret = 0; + goto err; + } + pdata->codec_root = entry; + } + if (wcd_datalane_mismatch) { bolero_set_port_map(component, ARRAY_SIZE(sm_port_map_khaje), @@ -5392,6 +5422,7 @@ static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = { .ignore_suspend = 1, .ops = &msm_cdc_dma_be_ops, SND_SOC_DAILINK_REG(rx_dma_rx0), + .init = &msm_aux_codec_init, }, { .name = LPASS_BE_RX_CDC_DMA_RX_1, @@ -5469,12 +5500,12 @@ static struct snd_soc_dai_link msm_va_cdc_dma_be_dai_links[] = { .stream_name = "VA CDC DMA0 Capture", .no_pcm = 1, .dpcm_capture = 1, - .init = &msm_int_audrx_init, .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_0, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_suspend = 1, .ops = &msm_cdc_dma_be_ops, SND_SOC_DAILINK_REG(va_dma_tx0), + .init = &msm_int_audrx_init, }, { .name = LPASS_BE_VA_CDC_DMA_TX_1, From 77b6d4fece595b53e02b8b631b223bbf8d2db80e Mon Sep 17 00:00:00 2001 From: Hexuan Zhu Date: Tue, 7 Dec 2021 08:27:03 +0800 Subject: [PATCH 36/82] audio-kernel: lvgvm 8295 related file modify Add qtigvmi3 in makefile and add snd card prob for lvgvm Change-Id: Ia7de956a4495f985623d15916bb2df665b77446b Signed-off-by: Hexuan Zhu --- Makefile.am | 4 +- asoc/gvm_auto_spf_dummy.c | 177 ++++++++++++++++++++++++++++++++++++-- asoc/msm_dailink.h | 40 +++++++++ 3 files changed, 210 insertions(+), 11 deletions(-) mode change 100644 => 100755 Makefile.am mode change 100644 => 100755 asoc/gvm_auto_spf_dummy.c mode change 100644 => 100755 asoc/msm_dailink.h diff --git a/Makefile.am b/Makefile.am old mode 100644 new mode 100755 index 2b135ca2fefd..ccbb7a2c7aeb --- a/Makefile.am +++ b/Makefile.am @@ -43,7 +43,7 @@ obj-m += asoc/codecs/bolero/ obj-m += asoc/codecs/wcd937x/ endif -ifeq ($(TARGET_SUPPORT), $(filter $(TARGET_SUPPORT), sa8155 sa8155ivi sa6155 sa8195 qtiquingvm qtiquingvm8295 sa8295)) +ifeq ($(TARGET_SUPPORT), $(filter $(TARGET_SUPPORT), sa8155 sa8155ivi sa6155 sa8195 qtiquingvm qtiquingvm8295 sa8295 qtigvmi3)) KBUILD_OPTIONS += CONFIG_SND_SOC_AUTO=y obj-m := ipc/ obj-m += dsp/ @@ -56,7 +56,7 @@ endif ifeq ($(TARGET_SUPPORT), $(filter $(TARGET_SUPPORT), sa6155)) KBUILD_OPTIONS += CONFIG_SND_SOC_SA6155=m endif -ifeq ($(TARGET_SUPPORT), $(filter $(TARGET_SUPPORT), qtiquingvm)) +ifeq ($(TARGET_SUPPORT), $(filter $(TARGET_SUPPORT), qtiquingvm qtigvmi3)) KBUILD_OPTIONS += CONFIG_SND_SOC_GVM=m endif ifeq ($(TARGET_SUPPORT), $(filter $(TARGET_SUPPORT), qtiquingvm8295)) diff --git a/asoc/gvm_auto_spf_dummy.c b/asoc/gvm_auto_spf_dummy.c old mode 100644 new mode 100755 index aeb6184d47c6..e081007b221c --- a/asoc/gvm_auto_spf_dummy.c +++ b/asoc/gvm_auto_spf_dummy.c @@ -280,6 +280,150 @@ static struct snd_soc_dai_link msm_common_dai_links[] = { }, }; +static struct snd_soc_dai_link msm_gvm8295_dai_links[] = { + /* BackEnd DAI Links */ + { + .name = "PRI_TDM_RX_0_DUMMY", + .stream_name = "TDM-LPAIF-RX-PRIMARY", + .dpcm_playback = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(primary_tdm_rx_0_dummy), + }, + { + .name = "PRI_TDM_TX_0_DUMMY", + .stream_name = "TDM-LPAIF-TX-PRIMARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(primary_tdm_tx_0_dummy), + }, + { + .name = "SEC_TDM_RX_0_DUMMY", + .stream_name = "TDM-LPAIF-RX-SECONDARY", + .dpcm_playback = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(secondary_tdm_rx_0_dummy), + }, + { + .name = "SEC_TDM_TX_0_DUMMY", + .stream_name = "TDM-LPAIF-TX-SECONDARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(secondary_tdm_tx_0_dummy), + }, + { + .name = "TERT_TDM_RX_0_DUMMY", + .stream_name = "TDM-LPAIF-RX-TERTIARY", + .dpcm_playback = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(tert_tdm_rx_0_dummy), + }, + { + .name = "TERT_TDM_TX_0_DUMMY", + .stream_name = "TDM-LPAIF-TX-TERTIARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(tert_tdm_tx_0_dummy), + }, + { + .name = "QUAT_TDM_RX_0_DUMMY", + .stream_name = "TDM-LPAIF-RX-QUATERNARY", + .dpcm_playback = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(quat_tdm_rx_0_dummy), + }, + { + .name = "QUAT_TDM_TX_0_DUMMY", + .stream_name = "TDM-LPAIF-TX-QUATERNARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(quat_tdm_tx_0_dummy), + }, + { + .name = "QUIN_TDM_RX_0_DUMMY", + .stream_name = "TDM-LPAIF-RX-QUINARY", + .dpcm_playback = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(quin_tdm_rx_0_dummy), + }, + { + .name = "QUIN_TDM_TX_0_DUMMY", + .stream_name = "TDM-LPAIF-TX-QUINARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(quin_tdm_tx_0_dummy), + }, + { + .name = "SEN_TDM_RX_0_DUMMY", + .stream_name = "TDM-LPAIF-RX-SENARY", + .dpcm_playback = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(sen_tdm_rx_0_dummy), + }, + { + .name = "SEN_TDM_TX_0_DUMMY", + .stream_name = "TDM-LPAIF-TX-SENARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(sen_tdm_tx_0_dummy), + }, + { + .name = "SEP_TDM_RX_0_DUMMY", + .stream_name = "TDM-LPAIF-RX-SEPTENARY", + .dpcm_playback = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(sep_tdm_rx_0_dummy), + }, + { + .name = "SEP_TDM_TX_0_DUMMY", + .stream_name = "TDM-LPAIF-TX-SEPTENARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(sep_tdm_tx_0_dummy), + }, +}; + static struct snd_soc_dai_link msm_talos_dai_links[] = { /* BackEnd DAI Links */ { @@ -352,6 +496,10 @@ struct snd_soc_card snd_soc_card_auto_talos_dummy_msm = { .name = "gvmauto-6155-snd-card", }; +struct snd_soc_card snd_soc_card_auto_makena_dummy_msm = { + .name = "gvmauto-8295-snd-card", +}; + static int msm_populate_dai_link_component_of_node( struct snd_soc_card *card) { @@ -370,9 +518,9 @@ static int msm_populate_dai_link_component_of_node( continue; /* populate platform_of_node for snd card dai links Skip this part for dummy snd card*/ - if(0) { - if (dai_link[i].platforms->name && - !dai_link[i].platforms->of_node) { + if(0) { + if (dai_link[i].platforms->name && + !dai_link[i].platforms->of_node) { index = of_property_match_string(cdev->of_node, "asoc-platform-names", dai_link[i].platforms->name); @@ -393,7 +541,7 @@ static int msm_populate_dai_link_component_of_node( } dai_link[i].platforms->of_node = np; dai_link[i].platforms->name = NULL; - } + } } /* populate cpu_of_node for snd card dai links */ @@ -401,7 +549,7 @@ static int msm_populate_dai_link_component_of_node( index = of_property_match_string(cdev->of_node, "asoc-cpu-names", dai_link[i].cpus->dai_name); - pr_err("%s: retrieving cpu_of_node for %s\n", + pr_err("%s: retrieving cpu_of_node for %s\n", __func__, dai_link[i].cpus->dai_name); if (index >= 0) { @@ -452,10 +600,12 @@ err: static const struct of_device_id gvm_asoc_machine_of_match[] = { { .compatible = "qcom,8155-spf-asoc-snd-adp-star", - .data = "adp_star_codec"}, + .data = "adp_star_codec"}, { .compatible = "qcom,6155-spf-asoc-snd-adp-star", - .data = "adp_star_codec"}, - {}, + .data = "adp_star_codec"}, + { .compatible = "qcom,gvm-auto-spf-asoc-snd-adp-star", + .data = "adp_star_codec"}, + {}, }; static struct snd_soc_dai_link msm_auto_dai_links[ ARRAY_SIZE(msm_common_dai_links)]; @@ -463,6 +613,9 @@ static struct snd_soc_dai_link msm_auto_dai_links[ static struct snd_soc_dai_link msm_auto_talos_dai_links[ ARRAY_SIZE(msm_talos_dai_links)]; +static struct snd_soc_dai_link msm_auto_gvm8295_dai_links[ + ARRAY_SIZE(msm_gvm8295_dai_links)]; + static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev) { struct snd_soc_card *card = NULL; @@ -491,8 +644,14 @@ static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev) memcpy(msm_auto_talos_dai_links, msm_talos_dai_links, sizeof(msm_talos_dai_links)); - dailink = msm_auto_talos_dai_links; + } else if (!strcmp(match->compatible, "qcom,gvm-auto-spf-asoc-snd-adp-star")) { + card = &snd_soc_card_auto_makena_dummy_msm; + total_links = ARRAY_SIZE(msm_gvm8295_dai_links); + memcpy(msm_auto_gvm8295_dai_links, + msm_gvm8295_dai_links, + sizeof(msm_gvm8295_dai_links)); + dailink = msm_auto_gvm8295_dai_links; } if (card) { diff --git a/asoc/msm_dailink.h b/asoc/msm_dailink.h old mode 100644 new mode 100755 index e68ef77e2d74..1cafb70abb91 --- a/asoc/msm_dailink.h +++ b/asoc/msm_dailink.h @@ -1344,3 +1344,43 @@ SND_SOC_DAILINK_DEFS(primary_tdm_tx_0_dummy, DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + +SND_SOC_DAILINK_DEFS(secondary_tdm_rx_0_dummy, + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + +SND_SOC_DAILINK_DEFS(secondary_tdm_tx_0_dummy, + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + +SND_SOC_DAILINK_DEFS(quin_tdm_rx_0_dummy, + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + +SND_SOC_DAILINK_DEFS(quin_tdm_tx_0_dummy, + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + +SND_SOC_DAILINK_DEFS(sen_tdm_rx_0_dummy, + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + +SND_SOC_DAILINK_DEFS(sen_tdm_tx_0_dummy, + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + +SND_SOC_DAILINK_DEFS(sep_tdm_rx_0_dummy, + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + +SND_SOC_DAILINK_DEFS(sep_tdm_tx_0_dummy, + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); From b12c68409d8f081278c8b055a5786d5df4ff990d Mon Sep 17 00:00:00 2001 From: Shubhasini Sugumaran Date: Wed, 15 Dec 2021 12:29:59 +0530 Subject: [PATCH 37/82] ARM: dts: msm: Change default state to sleep Change in pin state from active to sleep induced abnormal bias which produced pop noise in 6155/8155. Propagated from f4883ad19bb49a1221f2d3844454dffb3e348f52. Change-Id: I69eb7a6d17a0ae9e28f4cd78495c6f043b53209e Signed-off-by: Shubhasini Sugumaran --- asoc/sa6155.c | 16 ++++++++++++---- asoc/sa8155.c | 4 ++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/asoc/sa6155.c b/asoc/sa6155.c index 3d4b04017cda..5d79f69fcf68 100755 --- a/asoc/sa6155.c +++ b/asoc/sa6155.c @@ -3946,14 +3946,22 @@ static int msm_pinctrl_init(struct platform_device *pdev, enum pinctrl_mode mode pinctrl_info->pinctrl = pinctrl; /* get all the states handles from Device Tree */ - pinctrl_info->sleep = pinctrl_lookup_state(pinctrl, - "sleep"); + if (mode == TDM_PINCTRL) + pinctrl_info->sleep = pinctrl_lookup_state(pinctrl, + "default"); + else + pinctrl_info->sleep = pinctrl_lookup_state(pinctrl, + "sleep"); if (IS_ERR(pinctrl_info->sleep)) { pr_err("%s: could not get sleep pin state\n", __func__); goto err; } - pinctrl_info->active = pinctrl_lookup_state(pinctrl, - "default"); + if (mode == TDM_PINCTRL) + pinctrl_info->active = pinctrl_lookup_state(pinctrl, + "active"); + else + pinctrl_info->active = pinctrl_lookup_state(pinctrl, + "default"); if (IS_ERR(pinctrl_info->active)) { pr_err("%s: could not get active pin state\n", __func__); diff --git a/asoc/sa8155.c b/asoc/sa8155.c index 3d8b4605abb0..7bc1b17a4ef5 100644 --- a/asoc/sa8155.c +++ b/asoc/sa8155.c @@ -5183,13 +5183,13 @@ static int msm_get_pinctrl(struct platform_device *pdev) /* get all the states handles from Device Tree */ pinctrl_info->sleep = pinctrl_lookup_state(pinctrl, - "sleep"); + "default"); if (IS_ERR(pinctrl_info->sleep)) { pr_err("%s: could not get sleep pin state\n", __func__); goto err; } pinctrl_info->active = pinctrl_lookup_state(pinctrl, - "default"); + "active"); if (IS_ERR(pinctrl_info->active)) { pr_err("%s: could not get active pin state\n", __func__); From 6be85d4cabb4419516dc53212e36d746190ad4e9 Mon Sep 17 00:00:00 2001 From: Deru Wang Date: Fri, 28 Aug 2020 13:45:30 +0800 Subject: [PATCH 38/82] dsp: add new boot cmd for early audio The schedule_work of adsp loader boot will block machine driver probing need add new boot cmd without schedule_work to accelerate early audio. Change-Id: I5d344c56ef19985fca9d047687f4ea96a879dc27 Signed-off-by: Deru Wang --- dsp/adsp-loader.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dsp/adsp-loader.c b/dsp/adsp-loader.c index b74c9b5f5d76..ee0c7fd7e6d8 100755 --- a/dsp/adsp-loader.c +++ b/dsp/adsp-loader.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2012-2014, 2017-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2014, 2017-2021, The Linux Foundation. All rights reserved. */ #include @@ -24,6 +24,7 @@ #define SSR_RESET_CMD 1 #define IMAGE_UNLOAD_CMD 0 #define MAX_FW_IMAGES 4 +#define BOOT_FOR_EARLY_CHIME_CMD 2 static ssize_t adsp_boot_store(struct kobject *kobj, struct kobj_attribute *attr, @@ -260,7 +261,11 @@ static ssize_t adsp_boot_store(struct kobject *kobj, } else if (boot == IMAGE_UNLOAD_CMD) { pr_debug("%s: going to call adsp_unloader\n", __func__); adsp_loader_unload(adsp_private); + } else if (boot == BOOT_FOR_EARLY_CHIME_CMD) { + pr_debug("%s: going to call adsp_load_fw\n", __func__); + adsp_load_fw(NULL); } + return count; } From 7743f757cb5fe49b967d0792cac2e02ab8a095f3 Mon Sep 17 00:00:00 2001 From: Soumya Managoli Date: Mon, 6 Dec 2021 15:35:53 +0530 Subject: [PATCH 39/82] ASoC: bolero: Disable va_swr gpio on clk failure During SSR TX_MCLK failure is observed when both SVA and playback is active. Mute is observed post SSR even though there is no clk enable failure. Issue is seen due to va_swr gpio not being disabled during SSR and hence not enabled properly once uc resumes after SSR. Change-Id: I674bbc80edaaa35b53855166156dba41a32ef45d Signed-off-by: Soumya Managoli --- asoc/codecs/bolero/va-macro.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/asoc/codecs/bolero/va-macro.c b/asoc/codecs/bolero/va-macro.c index 7547f486248e..25bbb1d6fe88 100644 --- a/asoc/codecs/bolero/va-macro.c +++ b/asoc/codecs/bolero/va-macro.c @@ -704,6 +704,10 @@ static int va_macro_tx_va_mclk_enable(struct va_macro_priv *va_priv, TX_CORE_CLK, false); if (ret < 0) { + if (va_priv->swr_clk_users == 0) { + msm_cdc_pinctrl_select_sleep_state( + va_priv->va_swr_gpio_p); + } dev_err_ratelimited(va_priv->dev, "%s: swr request clk failed\n", __func__); From 22110db92c4dd8ae50e0cbe6b2658e5b68149e15 Mon Sep 17 00:00:00 2001 From: Soumya Managoli Date: Mon, 29 Nov 2021 13:14:57 +0530 Subject: [PATCH 40/82] ASoc: bolero: update logic to disable VA_MCLK When adsp SSR happens, VA_MCLK enabled by VA_SWR_PWR widget will not be disabled as ADSP is down and it cannot enable TX_MCLk before disabling VA_MCLK. After disabling SVA, VA_MCLk is left open. Add dev_up flag to indicate SSR and close VA_MCLK during SSR. Change-Id: I4cd08419be4035e2f337ab41348a814534480db6 Signed-off-by: Meng Wang Signed-off-by: Soumya Managoli --- asoc/codecs/bolero/va-macro.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/asoc/codecs/bolero/va-macro.c b/asoc/codecs/bolero/va-macro.c index 7547f486248e..400f84230d66 100644 --- a/asoc/codecs/bolero/va-macro.c +++ b/asoc/codecs/bolero/va-macro.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -184,6 +185,7 @@ struct va_macro_priv { int dec_mode[VA_MACRO_NUM_DECIMATORS]; u16 current_clk_id; int pcm_rate[VA_MACRO_NUM_DECIMATORS]; + bool dev_up; }; static bool va_macro_get_data(struct snd_soc_component *component, @@ -329,6 +331,7 @@ static int va_macro_event_handler(struct snd_soc_component *component, trace_printk("%s, enter SSR up\n", __func__); /* reset swr after ssr/pdr */ va_priv->reset_swr = true; + va_priv->dev_up = true; if (va_priv->swr_ctrl_data) swrm_wcd_notify( va_priv->swr_ctrl_data[0].va_swr_pdev, @@ -338,6 +341,8 @@ static int va_macro_event_handler(struct snd_soc_component *component, bolero_rsc_clk_reset(va_dev, VA_CORE_CLK); break; case BOLERO_MACRO_EVT_SSR_DOWN: + trace_printk("%s: BOLERO_MACRO_EVT_SSR_DOWN\n", __func__); + va_priv->dev_up = false; if (va_priv->swr_ctrl_data) { swrm_wcd_notify( va_priv->swr_ctrl_data[0].va_swr_pdev, @@ -441,9 +446,7 @@ static int va_macro_swr_pwr_event_v2(struct snd_soc_dapm_widget *w, } break; case SND_SOC_DAPM_POST_PMD: - if (va_priv->current_clk_id == VA_CORE_CLK && - va_priv->va_swr_clk_cnt != 0 && - va_priv->tx_clk_status) { + if (va_priv->current_clk_id == VA_CORE_CLK) { ret = bolero_clk_rsc_request_clock(va_priv->dev, va_priv->default_clk_id, TX_CORE_CLK, @@ -452,7 +455,8 @@ static int va_macro_swr_pwr_event_v2(struct snd_soc_dapm_widget *w, dev_dbg(component->dev, "%s: request clock TX_CLK disable failed\n", __func__); - break; + if (va_priv->dev_up) + break; } ret = bolero_clk_rsc_request_clock(va_priv->dev, va_priv->default_clk_id, @@ -462,10 +466,11 @@ static int va_macro_swr_pwr_event_v2(struct snd_soc_dapm_widget *w, dev_dbg(component->dev, "%s: request clock VA_CLK disable failed\n", __func__); - bolero_clk_rsc_request_clock(va_priv->dev, - TX_CORE_CLK, - TX_CORE_CLK, - false); + if (va_priv->dev_up) + bolero_clk_rsc_request_clock(va_priv->dev, + TX_CORE_CLK, + TX_CORE_CLK, + false); break; } va_priv->current_clk_id = TX_CORE_CLK; @@ -2839,6 +2844,8 @@ static int va_macro_init(struct snd_soc_component *component) } snd_soc_dapm_sync(dapm); + va_priv->dev_up = true; + for (i = 0; i < VA_MACRO_NUM_DECIMATORS; i++) { va_priv->va_hpf_work[i].va_priv = va_priv; va_priv->va_hpf_work[i].decimator = i; From 9a2dd3bd1d84629aef2efa32db7a9cbb3c3eb6a8 Mon Sep 17 00:00:00 2001 From: Deru Wang Date: Tue, 11 Jan 2022 21:35:14 +0800 Subject: [PATCH 41/82] asoc: set default value for port_id of logging kcontrol Uninitialized values may cause the get function of logging kcontrol to exit abnormally with error on auto LA platform. Change-Id: Id1f91a5454daafe499211763e26572bfe5dcbd47 Signed-off-by: Deru Wang --- asoc/msm-dai-q6-v2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/asoc/msm-dai-q6-v2.c b/asoc/msm-dai-q6-v2.c index 201aedd3cf24..70ab355ac3c0 100755 --- a/asoc/msm-dai-q6-v2.c +++ b/asoc/msm-dai-q6-v2.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2022, The Linux Foundation. All rights reserved. */ #include @@ -474,7 +474,7 @@ static const struct soc_enum tdm_config_enum[] = { SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tdm_header_type), tdm_header_type), }; -static u16 afe_port_logging_port_id; +static u16 afe_port_logging_port_id = 0x9000; static bool afe_port_logging_item[IDX_TDM_MAX]; From 0e1992003d490036ff478bf59a6da1b1ecccee97 Mon Sep 17 00:00:00 2001 From: Hexuan Zhu Date: Wed, 15 Dec 2021 07:51:45 +0800 Subject: [PATCH 42/82] audio-kernel: change the maxnum for stream in QACT Increase the max num for QACT stream, should merge together with 3931333 Change-Id: I4bdd9589be6821f7a44f8c89570b811b6fc03786 Signed-off-by: Hexuan Zhu --- include/dsp/rtac.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) mode change 100644 => 100755 include/dsp/rtac.h diff --git a/include/dsp/rtac.h b/include/dsp/rtac.h old mode 100644 new mode 100755 index 7b047a34a95b..68d6c1b1ab4c --- a/include/dsp/rtac.h +++ b/include/dsp/rtac.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2011, 2013-2015, 2017-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef __RTAC_H__ @@ -13,7 +14,7 @@ #define RTAC_CVS 1 #define RTAC_VOICE_MODES 2 -#define RTAC_MAX_ACTIVE_DEVICES 6 +#define RTAC_MAX_ACTIVE_DEVICES 15 #define RTAC_MAX_ACTIVE_POPP 8 #define DEFAULT_APP_TYPE 0x00011130 From 092ce1cc5c37b63a30dc01338c435c8fe8c7d21f Mon Sep 17 00:00:00 2001 From: Soumya Managoli Date: Tue, 28 Dec 2021 16:09:05 +0530 Subject: [PATCH 43/82] ASoC: Unmap lab buffer during listen session close Ensure lab buffer de-alloc even if listen session is not in start state to avoid memory leak when multiple listen clients are created. Change-Id: Id6d8b37a3dcdf49618ae2a4d80903d429393cd8e Signed-off-by: Soumya Managoli --- asoc/msm-lsm-client.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/asoc/msm-lsm-client.c b/asoc/msm-lsm-client.c index fe461ffc5e5a..69768bc38e51 100644 --- a/asoc/msm-lsm-client.c +++ b/asoc/msm-lsm-client.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2013-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include #include @@ -3092,14 +3093,6 @@ static int msm_lsm_close(struct snd_pcm_substream *substream) __func__, ret); prtd->lsm_client->lab_started = false; } - if (prtd->lsm_client->lab_buffer) { - ret = msm_lsm_lab_buffer_alloc(prtd, - LAB_BUFFER_DEALLOC); - if (ret) - dev_err(rtd->dev, - "%s: lab buffer dealloc failed ret %d\n", - __func__, ret); - } } if (!atomic_read(&prtd->read_abort)) { @@ -3120,6 +3113,15 @@ static int msm_lsm_close(struct snd_pcm_substream *substream) prtd->lsm_client->started = false; } + if (prtd->lsm_client->lab_enable && prtd->lsm_client->lab_buffer) { + ret = msm_lsm_lab_buffer_alloc(prtd, + LAB_BUFFER_DEALLOC); + if (ret) + dev_err(rtd->dev, + "%s: lab buffer dealloc failed ret %d\n", + __func__, ret); + } + /* * De-register existing sound models * to free SM and CAL buffer, even if From 5147ab5a87242d9355037e2d3901a8d4412212c8 Mon Sep 17 00:00:00 2001 From: Soumya Managoli Date: Mon, 24 Jan 2022 13:45:17 +0530 Subject: [PATCH 44/82] dsp: Update adsp packet timeout in voice drv Change TIMEOUT_MS from 300 to 1000 msec in q6voice drv. Change-Id: I383380dfbb5334a32c5c939a67606612344170ee Signed-off-by: Soumya Managoli --- dsp/q6voice.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dsp/q6voice.c b/dsp/q6voice.c index 45753c0381e7..433c2bdb2b0e 100644 --- a/dsp/q6voice.c +++ b/dsp/q6voice.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include #include @@ -25,7 +26,7 @@ #include #include -#define TIMEOUT_MS 300 +#define TIMEOUT_MS 1000 #define CMD_STATUS_SUCCESS 0 From f72f1bcfdaf86527e803fc784a9e828f015c0a83 Mon Sep 17 00:00:00 2001 From: E V Ravi Date: Tue, 4 Jan 2022 14:35:42 +0530 Subject: [PATCH 45/82] ASoC : add support for MultiMedia17 Support for MultiMedia17 to be used with TERT_TDM_TX_0 Change-Id: Id98a1a206f8beac79bc00972e72a158064365d0a Signed-off-by: E V Ravi --- asoc/msm-pcm-routing-v2.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/asoc/msm-pcm-routing-v2.c b/asoc/msm-pcm-routing-v2.c index 6915f566cd29..f2a9ba603fe8 100755 --- a/asoc/msm-pcm-routing-v2.c +++ b/asoc/msm-pcm-routing-v2.c @@ -26487,6 +26487,10 @@ static const struct snd_kcontrol_new mmul17_mixer_controls[] = { MSM_BACKEND_DAI_USB_TX, MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer, msm_routing_put_audio_mixer), + SOC_DOUBLE_EXT("TERT_TDM_TX_0", SND_SOC_NOPM, + MSM_BACKEND_DAI_TERT_TDM_TX_0, + MSM_FRONTEND_DAI_MULTIMEDIA17, 1, 0, msm_routing_get_audio_mixer, + msm_routing_put_audio_mixer), }; static const struct snd_kcontrol_new mmul18_mixer_controls[] = { @@ -38392,6 +38396,8 @@ static const struct snd_soc_dapm_route intercon_tdm[] = { {"MultiMedia10 Mixer", "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"}, {"MultiMedia10 Mixer", "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"}, + {"MultiMedia17 Mixer", "TERT_TDM_TX_0", "TERT_TDM_TX_0"}, + {"MultiMedia20 Mixer", "PRI_TDM_TX_0", "PRI_TDM_TX_0"}, {"MultiMedia20 Mixer", "PRI_TDM_TX_1", "PRI_TDM_TX_1"}, {"MultiMedia20 Mixer", "PRI_TDM_TX_2", "PRI_TDM_TX_2"}, From 47e815e52b52afe704d217bece1e15f05bed8336 Mon Sep 17 00:00:00 2001 From: Deru Wang Date: Tue, 25 Jan 2022 14:50:25 +0800 Subject: [PATCH 46/82] asoc: copyright fix Revert LF copyright and add QUIC copyright for change 3943882 Change-Id: I986ff4a667c653c5b8870e98655d9578d0fccf0b Signed-off-by: Deru Wang --- asoc/msm-dai-q6-v2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/asoc/msm-dai-q6-v2.c b/asoc/msm-dai-q6-v2.c index 70ab355ac3c0..ceba2e0ac11c 100755 --- a/asoc/msm-dai-q6-v2.c +++ b/asoc/msm-dai-q6-v2.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2012-2022, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include From 3aa09a8758704f310c22e2f48d0f9590c2c788a6 Mon Sep 17 00:00:00 2001 From: Lakshman Chaluvaraju Date: Fri, 5 Nov 2021 19:15:16 +0530 Subject: [PATCH 47/82] ASoC: bitra: Add support for VI sense backend Add changes for VI sense WSA_CDC_DMA_TX_0 as backend dailink to support recording of VI sense data. Change-Id: I6f0911c9a2b5b20ce3b4f099f93ad3fed3cff886 Signed-off-by: Lakshman Chaluvaraju --- asoc/kona.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/asoc/kona.c b/asoc/kona.c index 67deb67b15c7..2286f288ed4f 100644 --- a/asoc/kona.c +++ b/asoc/kona.c @@ -6841,6 +6841,17 @@ static struct snd_soc_dai_link msm_wsa_cdc_dma_be_dai_links[] = { .ops = &msm_cdc_dma_be_ops, SND_SOC_DAILINK_REG(wsa_dma_tx1), }, + { + .name = LPASS_BE_WSA_CDC_DMA_TX_0_VI, + .stream_name = "WSA CDC DMA0 Capture", + .no_pcm = 1, + .dpcm_capture = 1, + .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0, + .be_hw_params_fixup = msm_be_hw_params_fixup, + .ignore_suspend = 1, + .ops = &msm_cdc_dma_be_ops, + SND_SOC_DAILINK_REG(wsa_dma_tx0_vi), + }, }; static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = { From 5e85dafc9cfcc95bcc8e33c696fffaaf3a026850 Mon Sep 17 00:00:00 2001 From: Hongtao Peng Date: Tue, 15 Feb 2022 21:14:13 +0800 Subject: [PATCH 48/82] ASoC: msm: extend app type cfg mixer command with copp mode ADM can be opened with different perf mode with ASM Change-Id: I22c50ae57c1e1f9ee9a0b080a20bde5b4f50d06c Signed-off-by: Hongtao Peng --- asoc/msm-pcm-loopback-v2.c | 27 ++++++++++------ asoc/msm-pcm-q6-v2.c | 27 ++++++++++------ asoc/msm-pcm-routing-v2.c | 64 +++++++++++++++++++++++++++++--------- asoc/msm-pcm-routing-v2.h | 4 +++ 4 files changed, 88 insertions(+), 34 deletions(-) mode change 100755 => 100644 asoc/msm-pcm-routing-v2.c diff --git a/asoc/msm-pcm-loopback-v2.c b/asoc/msm-pcm-loopback-v2.c index 2492f75e45a9..8bb38cb7a6a5 100644 --- a/asoc/msm-pcm-loopback-v2.c +++ b/asoc/msm-pcm-loopback-v2.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2013-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -683,7 +684,7 @@ static int msm_pcm_playback_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol, u64 fe_id = kcontrol->private_value; int session_type = SESSION_TYPE_RX; int be_id = ucontrol->value.integer.value[3]; - struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000, 0, 0}; + struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000, 0, 0, 0}; int ret = 0; cfg_data.app_type = ucontrol->value.integer.value[0]; @@ -694,10 +695,12 @@ static int msm_pcm_playback_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol, cfg_data.copp_token = ucontrol->value.integer.value[4]; if (ucontrol->value.integer.value[5] != 0) cfg_data.bit_width = ucontrol->value.integer.value[5]; + if (ucontrol->value.integer.value[6] != 0) + cfg_data.copp_perf_mode = ucontrol->value.integer.value[6]; pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d" - "sample_rate- %d copp_token- %d bit_width- %d\n", + "sample_rate- %d copp_token- %d bit_width- %d copp_perf_mode- %d\n", __func__, fe_id, session_type, be_id, cfg_data.app_type, cfg_data.acdb_dev_id, - cfg_data.sample_rate, cfg_data.copp_token, cfg_data.bit_width); + cfg_data.sample_rate, cfg_data.copp_token, cfg_data.bit_width, cfg_data.copp_perf_mode); ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type, be_id, &cfg_data); if (ret < 0) @@ -730,11 +733,12 @@ static int msm_pcm_playback_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol, ucontrol->value.integer.value[3] = be_id; ucontrol->value.integer.value[4] = cfg_data.copp_token; ucontrol->value.integer.value[5] = cfg_data.bit_width; + ucontrol->value.integer.value[6] = cfg_data.copp_perf_mode; pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d" - "sample_rate- %d copp_token- %d bit_width- %d\n", + "sample_rate- %d copp_token- %d bit_width- %d copp_perf_mode- %d\n", __func__, fe_id, session_type, be_id, cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate, - cfg_data.copp_token, cfg_data.bit_width); + cfg_data.copp_token, cfg_data.bit_width, cfg_data.copp_perf_mode); done: return ret; @@ -746,7 +750,7 @@ static int msm_pcm_capture_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol, u64 fe_id = kcontrol->private_value; int session_type = SESSION_TYPE_TX; int be_id = ucontrol->value.integer.value[3]; - struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000, 0, 0}; + struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000, 0, 0, 0}; int ret = 0; cfg_data.app_type = ucontrol->value.integer.value[0]; @@ -757,10 +761,12 @@ static int msm_pcm_capture_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol, cfg_data.copp_token = ucontrol->value.integer.value[4]; if (ucontrol->value.integer.value[5] != 0) cfg_data.bit_width = ucontrol->value.integer.value[5]; + if (ucontrol->value.integer.value[6] != 0) + cfg_data.copp_perf_mode = ucontrol->value.integer.value[6]; pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d" - "sample_rate- %d copp_token- %d bit_width- %d\n", + "sample_rate- %d copp_token- %d bit_width- %d copp_perf_mode- %d\n", __func__, fe_id, session_type, be_id, cfg_data.app_type, cfg_data.acdb_dev_id, - cfg_data.sample_rate, cfg_data.copp_token, cfg_data.bit_width); + cfg_data.sample_rate, cfg_data.copp_token, cfg_data.bit_width, cfg_data.copp_perf_mode); ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type, be_id, &cfg_data); if (ret < 0) @@ -793,11 +799,12 @@ static int msm_pcm_capture_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol, ucontrol->value.integer.value[3] = be_id; ucontrol->value.integer.value[4] = cfg_data.copp_token; ucontrol->value.integer.value[5] = cfg_data.bit_width; + ucontrol->value.integer.value[6] = cfg_data.copp_perf_mode; pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d" - "sample_rate- %d copp_token- %d bit_width- %d\n", + "sample_rate- %d copp_token- %d bit_width- %d copp_perf_mode- %d\n", __func__, fe_id, session_type, be_id, cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate, - cfg_data.copp_token, cfg_data.bit_width); + cfg_data.copp_token, cfg_data.bit_width, cfg_data.copp_perf_mode); done: return ret; } diff --git a/asoc/msm-pcm-q6-v2.c b/asoc/msm-pcm-q6-v2.c index 31dcfc5027fa..b084c0081f1e 100644 --- a/asoc/msm-pcm-q6-v2.c +++ b/asoc/msm-pcm-q6-v2.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ @@ -2091,7 +2092,7 @@ static int msm_pcm_playback_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol, u64 fe_id = kcontrol->private_value; int session_type = SESSION_TYPE_RX; int be_id = ucontrol->value.integer.value[3]; - struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000, 0, 0}; + struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000, 0, 0, 0}; int ret = 0; cfg_data.app_type = ucontrol->value.integer.value[0]; @@ -2102,10 +2103,12 @@ static int msm_pcm_playback_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol, cfg_data.copp_token = ucontrol->value.integer.value[4]; if (ucontrol->value.integer.value[5] != 0) cfg_data.bit_width = ucontrol->value.integer.value[5]; + if (ucontrol->value.integer.value[6] != 0) + cfg_data.copp_perf_mode = ucontrol->value.integer.value[6]; pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d" - "sample_rate- %d copp_token- %d bit_width- %d\n", + "sample_rate- %d copp_token- %d bit_width- %d copp_perf_mode- %d\n", __func__, fe_id, session_type, be_id, cfg_data.app_type, cfg_data.acdb_dev_id, - cfg_data.sample_rate, cfg_data.copp_token, cfg_data.bit_width); + cfg_data.sample_rate, cfg_data.copp_token, cfg_data.bit_width, cfg_data.copp_perf_mode); ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type, be_id, &cfg_data); if (ret < 0) @@ -2138,10 +2141,11 @@ static int msm_pcm_playback_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol, ucontrol->value.integer.value[3] = be_id; ucontrol->value.integer.value[4] = cfg_data.copp_token; ucontrol->value.integer.value[5] = cfg_data.bit_width; + ucontrol->value.integer.value[6] = cfg_data.copp_perf_mode; pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d" - "sample_rate- %d copp_token- %d bit_width- %d\n", + "sample_rate- %d copp_token- %d bit_width- %d copp_perf_mode- %d\n", __func__, fe_id, session_type, be_id, cfg_data.app_type, cfg_data.acdb_dev_id, - cfg_data.sample_rate, cfg_data.copp_token, cfg_data.bit_width); + cfg_data.sample_rate, cfg_data.copp_token, cfg_data.bit_width, cfg_data.copp_perf_mode); done: return ret; } @@ -2152,7 +2156,7 @@ static int msm_pcm_capture_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol, u64 fe_id = kcontrol->private_value; int session_type = SESSION_TYPE_TX; int be_id = ucontrol->value.integer.value[3]; - struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000, 0, 0}; + struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000, 0, 0, 0}; int ret = 0; cfg_data.app_type = ucontrol->value.integer.value[0]; @@ -2163,10 +2167,12 @@ static int msm_pcm_capture_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol, cfg_data.copp_token = ucontrol->value.integer.value[4]; if (ucontrol->value.integer.value[5] != 0) cfg_data.bit_width = ucontrol->value.integer.value[5]; + if (ucontrol->value.integer.value[6] != 0) + cfg_data.copp_perf_mode = ucontrol->value.integer.value[6]; pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d" - "sample_rate- %d copp_token- %d bit_width- %d\n", + "sample_rate- %d copp_token- %d bit_width- %d copp_perf_mode- %d\n", __func__, fe_id, session_type, be_id, cfg_data.app_type, cfg_data.acdb_dev_id, - cfg_data.sample_rate, cfg_data.copp_token, cfg_data.bit_width); + cfg_data.sample_rate, cfg_data.copp_token, cfg_data.bit_width, cfg_data.copp_perf_mode); ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type, be_id, &cfg_data); if (ret < 0) @@ -2199,10 +2205,11 @@ static int msm_pcm_capture_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol, ucontrol->value.integer.value[3] = be_id; ucontrol->value.integer.value[4] = cfg_data.copp_token; ucontrol->value.integer.value[5] = cfg_data.bit_width; + ucontrol->value.integer.value[6] = cfg_data.copp_perf_mode; pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d" - "sample_rate- %d copp_token- %d bit_width- %d\n", + "sample_rate- %d copp_token- %d bit_width- %d copp_perf_mode- %d\n", __func__, fe_id, session_type, be_id, cfg_data.app_type, cfg_data.acdb_dev_id, - cfg_data.sample_rate, cfg_data.copp_token, cfg_data.bit_width); + cfg_data.sample_rate, cfg_data.copp_token, cfg_data.bit_width, cfg_data.copp_perf_mode); done: return ret; } diff --git a/asoc/msm-pcm-routing-v2.c b/asoc/msm-pcm-routing-v2.c old mode 100755 new mode 100644 index f2a9ba603fe8..5b7fc20a08e4 --- a/asoc/msm-pcm-routing-v2.c +++ b/asoc/msm-pcm-routing-v2.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -1283,6 +1284,30 @@ static bool is_mm_lsm_fe_id(int fe_id) return rc; } +static int get_copp_perf_mode(int fe_id, int sess_type, int port) +{ + int fdai_mode, copp_perf_mode, flag, value; + int rc = 0; + + if ((fe_id < 0) || (fe_id >= MSM_FRONTEND_DAI_MAX) || + (port < 0) || (port >= MSM_BACKEND_DAI_MAX) || + (sess_type != SESSION_TYPE_RX && sess_type != SESSION_TYPE_TX)) { + pr_err("%s: Input out of bounds\n", __func__); + return rc; + } + fdai_mode = fe_dai_map[fe_id][sess_type].perf_mode; + copp_perf_mode = fe_dai_app_type_cfg[fe_id][sess_type][port].copp_perf_mode; + flag = (copp_perf_mode & PP_PERF_MODE_FLAG_MASK); + value = (copp_perf_mode & PP_PERF_MODE_VALUE_MASK); + rc = fdai_mode; + if ((flag != 0) && (value >= LEGACY_PCM_MODE) && + (value <= ULL_POST_PROCESSING_PCM_MODE)) { + rc = value; + } + pr_debug("%s: Get copp_perf_mode = %d", __func__, rc); + return rc; +} + /* * msm_pcm_routing_send_chmix_cfg: * send the channel mixer command to mix the input channels @@ -1476,11 +1501,11 @@ int msm_pcm_routing_reg_stream_app_type_cfg( } pr_debug("%s: fedai_id %d, session_type %d, be_id %d, app_type %d, acdb_dev_id %d," - "sample_rate %d, copp_token %d, bit_width %d\n", + "sample_rate %d, copp_token %d, bit_width %d, copp_perf_mode %d\n", __func__, fedai_id, session_type, be_id, cfg_data->app_type, cfg_data->acdb_dev_id, cfg_data->sample_rate, cfg_data->copp_token, - cfg_data->bit_width); + cfg_data->bit_width, cfg_data->copp_perf_mode); if (!is_mm_lsm_fe_id(fedai_id)) { pr_err("%s: Invalid machine driver ID %d\n", @@ -1564,11 +1589,11 @@ int msm_pcm_routing_get_stream_app_type_cfg( *bedai_id = be_id; *cfg_data = fe_dai_app_type_cfg[fedai_id][session_type][be_id]; pr_debug("%s: fedai_id %d, session_type %d, be_id %d, app_type %d, acdb_dev_id %d," - "sample_rate %d, copp_token %d, bit_width %d\n", + "sample_rate %d, copp_token %d, bit_width %d, copp_perf_mode %d\n", __func__, fedai_id, session_type, *bedai_id, cfg_data->app_type, cfg_data->acdb_dev_id, cfg_data->sample_rate, cfg_data->copp_token, - cfg_data->bit_width); + cfg_data->bit_width, cfg_data->copp_perf_mode); done: return ret; } @@ -1906,6 +1931,7 @@ int msm_pcm_routing_reg_phy_compr_stream(int fe_id, int perf_mode, u16 bit_width = 16, be_bit_width; bool is_lsm; uint32_t copp_token = 0; + int copp_perf_mode = 0; pr_debug("%s:fe_id[%d] perf_mode[%d] id[%d] stream_type[%d] passt[%d]", __func__, fe_id, perf_mode, dspst_id, @@ -1999,6 +2025,7 @@ int msm_pcm_routing_reg_phy_compr_stream(int fe_id, int perf_mode, } acdb_dev_id = fe_dai_app_type_cfg[fe_id][session_type][i].acdb_dev_id; + copp_perf_mode = get_copp_perf_mode(fe_id, session_type, i); topology = msm_routing_get_adm_topology(fe_id, session_type, i); @@ -2020,7 +2047,7 @@ int msm_pcm_routing_reg_phy_compr_stream(int fe_id, int perf_mode, SNDRV_PCM_FORMAT_S32_LE); copp_idx = adm_open(port_id, path_type, sample_rate, - channels, topology, perf_mode, + channels, topology, copp_perf_mode, bit_width, app_type, acdb_dev_id, session_type, passthr_mode, copp_token); if ((copp_idx < 0) || @@ -2308,6 +2335,7 @@ int msm_pcm_routing_reg_phy_stream(int fedai_id, int perf_mode, uint32_t passthr_mode = LEGACY_PCM; int ret = 0; uint32_t copp_token = 0; + int copp_perf_mode = 0; if (fedai_id >= MSM_FRONTEND_DAI_MM_MAX_ID) { /* bad ID assigned in machine driver */ @@ -2380,7 +2408,7 @@ int msm_pcm_routing_reg_phy_stream(int fedai_id, int perf_mode, i); be_bit_width = msm_routing_get_bit_width( msm_bedais[i].format); - + copp_perf_mode = get_copp_perf_mode(fedai_id, session_type, i); if (hifi_filter_enabled && (msm_bedais[i].sample_rate == 384000 ||msm_bedais[i].sample_rate == 352800) && be_bit_width == 32) @@ -2403,7 +2431,7 @@ int msm_pcm_routing_reg_phy_stream(int fedai_id, int perf_mode, copp_idx = adm_open_v2(port_id, path_type, sample_rate, channels, topology, - perf_mode, bits_per_sample, + copp_perf_mode, bits_per_sample, app_type, acdb_dev_id, session_type, passthr_mode, copp_token, @@ -2414,7 +2442,7 @@ int msm_pcm_routing_reg_phy_stream(int fedai_id, int perf_mode, } else copp_idx = adm_open(port_id, path_type, sample_rate, channels, topology, - perf_mode, bits_per_sample, + copp_perf_mode, bits_per_sample, app_type, acdb_dev_id, session_type, passthr_mode, copp_token); if ((copp_idx < 0) || @@ -2495,6 +2523,7 @@ void msm_pcm_routing_dereg_phy_stream(int fedai_id, int stream_type) { int i, port_type, session_type, path_type, topology, port_id; struct msm_pcm_routing_fdai_data *fdai; + int copp_perf_mode; if (!is_mm_lsm_fe_id(fedai_id)) { /* bad ID assigned in machine driver */ @@ -2536,7 +2565,8 @@ void msm_pcm_routing_dereg_phy_stream(int fedai_id, int stream_type) topology = adm_get_topology_for_port_copp_idx( port_id, idx); msm_routing_unload_topology(topology); - adm_close(port_id, fdai->perf_mode, idx); + copp_perf_mode = get_copp_perf_mode(fedai_id, session_type, i); + adm_close(port_id, copp_perf_mode, idx); pr_debug("%s:copp:%ld,idx bit fe:%d,type:%d,be:%d\n", __func__, copp, fedai_id, session_type, i); clear_bit(idx, @@ -2580,6 +2610,7 @@ static void msm_pcm_routing_process_audio(u16 reg, u16 val, int set) uint32_t passthr_mode; bool is_lsm; uint32_t copp_token = 0; + int copp_perf_mode = 0; pr_debug("%s: reg %x val %x set %x\n", __func__, reg, val, set); @@ -2694,6 +2725,7 @@ static void msm_pcm_routing_process_audio(u16 reg, u16 val, int set) be_bit_width = msm_routing_get_bit_width( msm_bedais[reg].format); + copp_perf_mode = get_copp_perf_mode(val, session_type, reg); if (hifi_filter_enabled && (msm_bedais[reg].sample_rate == 384000 ||msm_bedais[reg].sample_rate == 352800) && be_bit_width == 32) @@ -2701,7 +2733,7 @@ static void msm_pcm_routing_process_audio(u16 reg, u16 val, int set) SNDRV_PCM_FORMAT_S32_LE); copp_idx = adm_open(port_id, path_type, sample_rate, channels, topology, - fdai->perf_mode, bits_per_sample, + copp_perf_mode, bits_per_sample, app_type, acdb_dev_id, session_type, passthr_mode, copp_token); if ((copp_idx < 0) || @@ -2762,7 +2794,8 @@ static void msm_pcm_routing_process_audio(u16 reg, u16 val, int set) topology = adm_get_topology_for_port_copp_idx(port_id, idx); msm_routing_unload_topology(topology); - adm_close(port_id, fdai->perf_mode, idx); + copp_perf_mode = get_copp_perf_mode(val, session_type, reg); + adm_close(port_id, copp_perf_mode, idx); pr_debug("%s: copp: %ld, reset idx bit fe:%d, type: %d, be:%d topology=0x%x\n", __func__, copp, val, session_type, reg, topology); @@ -41329,6 +41362,7 @@ static int msm_pcm_routing_close(struct snd_pcm_substream *substream) int i, session_type, path_type, topology; struct msm_pcm_routing_bdai_data *bedai; struct msm_pcm_routing_fdai_data *fdai; + int copp_perf_mode; pr_debug("%s: substream->pcm->id:%s\n", __func__, substream->pcm->id); @@ -41370,7 +41404,8 @@ static int msm_pcm_routing_close(struct snd_pcm_substream *substream) topology = adm_get_topology_for_port_copp_idx(port_id, idx); msm_routing_unload_topology(topology); - adm_close(port_id, fdai->perf_mode, idx); + copp_perf_mode = get_copp_perf_mode(i, session_type, be_id); + adm_close(port_id, copp_perf_mode, idx); pr_debug("%s: copp:%ld,idx bit fe:%d, type:%d,be:%d topology=0x%x\n", __func__, copp, i, session_type, be_id, topology); @@ -41405,6 +41440,7 @@ static int msm_pcm_routing_prepare(struct snd_pcm_substream *substream) struct media_format_info voc_be_media_format; bool is_lsm; uint32_t copp_token = 0; + int copp_perf_mode = 0; pr_debug("%s: substream->pcm->id:%s\n", __func__, substream->pcm->id); @@ -41515,7 +41551,7 @@ static int msm_pcm_routing_prepare(struct snd_pcm_substream *substream) be_bit_width = msm_routing_get_bit_width( bedai->format); - + copp_perf_mode = get_copp_perf_mode(i, session_type, be_id); if (hifi_filter_enabled && (bedai->sample_rate == 384000 || bedai->sample_rate == 352800) && be_bit_width == 32) @@ -41523,7 +41559,7 @@ static int msm_pcm_routing_prepare(struct snd_pcm_substream *substream) SNDRV_PCM_FORMAT_S32_LE); copp_idx = adm_open(port_id, path_type, sample_rate, channels, topology, - fdai->perf_mode, bits_per_sample, + copp_perf_mode, bits_per_sample, app_type, acdb_dev_id, session_type, fdai->passthr_mode, copp_token); if ((copp_idx < 0) || diff --git a/asoc/msm-pcm-routing-v2.h b/asoc/msm-pcm-routing-v2.h index 63ff45f58df6..4a8e4b6eda58 100644 --- a/asoc/msm-pcm-routing-v2.h +++ b/asoc/msm-pcm-routing-v2.h @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _MSM_PCM_ROUTING_H #define _MSM_PCM_ROUTING_H @@ -688,6 +689,8 @@ enum { #define STREAM_TYPE_ASM 0 #define STREAM_TYPE_LSM 1 +#define PP_PERF_MODE_FLAG_MASK 0x10000 +#define PP_PERF_MODE_VALUE_MASK 0xF enum { ADM_TOPOLOGY_CAL_TYPE_IDX = 0, ADM_LSM_TOPOLOGY_CAL_TYPE_IDX, @@ -743,6 +746,7 @@ struct msm_pcm_stream_app_type_cfg { int sample_rate; uint32_t copp_token; int bit_width; + int copp_perf_mode; }; /* dai_id: front-end ID, From 2b934435f68606040d627c553a15dd6d84c5e1aa Mon Sep 17 00:00:00 2001 From: Hugh Guan Date: Thu, 6 Jan 2022 12:52:02 -0800 Subject: [PATCH 49/82] asoc: refine dummy machine driver for gen3 Enable all LPAIF for gen3 dummy machine driver. Change-Id: I4e1f128e8f4283fa2ffbce981115201d8d50e38b Signed-off-by: Hugh Guan --- asoc/gvm_auto_spf_dummy.c | 164 ++++++++++++++++++++++++++++---------- asoc/msm_dailink.h | 112 +++++++++++++------------- 2 files changed, 178 insertions(+), 98 deletions(-) diff --git a/asoc/gvm_auto_spf_dummy.c b/asoc/gvm_auto_spf_dummy.c index e081007b221c..93bd664ae14c 100755 --- a/asoc/gvm_auto_spf_dummy.c +++ b/asoc/gvm_auto_spf_dummy.c @@ -218,26 +218,6 @@ static const struct snd_soc_dapm_widget msm_dapm_widgets[] = { /* Digital audio interface glue - connects codec <---> CPU */ static struct snd_soc_dai_link msm_common_dai_links[] = { /* BackEnd DAI Links */ - { - .name = "TERT_TDM_RX_0_DUMMY", - .stream_name = "TDM-LPAIF-RX-TERTIARY", - .dpcm_playback = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, - SND_SOC_DAILINK_REG(tert_tdm_rx_0_dummy), - }, - { - .name = "TERT_TDM_TX_0_DUMMY", - .stream_name = "TDM-LPAIF-TX-TERTIARY", - .dpcm_capture = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, - SND_SOC_DAILINK_REG(tert_tdm_tx_0_dummy), - }, { .name = "LPASS_BE_AUXPCM_RX_DUMMY", .stream_name = "AUXPCM-LPAIF-RX-PRIMARY", @@ -258,6 +238,46 @@ static struct snd_soc_dai_link msm_common_dai_links[] = { .ignore_pmdown_time = 1, SND_SOC_DAILINK_REG(lpass_be_auxpcm_tx_dummy), }, + { + .name = "SEC_TDM_RX_0_DUMMY", + .stream_name = "TDM-LPAIF-RX-SECONDARY", + .dpcm_playback = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(secondary_tdm_rx_0_dummy), + }, + { + .name = "SEC_TDM_TX_0_DUMMY", + .stream_name = "TDM-LPAIF-TX-SECONDARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(secondary_tdm_tx_0_dummy), + }, + { + .name = "TERT_TDM_RX_0_DUMMY", + .stream_name = "TDM-LPAIF-RX-TERTIARY", + .dpcm_playback = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(tert_tdm_rx_0_dummy), + }, + { + .name = "TERT_TDM_TX_0_DUMMY", + .stream_name = "TDM-LPAIF-TX-TERTIARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(tert_tdm_tx_0_dummy), + }, { .name = "QUAT_TDM_RX_0_DUMMY", .stream_name = "TDM-LPAIF-RX-QUATERNARY", @@ -278,6 +298,26 @@ static struct snd_soc_dai_link msm_common_dai_links[] = { .ignore_pmdown_time = 1, SND_SOC_DAILINK_REG(quat_tdm_tx_0_dummy), }, + { + .name = "QUIN_TDM_RX_0_DUMMY", + .stream_name = "TDM-LPAIF-RX-QUINARY", + .dpcm_playback = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(quin_tdm_rx_0_dummy), + }, + { + .name = "QUIN_TDM_TX_0_DUMMY", + .stream_name = "TDM-LPAIF-TX-QUINARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(quin_tdm_tx_0_dummy), + }, }; static struct snd_soc_dai_link msm_gvm8295_dai_links[] = { @@ -426,26 +466,6 @@ static struct snd_soc_dai_link msm_gvm8295_dai_links[] = { static struct snd_soc_dai_link msm_talos_dai_links[] = { /* BackEnd DAI Links */ - { - .name = "PRIMARY_TDM_RX_0_DUMMY", - .stream_name = "TDM-LPAIF_WSA-RX-PRIMARY", - .dpcm_playback = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, - SND_SOC_DAILINK_REG(primary_tdm_rx_0_dummy), - }, - { - .name = "PRIMARY_TDM_TX_0_DUMMY", - .stream_name = "TDM-LPAIF_WSA-TX-PRIMARY", - .dpcm_capture = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, - SND_SOC_DAILINK_REG(primary_tdm_tx_0_dummy), - }, { .name = "LPASS_BE_AUXPCM_RX_DUMMY", .stream_name = "AUXPCM-LPAIF-RX-PRIMARY", @@ -466,9 +486,49 @@ static struct snd_soc_dai_link msm_talos_dai_links[] = { .ignore_pmdown_time = 1, SND_SOC_DAILINK_REG(lpass_be_auxpcm_tx_dummy), }, + { + .name = "SEC_TDM_RX_0_DUMMY", + .stream_name = "TDM-LPAIF-RX-SECONDARY", + .dpcm_playback = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(secondary_tdm_rx_0_dummy), + }, + { + .name = "SEC_TDM_TX_0_DUMMY", + .stream_name = "TDM-LPAIF-TX-SECONDARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(secondary_tdm_tx_0_dummy), + }, + { + .name = "TERT_TDM_RX_0_DUMMY", + .stream_name = "TDM-LPAIF_WSA-RX-PRIMARY", + .dpcm_playback = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(tert_tdm_rx_0_dummy), + }, + { + .name = "TERT_TDM_TX_0_DUMMY", + .stream_name = "TDM-LPAIF_WSA-TX-PRIMARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(tert_tdm_tx_0_dummy), + }, { .name = "QUAT_TDM_RX_0_DUMMY", - .stream_name = "TDM-LPAIF-RX-QUATERNARY", + .stream_name = "TDM-LPAIF_RXTX-RX-PRIMARY", .dpcm_playback = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, @@ -478,7 +538,7 @@ static struct snd_soc_dai_link msm_talos_dai_links[] = { }, { .name = "QUAT_TDM_TX_0_DUMMY", - .stream_name = "TDM-LPAIF-TX-QUATERNARY", + .stream_name = "TDM-LPAIF_RXTX-TX-PRIMARY", .dpcm_capture = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, @@ -486,6 +546,26 @@ static struct snd_soc_dai_link msm_talos_dai_links[] = { .ignore_pmdown_time = 1, SND_SOC_DAILINK_REG(quat_tdm_tx_0_dummy), }, + { + .name = "QUIN_TDM_RX_0_DUMMY", + .stream_name = "TDM-LPAIF-RX-TERTIARY", + .dpcm_playback = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(quin_tdm_rx_0_dummy), + }, + { + .name = "QUIN_TDM_TX_0_DUMMY", + .stream_name = "TDM-LPAIF-TX-TERTIARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(quin_tdm_tx_0_dummy), + }, }; struct snd_soc_card snd_soc_card_auto_hana_dummy_msm = { diff --git a/asoc/msm_dailink.h b/asoc/msm_dailink.h index 1cafb70abb91..171db997f9df 100755 --- a/asoc/msm_dailink.h +++ b/asoc/msm_dailink.h @@ -1305,82 +1305,82 @@ SND_SOC_DAILINK_DEFS(ext_display_port, "msm_dp_audio_codec_rx_dai")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); -SND_SOC_DAILINK_DEFS(tert_tdm_rx_0_dummy, - DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), - DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), - DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); - -SND_SOC_DAILINK_DEFS(tert_tdm_tx_0_dummy, - DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), - DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), - DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); - -SND_SOC_DAILINK_DEFS(quat_tdm_rx_0_dummy, - DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), - DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), - DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); - -SND_SOC_DAILINK_DEFS(quat_tdm_tx_0_dummy, - DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), - DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), - DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); - SND_SOC_DAILINK_DEFS(lpass_be_auxpcm_rx_dummy, - DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), - DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), - DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); SND_SOC_DAILINK_DEFS(lpass_be_auxpcm_tx_dummy, - DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), - DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), - DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); SND_SOC_DAILINK_DEFS(primary_tdm_rx_0_dummy, - DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), - DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), - DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); SND_SOC_DAILINK_DEFS(primary_tdm_tx_0_dummy, - DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), - DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), - DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); SND_SOC_DAILINK_DEFS(secondary_tdm_rx_0_dummy, - DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), - DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), - DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); SND_SOC_DAILINK_DEFS(secondary_tdm_tx_0_dummy, - DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), - DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), - DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + +SND_SOC_DAILINK_DEFS(tert_tdm_rx_0_dummy, + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + +SND_SOC_DAILINK_DEFS(tert_tdm_tx_0_dummy, + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + +SND_SOC_DAILINK_DEFS(quat_tdm_rx_0_dummy, + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + +SND_SOC_DAILINK_DEFS(quat_tdm_tx_0_dummy, + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); SND_SOC_DAILINK_DEFS(quin_tdm_rx_0_dummy, - DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), - DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), - DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); SND_SOC_DAILINK_DEFS(quin_tdm_tx_0_dummy, - DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), - DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), - DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); SND_SOC_DAILINK_DEFS(sen_tdm_rx_0_dummy, - DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), - DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), - DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); SND_SOC_DAILINK_DEFS(sen_tdm_tx_0_dummy, - DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), - DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), - DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); SND_SOC_DAILINK_DEFS(sep_tdm_rx_0_dummy, - DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), - DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), - DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); SND_SOC_DAILINK_DEFS(sep_tdm_tx_0_dummy, - DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), - DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), - DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); From d1644ff55dc65e241c8ca4fff0bca00e3dc38dcf Mon Sep 17 00:00:00 2001 From: Dechen Chai Date: Tue, 22 Feb 2022 07:47:57 +0530 Subject: [PATCH 50/82] ASOC: Disable Temperature sensor of WSA881x for bengal -Temperature sensor of WSA881x is not used in bengal Hence disable compilation. -Initialize temp_val before use for wsa881x-analog. Change-Id: Ibfb2fdfabdba7acfad3f65911b89d007a0711f08 Signed-off-by: Dechen Chai --- config/bengalauto.conf | 1 + config/bengalautoconf.h | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/config/bengalauto.conf b/config/bengalauto.conf index f51e7be98f4f..8f2dc3bd953f 100644 --- a/config/bengalauto.conf +++ b/config/bengalauto.conf @@ -3,6 +3,7 @@ CONFIG_AUDIO_EXT_CLK=m CONFIG_SND_SOC_WCD9XXX_V2=m CONFIG_SND_SOC_WCD_MBHC=m CONFIG_SND_SOC_WSA881X_ANALOG=m +CONFIG_WSA881X_TEMP_SENSOR_DISABLE=m CONFIG_WCD9XXX_CODEC_CORE_V2=m CONFIG_MSM_CDC_PINCTRL=m CONFIG_MSM_QDSP6V2_CODECS=m diff --git a/config/bengalautoconf.h b/config/bengalautoconf.h index 42d962160927..b74279a8689a 100644 --- a/config/bengalautoconf.h +++ b/config/bengalautoconf.h @@ -1,5 +1,39 @@ /* SPDX-License-Identifier: GPL-2.0-only */ -/* Copyright (c) 2019-2020, The Linux Foundation. All rights reserved. +/* Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. + * + * Changes from Qualcomm Innovation Center are provided under the following license: + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted (subject to the limitations in the + * disclaimer below) provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of Qualcomm Innovation Center, Inc. nor the + * names of its contributors may be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE + * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT + * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #define CONFIG_PINCTRL_LPI 1 @@ -7,6 +41,7 @@ #define CONFIG_SND_SOC_WCD9XXX_V2 1 #define CONFIG_SND_SOC_WCD_MBHC 1 #define CONFIG_SND_SOC_WSA881X_ANALOG 1 +#define CONFIG_WSA881X_TEMP_SENSOR_DISABLE 1 #define CONFIG_WCD9XXX_CODEC_CORE_V2 1 #define CONFIG_MSM_CDC_PINCTRL 1 #define CONFIG_MSM_QDSP6V2_CODECS 1 From c11441a914a82eca26bbc6470ee833cef43218ce Mon Sep 17 00:00:00 2001 From: Jing Wang Date: Thu, 9 Dec 2021 15:28:47 +0530 Subject: [PATCH 51/82] asoc: afe: Add afe dyn mclk kcontrol Add afe dyn mclk kcontrol to support change external clk. Change-Id: I90f0a4a6a350ec261f216aa53bfa2f7306987bc1 Signed-off-by: Jing Wang --- asoc/msm-dai-q6-v2.c | 223 ++++++++++++++++++++++++++++++++++++- dsp/q6afe.c | 79 ++++++++++++- include/dsp/apr_audio-v2.h | 12 ++ include/dsp/q6afe-v2.h | 3 + 4 files changed, 315 insertions(+), 2 deletions(-) diff --git a/asoc/msm-dai-q6-v2.c b/asoc/msm-dai-q6-v2.c index ceba2e0ac11c..d39ef1e49b3f 100755 --- a/asoc/msm-dai-q6-v2.c +++ b/asoc/msm-dai-q6-v2.c @@ -481,6 +481,8 @@ static bool afe_port_logging_item[IDX_TDM_MAX]; static int afe_port_loggging_control_added; +static int afe_dyn_mclk_control_added; + static DEFINE_MUTEX(tdm_mutex); static atomic_t tdm_group_ref[IDX_GROUP_TDM_MAX]; @@ -522,6 +524,51 @@ static struct afe_clk_set tdm_clk_set = { 0, }; +static int clk_id_index; +static int clk_root_index; +static int clk_attri_index; +static int global_dyn_mclk_cfg_portid; +struct afe_param_id_clock_set_v2_t global_dyn_mclk_cfg = { + .clk_set_minor_version = Q6AFE_LPASS_CLK_CONFIG_API_VERSION, + .clk_id = Q6AFE_LPASS_CLK_ID_TER_PCM_IBIT, + .clk_freq_in_hz = 12288000, + .clk_attri = Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO, + .clk_root = Q6AFE_LPASS_MCLK_IN0, + .divider_2x = AFE_CLOCK_DEFAULT_INTEGER_DIVIDER, + .m = AFE_CLOCK_DEFAULT_M_VALUE, + .n = AFE_CLOCK_DEFAULT_N_VALUE, + .d = AFE_CLOCK_DEFAULT_D_VALUE, + .enable = 0, +}; + +static int afe_dyn_clk_root_enum[] = { + Q6AFE_LPASS_MCLK_IN0, + Q6AFE_LPASS_MCLK_IN1, +}; + +static int afe_dyn_clk_attri_enum[] = { + Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO, + Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_DIVIDEND, + Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_DIVISOR, +}; + +static int afe_dyn_clk_id_enum[] = { + Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT, Q6AFE_LPASS_CLK_ID_PRI_MI2S_EBIT, + Q6AFE_LPASS_CLK_ID_SEC_MI2S_IBIT, Q6AFE_LPASS_CLK_ID_SEC_MI2S_EBIT, + Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT, Q6AFE_LPASS_CLK_ID_TER_MI2S_EBIT, + Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT, Q6AFE_LPASS_CLK_ID_QUAD_MI2S_EBIT, + Q6AFE_LPASS_CLK_ID_SPEAKER_I2S_IBIT, Q6AFE_LPASS_CLK_ID_SPEAKER_I2S_EBIT, + Q6AFE_LPASS_CLK_ID_SPEAKER_I2S_OSR, + Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT, Q6AFE_LPASS_CLK_ID_PRI_PCM_EBIT, + Q6AFE_LPASS_CLK_ID_SEC_PCM_IBIT, Q6AFE_LPASS_CLK_ID_SEC_PCM_EBIT, + Q6AFE_LPASS_CLK_ID_TER_PCM_IBIT, Q6AFE_LPASS_CLK_ID_TER_PCM_EBIT, + Q6AFE_LPASS_CLK_ID_QUAD_PCM_IBIT, Q6AFE_LPASS_CLK_ID_QUAD_PCM_EBIT, + Q6AFE_LPASS_CLK_ID_MCLK_1, Q6AFE_LPASS_CLK_ID_MCLK_2, + Q6AFE_LPASS_CLK_ID_MCLK_3, Q6AFE_LPASS_CLK_ID_MCLK_4, + Q6AFE_LPASS_CLK_ID_MCLK_5, Q6AFE_LPASS_CLK_ID_AHB_HDMI_INPUT, + Q6AFE_LPASS_CLK_ID_SPDIF_CORE +}; + static int msm_dai_q6_get_tdm_clk_ref(u16 id) { switch (id) { @@ -10371,14 +10418,168 @@ static int msm_pcm_add_afe_port_logging_control(struct snd_soc_dai *dai) return rc; } +static int get_global_clk_root(int value) +{ + if ((value < 0) || (value > ARRAY_SIZE(afe_dyn_clk_root_enum) - 1)) { + pr_err("%s, %d set clk_root range failed\n", __func__, __LINE__); + return global_dyn_mclk_cfg.clk_root; + } + clk_root_index = value; + return afe_dyn_clk_root_enum[clk_root_index]; +} + +static int get_global_clk_attri(int value) +{ + if ((value < 0) || (value > ARRAY_SIZE(afe_dyn_clk_attri_enum) - 1)) { + pr_err("%s, %d set clk_attri range failed\n", __func__, __LINE__); + return global_dyn_mclk_cfg.clk_attri; + } + clk_attri_index = value; + return afe_dyn_clk_attri_enum[clk_attri_index]; +} + +static int get_global_clk_id(int value) +{ + if ((value < 0) || (value > ARRAY_SIZE(afe_dyn_clk_id_enum) - 1)) { + pr_err("%s, %d set clk_id range failed\n", __func__, __LINE__); + return global_dyn_mclk_cfg.clk_id; + } + clk_id_index = value; + return afe_dyn_clk_id_enum[clk_id_index]; +} + +static int msm_pcm_afe_dyn_mclk_ctl_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *ucontrol) +{ + ucontrol->type = SNDRV_CTL_ELEM_TYPE_INTEGER; + /* 11 int values:clk_set_minor_version, clk_id, clk_freq_in_hz, clk_attri, + * clk_root, enable, divider_2x, m, n, d + */ + ucontrol->count = 11; + ucontrol->value.integer.min = 0; + ucontrol->value.integer.max = INT_MAX; + /* Valid range is all positive values to support above controls */ + pr_debug("%s,%d\n", __func__, __LINE__); + + return 0; +} + +static int msm_pcm_afe_dyn_mclk_ctl_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + ucontrol->value.integer.value[0] = global_dyn_mclk_cfg_portid; + ucontrol->value.integer.value[1] = clk_id_index; + ucontrol->value.integer.value[2] = global_dyn_mclk_cfg.clk_freq_in_hz; + ucontrol->value.integer.value[3] = clk_attri_index; + ucontrol->value.integer.value[4] = clk_root_index; + ucontrol->value.integer.value[5] = global_dyn_mclk_cfg.enable; + ucontrol->value.integer.value[6] = global_dyn_mclk_cfg.divider_2x; + ucontrol->value.integer.value[7] = global_dyn_mclk_cfg.m; + ucontrol->value.integer.value[8] = global_dyn_mclk_cfg.n; + ucontrol->value.integer.value[9] = global_dyn_mclk_cfg.d; + ucontrol->value.integer.value[10] = global_dyn_mclk_cfg.clk_set_minor_version; + + pr_debug("%s:%d.... portid:%d, clk_id:%d, clk_freq_in_hz:%d, clk_attri:%d, clk_root:%d, enable:%d, divider_2x:%d, m:%d, n:%d, d:%d, version:%d\n", + __func__, __LINE__, global_dyn_mclk_cfg_portid, global_dyn_mclk_cfg.clk_id, + global_dyn_mclk_cfg.clk_freq_in_hz, global_dyn_mclk_cfg.clk_attri, + global_dyn_mclk_cfg.clk_root, global_dyn_mclk_cfg.enable, + global_dyn_mclk_cfg.divider_2x, global_dyn_mclk_cfg.m, global_dyn_mclk_cfg.n, + global_dyn_mclk_cfg.d, global_dyn_mclk_cfg.clk_set_minor_version); + + return 0; +} + +static int msm_pcm_afe_dyn_mclk_ctl_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + int ret = -EINVAL; + + pr_debug("%s: enter\n", __func__); + + global_dyn_mclk_cfg_portid = ucontrol->value.integer.value[0]; + + global_dyn_mclk_cfg.clk_id = get_global_clk_id(ucontrol->value.integer.value[1]); + + if (ucontrol->value.integer.value[2] >= 0) + global_dyn_mclk_cfg.clk_freq_in_hz = ucontrol->value.integer.value[2]; + + global_dyn_mclk_cfg.clk_attri = get_global_clk_attri(ucontrol->value.integer.value[3]); + + global_dyn_mclk_cfg.clk_root = get_global_clk_root(ucontrol->value.integer.value[4]); + + if ((ucontrol->value.integer.value[5] <= 1) && (ucontrol->value.integer.value[5] >= 0)) + global_dyn_mclk_cfg.enable = ucontrol->value.integer.value[5]; + + global_dyn_mclk_cfg.divider_2x = ucontrol->value.integer.value[6]; + global_dyn_mclk_cfg.m = ucontrol->value.integer.value[7]; + global_dyn_mclk_cfg.n = ucontrol->value.integer.value[8]; + global_dyn_mclk_cfg.d = ucontrol->value.integer.value[9]; + + pr_debug("%s:%d.... portid:%d, clk_id_index:%d, clk_freq_in_hz:%d, clk_attri_index:%d, clk_root_index:%d, enable:%d, divider_2x:%d, m:%d, n:%d, d:%d, version:%d\n", + __func__, __LINE__, ucontrol->value.integer.value[0], + ucontrol->value.integer.value[1], + ucontrol->value.integer.value[2], ucontrol->value.integer.value[3], + ucontrol->value.integer.value[4], ucontrol->value.integer.value[5], + ucontrol->value.integer.value[6], ucontrol->value.integer.value[7], + ucontrol->value.integer.value[8], ucontrol->value.integer.value[9]); + + ret = afe_set_lpass_clk_cfg_ext_mclk_v2(global_dyn_mclk_cfg_portid, + &global_dyn_mclk_cfg, 0); + if (ret) + pr_err("%s: AFE port logging setting for port 0x%x failed %d\n", + __func__, global_dyn_mclk_cfg_portid, ret); + + return ret; +} + +static int msm_pcm_add_afe_dyn_mclk_control(struct snd_soc_dai *dai) +{ + int rc = 0; + struct snd_kcontrol_new *knew = NULL; + struct snd_kcontrol *kctl = NULL; + const char *afe_dyn_mclk_ctl_name = "AFE_dyn_switch_mclk_source"; + + /* Add AFE port logging controls */ + knew = kzalloc(sizeof(struct snd_kcontrol_new), GFP_KERNEL); + if (!knew) + return -ENOMEM; + + knew->iface = SNDRV_CTL_ELEM_IFACE_MIXER; + knew->info = msm_pcm_afe_dyn_mclk_ctl_info; + knew->get = msm_pcm_afe_dyn_mclk_ctl_get; + knew->put = msm_pcm_afe_dyn_mclk_ctl_put; + knew->name = afe_dyn_mclk_ctl_name; + knew->private_value = dai->id; + kctl = snd_ctl_new1(knew, knew); + if (!kctl) { + kfree(knew); + return -ENOMEM; + } + + rc = snd_ctl_add(dai->component->card->snd_card, kctl); + if (rc < 0) + pr_err("%s: err add AFE dyn mclk control, DAI = %s\n", + __func__, dai->name); + + return rc; +} + +int jitter_cleaner_afe_enable_mclk_and_get_info_cb_func(void *private_data, + uint32_t enable, uint32_t mclk_freq, + struct afe_param_id_clock_set_v2_t *dyn_mclk_cfg) +{ + pr_debug("%s,%d\n", __func__, __LINE__); + return 0; +} + static int msm_dai_q6_dai_tdm_probe(struct snd_soc_dai *dai) { int rc = 0; + int port_idx = 0; struct msm_dai_q6_tdm_dai_data *tdm_dai_data = NULL; struct snd_kcontrol *data_format_kcontrol = NULL; struct snd_kcontrol *header_type_kcontrol = NULL; struct snd_kcontrol *header_kcontrol = NULL; - int port_idx = 0; const struct snd_kcontrol_new *data_format_ctrl = NULL; const struct snd_kcontrol_new *header_type_ctrl = NULL; const struct snd_kcontrol_new *header_ctrl = NULL; @@ -10459,6 +10660,26 @@ static int msm_dai_q6_dai_tdm_probe(struct snd_soc_dai *dai) afe_port_loggging_control_added = 1; } + /* add AFE dyn mclk controls */ + if (!afe_dyn_mclk_control_added) { + rc = msm_pcm_add_afe_dyn_mclk_control(dai); + if (rc < 0) { + dev_err(dai->dev, "%s: add AFE dyn mclk control failed DAI: %s\n", + __func__, dai->name); + goto rtn; + } + + afe_dyn_mclk_control_added = 1; + + rc = afe_register_ext_mclk_cb(jitter_cleaner_afe_enable_mclk_and_get_info_cb_func, + (void *)&global_dyn_mclk_cfg); + if (rc < 0) { + dev_err(dai->dev, "%s: add AFE afe_register_ext_mclk_cb failed : %s\n", + __func__, dai->name); + goto rtn; + } + } + if (tdm_dai_data->is_island_dai) rc = msm_dai_q6_add_island_mx_ctls( dai->component->card->snd_card, diff --git a/dsp/q6afe.c b/dsp/q6afe.c index 9a7d7def16c8..9334d4c2972f 100755 --- a/dsp/q6afe.c +++ b/dsp/q6afe.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved. */ #include #include @@ -9792,7 +9793,6 @@ static int afe_set_lpass_clk_cfg_ext_mclk(int index, struct afe_clk_set *cfg, dyn_mclk_cfg.clk_id = cfg->clk_id; dyn_mclk_cfg.clk_attri = cfg->clk_attri; dyn_mclk_cfg.enable = cfg->enable; - pr_debug("%s: Minor version =0x%x clk id = %d\n", __func__, dyn_mclk_cfg.clk_set_minor_version, dyn_mclk_cfg.clk_id); pr_debug("%s: clk freq (Hz) = %d, clk attri = 0x%x\n", __func__, @@ -9831,6 +9831,83 @@ stop_mclk: return ret; } +int afe_set_lpass_clk_cfg_ext_mclk_v2(int index, struct afe_param_id_clock_set_v2_t *dyn_mclk_cfg, + uint32_t mclk_freq) +{ + struct param_hdr_v3 param_hdr; + int ret = 0; + + if (!dyn_mclk_cfg) { + pr_err("%s: clock cfg is NULL\n", __func__); + ret = -EINVAL; + return ret; + } + + if (index < 0 || index >= AFE_MAX_PORTS) { + pr_err("%s: index[%d] invalid!\n", __func__, index); + return -EINVAL; + } + + memset(¶m_hdr, 0, sizeof(param_hdr)); + param_hdr.module_id = AFE_MODULE_CLOCK_SET; + param_hdr.instance_id = INSTANCE_ID_0; + param_hdr.param_id = AFE_PARAM_ID_CLOCK_SET_V2; + param_hdr.param_size = sizeof(struct afe_param_id_clock_set_v2_t); + + if (afe_ext_mclk.ext_mclk_cb) { + ret = afe_ext_mclk.ext_mclk_cb(afe_ext_mclk.private_data, + dyn_mclk_cfg->enable, mclk_freq, dyn_mclk_cfg); + if (ret) { + pr_err_ratelimited("%s: get mclk cfg failed %d\n", + __func__, ret); + return ret; + } + } else { + pr_err_ratelimited("%s: mclk callback not registered\n", __func__); + return -EINVAL; + } + + dyn_mclk_cfg->clk_set_minor_version = 1; + + pr_debug("%s: Minor version =0x%x clk id = %d\n", __func__, + dyn_mclk_cfg->clk_set_minor_version, dyn_mclk_cfg->clk_id); + pr_debug("%s: clk freq (Hz) = %d, clk attri = 0x%x\n", __func__, + dyn_mclk_cfg->clk_freq_in_hz, dyn_mclk_cfg->clk_attri); + pr_debug("%s: clk root = 0x%x clk enable = 0x%x\n", __func__, + dyn_mclk_cfg->clk_root, dyn_mclk_cfg->enable); + pr_debug("%s: divider_2x =%d m = %d n = %d, d =%d\n", __func__, + dyn_mclk_cfg->divider_2x, dyn_mclk_cfg->m, dyn_mclk_cfg->n, + dyn_mclk_cfg->d); + + ret = afe_q6_interface_prepare(); + if (ret != 0) { + pr_err_ratelimited("%s: Q6 interface prepare failed %d\n", + __func__, ret); + goto stop_mclk; + } + + mutex_lock(&this_afe.afe_cmd_lock); + ret = q6afe_svc_pack_and_set_param_in_band(index, param_hdr, + (u8 *) dyn_mclk_cfg); + if (ret < 0) + pr_err_ratelimited("%s: ext MCLK clk cfg failed with ret %d\n", + __func__, ret); + + mutex_unlock(&this_afe.afe_cmd_lock); + + if (ret >= 0) + return ret; + +stop_mclk: + if (afe_ext_mclk.ext_mclk_cb && dyn_mclk_cfg->enable) { + afe_ext_mclk.ext_mclk_cb(afe_ext_mclk.private_data, + dyn_mclk_cfg->enable, mclk_freq, dyn_mclk_cfg); + } + + return ret; +} +EXPORT_SYMBOL(afe_set_lpass_clk_cfg_ext_mclk_v2); + /** * afe_set_lpass_clk_cfg - Set AFE clk config * diff --git a/include/dsp/apr_audio-v2.h b/include/dsp/apr_audio-v2.h index 4fb7b49c41fa..b70670c04d2b 100644 --- a/include/dsp/apr_audio-v2.h +++ b/include/dsp/apr_audio-v2.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved. */ @@ -12209,6 +12210,9 @@ struct afe_param_id_clip_bank_sel { /* Supported LPASS CLK root*/ #define Q6AFE_LPASS_CLK_ROOT_DEFAULT 0 +#define Q6AFE_LPASS_MCLK_IN0 1 +#define Q6AFE_LPASS_MCLK_IN1 2 + enum afe_lpass_clk_mode { Q6AFE_LPASS_MODE_BOTH_INVALID, Q6AFE_LPASS_MODE_CLK1_VALID, @@ -12362,6 +12366,8 @@ enum afe_lpass_clk_mode { /* Clock ID for AHB HDMI input */ #define Q6AFE_LPASS_CLK_ID_AHB_HDMI_INPUT 0x400 +#define Q6AFE_LPASS_CLK_ID_SPDIF_CORE 0x000 + /* Clock ID for the primary SPDIF output core. */ #define AFE_CLOCK_SET_CLOCK_ID_PRI_SPDIF_OUTPUT_CORE 0x500 /* Clock ID for the secondary SPDIF output core. */ @@ -12448,6 +12454,12 @@ struct afe_clk_set { #define AFE_PARAM_ID_CLOCK_SET_V2 0x000102E6 +#define AFE_CLOCK_SET_CLOCK_ROOT_DEFAULT 0x2 +#define AFE_CLOCK_DEFAULT_INTEGER_DIVIDER 0x0 +#define AFE_CLOCK_DEFAULT_M_VALUE 0x1 +#define AFE_CLOCK_DEFAULT_N_VALUE 0x2 +#define AFE_CLOCK_DEFAULT_D_VALUE 0x1 + #define AFE_API_VERSION_CLOCK_SET_V2 0x1 struct afe_param_id_clock_set_v2_t { diff --git a/include/dsp/q6afe-v2.h b/include/dsp/q6afe-v2.h index 48209087a8a2..016996e3bb67 100644 --- a/include/dsp/q6afe-v2.h +++ b/include/dsp/q6afe-v2.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef __Q6AFE_V2_H__ #define __Q6AFE_V2_H__ @@ -592,6 +593,8 @@ int afe_port_send_logging_cfg(u16 port_id, struct afe_param_id_port_data_log_disable_t *log_disable); int afe_get_av_dev_drift(struct afe_param_id_dev_timing_stats *timing_stats, u16 port); +int afe_set_lpass_clk_cfg_ext_mclk_v2(int index, + struct afe_param_id_clock_set_v2_t *dyn_mclk_cfg, uint32_t mclk_freq); int afe_get_sp_rx_tmax_xmax_logging_data( struct afe_sp_rx_tmax_xmax_logging_param *xt_logging, u16 port_id); From 2899520da559be50488c1aae093537af05e4d9f4 Mon Sep 17 00:00:00 2001 From: Huicheng Liu Date: Wed, 2 Feb 2022 17:19:28 -0500 Subject: [PATCH 52/82] asoc: Enable all LPAIF interface Enable all LPAIF interface Change-Id: I3f70cda077e6600785a8e706246d3ad3820e51ac Signed-off-by: Huicheng Liu --- asoc/gvm_auto_spf_dummy.c | 76 ++++++++++++++++++++++++++++++++++----- asoc/msm_dailink.h | 30 ++++++++++++++++ 2 files changed, 98 insertions(+), 8 deletions(-) diff --git a/asoc/gvm_auto_spf_dummy.c b/asoc/gvm_auto_spf_dummy.c index 93bd664ae14c..d017ee36573b 100755 --- a/asoc/gvm_auto_spf_dummy.c +++ b/asoc/gvm_auto_spf_dummy.c @@ -384,7 +384,7 @@ static struct snd_soc_dai_link msm_gvm8295_dai_links[] = { }, { .name = "QUAT_TDM_RX_0_DUMMY", - .stream_name = "TDM-LPAIF-RX-QUATERNARY", + .stream_name = "TDM-LPAIF_RXTX-RX-PRIMARY", .dpcm_playback = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, @@ -394,7 +394,7 @@ static struct snd_soc_dai_link msm_gvm8295_dai_links[] = { }, { .name = "QUAT_TDM_TX_0_DUMMY", - .stream_name = "TDM-LPAIF-TX-QUATERNARY", + .stream_name = "TDM-LPAIF_RXTX-TX-PRIMARY", .dpcm_capture = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, @@ -404,7 +404,7 @@ static struct snd_soc_dai_link msm_gvm8295_dai_links[] = { }, { .name = "QUIN_TDM_RX_0_DUMMY", - .stream_name = "TDM-LPAIF-RX-QUINARY", + .stream_name = "TDM-LPAIF_VA-RX-PRIMARY", .dpcm_playback = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, @@ -414,7 +414,7 @@ static struct snd_soc_dai_link msm_gvm8295_dai_links[] = { }, { .name = "QUIN_TDM_TX_0_DUMMY", - .stream_name = "TDM-LPAIF-TX-QUINARY", + .stream_name = "TDM-LPAIF_VA-TX-PRIMARY", .dpcm_capture = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, @@ -424,7 +424,7 @@ static struct snd_soc_dai_link msm_gvm8295_dai_links[] = { }, { .name = "SEN_TDM_RX_0_DUMMY", - .stream_name = "TDM-LPAIF-RX-SENARY", + .stream_name = "TDM-LPAIF_WSA-RX-PRIMARY", .dpcm_playback = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, @@ -434,7 +434,7 @@ static struct snd_soc_dai_link msm_gvm8295_dai_links[] = { }, { .name = "SEN_TDM_TX_0_DUMMY", - .stream_name = "TDM-LPAIF-TX-SENARY", + .stream_name = "TDM-LPAIF_WSA-TX-PRIMARY", .dpcm_capture = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, @@ -444,7 +444,7 @@ static struct snd_soc_dai_link msm_gvm8295_dai_links[] = { }, { .name = "SEP_TDM_RX_0_DUMMY", - .stream_name = "TDM-LPAIF-RX-SEPTENARY", + .stream_name = "TDM-LPAIF_AUD-RX-PRIMARY", .dpcm_playback = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, @@ -454,7 +454,7 @@ static struct snd_soc_dai_link msm_gvm8295_dai_links[] = { }, { .name = "SEP_TDM_TX_0_DUMMY", - .stream_name = "TDM-LPAIF-TX-SEPTENARY", + .stream_name = "TDM-LPAIF_AUD-TX-PRIMARY", .dpcm_capture = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, @@ -462,6 +462,66 @@ static struct snd_soc_dai_link msm_gvm8295_dai_links[] = { .ignore_pmdown_time = 1, SND_SOC_DAILINK_REG(sep_tdm_tx_0_dummy), }, + { + .name = "HS_IF0_TDM_RX_0_DUMMY", + .stream_name = "TDM-LPAIF_SDR-RX-PRIMARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(hs_if0_tdm_rx_0_dummy), + }, + { + .name = "HS_IF0_TDM_TX_0_DUMMY", + .stream_name = "TDM-LPAIF_SDR-TX-PRIMARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(hs_if0_tdm_tx_0_dummy), + }, + { + .name = "HS_IF1_TDM_RX_0_DUMMY", + .stream_name = "TDM-LPAIF_SDR-RX-SECONDARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(hs_if1_tdm_rx_0_dummy), + }, + { + .name = "HS_IF1_TDM_TX_0_DUMMY", + .stream_name = "TDM-LPAIF_SDR-TX-SECONDARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(hs_if1_tdm_tx_0_dummy), + }, + { + .name = "HS_IF2_TDM_RX_0_DUMMY", + .stream_name = "TDM-LPAIF_SDR-RX-TERTIARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(hs_if2_tdm_rx_0_dummy), + }, + { + .name = "HS_IF2_TDM_TX_0_DUMMY", + .stream_name = "TDM-LPAIF_SDR-TX-TERTIARY", + .dpcm_capture = 1, + .trigger = {SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST}, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(hs_if2_tdm_tx_0_dummy), + }, }; static struct snd_soc_dai_link msm_talos_dai_links[] = { diff --git a/asoc/msm_dailink.h b/asoc/msm_dailink.h index 171db997f9df..4d9d1f5e1f64 100755 --- a/asoc/msm_dailink.h +++ b/asoc/msm_dailink.h @@ -1384,3 +1384,33 @@ SND_SOC_DAILINK_DEFS(sep_tdm_tx_0_dummy, DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + +SND_SOC_DAILINK_DEFS(hs_if0_tdm_rx_0_dummy, + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + +SND_SOC_DAILINK_DEFS(hs_if0_tdm_tx_0_dummy, + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + +SND_SOC_DAILINK_DEFS(hs_if1_tdm_rx_0_dummy, + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + +SND_SOC_DAILINK_DEFS(hs_if1_tdm_tx_0_dummy, + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + +SND_SOC_DAILINK_DEFS(hs_if2_tdm_rx_0_dummy, + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); + +SND_SOC_DAILINK_DEFS(hs_if2_tdm_tx_0_dummy, + DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")), + DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy"))); From ca6e1b40e30309620a3da6586207ea691d63d268 Mon Sep 17 00:00:00 2001 From: Hongtao Peng Date: Thu, 24 Feb 2022 10:30:40 +0800 Subject: [PATCH 53/82] dsp: support ADM output map for less then 2 channels Remove the conditional restriction greater than 2 in adm_arrange_mch_map_v8 Change-Id: I3bab28ddb443cd589d8de3751bd19b2a199978ab Signed-off-by: Hongtao Peng --- dsp/q6adm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) mode change 100755 => 100644 dsp/q6adm.c diff --git a/dsp/q6adm.c b/dsp/q6adm.c old mode 100755 new mode 100644 index 53a70d396ab2..9ad4cd90cd20 --- a/dsp/q6adm.c +++ b/dsp/q6adm.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include #include @@ -2720,9 +2721,8 @@ static int adm_arrange_mch_map_v8( goto non_mch_path; }; - if ((ep_payload->dev_num_channel > 2) && - (port_channel_map[port_idx].set_channel_map || - multi_ch_maps[idx].set_channel_map)) { + if (port_channel_map[port_idx].set_channel_map || + multi_ch_maps[idx].set_channel_map) { if (port_channel_map[port_idx].set_channel_map) memcpy(ep_payload->dev_channel_mapping, port_channel_map[port_idx].channel_mapping, From 91c556699af69ca3521ba7dee49858eea90e9e7e Mon Sep 17 00:00:00 2001 From: Krishna Kishor Jha Date: Mon, 21 Feb 2022 18:43:37 +0530 Subject: [PATCH 54/82] msm-audio: adding mixer control for soft step volume params adding new mixer control for set/get soft step volume module params values. This command is attached to FE DAI. Change-Id: I2572d6abe48dcb4d1fb685b5e9c0695fe83cc88a Signed-off-by: Krishna Kishor Jha --- asoc/msm-pcm-q6-v2.c | 187 ++++++++++++++++++++++++++++++++++++++ asoc/msm-pcm-routing-v2.c | 75 +++++++++++++++ asoc/msm-pcm-routing-v2.h | 20 ++++ include/dsp/q6asm-v2.h | 2 + 4 files changed, 284 insertions(+) mode change 100644 => 100755 asoc/msm-pcm-q6-v2.c mode change 100644 => 100755 asoc/msm-pcm-routing-v2.h mode change 100644 => 100755 include/dsp/q6asm-v2.h diff --git a/asoc/msm-pcm-q6-v2.c b/asoc/msm-pcm-q6-v2.c old mode 100644 new mode 100755 index b084c0081f1e..70fc54190027 --- a/asoc/msm-pcm-q6-v2.c +++ b/asoc/msm-pcm-q6-v2.c @@ -129,6 +129,8 @@ static struct snd_pcm_hw_constraint_list constraints_sample_rates = { .mask = 0, }; +static struct asm_softvolume_params soft_params = {0,0,0}; + struct msm_pcm_channel_map *chmap_pspd[MSM_FRONTEND_DAI_MM_SIZE][2]; static void msm_pcm_route_event_handler(enum msm_pcm_routing_event event, @@ -151,6 +153,181 @@ static void msm_pcm_route_event_handler(enum msm_pcm_routing_event event, } } +static int msm_pcm_set_soft_volume_params(struct msm_audio *prtd,struct asm_softvolume_params *soft_vol_params) +{ + int rc = 0; + + switch (prtd->audio_client->topology) { + default: + rc = q6asm_set_softvolume_v2(prtd->audio_client, soft_vol_params, + SOFT_VOLUME_INSTANCE_1); + if (rc < 0) + pr_err("%s: Send SoftVolume Param failed ret=%d\n", + __func__, rc); + + } + return rc; +} + +static int msm_pcm_soft_volume_ctl_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + + struct snd_pcm_soft_volume *soft_vol = (struct snd_pcm_soft_volume *) snd_kcontrol_chip(kcontrol); + struct msm_plat_data *pdata = NULL; + struct snd_pcm_substream *substream = NULL; + struct snd_soc_pcm_runtime *soc_prtd = NULL; + struct snd_soc_component *component = NULL; + + pr_debug("%s\n", __func__); + + if (!soft_vol || !soft_vol->pcm) { + pr_err("%s: soft vol is NULL\n", __func__); + return -ENODEV; + } + + substream = soft_vol->pcm->streams[soft_vol->stream].substream; + if (!substream) { + pr_err("%s substream not found\n", __func__); + return -ENODEV; + } + soc_prtd = substream->private_data; + if (!soc_prtd) { + pr_err("%s substream runtime or private_data not found\n", + __func__); + return -ENODEV; + } + + component = snd_soc_rtdcom_lookup(soc_prtd, DRV_NAME); + if (!component || !component->dev) { + pr_err("%s: component is NULL\n", __func__); + return -ENODEV; + } + + pdata = (struct msm_plat_data *) dev_get_drvdata(component->dev); + if (!pdata) { + pr_err("%s: pdata not found\n", __func__); + return -ENODEV; + } + + mutex_lock(&pdata->lock); + + ucontrol->value.integer.value[0] = soft_params.period; + ucontrol->value.integer.value[1] = soft_params.step; + ucontrol->value.integer.value[2] = soft_params.rampingcurve; + pr_debug("%s: period = %d, step = %d , ramping curve: %d",__func__, + ucontrol->value.integer.value[0], + ucontrol->value.integer.value[1], + ucontrol->value.integer.value[2]); + + mutex_unlock(&pdata->lock); + return 0; +} + +static int msm_pcm_soft_volume_ctl_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + int rc = 0; + struct snd_pcm_soft_volume *soft_vol = (struct snd_pcm_soft_volume *) snd_kcontrol_chip(kcontrol); + struct msm_plat_data *pdata = NULL; + struct snd_soc_pcm_runtime *soc_prtd = NULL; + struct snd_soc_component *component = NULL; + struct snd_pcm_substream *substream = NULL; + + struct msm_audio *prtd; + + if (!soft_vol || !soft_vol->pcm) { + pr_err("%s: soft vol is NULL\n", __func__); + return -ENODEV; + } + + substream = soft_vol->pcm->streams[soft_vol->stream].substream; + if (!substream) { + pr_err("%s: substream not found\n", __func__); + return -ENODEV; + } + + soc_prtd = substream->private_data; + if (!substream->runtime || !soc_prtd) { + pr_err("%s: substream runtime or private_data not found\n", + __func__); + return -ENODEV; + } + + component = snd_soc_rtdcom_lookup(soc_prtd, DRV_NAME); + if (!component || !component->dev) { + pr_err("%s: component is NULL\n", __func__); + return -ENODEV; + } + + pdata = (struct msm_plat_data *) dev_get_drvdata(component->dev); + if (!pdata) { + pr_err("%s: pdata not found\n", __func__); + return -ENODEV; + } + + mutex_lock(&pdata->lock); + + if (substream->ref_count > 0) { + prtd = substream->runtime->private_data; + + if ( prtd) { + if ((ucontrol->value.integer.value[0] < 0) || (ucontrol->value.integer.value[0] > 15000)) { + pr_err("%s : Ramp period range (0 to 15000), input value is out of range: %d",__func__,soft_params.period); + goto exit; + } else { + soft_params.period = ucontrol->value.integer.value[0]; + } + if ((ucontrol->value.integer.value[1] < 0) || (ucontrol->value.integer.value[1] > 15000000)) { + pr_err("%s : Ramp step range (0 to 15000000), input value is out of range: %d",__func__,soft_params.step); + goto exit; + } else { + soft_params.step = ucontrol->value.integer.value[1]; + } + if ((ucontrol->value.integer.value[2] < 0) || (ucontrol->value.integer.value[2] >= SOFT_VOLUME_CURVE_ENUM_MAX)) { + pr_err("%s : Ramping curve range (0 to 2), input value is out of range: %d",__func__,soft_params.rampingcurve); + goto exit; + } else { + soft_params.rampingcurve = ucontrol->value.integer.value[2]; + } + + pr_debug("%s : soft vol params, period: %d, step: %d, ramp curve: %d",__func__,soft_params.period, + soft_params.step,soft_params.rampingcurve); + rc = msm_pcm_set_soft_volume_params(prtd, &soft_params); + } else { + pr_err("%s: prtd not found\n", __func__); + return -ENODEV; + } + } else { + pr_err("%s: substream ref count is invalid\n", __func__); + return -ENODEV; + } +exit: + mutex_unlock(&pdata->lock); + return rc; +} + +static int msm_pcm_add_soft_volume_params_control(struct snd_soc_pcm_runtime *rtd, int stream) +{ + int ret = 0; + struct snd_pcm *pcm = rtd->pcm; + struct snd_pcm_soft_volume *soft_vol = NULL; + struct snd_kcontrol *kctl = NULL; + + dev_dbg(rtd->dev, "%s, volume control add\n", __func__); + ret = snd_pcm_add_soft_volume_ctls(pcm, stream, + NULL,/* 1,*/ rtd->dai_link->id, + &soft_vol); + if (ret < 0) { + pr_err("%s volume control failed ret %d\n", __func__, ret); + return ret; + } + kctl = soft_vol->kctl; + kctl->put = msm_pcm_soft_volume_ctl_put; + kctl->get = msm_pcm_soft_volume_ctl_get; + return 0; +} + static void event_handler(uint32_t opcode, uint32_t token, uint32_t *payload, void *priv) { @@ -3497,6 +3674,16 @@ static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd) pr_err("%s: Could not add pcm Volume Control %d\n", __func__, ret); ret = msm_pcm_add_volume_control(rtd, SNDRV_PCM_STREAM_CAPTURE); + if (ret) + pr_err("%s: Could not add pcm Volume Control %d\n", + __func__, ret); + /* adding soft vol module params mixer control command*/ + ret = msm_pcm_add_soft_volume_params_control(rtd, SNDRV_PCM_STREAM_PLAYBACK); + if (ret) + pr_err("%s: Could not add pcm Volume Control %d\n", + __func__, ret); + + ret = msm_pcm_add_soft_volume_params_control(rtd, SNDRV_PCM_STREAM_CAPTURE); if (ret) pr_err("%s: Could not add pcm Volume Control %d\n", __func__, ret); diff --git a/asoc/msm-pcm-routing-v2.c b/asoc/msm-pcm-routing-v2.c index 5b7fc20a08e4..8d8a5931bbe7 100644 --- a/asoc/msm-pcm-routing-v2.c +++ b/asoc/msm-pcm-routing-v2.c @@ -182,6 +182,81 @@ static int msm_routing_send_device_pp_params(int port_id, int copp_idx, static void msm_routing_load_topology(size_t data_size, void *data); static void msm_routing_unload_topology(uint32_t topology_id); +static int pcm_soft_volume_ctl_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; + uinfo->count = SOFT_VOLUME_CURVE_ENUM_MAX; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = INT_MAX; + return 0; +} + +static void pcm_soft_volume_ctl_private_free(struct snd_kcontrol *kcontrol) +{ + struct snd_pcm_volume *info = snd_kcontrol_chip(kcontrol); + + kfree(info); +} + +int snd_pcm_add_soft_volume_ctls(struct snd_pcm *pcm, int stream, + const struct snd_pcm_soft_vol_usr_elem *soft_vol_params, + unsigned long private_value, + struct snd_pcm_soft_volume **info_ret) +{ + int err = 0; + int size = 0; + struct snd_pcm_soft_volume *info; + struct snd_kcontrol_new knew = { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | + SNDRV_CTL_ELEM_ACCESS_READWRITE, + .info = pcm_soft_volume_ctl_info, + }; + + info = kzalloc(sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + info->pcm = pcm; + info->stream = stream; + info->usr_val = soft_vol_params; + size = sizeof("Playback ") + sizeof("Soft Vol Params") + + STRING_LENGTH_OF_INT*sizeof(char) + 1; + knew.name = kzalloc(size, GFP_KERNEL); + if (!knew.name) { + kfree(info); + return -ENOMEM; + } + if (stream == SNDRV_PCM_STREAM_PLAYBACK) + snprintf((char *)knew.name, size, "%s %d %s", + "Playback ", pcm->device, "Soft Vol Params"); + else + snprintf((char *)knew.name, size, "%s %d %s", + "Capture", pcm->device, "Soft Vol Params"); + knew.device = pcm->device; + knew.count = pcm->streams[stream].substream_count; + knew.private_value = private_value; + info->kctl = snd_ctl_new1(&knew, info); + if (!info->kctl) { + kfree(info); + kfree(knew.name); + return -ENOMEM; + } + info->kctl->private_free = pcm_soft_volume_ctl_private_free; + err = snd_ctl_add(pcm->card, info->kctl); + if (err < 0) { + kfree(info); + kfree(knew.name); + return -ENOMEM; + } + if (info_ret) + *info_ret = info; + kfree(knew.name); + + return 0; +} +EXPORT_SYMBOL(snd_pcm_add_soft_volume_ctls); + #ifndef SND_PCM_ADD_VOLUME_CTL static int pcm_volume_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) diff --git a/asoc/msm-pcm-routing-v2.h b/asoc/msm-pcm-routing-v2.h old mode 100644 new mode 100755 index 4a8e4b6eda58..6414d959eb95 --- a/asoc/msm-pcm-routing-v2.h +++ b/asoc/msm-pcm-routing-v2.h @@ -800,6 +800,26 @@ int msm_pcm_routing_set_channel_mixer_runtime( int msm_pcm_routing_set_stream_ec_ref_chmix_cfg( int fedai_id, struct msm_pcm_channel_mixer *cfg_data); + +/* array element of usr elem */ +struct snd_pcm_soft_vol_usr_elem { + int val[3]; +}; + +/* mixer control information; retrieved via snd_kcontrol_chip() */ +struct snd_pcm_soft_volume { + struct snd_pcm *pcm; /* assigned PCM instance */ + int stream; /* PLAYBACK or CAPTURE */ + struct snd_kcontrol *kctl; /* contorl handle*/ + const struct snd_pcm_soft_vol_usr_elem *usr_val; + int max_length; + void *private_data; +}; + +int snd_pcm_add_soft_volume_ctls(struct snd_pcm *pcm, int stream, + const struct snd_pcm_soft_vol_usr_elem *soft_vol_params, + unsigned long private_value, + struct snd_pcm_soft_volume **info_ret); #ifndef SND_PCM_ADD_VOLUME_CTL /* PCM Volume control API */ diff --git a/include/dsp/q6asm-v2.h b/include/dsp/q6asm-v2.h old mode 100644 new mode 100755 index eab3656e5161..37525c57a928 --- a/include/dsp/q6asm-v2.h +++ b/include/dsp/q6asm-v2.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2012-2019, 2021 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef __Q6_ASM_V2_H__ #define __Q6_ASM_V2_H__ @@ -150,6 +151,7 @@ enum { SOFT_VOLUME_CURVE_LINEAR = 0, SOFT_VOLUME_CURVE_EXP, SOFT_VOLUME_CURVE_LOG, + SOFT_VOLUME_CURVE_ENUM_MAX, }; #define SOFT_VOLUME_INSTANCE_1 1 From 7efca5cc14ed8d3886edc617af19641b251789e6 Mon Sep 17 00:00:00 2001 From: Hongtao Peng Date: Thu, 24 Feb 2022 00:05:54 +0800 Subject: [PATCH 55/82] ASoC: msm: support multi group matrix mixer configure for SSMD mode SSMD mode need to map one ASM session to multiple devices Need to configure all Matrix Mixer map for each device. Change-Id: I149a2f91561a99539cfbd16f1dbfe4c973976575 Signed-off-by: Hongtao Peng --- asoc/msm-pcm-routing-v2.c | 148 +++++++++++++++++++++++++------------- asoc/msm-pcm-routing-v2.h | 8 +++ 2 files changed, 106 insertions(+), 50 deletions(-) mode change 100644 => 100755 asoc/msm-pcm-routing-v2.c diff --git a/asoc/msm-pcm-routing-v2.c b/asoc/msm-pcm-routing-v2.c old mode 100644 new mode 100755 index 5b7fc20a08e4..5c1c6b7bad44 --- a/asoc/msm-pcm-routing-v2.c +++ b/asoc/msm-pcm-routing-v2.c @@ -105,8 +105,7 @@ static struct msm_ec_ref_port_cfg ec_ref_port_cfg; static struct msm_pcm_channel_mixer channel_mixer[MSM_FRONTEND_DAI_MM_SIZE]; /* all the FES which can support channel mixer for bidirection */ -static struct msm_pcm_channel_mixer - channel_mixer_v2[MSM_FRONTEND_DAI_MM_SIZE][2]; +static struct msm_pcm_channel_mixer_v2 channel_mixer_v2[MT_MX_MAX_PORTS]; /* input BE for each FE */ static int channel_input[MSM_FRONTEND_DAI_MM_SIZE][ADM_MAX_CHANNELS]; @@ -1308,6 +1307,38 @@ static int get_copp_perf_mode(int fe_id, int sess_type, int port) return rc; } +static int get_available_chmixer_index(int fe_id, int sess_type, int be_id) +{ + int index = 0; + bool need_research = true; + + /* + * If there is a item that have the same fe_id sess_type and be_id + * with input, use the index of this item and update it. + */ + for (index = 0; index < MT_MX_MAX_PORTS; index++) { + if ((channel_mixer_v2[index].fedai_id == fe_id) && + (channel_mixer_v2[index].session_type == sess_type) && + (channel_mixer_v2[index].be_id == be_id)) { + need_research = false; + break; + } + } + + /* + * If the item with fe_id sess_type and be_id is not exist, + * find an new unused item + */ + if (need_research) { + for (index = 0; index < MT_MX_MAX_PORTS; index++) { + if (!channel_mixer_v2[index].is_used) + break; + } + } + + return index; +} + /* * msm_pcm_routing_send_chmix_cfg: * send the channel mixer command to mix the input channels @@ -1385,31 +1416,46 @@ int msm_pcm_routing_set_channel_mixer_cfg( int fe_id, int type, struct msm_pcm_channel_mixer *params) { - int i, j = 0; + int i, j, index = 0; + int be_id = params->port_idx - 1; - channel_mixer_v2[fe_id][type].enable = params->enable; - channel_mixer_v2[fe_id][type].rule = params->rule; - channel_mixer_v2[fe_id][type].input_channel = + index = get_available_chmixer_index(fe_id, type, be_id); + if (index >= MT_MX_MAX_PORTS) { + pr_err("%s: Set channel mixer configure Fail!\n", __func__); + return -EINVAL; + } + + memset(&channel_mixer_v2[index], 0, + sizeof(struct msm_pcm_channel_mixer_v2)); + channel_mixer_v2[index].is_used = true; + channel_mixer_v2[index].fedai_id = fe_id; + channel_mixer_v2[index].session_type = type; + channel_mixer_v2[index].be_id = be_id; + channel_mixer_v2[index].mixer_cfg.port_idx = params->port_idx; + channel_mixer_v2[index].mixer_cfg.enable = params->enable; + channel_mixer_v2[index].mixer_cfg.rule = params->rule; + channel_mixer_v2[index].mixer_cfg.input_channel = params->input_channel; - channel_mixer_v2[fe_id][type].output_channel = + channel_mixer_v2[index].mixer_cfg.output_channel = params->output_channel; - channel_mixer_v2[fe_id][type].port_idx = params->port_idx; + channel_mixer_v2[index].mixer_cfg.input_channels[0] = + params->input_channel; for (i = 0; i < ADM_MAX_CHANNELS; i++) - channel_mixer_v2[fe_id][type].in_ch_map[i] = + channel_mixer_v2[index].mixer_cfg.in_ch_map[i] = params->in_ch_map[i]; for (i = 0; i < ADM_MAX_CHANNELS; i++) - channel_mixer_v2[fe_id][type].out_ch_map[i] = + channel_mixer_v2[index].mixer_cfg.out_ch_map[i] = params->out_ch_map[i]; for (i = 0; i < ADM_MAX_CHANNELS; i++) for (j = 0; j < ADM_MAX_CHANNELS; j++) - channel_mixer_v2[fe_id][type].channel_weight[i][j] = + channel_mixer_v2[index].mixer_cfg.channel_weight[i][j] = params->channel_weight[i][j]; - channel_mixer_v2[fe_id][type].override_in_ch_map = + channel_mixer_v2[index].mixer_cfg.override_in_ch_map = params->override_in_ch_map; - channel_mixer_v2[fe_id][type].override_out_ch_map = + channel_mixer_v2[index].mixer_cfg.override_out_ch_map = params->override_out_ch_map; return 0; @@ -2134,9 +2180,10 @@ static u32 msm_pcm_routing_get_voc_sessionid(u16 val) static int msm_pcm_routing_channel_mixer_v2(int fe_id, bool perf_mode, int dspst_id, int stream_type) { + struct msm_pcm_channel_mixer *mixer_config; int copp_idx = 0; int sess_type = 0; - int j = 0, be_id = 0; + int i = 0, j = 0, be_id = 0; int ret = 0; if (fe_id >= MSM_FRONTEND_DAI_MM_SIZE) { @@ -2149,44 +2196,45 @@ static int msm_pcm_routing_channel_mixer_v2(int fe_id, bool perf_mode, else sess_type = SESSION_TYPE_TX; - if (!(channel_mixer_v2[fe_id][sess_type].enable)) { - pr_debug("%s: channel mixer not enabled for FE %d direction %d\n", - __func__, fe_id, sess_type); - return 0; - } - - be_id = channel_mixer_v2[fe_id][sess_type].port_idx - 1; - if (be_id < 0 || be_id >= MSM_BACKEND_DAI_MAX) { - pr_err("%s: Received out of bounds be_id %d\n", - __func__, be_id); - return -EINVAL; - } - channel_mixer_v2[fe_id][sess_type].input_channels[0] = - channel_mixer_v2[fe_id][sess_type].input_channel; - - pr_debug("%s sess type %d,fe_id %d,override in:%d out:%d,be active %d\n", - __func__, sess_type, fe_id, - channel_mixer_v2[fe_id][sess_type].override_in_ch_map, - channel_mixer_v2[fe_id][sess_type].override_out_ch_map, - msm_bedais[be_id].active); - - if ((msm_bedais[be_id].active) && - test_bit(fe_id, &msm_bedais[be_id].fe_sessions[0])) { - unsigned long copp = - session_copp_map[fe_id][sess_type][be_id]; - for (j = 0; j < MAX_COPPS_PER_PORT; j++) { - if (test_bit(j, &copp)) { - copp_idx = j; - break; + for (i = 0; i < MT_MX_MAX_PORTS; i++) { + if ((channel_mixer_v2[i].fedai_id == fe_id) && + (channel_mixer_v2[i].session_type == sess_type)) { + if ((!channel_mixer_v2[i].mixer_cfg.enable) || + !(channel_mixer_v2[i].is_used)) { + pr_debug("%s: channel mixer not enabled for FE %d direction %d\n", + __func__, fe_id, sess_type); + continue; + } + be_id = channel_mixer_v2[i].be_id; + if (be_id < 0 || be_id >= MSM_BACKEND_DAI_MAX) { + pr_err("%s: Received out of bounds be_id %d\n", + __func__, be_id); + return -EINVAL; + } + mixer_config = &channel_mixer_v2[i].mixer_cfg; + pr_debug("%s sess type %d,fe_id %d,override in:%d out:%d,be active %d\n", + __func__, sess_type, fe_id, + mixer_config->override_in_ch_map, + mixer_config->override_out_ch_map, + msm_bedais[be_id].active); + if ((msm_bedais[be_id].active) && + test_bit(fe_id, &msm_bedais[be_id].fe_sessions[0])) { + unsigned long copp = + session_copp_map[fe_id][sess_type][be_id]; + for (j = 0; j < MAX_COPPS_PER_PORT; j++) { + if (test_bit(j, &copp)) { + copp_idx = j; + break; + } + } + ret = adm_programable_channel_mixer( + msm_bedais[be_id].port_id, + copp_idx, dspst_id, sess_type, + mixer_config, 0); + channel_mixer_v2[i].is_used = false; + } } - } - - ret = adm_programable_channel_mixer( - msm_bedais[be_id].port_id, - copp_idx, dspst_id, sess_type, - &channel_mixer_v2[fe_id][sess_type], 0); } - return ret; } diff --git a/asoc/msm-pcm-routing-v2.h b/asoc/msm-pcm-routing-v2.h index 4a8e4b6eda58..583189b93371 100644 --- a/asoc/msm-pcm-routing-v2.h +++ b/asoc/msm-pcm-routing-v2.h @@ -688,6 +688,7 @@ enum { #define STREAM_TYPE_ASM 0 #define STREAM_TYPE_LSM 1 +#define MT_MX_MAX_PORTS 64 #define PP_PERF_MODE_FLAG_MASK 0x10000 #define PP_PERF_MODE_VALUE_MASK 0xF @@ -749,6 +750,13 @@ struct msm_pcm_stream_app_type_cfg { int copp_perf_mode; }; +struct msm_pcm_channel_mixer_v2 { + struct msm_pcm_channel_mixer mixer_cfg; + int fedai_id; + int session_type; + int be_id; + bool is_used; +}; /* dai_id: front-end ID, * dspst_id: DSP audio stream ID * stream_type: playback or capture From 4a7f98b01c979c853a41bdd90c1a89eeb2a6b6a1 Mon Sep 17 00:00:00 2001 From: ftong Date: Thu, 24 Feb 2022 16:25:53 +0800 Subject: [PATCH 56/82] asoc:msm-lsm-client: potential deadlock fix After acquiring spinlock, if memory allocation fails, the spinlock is not released, thus inducing a potential deadlock. Change-Id: I8d390437a00b8a9ca2cb216f47434a0448506e1f Signed-off-by: ftong --- asoc/msm-lsm-client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/asoc/msm-lsm-client.c b/asoc/msm-lsm-client.c index 69768bc38e51..b688d64a06ee 100644 --- a/asoc/msm-lsm-client.c +++ b/asoc/msm-lsm-client.c @@ -412,6 +412,7 @@ static void lsm_event_handler(uint32_t opcode, uint32_t token, if (!temp) { dev_err(rtd->dev, "%s: no memory for event status\n", __func__); + spin_unlock_irqrestore(&prtd->event_lock, flags); __pm_relax(prtd->ws); return; } From 1e417536ee872b2f806eba168e6d2272860d03cf Mon Sep 17 00:00:00 2001 From: Aditya Bavanari Date: Fri, 25 Feb 2022 10:17:53 +0530 Subject: [PATCH 57/82] asoc: Set clock index correctly in mi2s slave mode When msm acts as slave mode in mi2s, clock ID for a clock index is not properly updated for first time. Fix the sequence issue to update clock ID accordingly for slave mode. Change-Id: Ie601547e8a5677ee778ff707f55e2d861a35f459 Signed-off-by: Aditya Bavanari --- asoc/bengal.c | 9 +++++---- asoc/holi.c | 9 +++++---- asoc/kona.c | 9 +++++---- asoc/lahaina.c | 9 +++++---- asoc/qcs405.c | 9 +++++---- asoc/sa6155.c | 9 +++++---- asoc/sa8155.c | 9 +++++---- asoc/sm6150.c | 9 +++++---- asoc/sm8150.c | 9 +++++---- 9 files changed, 45 insertions(+), 36 deletions(-) diff --git a/asoc/bengal.c b/asoc/bengal.c index 2fff3ff5d19b..08517e07ae30 100644 --- a/asoc/bengal.c +++ b/asoc/bengal.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -3956,6 +3957,9 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) */ mutex_lock(&mi2s_intf_conf[index].lock); if (++mi2s_intf_conf[index].ref_cnt == 1) { + /* Check if msm needs to provide the clock to the interface */ + if (!mi2s_intf_conf[index].msm_is_mi2s_master) + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; ret = msm_mi2s_set_sclk(substream, true); if (ret < 0) { dev_err(rtd->card->dev, @@ -3978,11 +3982,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) atomic_inc(&(pdata->mi2s_gpio_ref_count[index])); } } - /* Check if msm needs to provide the clock to the interface */ - if (!mi2s_intf_conf[index].msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + if (!mi2s_intf_conf[index].msm_is_mi2s_master) fmt = SND_SOC_DAIFMT_CBM_CFM; - } ret = snd_soc_dai_set_fmt(cpu_dai, fmt); if (ret < 0) { pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", diff --git a/asoc/holi.c b/asoc/holi.c index c364512af581..5cf2b1ad56f5 100644 --- a/asoc/holi.c +++ b/asoc/holi.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -4459,6 +4460,9 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) } if (++mi2s_intf_conf[index].ref_cnt == 1) { + /* Check if msm needs to provide the clock to the interface */ + if (!mi2s_intf_conf[index].msm_is_mi2s_master) + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; ret = msm_mi2s_set_sclk(substream, true); if (ret < 0) { dev_err(rtd->card->dev, @@ -4481,11 +4485,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) atomic_inc(&(pdata->mi2s_gpio_ref_count[index])); } } - /* Check if msm needs to provide the clock to the interface */ - if (!mi2s_intf_conf[index].msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + if (!mi2s_intf_conf[index].msm_is_mi2s_master) fmt = SND_SOC_DAIFMT_CBM_CFM; - } ret = snd_soc_dai_set_fmt(cpu_dai, fmt); if (ret < 0) { pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", diff --git a/asoc/kona.c b/asoc/kona.c index 2286f288ed4f..06b4fd167299 100644 --- a/asoc/kona.c +++ b/asoc/kona.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -5100,6 +5101,9 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) } if (++mi2s_intf_conf[index].ref_cnt == 1) { + /* Check if msm needs to provide the clock to the interface */ + if (!mi2s_intf_conf[index].msm_is_mi2s_master) + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; ret = msm_mi2s_set_sclk(substream, true); if (ret < 0) { dev_err(rtd->card->dev, @@ -5122,11 +5126,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) atomic_inc(&(pdata->mi2s_gpio_ref_count[index])); } } - /* Check if msm needs to provide the clock to the interface */ - if (!mi2s_intf_conf[index].msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + if (!mi2s_intf_conf[index].msm_is_mi2s_master) fmt = SND_SOC_DAIFMT_CBM_CFM; - } ret = snd_soc_dai_set_fmt(cpu_dai, fmt); if (ret < 0) { pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", diff --git a/asoc/lahaina.c b/asoc/lahaina.c index 32880abbbc3c..f5ad209553b9 100644 --- a/asoc/lahaina.c +++ b/asoc/lahaina.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -5440,6 +5441,9 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__, mi2s_clk[index].clk_freq_in_hz); + /* Check if msm needs to provide the clock to the interface */ + if (!mi2s_intf_conf[index].msm_is_mi2s_master) + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; ret = msm_mi2s_set_sclk(substream, true); if (ret < 0) { dev_err(rtd->card->dev, @@ -5462,11 +5466,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) atomic_inc(&(pdata->mi2s_gpio_ref_count[index])); } } - /* Check if msm needs to provide the clock to the interface */ - if (!mi2s_intf_conf[index].msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + if (!mi2s_intf_conf[index].msm_is_mi2s_master) fmt = SND_SOC_DAIFMT_CBM_CFM; - } ret = snd_soc_dai_set_fmt(cpu_dai, fmt); if (ret < 0) { pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", diff --git a/asoc/qcs405.c b/asoc/qcs405.c index ce8540bd15b7..8b012c6c7ccd 100644 --- a/asoc/qcs405.c +++ b/asoc/qcs405.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include #include @@ -7065,6 +7066,9 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) if (++mi2s_intf_conf[index].ref_cnt == 1) { if (data_format == AFE_DSD_DATA) fmt = SND_SOC_DAIFMT_CBM_CFS; + /* Check if msm needs to provide the clock to the interface */ + if (!mi2s_intf_conf[index].msm_is_mi2s_master) + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; ret = msm_mi2s_set_sclk(substream, true); if (ret < 0) { dev_err(rtd->card->dev, @@ -7101,11 +7105,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) } } } - /* Check if msm needs to provide the clock to the interface */ - if (!mi2s_intf_conf[index].msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + if (!mi2s_intf_conf[index].msm_is_mi2s_master) fmt = SND_SOC_DAIFMT_CBM_CFM; - } ret = snd_soc_dai_set_fmt(cpu_dai, fmt); if (ret < 0) { pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", diff --git a/asoc/sa6155.c b/asoc/sa6155.c index 5d79f69fcf68..1e3fd7a2b896 100755 --- a/asoc/sa6155.c +++ b/asoc/sa6155.c @@ -1,4 +1,5 @@ /* Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ /* * Copyright 2011, The Android Open Source Project @@ -5037,6 +5038,9 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) intf_conf = &pdata->mi2s_intf_conf[index]; mutex_lock(&intf_conf->lock); if (++intf_conf->ref_cnt == 1) { + /* Check if msm needs to provide the clock to the interface */ + if (!intf_conf->msm_is_mi2s_master) + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; ret = msm_mi2s_set_sclk(substream, true); if (ret < 0) { dev_err(rtd->card->dev, @@ -5054,11 +5058,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) __func__, ret_pinctrl); } } - /* Check if msm needs to provide the clock to the interface */ - if (!intf_conf->msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + if (!intf_conf->msm_is_mi2s_master) fmt = SND_SOC_DAIFMT_CBM_CFM; - } ret = snd_soc_dai_set_fmt(cpu_dai, fmt); if (ret < 0) { pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", diff --git a/asoc/sa8155.c b/asoc/sa8155.c index 7bc1b17a4ef5..8f4f243344da 100644 --- a/asoc/sa8155.c +++ b/asoc/sa8155.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ /* * Copyright 2011, The Android Open Source Project @@ -7427,6 +7428,9 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) intf_conf = &pdata->mi2s_intf_conf[index]; mutex_lock(&intf_conf->lock); if (++intf_conf->ref_cnt == 1) { + /* Check if msm needs to provide the clock to the interface */ + if (!intf_conf->msm_is_mi2s_master) + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; ret = msm_mi2s_set_sclk(substream, true); if (ret < 0) { dev_err(rtd->card->dev, @@ -7444,11 +7448,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) __func__, ret_pinctrl); } } - /* Check if msm needs to provide the clock to the interface */ - if (!intf_conf->msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + if (!intf_conf->msm_is_mi2s_master) fmt = SND_SOC_DAIFMT_CBM_CFM; - } ret = snd_soc_dai_set_fmt(cpu_dai, fmt); if (ret < 0) { pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", diff --git a/asoc/sm6150.c b/asoc/sm6150.c index e4763d81f099..92a9580327e4 100644 --- a/asoc/sm6150.c +++ b/asoc/sm6150.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2018-2019, 2021 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -5908,6 +5909,9 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) */ mutex_lock(&mi2s_intf_conf[index].lock); if (++mi2s_intf_conf[index].ref_cnt == 1) { + /* Check if msm needs to provide the clock to the interface */ + if (!mi2s_intf_conf[index].msm_is_mi2s_master) + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; ret = msm_mi2s_set_sclk(substream, true); if (ret < 0) { dev_err(rtd->card->dev, @@ -5932,11 +5936,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) msm_cdc_pinctrl_select_active_state( pdata->mi2s_gpio_p[index]); } - /* Check if msm needs to provide the clock to the interface */ - if (!mi2s_intf_conf[index].msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + if (!mi2s_intf_conf[index].msm_is_mi2s_master) fmt = SND_SOC_DAIFMT_CBM_CFM; - } ret = snd_soc_dai_set_fmt(cpu_dai, fmt); if (ret < 0) { pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", diff --git a/asoc/sm8150.c b/asoc/sm8150.c index ccfe38cdf042..e200dfc27336 100644 --- a/asoc/sm8150.c +++ b/asoc/sm8150.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2016-2019, 2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -4852,6 +4853,9 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) */ mutex_lock(&mi2s_intf_conf[index].lock); if (++mi2s_intf_conf[index].ref_cnt == 1) { + /* Check if msm needs to provide the clock to the interface */ + if (!mi2s_intf_conf[index].msm_is_mi2s_master) + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; ret = msm_mi2s_set_sclk(substream, true); if (ret < 0) { dev_err(rtd->card->dev, @@ -4868,11 +4872,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) __func__, ret_pinctrl); } } - /* Check if msm needs to provide the clock to the interface */ - if (!mi2s_intf_conf[index].msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + if (!mi2s_intf_conf[index].msm_is_mi2s_master) fmt = SND_SOC_DAIFMT_CBM_CFM; - } ret = snd_soc_dai_set_fmt(cpu_dai, fmt); if (ret < 0) { pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", From 7696eb78b6112e3d44ae1d50e34dbdd030ed4381 Mon Sep 17 00:00:00 2001 From: Shuai Zhang Date: Fri, 4 Mar 2022 12:27:06 +0530 Subject: [PATCH 58/82] ASOC: ext-clk: Fix hw init issue caused by CLK upgrade CLK driver upgrade causes hw->init to be NULL. Unable to get hw->init from CLK core. Modify to obtain hw->init from local static data. Change-Id: I2ffc3e7dfd356cfcb2735336dd67ff70a35328c4 Signed-off-by: Shuai Zhang --- asoc/codecs/audio-ext-clk-up.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/asoc/codecs/audio-ext-clk-up.c b/asoc/codecs/audio-ext-clk-up.c index acd00da91404..f3e9b694c5b5 100644 --- a/asoc/codecs/audio-ext-clk-up.c +++ b/asoc/codecs/audio-ext-clk-up.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2015-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -58,6 +59,8 @@ struct audio_ext_clk_priv { uint32_t lpass_audio_hwvote_client_handle; }; +static struct audio_ext_clk audio_clk_array[]; + static inline struct audio_ext_clk_priv *to_audio_clk(struct clk_hw *hw) { return container_of(hw, struct audio_ext_clk_priv, audio_clk.fact.hw); @@ -137,8 +140,8 @@ static u8 audio_ext_clk_get_parent(struct clk_hw *hw) { struct audio_ext_clk_priv *clk_priv = to_audio_clk(hw); int num_parents = clk_hw_get_num_parents(hw); - const char * const *parent_names = hw->init->parent_names; - u8 i = 0, ret = hw->init->num_parents + 1; + const char * const *parent_names = audio_clk_array[clk_priv->clk_src].fact.hw.init->parent_names; + u8 i = 0, ret = num_parents + 1; if ((clk_priv->clk_src == AUDIO_EXT_CLK_PMI) && clk_priv->clk_name) { for (i = 0; i < num_parents; i++) { From 31b7445e1790525554b3c3a55c45c09886bc8c76 Mon Sep 17 00:00:00 2001 From: Shuai Zhang Date: Fri, 4 Mar 2022 08:48:07 +0530 Subject: [PATCH 59/82] soc: swr-mstr-ctrl: Fix SWR cmd FIFO overflow error Fix SWR cmd FIFO overflow error. In 5.4 kernel there are few additional register writes added in soundwire driver, one of the register(SWRS_DP_SAMPLE_CONTROL_2_BANK) write is causing overflow error. Change-Id: I31f4855af52b24ceac53f55010ce1935c3bc1ea6 Signed-off-by: Shuai Zhang --- soc/swr-mstr-ctrl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/soc/swr-mstr-ctrl.c b/soc/swr-mstr-ctrl.c index f0a9e94f8ffb..2ef6ffe70422 100644 --- a/soc/swr-mstr-ctrl.c +++ b/soc/swr-mstr-ctrl.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -1464,12 +1465,14 @@ static void swrm_copy_data_port_config(struct swr_master *master, u8 bank) SWRS_DP_SAMPLE_CONTROL_1_BANK(slv_id, bank)); - reg[len] = SWRM_CMD_FIFO_WR_CMD; - val[len++] = SWR_REG_VAL_PACK( + if ((port_req->sinterval >> 8)& 0xFF) { + reg[len] = SWRM_CMD_FIFO_WR_CMD; + val[len++] = SWR_REG_VAL_PACK( (port_req->sinterval >> 8)& 0xFF, port_req->dev_num, 0x00, SWRS_DP_SAMPLE_CONTROL_2_BANK(slv_id, bank)); + } reg[len] = SWRM_CMD_FIFO_WR_CMD; val[len++] = SWR_REG_VAL_PACK(port_req->offset1, From 10e5816d4ad02ae761769a892b9e9307040465a2 Mon Sep 17 00:00:00 2001 From: Shuai Zhang Date: Fri, 4 Mar 2022 12:07:01 +0530 Subject: [PATCH 60/82] ASoC: codecs: wsa881x: add codec dai for each wsa881x Add new codec dai for each wsa881x, since each WSA is initialized as a codec and not as aux device. Change-Id: Ifee063cea54a65600d9040390666d58de49a0689 Signed-off-by: Shuai Zhang --- asoc/codecs/wsa881x.c | 128 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 122 insertions(+), 6 deletions(-) diff --git a/asoc/codecs/wsa881x.c b/asoc/codecs/wsa881x.c index 1c28ab051f24..fc4ae71882a9 100644 --- a/asoc/codecs/wsa881x.c +++ b/asoc/codecs/wsa881x.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2015-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -30,9 +31,21 @@ #include "wsa881x-temp-sensor.h" #include "asoc/bolero-slave-internal.h" -#define DRV_NAME "wsa-codec" #define WSA881X_NUM_RETRY 5 +#define MAX_NAME_LEN 30 +#define WSA881X_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\ + SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\ + SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000 |\ + SNDRV_PCM_RATE_384000) +/* Fractional Rates */ +#define WSA881X_FRAC_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_88200 |\ + SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800) + +#define WSA881X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ + SNDRV_PCM_FMTBIT_S24_LE |\ + SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE) + enum { G_18DB = 0, G_16P5DB, @@ -115,6 +128,9 @@ struct wsa881x_priv { struct dentry *debugfs_poke; struct dentry *debugfs_reg_dump; unsigned int read_data; + char *wsa881x_name_prefix; + struct snd_soc_dai_driver *dai_driver; + struct snd_soc_component_driver *driver; }; struct wsa_ctrl_platform_data { @@ -1356,7 +1372,7 @@ static void wsa881x_remove(struct snd_soc_component *component) } static const struct snd_soc_component_driver soc_codec_dev_wsa881x = { - .name = DRV_NAME, + .name = "wsa-codec", .probe = wsa881x_probe, .remove = wsa881x_remove, .controls = wsa881x_snd_controls, @@ -1367,6 +1383,21 @@ static const struct snd_soc_component_driver soc_codec_dev_wsa881x = { .num_dapm_routes = ARRAY_SIZE(wsa881x_audio_map), }; +static struct snd_soc_dai_driver wsa_dai[] = { + { + .name = "wsa_rx", + .playback = { + .stream_name = "WSA881X_AIF Playback", + .rates = WSA881X_RATES | WSA881X_FRAC_RATES, + .formats = WSA881X_FORMATS, + .rate_max = 192000, + .rate_min = 8000, + .channels_min = 1, + .channels_max = 2, + }, + }, +}; + static int wsa881x_gpio_ctrl(struct wsa881x_priv *wsa881x, bool enable) { int ret = 0; @@ -1461,9 +1492,13 @@ static int wsa881x_event_notify(struct notifier_block *nb, static int wsa881x_swr_probe(struct swr_device *pdev) { int ret = 0; - struct wsa881x_priv *wsa881x; + struct wsa881x_priv *wsa881x = NULL; + struct snd_soc_component *component; u8 devnum = 0; + int dev_index = 0; bool pin_state_current = false; + char buffer[MAX_NAME_LEN]; + const char *wsa881x_name_prefix_of = NULL; struct wsa_ctrl_platform_data *plat_data = NULL; wsa881x = devm_kzalloc(&pdev->dev, sizeof(struct wsa881x_priv), @@ -1553,14 +1588,74 @@ static int wsa881x_swr_probe(struct swr_device *pdev) goto dev_err; } - ret = snd_soc_register_component(&pdev->dev, &soc_codec_dev_wsa881x, - NULL, 0); + ret = of_property_read_string(pdev->dev.of_node, + "qcom,wsa-prefix", &wsa881x_name_prefix_of); + if (ret) { + dev_err(&pdev->dev, + "%s: Looking up %s property in node %s failed\n", + __func__, "qcom,wsa-prefix", + pdev->dev.of_node->full_name); + goto dev_err; + } + + wsa881x->driver = devm_kzalloc(&pdev->dev, + sizeof(struct snd_soc_component_driver), + GFP_KERNEL); + if (!wsa881x->driver) { + ret = -ENOMEM; + goto err_mem; + } + + memcpy(wsa881x->driver, &soc_codec_dev_wsa881x, + sizeof(struct snd_soc_component_driver)); + + wsa881x->dai_driver = devm_kzalloc(&pdev->dev, + sizeof(struct snd_soc_dai_driver), + GFP_KERNEL); + if (!wsa881x->dai_driver) { + ret = -ENOMEM; + goto err_mem; + } + + memcpy(wsa881x->dai_driver, wsa_dai, + sizeof(struct snd_soc_dai_driver)); + + dev_index = (int)((char)(pdev->addr & 0xF)); + + snprintf(buffer, sizeof(buffer), "wsa-codec.%d", dev_index); + wsa881x->driver->name = kstrndup(buffer, + strlen(buffer), GFP_KERNEL); + + snprintf(buffer, sizeof(buffer), "wsa_rx%d", dev_index); + wsa881x->dai_driver->name = + kstrndup(buffer, strlen(buffer), GFP_KERNEL); + + snprintf(buffer, sizeof(buffer), + "WSA881X_AIF%d Playback", dev_index); + wsa881x->dai_driver->playback.stream_name = + kstrndup(buffer, strlen(buffer), GFP_KERNEL); + + /* Number of DAI's used is 1 */ + ret = snd_soc_register_component(&pdev->dev, + wsa881x->driver, wsa881x->dai_driver, 1); if (ret) { dev_err(&pdev->dev, "%s: Codec registration failed\n", __func__); - goto dev_err; + goto err_mem; } + wsa881x->wsa881x_name_prefix = kstrndup(wsa881x_name_prefix_of, + strlen(wsa881x_name_prefix_of), GFP_KERNEL); + + component = snd_soc_lookup_component(&pdev->dev, wsa881x->driver->name); + if (!component) { + dev_err(&pdev->dev, "%s: component is NULL \n", __func__); + ret = -EINVAL; + goto err_mem; + } + + component->name_prefix = wsa881x->wsa881x_name_prefix; + wsa881x->bolero_np = of_parse_phandle(pdev->dev.of_node, "qcom,bolero-handle", 0); if (wsa881x->bolero_np) { @@ -1596,6 +1691,17 @@ static int wsa881x_swr_probe(struct swr_device *pdev) return 0; +err_mem: + kfree(wsa881x->wsa881x_name_prefix); + if (wsa881x->dai_driver) { + devm_kfree(&pdev->dev, wsa881x->dai_driver->name); + devm_kfree(&pdev->dev, wsa881x->dai_driver->playback.stream_name); + devm_kfree(&pdev->dev, wsa881x->dai_driver); + } + if (wsa881x->driver) { + devm_kfree(&pdev->dev, wsa881x->driver->name); + devm_kfree(&pdev->dev, wsa881x->driver); + } dev_err: if (pin_state_current == false) wsa881x_gpio_ctrl(wsa881x, false); @@ -1625,6 +1731,16 @@ static int wsa881x_swr_remove(struct swr_device *pdev) if (wsa881x->pd_gpio) gpio_free(wsa881x->pd_gpio); swr_set_dev_data(pdev, NULL); + kfree(wsa881x->wsa881x_name_prefix); + if (wsa881x->dai_driver) { + devm_kfree(&pdev->dev, wsa881x->dai_driver->name); + devm_kfree(&pdev->dev, wsa881x->dai_driver->playback.stream_name); + devm_kfree(&pdev->dev, wsa881x->dai_driver); + } + if (wsa881x->driver) { + devm_kfree(&pdev->dev, wsa881x->driver->name); + devm_kfree(&pdev->dev, wsa881x->driver); + } return 0; } From 4ec279c7cb257fe7d1a43ab5eda51bf41e6852dd Mon Sep 17 00:00:00 2001 From: Shuai Zhang Date: Fri, 4 Mar 2022 12:13:26 +0530 Subject: [PATCH 61/82] makefile: add config support for audio techpack for QCS610 Add required changes to makefile and enable the config keys for QCS610 target cpmpilation. Change-Id: I8ef55e9b237f10ae0d240d83c685f5580a939be3 Signed-off-by: Shuai Zhang --- Makefile | 8 +++- config/sm6150auto.conf | 96 +++++++++++++++++++++--------------------- 2 files changed, 55 insertions(+), 49 deletions(-) diff --git a/Makefile b/Makefile index d60a0236f5ee..73ad150b67ec 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,9 @@ endif ifeq ($(CONFIG_ARCH_SA6155), y) include $(srctree)/techpack/audio/config/sa6155auto.conf endif +ifeq ($(CONFIG_ARCH_SM6150), y) +include $(srctree)/techpack/audio/config/sm6150auto.conf +endif endif # Use USERINCLUDE when you must reference the UAPI directories only. USERINCLUDE += \ @@ -79,7 +82,10 @@ ifeq ($(CONFIG_ARCH_SA6155), y) LINUXINCLUDE += \ -include $(srctree)/techpack/audio/config/sa6155autoconf.h endif - +ifeq ($(CONFIG_ARCH_SM6150), y) +LINUXINCLUDE += \ + -include $(srctree)/techpack/audio/config/sm6150autoconf.h +endif obj-y += soc/ obj-y += dsp/ obj-y += ipc/ diff --git a/config/sm6150auto.conf b/config/sm6150auto.conf index f6074abbac0b..8ebc88a5e7de 100644 --- a/config/sm6150auto.conf +++ b/config/sm6150auto.conf @@ -1,48 +1,48 @@ -CONFIG_PINCTRL_WCD=m -CONFIG_PINCTRL_LPI=m -CONFIG_AUDIO_EXT_CLK=m -CONFIG_SND_SOC_WCD9XXX_V2=m -CONFIG_SND_SOC_WCD_MBHC=m -CONFIG_SND_SOC_WSA881X=m -CONFIG_SND_SOC_WCD_DSP_MGR=m -CONFIG_SND_SOC_WCD_SPI=m -CONFIG_SND_SOC_WCD934X=m -CONFIG_SND_SOC_WCD934X_MBHC=m -CONFIG_SND_SOC_WCD934X_DSD=m -CONFIG_WCD9XXX_CODEC_CORE=m -CONFIG_MSM_CDC_PINCTRL=m -CONFIG_MSM_QDSP6V2_CODECS=m -CONFIG_MSM_ULTRASOUND=m -CONFIG_MSM_QDSP6_APRV2_RPMSG=m -CONFIG_MSM_ADSP_LOADER=m -CONFIG_REGMAP_SWR=m -CONFIG_MSM_QDSP6_SSR=m -CONFIG_MSM_QDSP6_PDR=m -CONFIG_MSM_QDSP6_NOTIFIER=m -CONFIG_SND_SOC_MSM_HOSTLESS_PCM=m -CONFIG_SND_SOC_MSM_QDSP6V2_INTF=m -CONFIG_SND_SOC_SM6150=m -CONFIG_MSM_GLINK_SPI_XPRT=m -CONFIG_WCD_DSP_GLINK=m -CONFIG_SOUNDWIRE=m -CONFIG_SOUNDWIRE_MSTR_CTRL=m -CONFIG_SND_SOC_QDSP6V2=m -CONFIG_SND_SOC_WCD_MBHC_ADC=m -CONFIG_QTI_PP=m -CONFIG_SND_HWDEP_ROUTING=m -CONFIG_DTS_EAGLE=m -CONFIG_DOLBY_DS2=m -CONFIG_DOLBY_LICENSE=m -CONFIG_DTS_SRS_TM=m -CONFIG_SND_SOC_MSM_STUB=m -CONFIG_MSM_AVTIMER=m -CONFIG_SND_SOC_MSM_HDMI_CODEC_RX=m -CONFIG_SND_SOC_BOLERO=m -CONFIG_WSA_MACRO=m -CONFIG_VA_MACRO=m -CONFIG_RX_MACRO=m -CONFIG_TX_MACRO=m -CONFIG_SND_SOC_WCD_IRQ=m -CONFIG_SND_SOC_WCD937X=m -CONFIG_SND_SOC_WCD937X_SLAVE=m -CONFIG_SND_EVENT=m +export CONFIG_PINCTRL_WCD=m +export CONFIG_PINCTRL_LPI=m +export CONFIG_AUDIO_EXT_CLK=m +export CONFIG_SND_SOC_WCD9XXX_V2=m +export CONFIG_SND_SOC_WCD_MBHC=m +export CONFIG_SND_SOC_WSA881X=m +export CONFIG_SND_SOC_WCD_DSP_MGR=m +export CONFIG_SND_SOC_WCD_SPI=m +export CONFIG_SND_SOC_WCD934X=m +export CONFIG_SND_SOC_WCD934X_MBHC=m +export CONFIG_SND_SOC_WCD934X_DSD=m +export CONFIG_WCD9XXX_CODEC_CORE=m +export CONFIG_MSM_CDC_PINCTRL=m +export CONFIG_MSM_QDSP6V2_CODECS=m +export CONFIG_MSM_ULTRASOUND=m +export CONFIG_MSM_QDSP6_APRV2_RPMSG=m +export CONFIG_MSM_ADSP_LOADER=m +export CONFIG_REGMAP_SWR=m +export CONFIG_MSM_QDSP6_SSR=m +export CONFIG_MSM_QDSP6_PDR=m +export CONFIG_MSM_QDSP6_NOTIFIER=m +export CONFIG_SND_SOC_MSM_HOSTLESS_PCM=m +export CONFIG_SND_SOC_MSM_QDSP6V2_INTF=m +export CONFIG_SND_SOC_SM6150=m +export CONFIG_MSM_GLINK_SPI_XPRT=m +export CONFIG_WCD_DSP_GLINK=m +export CONFIG_SOUNDWIRE=m +export CONFIG_SOUNDWIRE_MSTR_CTRL=m +export CONFIG_SND_SOC_QDSP6V2=m +export CONFIG_SND_SOC_WCD_MBHC_ADC=m +export CONFIG_QTI_PP=m +export CONFIG_SND_HWDEP_ROUTING=m +export CONFIG_DTS_EAGLE=m +export CONFIG_DOLBY_DS2=m +export CONFIG_DOLBY_LICENSE=m +export CONFIG_DTS_SRS_TM=m +export CONFIG_SND_SOC_MSM_STUB=m +export CONFIG_MSM_AVTIMER=m +export CONFIG_SND_SOC_MSM_HDMI_CODEC_RX=m +export CONFIG_SND_SOC_BOLERO=m +export CONFIG_WSA_MACRO=m +export CONFIG_VA_MACRO=m +export CONFIG_RX_MACRO=m +export CONFIG_TX_MACRO=m +export CONFIG_SND_SOC_WCD_IRQ=m +export CONFIG_SND_SOC_WCD937X=m +export CONFIG_SND_SOC_WCD937X_SLAVE=m +export CONFIG_SND_EVENT=m From 21474dc6d78fe9766a67279661001d9a4e50db58 Mon Sep 17 00:00:00 2001 From: Shuai Zhang Date: Fri, 4 Mar 2022 12:18:56 +0530 Subject: [PATCH 62/82] ASoC: wcd-spi: Fix dma alloc compilation errors Fix dma_alloc_coherent compilation errors, using the new API Change-Id: I2188c9ab34e5c02cebc0f86a53e3f810aefc6caf Signed-off-by: Shuai Zhang --- asoc/codecs/wcd-spi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/asoc/codecs/wcd-spi.c b/asoc/codecs/wcd-spi.c index 4c7a85338ed4..8eca87d9a0da 100644 --- a/asoc/codecs/wcd-spi.c +++ b/asoc/codecs/wcd-spi.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -1478,7 +1479,7 @@ static int wcd_spi_component_bind(struct device *dev, spi_message_add_tail(&wcd_spi->xfer2[1], &wcd_spi->msg2); /* Pre-allocate the buffers */ - wcd_spi->tx_buf = dma_zalloc_coherent(&spi->dev, + wcd_spi->tx_buf = dma_alloc_coherent(&spi->dev, WCD_SPI_RW_MAX_BUF_SIZE, &wcd_spi->tx_dma, GFP_KERNEL); if (!wcd_spi->tx_buf) { @@ -1486,7 +1487,7 @@ static int wcd_spi_component_bind(struct device *dev, goto done; } - wcd_spi->rx_buf = dma_zalloc_coherent(&spi->dev, + wcd_spi->rx_buf = dma_alloc_coherent(&spi->dev, WCD_SPI_RW_MAX_BUF_SIZE, &wcd_spi->rx_dma, GFP_KERNEL); if (!wcd_spi->rx_buf) { From 0ac76a1d7aae397d59b9c0b4b8fc88529c737939 Mon Sep 17 00:00:00 2001 From: Shuai Zhang Date: Fri, 4 Mar 2022 08:23:07 +0530 Subject: [PATCH 63/82] ASOC: update sm6150 machine driver Update machine driver for sm6150. Compile wsa881x digital driver for sm6150. Change-Id: I46e0ef5ffa773e2c8e4b9fe3cf8819ac32f303d5 Signed-off-by: Shuai Zhang --- asoc/Kbuild | 1 - asoc/sm6150.c | 1399 +++++++++++++------------------------------------ 2 files changed, 355 insertions(+), 1045 deletions(-) diff --git a/asoc/Kbuild b/asoc/Kbuild index f59beb058c3a..8276d7df6000 100644 --- a/asoc/Kbuild +++ b/asoc/Kbuild @@ -136,7 +136,6 @@ endif # for SM6150 sound card driver ifdef CONFIG_SND_SOC_SM6150 MACHINE_OBJS += sm6150.o - MACHINE_OBJS += machine_615x_init.o endif # For sa6155 sound card driver diff --git a/asoc/sm6150.c b/asoc/sm6150.c index 92a9580327e4..5eb1b5d94397 100644 --- a/asoc/sm6150.c +++ b/asoc/sm6150.c @@ -38,6 +38,8 @@ #include #include "codecs/bolero/wsa-macro.h" #include "codecs/wcd937x/wcd937x.h" +#include "msm_talos_dailink.h" +#include "talos-port-config.h" #define DRV_NAME "sm6150-asoc-snd" @@ -76,7 +78,6 @@ #define SM6150_SOC_VERSION_1_0 0x00010000 #define SM6150_SOC_MSM_ID 0x163 - enum { SLIM_RX_0 = 0, SLIM_RX_1, @@ -197,11 +198,6 @@ struct msm_wsa881x_dev_info { u32 index; }; -struct aux_codec_dev_info { - struct device_node *of_node; - u32 index; -}; - struct msm_asoc_mach_data { struct snd_info_entry *codec_root; int usbc_en2_gpio; /* used by gpio driver API */ @@ -216,6 +212,7 @@ struct msm_asoc_mach_data { struct device_node *hph_en0_gpio_p; /* used by pinctrl API */ bool is_afe_config_done; struct device_node *fsa_handle; + u32 wsa_max_devs; }; struct msm_asoc_wcd93xx_codec { @@ -624,8 +621,6 @@ static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_sample_rate, static int msm_hifi_control; static bool codec_reg_done; -static struct snd_soc_aux_dev *msm_aux_dev; -static struct snd_soc_codec_conf *msm_codec_conf; static struct msm_asoc_wcd93xx_codec msm_codec_fn; static int dmic_0_1_gpio_cnt; @@ -634,8 +629,7 @@ static int dmic_2_3_gpio_cnt; static void *def_wcd_mbhc_cal(void); static int msm_snd_enable_codec_ext_clk(struct snd_soc_component *component, int enable, bool dapm); -static int msm_wsa881x_init(struct snd_soc_component *component); -static int msm_aux_codec_init(struct snd_soc_component *component); +static int msm_wsa881x_init(struct snd_soc_pcm_runtime *rtd); /* * Need to report LINEIN @@ -4235,7 +4229,6 @@ static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, SNDRV_PCM_HW_PARAM_RATE); struct snd_interval *channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); - struct snd_soc_dai *codec_dai = rtd->codec_dai; int rc = 0; int idx; @@ -4761,6 +4754,23 @@ static void msm_afe_clear_config(void) afe_clear_config(AFE_SLIMBUS_SLAVE_CONFIG); } +static struct snd_info_entry *msm_snd_info_create_subdir(struct module *mod, + const char *name, + struct snd_info_entry *parent) +{ + struct snd_info_entry *entry; + + entry = snd_info_create_module_entry(mod, name, parent); + if (!entry) + return NULL; + entry->mode = S_IFDIR | 0555; + if (snd_info_register(entry) < 0) { + snd_info_free_entry(entry); + return NULL; + } + return entry; +} + static int msm_audrx_tavil_init(struct snd_soc_pcm_runtime *rtd) { int ret = 0; @@ -4769,7 +4779,6 @@ static int msm_audrx_tavil_init(struct snd_soc_pcm_runtime *rtd) struct snd_soc_dapm_context *dapm; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_component *aux_comp; struct snd_card *card = rtd->card->snd_card; struct snd_info_entry *entry; struct msm_asoc_mach_data *pdata = @@ -4877,23 +4886,14 @@ static int msm_audrx_tavil_init(struct snd_soc_pcm_runtime *rtd) * Send speaker configuration only for WSA8810. * Default configuration is for WSA8815. */ - pr_debug("%s: Number of aux devices: %d\n", - __func__, rtd->card->num_aux_devs); - if (rtd->card->num_aux_devs && - !list_empty(&rtd->card->aux_comp_list)) { - aux_comp = list_first_entry(&rtd->card->aux_comp_list, - struct snd_soc_component, card_aux_list); - if (!strcmp(aux_comp->name, WSA8810_NAME_1) || - !strcmp(aux_comp->name, WSA8810_NAME_2)) { - tavil_set_spkr_mode(component, WCD934X_SPKR_MODE_1); - tavil_set_spkr_gain_offset(component, - WCD934X_RX_GAIN_OFFSET_M1P5_DB); - } - } + + tavil_set_spkr_mode(component, WCD934X_SPKR_MODE_1); + tavil_set_spkr_gain_offset(component, + WCD934X_RX_GAIN_OFFSET_M1P5_DB); card = rtd->card->snd_card; if (!pdata->codec_root) { - entry = snd_info_create_subdir(card->module, "codecs", + entry = msm_snd_info_create_subdir(card->module, "codecs", card->proc_root); if (!entry) { pr_debug("%s: Cannot create codecs module entry\n", @@ -4905,6 +4905,9 @@ static int msm_audrx_tavil_init(struct snd_soc_pcm_runtime *rtd) } tavil_codec_info_create_codec_entry(pdata->codec_root, component); + tavil_set_port_map(component, + ARRAY_SIZE(sm_port_map_tavil_wsa), sm_port_map_tavil_wsa); + codec_reg_done = true; return 0; err: @@ -4919,7 +4922,6 @@ static int msm_audrx_tasha_init(struct snd_soc_pcm_runtime *rtd) struct snd_soc_dapm_context *dapm; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_component *aux_comp; struct snd_card *card; struct snd_info_entry *entry; struct msm_asoc_mach_data *pdata = @@ -5055,23 +5057,14 @@ static int msm_audrx_tasha_init(struct snd_soc_pcm_runtime *rtd) * Send speaker configuration only for WSA8810. * Default configuration is for WSA8815. */ - pr_debug("%s: Number of aux devices: %d\n", - __func__, rtd->card->num_aux_devs); - if (rtd->card->num_aux_devs && - !list_empty(&rtd->card->aux_comp_list)) { - aux_comp = list_first_entry(&rtd->card->aux_comp_list, - struct snd_soc_component, card_aux_list); - if (!strcmp(aux_comp->name, WSA8810_NAME_1) || - !strcmp(aux_comp->name, WSA8810_NAME_2)) { - tasha_set_spkr_mode(component, SPKR_MODE_1); - tasha_set_spkr_gain_offset(component, - RX_GAIN_OFFSET_M1P5_DB); - } - } + + tasha_set_spkr_mode(component, SPKR_MODE_1); + tasha_set_spkr_gain_offset(component, + RX_GAIN_OFFSET_M1P5_DB); card = rtd->card->snd_card; if (!pdata->codec_root) { - entry = snd_info_create_subdir(card->module, "codecs", + entry = msm_snd_info_create_subdir(card->module, "codecs", card->proc_root); if (!entry) { pr_debug("%s: Cannot create codecs module entry\n", @@ -5089,22 +5082,23 @@ err: return ret; } -static int msm_int_audrx_init(struct snd_soc_pcm_runtime *rtd) +static int msm_rx_tx_codec_init(struct snd_soc_pcm_runtime *rtd) { int ret = 0; - struct snd_soc_component *component; - struct snd_soc_dapm_context *dapm; - struct snd_card *card; + struct snd_soc_component *component = NULL; + struct snd_soc_component *bolero_component = NULL; + struct snd_soc_dapm_context *dapm = NULL; + struct snd_card *card = NULL; struct snd_info_entry *entry; - struct snd_soc_component *aux_comp; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(rtd->card); - struct snd_soc_dai *codec_dai = rtd->codec_dai; component = snd_soc_rtdcom_lookup(rtd, "bolero_codec"); if (!component) { pr_err("%s: component is NULL\n", __func__); return -EINVAL; + } else { + bolero_component = component; } dapm = snd_soc_component_get_dapm(component); @@ -5147,25 +5141,15 @@ static int msm_int_audrx_init(struct snd_soc_pcm_runtime *rtd) * Send speaker configuration only for WSA8810. * Default configuration is for WSA8815. */ - dev_dbg(component->dev, "%s: Number of aux devices: %d\n", - __func__, rtd->card->num_aux_devs); - if (rtd->card->num_aux_devs && - !list_empty(&rtd->card->aux_comp_list)) { - list_for_each_entry(aux_comp, &rtd->card->aux_comp_list, - card_aux_list) { - if (!strcmp(aux_comp->name, WSA8810_NAME_1) || - !strcmp(aux_comp->name, WSA8810_NAME_2)) { - wsa_macro_set_spkr_mode(component, - WSA_MACRO_SPKR_MODE_1); - wsa_macro_set_spkr_gain_offset(component, - WSA_MACRO_GAIN_OFFSET_M1P5_DB); - break; - } - } - } + + wsa_macro_set_spkr_mode(component, + WSA_MACRO_SPKR_MODE_1); + wsa_macro_set_spkr_gain_offset(component, + WSA_MACRO_GAIN_OFFSET_M1P5_DB); + card = rtd->card->snd_card; if (!pdata->codec_root) { - entry = snd_info_create_subdir(card->module, "codecs", + entry = msm_snd_info_create_subdir(card->module, "codecs", card->proc_root); if (!entry) { pr_debug("%s: Cannot create codecs module entry\n", @@ -5175,7 +5159,7 @@ static int msm_int_audrx_init(struct snd_soc_pcm_runtime *rtd) } pdata->codec_root = entry; } - bolero_info_create_codec_entry(pdata->codec_root, codec); + bolero_info_create_codec_entry(pdata->codec_root, component); /* * SM6150 MSM 1.0 doesn't have hardware wake up interrupt line * from AOSS to APSS. So, it uses SW workaround and listens to @@ -5183,11 +5167,10 @@ static int msm_int_audrx_init(struct snd_soc_pcm_runtime *rtd) * Check for MSM version and MSM ID and register wake irq * accordingly to provide compatibility to all chipsets. */ - if (socinfo_get_id() == SM6150_SOC_MSM_ID && - socinfo_get_version() == SM6150_SOC_VERSION_1_0) - bolero_register_wake_irq(component, true); - else - bolero_register_wake_irq(component, false); + bolero_register_wake_irq(component, false); + + bolero_set_port_map(bolero_component, + ARRAY_SIZE(sm_port_map), sm_port_map); codec_reg_done = true; return 0; @@ -5850,21 +5833,7 @@ static struct snd_soc_ops sm6150_tdm_be_ops = { static int msm_fe_qos_prepare(struct snd_pcm_substream *substream) { - cpumask_t mask; - - if (pm_qos_request_active(&substream->latency_pm_qos_req)) - pm_qos_remove_request(&substream->latency_pm_qos_req); - - cpumask_clear(&mask); - cpumask_set_cpu(1, &mask); /* affine to core 1 */ - cpumask_set_cpu(2, &mask); /* affine to core 2 */ - cpumask_copy(&substream->latency_pm_qos_req.cpus_affine, &mask); - - substream->latency_pm_qos_req.type = PM_QOS_REQ_AFFINE_CORES; - - pm_qos_add_request(&substream->latency_pm_qos_req, - PM_QOS_CPU_DMA_LATENCY, - MSM_LL_QOS_VALUE); + pr_debug("%s: TODO: add new QOS implementation\n", __func__); return 0; } @@ -6034,43 +6003,37 @@ static struct snd_soc_dai_link msm_common_dai_links[] = { {/* hw:x,0 */ .name = MSM_DAILINK_NAME(Media1), .stream_name = "MultiMedia1", - .cpu_dai_name = "MultiMedia1", - .platform_name = "msm-pcm-dsp.0", .dynamic = 1, +#if IS_ENABLED(CONFIG_AUDIO_QGKI) .async_ops = ASYNC_DPCM_SND_SOC_PREPARE, +#endif /* CONFIG_AUDIO_QGKI */ .dpcm_playback = 1, .dpcm_capture = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .ignore_suspend = 1, /* this dainlink has playback support */ .ignore_pmdown_time = 1, - .id = MSM_FRONTEND_DAI_MULTIMEDIA1 + .id = MSM_FRONTEND_DAI_MULTIMEDIA1, + SND_SOC_DAILINK_REG(multimedia1), }, {/* hw:x,1 */ .name = MSM_DAILINK_NAME(Media2), .stream_name = "MultiMedia2", - .cpu_dai_name = "MultiMedia2", - .platform_name = "msm-pcm-dsp.0", .dynamic = 1, .dpcm_playback = 1, .dpcm_capture = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .ignore_suspend = 1, /* this dainlink has playback support */ .ignore_pmdown_time = 1, .id = MSM_FRONTEND_DAI_MULTIMEDIA2, + SND_SOC_DAILINK_REG(multimedia2), }, {/* hw:x,2 */ .name = "VoiceMMode1", .stream_name = "VoiceMMode1", - .cpu_dai_name = "VoiceMMode1", - .platform_name = "msm-pcm-voice", .dynamic = 1, .dpcm_playback = 1, .dpcm_capture = 1, @@ -6079,50 +6042,43 @@ static struct snd_soc_dai_link msm_common_dai_links[] = { .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ignore_suspend = 1, .ignore_pmdown_time = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .id = MSM_FRONTEND_DAI_VOICEMMODE1, + SND_SOC_DAILINK_REG(voicemmode1), }, {/* hw:x,3 */ .name = "MSM VoIP", .stream_name = "VoIP", - .cpu_dai_name = "VoIP", - .platform_name = "msm-voip-dsp", .dynamic = 1, .dpcm_playback = 1, .dpcm_capture = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .ignore_suspend = 1, /* this dainlink has playback support */ .ignore_pmdown_time = 1, .id = MSM_FRONTEND_DAI_VOIP, + SND_SOC_DAILINK_REG(msmvoip), }, {/* hw:x,4 */ .name = MSM_DAILINK_NAME(ULL), .stream_name = "MultiMedia3", - .cpu_dai_name = "MultiMedia3", - .platform_name = "msm-pcm-dsp.2", .dynamic = 1, +#if IS_ENABLED(CONFIG_AUDIO_QGKI) .async_ops = ASYNC_DPCM_SND_SOC_PREPARE, +#endif /* CONFIG_AUDIO_QGKI */ .dpcm_playback = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .ignore_suspend = 1, /* this dainlink has playback support */ .ignore_pmdown_time = 1, .id = MSM_FRONTEND_DAI_MULTIMEDIA3, + SND_SOC_DAILINK_REG(multimedia3), }, /* Hostless PCM purpose */ {/* hw:x,5 */ .name = "SLIMBUS_0 Hostless", .stream_name = "SLIMBUS_0 Hostless", - .cpu_dai_name = "SLIMBUS0_HOSTLESS", - .platform_name = "msm-pcm-hostless", .dynamic = 1, .dpcm_playback = 1, .dpcm_capture = 1, @@ -6132,54 +6088,44 @@ static struct snd_soc_dai_link msm_common_dai_links[] = { .ignore_suspend = 1, /* this dailink has playback support */ .ignore_pmdown_time = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", + SND_SOC_DAILINK_REG(slimbus0_hostless), }, {/* hw:x,6 */ .name = "MSM AFE-PCM RX", .stream_name = "AFE-PROXY RX", - .cpu_dai_name = "msm-dai-q6-dev.241", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .platform_name = "msm-pcm-afe", .dpcm_playback = 1, .ignore_suspend = 1, /* this dainlink has playback support */ .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(afepcm_rx), }, {/* hw:x,7 */ .name = "MSM AFE-PCM TX", .stream_name = "AFE-PROXY TX", - .cpu_dai_name = "msm-dai-q6-dev.240", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .platform_name = "msm-pcm-afe", .dpcm_capture = 1, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(afepcm_tx), }, {/* hw:x,8 */ .name = MSM_DAILINK_NAME(Compress1), .stream_name = "Compress1", - .cpu_dai_name = "MultiMedia4", - .platform_name = "msm-compress-dsp", .dynamic = 1, +#if IS_ENABLED(CONFIG_AUDIO_QGKI) .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS, +#endif /* CONFIG_AUDIO_QGKI */ .dpcm_playback = 1, .dpcm_capture = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .ignore_suspend = 1, .ignore_pmdown_time = 1, /* this dainlink has playback support */ .id = MSM_FRONTEND_DAI_MULTIMEDIA4, + SND_SOC_DAILINK_REG(multimedia4), }, {/* hw:x,9 */ .name = "AUXPCM Hostless", .stream_name = "AUXPCM Hostless", - .cpu_dai_name = "AUXPCM_HOSTLESS", - .platform_name = "msm-pcm-hostless", .dynamic = 1, .dpcm_playback = 1, .dpcm_capture = 1, @@ -6189,14 +6135,11 @@ static struct snd_soc_dai_link msm_common_dai_links[] = { .ignore_suspend = 1, /* this dainlink has playback support */ .ignore_pmdown_time = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", + SND_SOC_DAILINK_REG(auxpcm_hostless), }, {/* hw:x,10 */ .name = "SLIMBUS_1 Hostless", .stream_name = "SLIMBUS_1 Hostless", - .cpu_dai_name = "SLIMBUS1_HOSTLESS", - .platform_name = "msm-pcm-hostless", .dynamic = 1, .dpcm_playback = 1, .dpcm_capture = 1, @@ -6206,14 +6149,11 @@ static struct snd_soc_dai_link msm_common_dai_links[] = { .ignore_suspend = 1, /* this dailink has playback support */ .ignore_pmdown_time = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", + SND_SOC_DAILINK_REG(slimbus1_hostless), }, {/* hw:x,11 */ .name = "SLIMBUS_3 Hostless", .stream_name = "SLIMBUS_3 Hostless", - .cpu_dai_name = "SLIMBUS3_HOSTLESS", - .platform_name = "msm-pcm-hostless", .dynamic = 1, .dpcm_playback = 1, .dpcm_capture = 1, @@ -6223,14 +6163,11 @@ static struct snd_soc_dai_link msm_common_dai_links[] = { .ignore_suspend = 1, /* this dailink has playback support */ .ignore_pmdown_time = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", + SND_SOC_DAILINK_REG(slimbus3_hostless), }, {/* hw:x,12 */ .name = "SLIMBUS_7 Hostless", .stream_name = "SLIMBUS_7 Hostless", - .cpu_dai_name = "SLIMBUS7_HOSTLESS", - .platform_name = "msm-pcm-hostless", .dynamic = 1, .dpcm_playback = 1, .dpcm_capture = 1, @@ -6240,20 +6177,17 @@ static struct snd_soc_dai_link msm_common_dai_links[] = { .ignore_suspend = 1, /* this dailink has playback support */ .ignore_pmdown_time = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", + SND_SOC_DAILINK_REG(slimbus7_hostless), }, {/* hw:x,13 */ .name = MSM_DAILINK_NAME(LowLatency), .stream_name = "MultiMedia5", - .cpu_dai_name = "MultiMedia5", - .platform_name = "msm-pcm-dsp.1", .dynamic = 1, +#if IS_ENABLED(CONFIG_AUDIO_QGKI) .async_ops = ASYNC_DPCM_SND_SOC_PREPARE, +#endif /* CONFIG_AUDIO_QGKI */ .dpcm_playback = 1, .dpcm_capture = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .ignore_suspend = 1, @@ -6261,80 +6195,67 @@ static struct snd_soc_dai_link msm_common_dai_links[] = { .ignore_pmdown_time = 1, .id = MSM_FRONTEND_DAI_MULTIMEDIA5, .ops = &msm_fe_qos_ops, + SND_SOC_DAILINK_REG(multimedia5), }, {/* hw:x,14 */ .name = "Listen 1 Audio Service", .stream_name = "Listen 1 Audio Service", - .cpu_dai_name = "LSM1", - .platform_name = "msm-lsm-client", .dynamic = 1, .dpcm_capture = 1, .trigger = { SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST }, .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ignore_suspend = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .id = MSM_FRONTEND_DAI_LSM1, + SND_SOC_DAILINK_REG(listen1), }, /* Multiple Tunnel instances */ {/* hw:x,15 */ .name = MSM_DAILINK_NAME(Compress2), .stream_name = "Compress2", - .cpu_dai_name = "MultiMedia7", - .platform_name = "msm-compress-dsp", .dynamic = 1, .dpcm_playback = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .ignore_suspend = 1, .ignore_pmdown_time = 1, /* this dainlink has playback support */ .id = MSM_FRONTEND_DAI_MULTIMEDIA7, + SND_SOC_DAILINK_REG(multimedia7), }, {/* hw:x,16 */ .name = MSM_DAILINK_NAME(MultiMedia10), .stream_name = "MultiMedia10", - .cpu_dai_name = "MultiMedia10", - .platform_name = "msm-pcm-dsp.1", .dynamic = 1, .dpcm_playback = 1, .dpcm_capture = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .ignore_suspend = 1, .ignore_pmdown_time = 1, /* this dainlink has playback support */ .id = MSM_FRONTEND_DAI_MULTIMEDIA10, + SND_SOC_DAILINK_REG(multimedia10), }, {/* hw:x,17 */ .name = MSM_DAILINK_NAME(ULL_NOIRQ), .stream_name = "MM_NOIRQ", - .cpu_dai_name = "MultiMedia8", - .platform_name = "msm-pcm-dsp-noirq", .dynamic = 1, .dpcm_playback = 1, .dpcm_capture = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .ignore_suspend = 1, .ignore_pmdown_time = 1, /* this dainlink has playback support */ .id = MSM_FRONTEND_DAI_MULTIMEDIA8, .ops = &msm_fe_qos_ops, + SND_SOC_DAILINK_REG(multimedia8), }, /* HDMI Hostless */ {/* hw:x,18 */ .name = "HDMI_RX_HOSTLESS", .stream_name = "HDMI_RX_HOSTLESS", - .cpu_dai_name = "HDMI_HOSTLESS", - .platform_name = "msm-pcm-hostless", .dynamic = 1, .dpcm_playback = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, @@ -6342,14 +6263,11 @@ static struct snd_soc_dai_link msm_common_dai_links[] = { .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ignore_suspend = 1, .ignore_pmdown_time = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", + SND_SOC_DAILINK_REG(hdmi_rx_hostless), }, {/* hw:x,19 */ .name = "VoiceMMode2", .stream_name = "VoiceMMode2", - .cpu_dai_name = "VoiceMMode2", - .platform_name = "msm-pcm-voice", .dynamic = 1, .dpcm_playback = 1, .dpcm_capture = 1, @@ -6358,249 +6276,202 @@ static struct snd_soc_dai_link msm_common_dai_links[] = { .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ignore_suspend = 1, .ignore_pmdown_time = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .id = MSM_FRONTEND_DAI_VOICEMMODE2, + SND_SOC_DAILINK_REG(voicemmode2), }, /* LSM FE */ {/* hw:x,20 */ .name = "Listen 2 Audio Service", .stream_name = "Listen 2 Audio Service", - .cpu_dai_name = "LSM2", - .platform_name = "msm-lsm-client", .dynamic = 1, .dpcm_capture = 1, .trigger = { SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST }, .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ignore_suspend = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .id = MSM_FRONTEND_DAI_LSM2, + SND_SOC_DAILINK_REG(listen2), }, {/* hw:x,21 */ .name = "Listen 3 Audio Service", .stream_name = "Listen 3 Audio Service", - .cpu_dai_name = "LSM3", - .platform_name = "msm-lsm-client", .dynamic = 1, .dpcm_capture = 1, .trigger = { SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST }, .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ignore_suspend = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .id = MSM_FRONTEND_DAI_LSM3, + SND_SOC_DAILINK_REG(listen3), }, {/* hw:x,22 */ .name = "Listen 4 Audio Service", .stream_name = "Listen 4 Audio Service", - .cpu_dai_name = "LSM4", - .platform_name = "msm-lsm-client", .dynamic = 1, .dpcm_capture = 1, .trigger = { SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST }, .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ignore_suspend = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .id = MSM_FRONTEND_DAI_LSM4, + SND_SOC_DAILINK_REG(listen4), }, {/* hw:x,23 */ .name = "Listen 5 Audio Service", .stream_name = "Listen 5 Audio Service", - .cpu_dai_name = "LSM5", - .platform_name = "msm-lsm-client", .dynamic = 1, .dpcm_capture = 1, .trigger = { SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST }, .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ignore_suspend = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .id = MSM_FRONTEND_DAI_LSM5, + SND_SOC_DAILINK_REG(listen5), }, {/* hw:x,24 */ .name = "Listen 6 Audio Service", .stream_name = "Listen 6 Audio Service", - .cpu_dai_name = "LSM6", - .platform_name = "msm-lsm-client", .dynamic = 1, .dpcm_capture = 1, .trigger = { SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST }, .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ignore_suspend = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .id = MSM_FRONTEND_DAI_LSM6, + SND_SOC_DAILINK_REG(listen6), }, {/* hw:x,25 */ .name = "Listen 7 Audio Service", .stream_name = "Listen 7 Audio Service", - .cpu_dai_name = "LSM7", - .platform_name = "msm-lsm-client", .dynamic = 1, .dpcm_capture = 1, .trigger = { SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST }, .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ignore_suspend = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .id = MSM_FRONTEND_DAI_LSM7, + SND_SOC_DAILINK_REG(listen7), }, {/* hw:x,26 */ .name = "Listen 8 Audio Service", .stream_name = "Listen 8 Audio Service", - .cpu_dai_name = "LSM8", - .platform_name = "msm-lsm-client", .dynamic = 1, .dpcm_capture = 1, .trigger = { SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST }, .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ignore_suspend = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .id = MSM_FRONTEND_DAI_LSM8, + SND_SOC_DAILINK_REG(listen8), }, {/* hw:x,27 */ .name = MSM_DAILINK_NAME(Media9), .stream_name = "MultiMedia9", - .cpu_dai_name = "MultiMedia9", - .platform_name = "msm-pcm-dsp.0", .dynamic = 1, .dpcm_playback = 1, .dpcm_capture = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .ignore_suspend = 1, /* this dainlink has playback support */ .ignore_pmdown_time = 1, .id = MSM_FRONTEND_DAI_MULTIMEDIA9, + SND_SOC_DAILINK_REG(multimedia9), }, {/* hw:x,28 */ .name = MSM_DAILINK_NAME(Compress4), .stream_name = "Compress4", - .cpu_dai_name = "MultiMedia11", - .platform_name = "msm-compress-dsp", .dynamic = 1, .dpcm_playback = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .ignore_suspend = 1, .ignore_pmdown_time = 1, /* this dainlink has playback support */ .id = MSM_FRONTEND_DAI_MULTIMEDIA11, + SND_SOC_DAILINK_REG(multimedia11), }, {/* hw:x,29 */ .name = MSM_DAILINK_NAME(Compress5), .stream_name = "Compress5", - .cpu_dai_name = "MultiMedia12", - .platform_name = "msm-compress-dsp", .dynamic = 1, .dpcm_playback = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .ignore_suspend = 1, .ignore_pmdown_time = 1, /* this dainlink has playback support */ .id = MSM_FRONTEND_DAI_MULTIMEDIA12, + SND_SOC_DAILINK_REG(multimedia12), }, {/* hw:x,30 */ .name = MSM_DAILINK_NAME(Compress6), .stream_name = "Compress6", - .cpu_dai_name = "MultiMedia13", - .platform_name = "msm-compress-dsp", .dynamic = 1, .dpcm_playback = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .ignore_suspend = 1, .ignore_pmdown_time = 1, /* this dainlink has playback support */ .id = MSM_FRONTEND_DAI_MULTIMEDIA13, + SND_SOC_DAILINK_REG(multimedia13), }, {/* hw:x,31 */ .name = MSM_DAILINK_NAME(Compress7), .stream_name = "Compress7", - .cpu_dai_name = "MultiMedia14", - .platform_name = "msm-compress-dsp", .dynamic = 1, .dpcm_playback = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .ignore_suspend = 1, .ignore_pmdown_time = 1, /* this dainlink has playback support */ .id = MSM_FRONTEND_DAI_MULTIMEDIA14, + SND_SOC_DAILINK_REG(multimedia14), }, {/* hw:x,32 */ .name = MSM_DAILINK_NAME(Compress8), .stream_name = "Compress8", - .cpu_dai_name = "MultiMedia15", - .platform_name = "msm-compress-dsp", .dynamic = 1, .dpcm_playback = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .ignore_suspend = 1, .ignore_pmdown_time = 1, /* this dainlink has playback support */ .id = MSM_FRONTEND_DAI_MULTIMEDIA15, + SND_SOC_DAILINK_REG(multimedia15), }, {/* hw:x,33 */ .name = MSM_DAILINK_NAME(ULL_NOIRQ_2), .stream_name = "MM_NOIRQ_2", - .cpu_dai_name = "MultiMedia16", - .platform_name = "msm-pcm-dsp-noirq", .dynamic = 1, .dpcm_playback = 1, .dpcm_capture = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .ignore_suspend = 1, .ignore_pmdown_time = 1, /* this dainlink has playback support */ .id = MSM_FRONTEND_DAI_MULTIMEDIA16, + .ops = &msm_fe_qos_ops, + SND_SOC_DAILINK_REG(multimedia16), }, {/* hw:x,34 */ .name = "SLIMBUS_8 Hostless", .stream_name = "SLIMBUS8_HOSTLESS Capture", - .cpu_dai_name = "SLIMBUS8_HOSTLESS", - .platform_name = "msm-pcm-hostless", .dynamic = 1, .dpcm_capture = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ignore_suspend = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", + SND_SOC_DAILINK_REG(slimbus8_hostless), }, {/* hw:x,35 */ .name = "CDC_DMA Hostless", .stream_name = "CDC_DMA Hostless", - .cpu_dai_name = "CDC_DMA_HOSTLESS", - .platform_name = "msm-pcm-hostless", .dynamic = 1, .dpcm_playback = 1, .dpcm_capture = 1, @@ -6610,22 +6481,18 @@ static struct snd_soc_dai_link msm_common_dai_links[] = { .ignore_suspend = 1, /* this dailink has playback support */ .ignore_pmdown_time = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", + SND_SOC_DAILINK_REG(cdcdma_hostless), }, {/* hw:x,36 */ .name = "TX3_CDC_DMA Hostless", .stream_name = "TX3_CDC_DMA Hostless", - .cpu_dai_name = "TX3_CDC_DMA_HOSTLESS", - .platform_name = "msm-pcm-hostless", .dynamic = 1, .dpcm_capture = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ignore_suspend = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", + SND_SOC_DAILINK_REG(tx3_cdcdma_hostless), }, }; @@ -6633,40 +6500,31 @@ static struct snd_soc_dai_link msm_tavil_fe_dai_links[] = { {/* hw:x,37 */ .name = LPASS_BE_SLIMBUS_4_TX, .stream_name = "Slimbus4 Capture", - .cpu_dai_name = "msm-dai-q6-dev.16393", - .platform_name = "msm-pcm-hostless", - .codec_name = "tavil_codec", - .codec_dai_name = "tavil_vifeedback", .id = MSM_BACKEND_DAI_SLIMBUS_4_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ops = &msm_be_ops, .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(lpass_be_slimbus_4_tx), }, /* Ultrasound RX DAI Link */ {/* hw:x,38 */ .name = "SLIMBUS_2 Hostless Playback", .stream_name = "SLIMBUS_2 Hostless Playback", - .cpu_dai_name = "msm-dai-q6-dev.16388", - .platform_name = "msm-pcm-hostless", - .codec_name = "tavil_codec", - .codec_dai_name = "tavil_rx2", .ignore_suspend = 1, .ignore_pmdown_time = 1, .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ops = &msm_slimbus_2_be_ops, + SND_SOC_DAILINK_REG(slimbus_2_hostless_playback), }, /* Ultrasound TX DAI Link */ {/* hw:x,39 */ .name = "SLIMBUS_2 Hostless Capture", .stream_name = "SLIMBUS_2 Hostless Capture", - .cpu_dai_name = "msm-dai-q6-dev.16389", - .platform_name = "msm-pcm-hostless", - .codec_name = "tavil_codec", - .codec_dai_name = "tavil_tx2", .ignore_suspend = 1, .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ops = &msm_slimbus_2_be_ops, + SND_SOC_DAILINK_REG(slimbus_2_hostless_capture), }, }; @@ -6674,72 +6532,57 @@ static struct snd_soc_dai_link msm_int_compress_capture_dai[] = { { .name = "Compress9", .stream_name = "Compress9", - .cpu_dai_name = "MultiMedia17", - .platform_name = "msm-compress-dsp", .dynamic = 1, .dpcm_capture = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .ignore_suspend = 1, .id = MSM_FRONTEND_DAI_MULTIMEDIA17, + SND_SOC_DAILINK_REG(multimedia17), }, { .name = "Compress10", .stream_name = "Compress10", - .cpu_dai_name = "MultiMedia18", - .platform_name = "msm-compress-dsp", .dynamic = 1, .dpcm_capture = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .ignore_suspend = 1, .id = MSM_FRONTEND_DAI_MULTIMEDIA18, + SND_SOC_DAILINK_REG(multimedia18), }, { .name = "Compress11", .stream_name = "Compress11", - .cpu_dai_name = "MultiMedia19", - .platform_name = "msm-compress-dsp", .dynamic = 1, .dpcm_capture = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .ignore_suspend = 1, .id = MSM_FRONTEND_DAI_MULTIMEDIA19, + SND_SOC_DAILINK_REG(multimedia19), }, { .name = "Compress12", .stream_name = "Compress12", - .cpu_dai_name = "MultiMedia28", - .platform_name = "msm-compress-dsp", .dynamic = 1, .dpcm_capture = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .ignore_suspend = 1, .id = MSM_FRONTEND_DAI_MULTIMEDIA28, + SND_SOC_DAILINK_REG(multimedia28), }, { .name = "Compress13", .stream_name = "Compress13", - .cpu_dai_name = "MultiMedia29", - .platform_name = "msm-compress-dsp", .dynamic = 1, .dpcm_capture = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .ignore_suspend = 1, .id = MSM_FRONTEND_DAI_MULTIMEDIA29, + SND_SOC_DAILINK_REG(multimedia29), }, }; @@ -6747,15 +6590,12 @@ static struct snd_soc_dai_link msm_bolero_fe_dai_links[] = { {/* hw:x,37 */ .name = LPASS_BE_WSA_CDC_DMA_TX_0, .stream_name = "WSA CDC DMA0 Capture", - .cpu_dai_name = "msm-dai-cdc-dma-dev.45057", - .platform_name = "msm-pcm-hostless", - .codec_name = "bolero_codec", - .codec_dai_name = "wsa_macro_vifeedback", .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_suspend = 1, .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ops = &msm_cdc_dma_be_ops, + SND_SOC_DAILINK_REG(wsa_cdcdma0_capture), }, }; @@ -6764,64 +6604,50 @@ static struct snd_soc_dai_link msm_tasha_fe_dai_links[] = { { .name = LPASS_BE_SLIMBUS_4_TX, .stream_name = "Slimbus4 Capture", - .cpu_dai_name = "msm-dai-q6-dev.16393", - .platform_name = "msm-pcm-hostless", - .codec_name = "tasha_codec", - .codec_dai_name = "tasha_vifeedback", .id = MSM_BACKEND_DAI_SLIMBUS_4_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ops = &msm_be_ops, .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(lpass_be_slimbus_4_tx), }, /* Ultrasound RX DAI Link */ { .name = "SLIMBUS_2 Hostless Playback", .stream_name = "SLIMBUS_2 Hostless Playback", - .cpu_dai_name = "msm-dai-q6-dev.16388", - .platform_name = "msm-pcm-hostless", - .codec_name = "tasha_codec", - .codec_dai_name = "tasha_rx2", .ignore_suspend = 1, .dpcm_playback = 1, .dpcm_capture = 1, .ignore_pmdown_time = 1, .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ops = &msm_slimbus_2_be_ops, + SND_SOC_DAILINK_REG(slimbus_2_hostless_playback), }, /* Ultrasound TX DAI Link */ { .name = "SLIMBUS_2 Hostless Capture", .stream_name = "SLIMBUS_2 Hostless Capture", - .cpu_dai_name = "msm-dai-q6-dev.16389", - .platform_name = "msm-pcm-hostless", - .codec_name = "tasha_codec", - .codec_dai_name = "tasha_tx2", .ignore_suspend = 1, .dpcm_capture = 1, .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ops = &msm_slimbus_2_be_ops, + SND_SOC_DAILINK_REG(slimbus_2_hostless_capture), }, /* CPE LSM direct dai-link */ { .name = "CPE Listen service", .stream_name = "CPE Listen Audio Service", - .cpu_dai_name = "msm-dai-slim", - .platform_name = "msm-cpe-lsm", .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ignore_suspend = 1, .dpcm_capture = 1, - .codec_dai_name = "tasha_mad1", - .codec_name = "tasha_codec", .ops = &msm_ext_cpe_ops, + SND_SOC_DAILINK_REG(cpe_listen_service), }, { .name = "SLIMBUS_6 Hostless Playback", .stream_name = "SLIMBUS_6 Hostless", - .cpu_dai_name = "SLIMBUS6_HOSTLESS", - .platform_name = "msm-pcm-hostless", .dynamic = 1, .dpcm_playback = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, @@ -6830,22 +6656,18 @@ static struct snd_soc_dai_link msm_tasha_fe_dai_links[] = { .ignore_suspend = 1, /* this dailink has playback support */ .ignore_pmdown_time = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", + SND_SOC_DAILINK_REG(slimbus_6_hostless_playback), }, /* CPE LSM EC PP direct dai-link */ { .name = "CPE Listen service ECPP", .stream_name = "CPE Listen Audio Service ECPP", - .cpu_dai_name = "CPE_LSM_NOHOST", - .platform_name = "msm-cpe-lsm.3", .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ignore_suspend = 1, .ignore_pmdown_time = 1, - .codec_dai_name = "tasha_cpe", - .codec_name = "tasha_codec", + SND_SOC_DAILINK_REG(cpe_listen_service_ecpp), }, }; @@ -6853,25 +6675,20 @@ static struct snd_soc_dai_link msm_common_misc_fe_dai_links[] = { { .name = MSM_DAILINK_NAME(ASM Loopback), .stream_name = "MultiMedia6", - .cpu_dai_name = "MultiMedia6", - .platform_name = "msm-pcm-loopback", .dynamic = 1, .dpcm_playback = 1, .dpcm_capture = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .ignore_suspend = 1, .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ignore_pmdown_time = 1, .id = MSM_FRONTEND_DAI_MULTIMEDIA6, + SND_SOC_DAILINK_REG(multimedia6), }, { .name = "USB Audio Hostless", .stream_name = "USB Audio Hostless", - .cpu_dai_name = "USBAUDIO_HOSTLESS", - .platform_name = "msm-pcm-hostless", .dynamic = 1, .dpcm_playback = 1, .dpcm_capture = 1, @@ -6880,8 +6697,7 @@ static struct snd_soc_dai_link msm_common_misc_fe_dai_links[] = { .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, .ignore_suspend = 1, .ignore_pmdown_time = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", + SND_SOC_DAILINK_REG(usbaudio_hostless), }, }; @@ -6890,10 +6706,6 @@ static struct snd_soc_dai_link msm_common_be_dai_links[] = { { .name = LPASS_BE_AFE_PCM_RX, .stream_name = "AFE Playback", - .cpu_dai_name = "msm-dai-q6-dev.224", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_AFE_PCM_RX, @@ -6901,112 +6713,91 @@ static struct snd_soc_dai_link msm_common_be_dai_links[] = { /* this dainlink has playback support */ .ignore_pmdown_time = 1, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(afe_pcm_rx), }, { .name = LPASS_BE_AFE_PCM_TX, .stream_name = "AFE Capture", - .cpu_dai_name = "msm-dai-q6-dev.225", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_AFE_PCM_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(afe_pcm_tx), }, /* Incall Record Uplink BACK END DAI Link */ { .name = LPASS_BE_INCALL_RECORD_TX, .stream_name = "Voice Uplink Capture", - .cpu_dai_name = "msm-dai-q6-dev.32772", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_INCALL_RECORD_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(incall_record_tx), }, /* Incall Record Downlink BACK END DAI Link */ { .name = LPASS_BE_INCALL_RECORD_RX, .stream_name = "Voice Downlink Capture", - .cpu_dai_name = "msm-dai-q6-dev.32771", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_INCALL_RECORD_RX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(incall_record_rx), }, /* Incall Music BACK END DAI Link */ { .name = LPASS_BE_VOICE_PLAYBACK_TX, .stream_name = "Voice Farend Playback", - .cpu_dai_name = "msm-dai-q6-dev.32773", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_suspend = 1, .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(voice_playback_tx), }, /* Incall Music 2 BACK END DAI Link */ { .name = LPASS_BE_VOICE2_PLAYBACK_TX, .stream_name = "Voice2 Farend Playback", - .cpu_dai_name = "msm-dai-q6-dev.32770", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_suspend = 1, .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(voice2_playback_tx), }, { .name = LPASS_BE_USB_AUDIO_RX, .stream_name = "USB Audio Playback", - .cpu_dai_name = "msm-dai-q6-dev.28672", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", +#if IS_ENABLED(CONFIG_AUDIO_QGKI) + .dynamic_be = 1, +#endif /* CONFIG_AUDIO_QGKI */ .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_USB_RX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_pmdown_time = 1, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(usb_audio_rx), }, { .name = LPASS_BE_USB_AUDIO_TX, .stream_name = "USB Audio Capture", - .cpu_dai_name = "msm-dai-q6-dev.28673", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_USB_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(usb_audio_tx), }, { .name = LPASS_BE_PRI_TDM_RX_0, .stream_name = "Primary TDM0 Playback", - .cpu_dai_name = "msm-dai-q6-tdm.36864", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_PRI_TDM_RX_0, @@ -7014,28 +6805,22 @@ static struct snd_soc_dai_link msm_common_be_dai_links[] = { .ops = &sm6150_tdm_be_ops, .ignore_suspend = 1, .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(pri_tdm_rx_0), }, { .name = LPASS_BE_PRI_TDM_TX_0, .stream_name = "Primary TDM0 Capture", - .cpu_dai_name = "msm-dai-q6-tdm.36865", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_PRI_TDM_TX_0, .be_hw_params_fixup = msm_be_hw_params_fixup, .ops = &sm6150_tdm_be_ops, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(pri_tdm_tx_0), }, { .name = LPASS_BE_SEC_TDM_RX_0, .stream_name = "Secondary TDM0 Playback", - .cpu_dai_name = "msm-dai-q6-tdm.36880", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_SEC_TDM_RX_0, @@ -7043,28 +6828,22 @@ static struct snd_soc_dai_link msm_common_be_dai_links[] = { .ops = &sm6150_tdm_be_ops, .ignore_suspend = 1, .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(sec_tdm_rx_0), }, { .name = LPASS_BE_SEC_TDM_TX_0, .stream_name = "Secondary TDM0 Capture", - .cpu_dai_name = "msm-dai-q6-tdm.36881", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_SEC_TDM_TX_0, .be_hw_params_fixup = msm_be_hw_params_fixup, .ops = &sm6150_tdm_be_ops, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(sec_tdm_tx_0), }, { .name = LPASS_BE_TERT_TDM_RX_0, .stream_name = "Tertiary TDM0 Playback", - .cpu_dai_name = "msm-dai-q6-tdm.36896", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_TERT_TDM_RX_0, @@ -7072,28 +6851,22 @@ static struct snd_soc_dai_link msm_common_be_dai_links[] = { .ops = &sm6150_tdm_be_ops, .ignore_suspend = 1, .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(tert_tdm_rx_0), }, { .name = LPASS_BE_TERT_TDM_TX_0, .stream_name = "Tertiary TDM0 Capture", - .cpu_dai_name = "msm-dai-q6-tdm.36897", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_TERT_TDM_TX_0, .be_hw_params_fixup = msm_be_hw_params_fixup, .ops = &sm6150_tdm_be_ops, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(tert_tdm_tx_0), }, { .name = LPASS_BE_QUAT_TDM_RX_0, .stream_name = "Quaternary TDM0 Playback", - .cpu_dai_name = "msm-dai-q6-tdm.36912", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_QUAT_TDM_RX_0, @@ -7101,28 +6874,22 @@ static struct snd_soc_dai_link msm_common_be_dai_links[] = { .ops = &sm6150_tdm_be_ops, .ignore_suspend = 1, .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(quat_tdm_rx_0), }, { .name = LPASS_BE_QUAT_TDM_TX_0, .stream_name = "Quaternary TDM0 Capture", - .cpu_dai_name = "msm-dai-q6-tdm.36913", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_QUAT_TDM_TX_0, .be_hw_params_fixup = msm_be_hw_params_fixup, .ops = &sm6150_tdm_be_ops, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(quat_tdm_tx_0), }, { .name = LPASS_BE_QUIN_TDM_RX_0, .stream_name = "Quinary TDM0 Playback", - .cpu_dai_name = "msm-dai-q6-tdm.36928", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_QUIN_TDM_RX_0, @@ -7130,20 +6897,18 @@ static struct snd_soc_dai_link msm_common_be_dai_links[] = { .ops = &sm6150_tdm_be_ops, .ignore_suspend = 1, .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(quin_tdm_rx_0), }, { .name = LPASS_BE_QUIN_TDM_TX_0, .stream_name = "Quinary TDM0 Capture", - .cpu_dai_name = "msm-dai-q6-tdm.36929", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_QUIN_TDM_TX_0, .be_hw_params_fixup = msm_be_hw_params_fixup, .ops = &sm6150_tdm_be_ops, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(quin_tdm_tx_0), }, }; @@ -7151,10 +6916,6 @@ static struct snd_soc_dai_link msm_tavil_be_dai_links[] = { { .name = LPASS_BE_SLIMBUS_0_RX, .stream_name = "Slimbus Playback", - .cpu_dai_name = "msm-dai-q6-dev.16384", - .platform_name = "msm-pcm-routing", - .codec_name = "tavil_codec", - .codec_dai_name = "tavil_rx1", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_SLIMBUS_0_RX, @@ -7164,28 +6925,23 @@ static struct snd_soc_dai_link msm_tavil_be_dai_links[] = { .ignore_pmdown_time = 1, .ignore_suspend = 1, .ops = &msm_be_ops, + SND_SOC_DAILINK_REG(slimbus_0_rx), }, { .name = LPASS_BE_SLIMBUS_0_TX, .stream_name = "Slimbus Capture", - .cpu_dai_name = "msm-dai-q6-dev.16385", - .platform_name = "msm-pcm-routing", - .codec_name = "tavil_codec", - .codec_dai_name = "tavil_tx1", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_SLIMBUS_0_TX, + .init = &msm_wsa881x_init, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_suspend = 1, .ops = &msm_be_ops, + SND_SOC_DAILINK_REG(slimbus_0_tx), }, { .name = LPASS_BE_SLIMBUS_1_RX, .stream_name = "Slimbus1 Playback", - .cpu_dai_name = "msm-dai-q6-dev.16386", - .platform_name = "msm-pcm-routing", - .codec_name = "tavil_codec", - .codec_dai_name = "tavil_rx1", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_SLIMBUS_1_RX, @@ -7194,28 +6950,22 @@ static struct snd_soc_dai_link msm_tavil_be_dai_links[] = { /* dai link has playback support */ .ignore_pmdown_time = 1, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(slimbus_1_rx), }, { .name = LPASS_BE_SLIMBUS_1_TX, .stream_name = "Slimbus1 Capture", - .cpu_dai_name = "msm-dai-q6-dev.16387", - .platform_name = "msm-pcm-routing", - .codec_name = "tavil_codec", - .codec_dai_name = "tavil_tx3", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_SLIMBUS_1_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ops = &msm_be_ops, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(slimbus_1_tx), }, { .name = LPASS_BE_SLIMBUS_2_RX, .stream_name = "Slimbus2 Playback", - .cpu_dai_name = "msm-dai-q6-dev.16388", - .platform_name = "msm-pcm-routing", - .codec_name = "tavil_codec", - .codec_dai_name = "tavil_rx2", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_SLIMBUS_2_RX, @@ -7223,14 +6973,11 @@ static struct snd_soc_dai_link msm_tavil_be_dai_links[] = { .ops = &msm_be_ops, .ignore_pmdown_time = 1, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(slimbus_2_rx), }, { .name = LPASS_BE_SLIMBUS_3_RX, .stream_name = "Slimbus3 Playback", - .cpu_dai_name = "msm-dai-q6-dev.16390", - .platform_name = "msm-pcm-routing", - .codec_name = "tavil_codec", - .codec_dai_name = "tavil_rx1", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_SLIMBUS_3_RX, @@ -7239,28 +6986,22 @@ static struct snd_soc_dai_link msm_tavil_be_dai_links[] = { /* dai link has playback support */ .ignore_pmdown_time = 1, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(slimbus_3_rx), }, { .name = LPASS_BE_SLIMBUS_3_TX, .stream_name = "Slimbus3 Capture", - .cpu_dai_name = "msm-dai-q6-dev.16391", - .platform_name = "msm-pcm-routing", - .codec_name = "tavil_codec", - .codec_dai_name = "tavil_tx1", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_SLIMBUS_3_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ops = &msm_be_ops, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(slimbus_3_tx), }, { .name = LPASS_BE_SLIMBUS_4_RX, .stream_name = "Slimbus4 Playback", - .cpu_dai_name = "msm-dai-q6-dev.16392", - .platform_name = "msm-pcm-routing", - .codec_name = "tavil_codec", - .codec_dai_name = "tavil_rx1", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_SLIMBUS_4_RX, @@ -7269,14 +7010,11 @@ static struct snd_soc_dai_link msm_tavil_be_dai_links[] = { /* dai link has playback support */ .ignore_pmdown_time = 1, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(slimbus_4_rx), }, { .name = LPASS_BE_SLIMBUS_5_RX, .stream_name = "Slimbus5 Playback", - .cpu_dai_name = "msm-dai-q6-dev.16394", - .platform_name = "msm-pcm-routing", - .codec_name = "tavil_codec", - .codec_dai_name = "tavil_rx3", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_SLIMBUS_5_RX, @@ -7285,29 +7023,23 @@ static struct snd_soc_dai_link msm_tavil_be_dai_links[] = { /* dai link has playback support */ .ignore_pmdown_time = 1, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(slimbus_5_rx), }, /* MAD BE */ { .name = LPASS_BE_SLIMBUS_5_TX, .stream_name = "Slimbus5 Capture", - .cpu_dai_name = "msm-dai-q6-dev.16395", - .platform_name = "msm-pcm-routing", - .codec_name = "tavil_codec", - .codec_dai_name = "tavil_mad1", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_SLIMBUS_5_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ops = &msm_be_ops, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(slimbus_5_tx), }, { .name = LPASS_BE_SLIMBUS_6_RX, .stream_name = "Slimbus6 Playback", - .cpu_dai_name = "msm-dai-q6-dev.16396", - .platform_name = "msm-pcm-routing", - .codec_name = "tavil_codec", - .codec_dai_name = "tavil_rx4", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_SLIMBUS_6_RX, @@ -7316,21 +7048,19 @@ static struct snd_soc_dai_link msm_tavil_be_dai_links[] = { /* dai link has playback support */ .ignore_pmdown_time = 1, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(slimbus_6_rx), }, /* Slimbus VI Recording */ { .name = LPASS_BE_SLIMBUS_TX_VI, .stream_name = "Slimbus4 Capture", - .cpu_dai_name = "msm-dai-q6-dev.16393", - .platform_name = "msm-pcm-routing", - .codec_name = "tavil_codec", - .codec_dai_name = "tavil_vifeedback", .id = MSM_BACKEND_DAI_SLIMBUS_4_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ops = &msm_be_ops, .ignore_suspend = 1, .no_pcm = 1, .dpcm_capture = 1, + SND_SOC_DAILINK_REG(slimbus_tx_vi), }, }; @@ -7339,10 +7069,6 @@ static struct snd_soc_dai_link msm_tasha_be_dai_links[] = { { .name = LPASS_BE_SLIMBUS_0_RX, .stream_name = "Slimbus Playback", - .cpu_dai_name = "msm-dai-q6-dev.16384", - .platform_name = "msm-pcm-routing", - .codec_name = "tasha_codec", - .codec_dai_name = "tasha_mix_rx1", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_SLIMBUS_0_RX, @@ -7352,28 +7078,23 @@ static struct snd_soc_dai_link msm_tasha_be_dai_links[] = { .ignore_pmdown_time = 1, .ignore_suspend = 1, .ops = &msm_be_ops, + SND_SOC_DAILINK_REG(slimbus_0_rx), }, { .name = LPASS_BE_SLIMBUS_0_TX, .stream_name = "Slimbus Capture", - .cpu_dai_name = "msm-dai-q6-dev.16385", - .platform_name = "msm-pcm-routing", - .codec_name = "tasha_codec", - .codec_dai_name = "tasha_tx1", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_SLIMBUS_0_TX, + .init = &msm_wsa881x_init, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_suspend = 1, .ops = &msm_be_ops, + SND_SOC_DAILINK_REG(slimbus_0_tx), }, { .name = LPASS_BE_SLIMBUS_1_RX, .stream_name = "Slimbus1 Playback", - .cpu_dai_name = "msm-dai-q6-dev.16386", - .platform_name = "msm-pcm-routing", - .codec_name = "tasha_codec", - .codec_dai_name = "tasha_mix_rx1", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_SLIMBUS_1_RX, @@ -7382,28 +7103,22 @@ static struct snd_soc_dai_link msm_tasha_be_dai_links[] = { /* dai link has playback support */ .ignore_pmdown_time = 1, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(slimbus_1_rx), }, { .name = LPASS_BE_SLIMBUS_1_TX, .stream_name = "Slimbus1 Capture", - .cpu_dai_name = "msm-dai-q6-dev.16387", - .platform_name = "msm-pcm-routing", - .codec_name = "tasha_codec", - .codec_dai_name = "tasha_tx3", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_SLIMBUS_1_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ops = &msm_be_ops, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(slimbus_1_tx), }, { .name = LPASS_BE_SLIMBUS_3_RX, .stream_name = "Slimbus3 Playback", - .cpu_dai_name = "msm-dai-q6-dev.16390", - .platform_name = "msm-pcm-routing", - .codec_name = "tasha_codec", - .codec_dai_name = "tasha_mix_rx1", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_SLIMBUS_3_RX, @@ -7412,14 +7127,11 @@ static struct snd_soc_dai_link msm_tasha_be_dai_links[] = { /* dai link has playback support */ .ignore_pmdown_time = 1, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(slimbus_3_rx), }, { .name = LPASS_BE_SLIMBUS_3_TX, .stream_name = "Slimbus3 Capture", - .cpu_dai_name = "msm-dai-q6-dev.16391", - .platform_name = "msm-pcm-routing", - .codec_name = "tasha_codec", - .codec_dai_name = "tasha_tx1", .no_pcm = 1, .dpcm_capture = 1, .dpcm_playback = 1, @@ -7427,14 +7139,11 @@ static struct snd_soc_dai_link msm_tasha_be_dai_links[] = { .be_hw_params_fixup = msm_be_hw_params_fixup, .ops = &msm_be_ops, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(slimbus_3_tx), }, { .name = LPASS_BE_SLIMBUS_4_RX, .stream_name = "Slimbus4 Playback", - .cpu_dai_name = "msm-dai-q6-dev.16392", - .platform_name = "msm-pcm-routing", - .codec_name = "tasha_codec", - .codec_dai_name = "tasha_mix_rx1", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_SLIMBUS_4_RX, @@ -7443,14 +7152,11 @@ static struct snd_soc_dai_link msm_tasha_be_dai_links[] = { /* dai link has playback support */ .ignore_pmdown_time = 1, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(slimbus_4_rx), }, { .name = LPASS_BE_SLIMBUS_5_RX, .stream_name = "Slimbus5 Playback", - .cpu_dai_name = "msm-dai-q6-dev.16394", - .platform_name = "msm-pcm-routing", - .codec_name = "tasha_codec", - .codec_dai_name = "tasha_rx3", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_SLIMBUS_5_RX, @@ -7459,29 +7165,23 @@ static struct snd_soc_dai_link msm_tasha_be_dai_links[] = { /* dai link has playback support */ .ignore_pmdown_time = 1, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(slimbus_5_rx), }, /* MAD BE */ { .name = LPASS_BE_SLIMBUS_5_TX, .stream_name = "Slimbus5 Capture", - .cpu_dai_name = "msm-dai-q6-dev.16395", - .platform_name = "msm-pcm-routing", - .codec_name = "tasha_codec", - .codec_dai_name = "tasha_mad1", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_SLIMBUS_5_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ops = &msm_be_ops, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(slimbus_5_tx), }, { .name = LPASS_BE_SLIMBUS_6_RX, .stream_name = "Slimbus6 Playback", - .cpu_dai_name = "msm-dai-q6-dev.16396", - .platform_name = "msm-pcm-routing", - .codec_name = "tasha_codec", - .codec_dai_name = "tasha_rx4", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_SLIMBUS_6_RX, @@ -7490,21 +7190,18 @@ static struct snd_soc_dai_link msm_tasha_be_dai_links[] = { /* dai link has playback support */ .ignore_pmdown_time = 1, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(slimbus_6_rx), }, }; static struct snd_soc_dai_link msm_wcn_be_dai_links[] = { { - .name = LPASS_BE_SLIMBUS_7_RX, + .name = LPASS_BE_SLIMBUS_TX_VI, .stream_name = "Slimbus7 Playback", - .cpu_dai_name = "msm-dai-q6-dev.16398", - .platform_name = "msm-pcm-routing", - .codec_name = "btfmslim_slave", /* BT codec driver determines capabilities based on * dai name, bt codecdai name should always contains * supported usecase information */ - .codec_dai_name = "btfm_bt_sco_a2dp_slim_rx", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_SLIMBUS_7_RX, @@ -7513,28 +7210,22 @@ static struct snd_soc_dai_link msm_wcn_be_dai_links[] = { /* dai link has playback support */ .ignore_pmdown_time = 1, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(slimbus_7_rx), }, { .name = LPASS_BE_SLIMBUS_7_TX, .stream_name = "Slimbus7 Capture", - .cpu_dai_name = "msm-dai-q6-dev.16399", - .platform_name = "msm-pcm-routing", - .codec_name = "btfmslim_slave", - .codec_dai_name = "btfm_bt_sco_slim_tx", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_SLIMBUS_7_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ops = &msm_wcn_ops, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(slimbus_7_tx), }, { .name = LPASS_BE_SLIMBUS_8_TX, .stream_name = "Slimbus8 Capture", - .cpu_dai_name = "msm-dai-q6-dev.16401", - .platform_name = "msm-pcm-routing", - .codec_name = "btfmslim_slave", - .codec_dai_name = "btfm_fm_slim_tx", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_SLIMBUS_8_TX, @@ -7542,35 +7233,31 @@ static struct snd_soc_dai_link msm_wcn_be_dai_links[] = { .init = &msm_wcn_init, .ops = &msm_wcn_ops, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(slimbus_8_tx), }, }; +#if IS_ENABLED(CONFIG_AUDIO_QGKI) static struct snd_soc_dai_link ext_disp_be_dai_link[] = { /* DISP PORT BACK END DAI Link */ { .name = LPASS_BE_DISPLAY_PORT, .stream_name = "Display Port Playback", - .cpu_dai_name = "msm-dai-q6-dp.24608", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-ext-disp-audio-codec-rx", - .codec_dai_name = "msm_dp_audio_codec_rx_dai", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_pmdown_time = 1, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(ext_display_port), }, }; +#endif static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = { { .name = LPASS_BE_PRI_MI2S_RX, .stream_name = "Primary MI2S Playback", - .cpu_dai_name = "msm-dai-q6-mi2s.0", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_PRI_MI2S_RX, @@ -7578,28 +7265,22 @@ static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = { .ops = &msm_mi2s_be_ops, .ignore_suspend = 1, .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(pri_mi2s_rx), }, { .name = LPASS_BE_PRI_MI2S_TX, .stream_name = "Primary MI2S Capture", - .cpu_dai_name = "msm-dai-q6-mi2s.0", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_PRI_MI2S_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ops = &msm_mi2s_be_ops, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(pri_mi2s_tx), }, { .name = LPASS_BE_SEC_MI2S_RX, .stream_name = "Secondary MI2S Playback", - .cpu_dai_name = "msm-dai-q6-mi2s.1", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX, @@ -7607,28 +7288,22 @@ static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = { .ops = &msm_mi2s_be_ops, .ignore_suspend = 1, .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(sec_mi2s_rx), }, { .name = LPASS_BE_SEC_MI2S_TX, .stream_name = "Secondary MI2S Capture", - .cpu_dai_name = "msm-dai-q6-mi2s.1", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ops = &msm_mi2s_be_ops, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(sec_mi2s_tx), }, { .name = LPASS_BE_TERT_MI2S_RX, .stream_name = "Tertiary MI2S Playback", - .cpu_dai_name = "msm-dai-q6-mi2s.2", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX, @@ -7636,28 +7311,22 @@ static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = { .ops = &msm_mi2s_be_ops, .ignore_suspend = 1, .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(tert_mi2s_rx), }, { .name = LPASS_BE_TERT_MI2S_TX, .stream_name = "Tertiary MI2S Capture", - .cpu_dai_name = "msm-dai-q6-mi2s.2", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ops = &msm_mi2s_be_ops, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(tert_mi2s_tx), }, { .name = LPASS_BE_QUAT_MI2S_RX, .stream_name = "Quaternary MI2S Playback", - .cpu_dai_name = "msm-dai-q6-mi2s.3", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_RX, @@ -7665,28 +7334,22 @@ static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = { .ops = &msm_mi2s_be_ops, .ignore_suspend = 1, .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(quat_mi2s_rx), }, { .name = LPASS_BE_QUAT_MI2S_TX, .stream_name = "Quaternary MI2S Capture", - .cpu_dai_name = "msm-dai-q6-mi2s.3", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ops = &msm_mi2s_be_ops, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(quat_mi2s_tx), }, { .name = LPASS_BE_QUIN_MI2S_RX, .stream_name = "Quinary MI2S Playback", - .cpu_dai_name = "msm-dai-q6-mi2s.4", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_QUINARY_MI2S_RX, @@ -7694,20 +7357,18 @@ static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = { .ops = &msm_mi2s_be_ops, .ignore_suspend = 1, .ignore_pmdown_time = 1, + SND_SOC_DAILINK_REG(quin_mi2s_rx), }, { .name = LPASS_BE_QUIN_MI2S_TX, .stream_name = "Quinary MI2S Capture", - .cpu_dai_name = "msm-dai-q6-mi2s.4", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_QUINARY_MI2S_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ops = &msm_mi2s_be_ops, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(quin_mi2s_tx), }, }; @@ -7717,140 +7378,110 @@ static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = { { .name = LPASS_BE_AUXPCM_RX, .stream_name = "AUX PCM Playback", - .cpu_dai_name = "msm-dai-q6-auxpcm.1", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_AUXPCM_RX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_pmdown_time = 1, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(auxpcm_rx), }, { .name = LPASS_BE_AUXPCM_TX, .stream_name = "AUX PCM Capture", - .cpu_dai_name = "msm-dai-q6-auxpcm.1", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_AUXPCM_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(auxpcm_tx), }, /* Secondary AUX PCM Backend DAI Links */ { .name = LPASS_BE_SEC_AUXPCM_RX, .stream_name = "Sec AUX PCM Playback", - .cpu_dai_name = "msm-dai-q6-auxpcm.2", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_SEC_AUXPCM_RX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_pmdown_time = 1, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(sec_auxpcm_rx), }, { .name = LPASS_BE_SEC_AUXPCM_TX, .stream_name = "Sec AUX PCM Capture", - .cpu_dai_name = "msm-dai-q6-auxpcm.2", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_SEC_AUXPCM_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(sec_auxpcm_tx), }, /* Tertiary AUX PCM Backend DAI Links */ { .name = LPASS_BE_TERT_AUXPCM_RX, .stream_name = "Tert AUX PCM Playback", - .cpu_dai_name = "msm-dai-q6-auxpcm.3", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_TERT_AUXPCM_RX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(tert_auxpcm_rx), }, { .name = LPASS_BE_TERT_AUXPCM_TX, .stream_name = "Tert AUX PCM Capture", - .cpu_dai_name = "msm-dai-q6-auxpcm.3", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_TERT_AUXPCM_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(tert_auxpcm_tx), }, /* Quaternary AUX PCM Backend DAI Links */ { .name = LPASS_BE_QUAT_AUXPCM_RX, .stream_name = "Quat AUX PCM Playback", - .cpu_dai_name = "msm-dai-q6-auxpcm.4", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_QUAT_AUXPCM_RX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_pmdown_time = 1, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(quat_auxpcm_rx), }, { .name = LPASS_BE_QUAT_AUXPCM_TX, .stream_name = "Quat AUX PCM Capture", - .cpu_dai_name = "msm-dai-q6-auxpcm.4", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_QUAT_AUXPCM_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(quat_auxpcm_tx), }, /* Quinary AUX PCM Backend DAI Links */ { .name = LPASS_BE_QUIN_AUXPCM_RX, .stream_name = "Quin AUX PCM Playback", - .cpu_dai_name = "msm-dai-q6-auxpcm.5", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_QUIN_AUXPCM_RX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_pmdown_time = 1, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(quin_auxpcm_rx), }, { .name = LPASS_BE_QUIN_AUXPCM_TX, .stream_name = "Quin AUX PCM Capture", - .cpu_dai_name = "msm-dai-q6-auxpcm.5", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_QUIN_AUXPCM_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_suspend = 1, + SND_SOC_DAILINK_REG(quin_auxpcm_tx), }, }; @@ -7859,26 +7490,19 @@ static struct snd_soc_dai_link msm_wsa_cdc_dma_be_dai_links[] = { { .name = LPASS_BE_WSA_CDC_DMA_RX_0, .stream_name = "WSA CDC DMA0 Playback", - .cpu_dai_name = "msm-dai-cdc-dma-dev.45056", - .platform_name = "msm-pcm-routing", - .codec_name = "bolero_codec", - .codec_dai_name = "wsa_macro_rx1", .no_pcm = 1, .dpcm_playback = 1, - .init = &msm_int_audrx_init, + .init = &msm_wsa881x_init, .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_pmdown_time = 1, .ignore_suspend = 1, .ops = &msm_cdc_dma_be_ops, + SND_SOC_DAILINK_REG(wsa_dma_rx0), }, { .name = LPASS_BE_WSA_CDC_DMA_RX_1, .stream_name = "WSA CDC DMA1 Playback", - .cpu_dai_name = "msm-dai-cdc-dma-dev.45058", - .platform_name = "msm-pcm-routing", - .codec_name = "bolero_codec", - .codec_dai_name = "wsa_macro_rx_mix", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1, @@ -7886,20 +7510,18 @@ static struct snd_soc_dai_link msm_wsa_cdc_dma_be_dai_links[] = { .ignore_pmdown_time = 1, .ignore_suspend = 1, .ops = &msm_cdc_dma_be_ops, + SND_SOC_DAILINK_REG(wsa_dma_rx1), }, { .name = LPASS_BE_WSA_CDC_DMA_TX_1, .stream_name = "WSA CDC DMA1 Capture", - .cpu_dai_name = "msm-dai-cdc-dma-dev.45059", - .platform_name = "msm-pcm-routing", - .codec_name = "bolero_codec", - .codec_dai_name = "wsa_macro_echo", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_suspend = 1, .ops = &msm_cdc_dma_be_ops, + SND_SOC_DAILINK_REG(wsa_dma_tx1), }, }; @@ -7908,10 +7530,6 @@ static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = { { .name = LPASS_BE_RX_CDC_DMA_RX_0, .stream_name = "RX CDC DMA0 Playback", - .cpu_dai_name = "msm-dai-cdc-dma-dev.45104", - .platform_name = "msm-pcm-routing", - .codec_name = "bolero_codec", - .codec_dai_name = "rx_macro_rx1", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_0, @@ -7919,14 +7537,12 @@ static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = { .ignore_pmdown_time = 1, .ignore_suspend = 1, .ops = &msm_cdc_dma_be_ops, + SND_SOC_DAILINK_REG(rx_dma_rx0), + .init = &msm_rx_tx_codec_init, }, { .name = LPASS_BE_RX_CDC_DMA_RX_1, .stream_name = "RX CDC DMA1 Playback", - .cpu_dai_name = "msm-dai-cdc-dma-dev.45106", - .platform_name = "msm-pcm-routing", - .codec_name = "bolero_codec", - .codec_dai_name = "rx_macro_rx2", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_1, @@ -7934,14 +7550,11 @@ static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = { .ignore_pmdown_time = 1, .ignore_suspend = 1, .ops = &msm_cdc_dma_be_ops, + SND_SOC_DAILINK_REG(rx_dma_rx1), }, { .name = LPASS_BE_RX_CDC_DMA_RX_2, .stream_name = "RX CDC DMA2 Playback", - .cpu_dai_name = "msm-dai-cdc-dma-dev.45108", - .platform_name = "msm-pcm-routing", - .codec_name = "bolero_codec", - .codec_dai_name = "rx_macro_rx3", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_2, @@ -7949,14 +7562,11 @@ static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = { .ignore_pmdown_time = 1, .ignore_suspend = 1, .ops = &msm_cdc_dma_be_ops, + SND_SOC_DAILINK_REG(rx_dma_rx2), }, { .name = LPASS_BE_RX_CDC_DMA_RX_3, .stream_name = "RX CDC DMA3 Playback", - .cpu_dai_name = "msm-dai-cdc-dma-dev.45110", - .platform_name = "msm-pcm-routing", - .codec_name = "bolero_codec", - .codec_dai_name = "rx_macro_rx4", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_3, @@ -7964,49 +7574,41 @@ static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = { .ignore_pmdown_time = 1, .ignore_suspend = 1, .ops = &msm_cdc_dma_be_ops, + SND_SOC_DAILINK_REG(rx_dma_rx3), }, /* TX CDC DMA Backend DAI Links */ { .name = LPASS_BE_TX_CDC_DMA_TX_0, .stream_name = "TX CDC DMA0 Capture", - .cpu_dai_name = "msm-dai-cdc-dma-dev.45105", - .platform_name = "msm-pcm-routing", - .codec_name = "bolero_codec", - .codec_dai_name = "rx_macro_echo", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_0, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_suspend = 1, .ops = &msm_cdc_dma_be_ops, + SND_SOC_DAILINK_REG(rx_dma_tx0), }, { .name = LPASS_BE_TX_CDC_DMA_TX_3, .stream_name = "TX CDC DMA3 Capture", - .cpu_dai_name = "msm-dai-cdc-dma-dev.45111", - .platform_name = "msm-pcm-routing", - .codec_name = "bolero_codec", - .codec_dai_name = "tx_macro_tx1", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_3, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_suspend = 1, .ops = &msm_cdc_dma_be_ops, + SND_SOC_DAILINK_REG(rx_dma_tx3), }, { .name = LPASS_BE_TX_CDC_DMA_TX_4, .stream_name = "TX CDC DMA4 Capture", - .cpu_dai_name = "msm-dai-cdc-dma-dev.45113", - .platform_name = "msm-pcm-routing", - .codec_name = "bolero_codec", - .codec_dai_name = "tx_macro_tx2", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_4, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_suspend = 1, .ops = &msm_cdc_dma_be_ops, + SND_SOC_DAILINK_REG(rx_dma_tx4), }, }; @@ -8021,7 +7623,9 @@ static struct snd_soc_dai_link msm_sm6150_dai_links[ ARRAY_SIZE(msm_tavil_be_dai_links) + ARRAY_SIZE(msm_tasha_be_dai_links) + ARRAY_SIZE(msm_wcn_be_dai_links) + +#if IS_ENABLED(CONFIG_AUDIO_QGKI) ARRAY_SIZE(ext_disp_be_dai_link) + +#endif ARRAY_SIZE(msm_mi2s_be_dai_links) + ARRAY_SIZE(msm_auxpcm_be_dai_links) + ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links) + @@ -8119,82 +7723,139 @@ err_pcm_runtime: static int msm_populate_dai_link_component_of_node( struct snd_soc_card *card) { - int i, index, ret = 0; + int i, j, index, ret = 0; struct device *cdev = card->dev; struct snd_soc_dai_link *dai_link = card->dai_link; - struct device_node *np; + struct device_node *np = NULL; + int codecs_enabled = 0; + struct snd_soc_dai_link_component *codecs_comp = NULL; if (!cdev) { - pr_err("%s: Sound card device memory NULL\n", __func__); + dev_err(cdev, "%s: Sound card device memory NULL\n", __func__); return -ENODEV; } for (i = 0; i < card->num_links; i++) { - if (dai_link[i].platform_of_node && dai_link[i].cpu_of_node) + if (dai_link[i].platforms->of_node && dai_link[i].cpus->of_node) continue; /* populate platform_of_node for snd card dai links */ - if (dai_link[i].platform_name && - !dai_link[i].platform_of_node) { + if (dai_link[i].platforms->name && + !dai_link[i].platforms->of_node) { index = of_property_match_string(cdev->of_node, "asoc-platform-names", - dai_link[i].platform_name); + dai_link[i].platforms->name); if (index < 0) { - pr_err("%s: No match found for platform name: %s\n", - __func__, dai_link[i].platform_name); + dev_err(cdev, "%s: No match found for platform name: %s\n", + __func__, dai_link[i].platforms->name); ret = index; goto err; } np = of_parse_phandle(cdev->of_node, "asoc-platform", index); if (!np) { - pr_err("%s: retrieving phandle for platform %s, index %d failed\n", - __func__, dai_link[i].platform_name, + dev_err(cdev, "%s: retrieving phandle for platform %s, index %d failed\n", + __func__, dai_link[i].platforms->name, index); ret = -ENODEV; goto err; } - dai_link[i].platform_of_node = np; - dai_link[i].platform_name = NULL; + dai_link[i].platforms->of_node = np; + dai_link[i].platforms->name = NULL; } /* populate cpu_of_node for snd card dai links */ - if (dai_link[i].cpu_dai_name && !dai_link[i].cpu_of_node) { + if (dai_link[i].cpus->dai_name && !dai_link[i].cpus->of_node) { index = of_property_match_string(cdev->of_node, "asoc-cpu-names", - dai_link[i].cpu_dai_name); + dai_link[i].cpus->dai_name); if (index >= 0) { np = of_parse_phandle(cdev->of_node, "asoc-cpu", index); if (!np) { - pr_err("%s: retrieving phandle for cpu dai %s failed\n", + dev_err(cdev, "%s: retrieving phandle for cpu dai %s failed\n", __func__, - dai_link[i].cpu_dai_name); + dai_link[i].cpus->dai_name); ret = -ENODEV; goto err; } - dai_link[i].cpu_of_node = np; - dai_link[i].cpu_dai_name = NULL; + dai_link[i].cpus->of_node = np; + dai_link[i].cpus->dai_name = NULL; } } /* populate codec_of_node for snd card dai links */ - if (dai_link[i].codec_name && !dai_link[i].codec_of_node) { - index = of_property_match_string(cdev->of_node, - "asoc-codec-names", - dai_link[i].codec_name); - if (index < 0) - continue; - np = of_parse_phandle(cdev->of_node, "asoc-codec", - index); - if (!np) { - pr_err("%s: retrieving phandle for codec %s failed\n", - __func__, dai_link[i].codec_name); - ret = -ENODEV; - goto err; + if (dai_link[i].num_codecs > 0) { + for (j = 0; j < dai_link[i].num_codecs; j++) { + if (dai_link[i].codecs[j].of_node || + !dai_link[i].codecs[j].name) + continue; + + index = of_property_match_string(cdev->of_node, + "asoc-codec-names", + dai_link[i].codecs[j].name); + if (index < 0) + continue; + np = of_parse_phandle(cdev->of_node, + "asoc-codec", + index); + if (!np) { + dev_err(cdev, "%s: retrieving phandle for codec %s failed\n", + __func__, + dai_link[i].codecs[j].name); + ret = -ENODEV; + goto err; + } + dai_link[i].codecs[j].of_node = np; + dai_link[i].codecs[j].name = NULL; + } + } + } + + /* In multi-codec scenario, check if codecs are enabled for this platform */ + for (i = 0; i < card->num_links; i++) { + codecs_enabled = 0; + if (dai_link[i].num_codecs > 1) { + for (j = 0; j < dai_link[i].num_codecs; j++) { + if (!dai_link[i].codecs[j].of_node) + continue; + + np = dai_link[i].codecs[j].of_node; + if (!of_device_is_available(np)) { + dev_dbg(cdev, "%s: codec is disabled: %s\n", + __func__, + np->full_name); + dai_link[i].codecs[j].of_node = NULL; + continue; + } + + codecs_enabled++; + } + if (codecs_enabled > 0 && + codecs_enabled < dai_link[i].num_codecs) { + codecs_comp = devm_kzalloc(cdev, + sizeof(struct snd_soc_dai_link_component) + * codecs_enabled, GFP_KERNEL); + if (!codecs_comp) { + dev_err(cdev, "%s: %s dailink codec component alloc failed\n", + __func__, dai_link[i].name); + ret = -ENOMEM; + goto err; + } + index = 0; + for (j = 0; j < dai_link[i].num_codecs; j++) { + if(dai_link[i].codecs[j].of_node) { + codecs_comp[index].of_node = + dai_link[i].codecs[j].of_node; + codecs_comp[index].dai_name = + dai_link[i].codecs[j].dai_name; + codecs_comp[index].name = NULL; + index++; + } + } + dai_link[i].codecs = codecs_comp; + dai_link[i].num_codecs = codecs_enabled; } - dai_link[i].codec_of_node = np; - dai_link[i].codec_name = NULL; } } @@ -8262,20 +7923,19 @@ static struct snd_soc_dai_link msm_stub_fe_dai_links[] = { { .name = "MSMSTUB Media1", .stream_name = "MultiMedia1", - .cpu_dai_name = "MultiMedia1", - .platform_name = "msm-pcm-dsp.0", .dynamic = 1, +#if IS_ENABLED(CONFIG_AUDIO_QGKI) .async_ops = ASYNC_DPCM_SND_SOC_PREPARE, +#endif /* CONFIG_AUDIO_QGKI */ .dpcm_playback = 1, .dpcm_capture = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", .ignore_suspend = 1, /* this dainlink has playback support */ .ignore_pmdown_time = 1, - .id = MSM_FRONTEND_DAI_MULTIMEDIA1 + .id = MSM_FRONTEND_DAI_MULTIMEDIA1, + SND_SOC_DAILINK_REG(multimedia1), }, }; @@ -8285,10 +7945,6 @@ static struct snd_soc_dai_link msm_stub_be_dai_links[] = { { .name = LPASS_BE_SLIMBUS_0_RX, .stream_name = "Slimbus Playback", - .cpu_dai_name = "msm-dai-q6-dev.16384", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", .no_pcm = 1, .dpcm_playback = 1, .id = MSM_BACKEND_DAI_SLIMBUS_0_RX, @@ -8297,20 +7953,18 @@ static struct snd_soc_dai_link msm_stub_be_dai_links[] = { .ignore_pmdown_time = 1, /* dai link has playback support */ .ignore_suspend = 1, .ops = &msm_stub_be_ops, + SND_SOC_DAILINK_REG(slimbus_0_rx), }, { .name = LPASS_BE_SLIMBUS_0_TX, .stream_name = "Slimbus Capture", - .cpu_dai_name = "msm-dai-q6-dev.16385", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", .no_pcm = 1, .dpcm_capture = 1, .id = MSM_BACKEND_DAI_SLIMBUS_0_TX, .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_suspend = 1, .ops = &msm_stub_be_ops, + SND_SOC_DAILINK_REG(slimbus_0_tx), }, }; @@ -8335,8 +7989,8 @@ static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev) struct snd_soc_card *card = NULL; struct snd_soc_dai_link *dailink; int total_links = 0, rc = 0; - u32 tavil_codec = 0, auxpcm_audio_intf = 0; - u32 mi2s_audio_intf = 0, ext_disp_audio_intf = 0; + u32 tavil_codec = 0, val = 0; + u32 mi2s_audio_intf = 0; u32 wcn_btfm_intf = 0; const struct of_device_id *match; u32 tasha_codec = 0; @@ -8434,14 +8088,15 @@ static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev) ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links); } +#if IS_ENABLED(CONFIG_AUDIO_QGKI) rc = of_property_read_u32(dev->of_node, "qcom,ext-disp-audio-rx", - &ext_disp_audio_intf); + &val); if (rc) { dev_dbg(dev, "%s: No DT match Ext Disp interface\n", __func__); } else { - if (ext_disp_audio_intf) { + if (val) { memcpy(msm_sm6150_dai_links + total_links, ext_disp_be_dai_link, sizeof(ext_disp_be_dai_link)); @@ -8449,6 +8104,7 @@ static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev) ARRAY_SIZE(ext_disp_be_dai_link); } } +#endif rc = of_property_read_u32(dev->of_node, "qcom,mi2s-audio-intf", &mi2s_audio_intf); @@ -8483,12 +8139,12 @@ static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev) rc = of_property_read_u32(dev->of_node, "qcom,auxpcm-audio-intf", - &auxpcm_audio_intf); + &val); if (rc) { dev_dbg(dev, "%s: No DT match Aux PCM interface\n", __func__); } else { - if (auxpcm_audio_intf) { + if (val) { memcpy(msm_sm6150_dai_links + total_links, msm_auxpcm_be_dai_links, sizeof(msm_auxpcm_be_dai_links)); @@ -8522,7 +8178,7 @@ static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev) return card; } -static int msm_wsa881x_init(struct snd_soc_component *component) +static int msm_wsa881x_init(struct snd_soc_pcm_runtime *rtd) { u8 spkleft_ports[WSA881X_MAX_SWR_PORTS] = {0, 1, 2, 3}; u8 spkright_ports[WSA881X_MAX_SWR_PORTS] = {0, 1, 2, 3}; @@ -8532,22 +8188,21 @@ static int msm_wsa881x_init(struct snd_soc_component *component) SPKR_R_BOOST, SPKR_R_VI}; unsigned int ch_rate[WSA881X_MAX_SWR_PORTS] = {2400, 600, 300, 1200}; unsigned int ch_mask[WSA881X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3}; - struct msm_asoc_mach_data *pdata; - struct snd_soc_dapm_context *dapm; - struct snd_card *card = component->card->snd_card; - struct snd_info_entry *entry; - int ret = 0; + struct snd_soc_component *component = NULL; + struct msm_asoc_mach_data *pdata = + snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_dapm_context *dapm = NULL; - if (!component) { - pr_err("%s codec is NULL\n", __func__); - return -EINVAL; - } - dapm = snd_soc_component_get_dapm(component); + if (pdata->wsa_max_devs > 0) { + component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.1"); + if (!component) { + pr_err("%s: wsa-codec.1 component is NULL\n", __func__); + return -EINVAL; + } + + dapm = snd_soc_component_get_dapm(component); - if (!strcmp(component->name_prefix, "SpkrLeft")) { - dev_dbg(component->dev, "%s: setting left ch map to codec %s\n", - __func__, component->name); wsa881x_set_channel_map(component, &spkleft_ports[0], WSA881X_MAX_SWR_PORTS, &ch_mask[0], &ch_rate[0], &spkleft_port_types[0]); @@ -8555,9 +8210,20 @@ static int msm_wsa881x_init(struct snd_soc_component *component) snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft IN"); snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft SPKR"); } - } else if (!strcmp(component->name_prefix, "SpkrRight")) { - dev_dbg(component->dev, "%s: setting right ch map to codec %s\n", - __func__, component->name); + wsa881x_codec_info_create_codec_entry(pdata->codec_root, + component); + } + + /* If current platform has more than one WSA */ + if (pdata->wsa_max_devs > 1) { + component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.2"); + if (!component) { + pr_err("%s: wsa-codec.2 component is NULL\n", __func__); + return -EINVAL; + } + + dapm = snd_soc_component_get_dapm(component); + wsa881x_set_channel_map(component, &spkright_ports[0], WSA881X_MAX_SWR_PORTS, &ch_mask[0], &ch_rate[0], &spkright_port_types[0]); @@ -8565,367 +8231,12 @@ static int msm_wsa881x_init(struct snd_soc_component *component) snd_soc_dapm_ignore_suspend(dapm, "SpkrRight IN"); snd_soc_dapm_ignore_suspend(dapm, "SpkrRight SPKR"); } - } else { - dev_err(component->dev, "%s: wrong codec name %s\n", __func__, - component->name); - ret = -EINVAL; - goto err; + wsa881x_codec_info_create_codec_entry(pdata->codec_root, + component); } - pdata = snd_soc_card_get_drvdata(component->card); - if (!pdata->codec_root) { - entry = snd_info_create_subdir(card->module, "codecs", - card->proc_root); - if (!entry) { - pr_err("%s: Cannot create codecs module entry\n", - __func__); - ret = 0; - goto err; - } - pdata->codec_root = entry; - } - wsa881x_codec_info_create_codec_entry(pdata->codec_root, - component); -err: - return ret; + + return 0; } - -static int msm_aux_codec_init(struct snd_soc_component *component) -{ - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); - int ret = 0; - void *mbhc_calibration; - struct snd_info_entry *entry; - struct snd_card *card = component->card->snd_card; - struct msm_asoc_mach_data *pdata; - - snd_soc_dapm_ignore_suspend(dapm, "EAR"); - snd_soc_dapm_ignore_suspend(dapm, "AUX"); - snd_soc_dapm_ignore_suspend(dapm, "HPHL"); - snd_soc_dapm_ignore_suspend(dapm, "HPHR"); - snd_soc_dapm_ignore_suspend(dapm, "AMIC1"); - snd_soc_dapm_ignore_suspend(dapm, "AMIC2"); - snd_soc_dapm_ignore_suspend(dapm, "AMIC3"); - snd_soc_dapm_sync(dapm); - - pdata = snd_soc_card_get_drvdata(component->card); - if (!pdata->codec_root) { - entry = snd_info_create_subdir(card->module, "codecs", - card->proc_root); - if (!entry) { - pr_err("%s: Cannot create codecs module entry\n", - __func__); - ret = 0; - goto codec_root_err; - } - pdata->codec_root = entry; - } - wcd937x_info_create_codec_entry(pdata->codec_root, component); -codec_root_err: - mbhc_calibration = def_wcd_mbhc_cal(); - if (!mbhc_calibration) { - return -ENOMEM; - } - wcd_mbhc_cfg.calibration = mbhc_calibration; - ret = wcd937x_mbhc_hs_detect(component, &wcd_mbhc_cfg); - - return ret; -} - -static int msm_init_aux_dev(struct platform_device *pdev, - struct snd_soc_card *card) -{ - struct device_node *wsa_of_node; - struct device_node *aux_codec_of_node; - u32 wsa_max_devs; - u32 wsa_dev_cnt; - u32 codec_max_aux_devs = 0; - u32 codec_aux_dev_cnt = 0; - int i; - struct msm_wsa881x_dev_info *wsa881x_dev_info = NULL; - struct aux_codec_dev_info *aux_cdc_dev_info = NULL; - const char *auxdev_name_prefix[1]; - char *dev_name_str = NULL; - int found = 0; - int codecs_found = 0; - int ret = 0; - - /* Get maximum WSA device count for this platform */ - ret = of_property_read_u32(pdev->dev.of_node, - "qcom,wsa-max-devs", &wsa_max_devs); - if (ret) { - dev_err(&pdev->dev, - "%s: wsa-max-devs property missing in DT %s, ret = %d\n", - __func__, pdev->dev.of_node->full_name, ret); - wsa_max_devs = 0; - goto codec_aux_dev; - } - if (wsa_max_devs == 0) { - dev_dbg(&pdev->dev, - "%s: Max WSA devices is 0 for this target?\n", - __func__); - goto codec_aux_dev; - } - - /* Get count of WSA device phandles for this platform */ - wsa_dev_cnt = of_count_phandle_with_args(pdev->dev.of_node, - "qcom,wsa-devs", NULL); - if (wsa_dev_cnt == -ENOENT) { - dev_warn(&pdev->dev, "%s: No wsa device defined in DT.\n", - __func__); - goto err; - } else if (wsa_dev_cnt <= 0) { - dev_err(&pdev->dev, - "%s: Error reading wsa device from DT. wsa_dev_cnt = %d\n", - __func__, wsa_dev_cnt); - ret = -EINVAL; - goto err; - } - - /* - * Expect total phandles count to be NOT less than maximum possible - * WSA count. However, if it is less, then assign same value to - * max count as well. - */ - if (wsa_dev_cnt < wsa_max_devs) { - dev_dbg(&pdev->dev, - "%s: wsa_max_devs = %d cannot exceed wsa_dev_cnt = %d\n", - __func__, wsa_max_devs, wsa_dev_cnt); - wsa_max_devs = wsa_dev_cnt; - } - - /* Make sure prefix string passed for each WSA device */ - ret = of_property_count_strings(pdev->dev.of_node, - "qcom,wsa-aux-dev-prefix"); - if (ret != wsa_dev_cnt) { - dev_err(&pdev->dev, - "%s: expecting %d wsa prefix. Defined only %d in DT\n", - __func__, wsa_dev_cnt, ret); - ret = -EINVAL; - goto err; - } - - /* - * Alloc mem to store phandle and index info of WSA device, if already - * registered with ALSA core - */ - wsa881x_dev_info = devm_kcalloc(&pdev->dev, wsa_max_devs, - sizeof(struct msm_wsa881x_dev_info), - GFP_KERNEL); - if (!wsa881x_dev_info) { - ret = -ENOMEM; - goto err; - } - - /* - * search and check whether all WSA devices are already - * registered with ALSA core or not. If found a node, store - * the node and the index in a local array of struct for later - * use. - */ - for (i = 0; i < wsa_dev_cnt; i++) { - wsa_of_node = of_parse_phandle(pdev->dev.of_node, - "qcom,wsa-devs", i); - if (unlikely(!wsa_of_node)) { - /* we should not be here */ - dev_err(&pdev->dev, - "%s: wsa dev node is not present\n", - __func__); - ret = -EINVAL; - goto err; - } - if (soc_find_component_locked(wsa_of_node, NULL)) { - /* WSA device registered with ALSA core */ - wsa881x_dev_info[found].of_node = wsa_of_node; - wsa881x_dev_info[found].index = i; - found++; - if (found == wsa_max_devs) - break; - } - } - - if (found < wsa_max_devs) { - dev_dbg(&pdev->dev, - "%s: failed to find %d components. Found only %d\n", - __func__, wsa_max_devs, found); - return -EPROBE_DEFER; - } - dev_info(&pdev->dev, - "%s: found %d wsa881x devices registered with ALSA core\n", - __func__, found); - -codec_aux_dev: - if (!strnstr(card->name, "tavil", strlen(card->name)) && - !strnstr(card->name, "tasha", strlen(card->name))) { - /* Get maximum aux codec device count for this platform */ - ret = of_property_read_u32(pdev->dev.of_node, - "qcom,codec-max-aux-devs", - &codec_max_aux_devs); - if (ret) { - dev_err(&pdev->dev, - "%s: codec-max-aux-devs property missing in DT %s, ret = %d\n", - __func__, pdev->dev.of_node->full_name, ret); - codec_max_aux_devs = 0; - goto aux_dev_register; - } - if (codec_max_aux_devs == 0) { - dev_dbg(&pdev->dev, - "%s: Max aux codec devices is 0 for this target?\n", - __func__); - goto aux_dev_register; - } - - /* Get count of aux codec device phandles for this platform */ - codec_aux_dev_cnt = of_count_phandle_with_args( - pdev->dev.of_node, - "qcom,codec-aux-devs", NULL); - if (codec_aux_dev_cnt == -ENOENT) { - dev_warn(&pdev->dev, "%s: No aux codec defined in DT.\n", - __func__); - goto err; - } else if (codec_aux_dev_cnt <= 0) { - dev_err(&pdev->dev, - "%s: Error reading aux codec device from DT, dev_cnt=%d\n", - __func__, codec_aux_dev_cnt); - ret = -EINVAL; - goto err; - } - - /* - * Expect total phandles count to be NOT less than maximum possible - * AUX device count. However, if it is less, then assign same value to - * max count as well. - */ - if (codec_aux_dev_cnt < codec_max_aux_devs) { - dev_dbg(&pdev->dev, - "%s: codec_max_aux_devs = %d cannot exceed codec_aux_dev_cnt = %d\n", - __func__, codec_max_aux_devs, - codec_aux_dev_cnt); - codec_max_aux_devs = codec_aux_dev_cnt; - } - - /* - * Alloc mem to store phandle and index info of aux codec - * if already registered with ALSA core - */ - aux_cdc_dev_info = devm_kcalloc(&pdev->dev, codec_max_aux_devs, - sizeof(struct aux_codec_dev_info), - GFP_KERNEL); - if (!aux_cdc_dev_info) { - ret = -ENOMEM; - goto err; - } - - /* - * search and check whether all aux codecs are already - * registered with ALSA core or not. If found a node, store - * the node and the index in a local array of struct for later - * use. - */ - for (i = 0; i < codec_aux_dev_cnt; i++) { - aux_codec_of_node = of_parse_phandle(pdev->dev.of_node, - "qcom,codec-aux-devs", i); - if (unlikely(!aux_codec_of_node)) { - /* we should not be here */ - dev_err(&pdev->dev, - "%s: aux codec dev node is not present\n", - __func__); - ret = -EINVAL; - goto err; - } - if (soc_find_component_locked(aux_codec_of_node, NULL)) { - /* AUX codec registered with ALSA core */ - aux_cdc_dev_info[codecs_found].of_node = - aux_codec_of_node; - aux_cdc_dev_info[codecs_found].index = i; - codecs_found++; - } - } - - if (codecs_found < codec_max_aux_devs) { - dev_dbg(&pdev->dev, - "%s: failed to find %d components. Found only %d\n", - __func__, codec_max_aux_devs, codecs_found); - return -EPROBE_DEFER; - } - dev_info(&pdev->dev, - "%s: found %d AUX codecs registered with ALSA core\n", - __func__, codecs_found); - - } - -aux_dev_register: - card->num_aux_devs = wsa_max_devs + codec_max_aux_devs; - card->num_configs = wsa_max_devs + codec_max_aux_devs; - - /* Alloc array of AUX devs struct */ - msm_aux_dev = devm_kcalloc(&pdev->dev, card->num_aux_devs, - sizeof(struct snd_soc_aux_dev), - GFP_KERNEL); - if (!msm_aux_dev) { - ret = -ENOMEM; - goto err; - } - - /* Alloc array of codec conf struct */ - msm_codec_conf = devm_kcalloc(&pdev->dev, card->num_configs, - sizeof(struct snd_soc_codec_conf), - GFP_KERNEL); - if (!msm_codec_conf) { - ret = -ENOMEM; - goto err; - } - - for (i = 0; i < wsa_max_devs; i++) { - dev_name_str = devm_kzalloc(&pdev->dev, DEV_NAME_STR_LEN, - GFP_KERNEL); - if (!dev_name_str) { - ret = -ENOMEM; - goto err; - } - - ret = of_property_read_string_index(pdev->dev.of_node, - "qcom,wsa-aux-dev-prefix", - wsa881x_dev_info[i].index, - auxdev_name_prefix); - if (ret) { - dev_err(&pdev->dev, - "%s: failed to read wsa aux dev prefix, ret = %d\n", - __func__, ret); - ret = -EINVAL; - goto err; - } - - snprintf(dev_name_str, strlen("wsa881x.%d"), "wsa881x.%d", i); - msm_aux_dev[i].name = dev_name_str; - msm_aux_dev[i].codec_name = NULL; - msm_aux_dev[i].codec_of_node = - wsa881x_dev_info[i].of_node; - msm_aux_dev[i].init = msm_wsa881x_init; - msm_codec_conf[i].dev_name = NULL; - msm_codec_conf[i].name_prefix = auxdev_name_prefix[0]; - msm_codec_conf[i].of_node = - wsa881x_dev_info[i].of_node; - } - - for (i = 0; i < codec_aux_dev_cnt; i++) { - msm_aux_dev[wsa_max_devs + i].name = "aux_codec"; - msm_aux_dev[wsa_max_devs + i].codec_name = NULL; - msm_aux_dev[wsa_max_devs + i].codec_of_node = - aux_cdc_dev_info[i].of_node; - msm_aux_dev[wsa_max_devs + i].init = msm_aux_codec_init; - msm_codec_conf[wsa_max_devs + i].dev_name = NULL; - msm_codec_conf[wsa_max_devs + i].name_prefix = - NULL; - msm_codec_conf[wsa_max_devs + i].of_node = - aux_cdc_dev_info[i].of_node; - } - - card->codec_conf = msm_codec_conf; - card->aux_dev = msm_aux_dev; -err: - return ret; -} - static void msm_i2s_auxpcm_init(struct platform_device *pdev) { int count; @@ -9020,7 +8331,9 @@ static int sm6150_ssr_enable(struct device *dev, void *data) pdata->is_afe_config_done = true; } } +#if IS_ENABLED(CONFIG_AUDIO_QGKI) snd_soc_card_change_online_state(card, 1); +#endif /* CONFIG_AUDIO_QGKI */ dev_dbg(dev, "%s: setting snd_card to ONLINE\n", __func__); err: @@ -9039,7 +8352,9 @@ static void sm6150_ssr_disable(struct device *dev, void *data) } dev_dbg(dev, "%s: setting snd_card to OFFLINE\n", __func__); +#if IS_ENABLED(CONFIG_AUDIO_QGKI) snd_soc_card_change_online_state(card, 0); +#endif /* CONFIG_AUDIO_QGKI */ if (strnstr(card->name, "tavil", strlen(card->name)) || strnstr(card->name, "tasha", strlen(card->name))) { @@ -9161,9 +8476,16 @@ static int msm_asoc_machine_probe(struct platform_device *pdev) goto err; } - ret = msm_init_aux_dev(pdev, card); - if (ret) - goto err; + /* Get maximum WSA device count for this platform */ + ret = of_property_read_u32(pdev->dev.of_node, + "qcom,wsa-max-devs", &pdata->wsa_max_devs); + if (ret) { + dev_info(&pdev->dev, + "%s: wsa-max-devs property missing in DT %s, ret = %d\n", + __func__, pdev->dev.of_node->full_name, ret); + pdata->wsa_max_devs = 0; + } + ret = devm_snd_soc_register_card(&pdev->dev, card); if (ret == -EPROBE_DEFER) { @@ -9306,18 +8628,7 @@ static struct platform_driver sm6150_asoc_machine_driver = { .probe = msm_asoc_machine_probe, .remove = msm_asoc_machine_remove, }; - -int __init sm6150_init(void) -{ - pr_debug("%s\n", __func__); - return platform_driver_register(&sm6150_asoc_machine_driver); -} - -void sm6150_exit(void) -{ - pr_debug("%s\n", __func__); - platform_driver_unregister(&sm6150_asoc_machine_driver); -} +module_platform_driver(sm6150_asoc_machine_driver); MODULE_DESCRIPTION("ALSA SoC SM6150 Machine driver"); MODULE_LICENSE("GPL v2"); From 374b84c9b5f33f2f4ee71ee93ade357abdf3cc7f Mon Sep 17 00:00:00 2001 From: Shuai Zhang Date: Mon, 7 Mar 2022 14:10:56 +0530 Subject: [PATCH 64/82] ASOC: update wcd934x codec driver Compile wcd934x driver for sm6150. Change-Id: Ia0f41d6f1de03ec41cddb0bc1cef5d62ac815cdf --- asoc/codecs/Kbuild | 1 + asoc/codecs/wcd934x/wcd934x.c | 30 ++++++++++++++++++++++++++++++ asoc/codecs/wcd934x/wcd934x.h | 8 ++++++++ 3 files changed, 39 insertions(+) diff --git a/asoc/codecs/Kbuild b/asoc/codecs/Kbuild index 52d20d667a20..0e842ee1bf6c 100755 --- a/asoc/codecs/Kbuild +++ b/asoc/codecs/Kbuild @@ -147,6 +147,7 @@ ifdef CONFIG_WCD9XXX_CODEC_CORE WCD9XXX_OBJS += wcd9xxx-resmgr-v2.o WCD9XXX_OBJS += wcd-dsp-utils.o WCD9XXX_OBJS += wcd-dsp-mgr.o + WCD9XXX_OBJS += wcd-clsh.o else WCD9XXX_OBJS += wcd-clsh.o endif diff --git a/asoc/codecs/wcd934x/wcd934x.c b/asoc/codecs/wcd934x/wcd934x.c index 3a43485a7356..80923135bee3 100644 --- a/asoc/codecs/wcd934x/wcd934x.c +++ b/asoc/codecs/wcd934x/wcd934x.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2015-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include #include @@ -21,6 +22,7 @@ #include #include #include