asoc: wcd9335: Add support for SSR handling using SND event fwk
Add support for SSR/PDR handling using SND event framework in tasha codec. Change-Id: Ief0bc7dc62d83635fdc905f1f385571e0e4b3190 Signed-off-by: Aditya Bavanari <abavanar@codeaurora.org>
This commit is contained in:
parent
256a85678f
commit
baab9b123f
@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
|
* Copyright (c) 2015-2019, The Linux Foundation. All rights reserved.
|
||||||
*/
|
*/
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
@ -22,6 +22,7 @@
|
|||||||
#include <linux/gpio.h>
|
#include <linux/gpio.h>
|
||||||
#include <linux/mfd/wcd9xxx/wcd9xxx_registers.h>
|
#include <linux/mfd/wcd9xxx/wcd9xxx_registers.h>
|
||||||
#include <soc/swr-wcd.h>
|
#include <soc/swr-wcd.h>
|
||||||
|
#include <soc/snd_event.h>
|
||||||
#include <sound/pcm.h>
|
#include <sound/pcm.h>
|
||||||
#include <sound/pcm_params.h>
|
#include <sound/pcm_params.h>
|
||||||
#include <sound/soc.h>
|
#include <sound/soc.h>
|
||||||
@ -13708,11 +13709,23 @@ static int tasha_device_down(struct wcd9xxx *wcd9xxx)
|
|||||||
|
|
||||||
component = (struct snd_soc_component *)(wcd9xxx->ssr_priv);
|
component = (struct snd_soc_component *)(wcd9xxx->ssr_priv);
|
||||||
priv = snd_soc_component_get_drvdata(component);
|
priv = snd_soc_component_get_drvdata(component);
|
||||||
|
snd_event_notify(priv->dev->parent, SND_EVENT_DOWN);
|
||||||
wcd_cpe_ssr_event(priv->cpe_core, WCD_CPE_BUS_DOWN_EVENT);
|
wcd_cpe_ssr_event(priv->cpe_core, WCD_CPE_BUS_DOWN_EVENT);
|
||||||
for (i = 0; i < priv->nr; i++)
|
|
||||||
|
if (!priv->swr_ctrl_data)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
for (i = 0; i < priv->nr; i++) {
|
||||||
|
if (is_snd_event_fwk_enabled())
|
||||||
|
swrm_wcd_notify(
|
||||||
|
priv->swr_ctrl_data[i].swr_pdev,
|
||||||
|
SWR_DEVICE_SSR_DOWN, NULL);
|
||||||
swrm_wcd_notify(priv->swr_ctrl_data[i].swr_pdev,
|
swrm_wcd_notify(priv->swr_ctrl_data[i].swr_pdev,
|
||||||
SWR_DEVICE_DOWN, NULL);
|
SWR_DEVICE_DOWN, NULL);
|
||||||
snd_soc_card_change_online_state(component->card, 0);
|
}
|
||||||
|
|
||||||
|
if (!is_snd_event_fwk_enabled())
|
||||||
|
snd_soc_card_change_online_state(component->card, 0);
|
||||||
for (count = 0; count < NUM_CODEC_DAIS; count++)
|
for (count = 0; count < NUM_CODEC_DAIS; count++)
|
||||||
priv->dai[count].bus_down_in_recovery = true;
|
priv->dai[count].bus_down_in_recovery = true;
|
||||||
|
|
||||||
@ -13747,7 +13760,8 @@ static int tasha_post_reset_cb(struct wcd9xxx *wcd9xxx)
|
|||||||
if (tasha->machine_codec_event_cb)
|
if (tasha->machine_codec_event_cb)
|
||||||
tasha->machine_codec_event_cb(component,
|
tasha->machine_codec_event_cb(component,
|
||||||
WCD9335_CODEC_EVENT_CODEC_UP);
|
WCD9335_CODEC_EVENT_CODEC_UP);
|
||||||
snd_soc_card_change_online_state(component->card, 1);
|
if (!is_snd_event_fwk_enabled())
|
||||||
|
snd_soc_card_change_online_state(component->card, 1);
|
||||||
|
|
||||||
/* Class-H Init*/
|
/* Class-H Init*/
|
||||||
wcd_clsh_init(&tasha->clsh_d);
|
wcd_clsh_init(&tasha->clsh_d);
|
||||||
@ -13807,9 +13821,21 @@ static int tasha_post_reset_cb(struct wcd9xxx *wcd9xxx)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!tasha->swr_ctrl_data) {
|
||||||
|
ret = -EINVAL;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_snd_event_fwk_enabled()) {
|
||||||
|
for (i = 0; i < tasha->nr; i++)
|
||||||
|
swrm_wcd_notify(
|
||||||
|
tasha->swr_ctrl_data[i].swr_pdev,
|
||||||
|
SWR_DEVICE_SSR_UP, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
tasha_set_spkr_mode(component, tasha->spkr_mode);
|
tasha_set_spkr_mode(component, tasha->spkr_mode);
|
||||||
wcd_cpe_ssr_event(tasha->cpe_core, WCD_CPE_BUS_UP_EVENT);
|
wcd_cpe_ssr_event(tasha->cpe_core, WCD_CPE_BUS_UP_EVENT);
|
||||||
|
snd_event_notify(tasha->dev->parent, SND_EVENT_UP);
|
||||||
err:
|
err:
|
||||||
mutex_unlock(&tasha->codec_mutex);
|
mutex_unlock(&tasha->codec_mutex);
|
||||||
return ret;
|
return ret;
|
||||||
@ -13835,6 +13861,28 @@ static struct regulator *tasha_codec_find_ondemand_regulator(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void tasha_ssr_disable(struct device *dev, void *data)
|
||||||
|
{
|
||||||
|
struct wcd9xxx *wcd9xxx = dev_get_drvdata(dev);
|
||||||
|
struct tasha_priv *tasha;
|
||||||
|
struct snd_soc_component *component;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
if (!wcd9xxx) {
|
||||||
|
dev_dbg(dev, "%s: wcd9xxx pointer NULL.\n", __func__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
component = (struct snd_soc_component *)(wcd9xxx->ssr_priv);
|
||||||
|
tasha = snd_soc_component_get_drvdata(component);
|
||||||
|
|
||||||
|
for (count = 0; count < NUM_CODEC_DAIS; count++)
|
||||||
|
tasha->dai[count].bus_down_in_recovery = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct snd_event_ops tasha_ssr_ops = {
|
||||||
|
.disable = tasha_ssr_disable,
|
||||||
|
};
|
||||||
|
|
||||||
static int tasha_codec_probe(struct snd_soc_component *component)
|
static int tasha_codec_probe(struct snd_soc_component *component)
|
||||||
{
|
{
|
||||||
struct wcd9xxx *control;
|
struct wcd9xxx *control;
|
||||||
@ -14654,6 +14702,14 @@ static int tasha_probe(struct platform_device *pdev)
|
|||||||
tasha_update_reg_defaults(tasha);
|
tasha_update_reg_defaults(tasha);
|
||||||
schedule_work(&tasha->tasha_add_child_devices_work);
|
schedule_work(&tasha->tasha_add_child_devices_work);
|
||||||
tasha_get_codec_ver(tasha);
|
tasha_get_codec_ver(tasha);
|
||||||
|
ret = snd_event_client_register(pdev->dev.parent, &tasha_ssr_ops, NULL);
|
||||||
|
if (!ret) {
|
||||||
|
snd_event_notify(pdev->dev.parent, SND_EVENT_UP);
|
||||||
|
} else {
|
||||||
|
pr_err("%s: Registration with SND event fwk failed ret = %d\n",
|
||||||
|
__func__, ret);
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
|
||||||
dev_info(&pdev->dev, "%s: Tasha driver probe done\n", __func__);
|
dev_info(&pdev->dev, "%s: Tasha driver probe done\n", __func__);
|
||||||
return ret;
|
return ret;
|
||||||
@ -14682,6 +14738,7 @@ static int tasha_remove(struct platform_device *pdev)
|
|||||||
if (!tasha)
|
if (!tasha)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
snd_event_client_deregister(pdev->dev.parent);
|
||||||
for (count = 0; count < tasha->child_count &&
|
for (count = 0; count < tasha->child_count &&
|
||||||
count < WCD9335_CHILD_DEVICES_MAX; count++)
|
count < WCD9335_CHILD_DEVICES_MAX; count++)
|
||||||
platform_device_unregister(tasha->pdev_child_devices[count]);
|
platform_device_unregister(tasha->pdev_child_devices[count]);
|
||||||
|
Loading…
Reference in New Issue
Block a user