From c315833fa37b59bfd73a23fba0388b430f222ebc Mon Sep 17 00:00:00 2001 From: Srinivas Marka Date: Thu, 19 Aug 2021 19:08:17 +0530 Subject: [PATCH] asoc: set card state to online after snd card registration AGM might get initialized before sound card is populated with all pcm nodes. This will lead to AGM parsing fewer nodes and forms incomplete list of backends. To avoid this, kernel module sets card status to ONLINE, and AGM waits till the card status is ONLINE before parsing for the pcm nodes. Change-Id: I4b7f7085645706ba4351efe23ba048d3a177312c Signed-off-by: Srinivas Marka --- asoc/msm_common.c | 8 +++++++- asoc/msm_common.h | 8 +++++++- asoc/waipio.c | 8 ++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/asoc/msm_common.c b/asoc/msm_common.c index 438a5f3c1e..0b8dc89085 100644 --- a/asoc/msm_common.c +++ b/asoc/msm_common.c @@ -150,13 +150,19 @@ done: return ret; } -int snd_card_notify_user(int card_status) +int snd_card_notify_user(snd_card_status_t card_status) { snd_card_pdata->card_status = card_status; sysfs_notify(&snd_card_pdata->snd_card_kobj, NULL, "card_state"); return 0; } +int snd_card_set_card_status(snd_card_status_t card_status) +{ + snd_card_pdata->card_status = card_status; + return 0; +} + static ssize_t snd_card_sysfs_show(struct kobject *kobj, struct attribute *attr, char *buf) { diff --git a/asoc/msm_common.h b/asoc/msm_common.h index 2df9193f95..d3ef08dc9a 100644 --- a/asoc/msm_common.h +++ b/asoc/msm_common.h @@ -31,6 +31,11 @@ enum { MI2S_TDM_AUXPCM_MAX, }; +typedef enum snd_card_status_t { + SND_CARD_STATUS_OFFLINE = 0, + SND_CARD_STATUS_ONLINE = 1, +} snd_card_status_t; + struct msm_common_pdata { uint8_t *aud_dev_state; struct kobject aud_dev_kobj; @@ -46,7 +51,8 @@ struct msm_common_pdata { uint32_t is_audio_hw_vote_required[MI2S_TDM_AUXPCM_MAX]; }; -int snd_card_notify_user(int card_status); +int snd_card_notify_user(snd_card_status_t card_status); +int snd_card_set_card_status(snd_card_status_t card_status); struct msm_common_pdata *msm_common_get_pdata(struct snd_soc_card *card); void msm_common_set_pdata(struct snd_soc_card *card, diff --git a/asoc/waipio.c b/asoc/waipio.c index a295563ad0..30b4fb7496 100644 --- a/asoc/waipio.c +++ b/asoc/waipio.c @@ -1505,7 +1505,7 @@ static int waipio_ssr_enable(struct device *dev, void *data) dev_dbg(dev, "%s: TODO \n", __func__); } - snd_card_notify_user(1); + snd_card_notify_user(SND_CARD_STATUS_ONLINE); dev_dbg(dev, "%s: setting snd_card to ONLINE\n", __func__); err: @@ -1523,7 +1523,7 @@ static void waipio_ssr_disable(struct device *dev, void *data) } dev_dbg(dev, "%s: setting snd_card to OFFLINE\n", __func__); - snd_card_notify_user(0); + snd_card_notify_user(SND_CARD_STATUS_OFFLINE); if (!strcmp(card->name, "waipio-stub-snd-card")) { /* TODO */ @@ -1713,6 +1713,10 @@ static int msm_asoc_machine_probe(struct platform_device *pdev) /* Add QoS request for audio tasks */ msm_audio_add_qos_request(); + /* change card status to ONLINE */ + dev_dbg(&pdev->dev, "%s: setting snd_card to ONLINE\n", __func__); + snd_card_set_card_status(SND_CARD_STATUS_ONLINE); + return 0; err: devm_kfree(&pdev->dev, pdata);