diff options
author | Bhalchandra Gajare <gajare@codeaurora.org> | 2017-01-26 16:36:11 -0800 |
---|---|---|
committer | Bhalchandra Gajare <gajare@codeaurora.org> | 2017-01-30 18:00:06 -0800 |
commit | 896e0b12acfbcf071032e4b35091d87e1dd4f17f (patch) | |
tree | 6e5880791e0cff500c14682ff6e78e09e3e583c1 | |
parent | 314869eb56763d34f91d5483b0d510267894fadd (diff) |
ASoC: wcd-dsp-mgr: add suspend and resume functionality
Currently, the suspend and resume routines for the wcd dsp manager
driver are not implemented, which causes race conditions when the
components suspend or resume out of order. Implement the suspend/
resume functionality and route the events to the components in
the expected sequence.
CRs-Fixed: 1111863
Change-Id: Ie84cdef5ed7ffd61610cd83e5f627427f85bc125
Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
-rw-r--r-- | sound/soc/codecs/wcd-dsp-mgr.c | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/sound/soc/codecs/wcd-dsp-mgr.c b/sound/soc/codecs/wcd-dsp-mgr.c index f51301d1ab08..71a2052f1089 100644 --- a/sound/soc/codecs/wcd-dsp-mgr.c +++ b/sound/soc/codecs/wcd-dsp-mgr.c @@ -1,5 +1,4 @@ -/* - * Copyright (c) 2016, The Linux Foundation. All rights reserved. +/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -881,12 +880,50 @@ done: static int wdsp_suspend(struct device *wdsp_dev) { - return 0; + struct wdsp_mgr_priv *wdsp; + int rc = 0, i; + + if (!wdsp_dev) { + pr_err("%s: Invalid handle to device\n", __func__); + return -EINVAL; + } + + wdsp = dev_get_drvdata(wdsp_dev); + + for (i = WDSP_CMPNT_TYPE_MAX - 1; i >= 0; i--) { + rc = wdsp_unicast_event(wdsp, i, WDSP_EVENT_SUSPEND, NULL); + if (rc < 0) { + WDSP_ERR(wdsp, "component %s failed to suspend\n", + WDSP_GET_CMPNT_TYPE_STR(i)); + break; + } + } + + return rc; } static int wdsp_resume(struct device *wdsp_dev) { - return 0; + struct wdsp_mgr_priv *wdsp; + int rc = 0, i; + + if (!wdsp_dev) { + pr_err("%s: Invalid handle to device\n", __func__); + return -EINVAL; + } + + wdsp = dev_get_drvdata(wdsp_dev); + + for (i = 0; i < WDSP_CMPNT_TYPE_MAX; i++) { + rc = wdsp_unicast_event(wdsp, i, WDSP_EVENT_RESUME, NULL); + if (rc < 0) { + WDSP_ERR(wdsp, "component %s failed to resume\n", + WDSP_GET_CMPNT_TYPE_STR(i)); + break; + } + } + + return rc; } static struct wdsp_mgr_ops wdsp_ops = { |