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=-8.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 E1B94C433C1 for ; Sat, 20 Mar 2021 07:42:13 +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 7D06061998 for ; Sat, 20 Mar 2021 07:42:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7D06061998 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de 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 0E50A167D; Sat, 20 Mar 2021 08:41:19 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0E50A167D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1616226129; bh=WBWK3EtUPpTpTJmpgUb+kzH/A7EP4Fwbgp7cbdYa2GM=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=L1E7ajPQtDlfa2wfRZmBMGPItYaBtLEkn67dtz0qWDOgyxS4aoKLY4WgSaqBflVlt UWBv9f50AQZ3J4+a+1DK3K4pqxoVH+tTfIux+SsWZwL384CvN29DJf+eDht/bg5d/L YAC60KsKULzmpjYiwysKJulkt1bpC5n3a1/dVsII= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 784C0F80163; Sat, 20 Mar 2021 08:41:18 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1BE54F80165; Sat, 20 Mar 2021 08:41:17 +0100 (CET) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B4B54F80118 for ; Sat, 20 Mar 2021 08:41:10 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B4B54F80118 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 6DED4AC71; Sat, 20 Mar 2021 07:41:09 +0000 (UTC) Date: Sat, 20 Mar 2021 08:41:09 +0100 Message-ID: From: Takashi Iwai To: Hans de Goede Subject: Re: [PATCH v4 6/6] ALSA: led control - add sysfs kcontrol LED marking layer In-Reply-To: <3820909c-29ce-9f3f-d1e6-c4611e06abe4@redhat.com> References: <20210317172945.842280-1-perex@perex.cz> <20210317172945.842280-7-perex@perex.cz> <3820909c-29ce-9f3f-d1e6-c4611e06abe4@redhat.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: ALSA development 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" On Fri, 19 Mar 2021 23:08:33 +0100, Hans de Goede wrote: > > Hi, > > On 3/19/21 6:22 PM, Takashi Iwai wrote: > > On Fri, 19 Mar 2021 17:34:39 +0100, > > Hans de Goede wrote: > >> > >> Hi, > >> > >> On 3/17/21 6:29 PM, Jaroslav Kysela wrote: > >>> We need to manage the kcontrol entries association for the LED trigger > >>> from the user space. This patch adds a layer to the sysfs tree like: > >>> > >>> /sys/devices/virtual/sound/ctl-led/mic > >>> + card0 > >>> | + attach > >>> | + detach > >>> | ... > >>> + card1 > >>> + attach > >>> ... > >>> > >>> Operations: > >>> > >>> attach and detach > >>> - amixer style ID is accepted and easy strings for numid and > >>> simple names > >>> reset > >>> - reset all associated kcontrol entries > >>> list > >>> - list associated kcontrol entries (numid values only) > >>> > >>> Additional symlinks: > >>> > >>> /sys/devices/virtual/sound/ctl-led/mic/card0/card -> > >>> /sys/class/sound/card0 > >>> > >>> /sys/class/sound/card0/controlC0/led-mic -> > >>> /sys/devices/virtual/sound/ctl-led/mic/card0 > >>> > >>> Signed-off-by: Jaroslav Kysela > >> > >> Thank you so much for this patch. > >> > >> I've given this new version a try, dropping my sound/soc/codecs/rt56??.c patches to set the access-flags directly. > >> > >> And with these 3 lines in /etc/rc.d/rc.local I get nicely working control of the mute > >> LED build into the (detachable) USB-keyboard's mute hot-key: > >> > >> modprobe snd_ctl_led > >> echo -n name="Speaker Channel Switch" > /sys/class/sound/card1/controlC1/led-speaker/attach > >> echo -n name="HP Channel Switch" > /sys/class/sound/card1/controlC1/led-speaker/attach > >> > >> This needs to be replaced by some UCM profile code doing the equivalent of course, > >> but for a proof-of-concept test of the kernel API this introduces the above will do. > > > > IMO, that's the question: how we'll enable this in future. If the > > binding of the control/mute mapping is provided via UCM, it's supposed > > to be changeable by each user. Then the current sysfs permission > > doesn't fit. OTOH, if it's 0666, it's accessible to all users even > > remotely, which is worse than the access with the normal sound device > > file. Or if it's supposed to be changed via udev stuff or systemd? > > Or is it just for debugging? > > > > Through a quick glance over the series, I'm fine to take those > > patches, but the only concern is the sysfs entries. Basically, once > > when we use sysfs entries, it's set in stone. So we should be very > > clear about our strategy how to deploy the control/mute mapping > > regarding using those sysfs entries. > > > > OTOH, if the interface is thought for debugging or development > > purpose, it could be done in debugfs, which we can keep playing in > > further development, too. > > > > And, BTW, the mute LED mode setup doesn't have to be sysfs entries; > > we'd need primarily only the flags for inverted LED behavior, and > > those are only two, so it could be simply module options. Then it's > > even easier for users to set up than tweaking sysfs entries. > > The flexibility offered by this new sysfs API is necessary for the ASoC > codec drivers, because Mark does not want to have which controls are > tied to the LED triggers hard-coded inside the codec drivers. The hard-coded mapping itself isn't always bad things, IMO. Of course, it's a question whether to be done in the codec driver in a fixed routing. A machine driver would fit well, instead; i.e. instead of the control-access bit flag, just bind statically from the machine driver after instantiating the kctl objects like sysfs does. > So as Jaroslav mentions in his reply, the plan is to have the UCM > profiles contain commands to setup the LED triggers to this new > sysfs API. IIUC, this won't be only UCM but also the combination of udev + alsactl + UCM, right? Would other OS can follow a similar pattern? Let's check that first (although I myself think this should be feasible). thanks, Takashi