From patchwork Sun Oct 16 13:26:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siarhei Volkau X-Patchwork-Id: 3018 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1017464wrs; Sun, 16 Oct 2022 06:32:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5hxNEMmqIyeK/qbapis0MuUxCY323s2RUKp4pVQMY5PLW9EsowTAragiuNmOMJ5xkW0rIo X-Received: by 2002:a05:6402:847:b0:453:943b:bf4 with SMTP id b7-20020a056402084700b00453943b0bf4mr6093543edz.301.1665927157988; Sun, 16 Oct 2022 06:32:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665927157; cv=none; d=google.com; s=arc-20160816; b=R6d6l4fRe5mq7lqgXlVrfvfIVWOQI4iWyxCUJB4UeuRZZanCMcgm/2DcjZe4qvn//x s7sVcU8ZAas3oLaJWQ5BMAYntJNPOHBFuqjgnC19gs1GTAAe4E9qJ7MWls35i9r9cu3r lpDJvx/seV3eVOgs1OCsusar11PWna33UeUEsvTruJCl3tVA1HrOmj/poc9TVY+shHWA u0LcJ8teImsy24xCCIbe6CEmHUILtkmKklj5O+s4Fiu7erUiZkVafCntZze4TcABEKvf HTHQ8mBV5fVHvhwoHsc0Md28cy0IrSvzT/OOnz7nmzFq0Qksjqf82PScIRYadz/8Usfr rq/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=J+d4zYZ2OcrExgu67AwFyCEVw5ZLbwcKQnaxEzIUbSA=; b=JNzFrs1IKcClZiysHxdWy9xW90WUZT3Nq+gvBo19iQUaNT/bBfhtVaRZwJlptP2pLL JqjIrQnTVyvYkntspyR3XZTRY5Ioq/G5Ac5jPPNoLcZU18+Hm7JWtabAVo4Oe2tLMQtr /T7hOi8BARRAUE+xthkBFhOmK2l6T4rHSX+55/0aOL5hmC4N4curfR/30TLdAlbzDiTc yaPjG3mTG8vPX0TaTBRm1l57FTlLxkGRN8K+0i+SJnto6ZWA0V+bnYahn+leDc0dUfPr Y3KhJj7ol6lccK6DFjOvdMsV2rTQJalZeGrPzKF6teNXH5yf/S32DcCDxpqRYw5dK+/G 0eWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20210112 header.b=mMrjWmGO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f15-20020a056402354f00b0045d74aa4730si2073239edd.297.2022.10.16.06.32.12; Sun, 16 Oct 2022 06:32:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20210112 header.b=mMrjWmGO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229769AbiJPN2X (ORCPT + 99 others); Sun, 16 Oct 2022 09:28:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229734AbiJPN2F (ORCPT ); Sun, 16 Oct 2022 09:28:05 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 875BB17898; Sun, 16 Oct 2022 06:27:56 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id y14so19563028ejd.9; Sun, 16 Oct 2022 06:27:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=J+d4zYZ2OcrExgu67AwFyCEVw5ZLbwcKQnaxEzIUbSA=; b=mMrjWmGOWPj+C9rRMvyoO46WUEnlfRtEdLgPUR+JGPnHwMPR8SDTdC/OMHqnsvlbsO uAwIB6Dii987acRt1fXMF5i0TMU353WzTrDYcnBf1Qy61/5fTgyC8ZS8q1Hmwna9zEgw nSx2+QuChjF4E/rqYhj+nfwQ4DnUPgSrjHvw5J0li9Xq4Pk8Ki+MDQU4fkddJfQQBRGN sMj6I/x54DLEW1hPsx03ZHWgDNs1SMxzWIZ7iOc/RFOv0ZhVw3EdwsHqdVzXP+4Hh6Kx Ikr4iJKaEMbWgE/CeGhUWMVACdvtHreTDJOj+9pdQ5Uq29sHodsIf3dVM08LZqBjQtQk ho6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=J+d4zYZ2OcrExgu67AwFyCEVw5ZLbwcKQnaxEzIUbSA=; b=nRDj5lvZWKQnzdJj79gBwcgVxXt/l2/ql7x5NsA6aL3j7WYHvmdN9bU+QDHlochlSF +R/hXj/EpaRtR2HGaBhSl7tFQF90h535Oj7VIFlB6z6WZWDTMpDp9nPM3l1jcR+4jSmz EXRa3fiEix/N7JezGxvjhx3WF6D+jh2ZMJv70h7sLX2qMKkgXJTtkwvQh7nVFNe0nAD0 Gsd9Xd0w3Gg+jZYxPr7lHYA+GAytoFLvvxdzYiv6yVuHdgEslhIyKW8YgdMr6+e96GaA aw4nFVJ+MgO7uUPuM2yrhwPBLY/pNgpwFTMuWceOBT0r/n0Arljx97sPPO2R3+VtlgEn jMwg== X-Gm-Message-State: ACrzQf0CtGMSjEpukQKBZ5A6qu+OCbOxg+LM23iUBP+5hm3J+MGfEy7n UvARD1Jjyly0ILpqnfufuf4= X-Received: by 2002:a17:906:8479:b0:78d:cf17:2d70 with SMTP id hx25-20020a170906847900b0078dcf172d70mr5129252ejc.319.1665926874773; Sun, 16 Oct 2022 06:27:54 -0700 (PDT) Received: from hp-power-15.localdomain (mm-39-7-212-37.vitebsk.dynamic.pppoe.byfly.by. [37.212.7.39]) by smtp.gmail.com with ESMTPSA id y5-20020aa7ce85000000b0045c72bba0bfsm5572057edv.4.2022.10.16.06.27.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Oct 2022 06:27:54 -0700 (PDT) From: Siarhei Volkau Cc: Siarhei Volkau , Paul Cercueil , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , linux-mips@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 6/7] ASoC: codecs: jz4725b: add missed Mixer inputs Date: Sun, 16 Oct 2022 16:26:47 +0300 Message-Id: <20221016132648.3011729-7-lis8215@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221016132648.3011729-1-lis8215@gmail.com> References: <20221016132648.3011729-1-lis8215@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746851235522774257?= X-GMAIL-MSGID: =?utf-8?q?1746851235522774257?= The Mixer couples analog input from 4 sources (DAC, Line In, Mic 1, Mic 2) each input has its own gain & mute controls. At the moment only DAC is implemented fully and Line In path can be switched on/off. The patch implements Mic 1 and Mic 2 paths and fully implements Line In path. Manual states that these controls (16.6.3.3 Programmable attenuation: GOi) gain varies from -22.5dB to +6.0dB with 1.5dB step. Also there's extra values below the minimum, but they behave the same as the minimum value. Signed-off-by: Siarhei Volkau --- sound/soc/codecs/jz4725b.c | 42 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/jz4725b.c b/sound/soc/codecs/jz4725b.c index c39398e0a..52b2bb95b 100644 --- a/sound/soc/codecs/jz4725b.c +++ b/sound/soc/codecs/jz4725b.c @@ -136,6 +136,18 @@ enum { #define REG_CGR3_GO1L_OFFSET 0 #define REG_CGR3_GO1L_MASK (0x1f << REG_CGR3_GO1L_OFFSET) +#define REG_CGR4_GO2R_OFFSET 0 +#define REG_CGR4_GO2R_MASK (0x1f << REG_CGR4_GO2R_OFFSET) + +#define REG_CGR5_GO2L_OFFSET 0 +#define REG_CGR5_GO2L_MASK (0x1f << REG_CGR5_GO2L_OFFSET) + +#define REG_CGR6_GO3R_OFFSET 0 +#define REG_CGR6_GO3R_MASK (0x1f << REG_CGR6_GO3R_OFFSET) + +#define REG_CGR7_GO3L_OFFSET 0 +#define REG_CGR7_GO3L_MASK (0x1f << REG_CGR7_GO3L_OFFSET) + #define REG_CGR8_GOR_OFFSET 0 #define REG_CGR8_GOR_MASK (0x1f << REG_CGR8_GOR_OFFSET) @@ -153,6 +165,11 @@ struct jz_icdc { static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(jz4725b_adc_tlv, 0, 150, 0); static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(jz4725b_dac_tlv, -2250, 150, 0); +static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(jz4725b_mix_tlv, + 0, 11, TLV_DB_SCALE_ITEM(-2250, 0, 0), + 12, 31, TLV_DB_SCALE_ITEM(-2250, 150, 0), +); + static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(jz4725b_out_tlv, 0, 11, TLV_DB_SCALE_ITEM(-3350, 200, 0), 12, 23, TLV_DB_SCALE_ITEM(-1050, 100, 0), @@ -170,6 +187,21 @@ static const struct snd_kcontrol_new jz4725b_codec_controls[] = { REG_CGR10_GIL_OFFSET, REG_CGR10_GIR_OFFSET, 0xf, 0, jz4725b_adc_tlv), + SOC_DOUBLE_R_TLV("Mixer Line In Bypass Playback Volume", + JZ4725B_CODEC_REG_CGR3, + JZ4725B_CODEC_REG_CGR2, + REG_CGR2_GO1R_OFFSET, + 0x1f, 1, jz4725b_mix_tlv), + SOC_DOUBLE_R_TLV("Mixer Mic 1 Bypass Playback Volume", + JZ4725B_CODEC_REG_CGR5, + JZ4725B_CODEC_REG_CGR4, + REG_CGR4_GO2R_OFFSET, + 0x1f, 1, jz4725b_mix_tlv), + SOC_DOUBLE_R_TLV("Mixer Mic 2 Bypass Playback Volume", + JZ4725B_CODEC_REG_CGR7, + JZ4725B_CODEC_REG_CGR6, + REG_CGR6_GO3R_OFFSET, + 0x1f, 1, jz4725b_mix_tlv), SOC_DOUBLE_R_TLV("Master Playback Volume", JZ4725B_CODEC_REG_CGR9, @@ -203,8 +235,12 @@ static const struct snd_kcontrol_new jz4725b_codec_adc_src_ctrl = SOC_DAPM_ENUM("ADC Source Capture Route", jz4725b_codec_adc_src_enum); static const struct snd_kcontrol_new jz4725b_codec_mixer_controls[] = { - SOC_DAPM_SINGLE("Line In Bypass", JZ4725B_CODEC_REG_CR1, + SOC_DAPM_SINGLE("Line In Bypass Playback Switch", JZ4725B_CODEC_REG_CR1, REG_CR1_BYPASS_OFFSET, 1, 0), + SOC_DAPM_SINGLE("Mic 1 Bypass Playback Switch", JZ4725B_CODEC_REG_CR3, + REG_CR3_SIDETONE1_OFFSET, 1, 0), + SOC_DAPM_SINGLE("Mic 2 Bypass Playback Switch", JZ4725B_CODEC_REG_CR3, + REG_CR3_SIDETONE2_OFFSET, 1, 0), }; static int jz4725b_out_stage_enable(struct snd_soc_dapm_widget *w, @@ -299,7 +335,9 @@ static const struct snd_soc_dapm_route jz4725b_codec_dapm_routes[] = { {"Line In", NULL, "LLINEIN"}, {"Line In", NULL, "RLINEIN"}, - {"Mixer", "Line In Bypass", "Line In"}, + {"Mixer", "Mic 1 Bypass Playback Switch", "Mic 1"}, + {"Mixer", "Mic 2 Bypass Playback Switch", "Mic 2"}, + {"Mixer", "Line In Bypass Playback Switch", "Line In"}, {"DAC to Mixer", NULL, "DAC"}, {"Mixer", NULL, "DAC to Mixer"},