From patchwork Fri Aug 12 13:52:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaroslav Kysela X-Patchwork-Id: 9277389 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 16C1860752 for ; Fri, 12 Aug 2016 16:13:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0687428A85 for ; Fri, 12 Aug 2016 16:13:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF8F428A94; Fri, 12 Aug 2016 16:13:10 +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=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00A0528A85 for ; Fri, 12 Aug 2016 16:13:09 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id DF1A0266EDC; Fri, 12 Aug 2016 18:13:08 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 6C750267027; Fri, 12 Aug 2016 18:03:02 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 89EDC267035; Fri, 12 Aug 2016 18:03:01 +0200 (CEST) Received: from mail1.perex.cz (mail1.perex.cz [77.48.224.245]) by alsa0.perex.cz (Postfix) with ESMTP id 2C25826724C for ; Fri, 12 Aug 2016 15:52:31 +0200 (CEST) Received: from server.perex-int.cz (server.perex-srv.cz [172.16.0.20]) by smtp1.perex.cz (Perex's E-mail Delivery System) with ESMTP id 139A4129A98; Fri, 12 Aug 2016 15:52:31 +0200 (CEST) Received: from t510.perex-int.cz.com (localhost [127.0.0.1]) by server.perex-int.cz (Perex's E-mail Delivery System) with ESMTP id DA32D85113; Fri, 12 Aug 2016 15:52:30 +0200 (CEST) From: Jaroslav Kysela To: ALSA development Date: Fri, 12 Aug 2016 15:52:04 +0200 Message-Id: <1471009924-32261-1-git-send-email-perex@perex.cz> X-Mailer: git-send-email 2.5.5 Cc: Takashi Iwai Subject: [alsa-devel] [PATCH] ALSA: hda - repoll jack presence state on resume X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP The jack detection on resume might fail on some hardware (Lenovo T430s, T440s and X1 Carbon 2016). The codec registers reports that the jack is not used and the unsolicited event is not sent on change (or perhaps, it's lost?). This patch will repoll the jack presence state after 100ms again. Because the jack status is updated from two workqueues now, create a new codec->jack_mutex to protect the concurrent access. Signed-off-by: Jaroslav Kysela --- sound/pci/hda/hda_bind.c | 2 ++ sound/pci/hda/hda_codec.c | 9 ++++++++- sound/pci/hda/hda_codec.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sound/pci/hda/hda_bind.c b/sound/pci/hda/hda_bind.c index 6efadbf..81a9284 100644 --- a/sound/pci/hda/hda_bind.c +++ b/sound/pci/hda/hda_bind.c @@ -42,8 +42,10 @@ static void hda_codec_unsol_event(struct hdac_device *dev, unsigned int ev) { struct hda_codec *codec = container_of(dev, struct hda_codec, core); + mutex_lock(&codec->jack_mutex); if (codec->patch_ops.unsol_event) codec->patch_ops.unsol_event(codec, ev); + mutex_unlock(&codec->jack_mutex); } /** diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 9913be8..4339e98 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -592,8 +592,10 @@ static void hda_jackpoll_work(struct work_struct *work) struct hda_codec *codec = container_of(work, struct hda_codec, jackpoll_work.work); + mutex_lock(&codec->jack_mutex); snd_hda_jack_set_dirty_all(codec); snd_hda_jack_poll_all(codec); + mutex_unlock(&codec->jack_mutex); if (!codec->jackpoll_interval) return; @@ -837,6 +839,7 @@ int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card, codec->addr = codec_addr; mutex_init(&codec->spdif_mutex); mutex_init(&codec->control_mutex); + mutex_init(&codec->jack_mutex); snd_array_init(&codec->mixers, sizeof(struct hda_nid_item), 32); snd_array_init(&codec->nids, sizeof(struct hda_nid_item), 32); snd_array_init(&codec->init_pins, sizeof(struct hda_pincfg), 16); @@ -3002,8 +3005,12 @@ static void hda_call_codec_resume(struct hda_codec *codec) if (codec->jackpoll_interval) hda_jackpoll_work(&codec->jackpoll_work.work); - else + else { snd_hda_jack_report_sync(codec); + /* Some hw requires a little time to settle things */ + schedule_delayed_work(&codec->jackpoll_work, + msecs_to_jiffies(100)); + } atomic_dec(&codec->core.in_pm); } diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 373fcad..6a4a631 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h @@ -213,6 +213,7 @@ struct hda_codec { struct mutex spdif_mutex; struct mutex control_mutex; + struct mutex jack_mutex; struct snd_array spdif_out; unsigned int spdif_in_enable; /* SPDIF input enable? */ const hda_nid_t *slave_dig_outs; /* optional digital out slave widgets */