From patchwork Wed Feb 14 04:06:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhijeet Kumar X-Patchwork-Id: 10218017 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7BA1A60467 for ; Wed, 14 Feb 2018 03:58:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65F59289E1 for ; Wed, 14 Feb 2018 03:58:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 592DA289FD; Wed, 14 Feb 2018 03:58:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 64111289E1 for ; Wed, 14 Feb 2018 03:58:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5A59F89FED; Wed, 14 Feb 2018 03:58:27 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 39C3789FED for ; Wed, 14 Feb 2018 03:58:25 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Feb 2018 19:58:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,510,1511856000"; d="scan'208";a="19841203" Received: from intel-h97m-d3h.iind.intel.com ([10.66.247.169]) by fmsmga002.fm.intel.com with ESMTP; 13 Feb 2018 19:58:23 -0800 From: abhijeet.kumar@intel.com To: intel-gfx@lists.freedesktop.org, chris@chris-wilson.co.uk, abhijeet.kumar@intel.com Date: Wed, 14 Feb 2018 09:36:30 +0530 Message-Id: <1518581192-26400-1-git-send-email-abhijeet.kumar@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <20180213192918.26331-2-chris@chris-wilson.co.uk> References: <20180213192918.26331-2-chris@chris-wilson.co.uk> Subject: [Intel-gfx] [PATCH 1/3] Revert "ALSA: hda: Make use of core codec functions to sync power state" X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Abhijeet Kumar This reverts commit 3b5b899ca67db07a4c4825911072221f99e157e2. --- sound/pci/hda/hda_codec.c | 28 +++++++++++++++++++++++++++- sound/pci/hda/hda_local.h | 6 +----- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 5bc3a7468e17..e018ecbf78a8 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -2702,6 +2702,32 @@ void snd_hda_codec_set_power_to_all(struct hda_codec *codec, hda_nid_t fg, } EXPORT_SYMBOL_GPL(snd_hda_codec_set_power_to_all); +/* + * wait until the state is reached, returns the current state + */ +static unsigned int hda_sync_power_state(struct hda_codec *codec, + hda_nid_t fg, + unsigned int power_state) +{ + unsigned long end_time = jiffies + msecs_to_jiffies(500); + unsigned int state, actual_state; + + for (;;) { + state = snd_hda_codec_read(codec, fg, 0, + AC_VERB_GET_POWER_STATE, 0); + if (state & AC_PWRST_ERROR) + break; + actual_state = (state >> 4) & 0x0f; + if (actual_state == power_state) + break; + if (time_after_eq(jiffies, end_time)) + break; + /* wait until the codec reachs to the target state */ + msleep(1); + } + return state; +} + /** * snd_hda_codec_eapd_power_filter - A power filter callback for EAPD * @codec: the HDA codec @@ -2764,7 +2790,7 @@ static unsigned int hda_set_power_state(struct hda_codec *codec, state); snd_hda_codec_set_power_to_all(codec, fg, power_state); } - state = snd_hda_sync_power_state(codec, fg, power_state); + state = hda_sync_power_state(codec, fg, power_state); if (!(state & AC_PWRST_ERROR)) break; } diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 321e78baa63c..5b5c324c99b9 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -622,11 +622,7 @@ int snd_hda_check_amp_list_power(struct hda_codec *codec, { return snd_hdac_check_power_state(&codec->core, nid, target_state); } -static inline bool snd_hda_sync_power_state(struct hda_codec *codec, - hda_nid_t nid, unsigned int target_state) -{ - return snd_hdac_sync_power_state(&codec->core, nid, target_state); -} + unsigned int snd_hda_codec_eapd_power_filter(struct hda_codec *codec, hda_nid_t nid, unsigned int power_state);