Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1233808pxb; Fri, 27 Aug 2021 04:34:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBWhajsO9U6se82oRIKuETwKH30yzSiYMQLbFHKty9d3eWFAqXZGGDS3Mspgq309K931w/ X-Received: by 2002:a05:6e02:ed1:: with SMTP id i17mr6379785ilk.272.1630064057993; Fri, 27 Aug 2021 04:34:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630064057; cv=none; d=google.com; s=arc-20160816; b=TOE49Tl/ekUE2VgjSWLhZZk1jhD/IorYemNRexNMmKf10/MRhYVGBnPK/M0zQyO6sC BnaQVqdzEYcbvi7ai+tWtasisND+WfcneN34csBIverD6wYaOJaaeYZrsd4Ke+m0658k t+jUm2MSwurC6geuepZEMtZviIKOESSnswUxynXAIART0lClIobbg449qlzkQnHIczIC K0TRV8QCnCd7JfSc8c9aLoQ/2mizAqlS3fYOrnCCDOK7b/64AppAub37wYDCMAaUHrfF 55FC1FTq9ad06pz4PmVPH4aQxWeS+p3iLNryl4tdBwpNM9pL6jmIlc69sLu1Vj0HLxQ8 pXZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=fgC7+0bMytPVb3Z8IsZAuaN8+WcXgaQVIeFmCMgmnaU=; b=l7IiC8va12bLfdlYr1nXCmbeNvFPeGhX9pYAP4SW5A+HoRzxqt7bqx+WDiwmiBmJQ6 8cWxhQ/5K1Rg43AU2PKZOv7dMR2I2ewfOb2tC6z9hk8pHLbKCntrZVYeXtqQSgo3bR/t uEOfEOqg5T/QQcQoNtnwvipyB7HA73bhbteloRXMlOg0uE8YQ4JvBsYM785iTvW7m/hH rFwsFHu9SavNP3P8ia2JyhXIXcRqqRVz+q9aZKMCFnOLVK4oNOEGs2SCENx3vhAA9Wvj TiTnieP7Eql2qKsFLdmsaTaendsxWV/wPObpEtdeRMFGpg2paSUVMapBjCmM/E7kkJka +LrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=lp9H0Op8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h9si6456520ils.85.2021.08.27.04.34.05; Fri, 27 Aug 2021 04:34:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=lp9H0Op8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245011AbhH0LeO (ORCPT + 99 others); Fri, 27 Aug 2021 07:34:14 -0400 Received: from mx0b-001ae601.pphosted.com ([67.231.152.168]:61993 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233296AbhH0LeM (ORCPT ); Fri, 27 Aug 2021 07:34:12 -0400 Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 17R81B0B012251; Fri, 27 Aug 2021 06:33:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=fgC7+0bMytPVb3Z8IsZAuaN8+WcXgaQVIeFmCMgmnaU=; b=lp9H0Op8oKZZ7B1t9PrcH85I+L69eIMazO9OF3NG5kvyJ//jzwqb7oIGkwf56fNFfjZ7 TBI8um9cXaWpFGHjGSuQmcXVsU1ny4AIcvZ47kKnw46YrDNgvv50EongAfnOMDqczvsR tKoataG1+G3hyZ/fQuvPY0rrizmkFqlz56hp3xeH4DweJlFin+u14l6wpHil7fLfgBbv u+TyCZ+7VWaC2HI3g+JiU0IvZCJ4KlOvPL8F1AGCUsg8Eg4618Kj6ZgpzLSon64pZ2Ms EAKknzjvhLjSDeVR9wiptMnysTWbDQX9nt2ViqzcMeTFSi81Ds/fAGVgg1KTLWgJwP2P DA== Received: from ediex02.ad.cirrus.com ([87.246.76.36]) by mx0b-001ae601.pphosted.com with ESMTP id 3apv5sg7fa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Fri, 27 Aug 2021 06:33:07 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Fri, 27 Aug 2021 12:03:01 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2242.12 via Frontend Transport; Fri, 27 Aug 2021 12:03:01 +0100 Received: from vitaly-Inspiron-5415.ad.cirrus.com (unknown [198.90.238.186]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 464E32A9; Fri, 27 Aug 2021 11:03:00 +0000 (UTC) From: Vitaly Rodionov To: Jaroslav Kysela , Takashi Iwai CC: , , , Stefan Binding Subject: [PATCH 1/2] ALSA: hda/cs8409: Ensure Type Detection is only run on startup when necessary Date: Fri, 27 Aug 2021 12:02:51 +0100 Message-ID: <20210827110252.5361-1-vitalyr@opensource.cirrus.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: -41n5sueXKnydCdamrnkG6EbQmwZ7-TS X-Proofpoint-GUID: -41n5sueXKnydCdamrnkG6EbQmwZ7-TS X-Proofpoint-Spam-Reason: safe Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefan Binding Type Detection should only be run after init and when the controls have been built. There is no need to run it multiple times. Signed-off-by: Stefan Binding Signed-off-by: Vitaly Rodionov --- sound/pci/hda/patch_cs8409.c | 34 ++++++++++++++++++++++++++++------ sound/pci/hda/patch_cs8409.h | 2 ++ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/sound/pci/hda/patch_cs8409.c b/sound/pci/hda/patch_cs8409.c index 9db16b6292f4..805441b7bf86 100644 --- a/sound/pci/hda/patch_cs8409.c +++ b/sound/pci/hda/patch_cs8409.c @@ -784,6 +784,8 @@ static void cs42l42_suspend(struct sub_codec *cs42l42) cs8409_i2c_write(cs42l42, 0x1102, 0x9C); cs42l42->suspended = 1; cs42l42->last_page = 0; + cs42l42->hp_jack_in = 0; + cs42l42->mic_jack_in = 0; /* Put CS42L42 into Reset */ gpio_data = snd_hda_codec_read(codec, CS8409_PIN_AFG, 0, AC_VERB_GET_GPIO_DATA, 0); @@ -852,6 +854,8 @@ static int cs8409_cs42l42_suspend(struct hda_codec *codec) struct cs8409_spec *spec = codec->spec; int i; + spec->init_done = 0; + cs8409_enable_ur(codec, 0); for (i = 0; i < spec->num_scodecs; i++) @@ -1025,14 +1029,21 @@ void cs8409_cs42l42_fixups(struct hda_codec *codec, const struct hda_fixup *fix, break; case HDA_FIXUP_ACT_INIT: cs8409_cs42l42_hw_init(codec); - fallthrough; + spec->init_done = 1; + if (spec->init_done && spec->build_ctrl_done + && !spec->scodecs[CS8409_CODEC0]->hp_jack_in) + cs42l42_run_jack_detect(spec->scodecs[CS8409_CODEC0]); + break; case HDA_FIXUP_ACT_BUILD: + spec->build_ctrl_done = 1; /* Run jack auto detect first time on boot * after controls have been added, to check if jack has * been already plugged in. * Run immediately after init. */ - cs42l42_run_jack_detect(spec->scodecs[CS8409_CODEC0]); + if (spec->init_done && spec->build_ctrl_done + && !spec->scodecs[CS8409_CODEC0]->hp_jack_in) + cs42l42_run_jack_detect(spec->scodecs[CS8409_CODEC0]); break; default: break; @@ -1223,16 +1234,27 @@ void dolphin_fixups(struct hda_codec *codec, const struct hda_fixup *fix, int ac break; case HDA_FIXUP_ACT_INIT: dolphin_hw_init(codec); - fallthrough; + spec->init_done = 1; + if (spec->init_done && spec->build_ctrl_done) { + for (i = 0; i < spec->num_scodecs; i++) { + if (!spec->scodecs[i]->hp_jack_in) + cs42l42_run_jack_detect(spec->scodecs[i]); + } + } + break; case HDA_FIXUP_ACT_BUILD: + spec->build_ctrl_done = 1; /* Run jack auto detect first time on boot * after controls have been added, to check if jack has * been already plugged in. * Run immediately after init. */ - for (i = 0; i < spec->num_scodecs; i++) - cs42l42_run_jack_detect(spec->scodecs[i]); - + if (spec->init_done && spec->build_ctrl_done) { + for (i = 0; i < spec->num_scodecs; i++) { + if (!spec->scodecs[i]->hp_jack_in) + cs42l42_run_jack_detect(spec->scodecs[i]); + } + } break; default: break; diff --git a/sound/pci/hda/patch_cs8409.h b/sound/pci/hda/patch_cs8409.h index 207315ad5bf6..ade2b838590c 100644 --- a/sound/pci/hda/patch_cs8409.h +++ b/sound/pci/hda/patch_cs8409.h @@ -333,6 +333,8 @@ struct cs8409_spec { unsigned int playback_started:1; unsigned int capture_started:1; + unsigned int init_done:1; + unsigned int build_ctrl_done:1; /* verb exec op override */ int (*exec_verb)(struct hdac_device *dev, unsigned int cmd, unsigned int flags, -- 2.25.1