From patchwork Wed Sep 20 15:54:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 142547 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp4331846vqi; Wed, 20 Sep 2023 11:12:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHn5klcrhx0WpganBRWRvbDAeCFiVIor6s7HPbaOPy/rHCk5kMsJewhfE0BDD+Qz7DyjBfH X-Received: by 2002:a05:6358:2607:b0:141:bfc:b11d with SMTP id l7-20020a056358260700b001410bfcb11dmr3829156rwc.16.1695233565820; Wed, 20 Sep 2023 11:12:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695233565; cv=none; d=google.com; s=arc-20160816; b=WemF+H7O3l9tJ2g53BUqx+/jWvH5D58VlprIyhKrdoMuS4HIWPbss3rmShScV3f49p UrXSGPJ9RnWDaeChXsi38P/Jtz9/Jb/8rcI9SC7jta5dF/hadyaiWBTteIzv1HiT8mPe ImqZQFORMuWYQn+0ikiK7S2p2cJDJTkT8U057PzEn4cE5y7R+dkMrc7uJrk7fEvsVCkJ EyBCqG98l1NlRvsqmaIio5f98GhGTvGbdqtsfZWckTnkV5O9l3UhlLbFgPmHwledJ1wJ wrD1bR5EKVHqa2epoJNsGsVcBOWDYgNThIeh/H53wzeC+kCZcnpFljuE8iG2AR2HItto DLJA== 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=PzgE18K4PqO8dXD62uIrqgRS5xHATb17ID0/Z6vMJHE=; fh=w0YUzQ46fBcI9TSX4/vlEjRtiHb0kiqukhFXye02PR8=; b=gtA+rJ0PCXKSz+pRRikQiSxOnsvXnREAeY0rs0GxNVMl0XSVZo2B2KNctvKf/VG5Dn NK0eSk+3po2FfzTiLx/VSMARTyEhbF/q6RriPd6mWPaeAX9ib8vwcjH0y4lt/gIf4AXr 9dVZcXju4NSkiUpENoQ7LEeonPYj44iKInIpYqlsJym6DQpIjb8WBj7zvYA7khkMipi8 34AVHsyjuT99kArGENxM70ETAckkQ0hyBzIb5QFs4neCJ4OXsqBOSjE0hxk1oG/m3BrO 6AZdTjiOQ3quDezpS3w3fnklGmMGyFVCQL9kRpiD0rO9UutEJwpoDZMeYsRplcxMNmvg JvCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=YWbx3A5E; 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 j10-20020a63fc0a000000b00573fa0fffcdsi11951573pgi.538.2023.09.20.11.12.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 11:12:45 -0700 (PDT) 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=YWbx3A5E; 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 7D4508335B1B; Wed, 20 Sep 2023 09:34:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234979AbjITQeR (ORCPT + 27 others); Wed, 20 Sep 2023 12:34:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234795AbjITQeL (ORCPT ); Wed, 20 Sep 2023 12:34:11 -0400 Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5726DDC for ; Wed, 20 Sep 2023 09:34:05 -0700 (PDT) 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 38KFt6MZ023727; Wed, 20 Sep 2023 11:33:39 -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=PzgE18K4PqO8dXD62uIrqgRS5xHATb17ID0/Z6vMJHE=; b= YWbx3A5Ecp6k7YzYCpzXyDXj+LPXsyFHg7swCcqlPTVkoEIF7mOTOUYJAIwZ/yuv 8NKiYaodEeULYqdozFiZGpD+dFm+pVgWp67ePuR5Ban5b5TNEFRJxObkHPi2tSUN cIPdQKuJaNbMW1WWXapgcMGJKzIVbkVm1R19C+TVh6YSCd062lsJsbtvOdGJaClF ng+9kfpdTLrCgBTaOD0CyTiGOhbMajsup1CWt8CRiKW9q629gLWVSOOxnHAK48Dd BFya0A+UCOXSJuupSf4PYiv6Q2iY6o2RcbXbw6t5Qr7hB7oR7Z9tJOprCEmoj1+4 m4tTVjRqTMHpagvY8+0ByA== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3t58shvnd5-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Sep 2023 11:33:39 -0500 (CDT) Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.37; Wed, 20 Sep 2023 17:33:37 +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.2.1118.37 via Frontend Transport; Wed, 20 Sep 2023 17:33:37 +0100 Received: from sbinding-cirrus-dsktp2.ad.cirrus.com (unknown [198.90.238.135]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 393BE458; Wed, 20 Sep 2023 16:33:37 +0000 (UTC) From: Stefan Binding To: Jaroslav Kysela , Takashi Iwai CC: , , , Stefan Binding Subject: [PATCH v4 4/4] ALSA: hda: cs35l41: Add read-only ALSA control for forced mute Date: Wed, 20 Sep 2023 16:54:50 +0100 Message-ID: <20230920155450.576287-5-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230920155450.576287-1-sbinding@opensource.cirrus.com> References: <20230920155450.576287-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: EUwYUiMW8bgtt8XIRHweRy9CqW2mTvf_ X-Proofpoint-ORIG-GUID: EUwYUiMW8bgtt8XIRHweRy9CqW2mTvf_ 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 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]); Wed, 20 Sep 2023 09:34:56 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777581231617235636 X-GMAIL-MSGID: 1777581231617235636 When the CS35L41 amp is requested to mute using the ACPI notification mechanism, userspace is not notified that the amp is muted. To allow userspace to know about the mute, add an ALSA control which tracks the forced mute override. This control does not track the overall mute state of the amp, since the amp is only unmuted during playback anyway, instead it tracks the mute override request from the ACPI notification. Signed-off-by: Stefan Binding --- sound/pci/hda/cs35l41_hda.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c index 7b56bceea9e8..dd10b4cd3d1a 100644 --- a/sound/pci/hda/cs35l41_hda.c +++ b/sound/pci/hda/cs35l41_hda.c @@ -972,6 +972,15 @@ static int cs35l41_fw_load_ctl_get(struct snd_kcontrol *kcontrol, return 0; } +static int cs35l41_mute_override_ctl_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct cs35l41_hda *cs35l41 = snd_kcontrol_chip(kcontrol); + + ucontrol->value.integer.value[0] = cs35l41->mute_override; + return 0; +} + static void cs35l41_fw_load_work(struct work_struct *work) { struct cs35l41_hda *cs35l41 = container_of(work, struct cs35l41_hda, fw_load_work); @@ -1055,6 +1064,7 @@ static int cs35l41_create_controls(struct cs35l41_hda *cs35l41) { char fw_type_ctl_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; char fw_load_ctl_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; + char mute_override_ctl_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; struct snd_kcontrol_new fw_type_ctl = { .name = fw_type_ctl_name, .iface = SNDRV_CTL_ELEM_IFACE_CARD, @@ -1069,12 +1079,21 @@ static int cs35l41_create_controls(struct cs35l41_hda *cs35l41) .get = cs35l41_fw_load_ctl_get, .put = cs35l41_fw_load_ctl_put, }; + struct snd_kcontrol_new mute_override_ctl = { + .name = mute_override_ctl_name, + .iface = SNDRV_CTL_ELEM_IFACE_CARD, + .info = snd_ctl_boolean_mono_info, + .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, + .get = cs35l41_mute_override_ctl_get, + }; int ret; scnprintf(fw_type_ctl_name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "%s DSP1 Firmware Type", cs35l41->amp_name); scnprintf(fw_load_ctl_name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "%s DSP1 Firmware Load", cs35l41->amp_name); + scnprintf(mute_override_ctl_name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "%s Forced Mute Status", + cs35l41->amp_name); ret = snd_ctl_add(cs35l41->codec->card, snd_ctl_new1(&fw_type_ctl, cs35l41)); if (ret) { @@ -1092,6 +1111,15 @@ static int cs35l41_create_controls(struct cs35l41_hda *cs35l41) dev_dbg(cs35l41->dev, "Added Control %s\n", fw_load_ctl.name); + ret = snd_ctl_add(cs35l41->codec->card, snd_ctl_new1(&mute_override_ctl, cs35l41)); + if (ret) { + dev_err(cs35l41->dev, "Failed to add KControl %s = %d\n", mute_override_ctl.name, + ret); + return ret; + } + + dev_dbg(cs35l41->dev, "Added Control %s\n", mute_override_ctl.name); + return 0; }