From patchwork Sat Jan 20 10:12:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Ning X-Patchwork-Id: 764472 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 2EFB2C47DB7 for ; Sat, 20 Jan 2024 10:14:58 +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 8F44D84A; Sat, 20 Jan 2024 11:14:45 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8F44D84A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1705745695; bh=nktPXpHTG5txLhyDhyAWa2XI7cn2h1kJ2RyPfnbfKZs=; 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=WAIc61qe9oq60HXmmzfJ2edKIGf0SandA9tJR/3o/zLx+3W2zuLK7H9K37iEL1mMu LugHZSiEeXfNyLQZY1EStgjxBNuzKTiJFfuaFbXbNqiEMhOkUGg530NGJzK1EvP1+V VZgf6upbZ/GX1SkObPyF+nhhHoK9EtAT2+a3Cz3U= Received: by alsa1.perex.cz (Postfix, from userid 50401) id CFCC5F805C2; Sat, 20 Jan 2024 11:14:02 +0100 (CET) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id C6CA0F805C3; Sat, 20 Jan 2024 11:14:01 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 799C0F802E8; Sat, 20 Jan 2024 11:13:04 +0100 (CET) Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) (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 37231F800F5 for ; Sat, 20 Jan 2024 11:12:52 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 37231F800F5 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=20230601 header.b=eTUy5V9I Received: by mail-il1-x133.google.com with SMTP id e9e14a558f8ab-361b0f0f971so2496835ab.2 for ; Sat, 20 Jan 2024 02:12:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705745570; x=1706350370; darn=alsa-project.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=MmNb3ymqWtIOO6mpFa0sJnvesbvkzZ3Mqz86FTB3urA=; b=eTUy5V9I9pV3SCNfd+DOIp7Ifgf+8TgACuG6PO+9hlTVBudwxlstYis/HXxL59Qhxx uFeUGoTGGnYdW2BNMNwYAKeY469iiGr24fAIcez/dNjF5IDdCFRKbPbPXxUCY34D7Glq 5sGcsWzfL4ihN1QcxcHJl0JbNlWFCMkckpfgD8mTFig6M80LbMghQeu7dmYQjmosM5pX CUtK9CB783E+U1+xaDoVfcp1hucoeMjce4hQrFy+zrgZRv47TAuN7DX+M7F3BBxwIFpX Lx/4DuFW9QUL+Zdrtco6vXselujFCjQml8549OD1u61vGTTkC0/3Q7UIMHnIQ6N5JFtD wa3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705745570; x=1706350370; h=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=MmNb3ymqWtIOO6mpFa0sJnvesbvkzZ3Mqz86FTB3urA=; b=rbSuupH8dxJZFdSzvhIJkGq8AXaJtRjufDut/d2Fw5XBPNk9KL117L27O53bNHoQyD 5Q9qmXLUJNCjsbdPCQ1v+jEFJioiiIZvLEicPJsGBSHaBpHYvRQWZ2Bp517/6nmizrQO kUXjVO658rHy3OZnnW3RyEcfsuFTwHBX0naP5t1VO/aa+uMk9DEKa18IdywYYcxcdMSU tmLet9moSm17PhhhHxp1JTWB49YA8OuGX5ue/grWQyjE2b0iKOfoQeQQU3ejnX3UKt9W 06fIusH/FpaWtrR30FXVeSDH4m+NbyeSvLswQHp7jmN2Y2UrKEyW7l3Niigs9UUiuysF KoIA== X-Gm-Message-State: AOJu0YwXbLMXTaRoMp00PuvSF0iDCyR0NGKagpZh9Vfl7H4jVKzbLQOH 8QVQg7MzvU/aWB9ShUKAiRICcxq6ToUUnMY4pTsSwbNmJCxuR3POfoJDhQ9ugjOj/Q== X-Google-Smtp-Source: AGHT+IHOucaJWSyKnoknO3nkVh9Qow1B0xqjW5lACj1s9mMOo2AatkcLrm5hxZb4WMLpmIma+gONjQ== X-Received: by 2002:a05:6e02:d45:b0:360:702a:3f81 with SMTP id h5-20020a056e020d4500b00360702a3f81mr1344507ilj.27.1705745570566; Sat, 20 Jan 2024 02:12:50 -0800 (PST) Received: from zy-virtual-machine.localdomain ([222.70.13.170]) by smtp.gmail.com with ESMTPSA id jc17-20020a17090325d100b001d72cf69508sm967365plb.23.2024.01.20.02.12.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 02:12:50 -0800 (PST) From: Zhu Ning To: alsa-devel@alsa-project.org, broonie@kernel.org Cc: tiwai@suse.com, amadeuszx.slawinski@linux.intel.com, yangxiaohua@everest-semi.com, zhuning@everest-semi.com, zhangyi@everest-semi.com, Zhu Ning Subject: [PATCH v1 1/5] ASoC: codecs: ES8326: improving crosstalk performance Date: Sat, 20 Jan 2024 18:12:36 +0800 Message-Id: <20240120101240.12496-2-zhuning0077@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240120101240.12496-1-zhuning0077@gmail.com> References: <20240120101240.12496-1-zhuning0077@gmail.com> Message-ID-Hash: W3SCL62T2LPPIIST5CE52V4Q4IFY7GHB X-Message-ID-Hash: W3SCL62T2LPPIIST5CE52V4Q4IFY7GHB 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.9 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: We change the crosstalk parameter in es8326_resume function to improve crosstalk performance. Adding crosstalk kcontrol to enhance the flexibility of crosstalk debugging in machine. Adding ES8326_DAC_CROSSTALK macro to declare the crosstalk register. Signed-off-by: Zhu Ning --- sound/soc/codecs/es8326.c | 82 +++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/es8326.h | 1 + 2 files changed, 83 insertions(+) diff --git a/sound/soc/codecs/es8326.c b/sound/soc/codecs/es8326.c index fa890f6205e2..82d1c4f8324c 100755 --- a/sound/soc/codecs/es8326.c +++ b/sound/soc/codecs/es8326.c @@ -45,6 +45,82 @@ struct es8326_priv { int jack_remove_retry; }; +static int es8326_crosstalk1_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component); + unsigned int crosstalk_h, crosstalk_l; + unsigned int crosstalk; + + regmap_read(es8326->regmap, ES8326_DAC_RAMPRATE, &crosstalk_h); + regmap_read(es8326->regmap, ES8326_DAC_CROSSTALK, &crosstalk_l); + crosstalk_h &= 0x20; + crosstalk_l &= 0xf0; + crosstalk = crosstalk_h >> 1 | crosstalk_l >> 4; + ucontrol->value.integer.value[0] = crosstalk; + + return 0; +} + +static int es8326_crosstalk1_set(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component); + unsigned int crosstalk_h, crosstalk_l; + unsigned int crosstalk; + + crosstalk = ucontrol->value.integer.value[0]; + regmap_read(es8326->regmap, ES8326_DAC_CROSSTALK, &crosstalk_l); + crosstalk_h = (crosstalk & 0x10) << 1; + crosstalk_l &= 0x0f; + crosstalk_l |= (crosstalk & 0x0f) << 4; + regmap_update_bits(es8326->regmap, ES8326_DAC_RAMPRATE, + 0x20, crosstalk_h); + regmap_write(es8326->regmap, ES8326_DAC_CROSSTALK, crosstalk_l); + + return 0; +} + +static int es8326_crosstalk2_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component); + unsigned int crosstalk_h, crosstalk_l; + unsigned int crosstalk; + + regmap_read(es8326->regmap, ES8326_DAC_RAMPRATE, &crosstalk_h); + regmap_read(es8326->regmap, ES8326_DAC_CROSSTALK, &crosstalk_l); + crosstalk_h &= 0x10; + crosstalk_l &= 0x0f; + crosstalk = crosstalk_h | crosstalk_l; + ucontrol->value.integer.value[0] = crosstalk; + + return 0; +} + +static int es8326_crosstalk2_set(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component); + unsigned int crosstalk_h, crosstalk_l; + unsigned int crosstalk; + + crosstalk = ucontrol->value.integer.value[0]; + regmap_read(es8326->regmap, ES8326_DAC_CROSSTALK, &crosstalk_l); + crosstalk_h = crosstalk & 0x10; + crosstalk_l &= 0xf0; + crosstalk_l |= crosstalk & 0x0f; + regmap_update_bits(es8326->regmap, ES8326_DAC_RAMPRATE, + 0x10, crosstalk_h); + regmap_write(es8326->regmap, ES8326_DAC_CROSSTALK, crosstalk_l); + + return 0; +} + static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(dac_vol_tlv, -9550, 50, 0); static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(adc_vol_tlv, -9550, 50, 0); static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(adc_analog_pga_tlv, 0, 300, 0); @@ -102,6 +178,10 @@ static const struct snd_kcontrol_new es8326_snd_controls[] = { SOC_SINGLE_TLV("ALC Capture Target Level", ES8326_ALC_LEVEL, 0, 0x0f, 0, drc_target_tlv), + SOC_SINGLE_EXT("CROSSTALK1", SND_SOC_NOPM, 0, 31, 0, + es8326_crosstalk1_get, es8326_crosstalk1_set), + SOC_SINGLE_EXT("CROSSTALK2", SND_SOC_NOPM, 0, 31, 0, + es8326_crosstalk2_get, es8326_crosstalk2_set), }; static const struct snd_soc_dapm_widget es8326_dapm_widgets[] = { @@ -844,6 +924,8 @@ static int es8326_resume(struct snd_soc_component *component) regmap_write(es8326->regmap, ES8326_CLK_CAL_TIME, 0x00); /* calibrate for B version */ es8326_calibrate(component); + regmap_write(es8326->regmap, ES8326_DAC_CROSSTALK, 0xaa); + regmap_write(es8326->regmap, ES8326_DAC_RAMPRATE, 0x00); /* turn off headphone out */ regmap_write(es8326->regmap, ES8326_HP_CAL, 0x00); /* set ADC and DAC in low power mode */ diff --git a/sound/soc/codecs/es8326.h b/sound/soc/codecs/es8326.h index 90a08351d6ac..dfef808673f4 100644 --- a/sound/soc/codecs/es8326.h +++ b/sound/soc/codecs/es8326.h @@ -72,6 +72,7 @@ #define ES8326_DAC_VOL 0x50 #define ES8326_DRC_RECOVERY 0x53 #define ES8326_DRC_WINSIZE 0x54 +#define ES8326_DAC_CROSSTALK 0x55 #define ES8326_HPJACK_TIMER 0x56 #define ES8326_HPDET_TYPE 0x57 #define ES8326_INT_SOURCE 0x58 From patchwork Sat Jan 20 10:12:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Ning X-Patchwork-Id: 764276 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 83082C47258 for ; Sat, 20 Jan 2024 10:16:31 +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 64599857; Sat, 20 Jan 2024 11:16:19 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 64599857 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1705745789; bh=biAapYxHeeokdyQw9Z1WAP41WVsRCym8l3FljfSgHUI=; 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=ZoQjrK8Hec7ShCkauwZF3GFk0tBntrjNxPibgaaRdpTwMALAyLQhogkGdpX7cUkmn /+28qlOaNeHvtPNS5jgHPiHunIDrfooxMFOGGjnqKPMaV9BeldTo2ayIGv8H5TrpMU kcEtxhmhJ7Ptcaq2Qt15XAOugizPU30HKzg0OOns= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 47474F8057E; Sat, 20 Jan 2024 11:15:40 +0100 (CET) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 62B74F805A8; Sat, 20 Jan 2024 11:15:39 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 27B49F80236; Sat, 20 Jan 2024 11:13:41 +0100 (CET) Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) (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 D3813F8014B for ; Sat, 20 Jan 2024 11:12:55 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D3813F8014B 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=20230601 header.b=hreshklg Received: by mail-il1-x12e.google.com with SMTP id e9e14a558f8ab-361af86c7f7so3863985ab.3 for ; Sat, 20 Jan 2024 02:12:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705745573; x=1706350373; darn=alsa-project.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=tarW1IWFVdEd8Eg2tTqYDQxdL2RArk29+vqx+X5rhUU=; b=hreshklgsehhTADbtCUMIdeEzbE2IrqNC/o2G3NM6xMaoYS8S3WRQeY1LaS9En+ejo 1K+ggfThw+fqvGfn/vVeZFp1b8UHoTNuha+tx3VXCfsewO6OdZ3IuCbJDGDZyHN5wfx5 3OvOq4055NMC2XaLtN4uTlm6vxkJveI/CJ4BQDtJhYGEvaEeVH4ayURx4hiqMvAo9ynF Ut+p1kg+Tmjy2QHpiI7vEVmJAxlOaNT6jsRF6SJqQQRqj2x/FUc4ZC5Atut+DEVM5PUR lHpIKEW0/W3yaIhwhoyYVAp1Uk1XJAQjnczPjR0sfrtTPVKbfFukBg9xls/z9wgWFzje nPNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705745573; x=1706350373; h=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=tarW1IWFVdEd8Eg2tTqYDQxdL2RArk29+vqx+X5rhUU=; b=dApmMd2RchMP6siXI2QEgFon+IwD7HxckTyC7PNmf4emNVaRKtpW5yV+YzKIgoZK+s EkEY8iwVFC3iqVUbk9EF4RkxQntNGMlDkxuTyON8bODJqrWxeBisBzUNsNqtaOM33IdX Rfk7hhoMBpV9RoDUwEjlqXqk25BfVPI3rKWI6KO7O4+yVIM7cRS4SVRExehceMPNVWog SW0ZerNtSNqKgfnJR2bT18OdxxarW7u4UpTr11Ii8FJs9m7P1x2vbnPG40HqbO/X+n1K RtM3LcRwcGSU0jgWS5fr0ghCBmjIC/RUFMYgBxpiJwRbatou8C1aSjeF2eZ/+op/7yN5 EIPg== X-Gm-Message-State: AOJu0YyZUNSO+N4i+AanzJthr/G4kZTy0nIVyqQUGT5ISnkdgfkACYtk G3jyBuRpbFCZElgSzp1Z+hASkai8JK3LUauQK2zhGXvXJgNTA4rkVnVxFsnu3jyv0g== X-Google-Smtp-Source: AGHT+IGgC6ECdtCWi1zIV7aUGnDdXVxTy/augsh5rQItYRUMtYA69PDQmosTPAcw4qu4iVF0PjkelA== X-Received: by 2002:a05:6e02:c73:b0:35f:d8fd:8ecc with SMTP id f19-20020a056e020c7300b0035fd8fd8eccmr1578082ilj.0.1705745573503; Sat, 20 Jan 2024 02:12:53 -0800 (PST) Received: from zy-virtual-machine.localdomain ([222.70.13.170]) by smtp.gmail.com with ESMTPSA id jc17-20020a17090325d100b001d72cf69508sm967365plb.23.2024.01.20.02.12.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 02:12:53 -0800 (PST) From: Zhu Ning To: alsa-devel@alsa-project.org, broonie@kernel.org Cc: tiwai@suse.com, amadeuszx.slawinski@linux.intel.com, yangxiaohua@everest-semi.com, zhuning@everest-semi.com, zhangyi@everest-semi.com, Zhu Ning Subject: [PATCH v1 2/5] ASoC: codecs: ES8326: Improving the THD+N performance Date: Sat, 20 Jan 2024 18:12:37 +0800 Message-Id: <20240120101240.12496-3-zhuning0077@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240120101240.12496-1-zhuning0077@gmail.com> References: <20240120101240.12496-1-zhuning0077@gmail.com> Message-ID-Hash: FYPLCISXISSZFYDT5N2WM5MX47EKXBWI X-Message-ID-Hash: FYPLCISXISSZFYDT5N2WM5MX47EKXBWI 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.9 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: We update the values of some registers in the initialization sequence in es8326_resume function to improve THD+N performance. THD+N performance decreases if the output level on headphone is close to full scale. So we change the register setting in es8326_jack_detect_handler function to improve THD+N performance if headphone pulgged. Also, the register setting should be restored when the headset is unplugged Signed-off-by: Zhu Ning --- sound/soc/codecs/es8326.c | 21 +++++++++++++-------- sound/soc/codecs/es8326.h | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/sound/soc/codecs/es8326.c b/sound/soc/codecs/es8326.c index 82d1c4f8324c..10157a4bd500 100755 --- a/sound/soc/codecs/es8326.c +++ b/sound/soc/codecs/es8326.c @@ -752,6 +752,8 @@ static void es8326_jack_detect_handler(struct work_struct *work) es8326->hp = 0; } regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x01); + regmap_write(es8326->regmap, ES8326_SYS_BIAS, 0x0a); + regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, 0x0f, 0x03); /* * Inverted HPJACK_POL bit to trigger one IRQ to double check HP Removal event */ @@ -777,6 +779,8 @@ static void es8326_jack_detect_handler(struct work_struct *work) regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x01); usleep_range(50000, 70000); regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x00); + regmap_write(es8326->regmap, ES8326_SYS_BIAS, 0x1f); + regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, 0x0f, 0x08); queue_delayed_work(system_wq, &es8326->jack_detect_work, msecs_to_jiffies(400)); es8326->hp = 1; @@ -846,14 +850,14 @@ static int es8326_calibrate(struct snd_soc_component *component) 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_DIV1, 0x03); regmap_write(es8326->regmap, ES8326_CLK_DLL, 0x30); regmap_write(es8326->regmap, ES8326_CLK_MUX, 0xed); regmap_write(es8326->regmap, ES8326_CLK_DAC_SEL, 0x08); 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, 0x03); + regmap_write(es8326->regmap, ES8326_VMIDLOW, 0x23); regmap_write(es8326->regmap, ES8326_DAC2HPMIX, 0x88); usleep_range(15000, 20000); regmap_write(es8326->regmap, ES8326_HP_OFFSET_CAL, 0x8c); @@ -894,13 +898,13 @@ static int es8326_resume(struct snd_soc_component *component) /* reset internal clock state */ regmap_write(es8326->regmap, ES8326_RESET, 0x1f); regmap_write(es8326->regmap, ES8326_VMIDSEL, 0x0E); + regmap_write(es8326->regmap, ES8326_ANA_LP, 0xf0); usleep_range(10000, 15000); regmap_write(es8326->regmap, ES8326_HPJACK_TIMER, 0xe9); - regmap_write(es8326->regmap, ES8326_ANA_MICBIAS, 0x4b); + regmap_write(es8326->regmap, ES8326_ANA_MICBIAS, 0xcb); /* set headphone default type and detect pin */ regmap_write(es8326->regmap, ES8326_HPDET_TYPE, 0x83); regmap_write(es8326->regmap, ES8326_CLK_RESAMPLE, 0x05); - regmap_write(es8326->regmap, ES8326_HP_MISC, 0x30); /* set internal oscillator as clock source of headpone cp */ regmap_write(es8326->regmap, ES8326_CLK_DIV_CPC, 0x89); @@ -908,14 +912,15 @@ static int es8326_resume(struct snd_soc_component *component) /* 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, 0x30); + regmap_write(es8326->regmap, ES8326_HP_MISC, 0x3d); regmap_write(es8326->regmap, ES8326_PULLUP_CTL, 0x00); /* enable headphone driver */ + regmap_write(es8326->regmap, ES8326_HP_VOL, 0xc4); regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa7); usleep_range(2000, 5000); - regmap_write(es8326->regmap, ES8326_HP_DRIVER_REF, 0xa3); - regmap_write(es8326->regmap, ES8326_HP_DRIVER_REF, 0xb3); + regmap_write(es8326->regmap, ES8326_HP_DRIVER_REF, 0x23); + regmap_write(es8326->regmap, ES8326_HP_DRIVER_REF, 0x33); regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa1); regmap_write(es8326->regmap, ES8326_CLK_INV, 0x00); @@ -946,7 +951,7 @@ static int es8326_resume(struct snd_soc_component *component) (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_ANA_PDN, 0x00); regmap_write(es8326->regmap, ES8326_RESET, ES8326_CSM_ON); regmap_update_bits(es8326->regmap, ES8326_PGAGAIN, ES8326_MIC_SEL_MASK, ES8326_MIC1_SEL); diff --git a/sound/soc/codecs/es8326.h b/sound/soc/codecs/es8326.h index dfef808673f4..4234bbb900c4 100644 --- a/sound/soc/codecs/es8326.h +++ b/sound/soc/codecs/es8326.h @@ -101,7 +101,7 @@ #define ES8326_MUTE (3 << 0) /* ES8326_CLK_CTL */ -#define ES8326_CLK_ON (0x7f << 0) +#define ES8326_CLK_ON (0x7e << 0) #define ES8326_CLK_OFF (0 << 0) /* ES8326_CLK_INV */ From patchwork Sat Jan 20 10:12:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Ning X-Patchwork-Id: 764277 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 06181C47258 for ; Sat, 20 Jan 2024 10:15: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 E72C2822; Sat, 20 Jan 2024 11:14:56 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E72C2822 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1705745707; bh=4XTMv/27kW3P5osWJ1kSddhcEjOZbvIuwRXxZPpGMlQ=; 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=kT2KrWF4MMGmorwxF+Zq//qBZKZuRMCsFDC+ZvU4lCV20UHsyQjVhP30ILrGP2ru9 C0DdxOhoma2vl+uvHPxxIB9f8FVz/WdbGBXgZw/IyF+QhFIRFonJUmp45r4iQAiN5y ZDN35pC9NdLIbtTkvz4pfU42uNnHZpX2PRHEQ/Lk= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 43DA4F805E7; Sat, 20 Jan 2024 11:14:04 +0100 (CET) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 6ACBAF805F5; Sat, 20 Jan 2024 11:14:03 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 16764F802BE; Sat, 20 Jan 2024 11:13:09 +0100 (CET) Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) (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 0557FF80074 for ; Sat, 20 Jan 2024 11:13:00 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0557FF80074 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=20230601 header.b=PZv0iu+J Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-5ce74ea4bf2so1089567a12.0 for ; Sat, 20 Jan 2024 02:13:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705745576; x=1706350376; darn=alsa-project.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=mL1Pe0qczNWUMTVPbR6DgJnFhcx08H1tylBUx7/ziTo=; b=PZv0iu+JjpTgZEM9Z/fi5S+whtJW1baovv+kvI3pV/dDu4MTLREXLk8jpeXHOTmfyj YcyugN0uMuBwMIiBcmOsZ6L5ADcsaerirBbGTd6utIF1IqF/+yAwChfnf5R221exmulm lLJ4NNqQIiek28kfMKvWbZn0qKVlzlSUeTmIjsd9JD+mzBXKv4TU4ZjHqIbiJc4n7RZl 5vLsbbXI3Uxkxoc/74eMwltK57zsMJ0UHr4ngoa0ncqk7zkZApvvpHGdAv1nirwpIpzM exopK6AYYS9DwdB+TdXpF9Lcp9DbedPWz47LHe8L48yBXBG55rQ22o3E6GQUFoR30LmB xv6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705745576; x=1706350376; h=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=mL1Pe0qczNWUMTVPbR6DgJnFhcx08H1tylBUx7/ziTo=; b=THVxbgZeMZSXfop6C/xAzlD8DBmMgfkVaB1uFlgSXfqw40sSoAy/JYphyxLKWp96qZ 8kZPA8aBNfXlD2ueaJHF2hsi+LnRbI2KG3+PS/SJrVC84QflQBwH80wsX1qPb7Begaak zzI0q3bkl7jkSNtLXfs46o5jAyvpLI8WOIKPdNUjsp7qRdLbVYd7Ocn/7iAImoEa3lUo H8TqROcLfsJYXcvW7zzuqubm4ZoH4s8nNRTyRtFy7Th4uhV42zjsojmHfMcP3ZWkiB+r QTumHHHzOmR0KAWM2b1gHBtfnAV4hj3BDrg/k/sKYrJobWPBNPApRwFnoczQb/GZhEEp /Xew== X-Gm-Message-State: AOJu0YwdQlaaj0oo7tkvyGIppMX1ggREUn+1D8SJUs1EpQTmnbEeyIZq ht2pKSPoO3dTAqovzo6ABuVNdsrZdagDhUA5Wg6MYBqA4PwJxYn4A96vAi9ODpLEtA== X-Google-Smtp-Source: AGHT+IHeCmQ1DMOPuaYVZ7vXg/L9UHqgrChyCXK4VKCTUIImDtAFtV0oIDMe4GctpmoZw4VS5BdywQ== X-Received: by 2002:a17:90a:9306:b0:28d:d3bb:7359 with SMTP id p6-20020a17090a930600b0028dd3bb7359mr1607351pjo.8.1705745576336; Sat, 20 Jan 2024 02:12:56 -0800 (PST) Received: from zy-virtual-machine.localdomain ([222.70.13.170]) by smtp.gmail.com with ESMTPSA id jc17-20020a17090325d100b001d72cf69508sm967365plb.23.2024.01.20.02.12.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 02:12:56 -0800 (PST) From: Zhu Ning To: alsa-devel@alsa-project.org, broonie@kernel.org Cc: tiwai@suse.com, amadeuszx.slawinski@linux.intel.com, yangxiaohua@everest-semi.com, zhuning@everest-semi.com, zhangyi@everest-semi.com, Zhu Ning Subject: [PATCH v1 3/5] ASoC: codecs: ES8326: Adding new volume kcontrols Date: Sat, 20 Jan 2024 18:12:38 +0800 Message-Id: <20240120101240.12496-4-zhuning0077@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240120101240.12496-1-zhuning0077@gmail.com> References: <20240120101240.12496-1-zhuning0077@gmail.com> Message-ID-Hash: PJ6KZ36YTJYD7R2JEBD4SEANK6ANG6X6 X-Message-ID-Hash: PJ6KZ36YTJYD7R2JEBD4SEANK6ANG6X6 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.9 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: ES8326 features a headphone volume control register and four DAC volume control registers. We add new volume Kcontrols for these registers to enhance the configurability of the volume settings, providing users with greater flexibility. Signed-off-by: Zhu Ning --- sound/soc/codecs/es8326.c | 88 ++++++++++++++++++++++++++++++++++++++- sound/soc/codecs/es8326.h | 5 ++- 2 files changed, 91 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/es8326.c b/sound/soc/codecs/es8326.c index 10157a4bd500..51dc8081e475 100755 --- a/sound/soc/codecs/es8326.c +++ b/sound/soc/codecs/es8326.c @@ -121,6 +121,72 @@ static int es8326_crosstalk2_set(struct snd_kcontrol *kcontrol, return 0; } +static int es8326_hplvol_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component); + unsigned int hp_vol; + + regmap_read(es8326->regmap, ES8326_HP_VOL, &hp_vol); + hp_vol &= 0x70; + ucontrol->value.integer.value[0] = hp_vol >> 4; + + return 0; +} + +static int es8326_hplvol_set(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component); + unsigned int hp_vol; + + if (ucontrol->value.integer.value[0] == 3) { + dev_dbg(component->dev, "HPL_VOL does not change"); + return 0; + } + regmap_read(es8326->regmap, ES8326_HP_VOL, &hp_vol); + hp_vol &= 0x8F; + hp_vol |= ucontrol->value.integer.value[0] << 4; + regmap_write(es8326->regmap, ES8326_HP_VOL, hp_vol); + + return 0; +} + +static int es8326_hprvol_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component); + unsigned int hp_vol; + + regmap_read(es8326->regmap, ES8326_HP_VOL, &hp_vol); + hp_vol &= 0x07; + ucontrol->value.integer.value[0] = hp_vol; + + return 0; +} + +static int es8326_hprvol_set(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component); + unsigned int hp_vol; + + if (ucontrol->value.integer.value[0] == 3) { + dev_dbg(component->dev, "HPR_VOL does not change"); + return 0; + } + regmap_read(es8326->regmap, ES8326_HP_VOL, &hp_vol); + hp_vol &= 0xF8; + hp_vol |= ucontrol->value.integer.value[0]; + regmap_write(es8326->regmap, ES8326_HP_VOL, hp_vol); + + return 0; +} + static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(dac_vol_tlv, -9550, 50, 0); static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(adc_vol_tlv, -9550, 50, 0); static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(adc_analog_pga_tlv, 0, 300, 0); @@ -151,15 +217,24 @@ static const char *const winsize[] = { static const char *const dacpol_txt[] = { "Normal", "R Invert", "L Invert", "L + R Invert" }; +static const char *const hp_spkvol_switch[] = { + "HPVOL: HPL+HPL, SPKVOL: HPL+HPL", + "HPVOL: HPL+HPR, SPKVOL: HPL+HPR", + "HPVOL: HPL+HPL, SPKVOL: SPKL+SPKR", + "HPVOL: HPL+HPR, SPKVOL: SPKL+SPKR", +}; + static const struct soc_enum dacpol = SOC_ENUM_SINGLE(ES8326_DAC_DSM, 4, 4, dacpol_txt); static const struct soc_enum alc_winsize = SOC_ENUM_SINGLE(ES8326_ADC_RAMPRATE, 4, 16, winsize); static const struct soc_enum drc_winsize = SOC_ENUM_SINGLE(ES8326_DRC_WINSIZE, 4, 16, winsize); +static const struct soc_enum hpvol_spkvol_switch = + SOC_ENUM_SINGLE(ES8326_HP_MISC, 6, 4, hp_spkvol_switch); static const struct snd_kcontrol_new es8326_snd_controls[] = { - SOC_SINGLE_TLV("DAC Playback Volume", ES8326_DAC_VOL, 0, 0xbf, 0, dac_vol_tlv), + SOC_SINGLE_TLV("DAC Playback Volume", ES8326_DACL_VOL, 0, 0xbf, 0, dac_vol_tlv), SOC_ENUM("Playback Polarity", dacpol), SOC_SINGLE_TLV("DAC Ramp Rate", ES8326_DAC_RAMPRATE, 0, 0x0f, 0, softramp_rate), SOC_SINGLE_TLV("DRC Recovery Level", ES8326_DRC_RECOVERY, 0, 4, 0, drc_recovery_tlv), @@ -182,6 +257,17 @@ static const struct snd_kcontrol_new es8326_snd_controls[] = { es8326_crosstalk1_get, es8326_crosstalk1_set), SOC_SINGLE_EXT("CROSSTALK2", SND_SOC_NOPM, 0, 31, 0, es8326_crosstalk2_get, es8326_crosstalk2_set), + SOC_SINGLE_EXT("HPL Volume", SND_SOC_NOPM, 0, 6, 0, + es8326_hplvol_get, es8326_hplvol_set), + SOC_SINGLE_EXT("HPR Volume", SND_SOC_NOPM, 0, 6, 0, + es8326_hprvol_get, es8326_hprvol_set), + + SOC_SINGLE_TLV("HPL Playback Volume", ES8326_DACL_VOL, 0, 0xbf, 0, dac_vol_tlv), + SOC_SINGLE_TLV("HPR Playback Volume", ES8326_DACR_VOL, 0, 0xbf, 0, dac_vol_tlv), + SOC_SINGLE_TLV("SPKL Playback Volume", ES8326_SPKL_VOL, 0, 0xbf, 0, dac_vol_tlv), + SOC_SINGLE_TLV("SPKR Playback Volume", ES8326_SPKR_VOL, 0, 0xbf, 0, dac_vol_tlv), + + SOC_ENUM("HPVol SPKVol switch", hpvol_spkvol_switch), }; static const struct snd_soc_dapm_widget es8326_dapm_widgets[] = { diff --git a/sound/soc/codecs/es8326.h b/sound/soc/codecs/es8326.h index 4234bbb900c4..ee12caef8105 100644 --- a/sound/soc/codecs/es8326.h +++ b/sound/soc/codecs/es8326.h @@ -69,7 +69,7 @@ #define ES8326_DAC_DSM 0x4D #define ES8326_DAC_RAMPRATE 0x4E #define ES8326_DAC_VPPSCALE 0x4F -#define ES8326_DAC_VOL 0x50 +#define ES8326_DACL_VOL 0x50 #define ES8326_DRC_RECOVERY 0x53 #define ES8326_DRC_WINSIZE 0x54 #define ES8326_DAC_CROSSTALK 0x55 @@ -81,6 +81,9 @@ #define ES8326_SDINOUT23_IO 0x5B #define ES8326_JACK_PULSE 0x5C +#define ES8326_DACR_VOL 0xF4 +#define ES8326_SPKL_VOL 0xF5 +#define ES8326_SPKR_VOL 0xF6 #define ES8326_HP_MISC 0xF7 #define ES8326_CTIA_OMTP_STA 0xF8 #define ES8326_PULLUP_CTL 0xF9 From patchwork Sat Jan 20 10:12:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Ning X-Patchwork-Id: 764471 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 3C6D9C47258 for ; Sat, 20 Jan 2024 10:16:10 +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 79249820; Sat, 20 Jan 2024 11:15:58 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 79249820 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1705745768; bh=ygvcz+NWIUIH6LHyik5hfLBedU4S6dABw75FZJaznoU=; 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=VIMNR99aMrVeareAIDJbs3TYWaa05xaPvN+novEJC/iJnMZpzJcVB9Kw0xfMZvlYW 7Qxx4fyli+UycX7V73Ljj/2KVdxBdKDUpwaa3u8BWWCkJ8bIVUeLNN6SScKuud1V5T m4YM/iGGvizOSzc/S1jr0fxfoXDqZiLqYSiKXHRE= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 537B6F8059F; Sat, 20 Jan 2024 11:15:38 +0100 (CET) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id C94D8F805A0; Sat, 20 Jan 2024 11:15:37 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D114EF8028D; Sat, 20 Jan 2024 11:13:13 +0100 (CET) Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) (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 DE43FF801F5 for ; Sat, 20 Jan 2024 11:13:01 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DE43FF801F5 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=20230601 header.b=msG4mcH7 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d50d0c98c3so21804315ad.1 for ; Sat, 20 Jan 2024 02:13:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705745579; x=1706350379; darn=alsa-project.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=6Rxg5H5p4tbdSlrf4IdnunK3FrEk/iuoyb/MbENhqw8=; b=msG4mcH7Nc4699UuYxCiAt3nrSLG15Pu03Reok9ZBQ41WtCmigvCkhEE55HnHsYjbW 2wqvrSTXfe9eOKVJ+FYb+3Qx7dYN1RMM/k6m2kGBd//0NKIS++qeDSg/qZvQwUlpvgfi 7z/0sdVaZLDrYQ//uXRY71xTPJasw4OWkcc5UjZZYOp2vXVkYn38kOFzT8S0tHBHjN4C RPFd/L67iZG2E4LWkpzTsPU9/KETLe4fEMq03e1BlAOifPQdCZUcB2e2ET5A5Ms+KQ6C S5Juk3/R+8Vowgf43liRzkTT6AVJtRGQiodKSwHjoqIrEPkixNuvcMM98xpjDosiv4m0 Bwiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705745579; x=1706350379; h=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=6Rxg5H5p4tbdSlrf4IdnunK3FrEk/iuoyb/MbENhqw8=; b=m5iL+scAk2no5qYYvVX+3h6fKgqbXwmrhwc5x4ZwXdxyqzrML6mErXuKBcVdp3BF+G SBaz5Cky7TgeWKVMHiiUAdr7OIdE7H6AyScNTIEUOiL//GfGuHKt4KDM1e5FoRArhmAH 0V6V+ljRRf24YeX9C47iiXUmgsxYuZWHbMs5c9Hxs6ui2rqWQUQbKOo9gvKY5AERAzye opJ04SNewkgAi5qOV3Gf2l/8kpESbhzAjcQGX+QaFOOmrCx0/kTR8zJ4Da9l0pSf7yvN gNNQ6JDhuavuwZI8Mm7R8IrkT9QofsP0ISd4ICYusbBq7OO3nDKkcp37qRyAQOM9xO9R cHpA== X-Gm-Message-State: AOJu0Yxg68e5CR2W7Afp4wcOScB7xQFe1SWORd7wngfpBur6SYma9oNM WuwZ2C7pdIpguzXRWcWFYGQ/USQrWMDdUAGVYth15yYNGW7bxjhpgaGHYbNuNjGRKQ== X-Google-Smtp-Source: AGHT+IH0l2k8S9nVJIlspPFCcXsi7wS+0gjodae9/FnsCYiZASPE78/YdgGE7PEot97SaulXPWlw5g== X-Received: by 2002:a17:902:ecc9:b0:1d7:323a:ecdc with SMTP id a9-20020a170902ecc900b001d7323aecdcmr453050plh.53.1705745579184; Sat, 20 Jan 2024 02:12:59 -0800 (PST) Received: from zy-virtual-machine.localdomain ([222.70.13.170]) by smtp.gmail.com with ESMTPSA id jc17-20020a17090325d100b001d72cf69508sm967365plb.23.2024.01.20.02.12.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 02:12:58 -0800 (PST) From: Zhu Ning To: alsa-devel@alsa-project.org, broonie@kernel.org Cc: tiwai@suse.com, amadeuszx.slawinski@linux.intel.com, yangxiaohua@everest-semi.com, zhuning@everest-semi.com, zhangyi@everest-semi.com, Zhu Ning Subject: [PATCH v1 4/5] ASoC: codecs: ES8326: Minimize the pop noise on headphone Date: Sat, 20 Jan 2024 18:12:39 +0800 Message-Id: <20240120101240.12496-5-zhuning0077@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240120101240.12496-1-zhuning0077@gmail.com> References: <20240120101240.12496-1-zhuning0077@gmail.com> Message-ID-Hash: QS7TTXR3AS3YO4A6DFJMVPC5QY2OYGOQ X-Message-ID-Hash: QS7TTXR3AS3YO4A6DFJMVPC5QY2OYGOQ 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.9 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: We modify the register settings to minimize headphone pop noise during ES8326 power-up and music start/stop. Signed-off-by: Zhu Ning --- sound/soc/codecs/es8326.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/sound/soc/codecs/es8326.c b/sound/soc/codecs/es8326.c index 51dc8081e475..33c4ebddab40 100755 --- a/sound/soc/codecs/es8326.c +++ b/sound/soc/codecs/es8326.c @@ -609,7 +609,8 @@ static int es8326_mute(struct snd_soc_dai *dai, int mute, int direction) regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_OFF); regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE, ES8326_MUTE_MASK, ES8326_MUTE); - regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xf0); + regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, + 0x30, 0x00); } else { if (!es8326->calibrated) { regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_FORCE_CAL); @@ -622,8 +623,13 @@ static int es8326_mute(struct snd_soc_dai *dai, int mute, int direction) regmap_write(es8326->regmap, ES8326_HPR_OFFSET_INI, offset_r); es8326->calibrated = true; } + regmap_update_bits(es8326->regmap, ES8326_DAC_DSM, 0x01, 0x01); + usleep_range(1000, 5000); + regmap_update_bits(es8326->regmap, ES8326_DAC_DSM, 0x01, 0x00); + usleep_range(1000, 5000); + regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, 0x30, 0x20); + regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, 0x30, 0x30); regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa1); - regmap_write(es8326->regmap, ES8326_HP_VOL, 0x91); regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_ON); regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE, ES8326_MUTE_MASK, ~(ES8326_MUTE)); @@ -643,23 +649,20 @@ static int es8326_set_bias_level(struct snd_soc_component *codec, if (ret) return ret; - regmap_update_bits(es8326->regmap, ES8326_DAC_DSM, 0x01, 0x00); + regmap_update_bits(es8326->regmap, ES8326_RESET, 0x02, 0x02); + usleep_range(5000, 10000); 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_VMIDSEL, 0x0E); regmap_write(es8326->regmap, ES8326_PGA_PDN, 0x40); regmap_write(es8326->regmap, ES8326_ANA_PDN, 0x00); regmap_update_bits(es8326->regmap, ES8326_CLK_CTL, 0x20, 0x20); - - regmap_update_bits(es8326->regmap, ES8326_RESET, - ES8326_CSM_ON, ES8326_CSM_ON); + regmap_update_bits(es8326->regmap, ES8326_RESET, 0x02, 0x00); break; case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: regmap_write(es8326->regmap, ES8326_ANA_PDN, 0x3b); - regmap_write(es8326->regmap, ES8326_VMIDSEL, 0x00); regmap_update_bits(es8326->regmap, ES8326_CLK_CTL, 0x20, 0x00); regmap_write(es8326->regmap, ES8326_SDINOUT1_IO, ES8326_IO_INPUT); break; @@ -863,6 +866,7 @@ static void es8326_jack_detect_handler(struct work_struct *work) * Don't report jack status. */ regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x01); + es8326_enable_micbias(es8326->component); usleep_range(50000, 70000); regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x00); regmap_write(es8326->regmap, ES8326_SYS_BIAS, 0x1f); @@ -906,13 +910,10 @@ static void es8326_jack_detect_handler(struct work_struct *work) static irqreturn_t es8326_irq(int irq, void *dev_id) { struct es8326_priv *es8326 = dev_id; - struct snd_soc_component *comp = es8326->component; if (!es8326->jack) goto out; - es8326_enable_micbias(comp); - if (es8326->jack->status & SND_JACK_HEADSET) queue_delayed_work(system_wq, &es8326->jack_detect_work, msecs_to_jiffies(10)); @@ -1029,6 +1030,14 @@ static int es8326_resume(struct snd_soc_component *component) regmap_write(es8326->regmap, ES8326_DAC_DSM, 0x08); regmap_write(es8326->regmap, ES8326_DAC_VPPSCALE, 0x15); + 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))); + usleep_range(5000, 10000); + es8326_enable_micbias(es8326->component); + usleep_range(50000, 70000); + regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x00); regmap_write(es8326->regmap, ES8326_INT_SOURCE, (ES8326_INT_SRC_PIN9 | ES8326_INT_SRC_BUTTON)); regmap_write(es8326->regmap, ES8326_INTOUT_IO, @@ -1045,11 +1054,6 @@ static int es8326_resume(struct snd_soc_component *component) 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))); - regmap_write(es8326->regmap, ES8326_HP_VOL, 0x11); es8326->jack_remove_retry = 0; es8326->hp = 0; From patchwork Sat Jan 20 10:12:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Ning X-Patchwork-Id: 764470 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 28366C47DB7 for ; Sat, 20 Jan 2024 10:16:42 +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 5778F83B; Sat, 20 Jan 2024 11:16:30 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5778F83B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1705745800; bh=HaxmkBU4NtqPbYo58I/nC/41mHNjaslWLh6YNP3krV4=; 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=JC5CPCcZCt2IWkihLhIII+NQUWJ5fF38hvKEuLqrxeDuGxGitb9HQrbaR/14uP8g/ M8nWt9vD9tahacSP4PGZOBkvSoeT4nd6NnUgqFYp5f8pYHiaHIE7WaS3ZjhDvzMgno Js/Lcz5ivcqDT5Sg35xwhVhC/cbf/zNvaNNwn8IY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id A3A41F805DF; Sat, 20 Jan 2024 11:15:42 +0100 (CET) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 3DDB8F805E1; Sat, 20 Jan 2024 11:15:42 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E31EEF80548; Sat, 20 Jan 2024 11:14:55 +0100 (CET) Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) (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 53F66F800F5 for ; Sat, 20 Jan 2024 11:13:03 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 53F66F800F5 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=20230601 header.b=E5A1NjzO Received: by mail-io1-xd2f.google.com with SMTP id ca18e2360f4ac-7bb5fda069bso86701939f.0 for ; Sat, 20 Jan 2024 02:13:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705745582; x=1706350382; darn=alsa-project.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=4JOKB58cvW2V6tKWmuZJJ+pX8d6gLjIVuLPMZDSDgJ4=; b=E5A1NjzO+XOphBM0rqk9SFdI6sJJYALCzlxFZSgtiLPElRc9zircbxfAB1f26MipmO 5nHJKNCUbsKTL9zeGvuy2nS+99kggctoO9/yIXCIWuYREBQB3mwgKZEIIS+0y7kIu7CG RVS1oWYNhy79a8VKR+NfJRdcdNc8qN2+BsHjjNkQzz2wuhTdWF3/N51pUQHBvbyFl/kj PZOrrATGGrCwTqufZdtn0G7gUEwIgoJEKO+BGGXbCpkzbeALTZmAKeIIteIEUlQri12O 2hlLt6s+EjN6BK/8uEUSHWrrzbnmx3oj8KBXh5yK+NxBGjgMyk0qgDQANkdGuW6BOgLH WXhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705745582; x=1706350382; h=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=4JOKB58cvW2V6tKWmuZJJ+pX8d6gLjIVuLPMZDSDgJ4=; b=XIPwsSvXHAfMu8/H4o6WpatWLNAZ27Bfn5w/WaoPosflyK3VfpUqxN+FIMO2zYJXhX GxkoFlHVLqblVbVpNLKmVB2dT02jLjiv1nE+yHyRkqqnF4Sf0hclfZX+CZe4t+FMLZj6 gn38PGN+Kz8cgn6PDFkplunK7u3Z04mLXLblOekg8uvdQTTOyoUMgDwR5qEYSxL9Z8cR mVUTCOI2Z7hEy9AMqFzoDOCF2IFameyEt5XWaBKZGID0au8h4vnlMtid64TFpqGUVLcb T3Hu04ijBa8MAmrxBXqHi+M+zIfUuXe/vJYqagK/CH/+ZDJDDVxmWedl5i5SjQiy101d IdbQ== X-Gm-Message-State: AOJu0YxKQkbt5IB2zzi99Xch5edeqy4jHetzZwnc7MVQUxenQ/eIarcA 42P9LFAGDP5S+Un4el5BfAPak2Ghfh2Dtz7SFJxbgvcaue1G3FGs5/1Q3752euv8Lw== X-Google-Smtp-Source: AGHT+IEt4Ff+sHOXR/qTe9hEUB0lJ0JGjFWfEq0YTi3OKPlro3xPqfIYsJhZavAwYFVQcWTNQp++DQ== X-Received: by 2002:a5d:9ed0:0:b0:7bb:bca0:7670 with SMTP id a16-20020a5d9ed0000000b007bbbca07670mr1537204ioe.23.1705745582076; Sat, 20 Jan 2024 02:13:02 -0800 (PST) Received: from zy-virtual-machine.localdomain ([222.70.13.170]) by smtp.gmail.com with ESMTPSA id jc17-20020a17090325d100b001d72cf69508sm967365plb.23.2024.01.20.02.13.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 02:13:01 -0800 (PST) From: Zhu Ning To: alsa-devel@alsa-project.org, broonie@kernel.org Cc: tiwai@suse.com, amadeuszx.slawinski@linux.intel.com, yangxiaohua@everest-semi.com, zhuning@everest-semi.com, zhangyi@everest-semi.com, Zhu Ning Subject: [PATCH v1 5/5] ASoC: codecs: ES8326: fix the capture noise issue Date: Sat, 20 Jan 2024 18:12:40 +0800 Message-Id: <20240120101240.12496-6-zhuning0077@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240120101240.12496-1-zhuning0077@gmail.com> References: <20240120101240.12496-1-zhuning0077@gmail.com> Message-ID-Hash: GSFF7GVE3AYH5LWJS6EBCVNVAAN35FRQ X-Message-ID-Hash: GSFF7GVE3AYH5LWJS6EBCVNVAAN35FRQ 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.9 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: We get a noise issue during the startup of recording. We update the register setting and dapm widgets to fix this issue. we change callback type of es8326_mute function to mute_stream. ES8326_ADC_MUTE is moved to es8326_mute function so it can be turned on at last and turned off at first. Signed-off-by: Zhu Ning --- sound/soc/codecs/es8326.c | 63 ++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/sound/soc/codecs/es8326.c b/sound/soc/codecs/es8326.c index 33c4ebddab40..d51b3e13d1a1 100755 --- a/sound/soc/codecs/es8326.c +++ b/sound/soc/codecs/es8326.c @@ -283,12 +283,6 @@ static const struct snd_soc_dapm_widget es8326_dapm_widgets[] = { SND_SOC_DAPM_AIF_OUT("I2S OUT", "I2S1 Capture", 0, SND_SOC_NOPM, 0, 0), SND_SOC_DAPM_AIF_IN("I2S IN", "I2S1 Playback", 0, SND_SOC_NOPM, 0, 0), - /* ADC Digital Mute */ - SND_SOC_DAPM_PGA("ADC L1", ES8326_ADC_MUTE, 0, 1, NULL, 0), - SND_SOC_DAPM_PGA("ADC R1", ES8326_ADC_MUTE, 1, 1, NULL, 0), - SND_SOC_DAPM_PGA("ADC L2", ES8326_ADC_MUTE, 2, 1, NULL, 0), - SND_SOC_DAPM_PGA("ADC R2", ES8326_ADC_MUTE, 3, 1, NULL, 0), - /* Analog Power Supply*/ SND_SOC_DAPM_DAC("Right DAC", NULL, ES8326_ANA_PDN, 0, 1), SND_SOC_DAPM_DAC("Left DAC", NULL, ES8326_ANA_PDN, 1, 1), @@ -308,15 +302,10 @@ static const struct snd_soc_dapm_widget es8326_dapm_widgets[] = { }; static const struct snd_soc_dapm_route es8326_dapm_routes[] = { - {"ADC L1", NULL, "MIC1"}, - {"ADC R1", NULL, "MIC2"}, - {"ADC L2", NULL, "MIC3"}, - {"ADC R2", NULL, "MIC4"}, - - {"ADC L", NULL, "ADC L1"}, - {"ADC R", NULL, "ADC R1"}, - {"ADC L", NULL, "ADC L2"}, - {"ADC R", NULL, "ADC R2"}, + {"ADC L", NULL, "MIC1"}, + {"ADC R", NULL, "MIC2"}, + {"ADC L", NULL, "MIC3"}, + {"ADC R", NULL, "MIC4"}, {"I2S OUT", NULL, "ADC L"}, {"I2S OUT", NULL, "ADC R"}, @@ -606,11 +595,16 @@ static int es8326_mute(struct snd_soc_dai *dai, int mute, int direction) unsigned int offset_l, offset_r; if (mute) { - regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_OFF); - regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE, - ES8326_MUTE_MASK, ES8326_MUTE); - regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, - 0x30, 0x00); + if (direction == SNDRV_PCM_STREAM_PLAYBACK) { + regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_OFF); + regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE, + ES8326_MUTE_MASK, ES8326_MUTE); + regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, + 0x30, 0x00); + } else { + regmap_update_bits(es8326->regmap, ES8326_ADC_MUTE, + 0x0F, 0x0F); + } } else { if (!es8326->calibrated) { regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_FORCE_CAL); @@ -623,16 +617,22 @@ static int es8326_mute(struct snd_soc_dai *dai, int mute, int direction) regmap_write(es8326->regmap, ES8326_HPR_OFFSET_INI, offset_r); es8326->calibrated = true; } - regmap_update_bits(es8326->regmap, ES8326_DAC_DSM, 0x01, 0x01); - usleep_range(1000, 5000); - regmap_update_bits(es8326->regmap, ES8326_DAC_DSM, 0x01, 0x00); - usleep_range(1000, 5000); - regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, 0x30, 0x20); - regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, 0x30, 0x30); - regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa1); - regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_ON); - regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE, - ES8326_MUTE_MASK, ~(ES8326_MUTE)); + if (direction == SNDRV_PCM_STREAM_PLAYBACK) { + regmap_update_bits(es8326->regmap, ES8326_DAC_DSM, 0x01, 0x01); + usleep_range(1000, 5000); + regmap_update_bits(es8326->regmap, ES8326_DAC_DSM, 0x01, 0x00); + usleep_range(1000, 5000); + regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, 0x30, 0x20); + regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, 0x30, 0x30); + regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa1); + regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_ON); + regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE, + ES8326_MUTE_MASK, ~(ES8326_MUTE)); + } else { + msleep(300); + regmap_update_bits(es8326->regmap, ES8326_ADC_MUTE, + 0x0F, 0x00); + } } return 0; } @@ -682,7 +682,7 @@ static const struct snd_soc_dai_ops es8326_ops = { .set_fmt = es8326_set_dai_fmt, .set_sysclk = es8326_set_dai_sysclk, .mute_stream = es8326_mute, - .no_capture_mute = 1, + .no_capture_mute = 0, }; static struct snd_soc_dai_driver es8326_dai = { @@ -1054,6 +1054,7 @@ static int es8326_resume(struct snd_soc_component *component) regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE, ES8326_MUTE_MASK, ES8326_MUTE); + regmap_write(es8326->regmap, ES8326_ADC_MUTE, 0x0f); es8326->jack_remove_retry = 0; es8326->hp = 0;