From patchwork Mon Jul 12 07:02:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Koba Ko X-Patchwork-Id: 1503810 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=EOiPYusL; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GNZV35SV0z9snk; Mon, 12 Jul 2021 17:03:07 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1m2py2-0001Z0-2F; Mon, 12 Jul 2021 07:03:02 +0000 Received: from smtp-relay-canonical-0.internal ([10.131.114.83] helo=smtp-relay-canonical-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1m2pxz-0001YJ-OV for kernel-team@lists.ubuntu.com; Mon, 12 Jul 2021 07:02:59 +0000 Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) (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-canonical-0.canonical.com (Postfix) with ESMTPS id 911BF404A0 for ; Mon, 12 Jul 2021 07:02:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1626073379; bh=Kkaa8nTCNtOHolKUjMon9Wsb+t3aZx6fHtIglbBGqrU=; h=From:To:Subject:Date:Message-Id:MIME-Version:Content-Type; b=EOiPYusLRly1NRO3XEi0WbpdU3GP29TK4x+O2zMPEhBa2klqvxhF4Pm6VUWjoGx/E JkQ4U1ah2JsPQSESi3P7BXFHMRRUfa6oXQWE1S5D4VPPLyPL+FPnCtVkqjJUs8e9Wx a0Dklk3j1XFBi+PHOKEuZV9FnPgdxyE7KpEd3ORMZfSy3W9eyyIOiomAlKUdVcex6S HkvXVrO6M2+0PgkJbXhVBygG+Rrc9SmQdPDti92QkOOFCDXzzULjOOyGQ+pWeBKrGq Z23p+yqNi+SWjoHSIoJpD72Pva2ClXDO59lxgP+EFGLRPwpltPwVk1iCkFr4z4RLX3 9+MFf64cMRjSg== Received: by mail-pj1-f71.google.com with SMTP id k92-20020a17090a14e5b02901731af08bd7so11474898pja.2 for ; Mon, 12 Jul 2021 00:02:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=Kkaa8nTCNtOHolKUjMon9Wsb+t3aZx6fHtIglbBGqrU=; b=QDMP/5l8Bo/fQ3vCxgQ+loB5qsSJfR3yhQmjJjJ4sjqSkQi2UXQIpisopOkAGEFQmA wiVa7Jix3W44bTI9JEmgPepOAtXuacEKB42G7n5Pz5GHFSOaQTKZXBujLvZyW1txd6TY HYevpOu2lzDrEYDOP2jg3yx1zoPfKNI2iPzN1SrQLjKXq+/6onzh0eW3DE1unllunkjP Sy1Gz7N+CZhtV/f2sqsOEZdnCOvjqii1Uq/bzwNt1h+w+WyRkNdRxor5+iyedovPOIh8 ljo2HFBimpiko4+2CR9fJLD3urJkUNoHSuOxFzqaoflp+Nc/rR75rbnRmlaWETJRyfdl ylXw== X-Gm-Message-State: AOAM532pvFmq8OAb0/kAMwogYN4PYDqviLaZ0KtEiHpxDi1ttIChd1J2 Yu1jOZHdYbSHPl9A/0HEATuZ0ShfN1QpBRDGMJ+Ukif0HnqHZLXXG8pn2vXmiGFK3FtIztdzo28 wxuTVrLSaTQxP9i4IDPp4l3YZKzhHBtp4S+4Wa6ngow== X-Received: by 2002:a17:902:a983:b029:129:c270:9222 with SMTP id bh3-20020a170902a983b0290129c2709222mr24557019plb.78.1626073377819; Mon, 12 Jul 2021 00:02:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuOrH2ox7v14/Fc39hS7ZMr4eDMxTLPzDnAfxQMc2bf+N8rI0RlvpkXAx4f4xefmF8rruWcg== X-Received: by 2002:a17:902:a983:b029:129:c270:9222 with SMTP id bh3-20020a170902a983b0290129c2709222mr24556997plb.78.1626073377486; Mon, 12 Jul 2021 00:02:57 -0700 (PDT) Received: from canonical.com (61-220-137-34.HINET-IP.hinet.net. [61.220.137.34]) by smtp.gmail.com with ESMTPSA id c24sm14362963pfn.86.2021.07.12.00.02.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 00:02:57 -0700 (PDT) From: Koba Ko To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/4][SRU][OEM-5.13] platform/x86: dell-wmi: Rename dell-wmi.c to dell-wmi-base.c Date: Mon, 12 Jul 2021 15:02:52 +0800 Message-Id: <20210712070255.28295-1-koba.ko@canonical.com> X-Mailer: git-send-email 2.25.1 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: Hans de Goede BugLink: https://bugs.launchpad.net/bugs/1928750 Rename dell-wmi.c to dell-wmi-base.c, so that we can have other dell-wmi-foo.c files which can be added to dell-wmi.ko as "plugins" controlled by separate boolean Kconfig options. Signed-off-by: Hans de Goede (cherry picked from commit 8bf388a0a0fe257dd7be9db0352b5b71b4e9138a) Signed-off-by: Koba Ko Acked-By: AceLan Kao --- MAINTAINERS | 2 +- drivers/platform/x86/dell/Makefile | 1 + drivers/platform/x86/dell/{dell-wmi.c => dell-wmi-base.c} | 0 3 files changed, 2 insertions(+), 1 deletion(-) rename drivers/platform/x86/dell/{dell-wmi.c => dell-wmi-base.c} (100%) diff --git a/MAINTAINERS b/MAINTAINERS index ca74514e1db04..03e48fa0e1afc 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -5191,7 +5191,7 @@ DELL WMI NOTIFICATIONS DRIVER M: Matthew Garrett M: Pali Rohár S: Maintained -F: drivers/platform/x86/dell/dell-wmi.c +F: drivers/platform/x86/dell/dell-wmi-base.c DELTA ST MEDIA DRIVER M: Hugues Fruchet diff --git a/drivers/platform/x86/dell/Makefile b/drivers/platform/x86/dell/Makefile index d3805d34cd0a4..0b9ece8505548 100644 --- a/drivers/platform/x86/dell/Makefile +++ b/drivers/platform/x86/dell/Makefile @@ -16,6 +16,7 @@ dell-smbios-$(CONFIG_DELL_SMBIOS_SMM) += dell-smbios-smm.o obj-$(CONFIG_DELL_SMO8800) += dell-smo8800.o obj-$(CONFIG_DELL_UART_BACKLIGHT) += dell-uart-backlight.o obj-$(CONFIG_DELL_WMI) += dell-wmi.o +dell-wmi-objs := dell-wmi-base.o obj-$(CONFIG_DELL_WMI_AIO) += dell-wmi-aio.o obj-$(CONFIG_DELL_WMI_DESCRIPTOR) += dell-wmi-descriptor.o obj-$(CONFIG_DELL_WMI_LED) += dell-wmi-led.o diff --git a/drivers/platform/x86/dell/dell-wmi.c b/drivers/platform/x86/dell/dell-wmi-base.c similarity index 100% rename from drivers/platform/x86/dell/dell-wmi.c rename to drivers/platform/x86/dell/dell-wmi-base.c From patchwork Mon Jul 12 07:02:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Koba Ko X-Patchwork-Id: 1503811 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=gnEhkiMz; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GNZV65whkz9ssD; Mon, 12 Jul 2021 17:03:10 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1m2py7-0001Ze-7y; Mon, 12 Jul 2021 07:03:07 +0000 Received: from smtp-relay-canonical-0.internal ([10.131.114.83] helo=smtp-relay-canonical-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1m2py1-0001Yu-Sz for kernel-team@lists.ubuntu.com; Mon, 12 Jul 2021 07:03:01 +0000 Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.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-canonical-0.canonical.com (Postfix) with ESMTPS id 8330A404A0 for ; Mon, 12 Jul 2021 07:03:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1626073381; bh=GT7Iq93U7lNZVGdBJd2QEqT2Ru9kyXE1G6RvJGen5Y8=; h=From:To:Subject:Date:Message-Id:MIME-Version:Content-Type; b=gnEhkiMzfuRxKEODKMa0oUoYErGs4H7+Leue87OoP4OWPssFWGOYDPTN7lOCDiBu7 RlIyAxdUUnXqjamBzwpzcZHMKX8oeQiy0E3Qm7G2Pqhba70wKlsz9kQhTFHL3OSIOa LAK2h5UDVhvSeonspwU6wTn9M+Sgxssqg4qspcDWlCXp0bdRh5AsxZbhfyAOEGOmZq sreV3QkZl8HNZVVQHFL4UaMcWGZZ4GjvQTh9R1UINvsOLfcq8wLVNU9ldFNRGwUD8k sJYFomrbrv4z1TMAoc+fyvTIblV+54JoSLsLYj963h+EV8q7QIOIMVCqUlGuB0nHtm hGTljg4Yt2IVA== Received: by mail-pl1-f200.google.com with SMTP id c24-20020a1709028498b0290128cdfbb2f1so5685881plo.14 for ; Mon, 12 Jul 2021 00:03:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GT7Iq93U7lNZVGdBJd2QEqT2Ru9kyXE1G6RvJGen5Y8=; b=GWNJGSvJY1QnysFngdwlpIxFHv72NYqmtU7p5ePj62uXT0mqEX78bvAXxXE2JHdNZy aXfSqV73HCy2mPgQTdKflX9zQnKnTL/mBPNIxenMXBFAwh8+ug4dZsyt6Rh6vxFa9i8o GQy5cfEUmGTrF6K1V+WtZTPDgKH4ebD1OBtri1h2XC0NlWSIKJFNtB/w1dz1XISmHvsP Ut2yAiMi/yJATuDH2TXozlNut2RgD5CrgRguI8O938CmHMBqlxZQTAs2JyIkSH4teT8D npJ6693DQOEHvg7qPD2/A/uLImpra1hGRLpAHc5RjbbJAFkmm11xH25bu8/MwqZZ9PEc Qxkw== X-Gm-Message-State: AOAM532jZdShv3++9AQzYZRlhPsi0Q9x5SJSoGs8Q7Punw67sFynMrrs DrbcOZAv9mHGEsJt39Zh7Q3xveItUDVnL+h6rS9uvqaeHc4oBWEsn6N7KECoyv5mSk/QHHvZXD3 DsW0vg/gwALOjeH/0E6zI6w25t/Ic6Tk0AFlfDxiUjw== X-Received: by 2002:a17:902:a582:b029:129:c8a4:1e48 with SMTP id az2-20020a170902a582b0290129c8a41e48mr22642289plb.19.1626073379739; Mon, 12 Jul 2021 00:02:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6FK9/O2UfqT/JCVKCSLUZseoWMqYU7IDp0Sq5e3rT54u/cm2CYxWXTbfiK59+a2/7BXpOtw== X-Received: by 2002:a17:902:a582:b029:129:c8a4:1e48 with SMTP id az2-20020a170902a582b0290129c8a41e48mr22642269plb.19.1626073379270; Mon, 12 Jul 2021 00:02:59 -0700 (PDT) Received: from canonical.com (61-220-137-34.HINET-IP.hinet.net. [61.220.137.34]) by smtp.gmail.com with ESMTPSA id s15sm14447920pfw.207.2021.07.12.00.02.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 00:02:58 -0700 (PDT) From: Koba Ko To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/4][SRU][OEM-5.13] platform/x86: dell-privacy: Add support for Dell hardware privacy Date: Mon, 12 Jul 2021 15:02:53 +0800 Message-Id: <20210712070255.28295-2-koba.ko@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210712070255.28295-1-koba.ko@canonical.com> References: <20210712070255.28295-1-koba.ko@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: Perry Yuan BugLink: https://bugs.launchpad.net/bugs/1928750 add support for Dell privacy driver for the Dell units equipped hardware privacy design, which protect users privacy of audio and camera from hardware level. Once the audio or camera privacy mode activated, any applications will not get any audio or video stream when user pressed ctrl+F4 hotkey, audio privacy mode will be enabled, micmute led will be also changed accordingly The micmute led is fully controlled by hardware & EC(embedded controller) and camera mute hotkey is Ctrl+F9. Currently design only emits SW_CAMERA_LENS_COVER event while the camera lens shutter will be changed by EC & HW(hardware) control *The flow is like this: 1) User presses key. HW does stuff with this key (timeout timer is started) 2) WMI event is emitted from BIOS to kernel 3) WMI event is received by dell-privacy 4) KEY_MICMUTE emitted from dell-privacy 5) Userland picks up key and modifies kcontrol for SW mute 6) Codec kernel driver catches and calls ledtrig_audio_set 7) dell-privacy notifies EC, the timeout is cancelled and the HW mute is activated. If the EC is not notified then the HW mic mute will activate when the timeout triggers, just a bit later than with the active ack. Signed-off-by: Perry Yuan Link: https://lore.kernel.org/r/20210506115605.1504-1-Perry_Yuan@Dell.com [hdegoede@redhat.com: Rework Kconfig/Makefile bits + other small fixups] Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede (cherry picked from commit 8af9fa37b8a3637832cbf8fdd9bd828bd5f0de66) Signed-off-by: Koba Ko --- .../testing/sysfs-platform-dell-privacy-wmi | 55 +++ MAINTAINERS | 7 + drivers/platform/x86/dell/Kconfig | 9 + drivers/platform/x86/dell/Makefile | 1 + drivers/platform/x86/dell/dell-laptop.c | 13 +- drivers/platform/x86/dell/dell-wmi-base.c | 14 +- drivers/platform/x86/dell/dell-wmi-privacy.c | 391 ++++++++++++++++++ drivers/platform/x86/dell/dell-wmi-privacy.h | 36 ++ 8 files changed, 522 insertions(+), 4 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-platform-dell-privacy-wmi create mode 100644 drivers/platform/x86/dell/dell-wmi-privacy.c create mode 100644 drivers/platform/x86/dell/dell-wmi-privacy.h diff --git a/Documentation/ABI/testing/sysfs-platform-dell-privacy-wmi b/Documentation/ABI/testing/sysfs-platform-dell-privacy-wmi new file mode 100644 index 0000000000000..7f9e18705861e --- /dev/null +++ b/Documentation/ABI/testing/sysfs-platform-dell-privacy-wmi @@ -0,0 +1,55 @@ +What: /sys/bus/wmi/devices/6932965F-1671-4CEB-B988-D3AB0A901919/dell_privacy_supported_type +Date: Apr 2021 +KernelVersion: 5.13 +Contact: "perry.yuan@dell.com>" +Description: + Display which dell hardware level privacy devices are supported + “Dell Privacy” is a set of HW, FW, and SW features to enhance + Dell’s commitment to platform privacy for MIC, Camera, and + ePrivacy screens. + The supported hardware privacy devices are: +Attributes: + Microphone Mute: + Identifies the local microphone can be muted by hardware, no applications + is available to capture system mic sound + + Camera Shutter: + Identifies camera shutter controlled by hardware, which is a micromechanical + shutter assembly that is built onto the camera module to block capturing images + from outside the laptop + + supported: + The privacy device is supported by this system + + unsupported: + The privacy device is not supported on this system + + For example to check which privacy devices are supported: + + # cat /sys/bus/wmi/drivers/dell-privacy/6932965F-1671-4CEB-B988-D3AB0A901919/dell_privacy_supported_type + [Microphone Mute] [supported] + [Camera Shutter] [supported] + [ePrivacy Screen] [unsupported] + +What: /sys/bus/wmi/devices/6932965F-1671-4CEB-B988-D3AB0A901919/dell_privacy_current_state +Date: Apr 2021 +KernelVersion: 5.13 +Contact: "perry.yuan@dell.com>" +Description: + Allow user space to check current dell privacy device state. + Describes the Device State class exposed by BIOS which can be + consumed by various applications interested in knowing the Privacy + feature capabilities +Attributes: + muted: + Identifies the privacy device is turned off and cannot send stream to OS applications + + unmuted: + Identifies the privacy device is turned on ,audio or camera driver can get + stream from mic and camera module to OS applications + + For example to check all supported current privacy device states: + + # cat /sys/bus/wmi/drivers/dell-privacy/6932965F-1671-4CEB-B988-D3AB0A901919/dell_privacy_current_state + [Microphone] [unmuted] + [Camera Shutter] [unmuted] diff --git a/MAINTAINERS b/MAINTAINERS index 03e48fa0e1afc..c5b091abbe1b7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -5193,6 +5193,13 @@ M: Pali Rohár S: Maintained F: drivers/platform/x86/dell/dell-wmi-base.c +DELL WMI HARDWARE PRIVACY SUPPORT +M: Perry Yuan +L: Dell.Client.Kernel@dell.com +L: platform-driver-x86@vger.kernel.org +S: Maintained +F: drivers/platform/x86/dell/dell-wmi-privacy.c + DELTA ST MEDIA DRIVER M: Hugues Fruchet L: linux-media@vger.kernel.org diff --git a/drivers/platform/x86/dell/Kconfig b/drivers/platform/x86/dell/Kconfig index e0a55337f51a7..b5c6a6a32bf9e 100644 --- a/drivers/platform/x86/dell/Kconfig +++ b/drivers/platform/x86/dell/Kconfig @@ -53,6 +53,7 @@ config DELL_LAPTOP depends on BACKLIGHT_CLASS_DEVICE depends on ACPI_VIDEO || ACPI_VIDEO = n depends on RFKILL || RFKILL = n + depends on DELL_WMI || DELL_WMI = n depends on SERIO_I8042 depends on DELL_SMBIOS select POWER_SUPPLY @@ -164,6 +165,14 @@ config DELL_WMI To compile this driver as a module, choose M here: the module will be called dell-wmi. +config DELL_WMI_PRIVACY + bool "Dell WMI Hardware Privacy Support" + depends on DELL_WMI + depends on LEDS_TRIGGER_AUDIO + help + This option adds integration with the "Dell Hardware Privacy" + feature of Dell laptops to the dell-wmi driver. + config DELL_WMI_AIO tristate "WMI Hotkeys for Dell All-In-One series" default m diff --git a/drivers/platform/x86/dell/Makefile b/drivers/platform/x86/dell/Makefile index 0b9ece8505548..6ac979af539b3 100644 --- a/drivers/platform/x86/dell/Makefile +++ b/drivers/platform/x86/dell/Makefile @@ -17,6 +17,7 @@ obj-$(CONFIG_DELL_SMO8800) += dell-smo8800.o obj-$(CONFIG_DELL_UART_BACKLIGHT) += dell-uart-backlight.o obj-$(CONFIG_DELL_WMI) += dell-wmi.o dell-wmi-objs := dell-wmi-base.o +dell-wmi-$(CONFIG_DELL_WMI_PRIVACY) += dell-wmi-privacy.o obj-$(CONFIG_DELL_WMI_AIO) += dell-wmi-aio.o obj-$(CONFIG_DELL_WMI_DESCRIPTOR) += dell-wmi-descriptor.o obj-$(CONFIG_DELL_WMI_LED) += dell-wmi-led.o diff --git a/drivers/platform/x86/dell/dell-laptop.c b/drivers/platform/x86/dell/dell-laptop.c index 70edc5bb3a146..8230e7a68a5eb 100644 --- a/drivers/platform/x86/dell/dell-laptop.c +++ b/drivers/platform/x86/dell/dell-laptop.c @@ -31,6 +31,8 @@ #include "dell-rbtn.h" #include "dell-smbios.h" +#include "dell-wmi-privacy.h" + struct quirk_entry { bool touchpad_led; bool kbd_led_not_present; @@ -90,6 +92,7 @@ static struct rfkill *wifi_rfkill; static struct rfkill *bluetooth_rfkill; static struct rfkill *wwan_rfkill; static bool force_rfkill; +static bool micmute_led_registered; module_param(force_rfkill, bool, 0444); MODULE_PARM_DESC(force_rfkill, "enable rfkill on non whitelisted models"); @@ -2205,11 +2208,13 @@ static int __init dell_init(void) dell_laptop_register_notifier(&dell_laptop_notifier); if (dell_smbios_find_token(GLOBAL_MIC_MUTE_DISABLE) && - dell_smbios_find_token(GLOBAL_MIC_MUTE_ENABLE)) { + dell_smbios_find_token(GLOBAL_MIC_MUTE_ENABLE) && + !dell_privacy_has_mic_mute()) { micmute_led_cdev.brightness = ledtrig_audio_get(LED_AUDIO_MICMUTE); ret = led_classdev_register(&platform_device->dev, &micmute_led_cdev); if (ret < 0) goto fail_led; + micmute_led_registered = true; } if (acpi_video_get_backlight_type() != acpi_backlight_vendor) @@ -2257,7 +2262,8 @@ static int __init dell_init(void) fail_get_brightness: backlight_device_unregister(dell_backlight_device); fail_backlight: - led_classdev_unregister(&micmute_led_cdev); + if (micmute_led_registered) + led_classdev_unregister(&micmute_led_cdev); fail_led: dell_cleanup_rfkill(); fail_rfkill: @@ -2278,7 +2284,8 @@ static void __exit dell_exit(void) touchpad_led_exit(); kbd_led_exit(); backlight_device_unregister(dell_backlight_device); - led_classdev_unregister(&micmute_led_cdev); + if (micmute_led_registered) + led_classdev_unregister(&micmute_led_cdev); dell_cleanup_rfkill(); if (platform_device) { platform_device_unregister(platform_device); diff --git a/drivers/platform/x86/dell/dell-wmi-base.c b/drivers/platform/x86/dell/dell-wmi-base.c index 5e1b7f897df58..089c125e18f70 100644 --- a/drivers/platform/x86/dell/dell-wmi-base.c +++ b/drivers/platform/x86/dell/dell-wmi-base.c @@ -27,6 +27,7 @@ #include #include "dell-smbios.h" #include "dell-wmi-descriptor.h" +#include "dell-wmi-privacy.h" MODULE_AUTHOR("Matthew Garrett "); MODULE_AUTHOR("Pali Rohár "); @@ -427,7 +428,6 @@ static void dell_wmi_notify(struct wmi_device *wdev, switch (buffer_entry[1]) { case 0x0000: /* One key pressed or event occurred */ - case 0x0012: /* Event with extended data occurred */ if (len > 2) dell_wmi_process_key(wdev, buffer_entry[1], buffer_entry[2]); @@ -439,6 +439,13 @@ static void dell_wmi_notify(struct wmi_device *wdev, dell_wmi_process_key(wdev, buffer_entry[1], buffer_entry[i]); break; + case 0x0012: + if ((len > 4) && dell_privacy_process_event(buffer_entry[1], buffer_entry[3], + buffer_entry[4])) + /* dell_privacy_process_event has handled the event */; + else if (len > 2) + dell_wmi_process_key(wdev, buffer_entry[1], buffer_entry[2]); + break; default: /* Unknown event */ pr_info("Unknown WMI event type 0x%x\n", (int)buffer_entry[1]); @@ -747,6 +754,10 @@ static int __init dell_wmi_init(void) } } + err = dell_privacy_register_driver(); + if (err) + return err; + return wmi_driver_register(&dell_wmi_driver); } late_initcall(dell_wmi_init); @@ -757,6 +768,7 @@ static void __exit dell_wmi_exit(void) dell_wmi_events_set_enabled(false); wmi_driver_unregister(&dell_wmi_driver); + dell_privacy_unregister_driver(); } module_exit(dell_wmi_exit); diff --git a/drivers/platform/x86/dell/dell-wmi-privacy.c b/drivers/platform/x86/dell/dell-wmi-privacy.c new file mode 100644 index 0000000000000..074b7e68c227c --- /dev/null +++ b/drivers/platform/x86/dell/dell-wmi-privacy.c @@ -0,0 +1,391 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Dell privacy notification driver + * + * Copyright (C) 2021 Dell Inc. All Rights Reserved. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "dell-wmi-privacy.h" + +#define DELL_PRIVACY_GUID "6932965F-1671-4CEB-B988-D3AB0A901919" +#define MICROPHONE_STATUS BIT(0) +#define CAMERA_STATUS BIT(1) +#define DELL_PRIVACY_AUDIO_EVENT 0x1 +#define DELL_PRIVACY_CAMERA_EVENT 0x2 +#define led_to_priv(c) container_of(c, struct privacy_wmi_data, cdev) + +/* + * The wmi_list is used to store the privacy_priv struct with mutex protecting + */ +static LIST_HEAD(wmi_list); +static DEFINE_MUTEX(list_mutex); + +struct privacy_wmi_data { + struct input_dev *input_dev; + struct wmi_device *wdev; + struct list_head list; + struct led_classdev cdev; + u32 features_present; + u32 last_status; +}; + +/* DELL Privacy Type */ +enum dell_hardware_privacy_type { + DELL_PRIVACY_TYPE_AUDIO = 0, + DELL_PRIVACY_TYPE_CAMERA, + DELL_PRIVACY_TYPE_SCREEN, + DELL_PRIVACY_TYPE_MAX, +}; + +static const char * const privacy_types[DELL_PRIVACY_TYPE_MAX] = { + [DELL_PRIVACY_TYPE_AUDIO] = "Microphone", + [DELL_PRIVACY_TYPE_CAMERA] = "Camera Shutter", + [DELL_PRIVACY_TYPE_SCREEN] = "ePrivacy Screen", +}; + +/* + * Keymap for WMI privacy events of type 0x0012 + */ +static const struct key_entry dell_wmi_keymap_type_0012[] = { + /* privacy mic mute */ + { KE_KEY, 0x0001, { KEY_MICMUTE } }, + /* privacy camera mute */ + { KE_SW, 0x0002, { SW_CAMERA_LENS_COVER } }, + { KE_END, 0}, +}; + +bool dell_privacy_has_mic_mute(void) +{ + struct privacy_wmi_data *priv; + + mutex_lock(&list_mutex); + priv = list_first_entry_or_null(&wmi_list, + struct privacy_wmi_data, + list); + mutex_unlock(&list_mutex); + + return priv && (priv->features_present & BIT(DELL_PRIVACY_TYPE_AUDIO)); +} +EXPORT_SYMBOL_GPL(dell_privacy_has_mic_mute); + +/* + * The flow of privacy event: + * 1) User presses key. HW does stuff with this key (timeout is started) + * 2) WMI event is emitted from BIOS + * 3) WMI event is received by dell-privacy + * 4) KEY_MICMUTE emitted from dell-privacy + * 5) Userland picks up key and modifies kcontrol for SW mute + * 6) Codec kernel driver catches and calls ledtrig_audio_set which will call + * led_set_brightness() on the LED registered by dell_privacy_leds_setup() + * 7) dell-privacy notifies EC, the timeout is cancelled and the HW mute activates. + * If the EC is not notified then the HW mic mute will activate when the timeout + * triggers, just a bit later than with the active ack. + */ +bool dell_privacy_process_event(int type, int code, int status) +{ + struct privacy_wmi_data *priv; + const struct key_entry *key; + bool ret = false; + + mutex_lock(&list_mutex); + priv = list_first_entry_or_null(&wmi_list, + struct privacy_wmi_data, + list); + if (!priv) + goto error; + + key = sparse_keymap_entry_from_scancode(priv->input_dev, (type << 16) | code); + if (!key) { + dev_warn(&priv->wdev->dev, "Unknown key with type 0x%04x and code 0x%04x pressed\n", + type, code); + goto error; + } + dev_dbg(&priv->wdev->dev, "Key with type 0x%04x and code 0x%04x pressed\n", type, code); + + switch (code) { + case DELL_PRIVACY_AUDIO_EVENT: /* Mic mute */ + case DELL_PRIVACY_CAMERA_EVENT: /* Camera mute */ + priv->last_status = status; + sparse_keymap_report_entry(priv->input_dev, key, 1, true); + ret = true; + break; + default: + dev_dbg(&priv->wdev->dev, "unknown event type 0x%04x 0x%04x\n", type, code); + } + +error: + mutex_unlock(&list_mutex); + return ret; +} + +static ssize_t dell_privacy_supported_type_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct privacy_wmi_data *priv = dev_get_drvdata(dev); + enum dell_hardware_privacy_type type; + u32 privacy_list; + int len = 0; + + privacy_list = priv->features_present; + for (type = DELL_PRIVACY_TYPE_AUDIO; type < DELL_PRIVACY_TYPE_MAX; type++) { + if (privacy_list & BIT(type)) + len += sysfs_emit_at(buf, len, "[%s] [supported]\n", privacy_types[type]); + else + len += sysfs_emit_at(buf, len, "[%s] [unsupported]\n", privacy_types[type]); + } + + return len; +} + +static ssize_t dell_privacy_current_state_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct privacy_wmi_data *priv = dev_get_drvdata(dev); + u32 privacy_supported = priv->features_present; + enum dell_hardware_privacy_type type; + u32 privacy_state = priv->last_status; + int len = 0; + + for (type = DELL_PRIVACY_TYPE_AUDIO; type < DELL_PRIVACY_TYPE_MAX; type++) { + if (privacy_supported & BIT(type)) { + if (privacy_state & BIT(type)) + len += sysfs_emit_at(buf, len, "[%s] [unmuted]\n", privacy_types[type]); + else + len += sysfs_emit_at(buf, len, "[%s] [muted]\n", privacy_types[type]); + } + } + + return len; +} + +static DEVICE_ATTR_RO(dell_privacy_supported_type); +static DEVICE_ATTR_RO(dell_privacy_current_state); + +static struct attribute *privacy_attributes[] = { + &dev_attr_dell_privacy_supported_type.attr, + &dev_attr_dell_privacy_current_state.attr, + NULL, +}; + +static const struct attribute_group privacy_attribute_group = { + .attrs = privacy_attributes +}; + +/* + * Describes the Device State class exposed by BIOS which can be consumed by + * various applications interested in knowing the Privacy feature capabilities. + * class DeviceState + * { + * [key, read] string InstanceName; + * [read] boolean ReadOnly; + * + * [WmiDataId(1), read] uint32 DevicesSupported; + * 0 - None; 0x1 - Microphone; 0x2 - Camera; 0x4 - ePrivacy Screen + * + * [WmiDataId(2), read] uint32 CurrentState; + * 0 - Off; 1 - On; Bit0 - Microphone; Bit1 - Camera; Bit2 - ePrivacyScreen + * }; + */ +static int get_current_status(struct wmi_device *wdev) +{ + struct privacy_wmi_data *priv = dev_get_drvdata(&wdev->dev); + union acpi_object *obj_present; + u32 *buffer; + int ret = 0; + + if (!priv) { + dev_err(&wdev->dev, "dell privacy priv is NULL\n"); + return -EINVAL; + } + /* check privacy support features and device states */ + obj_present = wmidev_block_query(wdev, 0); + if (!obj_present) { + dev_err(&wdev->dev, "failed to read Binary MOF\n"); + return -EIO; + } + + if (obj_present->type != ACPI_TYPE_BUFFER) { + dev_err(&wdev->dev, "Binary MOF is not a buffer!\n"); + ret = -EIO; + goto obj_free; + } + /* Although it's not technically a failure, this would lead to + * unexpected behavior + */ + if (obj_present->buffer.length != 8) { + dev_err(&wdev->dev, "Dell privacy buffer has unexpected length (%d)!\n", + obj_present->buffer.length); + ret = -EINVAL; + goto obj_free; + } + buffer = (u32 *)obj_present->buffer.pointer; + priv->features_present = buffer[0]; + priv->last_status = buffer[1]; + +obj_free: + kfree(obj_present); + return ret; +} + +static int dell_privacy_micmute_led_set(struct led_classdev *led_cdev, + enum led_brightness brightness) +{ + struct privacy_wmi_data *priv = led_to_priv(led_cdev); + static char *acpi_method = (char *)"ECAK"; + acpi_status status; + acpi_handle handle; + + handle = ec_get_handle(); + if (!handle) + return -EIO; + + if (!acpi_has_method(handle, acpi_method)) + return -EIO; + + status = acpi_evaluate_object(handle, acpi_method, NULL, NULL); + if (ACPI_FAILURE(status)) { + dev_err(&priv->wdev->dev, "Error setting privacy EC ack value: %s\n", + acpi_format_exception(status)); + return -EIO; + } + + return 0; +} + +/* + * Pressing the mute key activates a time delayed circuit to physically cut + * off the mute. The LED is in the same circuit, so it reflects the true + * state of the HW mute. The reason for the EC "ack" is so that software + * can first invoke a SW mute before the HW circuit is cut off. Without SW + * cutting this off first does not affect the time delayed muting or status + * of the LED but there is a possibility of a "popping" noise. + * + * If the EC receives the SW ack, the circuit will be activated before the + * delay completed. + * + * Exposing as an LED device allows the codec drivers notification path to + * EC ACK to work + */ +static int dell_privacy_leds_setup(struct device *dev) +{ + struct privacy_wmi_data *priv = dev_get_drvdata(dev); + + priv->cdev.name = "dell-privacy::micmute"; + priv->cdev.max_brightness = 1; + priv->cdev.brightness_set_blocking = dell_privacy_micmute_led_set; + priv->cdev.default_trigger = "audio-micmute"; + priv->cdev.brightness = ledtrig_audio_get(LED_AUDIO_MICMUTE); + return devm_led_classdev_register(dev, &priv->cdev); +} + +static int dell_privacy_wmi_probe(struct wmi_device *wdev, const void *context) +{ + struct privacy_wmi_data *priv; + struct key_entry *keymap; + int ret, i; + + ret = wmi_has_guid(DELL_PRIVACY_GUID); + if (!ret) + pr_debug("Unable to detect available Dell privacy devices!\n"); + + priv = devm_kzalloc(&wdev->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + dev_set_drvdata(&wdev->dev, priv); + priv->wdev = wdev; + /* create evdev passing interface */ + priv->input_dev = devm_input_allocate_device(&wdev->dev); + if (!priv->input_dev) + return -ENOMEM; + + /* remap the wmi keymap event to new keymap */ + keymap = kcalloc(ARRAY_SIZE(dell_wmi_keymap_type_0012), + sizeof(struct key_entry), GFP_KERNEL); + if (!keymap) + return -ENOMEM; + + /* remap the keymap code with Dell privacy key type 0x12 as prefix + * KEY_MICMUTE scancode will be reported as 0x120001 + */ + for (i = 0; i < ARRAY_SIZE(dell_wmi_keymap_type_0012); i++) { + keymap[i] = dell_wmi_keymap_type_0012[i]; + keymap[i].code |= (0x0012 << 16); + } + ret = sparse_keymap_setup(priv->input_dev, keymap, NULL); + kfree(keymap); + if (ret) + return ret; + + priv->input_dev->dev.parent = &wdev->dev; + priv->input_dev->name = "Dell Privacy Driver"; + priv->input_dev->id.bustype = BUS_HOST; + + ret = input_register_device(priv->input_dev); + if (ret) + return ret; + + ret = get_current_status(priv->wdev); + if (ret) + return ret; + + ret = devm_device_add_group(&wdev->dev, &privacy_attribute_group); + if (ret) + return ret; + + if (priv->features_present & BIT(DELL_PRIVACY_TYPE_AUDIO)) { + ret = dell_privacy_leds_setup(&priv->wdev->dev); + if (ret) + return ret; + } + mutex_lock(&list_mutex); + list_add_tail(&priv->list, &wmi_list); + mutex_unlock(&list_mutex); + return 0; +} + +static void dell_privacy_wmi_remove(struct wmi_device *wdev) +{ + struct privacy_wmi_data *priv = dev_get_drvdata(&wdev->dev); + + mutex_lock(&list_mutex); + list_del(&priv->list); + mutex_unlock(&list_mutex); +} + +static const struct wmi_device_id dell_wmi_privacy_wmi_id_table[] = { + { .guid_string = DELL_PRIVACY_GUID }, + { }, +}; + +static struct wmi_driver dell_privacy_wmi_driver = { + .driver = { + .name = "dell-privacy", + }, + .probe = dell_privacy_wmi_probe, + .remove = dell_privacy_wmi_remove, + .id_table = dell_wmi_privacy_wmi_id_table, +}; + +int dell_privacy_register_driver(void) +{ + return wmi_driver_register(&dell_privacy_wmi_driver); +} + +void dell_privacy_unregister_driver(void) +{ + wmi_driver_unregister(&dell_privacy_wmi_driver); +} diff --git a/drivers/platform/x86/dell/dell-wmi-privacy.h b/drivers/platform/x86/dell/dell-wmi-privacy.h new file mode 100644 index 0000000000000..50c9b943dd475 --- /dev/null +++ b/drivers/platform/x86/dell/dell-wmi-privacy.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Dell privacy notification driver + * + * Copyright (C) 2021 Dell Inc. All Rights Reserved. + */ + +#ifndef _DELL_PRIVACY_WMI_H_ +#define _DELL_PRIVACY_WMI_H_ + +#if IS_ENABLED(CONFIG_DELL_WMI_PRIVACY) +bool dell_privacy_has_mic_mute(void); +bool dell_privacy_process_event(int type, int code, int status); +int dell_privacy_register_driver(void); +void dell_privacy_unregister_driver(void); +#else /* CONFIG_DELL_PRIVACY */ +static inline bool dell_privacy_has_mic_mute(void) +{ + return false; +} + +static inline bool dell_privacy_process_event(int type, int code, int status) +{ + return false; +} + +static inline int dell_privacy_register_driver(void) +{ + return 0; +} + +static inline void dell_privacy_unregister_driver(void) +{ +} +#endif /* CONFIG_DELL_PRIVACY */ +#endif From patchwork Mon Jul 12 07:02:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Koba Ko X-Patchwork-Id: 1503812 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=lhRisOkr; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GNZV73w4Xz9sxS; Mon, 12 Jul 2021 17:03:11 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1m2py8-0001aH-Fy; Mon, 12 Jul 2021 07:03:08 +0000 Received: from smtp-relay-canonical-1.internal ([10.131.114.174] helo=smtp-relay-canonical-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1m2py3-0001ZD-7d for kernel-team@lists.ubuntu.com; Mon, 12 Jul 2021 07:03:03 +0000 Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) (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-canonical-1.canonical.com (Postfix) with ESMTPS id 174784032A for ; Mon, 12 Jul 2021 07:03:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1626073383; bh=z2p62iO/TWWqSV75wTQojrAp3VIrvk3s+PUmZj97hfE=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=lhRisOkrD57mANBvcLILjAa/+lPeCppUgIiHG0pvSFv1qfzfIRf29Lo1PvviNRR/K 5c4wyBPKf/SROmrqKHytNjwIIhsg1/XoasURrt85M5dBSszICesSHSGg7QsC/DybAM lqQ3Sl3ddvwdT8LbhySViXDAeu+OgDOA0IC9gZmxQ45quUw0tcVswF5ikkI973V7UA Fss21sZj63kntamVzTc0Ag8yMjizHQnZVAQ8zTN5o28LgfY6CbPE7Mq9CBZswT1W8B YKvxzPl9p2NJf1LWPmKC0S3uQsl3u6ikWgHPWnthD7Ej4mZ5b3rnYKd5aNooSmdhW1 QUqXyzPkjKjyQ== Received: by mail-pj1-f69.google.com with SMTP id k92-20020a17090a14e5b02901731af08bd7so11475012pja.2 for ; Mon, 12 Jul 2021 00:03:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z2p62iO/TWWqSV75wTQojrAp3VIrvk3s+PUmZj97hfE=; b=csrNCa5CIf8AHRzokfAkD0oy7cnOYTOoXkfKh/PAxSsUzlrhfSW/hrBHXpZeblf/ML lpEz9jeoLxeJbWYnM8ANMCCSRaAWINvdfkAqDNuPCBUP3JvMCV5Yn+c5LpKnkUa1if8N Xugu8Hwd9TmeVU2CTuE4Y/T/nPY7ldNKlOuIzjrVroN6xv5VndrIe7RzWyWQDFPdgXd7 cNnLArvjMA3MA/AOT41dRSNBKl7Hpc+DynbNK9MHI58sef2fqf+POqIFtYdAFatWJKwZ YvQDbx5tAo0VjOoalZrR/eSC7P6P8rf4aKqrEBlERedrGUXLnxUlex+JRUyZ/sqxm6PT 4ewQ== X-Gm-Message-State: AOAM5306pepf+oTAiswqXzNWu2Fnh9EE8FmOxIKpkF/89TN/7DSmQUAB vqdXt/qqxAaF6LeLEY2UHThC1LmwB1kWu1ba9yP6mU1J5PUXvhkq/puVeUC+zRW3Iw9fpmgl7ms Fsso8DL7zTDlMpP+ZExCDSwZwhS9b6hh2NMHVkfvzqw== X-Received: by 2002:a65:6145:: with SMTP id o5mr52115313pgv.410.1626073381419; Mon, 12 Jul 2021 00:03:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxe1v4I4Hd9kZ+/lS8oxdQgEbd2OVBEhhbjGVAewhfnQiGQ0ahTXsN8h8reJhU+dQ9v+KE6cg== X-Received: by 2002:a65:6145:: with SMTP id o5mr52115295pgv.410.1626073381077; Mon, 12 Jul 2021 00:03:01 -0700 (PDT) Received: from canonical.com (61-220-137-34.HINET-IP.hinet.net. [61.220.137.34]) by smtp.gmail.com with ESMTPSA id t6sm19577598pjo.4.2021.07.12.00.03.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 00:03:00 -0700 (PDT) From: Koba Ko To: kernel-team@lists.ubuntu.com Subject: [PATCH 3/4][SRU][OEM-5.13] UBUNTU: SAUCE: ASoC: rt715:add micmute led state control supports Date: Mon, 12 Jul 2021 15:02:54 +0800 Message-Id: <20210712070255.28295-3-koba.ko@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210712070255.28295-1-koba.ko@canonical.com> References: <20210712070255.28295-1-koba.ko@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: Perry Yuan BugLink: https://bugs.launchpad.net/bugs/1928750 Some new Dell system is going to support audio internal micphone privacy setting from hardware level with micmute led state changing When micmute hotkey pressed by user, soft mute will need to be enabled firstly in case of pop noise, and codec driver need to react to mic mute event to EC(embedded controller) notifying that SW mute is completed Then EC will do the hardware mute physically within the timeout reached This patch allow codec rt715 and rt715 sdca driver to change the local micmute led state. Dell privacy led trigger driver will ack EC when micmute key pressed through this micphone led control interface like hda_generic provided ACPI method defined in dell-privacy micmute led trigger will be called for notifying the EC that software mute has been completed, then hardware audio circuit solution controlled by EC will switch the audio input source off/on Signed-off-by: Perry Yuan -------- v7 -> v8: * N/A v6 -> v7: * addresed review comments from Jaroslav * use device id in the quirk list v5 -> v6: * add quirks for micmute led control as short term solution to control micmute led state change * add comments for the invert checking v4 -> v5: * rebase to latest 5.12 rc4 upstream kernel v3 -> v4: * remove unused debug log * remove compile flag of DELL privacy * move the micmute_led to local from rt715_priv * when Jaroslav upstream his gerneric LED trigger driver,I will rebase this patch,please consider merge this at first https://lore.kernel.org/alsa-devel/20210211111400.1131020-1-perex@perex.cz/ v2 -> v3: * simplify the patch to reuse some val value * add more detail to the commit info v1 -> v2: * fix some format issue -------- Link: https://patchwork.kernel.org/project/alsa-devel/patch/20210506115626.12480-1-Perry_Yuan@Dell.com/ Signed-off-by: Koba Ko --- sound/soc/codecs/rt715-sdca.c | 42 +++++++++++++++++++++++++++++++++++ sound/soc/codecs/rt715.c | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/sound/soc/codecs/rt715-sdca.c b/sound/soc/codecs/rt715-sdca.c index 7db76c19e0480..327c7c69a4658 100644 --- a/sound/soc/codecs/rt715-sdca.c +++ b/sound/soc/codecs/rt715-sdca.c @@ -11,12 +11,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -344,6 +346,32 @@ static int rt715_sdca_get_volsw(struct snd_kcontrol *kcontrol, return 0; } +static bool micmute_led_set; +static int dmi_matched(const struct dmi_system_id *dmi) +{ + micmute_led_set = 1; + return 1; +} + +/* Some systems will need to use this to trigger mic mute LED state changed */ +static const struct dmi_system_id micmute_led_dmi_table[] = { + { + .callback = dmi_matched, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_SKU, "0A32"), + }, + }, + { + .callback = dmi_matched, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_SKU, "0A3E"), + }, + }, + {}, +}; + static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { @@ -358,6 +386,7 @@ static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol, unsigned int mask = (1 << fls(max)) - 1; unsigned int invert = p->invert; int err; + bool micmute_led; for (i = 0; i < 4; i++) { if (ucontrol->value.integer.value[i] != rt715->kctl_switch_orig[i]) { @@ -394,6 +423,18 @@ static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol, return err; } + /* Micmute LED state changed by muted/unmute switch + * to keep syncing with actual hardware mic mute led state + * invert will be checked to change the state switch + */ + if (invert && micmute_led_set) { + if (ucontrol->value.integer.value[0] || ucontrol->value.integer.value[1]) + micmute_led = LED_OFF; + else + micmute_led = LED_ON; + ledtrig_audio_set(LED_AUDIO_MICMUTE, micmute_led); + } + return k_changed; } @@ -1066,6 +1107,7 @@ int rt715_sdca_io_init(struct device *dev, struct sdw_slave *slave) pm_runtime_mark_last_busy(&slave->dev); pm_runtime_put_autosuspend(&slave->dev); + dmi_check_system(micmute_led_dmi_table); return 0; } diff --git a/sound/soc/codecs/rt715.c b/sound/soc/codecs/rt715.c index 1352869cc0867..4dbd870009b8d 100644 --- a/sound/soc/codecs/rt715.c +++ b/sound/soc/codecs/rt715.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -25,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -70,6 +72,32 @@ static void rt715_get_gain(struct rt715_priv *rt715, unsigned int addr_h, pr_err("Failed to get L channel gain.\n"); } +static bool micmute_led_set; +static int dmi_matched(const struct dmi_system_id *dmi) +{ + micmute_led_set = 1; + return 1; +} + +/* Some systems will need to use this to trigger mic mute LED state changed */ +static const struct dmi_system_id micmute_led_dmi_table[] = { + { + .callback = dmi_matched, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_SKU, "0A32"), + }, + }, + { + .callback = dmi_matched, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_SKU, "0A3E"), + }, + }, + {}, +}; + /* For Verb-Set Amplifier Gain (Verb ID = 3h) */ static int rt715_set_amp_gain_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) @@ -83,6 +111,7 @@ static int rt715_set_amp_gain_put(struct snd_kcontrol *kcontrol, unsigned int addr_h, addr_l, val_h, val_ll, val_lr; unsigned int read_ll, read_rl, i; unsigned int k_vol_changed = 0; + bool micmute_led; for (i = 0; i < 2; i++) { if (ucontrol->value.integer.value[i] != rt715->kctl_2ch_vol_ori[i]) { @@ -155,6 +184,18 @@ static int rt715_set_amp_gain_put(struct snd_kcontrol *kcontrol, break; } + /* Micmute LED state changed by muted/unmute switch + * to keep syncing with actual hardware mic mute led state + * invert will be checked to change the state switch + */ + if (micmute_led_set) { + if (ucontrol->value.integer.value[0] || ucontrol->value.integer.value[1]) + micmute_led = LED_OFF; + else + micmute_led = LED_ON; + ledtrig_audio_set(LED_AUDIO_MICMUTE, micmute_led); + } + /* D0:power on state, D3: power saving mode */ if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) regmap_write(rt715->regmap, @@ -1088,6 +1129,7 @@ int rt715_io_init(struct device *dev, struct sdw_slave *slave) pm_runtime_mark_last_busy(&slave->dev); pm_runtime_put_autosuspend(&slave->dev); + dmi_check_system(micmute_led_dmi_table); return 0; } From patchwork Mon Jul 12 07:02:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Koba Ko X-Patchwork-Id: 1503813 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=fejT5Z5B; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GNZVC2NgLz9sWS; Mon, 12 Jul 2021 17:03:15 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1m2pyB-0001c4-RO; Mon, 12 Jul 2021 07:03:11 +0000 Received: from smtp-relay-canonical-0.internal ([10.131.114.83] helo=smtp-relay-canonical-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1m2py5-0001ZS-6U for kernel-team@lists.ubuntu.com; Mon, 12 Jul 2021 07:03:05 +0000 Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) (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-canonical-0.canonical.com (Postfix) with ESMTPS id 0CF38404A0 for ; Mon, 12 Jul 2021 07:03:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1626073385; bh=cdZl/643FPhnZcmZdd/XiMzFf+VtjisGHibgR3KsewA=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=fejT5Z5BYBuUXv3znTHmDFYZF0ymlqtpRVBtERJnbBqDO6JJIab5LqM8gbresi22H QjxUhzhIe/4WXVex9ygJQMYfERte7YhgyipfjWbLJppfWnrJjdg3ZFhb/3IuD/PkRE eeDXxTVNusJg6dkQjHTV+PXIECnut4lRbL+Rft/78IqSg1sxRnxUIqTR1wNNuXPnb2 iRHdAE6v16K5J7NlzsT+yT6eauCLSze3CH/tKf8T3s9oFxJHG5Ib+GwrMEMZUqItXN es1W9k947PEFM1PKN+3tFBNdS08HY17cyXhAOlo6PNA7mh9V/wZTL4JSzS3c/LJylu 8UDzsrqQleAKQ== Received: by mail-pj1-f71.google.com with SMTP id dw7-20020a17090b0947b0290173b4d6dd74so1646949pjb.0 for ; Mon, 12 Jul 2021 00:03:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cdZl/643FPhnZcmZdd/XiMzFf+VtjisGHibgR3KsewA=; b=hH7ljUALMrJi3zs4ofThcwXOPRa0CJza6eCGXypupkz43P7jfipahfyyWgbce8Vo72 lNOK8V97zyPVvc5ao5UVjUZhZVMUn2SZ9lbbEUFAOQP3VSeJnqAw/gorYzt6ycZMjvLp kqIESV9o4slrB0oR1HyffBD9dfN9f9eV3Z1nwfrlcWeo+Z+Z6WU6Yp5TJmfzkmh2fr6I OLqL2SX6393gEfTNFiJ8Bs9DTg+rnF6w6EY7SpOTGa0tEjU/AW++0++YZgRvtEYN5gwt 2M29IoTP2ohS2ovft6qjDBCPm8bXxMFVLUL6ZrV9Y+g3z4lgKYgc1Nhs+u2Q2qlZZxOp mT2A== X-Gm-Message-State: AOAM530QrIbzwigS9demO9+9uoe0+cNWzBTsOOD8Er9uxrNkTLaTa3e7 A3ZlQTudEZ8jDT+HBKZF/rBih0aLy/1JxGOEBK5oQyqvtVEOxP9RnFGg3bjh0z7g4szEWU8YaMU MRm9LG9HqLSupN2o+PiHGWFEupRSoLVtdGYbRogwUQA== X-Received: by 2002:a17:90a:73ca:: with SMTP id n10mr12806694pjk.16.1626073383410; Mon, 12 Jul 2021 00:03:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8TBpvlZMD5VkU5knjT/MiyEhmjGsI4NSdCgo0Pr5mA7XooR/QvvAUp7KmY+blCa3veHQbVg== X-Received: by 2002:a17:90a:73ca:: with SMTP id n10mr12806680pjk.16.1626073383136; Mon, 12 Jul 2021 00:03:03 -0700 (PDT) Received: from canonical.com (61-220-137-34.HINET-IP.hinet.net. [61.220.137.34]) by smtp.gmail.com with ESMTPSA id k10sm14434594pfc.169.2021.07.12.00.03.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 00:03:02 -0700 (PDT) From: Koba Ko To: kernel-team@lists.ubuntu.com Subject: [PATCH 4/4][SRU][OEM-5.13] UBUTNU: [Config] Update configs for Dell's E-Privacy Date: Mon, 12 Jul 2021 15:02:55 +0800 Message-Id: <20210712070255.28295-4-koba.ko@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210712070255.28295-1-koba.ko@canonical.com> References: <20210712070255.28295-1-koba.ko@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" BugLink: https://bugs.launchpad.net/bugs/1928750 Signed-off-by: Koba Ko --- debian.oem/config/annotations | 1 + debian.oem/config/config.common.ubuntu | 1 + 2 files changed, 2 insertions(+) diff --git a/debian.oem/config/annotations b/debian.oem/config/annotations index 0bb65eb65a3e6..79aae727a7893 100644 --- a/debian.oem/config/annotations +++ b/debian.oem/config/annotations @@ -10250,6 +10250,7 @@ CONFIG_DELL_RBTN policy<{'amd64': 'm'}> CONFIG_DELL_SMO8800 policy<{'amd64': 'm'}> CONFIG_DELL_WMI_AIO policy<{'amd64': 'm'}> CONFIG_DELL_WMI_LED policy<{'amd64': 'm'}> +CONFIG_DELL_WMI_PRIVACY policy<{'amd64': 'y'}> CONFIG_DELL_WMI_SYSMAN policy<{'amd64': 'm'}> # Menu: Device Drivers >> X86 Platform Specific Device Drivers >> Dell X86 Platform Specific Device Drivers >> Dell SMBIOS driver diff --git a/debian.oem/config/config.common.ubuntu b/debian.oem/config/config.common.ubuntu index 534d9652d857f..88111a647fb5c 100644 --- a/debian.oem/config/config.common.ubuntu +++ b/debian.oem/config/config.common.ubuntu @@ -1719,6 +1719,7 @@ CONFIG_DELL_WMI=m CONFIG_DELL_WMI_AIO=m CONFIG_DELL_WMI_DESCRIPTOR=m CONFIG_DELL_WMI_LED=m +CONFIG_DELL_WMI_PRIVACY=y CONFIG_DELL_WMI_SYSMAN=m CONFIG_DETECT_HUNG_TASK=y CONFIG_DEVFREQ_GOV_PASSIVE=y