From nobody Thu Sep 19 01:15:46 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06C41E71096 for ; Thu, 21 Sep 2023 17:07:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230166AbjIURHo (ORCPT ); Thu, 21 Sep 2023 13:07:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230119AbjIURHR (ORCPT ); Thu, 21 Sep 2023 13:07:17 -0400 Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 348FE4C1C for ; Thu, 21 Sep 2023 10:05:01 -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 38LFWYi7009262; Thu, 21 Sep 2023 11:29:00 -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=MaHpdygZ/aP2aJTDzDqitZm8Hr1umO0xthwnGH/UKh4=; b= jIQsgshesJgCUN1YdVO9UDEmyAgX6B0saJnL2OWOc5xcJE2W39kdzaOlfCWKpjjB g+FuAYB1UmLS61WTskl4QI1qLWobVqNVK4dVrYtH4GHOgTC1qNUVh1j8Qh7Tn99u W1amWyokDGPWCRJmJBk3xtkPFhJefw6bgerFCBwKCggOCY6/EjUlcMSci7kFAXaz CTRB1uQkK8kcFwKNdYbq9hQXKqOvkN5wc1ldjwxZlZAhoHnHxyfzNwyVD0nmQCtb rTvSRmIlFOTIE0wqalGNsha4C+XvvJNNJTwNooFmrexDfPWzwWqbkzm4yuEBCzKG 8kiXjALUE15RB837TcA9+g== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3t58shx0ab-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Sep 2023 11:29:00 -0500 (CDT) 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.37; Thu, 21 Sep 2023 17:28:57 +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; Thu, 21 Sep 2023 17:28:57 +0100 Received: from sbinding-cirrus-dsktp2.ad.cirrus.com (unknown [198.90.238.135]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id AEE8615B9; Thu, 21 Sep 2023 16:28:57 +0000 (UTC) From: Stefan Binding To: Jaroslav Kysela , Takashi Iwai CC: , , , Stefan Binding Subject: [PATCH v5 4/4] ALSA: hda: cs35l41: Add read-only ALSA control for forced mute Date: Thu, 21 Sep 2023 17:28:49 +0100 Message-ID: <20230921162849.1988124-5-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230921162849.1988124-1-sbinding@opensource.cirrus.com> References: <20230921162849.1988124-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: apFXas9Py_YWxUMrItTTFvVR4_hQlcD8 X-Proofpoint-ORIG-GUID: apFXas9Py_YWxUMrItTTFvVR4_hQlcD8 X-Proofpoint-Spam-Reason: safe Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 18ca00c0a8cd..92b815ce193b 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; } =20 +static int cs35l41_mute_override_ctl_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct cs35l41_hda *cs35l41 =3D snd_kcontrol_chip(kcontrol); + + ucontrol->value.integer.value[0] =3D cs35l41->mute_override; + return 0; +} + static void cs35l41_fw_load_work(struct work_struct *work) { struct cs35l41_hda *cs35l41 =3D 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 =3D { .name =3D fw_type_ctl_name, .iface =3D SNDRV_CTL_ELEM_IFACE_CARD, @@ -1069,12 +1079,21 @@ static int cs35l41_create_controls(struct cs35l41_h= da *cs35l41) .get =3D cs35l41_fw_load_ctl_get, .put =3D cs35l41_fw_load_ctl_put, }; + struct snd_kcontrol_new mute_override_ctl =3D { + .name =3D mute_override_ctl_name, + .iface =3D SNDRV_CTL_ELEM_IFACE_CARD, + .info =3D snd_ctl_boolean_mono_info, + .access =3D SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, + .get =3D cs35l41_mute_override_ctl_get, + }; int ret; =20 scnprintf(fw_type_ctl_name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "%s DSP1 Firmw= are Type", cs35l41->amp_name); scnprintf(fw_load_ctl_name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "%s DSP1 Firmw= are Load", cs35l41->amp_name); + scnprintf(mute_override_ctl_name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "%s Forc= ed Mute Status", + cs35l41->amp_name); =20 ret =3D snd_ctl_add(cs35l41->codec->card, snd_ctl_new1(&fw_type_ctl, cs35= l41)); if (ret) { @@ -1092,6 +1111,15 @@ static int cs35l41_create_controls(struct cs35l41_hd= a *cs35l41) =20 dev_dbg(cs35l41->dev, "Added Control %s\n", fw_load_ctl.name); =20 + ret =3D snd_ctl_add(cs35l41->codec->card, snd_ctl_new1(&mute_override_ctl= , cs35l41)); + if (ret) { + dev_err(cs35l41->dev, "Failed to add KControl %s =3D %d\n", mute_overrid= e_ctl.name, + ret); + return ret; + } + + dev_dbg(cs35l41->dev, "Added Control %s\n", mute_override_ctl.name); + return 0; } =20 --=20 2.34.1