From patchwork Tue Nov 21 12:28:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Chiu X-Patchwork-Id: 1866718 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SZNwh3GT9z1yRV for ; Tue, 21 Nov 2023 23:29:24 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1r5PsS-0005D4-VI; Tue, 21 Nov 2023 12:29:17 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1r5Prz-0004qd-6w for kernel-team@lists.ubuntu.com; Tue, 21 Nov 2023 12:28:48 +0000 Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id DB4303F6E7 for ; Tue, 21 Nov 2023 12:28:46 +0000 (UTC) Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-6c0362a50bbso7376798b3a.2 for ; Tue, 21 Nov 2023 04:28:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700569725; x=1701174525; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=er4RVSTbLBukgfq1PtOO5y5RgGqsA0Kf88Fcnp0W8Ts=; b=Feu5zQZhelQ0CBlyQacsEy6StcJywPAMOKNYmOHO6x3kzMf5l0Mb0NCwu1dk2kZhGC j1Q5Jq9LEX5Ffd3AepnxMll4V/pqe3AYjAsSA0qXBWQHM/5pMFFV/MeaNRHn8gEh3Hs+ c+69O/odEhOZHPQkipkv/xqulkEPmUQ3//o6W+4FwoXdwj2+j4UXG0PZ3p2hmDl8p/6O 6OE5bh60gdg7sCQ4irWd1QMQxJ8DHNFBWeMOD30gkqShDkwv9NIYOVVlUT59nYZl+h0k LxtkPloPDZLdK/TZz3xpyl1ZBOOnllU2R71XnC5DRlW2dyt3udoIY8KrTZWXy8rxw47D krfQ== X-Gm-Message-State: AOJu0YzsXl5/qwgnBOp5JHEhfuN0n4BRwYTSU65UtlMZuEbdYv/6Vq+z rIOM14xTP/g9IrFRZpOKixhTwjGA6RgEd9oLyruInGqPihJ3VbvvFNRAsGc3sGRHSlwU/prn71F RW0NDAemSfDeNew9yLN4BT496OZkdtIlPPkmSqrlSgdLTpVUWlQ== X-Received: by 2002:a05:6a00:887:b0:6be:287d:46d6 with SMTP id q7-20020a056a00088700b006be287d46d6mr9693747pfj.33.1700569725167; Tue, 21 Nov 2023 04:28:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IFejgsaD4AyVhEZx5F7Zyln8naKRU7KlsucCCttDzjrk3DB62fJtcIfrUNrzpu9+ycsuNtZFA== X-Received: by 2002:a05:6a00:887:b0:6be:287d:46d6 with SMTP id q7-20020a056a00088700b006be287d46d6mr9693724pfj.33.1700569724757; Tue, 21 Nov 2023 04:28:44 -0800 (PST) Received: from localhost.localdomain (114-36-219-155.dynamic-ip.hinet.net. [114.36.219.155]) by smtp.gmail.com with ESMTPSA id o12-20020a056a00214c00b006c34015a8f2sm8006096pfk.146.2023.11.21.04.28.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 04:28:44 -0800 (PST) From: Chris Chiu To: kernel-team@lists.ubuntu.com Subject: [PATCH 6/6][SRU][M] ALSA: hda: cs35l41: Add read-only ALSA control for forced mute Date: Tue, 21 Nov 2023 20:28:33 +0800 Message-Id: <20231121122833.11493-7-chris.chiu@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231121122833.11493-1-chris.chiu@canonical.com> References: <20231121122833.11493-1-chris.chiu@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Stefan Binding BugLink: https://bugs.launchpad.net/bugs/2039151 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 Link: https://lore.kernel.org/r/20230921162849.1988124-5-sbinding@opensource.cirrus.com Signed-off-by: Takashi Iwai (cherry picked from commit 4c870513fbb02b842408b840cf68ea8fe09ed82e) Signed-off-by: Chris Chiu --- 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 55c32896125b..d13c45b5748b 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; }