From patchwork Mon Jul 17 03:32:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Ning X-Patchwork-Id: 13315123 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9C1EBEB64DA for ; Mon, 17 Jul 2023 03:36:18 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3DA6E850; Mon, 17 Jul 2023 05:35:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3DA6E850 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1689564975; bh=QjDnB89hjRx55s7EDZuB9ho6HsYGvnAnuBjm0bhJJIQ=; h=From:To:Cc:Subject:Date:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=ckcfSFkG78j6fcjjzUm7ohnL7FDNRTTtG53fKulO/MrZmvhZrU6/iUBVF2B+7m9gO 4JZczFRAJv0GfY4a5Vbc8G2EjL46ZG5c4xf1v8tR2bNLRgEqj0++I19PJRUawomcaQ Pf+qhPaA5ibfjtFb5pPJ/lp9q/Q3/7y/6oNLhGog= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 58C85F80535; Mon, 17 Jul 2023 05:34:58 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 601F9F800D2; Mon, 17 Jul 2023 05:34:57 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BDA7DF80527; Mon, 17 Jul 2023 05:32:44 +0200 (CEST) Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 163EDF800D2 for ; Mon, 17 Jul 2023 05:32:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 163EDF800D2 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=IaGBK371 Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-6b9b89627c3so1711407a34.1 for ; Sun, 16 Jul 2023 20:32:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689564749; x=1692156749; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=OSQ/EF4eTeZehLtAwdrrxfniB7LkpUpWRgcBFX06IoY=; b=IaGBK371AH+W28iGujdqp77Jk3e+29UkB3k1JOp5WVxrMN6WTt9jDC8EiaJJC0UT6x YR5yP+fgIBFiOJVOvPgwjmbPpcY49fYKymEAAUQKMZvl5JDMDMWxxUQcbEhhYe+wkLW7 yTINTNsvKAgxhlAWPGr5S+eUFKZEnw8ZfQNL1JgjsOnntGRXqzqQaGCqRfiUXMi0Yag/ RZbaQ6w84fiPntEd1bcBL4smJxndGlhxfU5aOkHLme0PVTv+qT6EPuPt595ERQe9Rv+7 nGbQv3r8BE2qVwkbH6oqwCRJ4m/fMIx6L9MxrlFhRzVQm3+7m6ucTY60QNKQMrPMfEYu Akyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689564749; x=1692156749; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OSQ/EF4eTeZehLtAwdrrxfniB7LkpUpWRgcBFX06IoY=; b=VFfRM0jBFePZLB3V3KyHHsHhM1msEFR/c9RjunyZ+1z422Ads7PXhwkUwz1fCOgiLG GiLLT+YP8IUYe4lk2Y2tSFe3iUYEKSecWIHkJ8/O4mQNUhwAwk2MXtHeL3bPqc3VqyEs AjW1o48UI6v/6GDw+uNTRIlpVUfoDeWnSFgXJ0ntYKTGGhb9aPM+r8KJBOTeCXzEaGNO ZERdrOp0Hg6Mi3580sR7H/BTQrp25Eg7Y80a9gDhW5CS1bx2dXWNKei1H8+1cwWYLfBH YN9OGGBIDIw1pO+AJKthkwWJ5CwiRHyboYN4KWQN2OCYvuozNZa6xhMtRqH2GBriuUYH 6HmQ== X-Gm-Message-State: ABy/qLa+Bu6tZB47sUKoSZ89+fKiFCvoCJ8/w6LSTFmrlSik/osr444B XBT5w7kkby0mMQd8SKNkHLXZfTrMwdSoZExQ X-Google-Smtp-Source: APBJJlGg8JYNaTcEI4w4FmPP+UoihsWazxN4PnsVp22P5uh5MAU2lthLhzuKclMyf3+e/7VZG0/cZw== X-Received: by 2002:a05:6830:148:b0:6b9:c869:862c with SMTP id j8-20020a056830014800b006b9c869862cmr3382128otp.1.1689564748854; Sun, 16 Jul 2023 20:32:28 -0700 (PDT) Received: from a-VirtualBox.. ([116.233.75.15]) by smtp.gmail.com with ESMTPSA id a28-20020a63705c000000b00528513c6bbcsm11647509pgn.28.2023.07.16.20.32.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jul 2023 20:32:28 -0700 (PDT) From: Zhu Ning To: alsa-devel@alsa-project.org, broonie@kernel.org Cc: pierre-louis.bossart@linux.intel.com, tiwai@suse.com, amadeuszx.slawinski@linux.intel.com, yangxiaohua@everest-semi.com, zhuning@everest-semi.com, Zhu Ning Subject: [PATCH v2 1/5] ASoC: codecs: ES8326: Change Hp_detect register names Date: Mon, 17 Jul 2023 11:32:19 +0800 Message-Id: <20230717033223.42506-1-zhuning0077@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Message-ID-Hash: NH3DZORNQJTELWNPVS5S6JTRZXR37IBU X-Message-ID-Hash: NH3DZORNQJTELWNPVS5S6JTRZXR37IBU X-MailFrom: zhuning0077@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The old register naming method is confusing. The reg 0x57 decides the default headset hardware connection type, and the reg 0xfb is the headset detection status register, which changes during headset insertion. Change the name to ES8326_HPDET_TYPE and ES8326_HPDET_STA. Signed-off-by: Zhu Ning --- sound/soc/codecs/es8326.c | 10 +++++----- sound/soc/codecs/es8326.h | 13 ++++++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/sound/soc/codecs/es8326.c b/sound/soc/codecs/es8326.c index 4399ba36aee2..e953c0157ba0 100644 --- a/sound/soc/codecs/es8326.c +++ b/sound/soc/codecs/es8326.c @@ -159,7 +159,7 @@ static const struct snd_soc_dapm_route es8326_dapm_routes[] = { }; static const struct regmap_range es8326_volatile_ranges[] = { - regmap_reg_range(ES8326_HP_DETECT, ES8326_HP_DETECT), + regmap_reg_range(ES8326_HPDET_STA, ES8326_HPDET_STA), }; static const struct regmap_access_table es8326_volatile_table = { @@ -519,7 +519,7 @@ static void es8326_jack_button_handler(struct work_struct *work) return; mutex_lock(&es8326->lock); - iface = snd_soc_component_read(comp, ES8326_HP_DETECT); + iface = snd_soc_component_read(comp, ES8326_HPDET_STA); switch (iface) { case 0x93: /* pause button detected */ @@ -578,7 +578,7 @@ static void es8326_jack_detect_handler(struct work_struct *work) unsigned int iface; mutex_lock(&es8326->lock); - iface = snd_soc_component_read(comp, ES8326_HP_DETECT); + iface = snd_soc_component_read(comp, ES8326_HPDET_STA); dev_dbg(comp->dev, "gpio flag %#04x", iface); if ((iface & ES8326_HPINSERT_FLAG) == 0) { /* Jack unplugged or spurious IRQ */ @@ -651,7 +651,7 @@ static int es8326_resume(struct snd_soc_component *component) regmap_write(es8326->regmap, ES8326_ADC1_SRC, es8326->mic1_src); regmap_write(es8326->regmap, ES8326_ADC2_SRC, es8326->mic2_src); regmap_write(es8326->regmap, ES8326_HPJACK_TIMER, 0x88); - regmap_write(es8326->regmap, ES8326_HP_DET, + regmap_write(es8326->regmap, ES8326_HPDET_TYPE, ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol); regmap_write(es8326->regmap, ES8326_INT_SOURCE, es8326->interrupt_src); regmap_write(es8326->regmap, ES8326_INTOUT_IO, es8326->interrupt_clk); @@ -743,7 +743,7 @@ static void es8326_enable_jack_detect(struct snd_soc_component *component, mutex_lock(&es8326->lock); if (es8326->jd_inverted) - snd_soc_component_update_bits(component, ES8326_HP_DET, + snd_soc_component_update_bits(component, ES8326_HPDET_TYPE, ES8326_HP_DET_JACK_POL, ~es8326->jack_pol); es8326->jack = jack; diff --git a/sound/soc/codecs/es8326.h b/sound/soc/codecs/es8326.h index 3f8f7da58062..cd04d11a88d9 100644 --- a/sound/soc/codecs/es8326.h +++ b/sound/soc/codecs/es8326.h @@ -73,15 +73,19 @@ #define ES8326_DRC_RECOVERY 0x53 #define ES8326_DRC_WINSIZE 0x54 #define ES8326_HPJACK_TIMER 0x56 -#define ES8326_HP_DET 0x57 +#define ES8326_HPDET_TYPE 0x57 #define ES8326_INT_SOURCE 0x58 #define ES8326_INTOUT_IO 0x59 #define ES8326_SDINOUT1_IO 0x5A #define ES8326_SDINOUT23_IO 0x5B #define ES8326_JACK_PULSE 0x5C +#define ES8326_HP_MISC 0xF7 +#define ES8326_CTIA_OMTP_STA 0xF8 #define ES8326_PULLUP_CTL 0xF9 -#define ES8326_HP_DETECT 0xFB +#define ES8326_CSM_I2C_STA 0xFA +#define ES8326_HPDET_STA 0xFB +#define ES8326_CSM_MUTE_STA 0xFC #define ES8326_CHIP_ID1 0xFD #define ES8326_CHIP_ID2 0xFE #define ES8326_CHIP_VERSION 0xFF @@ -146,7 +150,7 @@ #define ES8326_ADC3_SHIFT 0 #define ES8326_ADC4_SHIFT 3 -/* ES8326_HP_DET */ +/* ES8326_HPDET_TYPE */ #define ES8326_HP_DET_SRC_PIN27 (1 << 5) #define ES8326_HP_DET_SRC_PIN9 (1 << 4) #define ES8326_HP_DET_JACK_POL (1 << 3) @@ -174,7 +178,7 @@ #define ES8326_SDINOUT2_SHIFT 4 #define ES8326_SDINOUT3_SHIFT 0 -/* ES8326_HP_DETECT */ +/* ES8326_HPDET_STA */ #define ES8326_HPINSERT_FLAG (1 << 1) #define ES8326_HPBUTTON_FLAG (1 << 0) @@ -182,4 +186,3 @@ #define ES8326_VERSION_B (1 << 0) #endif - From patchwork Mon Jul 17 03:32:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Ning X-Patchwork-Id: 13315125 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C37FEEB64DA for ; Mon, 17 Jul 2023 03:37:02 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C39B8AE9; Mon, 17 Jul 2023 05:36:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C39B8AE9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1689565020; bh=KCAnswSABYr2ITXy8z4k/eFmHYY+VeqKD+NeQuMer60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=CzxeeugvchTlBngAGrmekvVVcrWgcasbIaVYxCEvkhDNXxe1+dooF3+UUPbw6E79e k0sBNQMMRzMMCRzlXSENOL35lDuVGHnCoZoH78gcYN8F2yAmzKVhlmnkQ7kSETYv6y 8OsficttpBaLNdyH06Bi8a3Naop/cdFxzAQZKH4I= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2C56BF8055C; Mon, 17 Jul 2023 05:35:00 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id B6EE3F80551; Mon, 17 Jul 2023 05:34:59 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 69E74F804DA; Mon, 17 Jul 2023 05:33:35 +0200 (CEST) Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E3571F8007E for ; Mon, 17 Jul 2023 05:32:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E3571F8007E Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=llYatUmB Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-3a36b30aa7bso3002335b6e.3 for ; Sun, 16 Jul 2023 20:32:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689564751; x=1692156751; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PvI0P+9cSyZtkmqCZIS8QCJlA+e7eXnlLRhnl2WbHKY=; b=llYatUmBkNw2Zh+iPmtnUZwca/Y2fmO8hm1PmpcbID/cgpc3HXN2KLRjsVofnN1mU5 orM6Kr9pTHQHnR9AjZbvp8siVl17mQt+Zhd/hrwRN02bWF/QA8bCL2uM8BvtoWaOVpr9 eciuQwMGEfDZFJUCuY4UOt4xtlK12/nG6AZPAChqWxTm7xkGwYl35MimhKFgXPVGaase r26wfTSehVvzE2QLz8X4AZ7ms/QtSE/+2wZWkPoLGN80+PvKN870JW8oyXh4u/Vb4IrA 1VatLeBy1dnZMWf8cNIjJq7RhEL5BNoM5e0SaXUUT+jSwh2JTDLPrei2qKs0dZvP6JOW s8Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689564751; x=1692156751; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PvI0P+9cSyZtkmqCZIS8QCJlA+e7eXnlLRhnl2WbHKY=; b=CQL/cEoRySWKNaqMKEmqPCzE6Vbm1W4mWWapSk2oOZEOTnb/zIFq8z4G/KF4XyHUoX cGii4ngBLUODhZtlbMv38JwZ5B4fuyyBwguDTao1u8yvhixg3X3uZf2g7S3zkQO37uFd qLaYERfNictk3WcYjD7AVETYp/JgP/A22wdwI6VSbwm7r6yPAK/dmseDFgcLXAsXsMA1 LWpH2U1cBBckyftb5I9Dksqztdo+DEOKEZRp4jfBxjAftrH4NhmyNcHa2hUbCUePuDbe vM/vot+38VNh3swJYECykyzRwXlsjR15/aMfk1C/1rrLC3H4lonXWDBW2jAU7FesPJ4p 4gJw== X-Gm-Message-State: ABy/qLYkYs/1th1wSMMbpxKEfbGVjQUj6uHyJHIsvWGGdIg0S6cvJUtC Skc+fKMYkZVijEw+fYuvPyxedZaB4WkmEGOm X-Google-Smtp-Source: APBJJlE364QYoS3zNEs1g16WFN6Bf0gfUSUbnfVkniNh035K/c03wk8RBm5/TNXiqfrc8cGF9bCBKg== X-Received: by 2002:a05:6808:1283:b0:3a4:31ee:da6a with SMTP id a3-20020a056808128300b003a431eeda6amr12654821oiw.55.1689564751040; Sun, 16 Jul 2023 20:32:31 -0700 (PDT) Received: from a-VirtualBox.. ([116.233.75.15]) by smtp.gmail.com with ESMTPSA id a28-20020a63705c000000b00528513c6bbcsm11647509pgn.28.2023.07.16.20.32.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jul 2023 20:32:30 -0700 (PDT) From: Zhu Ning To: alsa-devel@alsa-project.org, broonie@kernel.org Cc: pierre-louis.bossart@linux.intel.com, tiwai@suse.com, amadeuszx.slawinski@linux.intel.com, yangxiaohua@everest-semi.com, zhuning@everest-semi.com, Zhu Ning Subject: [PATCH v2 2/5] ASoC: codecs: ES8326: Change Volatile Reg function Date: Mon, 17 Jul 2023 11:32:20 +0800 Message-Id: <20230717033223.42506-2-zhuning0077@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230717033223.42506-1-zhuning0077@gmail.com> References: <20230717033223.42506-1-zhuning0077@gmail.com> MIME-Version: 1.0 Message-ID-Hash: 3M423Y3RFZYHX6LAKTN6RLEAQT2LVCH7 X-Message-ID-Hash: 3M423Y3RFZYHX6LAKTN6RLEAQT2LVCH7 X-MailFrom: zhuning0077@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: <> List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The new calibration and headphone detection function require reading new volatile registers. Add them in the volatile register function. Signed-off-by: Zhu Ning --- sound/soc/codecs/es8326.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/sound/soc/codecs/es8326.c b/sound/soc/codecs/es8326.c index e953c0157ba0..7cfe535e0b6d 100644 --- a/sound/soc/codecs/es8326.c +++ b/sound/soc/codecs/es8326.c @@ -158,20 +158,25 @@ static const struct snd_soc_dapm_route es8326_dapm_routes[] = { {"HPOR", NULL, "RHPMIX"}, }; -static const struct regmap_range es8326_volatile_ranges[] = { - regmap_reg_range(ES8326_HPDET_STA, ES8326_HPDET_STA), -}; - -static const struct regmap_access_table es8326_volatile_table = { - .yes_ranges = es8326_volatile_ranges, - .n_yes_ranges = ARRAY_SIZE(es8326_volatile_ranges), -}; +static bool es8326_volatile_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case ES8326_HPL_OFFSET_INI: + case ES8326_HPR_OFFSET_INI: + case ES8326_HPDET_STA: + case ES8326_CTIA_OMTP_STA: + case ES8326_CSM_MUTE_STA: + return true; + default: + return false; + } +} static const struct regmap_config es8326_regmap_config = { .reg_bits = 8, .val_bits = 8, .max_register = 0xff, - .volatile_table = &es8326_volatile_table, + .volatile_reg = es8326_volatile_register, .cache_type = REGCACHE_RBTREE, }; From patchwork Mon Jul 17 03:32:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Ning X-Patchwork-Id: 13315124 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 83551EB64DA for ; Mon, 17 Jul 2023 03:36:44 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A582ADEE; Mon, 17 Jul 2023 05:35:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A582ADEE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1689565001; bh=/IEpAVF78Rqv2LVczrZlfFO477LOjAVAjWBRPvOnjh4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=q7ku4K0AzlkS8uW33XdIe7ni2Fwp4jodtac4PdVqe2pzFWk9xF1GP5ZoxJpWtqiTU eIIaA6+AmVxGe83i9DzNNPud1ME89S5DTLhstWZUWac8AJwdWGcyxeb7q6XA2UIZAt CFYirf83wr9mafGTxc0tUYbp4A2dUxAUL1OmZPUI= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1CD25F80553; Mon, 17 Jul 2023 05:34:58 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 290C8F80551; Mon, 17 Jul 2023 05:34:58 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 462B7F80520; Mon, 17 Jul 2023 05:32:51 +0200 (CEST) Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2C160F8047D for ; Mon, 17 Jul 2023 05:32:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2C160F8047D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=Mv1EXEXa Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-666ed230c81so4185593b3a.0 for ; Sun, 16 Jul 2023 20:32:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689564753; x=1692156753; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QqKM93j3IhItw8kQLLKECLDwgBAuQVtO1eMhzHy4jXo=; b=Mv1EXEXaMTnQU83Pm9cVrpngqVnemxd7Xf7bb5pAOCsHMFIOwzk3aL5wFptPEmPH5s nNWGN5f6uJ40EgZ/F7aAX+BfdVYpO9ooLmqrVDvdFOeR4iztzwlEnrGaOVENKGymOigS +nWtgMWmIOCP4Rn9M8NZs6DHrgGLfqwYfokpGz7X2Xyg2+h4m9zA7tPximR37jGWXK6Q mqOUOVJPKGzlb2HrFCFcgE3Fk95mVKg9hUHBRlSQR4ygavBSqJDqaTTzAavqzSK/J4cm 7AGbMuXJTU7BnEOay9acsSyuYYesOnbzmKhPvNEbSfr7xO/26hMU7yXjdqhAjR28uemV inyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689564753; x=1692156753; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QqKM93j3IhItw8kQLLKECLDwgBAuQVtO1eMhzHy4jXo=; b=huteRwWT2VnvqcLM/mLOjz1tQNJZQXG+A4tftkJQq/klhyuUCUUPjJk/GbcEqhG5Qs mYa2pe3iPLSg67OK2ZJ7VQq8tJQ/GxkDOZ0zjWHU+NtKGn9tVXH9Ig7h/++fj5JUATr6 33JTgJ4sUSZzV14mmI9MNeyunZPIH1FSZPPi5zdqaMMt/GTzw6MEZrV/RkFpZCi5ZAHc zhWBFD/M9F0WXWwWAIXdUD89XHpARZ/rQHH9AKfPU3VO24Z4+N3iU2aezqBWc8/OKTBF V2LtGRi5AnFqmDJxWzvSFHIHcKwke4m5OxhVQhf6X3rfAv8RV/lylG55EYuVU1dSBpO6 QnbQ== X-Gm-Message-State: ABy/qLYhGZVmfMIDk63ZJr0qAkjiOxmQu4Q/zFdLV7s3yrLzNuOoKZoX UT3hxD4IHV80WI1F9iECq07bOtbYiQA0gWDU X-Google-Smtp-Source: APBJJlFmRIXs7se0lMvJHtX23dDZ839dPXuVp0j3zvaND4B/ksNFzVUOyiXWJZsh2fAzuHOSsKE58w== X-Received: by 2002:a05:6a20:12ca:b0:121:fd18:4b51 with SMTP id v10-20020a056a2012ca00b00121fd184b51mr14362663pzg.36.1689564753224; Sun, 16 Jul 2023 20:32:33 -0700 (PDT) Received: from a-VirtualBox.. ([116.233.75.15]) by smtp.gmail.com with ESMTPSA id a28-20020a63705c000000b00528513c6bbcsm11647509pgn.28.2023.07.16.20.32.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jul 2023 20:32:32 -0700 (PDT) From: Zhu Ning To: alsa-devel@alsa-project.org, broonie@kernel.org Cc: pierre-louis.bossart@linux.intel.com, tiwai@suse.com, amadeuszx.slawinski@linux.intel.com, yangxiaohua@everest-semi.com, zhuning@everest-semi.com, Zhu Ning Subject: [PATCH v2 3/5] ASoC: codecs: ES8326: Fix power-up sequence Date: Mon, 17 Jul 2023 11:32:21 +0800 Message-Id: <20230717033223.42506-3-zhuning0077@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230717033223.42506-1-zhuning0077@gmail.com> References: <20230717033223.42506-1-zhuning0077@gmail.com> MIME-Version: 1.0 Message-ID-Hash: NRAMVVK7OLNZXE7K23QYDSTKLCHIJHBT X-Message-ID-Hash: NRAMVVK7OLNZXE7K23QYDSTKLCHIJHBT X-MailFrom: zhuning0077@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Old power-up sequence causes large pop noise during start-up. Using a new sequence instead. Also, the registers are now reset to default value in suspend function. Signed-off-by: Zhu Ning --- sound/soc/codecs/es8326.c | 95 ++++++++++++++++++++++++++++----------- sound/soc/codecs/es8326.h | 10 ++++- 2 files changed, 77 insertions(+), 28 deletions(-) diff --git a/sound/soc/codecs/es8326.c b/sound/soc/codecs/es8326.c index 7cfe535e0b6d..1525fac1f9b8 100644 --- a/sound/soc/codecs/es8326.c +++ b/sound/soc/codecs/es8326.c @@ -638,40 +638,77 @@ static irqreturn_t es8326_irq(int irq, void *dev_id) static int es8326_resume(struct snd_soc_component *component) { struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component); - unsigned int reg; regcache_cache_only(es8326->regmap, false); regcache_sync(es8326->regmap); + /* reset internal clock state */ + regmap_write(es8326->regmap, ES8326_RESET, 0x1f); + regmap_write(es8326->regmap, ES8326_VMIDSEL, 0x0E); + usleep_range(10000, 15000); + regmap_write(es8326->regmap, ES8326_HPJACK_TIMER, 0x88); + /* set headphone default type and detect pin */ + regmap_write(es8326->regmap, ES8326_HPDET_TYPE, 0x81); + regmap_write(es8326->regmap, ES8326_CLK_RESAMPLE, 0x05); + + /* set internal oscillator as clock source of headpone cp */ + regmap_write(es8326->regmap, ES8326_CLK_DIV_CPC, 0x84); regmap_write(es8326->regmap, ES8326_CLK_CTL, ES8326_CLK_ON); - /* Two channel ADC */ - regmap_write(es8326->regmap, ES8326_PULLUP_CTL, 0x02); + /* clock manager reset release */ + regmap_write(es8326->regmap, ES8326_RESET, 0x17); + /* set headphone detection as half scan mode */ + regmap_write(es8326->regmap, ES8326_HP_MISC, 0x08); + regmap_write(es8326->regmap, ES8326_PULLUP_CTL, 0x00); + + /* enable headphone driver */ + regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa7); + usleep_range(2000, 5000); + regmap_write(es8326->regmap, ES8326_HP_DRIVER_REF, 0xab); + usleep_range(2000, 5000); + regmap_write(es8326->regmap, ES8326_HP_DRIVER_REF, 0xbb); + usleep_range(2000, 5000); + regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa1); + regmap_write(es8326->regmap, ES8326_CLK_INV, 0x00); - regmap_write(es8326->regmap, ES8326_CLK_DIV_CPC, 0x1F); - regmap_write(es8326->regmap, ES8326_CLK_VMIDS1, 0xC8); - regmap_write(es8326->regmap, ES8326_CLK_VMIDS2, 0x88); - regmap_write(es8326->regmap, ES8326_CLK_CAL_TIME, 0x20); + regmap_write(es8326->regmap, ES8326_CLK_VMIDS1, 0xc4); + regmap_write(es8326->regmap, ES8326_CLK_VMIDS2, 0x81); + regmap_write(es8326->regmap, ES8326_CLK_CAL_TIME, 0x00); + + /* turn off headphone out */ + regmap_write(es8326->regmap, ES8326_HP_CAL, 0x00); + /* set ADC and DAC in low power mode */ + regmap_write(es8326->regmap, ES8326_ANA_LP, 0xf0); + + /* force micbias on */ + regmap_write(es8326->regmap, ES8326_ANA_MICBIAS, 0x4f); regmap_write(es8326->regmap, ES8326_SYS_BIAS, 0x08); - regmap_write(es8326->regmap, ES8326_DAC2HPMIX, 0x22); - regmap_write(es8326->regmap, ES8326_ADC1_SRC, es8326->mic1_src); - regmap_write(es8326->regmap, ES8326_ADC2_SRC, es8326->mic2_src); - regmap_write(es8326->regmap, ES8326_HPJACK_TIMER, 0x88); - regmap_write(es8326->regmap, ES8326_HPDET_TYPE, - ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol); - regmap_write(es8326->regmap, ES8326_INT_SOURCE, es8326->interrupt_src); - regmap_write(es8326->regmap, ES8326_INTOUT_IO, es8326->interrupt_clk); + regmap_write(es8326->regmap, ES8326_ANA_VSEL, 0x7F); + /* select vdda as micbias source */ + regmap_write(es8326->regmap, ES8326_VMIDLOW, 0x23); + /* set dac dsmclip = 1 */ + regmap_write(es8326->regmap, ES8326_DAC_DSM, 0x08); + regmap_write(es8326->regmap, ES8326_DAC_VPPSCALE, 0x15); + + regmap_write(es8326->regmap, ES8326_INT_SOURCE, + (ES8326_INT_SRC_PIN9 | ES8326_INT_SRC_BUTTON)); + regmap_write(es8326->regmap, ES8326_INTOUT_IO, + es8326->interrupt_clk); + regmap_write(es8326->regmap, ES8326_SDINOUT1_IO, + (ES8326_IO_DMIC_CLK << ES8326_SDINOUT1_SHIFT)); + regmap_write(es8326->regmap, ES8326_SDINOUT23_IO, ES8326_IO_INPUT); + + regmap_write(es8326->regmap, ES8326_ANA_PDN, 0x3b); regmap_write(es8326->regmap, ES8326_RESET, ES8326_CSM_ON); - snd_soc_component_update_bits(component, ES8326_PGAGAIN, - ES8326_MIC_SEL_MASK, ES8326_MIC1_SEL); - - regmap_read(es8326->regmap, ES8326_CHIP_VERSION, ®); - if ((reg & ES8326_VERSION_B) == 1) { - regmap_write(es8326->regmap, ES8326_ANA_MICBIAS, 0xDD); - regmap_write(es8326->regmap, ES8326_ANA_VSEL, 0x7F); - regmap_write(es8326->regmap, ES8326_VMIDLOW, 0x0F); - /* enable button detect */ - regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xA0); - } + regmap_update_bits(es8326->regmap, ES8326_PGAGAIN, ES8326_MIC_SEL_MASK, + ES8326_MIC1_SEL); + + regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE, ES8326_MUTE_MASK, + ES8326_MUTE); + + regmap_write(es8326->regmap, ES8326_HPDET_TYPE, 0x80 | + ((es8326->version == ES8326_VERSION_B) ? + (ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol) : + (ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol | 0x04))); es8326_irq(es8326->irq, es8326); return 0; @@ -688,6 +725,10 @@ static int es8326_suspend(struct snd_soc_component *component) regcache_cache_only(es8326->regmap, true); regcache_mark_dirty(es8326->regmap); + /* reset register value to default */ + regmap_write(es8326->regmap, ES8326_CSM_I2C_STA, 0x01); + usleep_range(1000, 3000); + regmap_write(es8326->regmap, ES8326_CSM_I2C_STA, 0x00); return 0; } @@ -717,7 +758,7 @@ static int es8326_probe(struct snd_soc_component *component) ret = device_property_read_u8(component->dev, "everest,jack-pol", &es8326->jack_pol); if (ret != 0) { dev_dbg(component->dev, "jack-pol return %d", ret); - es8326->jack_pol = ES8326_HP_DET_BUTTON_POL | ES8326_HP_TYPE_OMTP; + es8326->jack_pol = ES8326_HP_TYPE_AUTO; } dev_dbg(component->dev, "jack-pol %x", es8326->jack_pol); diff --git a/sound/soc/codecs/es8326.h b/sound/soc/codecs/es8326.h index cd04d11a88d9..90a08351d6ac 100644 --- a/sound/soc/codecs/es8326.h +++ b/sound/soc/codecs/es8326.h @@ -160,6 +160,13 @@ #define ES8326_HP_TYPE_AUTO (1 << 0) #define ES8326_HP_TYPE_AUTO_INV (0 << 0) +/* ES8326_INT_SOURCE */ +#define ES8326_INT_SRC_DAC_MOZ (1 << 0) +#define ES8326_INT_SRC_ADC_MOZ (1 << 1) +#define ES8326_INT_SRC_BUTTON (1 << 2) +#define ES8326_INT_SRC_PIN9 (1 << 3) +#define ES8326_INT_SRC_PIN27 (1 << 4) + /* ES8326_SDINOUT1_IO */ #define ES8326_IO_INPUT (0 << 0) #define ES8326_IO_SDIN_SLOT0 (1 << 0) @@ -183,6 +190,7 @@ #define ES8326_HPBUTTON_FLAG (1 << 0) /* ES8326_CHIP_VERSION 0xFF */ -#define ES8326_VERSION_B (1 << 0) +#define ES8326_VERSION (1 << 0) +#define ES8326_VERSION_B (3 << 0) #endif From patchwork Mon Jul 17 03:32:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Ning X-Patchwork-Id: 13315127 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 19703EB64DA for ; Mon, 17 Jul 2023 03:37:33 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 54A82E10; Mon, 17 Jul 2023 05:36:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 54A82E10 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1689565051; bh=d1EtMuAPXKt0IrqTmnH6abijFeok0paumvwCJBqWAjc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=YLnqUOlhETDWR/JEPA/dM96lHevezODv02SLsOkac0o3GN78ZI1X3bL7BLhqh8NXB +zOnjtqMVfLhZTm1Pj5mJeTbjNqpeSCvYzroq18kfKglk961YX8oXGBEufBias9qVD NstTrxNVQEXhXxa9FFmiyDlnBwyKVA69w6RNORs4= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5DD17F8059F; Mon, 17 Jul 2023 05:35:03 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 10954F80589; Mon, 17 Jul 2023 05:35:03 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id AA09BF8032D; Mon, 17 Jul 2023 05:33:43 +0200 (CEST) Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2AD2AF80494 for ; Mon, 17 Jul 2023 05:32:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2AD2AF80494 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=o3CS0usd Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-666edfc50deso2365392b3a.0 for ; Sun, 16 Jul 2023 20:32:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689564755; x=1692156755; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iKysbFPEQ1mXdv4neuP/+sReutuRtBTNjuQMkBrohhQ=; b=o3CS0usdSPGOgCUA7uVl/ICG+6WpC5jcZX5C8WdpZvWn5NqkKbQYPIltn9GLB5ZZd9 Eoe+69Nh8eHPofVb6yIueU3TjxK7W6eaTqem9hSY8P9o5jYP76E4sXN7/6BLNyy8QhYu 0PoIjH8YheEzrlcRjg+KhHLdoy3ea0HpXnutImmSB5j3F9eFYFezNTBwyGzfFYzsWYaD I+IbSDq3+ok1V8f68p14oMdLAiHnBKbwVlQSuUN7p2HBjL7ahXcI7n4Ubp+ajnMTc+Bs oh6e/d/WzSbT37z2pr9rj2SW5S8dCFcAMQAE6+5aRy5ziohPvAGE9ufr6pnYBVYSSeyH Ha/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689564755; x=1692156755; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iKysbFPEQ1mXdv4neuP/+sReutuRtBTNjuQMkBrohhQ=; b=ChPkLV7ISstGcqFn9hStNxSW37w5POFoTLWWaDf/DOSOt28CVkDs852jTKLAMy1wb9 dGIicyX8WWmEz+vyGcObowaZn6K0DdEc0q+b3heHyMXn1EMPokbFC8mikpyvnRPZ1YlB xkbLHENA43xLHTOVCzw2XR/HsUHJFCuJJckztQbPNirH3FUisTamJ0MsSAOyJae2Yyfj d/XqWEUOv5fxCGHHiKaFaDEcxaUMqhYNPwQqSgT/jArWeBBn+N0uwmu4TlzKb0FQzUe5 ztWTGo9/5+HFhUg8h0Ka9sIVZKnnHpfr7VhOkX/m1ARBvOUf45kSesg3b2TqKhzYjKdK 2sKw== X-Gm-Message-State: ABy/qLb9QSxxQc798AiEdcF0uH4gyOpbFGSDrGvkl9F+1NBHrNsbPJHX YvyfxtRQHrnqO/uNyDHPTarrgPwbPGkQuOGD X-Google-Smtp-Source: APBJJlEejfyoELXm+x9eKqX5xnj5ZMKr+uqElsu40z+WksnP+e02lz5KL1dXr+9w1mTcwBD8tNVQJA== X-Received: by 2002:a05:6a00:368e:b0:64d:42b9:6895 with SMTP id dw14-20020a056a00368e00b0064d42b96895mr10933315pfb.5.1689564755379; Sun, 16 Jul 2023 20:32:35 -0700 (PDT) Received: from a-VirtualBox.. ([116.233.75.15]) by smtp.gmail.com with ESMTPSA id a28-20020a63705c000000b00528513c6bbcsm11647509pgn.28.2023.07.16.20.32.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jul 2023 20:32:35 -0700 (PDT) From: Zhu Ning To: alsa-devel@alsa-project.org, broonie@kernel.org Cc: pierre-louis.bossart@linux.intel.com, tiwai@suse.com, amadeuszx.slawinski@linux.intel.com, yangxiaohua@everest-semi.com, zhuning@everest-semi.com, Zhu Ning Subject: [PATCH v2 4/5] ASOC: codecs: ES8326: Add calibration support for version_b Date: Mon, 17 Jul 2023 11:32:22 +0800 Message-Id: <20230717033223.42506-4-zhuning0077@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230717033223.42506-1-zhuning0077@gmail.com> References: <20230717033223.42506-1-zhuning0077@gmail.com> MIME-Version: 1.0 Message-ID-Hash: UADT5PZASJD4R5RWQ66RAH73XGFFP46M X-Message-ID-Hash: UADT5PZASJD4R5RWQ66RAH73XGFFP46M X-MailFrom: zhuning0077@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Version_b requires a new way of calibrating headset offset. A new calibration function is added. Signed-off-by: Zhu Ning --- sound/soc/codecs/es8326.c | 83 ++++++++++++++++++++++++++++++++------- 1 file changed, 68 insertions(+), 15 deletions(-) diff --git a/sound/soc/codecs/es8326.c b/sound/soc/codecs/es8326.c index 1525fac1f9b8..50b13296e246 100644 --- a/sound/soc/codecs/es8326.c +++ b/sound/soc/codecs/es8326.c @@ -388,6 +388,7 @@ static int es8326_mute(struct snd_soc_dai *dai, int mute, int direction) { struct snd_soc_component *component = dai->component; struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component); + unsigned int offset_l, offset_r; if (mute) { regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_OFF); @@ -398,10 +399,16 @@ static int es8326_mute(struct snd_soc_dai *dai, int mute, int direction) if (!es8326->calibrated) { regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_FORCE_CAL); msleep(30); + regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_OFF); + regmap_read(es8326->regmap, ES8326_HPL_OFFSET_INI, &offset_l); + regmap_read(es8326->regmap, ES8326_HPR_OFFSET_INI, &offset_r); + regmap_write(es8326->regmap, ES8326_HP_OFFSET_CAL, 0x8c); + regmap_write(es8326->regmap, ES8326_HPL_OFFSET_INI, offset_l); + regmap_write(es8326->regmap, ES8326_HPR_OFFSET_INI, offset_r); es8326->calibrated = true; } regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa0); - regmap_write(es8326->regmap, ES8326_HP_VOL, 0x00); + regmap_write(es8326->regmap, ES8326_HP_VOL, 0x80); regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_ON); regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE, ES8326_MUTE_MASK, ~(ES8326_MUTE)); @@ -420,15 +427,17 @@ static int es8326_set_bias_level(struct snd_soc_component *codec, ret = clk_prepare_enable(es8326->mclk); if (ret) return ret; - regmap_write(es8326->regmap, ES8326_RESET, ES8326_PWRUP_SEQ_EN); - regmap_write(es8326->regmap, ES8326_INTOUT_IO, 0x45); + + regmap_write(es8326->regmap, ES8326_RESET, 0x9f); + msleep(20); + regmap_update_bits(es8326->regmap, ES8326_DAC_DSM, 0x01, 0x00); + regmap_write(es8326->regmap, ES8326_INTOUT_IO, es8326->interrupt_clk); regmap_write(es8326->regmap, ES8326_SDINOUT1_IO, (ES8326_IO_DMIC_CLK << ES8326_SDINOUT1_SHIFT)); - regmap_write(es8326->regmap, ES8326_SDINOUT23_IO, ES8326_IO_INPUT); - regmap_write(es8326->regmap, ES8326_CLK_RESAMPLE, 0x05); - regmap_write(es8326->regmap, ES8326_VMIDSEL, 0x02); + regmap_write(es8326->regmap, ES8326_VMIDSEL, 0x0E); regmap_write(es8326->regmap, ES8326_PGA_PDN, 0x40); - regmap_write(es8326->regmap, ES8326_DAC2HPMIX, 0xAA); + regmap_write(es8326->regmap, ES8326_ANA_PDN, 0x00); + regmap_update_bits(es8326->regmap, ES8326_CLK_CTL, 0x20, 0x20); regmap_write(es8326->regmap, ES8326_RESET, ES8326_CSM_ON); break; case SND_SOC_BIAS_PREPARE: @@ -437,15 +446,10 @@ static int es8326_set_bias_level(struct snd_soc_component *codec, break; case SND_SOC_BIAS_OFF: clk_disable_unprepare(es8326->mclk); - regmap_write(es8326->regmap, ES8326_DAC2HPMIX, 0x11); - regmap_write(es8326->regmap, ES8326_RESET, ES8326_CSM_OFF); - regmap_write(es8326->regmap, ES8326_PGA_PDN, 0xF8); + regmap_write(es8326->regmap, ES8326_ANA_PDN, 0x3b); regmap_write(es8326->regmap, ES8326_VMIDSEL, 0x00); - regmap_write(es8326->regmap, ES8326_INT_SOURCE, 0x08); + regmap_update_bits(es8326->regmap, ES8326_CLK_CTL, 0x20, 0x00); regmap_write(es8326->regmap, ES8326_SDINOUT1_IO, ES8326_IO_INPUT); - regmap_write(es8326->regmap, ES8326_SDINOUT23_IO, ES8326_IO_INPUT); - regmap_write(es8326->regmap, ES8326_RESET, - ES8326_CODEC_RESET | ES8326_PWRUP_SEQ_EN); break; } @@ -635,6 +639,54 @@ static irqreturn_t es8326_irq(int irq, void *dev_id) return IRQ_HANDLED; } +static int es8326_calibrate(struct snd_soc_component *component) +{ + struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component); + unsigned int reg; + unsigned int offset_l, offset_r; + + regmap_read(es8326->regmap, ES8326_CHIP_VERSION, ®); + es8326->version = reg; + + if ((es8326->version == ES8326_VERSION_B) && (es8326->calibrated == false)) { + dev_dbg(component->dev, "ES8326_VERSION_B, calibrating\n"); + regmap_write(es8326->regmap, ES8326_CLK_INV, 0xc0); + regmap_write(es8326->regmap, ES8326_CLK_DIV1, 0x01); + regmap_write(es8326->regmap, ES8326_CLK_DLL, 0x30); + regmap_write(es8326->regmap, ES8326_CLK_MUX, 0xed); + regmap_write(es8326->regmap, ES8326_CLK_TRI, 0xc1); + regmap_write(es8326->regmap, ES8326_DAC_MUTE, 0x03); + regmap_write(es8326->regmap, ES8326_ANA_VSEL, 0x7f); + regmap_write(es8326->regmap, ES8326_VMIDLOW, 0x33); + regmap_write(es8326->regmap, ES8326_DAC2HPMIX, 0x88); + regmap_write(es8326->regmap, ES8326_HP_VOL, 0x80); + regmap_write(es8326->regmap, ES8326_HP_OFFSET_CAL, 0x8c); + regmap_write(es8326->regmap, ES8326_RESET, 0xc0); + usleep_range(15000, 20000); + + regmap_write(es8326->regmap, ES8326_HP_OFFSET_CAL, ES8326_HP_OFF); + regmap_read(es8326->regmap, ES8326_CSM_MUTE_STA, ®); + if ((reg & 0xf0) != 0x40) + msleep(50); + + regmap_write(es8326->regmap, ES8326_HP_CAL, 0xd4); + msleep(200); + regmap_write(es8326->regmap, ES8326_HP_CAL, 0x4d); + msleep(200); + regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_OFF); + regmap_read(es8326->regmap, ES8326_HPL_OFFSET_INI, &offset_l); + regmap_read(es8326->regmap, ES8326_HPR_OFFSET_INI, &offset_r); + regmap_write(es8326->regmap, ES8326_HP_OFFSET_CAL, 0x8c); + regmap_write(es8326->regmap, ES8326_HPL_OFFSET_INI, offset_l); + regmap_write(es8326->regmap, ES8326_HPR_OFFSET_INI, offset_r); + regmap_write(es8326->regmap, ES8326_CLK_INV, 0x00); + + es8326->calibrated = true; + } + + return 0; +} + static int es8326_resume(struct snd_soc_component *component) { struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component); @@ -673,7 +725,8 @@ static int es8326_resume(struct snd_soc_component *component) regmap_write(es8326->regmap, ES8326_CLK_VMIDS1, 0xc4); regmap_write(es8326->regmap, ES8326_CLK_VMIDS2, 0x81); regmap_write(es8326->regmap, ES8326_CLK_CAL_TIME, 0x00); - + /* calibrate for B version */ + es8326_calibrate(component); /* turn off headphone out */ regmap_write(es8326->regmap, ES8326_HP_CAL, 0x00); /* set ADC and DAC in low power mode */ From patchwork Mon Jul 17 03:32:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Ning X-Patchwork-Id: 13315126 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 506E5EB64DA for ; Mon, 17 Jul 2023 03:37:08 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 370AEE72; Mon, 17 Jul 2023 05:36:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 370AEE72 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1689565026; bh=rtdGQYBWGUpna2FPjsL9T4rQG6S0ab/3WCfgQD2+N10=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=LLeVoVikYkBw+PjMGomXRUI/m5j4LY+SLzIBmbj5k+4awES5DA2fqZQm8Bf7//LIv aUs7SGjS+C0upYricqZtPmRV7DExxuZFyDFdXApgGqybF5e5cS5eNi6HiYWvpmgyti up/q7zpS7j9ZN+/YDMBp/fMfPgtQzLxDAiKXi57E= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2F846F8057E; Mon, 17 Jul 2023 05:35:02 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 683BDF8057E; Mon, 17 Jul 2023 05:35:01 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BCD62F8047D; Mon, 17 Jul 2023 05:33:40 +0200 (CEST) Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5414FF8032D for ; Mon, 17 Jul 2023 05:32:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5414FF8032D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=FUqeePH0 Received: by mail-oi1-x22d.google.com with SMTP id 5614622812f47-3a1e6022b93so2939412b6e.1 for ; Sun, 16 Jul 2023 20:32:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689564758; x=1692156758; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZbZ8B9EmRUagDKp2bmjGUZzuohr9WL08JwlgNpFRSPk=; b=FUqeePH0dmcgxhHNTF9xOXEfXtFY2knFN618TyPHDyzW+JmLShbbxnHVkjQYG5t9yH JkX8L1tkxYvqHnAv13CQCa1G55p5zGA7pGkMnwWFevEIslDrgKEQAfzfrm/pacf3d4QI yTkFo2OP/yBjypdp5GACrPecStaTjHReBdeRRdQEl2XYT0JdbJrnqPKu6RJU1nSbnKN3 3oFoXCpsgIWJvRDvrFZ34w5rkNlsxg6R/+Pqg9uKNuaKKTp7l4+KPbk6lBKA+oe0LYjO wNXoUJeRDtBzu53CTLP90saTYXn3fMxAmb29zKh6w47o0jkeSdwy/ESV9HqWeXqqJLbK QFvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689564758; x=1692156758; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZbZ8B9EmRUagDKp2bmjGUZzuohr9WL08JwlgNpFRSPk=; b=anfk9qiEnNnfbIZqv8+z5YdaG85bggiIVYLF/xAbD//rYRxvUlQaBPhp80ONZOKNmf VPqhfNr3995P62ShdmroUVmhigDlkjqpOHxhptl3bqyAeS2gQTJf8Lwf4CQil2pux20I sawQ0OQH1eFZDB2Owb730cX3gAP9uohYg1CJahZHOcxr9pwK5jPRPA64VY60xaeH42Tv MXhIGagWrpU/EnV1EhNQFtbi+/itCbDPtVEv/4CZF+joKTVLyFaa2rzmsUx+TWMnFScv k7mWqhID6k4jeHCddn27SyB9GLRav/oyTdfFs3BNweTLAaPwDKWqJTivvLQj3xpDYxof fQNw== X-Gm-Message-State: ABy/qLYkXUY1qx8uzRxs/K+5xyaWB+YIGgc0VhB2+oddQGSBoFw9Is5x ClYB5agTArQJRo8MpbxqE1q/WIY0TkYfMlRa X-Google-Smtp-Source: APBJJlEWMVVqeKj8z9+jTurhA6evp44VtrxH+r5igBjvCOdmByWsF3ZlsryhLh5MEsSDp0J+h+8yBA== X-Received: by 2002:a05:6808:1645:b0:3a3:7977:8995 with SMTP id az5-20020a056808164500b003a379778995mr10537548oib.47.1689564757822; Sun, 16 Jul 2023 20:32:37 -0700 (PDT) Received: from a-VirtualBox.. ([116.233.75.15]) by smtp.gmail.com with ESMTPSA id a28-20020a63705c000000b00528513c6bbcsm11647509pgn.28.2023.07.16.20.32.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jul 2023 20:32:37 -0700 (PDT) From: Zhu Ning To: alsa-devel@alsa-project.org, broonie@kernel.org Cc: pierre-louis.bossart@linux.intel.com, tiwai@suse.com, amadeuszx.slawinski@linux.intel.com, yangxiaohua@everest-semi.com, zhuning@everest-semi.com, Zhu Ning Subject: [PATCH v2 5/5] ASoC: codecs: ES8326: Update jact detection function Date: Mon, 17 Jul 2023 11:32:23 +0800 Message-Id: <20230717033223.42506-5-zhuning0077@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230717033223.42506-1-zhuning0077@gmail.com> References: <20230717033223.42506-1-zhuning0077@gmail.com> MIME-Version: 1.0 Message-ID-Hash: 2E2AFLBGMJHBB4GFSV22V34SSD7HSS2M X-Message-ID-Hash: 2E2AFLBGMJHBB4GFSV22V34SSD7HSS2M X-MailFrom: zhuning0077@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The old jack detection function only supports fixed OMTP/CTIA hardware connection. The new one supports auto OMTP/CTIA headset detection Signed-off-by: Zhu Ning --- sound/soc/codecs/es8326.c | 109 +++++++++++++++++++++++++++++++------- 1 file changed, 89 insertions(+), 20 deletions(-) diff --git a/sound/soc/codecs/es8326.c b/sound/soc/codecs/es8326.c index 50b13296e246..74c03d151005 100644 --- a/sound/soc/codecs/es8326.c +++ b/sound/soc/codecs/es8326.c @@ -41,6 +41,8 @@ struct es8326_priv { bool calibrated; int version; + int hp; + int jack_remove_retry; }; static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(dac_vol_tlv, -9550, 50, 0); @@ -535,6 +537,7 @@ static void es8326_jack_button_handler(struct work_struct *work) cur_button = SND_JACK_BTN_0; break; case 0x6f: + case 0x4b: /* button volume up */ cur_button = SND_JACK_BTN_1; break; @@ -543,6 +546,7 @@ static void es8326_jack_button_handler(struct work_struct *work) cur_button = SND_JACK_BTN_2; break; case 0x1e: + case 0xe2: /* button released or not pressed */ cur_button = 0; break; @@ -552,20 +556,20 @@ static void es8326_jack_button_handler(struct work_struct *work) if ((prev_button == cur_button) && (cur_button != 0)) { press_count++; - if (press_count > 10) { - /* report a press every 500ms */ + if (press_count > 3) { + /* report a press every 120ms */ snd_soc_jack_report(es8326->jack, cur_button, SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2); press_count = 0; } button_to_report = cur_button; queue_delayed_work(system_wq, &es8326->button_press_work, - msecs_to_jiffies(50)); + msecs_to_jiffies(35)); } else if (prev_button != cur_button) { /* mismatch, detect again */ prev_button = cur_button; queue_delayed_work(system_wq, &es8326->button_press_work, - msecs_to_jiffies(50)); + msecs_to_jiffies(35)); } else { /* released or no pressed */ if (button_to_report != 0) { @@ -589,32 +593,96 @@ static void es8326_jack_detect_handler(struct work_struct *work) mutex_lock(&es8326->lock); iface = snd_soc_component_read(comp, ES8326_HPDET_STA); dev_dbg(comp->dev, "gpio flag %#04x", iface); + + if (es8326->jack_remove_retry == 1) { + if (iface & ES8326_HPINSERT_FLAG) + es8326->jack_remove_retry = 2; + else + es8326->jack_remove_retry = 0; + + dev_dbg(comp->dev, "remove event check, set HPJACK_POL normal, cnt = %d\n", + es8326->jack_remove_retry); + /* + * Inverted HPJACK_POL bit to trigger one IRQ to double check HP Removal event + */ + regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, + ES8326_HP_DET_JACK_POL, (es8326->jd_inverted ? + ~es8326->jack_pol : es8326->jack_pol)); + goto exit; + } + if ((iface & ES8326_HPINSERT_FLAG) == 0) { /* Jack unplugged or spurious IRQ */ - dev_dbg(comp->dev, "No headset detected"); + dev_dbg(comp->dev, "No headset detected\n"); + es8326_disable_micbias(es8326->component); if (es8326->jack->status & SND_JACK_HEADPHONE) { + dev_dbg(comp->dev, "Report hp remove event\n"); snd_soc_jack_report(es8326->jack, 0, SND_JACK_HEADSET); - snd_soc_component_write(comp, ES8326_ADC1_SRC, es8326->mic2_src); - es8326_disable_micbias(comp); + /* mute adc when mic path switch */ + regmap_write(es8326->regmap, ES8326_ADC_SCALE, 0x33); + regmap_write(es8326->regmap, ES8326_ADC1_SRC, 0x44); + regmap_write(es8326->regmap, ES8326_ADC2_SRC, 0x66); + es8326->hp = 0; + } + regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x01); + /* + * Inverted HPJACK_POL bit to trigger one IRQ to double check HP Removal event + */ + if (es8326->jack_remove_retry == 0) { + es8326->jack_remove_retry = 1; + dev_dbg(comp->dev, "remove event check, invert HPJACK_POL, cnt = %d\n", + es8326->jack_remove_retry); + regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, + ES8326_HP_DET_JACK_POL, (es8326->jd_inverted ? + es8326->jack_pol : ~es8326->jack_pol)); + + } else { + es8326->jack_remove_retry = 0; } } else if ((iface & ES8326_HPINSERT_FLAG) == ES8326_HPINSERT_FLAG) { + es8326->jack_remove_retry = 0; + if (es8326->hp == 0) { + dev_dbg(comp->dev, "First insert, start OMTP/CTIA type check\n"); + /* + * set auto-check mode, then restart jack_detect_work after 100ms. + * Don't report jack status. + */ + regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x01); + usleep_range(50000, 70000); + regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x00); + queue_delayed_work(system_wq, &es8326->jack_detect_work, + msecs_to_jiffies(100)); + es8326->hp = 1; + goto exit; + } if (es8326->jack->status & SND_JACK_HEADSET) { /* detect button */ + dev_dbg(comp->dev, "button pressed\n"); queue_delayed_work(system_wq, &es8326->button_press_work, 10); + goto exit; + } + if ((iface & ES8326_HPBUTTON_FLAG) == 0x01) { + dev_dbg(comp->dev, "Headphone detected\n"); + snd_soc_jack_report(es8326->jack, + SND_JACK_HEADPHONE, SND_JACK_HEADSET); } else { - if ((iface & ES8326_HPBUTTON_FLAG) == 0x00) { - dev_dbg(comp->dev, "Headset detected"); - snd_soc_jack_report(es8326->jack, - SND_JACK_HEADSET, SND_JACK_HEADSET); - snd_soc_component_write(comp, - ES8326_ADC1_SRC, es8326->mic1_src); - } else { - dev_dbg(comp->dev, "Headphone detected"); - snd_soc_jack_report(es8326->jack, - SND_JACK_HEADPHONE, SND_JACK_HEADSET); - } + dev_dbg(comp->dev, "Headset detected\n"); + snd_soc_jack_report(es8326->jack, + SND_JACK_HEADSET, SND_JACK_HEADSET); + + regmap_write(es8326->regmap, ES8326_ADC_SCALE, 0x33); + regmap_update_bits(es8326->regmap, ES8326_PGA_PDN, + 0x08, 0x08); + regmap_update_bits(es8326->regmap, ES8326_PGAGAIN, + 0x80, 0x80); + regmap_write(es8326->regmap, ES8326_ADC1_SRC, 0x00); + regmap_write(es8326->regmap, ES8326_ADC2_SRC, 0x00); + regmap_update_bits(es8326->regmap, ES8326_PGA_PDN, + 0x08, 0x00); + usleep_range(10000, 15000); } } +exit: mutex_unlock(&es8326->lock); } @@ -633,7 +701,7 @@ static irqreturn_t es8326_irq(int irq, void *dev_id) msecs_to_jiffies(10)); else queue_delayed_work(system_wq, &es8326->jack_detect_work, - msecs_to_jiffies(300)); + msecs_to_jiffies(600)); out: return IRQ_HANDLED; @@ -763,7 +831,8 @@ static int es8326_resume(struct snd_soc_component *component) (ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol) : (ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol | 0x04))); - es8326_irq(es8326->irq, es8326); + es8326->jack_remove_retry = 0; + es8326->hp = 0; return 0; }