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=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, 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 62076C433E0 for ; Mon, 25 Jan 2021 14:33:12 +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 BBE942228A for ; Mon, 25 Jan 2021 14:33:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BBE942228A 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 E1669183D; Mon, 25 Jan 2021 15:32:19 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E1669183D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1611585190; bh=aWSHaF1nqcuVQXwiMzkLvGtge2pto/xi+N7XQqcteK8=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=rMrhdn4qWGLSqggEHwqBa+jF3F8A1PilNCJerBJl8piGf7YGmDEc8xKc1C3MYPc8n fW++B2uyuynv1pRbOzwLsgO1B72VYnoVQ4WMzw26Q7qMR2/RiGsEEWHclJOhanNECN 2c9MlWNRGkdZEv5rM2/YgO7wM9MeYQPziupUAHE4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 6957FF8012D; Mon, 25 Jan 2021 15:32:19 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 517F7F80259; Mon, 25 Jan 2021 15:32: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 04E47F8012D for ; Mon, 25 Jan 2021 15:32:10 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 04E47F8012D 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 EAB82B9BA; Mon, 25 Jan 2021 14:32:09 +0000 (UTC) Date: Mon, 25 Jan 2021 15:32:09 +0100 Message-ID: From: Takashi Iwai To: Hui Wang Subject: Re: [PATCH v7 1/1] alsa: jack: implement software jack injection via debugfs In-Reply-To: <20210125032118.13269-2-hui.wang@canonical.com> References: <20210125032118.13269-1-hui.wang@canonical.com> <20210125032118.13269-2-hui.wang@canonical.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=UTF-8 Content-Transfer-Encoding: 8bit Cc: alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com 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 Mon, 25 Jan 2021 04:21:18 +0100, Hui Wang wrote: > > This change adds audio jack injection feature through debugfs, with > this feature, we could validate alsa userspace changes by injecting > plugin or plugout events to the non-phantom audio jacks. > > With this change, the sound core will build the folders > $debugfs_mount_dir/sound/cardN if SND_DEBUG and DEBUG_FS are enabled. > And if users also enable the SND_JACK_INJECTION_DEBUG, the jack > injection nodes will be built in the folder cardN like below: > > $tree $debugfs_mount_dir/sound > $debugfs_mount_dir/sound > ├── card0 > │   ├── HDMI_DP_pcm_10_Jack > │   │   ├── jackin_inject > │   │   ├── kctl_id > │   │   ├── mask_bits > │   │   ├── status > │   │   ├── sw_inject_enable > │   │   └── type > ... > │   └── HDMI_DP_pcm_9_Jack > │   ├── jackin_inject > │   ├── kctl_id > │   ├── mask_bits > │   ├── status > │   ├── sw_inject_enable > │   └── type > └── card1 > ├── HDMI_DP_pcm_5_Jack > │   ├── jackin_inject > │   ├── kctl_id > │   ├── mask_bits > │   ├── status > │   ├── sw_inject_enable > │   └── type > ... > ├── Headphone_Jack > │   ├── jackin_inject > │   ├── kctl_id > │   ├── mask_bits > │   ├── status > │   ├── sw_inject_enable > │   └── type > └── Headset_Mic_Jack > ├── jackin_inject > ├── kctl_id > ├── mask_bits > ├── status > ├── sw_inject_enable > └── type > > The nodes kctl_id, mask_bits, status and type are read-only, users > could check jack or jack_kctl's information through them. > > The nodes sw_inject_enable and jackin_inject are directly used for > injection. The sw_inject_enable is read-write, users could check if > software injection is enabled or not on this jack, and users could > echo 1 or 0 to enable or disable software injection on this jack. Once > the injection is enabled, the jack will not change by hardware events > anymore, once the injection is disabled, the jack will restore the > last reported hardware events to the jack. The jackin_inject is > write-only, if the injection is enabled, users could echo 1 or 0 to > this node to inject plugin or plugout events to this jack. > > For the detailed usage information on these nodes, please refer to > Documentation/sound/designs/jack-injection.rst. > > Reviewed-by: Takashi Iwai > Reviewed-by: Jaroslav Kysela > Reviewed-by: Kai Vehmanen > Signed-off-by: Hui Wang Some minor nitpicking: > +static int snd_jack_debugfs_add_inject_node(struct snd_jack *jack, > + struct snd_jack_kctl *jack_kctl) > +{ > + char *tname; > + int i; > + > + tname = kstrdup(jack_kctl->kctl->id.name, GFP_KERNEL); > + if (!tname) > + return -ENOMEM; > + > + /* replace the chars which are not suitable for folder's name with _ */ > + for (i = 0; i < strlen(tname); i++) No need to use strlen(), just check the NUL character on tname[i]. > --- a/sound/core/sound.c > +++ b/sound/core/sound.c > @@ -9,6 +9,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -39,6 +40,9 @@ MODULE_ALIAS_CHARDEV_MAJOR(CONFIG_SND_MAJOR); > int snd_ecards_limit; > EXPORT_SYMBOL(snd_ecards_limit); > > +struct dentry *sound_debugfs_root; > +EXPORT_SYMBOL_GPL(sound_debugfs_root); I guess this should be wrapped with CONFIG_SND_DEBUG ifdef? thanks, Takashi