From patchwork Mon Feb 22 09:15:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaroslav Kysela X-Patchwork-Id: 12098159 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F280CC433DB for ; Mon, 22 Feb 2021 09:16:43 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 60A9064E41 for ; Mon, 22 Feb 2021 09:16:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 60A9064E41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=perex.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 6D2291674; Mon, 22 Feb 2021 10:15:48 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6D2291674 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1613985398; bh=kVjwBYucKgqYzl5UJ8i5LzV/T355EBZI3711VPy1p+M=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=OB9xXmnzeDxioBPZ+vnGU65bOnCvyycW0ovLjBY0A1ARQQ4zAmmLgAsMBfGqFifez t14R09NaqxUJt44vj5L/hX6S9jb4Bons3ptvO6WYtyMGY30ycIVFdamMlLvmfSWqOd IRPCLs2cL57YU3UTCqs7SNHZ1KylZeVmq239GAxg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 6073FF80154; Mon, 22 Feb 2021 10:15:47 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 23D63F8025E; Mon, 22 Feb 2021 10:15:46 +0100 (CET) Received: from mail1.perex.cz (mail1.perex.cz [77.48.224.245]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B3910F80154 for ; Mon, 22 Feb 2021 10:15:41 +0100 (CET) Received: from mail1.perex.cz (localhost [127.0.0.1]) by smtp1.perex.cz (Perex's E-mail Delivery System) with ESMTP id A348DA003F; Mon, 22 Feb 2021 10:15:40 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.perex.cz A348DA003F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=perex.cz; s=default; t=1613985340; bh=PrZsdDJDIZSb7GmPojQ7aj4YtsI6iS2XHZ1oMT4FUbE=; h=From:To:Cc:Subject:Date:From; b=SdHs/HNgFAVMhmdWhSVfWpyB9EXWg+i8U8ntPyw4sm3q411/YrLF3TXN6pImp8F6+ v1EVNjpGGrPn+tK8lXKvex06NYFzEt9zcL9Da6san3VVwGvzSOQvpDCc0lUcVWgewY DFoVPDMOtcg2BEwC7HX8yEsDWxSMEYSVdt2EbBZI= Received: from p1gen2.perex-int.cz (unknown [192.168.100.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: perex) by mail1.perex.cz (Perex's E-mail Delivery System) with ESMTPSA; Mon, 22 Feb 2021 10:15:35 +0100 (CET) From: Jaroslav Kysela To: ALSA development Subject: [PATCH v3 0/5] ALSA: control - add generic LED API Date: Mon, 22 Feb 2021 10:15:11 +0100 Message-Id: <20210222091516.1752662-1-perex@perex.cz> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Cc: Takashi Iwai , Hans de Goede , Perry Yuan X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This patchset tries to resolve the diversity in the audio LED control among the ALSA drivers. A new control layer registration is introduced which allows to run additional operations on top of the elementary ALSA sound controls. A new control access group (three bits in the access flags) was introduced to carry the LED group information for the sound controls. The low-level sound drivers can just mark those controls using this access group. This information is exported to the user space and eventually the user space can create sound controls which can belong to a LED group. The actual state ('route') evaluation is really easy (the minimal value check for all channels / controls / cards). If there's more complicated logic for a given hardware, the card driver may eventually export a new read-only sound control for the LED group and do the logic itself. The new LED trigger control code is completely separated and possibly optional (there's no symbol dependency). The full code separation allows eventually to move this LED trigger control to the user space in future. Actually it replaces the already present functionality in the kernel space (HDA drivers) and allows a quick adoption for the recent hardware (SoundWire ASoC codecs). # lsmod | grep snd_ctl_led snd_ctl_led 16384 0 The sound driver implementation is really easy: 1) call snd_ctl_led_request() when control LED layer should be automatically activated / it calls module_request("snd-ctl-led") on demand / 2) mark all related kcontrols with SNDRV_CTL_ELEM_ACCESS_SPK_LED or SNDRV_CTL_ELEM_ACCESS_MIC_LED v3 changes: - reorder the controls_rwsem use to fix the remaining mutex issue card->controls_rwsem <-> snd_ctl_layer_rwsem v2 changes: - fix the locking - remove the controls_rwsem read lock in the element get (the consistency is already protected with the global snd_ctl_led_mutex and possible partial value writes are catched with the next value change notification callback) - rename state to brightness and show the brightness unsigned integer value instead the text on/off string (sync with the LED core routines) - remove snd_ctl_led_hello() function (CI warning) - make snd_ctl_led_get_by_access() function static (CI warning) - move snd_ctl_layer_rwsem lock before the registraction callback call in snd_ctl_register_layer() - optimization v1: - https://lore.kernel.org/alsa-devel/20210211111400.1131020-1-perex@perex.cz/ Original RFC: - https://lore.kernel.org/alsa-devel/20210207201157.869972-1-perex@perex.cz/ Cc: Hans de Goede Cc: Perry Yuan Jaroslav Kysela (5): ALSA: control - introduce snd_ctl_notify_one() helper ALSA: control - add layer registration routines ALSA: control - add generic LED trigger module as the new control layer ALSA: HDA - remove the custom implementation for the audio LED trigger ALSA: control - add sysfs support to the LED trigger module include/sound/control.h | 27 ++- include/uapi/sound/asound.h | 6 +- sound/core/Kconfig | 6 + sound/core/Makefile | 2 + sound/core/control.c | 179 ++++++++++++--- sound/core/control_led.c | 377 ++++++++++++++++++++++++++++++++ sound/pci/hda/Kconfig | 4 +- sound/pci/hda/hda_codec.c | 69 +----- sound/pci/hda/hda_generic.c | 162 +++----------- sound/pci/hda/hda_generic.h | 15 +- sound/pci/hda/hda_local.h | 16 +- sound/pci/hda/patch_ca0132.c | 4 +- sound/pci/hda/patch_realtek.c | 2 +- sound/pci/hda/patch_sigmatel.c | 6 +- sound/pci/hda/thinkpad_helper.c | 2 +- 15 files changed, 614 insertions(+), 263 deletions(-) create mode 100644 sound/core/control_led.c