From c8073dc181b56e5bd03b5df2937958dd6d052f92 Mon Sep 17 00:00:00 2001 From: "Yoon (Seungyoon) Lee" Date: Wed, 1 Aug 2018 11:08:41 -0500 Subject: [PATCH] ASoC: madera: report QDSP/LPASS SSR to soundcard Cirrus madera codecs don't have a mechanism to report QDSP/LPASS SSR to AP over soundcard status change. Add logic to reflect LPASS status to soundcard, so AudioHAL can monitor and trigger necessary code on SSR. Change-Id: I93de60b97b8baea0dc6b7cea0fee1f7a4f9219d1 Signed-off-by: Yoon (Seungyoon) Lee Reviewed-on: https://gerrit.mot.com/1219154 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Rav(CR) Vembu Submit-Approved: Jira Key Reviewed-by: Konstantin Makariev --- sound/soc/codecs/madera-slimbus.c | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/sound/soc/codecs/madera-slimbus.c b/sound/soc/codecs/madera-slimbus.c index 15cc39b78bf2..737b1aec6e21 100644 --- a/sound/soc/codecs/madera-slimbus.c +++ b/sound/soc/codecs/madera-slimbus.c @@ -315,6 +315,15 @@ int madera_set_channel_map(struct snd_soc_dai *dai, return -EINVAL; } + /* + * same reason with stashed_slim_dev, there is no clever way to link + * codec and slimbus driver on madera based platform. whenever codec + * calls slimbus driver, it will keep its client codec pointer and use + * it as a bridge to call codec related functions. + */ + if (dai->codec != NULL) + slim_set_clientdata(stashed_slim_dev, dai->codec); + if (!priv->slim_logic_addr) { madera_slim_get_la(stashed_slim_dev, &laddr); priv->slim_logic_addr = laddr; @@ -468,6 +477,38 @@ static int madera_slim_audio_probe(struct slim_device *slim) return 0; } +static int madera_slim_device_reset(struct slim_device *slim) +{ + struct snd_soc_codec *codec; + + if (slim == NULL) + return -EINVAL; + + codec = slim_get_devicedata(slim); + if (codec != NULL) { + dev_info(&slim->dev, "%s handle SLIM RESET\n", __func__); + snd_soc_card_change_online_state(codec->component.card, 1); + } + + return 0; +} + +static int madera_slim_device_down(struct slim_device *slim) +{ + struct snd_soc_codec *codec; + + if (slim == NULL) + return -EINVAL; + + codec = slim_get_devicedata(slim); + if (codec != NULL) { + dev_info(&slim->dev, "%s handle SLIM DOWN\n", __func__); + snd_soc_card_change_online_state(codec->component.card, 0); + } + + return 0; +} + static struct slim_driver madera_slim_audio = { .driver = { .name = "madera-slim-audio", @@ -475,6 +516,8 @@ static struct slim_driver madera_slim_audio = { }, .probe = madera_slim_audio_probe, .id_table = madera_slim_id, + .reset_device = madera_slim_device_reset, + .device_down = madera_slim_device_down, }; static int __init madera_slim_audio_init(void)