Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp5558617pxb; Mon, 28 Mar 2022 14:12:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKTAl+bnFkkXAhucOSsvhA6IwJ9vnXkqnvIHaaOVJUIIwnwI1i08KCAj05nGw/LUEquZby X-Received: by 2002:a9d:5a07:0:b0:5cd:afdb:b0da with SMTP id v7-20020a9d5a07000000b005cdafdbb0damr10884354oth.188.1648501947242; Mon, 28 Mar 2022 14:12:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648501947; cv=none; d=google.com; s=arc-20160816; b=rOvlKWGTP4UeOR7BGaz6FRvwZAIUeFXy1LK/DJrLdTSFlcy6MFTVlrRet+mQJh/rfL B2fD1RTP45ZYFz2Ri2pu8lEhvDetjES/HB5mbwL0Jj9WJBIQsaVg9R71BqK9Olaw9TIX dvVo1ci1tMO4xYPO7Qa3ZKypQxsMIXZ/nmwxAZexnfKFQhgTxjDc0RLfmh/5IDYoiXZe Q3v4D8PGCi3eajGYI4UBm4FbZtAkeTSCRbbzkZemWGgLTajaFwpEayYyzpZwDHo3wMWN w4oD2Wz3NXEJH5dB6VVQBSAK2TeWhnrsYY+cRaRUzgQkQ8BsuHHBkrjipIqKhU1UiLtt +YFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kiEn5VB/Wb3y2dfI5i5h5/iriKd0jxYjh1fSYi+iKpY=; b=fyVQkDbS38BUlZRh8JpvDDv+pqJl92E2u4Nb2fhOJdpLmRGAMhhaj+jMsBbhcXJxJo g6pmMBaBjLeVI1Vo64Xmj1bZSjVc8fm5WgQtlZTVxoFXdXDbOEPHgmqV5HsPr0JNH1bX J9XyoeprQKsvEraj2tfXRFLzWOfjdZbANk75ZrULuoh4gtCakj6zRI9wEeYXjAAXMlbe zt/7cWFm8/gmLDiV0lDxmxyqhd6A1gM1e7J9tLXfgDrUT7lMshoO+cr8XCBkGYiq4H1V 8/4hymhnI3aapmSzypLEuP2+Hwwr7rvnpJFkgCjURlj1j7lpXqU66Uq6F4VaglJ2aG3f aYxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=PiT97eDf; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id r11-20020a05683001cb00b005cb2fc1380asi12013114ota.134.2022.03.28.14.12.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 14:12:27 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=PiT97eDf; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 037BB53700; Mon, 28 Mar 2022 14:04:01 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242193AbiC1MAA (ORCPT + 99 others); Mon, 28 Mar 2022 08:00:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242588AbiC1L6Z (ORCPT ); Mon, 28 Mar 2022 07:58:25 -0400 Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A054D329A6 for ; Mon, 28 Mar 2022 04:56:29 -0700 (PDT) Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 22S89QbQ026189; Mon, 28 Mar 2022 06:56:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=kiEn5VB/Wb3y2dfI5i5h5/iriKd0jxYjh1fSYi+iKpY=; b=PiT97eDfVAnl0usbap+IcaF4OW+fu5EIWTWETUMjIl8ZQ/4WYgj83hryH3/GqZngCww9 s0ILdFmQs4TM3iX7Sh1d62/31JTcdTfTwcTBTHYRwOHF5pGl2jTgByimqZAeBZrzq1jc P9+fpyYyVDa10Rc6BKJvBVwFxvfhhqlXXNY1B4HHantMjc6y8nolaBnQVUQsDYHX4/Yd nzPgUVtOHhBDL1Oxz3aEPI9Zw3OThImwjVkDGiph9IGUcLO/E289dybiZYre+qU7Zoft 8w/iPqWn0KrHOkNcf/624MxMAjVRaUIqJTyzDR6erNv0wJE7IfRyhXVurKlFQgrYaCvy 7w== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3f1y8pad75-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 28 Mar 2022 06:56:18 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 28 Mar 2022 12:56:16 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2375.24 via Frontend Transport; Mon, 28 Mar 2022 12:56:16 +0100 Received: from vitaly-Legion-7-16ACHg6.ad.cirrus.com (unknown [198.90.238.244]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 4825DB1A; Mon, 28 Mar 2022 11:56:16 +0000 (UTC) From: Vitaly Rodionov To: Jaroslav Kysela , Takashi Iwai CC: , , , Stefan Binding Subject: [PATCH v2 3/6] ALSA: hda/cs8409: Fix Full Scale Volume setting for all variants Date: Mon, 28 Mar 2022 12:56:11 +0100 Message-ID: <20220328115614.15761-4-vitalyr@opensource.cirrus.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220328115614.15761-1-vitalyr@opensource.cirrus.com> References: <20220328115614.15761-1-vitalyr@opensource.cirrus.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: tuZjagM1IgitpamjA_PzWHWUYu2Wg-On X-Proofpoint-ORIG-GUID: tuZjagM1IgitpamjA_PzWHWUYu2Wg-On X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefan Binding All current variants (Bullseye/Warlock/Cyborg) should be using reduced volume (-6dB) for better speaker protection. Refactor to make more explicit the meaning and setting of Full Scale Volume setting to avoid future confusion. Signed-off-by: Stefan Binding Signed-off-by: Vitaly Rodionov Changes in v2: Add patch description in commit message. --- sound/pci/hda/patch_cs8409.c | 29 ++++++++++++++++------------- sound/pci/hda/patch_cs8409.h | 3 +++ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/sound/pci/hda/patch_cs8409.c b/sound/pci/hda/patch_cs8409.c index 1411e3845f16..163ff3b3092a 100644 --- a/sound/pci/hda/patch_cs8409.c +++ b/sound/pci/hda/patch_cs8409.c @@ -733,6 +733,7 @@ static void cs42l42_resume(struct sub_codec *cs42l42) { 0x130A, 0x00 }, { 0x130F, 0x00 }, }; + int fsv_old, fsv_new; /* Bring CS42L42 out of Reset */ gpio_data = snd_hda_codec_read(codec, CS8409_PIN_AFG, 0, AC_VERB_GET_GPIO_DATA, 0); @@ -749,8 +750,13 @@ static void cs42l42_resume(struct sub_codec *cs42l42) /* Clear interrupts, by reading interrupt status registers */ cs8409_i2c_bulk_read(cs42l42, irq_regs, ARRAY_SIZE(irq_regs)); - if (cs42l42->full_scale_vol) - cs8409_i2c_write(cs42l42, 0x2001, 0x01); + fsv_old = cs8409_i2c_read(cs42l42, 0x2001); + if (cs42l42->full_scale_vol == CS42L42_FULL_SCALE_VOL_0DB) + fsv_new = fsv_old & ~CS42L42_FULL_SCALE_VOL_MASK; + else + fsv_new = fsv_old & CS42L42_FULL_SCALE_VOL_MASK; + if (fsv_new != fsv_old) + cs8409_i2c_write(cs42l42, 0x2001, fsv_new); /* we have to explicitly allow unsol event handling even during the * resume phase so that the jack event is processed properly @@ -997,21 +1003,15 @@ void cs8409_cs42l42_fixups(struct hda_codec *codec, const struct hda_fixup *fix, * Additionally set HSBIAS_SENSE_EN and Full Scale volume for some variants. */ switch (codec->fixup_id) { - case CS8409_WARLOCK: - spec->scodecs[CS8409_CODEC0]->hsbias_hiz = 0x0020; - spec->scodecs[CS8409_CODEC0]->full_scale_vol = 1; - break; - case CS8409_BULLSEYE: - spec->scodecs[CS8409_CODEC0]->hsbias_hiz = 0x0020; - spec->scodecs[CS8409_CODEC0]->full_scale_vol = 0; - break; case CS8409_CYBORG: spec->scodecs[CS8409_CODEC0]->hsbias_hiz = 0x00a0; - spec->scodecs[CS8409_CODEC0]->full_scale_vol = 1; + spec->scodecs[CS8409_CODEC0]->full_scale_vol = + CS42L42_FULL_SCALE_VOL_MINUS6DB; break; default: - spec->scodecs[CS8409_CODEC0]->hsbias_hiz = 0x0003; - spec->scodecs[CS8409_CODEC0]->full_scale_vol = 1; + spec->scodecs[CS8409_CODEC0]->hsbias_hiz = 0x0020; + spec->scodecs[CS8409_CODEC0]->full_scale_vol = + CS42L42_FULL_SCALE_VOL_MINUS6DB; break; } @@ -1222,6 +1222,9 @@ void dolphin_fixups(struct hda_codec *codec, const struct hda_fixup *fix, int ac cs8409_fix_caps(codec, DOLPHIN_LO_PIN_NID); cs8409_fix_caps(codec, DOLPHIN_AMIC_PIN_NID); + spec->scodecs[CS8409_CODEC0]->full_scale_vol = CS42L42_FULL_SCALE_VOL_MINUS6DB; + spec->scodecs[CS8409_CODEC1]->full_scale_vol = CS42L42_FULL_SCALE_VOL_MINUS6DB; + break; case HDA_FIXUP_ACT_PROBE: /* Fix Sample Rate to 48kHz */ diff --git a/sound/pci/hda/patch_cs8409.h b/sound/pci/hda/patch_cs8409.h index d0b725c7285b..8e846f292cd0 100644 --- a/sound/pci/hda/patch_cs8409.h +++ b/sound/pci/hda/patch_cs8409.h @@ -235,6 +235,9 @@ enum cs8409_coefficient_index_registers { #define CS42L42_I2C_SLEEP_US (2000) #define CS42L42_PDN_TIMEOUT_US (250000) #define CS42L42_PDN_SLEEP_US (2000) +#define CS42L42_FULL_SCALE_VOL_MASK (2) +#define CS42L42_FULL_SCALE_VOL_0DB (1) +#define CS42L42_FULL_SCALE_VOL_MINUS6DB (0) /* Dell BULLSEYE / WARLOCK / CYBORG Specific Definitions */ -- 2.25.1