From be581c2cec81baf613ae8cd1e8cd7e429f3dcc16 Mon Sep 17 00:00:00 2001 From: Laxminath Kasam Date: Thu, 23 Apr 2020 17:32:17 +0530 Subject: [PATCH] asoc: wsa883x: Fix speaker noise issue Soundwire port is misconfigured and causing noise issue randomly. Ensure reset and powerup WSA speaker amp for every usecase. Change-Id: I857ff2939900ab60ec7208554e340d7d2c693fa9 Signed-off-by: Laxminath Kasam --- asoc/codecs/wsa883x/wsa883x.c | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/asoc/codecs/wsa883x/wsa883x.c b/asoc/codecs/wsa883x/wsa883x.c index 1c735189d45e..a2dbea65f9ec 100644 --- a/asoc/codecs/wsa883x/wsa883x.c +++ b/asoc/codecs/wsa883x/wsa883x.c @@ -1264,6 +1264,19 @@ static int wsa883x_swr_up(struct wsa883x_priv *wsa883x) return ret; } +static int wsa883x_swr_device_up(struct swr_device *pdev) +{ + struct wsa883x_priv *wsa883x; + + wsa883x = swr_get_dev_data(pdev); + if (!wsa883x) { + dev_err(&pdev->dev, "%s: wsa883x is NULL\n", __func__); + return -EINVAL; + } + wsa883x_swr_up(wsa883x); + return 0; +} + static int wsa883x_swr_down(struct wsa883x_priv *wsa883x) { int ret; @@ -1275,6 +1288,19 @@ static int wsa883x_swr_down(struct wsa883x_priv *wsa883x) return ret; } +static int wsa883x_swr_device_down(struct swr_device *pdev) +{ + struct wsa883x_priv *wsa883x; + + wsa883x = swr_get_dev_data(pdev); + if (!wsa883x) { + dev_err(&pdev->dev, "%s: wsa883x is NULL\n", __func__); + return -EINVAL; + } + wsa883x_swr_down(wsa883x); + return 0; +} + static int wsa883x_swr_reset(struct wsa883x_priv *wsa883x) { u8 retry = WSA883X_NUM_RETRY; @@ -1292,6 +1318,19 @@ static int wsa883x_swr_reset(struct wsa883x_priv *wsa883x) return 0; } +static int wsa883x_swr_device_reset(struct swr_device *pdev) +{ + struct wsa883x_priv *wsa883x; + + wsa883x = swr_get_dev_data(pdev); + if (!wsa883x) { + dev_err(&pdev->dev, "%s: wsa883x is NULL\n", __func__); + return -EINVAL; + } + wsa883x_swr_reset(wsa883x); + return 0; +} + static int wsa883x_event_notify(struct notifier_block *nb, unsigned long val, void *ptr) { @@ -1670,6 +1709,9 @@ static struct swr_driver wsa883x_swr_driver = { .probe = wsa883x_swr_probe, .remove = wsa883x_swr_remove, .id_table = wsa883x_swr_id, + .device_up = wsa883x_swr_device_up, + .device_down = wsa883x_swr_device_down, + .reset_device = wsa883x_swr_device_reset, }; static int __init wsa883x_swr_init(void)