soc: soundwire: Add support to listen for DC detection

Add support to listen for DC detection event.
Shutdown WSA on receiving DC detection event.

CRs-Fixed: 2244131
Change-Id: Ifecab8bb9862976a647a161bad4c202b6e6459c7
Signed-off-by: Vignesh Kulothungan <vigneshk@codeaurora.org>
此提交包含在:
Vignesh Kulothungan
2018-05-09 17:41:11 -07:00
提交者 Gerrit - the friendly Code Review server
父節點 94bd8731ae
當前提交 9ca8dc327c
共有 2 個檔案被更改,包括 35 行新增0 行删除

查看文件

@@ -26,6 +26,7 @@
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <soc/soundwire.h> #include <soc/soundwire.h>
#include <soc/swr-wcd.h> #include <soc/swr-wcd.h>
#include <dsp/msm-audio-event-notify.h>
#include "swrm_registers.h" #include "swrm_registers.h"
#include "swr-wcd-ctrl.h" #include "swr-wcd-ctrl.h"
@@ -1393,6 +1394,32 @@ static int swrm_master_init(struct swr_mstr_ctrl *swrm)
return ret; return ret;
} }
static int swrm_event_notify(struct notifier_block *self,
unsigned long action, void *data)
{
struct swr_mstr_ctrl *swrm = container_of(self, struct swr_mstr_ctrl,
event_notifier);
if (!swrm || !swrm->pdev) {
pr_err("%s: swrm or pdev is NULL\n", __func__);
return -EINVAL;
}
if (action != MSM_AUD_DC_EVENT) {
dev_err(&swrm->pdev->dev, "%s: invalid event type: %lu\n", __func__, action);
return -EINVAL;
}
schedule_work(&(swrm->dc_presence_work));
return 0;
}
static void swrm_notify_work_fn(struct work_struct *work)
{
struct swr_mstr_ctrl *swrm = container_of(work, struct swr_mstr_ctrl,
dc_presence_work);
swrm_wcd_notify(swrm->pdev, SWR_DEVICE_DOWN, NULL);
}
static int swrm_probe(struct platform_device *pdev) static int swrm_probe(struct platform_device *pdev)
{ {
struct swr_mstr_ctrl *swrm; struct swr_mstr_ctrl *swrm;
@@ -1553,6 +1580,10 @@ static int swrm_probe(struct platform_device *pdev)
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
pm_runtime_mark_last_busy(&pdev->dev); pm_runtime_mark_last_busy(&pdev->dev);
INIT_WORK(&swrm->dc_presence_work, swrm_notify_work_fn);
swrm->event_notifier.notifier_call = swrm_event_notify;
msm_aud_evt_register_client(&swrm->event_notifier);
return 0; return 0;
err_mstr_fail: err_mstr_fail:
swrm->reg_irq(swrm->handle, swr_mstr_interrupt, swrm->reg_irq(swrm->handle, swr_mstr_interrupt,
@@ -1583,6 +1614,7 @@ static int swrm_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
pm_runtime_set_suspended(&pdev->dev); pm_runtime_set_suspended(&pdev->dev);
swr_unregister_master(&swrm->master); swr_unregister_master(&swrm->master);
msm_aud_evt_unregister_client(&swrm->event_notifier);
mutex_destroy(&swrm->mlock); mutex_destroy(&swrm->mlock);
mutex_destroy(&swrm->reslock); mutex_destroy(&swrm->reslock);
mutex_destroy(&swrm->force_down_lock); mutex_destroy(&swrm->force_down_lock);

查看文件

@@ -108,6 +108,9 @@ struct swr_mstr_ctrl {
u8 num_cfg_devs; u8 num_cfg_devs;
struct mutex force_down_lock; struct mutex force_down_lock;
int force_down_state; int force_down_state;
struct notifier_block event_notifier;
struct work_struct dc_presence_work;
}; };
#endif /* _SWR_WCD_CTRL_H */ #endif /* _SWR_WCD_CTRL_H */