From patchwork Fri Nov 17 16:36:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 166260 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp657310vqn; Fri, 17 Nov 2023 08:37:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHlg85dWnJOth6sgvnrcYI8CxPb3ZEqNKgNfk6rwGp5L1RpZY+cSc9keofluKXcYMk3kjkf X-Received: by 2002:a17:902:cec5:b0:1ce:5f09:ffdf with SMTP id d5-20020a170902cec500b001ce5f09ffdfmr240210plg.0.1700239044403; Fri, 17 Nov 2023 08:37:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700239044; cv=none; d=google.com; s=arc-20160816; b=CWKSQHM0FlJpINQlCTe55IcWZ/YraiftqPuA/tTc+YNsyCaPSY3ShANr2KkLVcIxBq ZTsBdQF17jtsTmVOj86iHNjhJsqyARFJ71QhEByFOokVR5RpmeLL2y2e6OOsZUdeMHyS 3krH7NyXYQuQLfj1ehV1yVKFVROMJT/698grfGj2qO0P49eVIBIUcYDDlUSTj0zOfAgY C58rTzaQvmJVkokSYBLUVH/OUFBTqVuZpuQeanirAAqCOu3cGLeDOXRQVFVyGKBWmxxp 0yRlw8aqkds/02+mvZ1HU1gTWL2bF+ZH2+Q4ef8/kG1CVzkuqUIq+Dt2MeygTUuhy2vx bsiA== 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=Epb7xGZ2Giek5XF+eYpKTMktQlwyiszM0+Z8CYXB2gU=; fh=cpd6h5xMdmzuGST2FDaWAhhre4GA/isgFZt04DpKlWI=; b=K7J9c06TDJU8+oc+HN5qADo/a3FMw0+C5tS1XJJw/eLbJXkt48VNcPYd/0W8/UvAkb /3kOw3dh7LW0nkPtr80s4bjnNL8GnNbvI1xZ8NLpV8VVo5wuuE+Z3tEd1mhwS0tH5qfX ypj61/uf8dtXz1JF/pnhY1OrDoCCGOHqfIv2K7gXajKbxAZF9rdhTpLy7/NnFhB/qTA9 ILUsViXQWdbfmJ2G03U1/H607IPk7xU1+2mSjtWGUgSj7BGsvg/4kB7qHBVMCMU7F8sc 4CpUFH0VVxnByrzHXL34jtUYhJNWFaGMeN5AJQglIashISuc8t+dxYAgCrTtcTh1BmNO PBNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=idymcZEt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id q15-20020a17090311cf00b001b9d180fd9asi2213142plh.121.2023.11.17.08.37.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 08:37:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=idymcZEt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 72DD18316EAD; Fri, 17 Nov 2023 08:37:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233317AbjKQQgu (ORCPT + 30 others); Fri, 17 Nov 2023 11:36:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346084AbjKQQgo (ORCPT ); Fri, 17 Nov 2023 11:36:44 -0500 Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F18FCD4B; Fri, 17 Nov 2023 08:36:37 -0800 (PST) Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 3AHFq7aw014874; Fri, 17 Nov 2023 10:36:20 -0600 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=Epb7xGZ2Giek5XF+eYpKTMktQlwyiszM0+Z8CYXB2gU=; b= idymcZEtxFnbtqWNpvU+pUocJtEKM15QBet35nLYfAX2PDe4iTJWloh/5iCmy5CV YouxDNj/yfHs7o4jJTzUo/S/9r/eggXT6GTsNxLGLRO+HNfJ1gZnPU730DkoRYZq B75s0lSOkJlLOesOqNHHkbUs4K2wvwAl9X75WfnY/Fpghb8FYBQyHZF05K+fc36T 50ktwjl1sD+Cf+H9iP8HimiIP0AURWbQ0A3VSGRuJm3hou6TtEgkFTAgCSA5RlQe LcRDoyiQVbomgr9rQhTCC9ZIo8Pko2sXk4/koxoEP+yzu8d7k5tnOs1bILnssu4I MzK9/Oez+S+8DoY1AUkl1A== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3ua6wpfrca-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Nov 2023 10:36:19 -0600 (CST) 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_256_GCM_SHA384) id 15.2.1118.39; Fri, 17 Nov 2023 16:36:17 +0000 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.2.1118.39 via Frontend Transport; Fri, 17 Nov 2023 16:36:17 +0000 Received: from sbinding-cirrus-dsktp2.ad.cirrus.com (unknown [198.90.238.225]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 7011AB12; Fri, 17 Nov 2023 16:36:17 +0000 (UTC) From: Stefan Binding To: Mark Brown , Jaroslav Kysela , "Takashi Iwai" CC: , , , , "Stefan Binding" Subject: [PATCH v2 1/2] ALSA: hda: cs35l41: Remove unnecessary boolean state variable firmware_running Date: Fri, 17 Nov 2023 16:36:08 +0000 Message-ID: <20231117163609.823627-2-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231117163609.823627-1-sbinding@opensource.cirrus.com> References: <20231117163609.823627-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: _daGspqCCRY1BCOu1fKk_bVkRe5a_RzO X-Proofpoint-ORIG-GUID: _daGspqCCRY1BCOu1fKk_bVkRe5a_RzO X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 17 Nov 2023 08:37:21 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782829856125216815 X-GMAIL-MSGID: 1782829856125216815 This state duplicates the running state inside cs_dsp, so is not necessary. Remove it, and use cs_dsp.running instead. This brings the CS35L41 HDA driver more inline with its ASoC version, allowing the same state to be used when calling library functions. Fixes: fa3efcc36aac ("ALSA: cs35l41: Use mbox command to enable speaker output for external boost") Signed-off-by: Stefan Binding --- sound/pci/hda/cs35l41_hda.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c index b2db8091f0ed..b7d2aa18c566 100644 --- a/sound/pci/hda/cs35l41_hda.c +++ b/sound/pci/hda/cs35l41_hda.c @@ -504,7 +504,6 @@ static void cs35l41_shutdown_dsp(struct cs35l41_hda *cs35l41) cs_dsp_stop(dsp); cs_dsp_power_down(dsp); - cs35l41->firmware_running = false; dev_dbg(cs35l41->dev, "Unloaded Firmware\n"); } @@ -550,7 +549,7 @@ static void cs35l41_hda_play_start(struct device *dev) cs35l41->playback_started = true; - if (cs35l41->firmware_running) { + if (cs35l41->cs_dsp.running) { regmap_multi_reg_write(reg, cs35l41_hda_config_dsp, ARRAY_SIZE(cs35l41_hda_config_dsp)); regmap_update_bits(reg, CS35L41_PWR_CTRL2, @@ -580,7 +579,7 @@ static void cs35l41_mute(struct device *dev, bool mute) regmap_multi_reg_write(reg, cs35l41_hda_mute, ARRAY_SIZE(cs35l41_hda_mute)); } else { dev_dbg(dev, "Unmuting\n"); - if (cs35l41->firmware_running) { + if (cs35l41->cs_dsp.running) { regmap_multi_reg_write(reg, cs35l41_hda_unmute_dsp, ARRAY_SIZE(cs35l41_hda_unmute_dsp)); } else { @@ -599,7 +598,7 @@ static void cs35l41_hda_play_done(struct device *dev) dev_dbg(dev, "Play (Complete)\n"); cs35l41_global_enable(dev, reg, cs35l41->hw_cfg.bst_type, 1, - cs35l41->firmware_running); + cs35l41->cs_dsp.running); cs35l41_mute(dev, false); } @@ -612,7 +611,7 @@ static void cs35l41_hda_pause_start(struct device *dev) cs35l41_mute(dev, true); cs35l41_global_enable(dev, reg, cs35l41->hw_cfg.bst_type, 0, - cs35l41->firmware_running); + cs35l41->cs_dsp.running); } static void cs35l41_hda_pause_done(struct device *dev) @@ -625,7 +624,7 @@ static void cs35l41_hda_pause_done(struct device *dev) regmap_update_bits(reg, CS35L41_PWR_CTRL2, CS35L41_AMP_EN_MASK, 0 << CS35L41_AMP_EN_SHIFT); if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) regmap_write(reg, CS35L41_GPIO1_CTRL1, 0x00000001); - if (cs35l41->firmware_running) { + if (cs35l41->cs_dsp.running) { cs35l41_set_cspl_mbox_cmd(dev, reg, CSPL_MBOX_CMD_PAUSE); regmap_update_bits(reg, CS35L41_PWR_CTRL2, CS35L41_VMON_EN_MASK | CS35L41_IMON_EN_MASK, @@ -675,7 +674,7 @@ static void cs35l41_hda_playback_hook(struct device *dev, int action) break; case HDA_GEN_PCM_ACT_CLOSE: mutex_lock(&cs35l41->fw_mutex); - if (!cs35l41->firmware_running && cs35l41->request_fw_load && + if (!cs35l41->cs_dsp.running && cs35l41->request_fw_load && !cs35l41->fw_request_ongoing) { dev_info(dev, "Requesting Firmware Load after HDA_GEN_PCM_ACT_CLOSE\n"); cs35l41->fw_request_ongoing = true; @@ -761,10 +760,9 @@ static int cs35l41_verify_id(struct cs35l41_hda *cs35l41, unsigned int *regid, u static int cs35l41_ready_for_reset(struct cs35l41_hda *cs35l41) { mutex_lock(&cs35l41->fw_mutex); - if (cs35l41->firmware_running) { + if (cs35l41->cs_dsp.running) { cs35l41->cs_dsp.running = false; cs35l41->cs_dsp.booted = false; - cs35l41->firmware_running = false; } regcache_mark_dirty(cs35l41->regmap); mutex_unlock(&cs35l41->fw_mutex); @@ -925,7 +923,7 @@ static int cs35l41_runtime_suspend(struct device *dev) mutex_lock(&cs35l41->fw_mutex); - if (cs35l41->firmware_running) { + if (cs35l41->cs_dsp.running) { ret = cs35l41_enter_hibernate(cs35l41->dev, cs35l41->regmap, cs35l41->hw_cfg.bst_type); if (ret) @@ -960,7 +958,7 @@ static int cs35l41_runtime_resume(struct device *dev) regcache_cache_only(cs35l41->regmap, false); - if (cs35l41->firmware_running) { + if (cs35l41->cs_dsp.running) { ret = cs35l41_exit_hibernate(cs35l41->dev, cs35l41->regmap); if (ret) { dev_warn(cs35l41->dev, "Unable to exit Hibernate."); @@ -1052,8 +1050,6 @@ static int cs35l41_smart_amp(struct cs35l41_hda *cs35l41) goto clean_dsp; } - cs35l41->firmware_running = true; - return 0; clean_dsp: @@ -1063,10 +1059,10 @@ static int cs35l41_smart_amp(struct cs35l41_hda *cs35l41) static void cs35l41_load_firmware(struct cs35l41_hda *cs35l41, bool load) { - if (cs35l41->firmware_running && !load) { + if (cs35l41->cs_dsp.running && !load) { dev_dbg(cs35l41->dev, "Unloading Firmware\n"); cs35l41_shutdown_dsp(cs35l41); - } else if (!cs35l41->firmware_running && load) { + } else if (!cs35l41->cs_dsp.running && load) { dev_dbg(cs35l41->dev, "Loading Firmware\n"); cs35l41_smart_amp(cs35l41); } else { @@ -1346,7 +1342,7 @@ static int cs35l41_hda_bind(struct device *dev, struct device *master, void *mas cs35l41->acpi_subsystem_id, cs35l41->hw_cfg.bst_type, cs35l41->hw_cfg.gpio1.func == CS35l41_VSPK_SWITCH, cs35l41->hw_cfg.spk_pos ? 'R' : 'L', - cs35l41->firmware_running, cs35l41->speaker_id); + cs35l41->cs_dsp.running, cs35l41->speaker_id); return ret; } From patchwork Fri Nov 17 16:36:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 166261 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp657514vqn; Fri, 17 Nov 2023 08:37:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IGjOZwiM85nozVJtUJEVqf3W50txJVP092TI3l1/SqauoPAGy7EdaBZGSiM7sr/RsSFYBbw X-Received: by 2002:a17:902:eb4b:b0:1ca:362b:166c with SMTP id i11-20020a170902eb4b00b001ca362b166cmr28741pli.61.1700239063146; Fri, 17 Nov 2023 08:37:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700239063; cv=none; d=google.com; s=arc-20160816; b=L6EA0YXxOqy9bd63udp4E8CfYZCehEHh+4qQgaF4C7SeJEa/Tg6sdksAG/40pGaByU yDt4gosh1rnrDc7HSQM3p7mCMS2inL6jFRp+7bJpcOY1uyR5pmtUc04QOAMtPiSK6Qjk PxSVLFCiOYxhDl129ER7zfezScIJRCePQ2d7TgqzHG+5EJtObmQWl2dN6uCShIlrEUsI gu0AR1BgIAwiCoLRftmtYa297kFAF+3U1zESTgM0LiRZKbHYBYAlo/D765UAYqPjcoS5 HXs1x2F9wuXl/d7V3wDXaeXf9kylJrklPKpEJY9Z/62rEd6ZgPkoqN8yYI4N3JZIxZaf H56A== 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=E3wwcijZLLR2v3vODORrLKbR58/61l5lOeY6OfWRCJk=; fh=cpd6h5xMdmzuGST2FDaWAhhre4GA/isgFZt04DpKlWI=; b=Ulh+zzMTxWfawgtc0ZCeJJCvwxb94VLscxYgcdZLt/t0MTXIbf9vNLa142dzD6CdKE Qngna3/3K68I6paI4DlbgnIdYPtH+hojscQswdttbyblObFPIWPNrEOUH3HI5+d3TnZD BxcBr2kM/my1dB6rOm1Srv0EiuZIO0NJDFs2SXwpcKy88HgXshz1MW/bVjwJMspJq2sA 16qDV//oSXCwTbPSBL+ax5byKj3AwFkso/tKNMiBHNZANKkevPvLf/0ItqY6x6z1HCEV tBmqGfxobvm276fHr34jyaIgYppVMM3UNL5MD8ku9/+I+zFwXmpVryUzCSw2tjFdGNtF 7DCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=Y+Rwckva; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id a16-20020a170902ecd000b001ce5b8cb05dsi2287316plh.598.2023.11.17.08.37.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 08:37:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=Y+Rwckva; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5AEE5806B568; Fri, 17 Nov 2023 08:36:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235563AbjKQQgr (ORCPT + 30 others); Fri, 17 Nov 2023 11:36:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235091AbjKQQgl (ORCPT ); Fri, 17 Nov 2023 11:36:41 -0500 Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5714D57; Fri, 17 Nov 2023 08:36:37 -0800 (PST) Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 3AHFq7ax014874; Fri, 17 Nov 2023 10:36:20 -0600 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=E3wwcijZLLR2v3vODORrLKbR58/61l5lOeY6OfWRCJk=; b= Y+Rwckva4J34qmWrWwOOQ1AXWIxDp6blO8qqAIJCzYlNfJckXFyU8dScysHhpXD/ OlTrEFlJi6tEsok35d/viDoZKNmZpzXvJjhn6KYkW/ySUxGT9nyhoghisly+hBvH T0ZPrg2KMMmUo5tmFRLqaA7OJc79a/Aq4elqjhq0+gF+o+R9k3oXeWN34hOptSIh 0FjAh/QEgk6Qu5rsbHhsSaVLE3Oe5NxZ3gU79rauf6Dv8RJtuyMDTH2p08x/ZjNR DwqA4qzy72jQ6eK/LyPQ+wu1pBglhaRVvIWqxozG3wQn82DSjbt2ozLdge8aScE3 J/TdUYidvJpWnpjUG4MUoA== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3ua6wpfrca-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Nov 2023 10:36:20 -0600 (CST) 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_256_GCM_SHA384) id 15.2.1118.39; Fri, 17 Nov 2023 16:36:17 +0000 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.2.1118.39 via Frontend Transport; Fri, 17 Nov 2023 16:36:17 +0000 Received: from sbinding-cirrus-dsktp2.ad.cirrus.com (unknown [198.90.238.225]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id AD63E3581; Fri, 17 Nov 2023 16:36:17 +0000 (UTC) From: Stefan Binding To: Mark Brown , Jaroslav Kysela , "Takashi Iwai" CC: , , , , "Stefan Binding" Subject: [PATCH v2 2/2] ALSA: cs35l41: Fix for old systems which do not support command Date: Fri, 17 Nov 2023 16:36:09 +0000 Message-ID: <20231117163609.823627-3-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231117163609.823627-1-sbinding@opensource.cirrus.com> References: <20231117163609.823627-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: tzs2NI77yzwds6AQd80xxs2B9Ui9vB7k X-Proofpoint-ORIG-GUID: tzs2NI77yzwds6AQd80xxs2B9Ui9vB7k X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 17 Nov 2023 08:36:48 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782829875811343098 X-GMAIL-MSGID: 1782829875811343098 Some older laptops using cs35l41 use firmware which does not support the CSPL_MBOX_CMD_SPK_OUT_ENABLE command. Firmware versions v0.28.0 and older do not support this command. Fixes: fa3efcc36aac ("ALSA: cs35l41: Use mbox command to enable speaker output for external boost") Signed-off-by: Stefan Binding --- include/sound/cs35l41.h | 2 +- sound/pci/hda/cs35l41_hda.c | 4 ++-- sound/soc/codecs/cs35l41-lib.c | 6 ++++-- sound/soc/codecs/cs35l41.c | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/sound/cs35l41.h b/include/sound/cs35l41.h index 043f8ac65dbf..68e053fe7340 100644 --- a/include/sound/cs35l41.h +++ b/include/sound/cs35l41.h @@ -906,6 +906,6 @@ int cs35l41_init_boost(struct device *dev, struct regmap *regmap, bool cs35l41_safe_reset(struct regmap *regmap, enum cs35l41_boost_type b_type); int cs35l41_mdsync_up(struct regmap *regmap); int cs35l41_global_enable(struct device *dev, struct regmap *regmap, enum cs35l41_boost_type b_type, - int enable, bool firmware_running); + int enable, struct cs_dsp *dsp); #endif /* __CS35L41_H */ diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c index b7d2aa18c566..cbd7d8badf91 100644 --- a/sound/pci/hda/cs35l41_hda.c +++ b/sound/pci/hda/cs35l41_hda.c @@ -598,7 +598,7 @@ static void cs35l41_hda_play_done(struct device *dev) dev_dbg(dev, "Play (Complete)\n"); cs35l41_global_enable(dev, reg, cs35l41->hw_cfg.bst_type, 1, - cs35l41->cs_dsp.running); + &cs35l41->cs_dsp); cs35l41_mute(dev, false); } @@ -611,7 +611,7 @@ static void cs35l41_hda_pause_start(struct device *dev) cs35l41_mute(dev, true); cs35l41_global_enable(dev, reg, cs35l41->hw_cfg.bst_type, 0, - cs35l41->cs_dsp.running); + &cs35l41->cs_dsp); } static void cs35l41_hda_pause_done(struct device *dev) diff --git a/sound/soc/codecs/cs35l41-lib.c b/sound/soc/codecs/cs35l41-lib.c index 4569e4f7cf7e..e9993a39f7d0 100644 --- a/sound/soc/codecs/cs35l41-lib.c +++ b/sound/soc/codecs/cs35l41-lib.c @@ -16,6 +16,8 @@ #include +#define CS35L41_FIRMWARE_OLD_VERSION 0x001C00 /* v0.28.0 */ + static const struct reg_default cs35l41_reg[] = { { CS35L41_PWR_CTRL1, 0x00000000 }, { CS35L41_PWR_CTRL2, 0x00000000 }, @@ -1214,7 +1216,7 @@ EXPORT_SYMBOL_GPL(cs35l41_safe_reset); * the PLL Lock interrupt, in the IRQ handler. */ int cs35l41_global_enable(struct device *dev, struct regmap *regmap, enum cs35l41_boost_type b_type, - int enable, bool firmware_running) + int enable, struct cs_dsp *dsp) { int ret; unsigned int gpio1_func, pad_control, pwr_ctrl1, pwr_ctrl3, int_status, pup_pdn_mask; @@ -1309,7 +1311,7 @@ int cs35l41_global_enable(struct device *dev, struct regmap *regmap, enum cs35l4 } regmap_write(regmap, CS35L41_IRQ1_STATUS1, CS35L41_PUP_DONE_MASK); - if (firmware_running) + if (dsp->running && dsp->fw_id_version > CS35L41_FIRMWARE_OLD_VERSION) ret = cs35l41_set_cspl_mbox_cmd(dev, regmap, CSPL_MBOX_CMD_SPK_OUT_ENABLE); else diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c index d0e9128ac6d0..dfb4ce53491b 100644 --- a/sound/soc/codecs/cs35l41.c +++ b/sound/soc/codecs/cs35l41.c @@ -519,11 +519,11 @@ static int cs35l41_main_amp_event(struct snd_soc_dapm_widget *w, ARRAY_SIZE(cs35l41_pup_patch)); ret = cs35l41_global_enable(cs35l41->dev, cs35l41->regmap, cs35l41->hw_cfg.bst_type, - 1, cs35l41->dsp.cs_dsp.running); + 1, &cs35l41->dsp.cs_dsp); break; case SND_SOC_DAPM_POST_PMD: ret = cs35l41_global_enable(cs35l41->dev, cs35l41->regmap, cs35l41->hw_cfg.bst_type, - 0, cs35l41->dsp.cs_dsp.running); + 0, &cs35l41->dsp.cs_dsp); regmap_multi_reg_write_bypassed(cs35l41->regmap, cs35l41_pdn_patch,