From mboxrd@z Thu Jan 1 00:00:00 1970 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.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 974E4C10DCE for ; Tue, 24 Mar 2020 03:41:19 +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 1A3302073E for ; Tue, 24 Mar 2020 03:41:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="eKZuYtGg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1A3302073E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com 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 5004086F; Tue, 24 Mar 2020 04:40:27 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5004086F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1585021277; bh=ISzvoINRWyOubaRFeP4tv27fOomfgjXpcqnsZpCynCA=; h=Subject:To:References:From:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=eKZuYtGgcQd0FjHSlQ0UEk0bEN81aql3nFjJmslVTTEdH1dj2/QzbA7KzokSZfUqc oM3DsHLY2OhL6pdchNTiGLfCNAQtxlSwvt4to2sfo365uhrlcN4IXotgFe13fwT2X+ wgdWLp4PGfw1c2DNmXEfg74aZYxXkwFBjngPDB2A= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C668BF801F8; Tue, 24 Mar 2020 04:40:26 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id F1299F801F9; Tue, 24 Mar 2020 04:40:23 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 4BD41F800FE for ; Tue, 24 Mar 2020 04:40:18 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4BD41F800FE IronPort-SDR: J+p+IfQc8U7rxTq8HH2KNS+fBzbQHd8X6Uz9Ny/NndxxO8v9DN8vPy+NEJZzwSfOso/i1rcYxa ECWBSLlblDEw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2020 20:40:15 -0700 IronPort-SDR: Oz2Cs+8ZFG8ghLkuJgLVF8bqsKfJMSRIHsfec49xmZJeL0FJeYlpNHrBY4GjUQ9h9o0SDkHA2z 4o1Lq7sI0a0A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,298,1580803200"; d="scan'208";a="238088986" Received: from chialinh-mobl1.amr.corp.intel.com (HELO [10.134.83.72]) ([10.134.83.72]) by fmsmga007.fm.intel.com with ESMTP; 23 Mar 2020 20:40:14 -0700 Subject: Re: [PATCH] ALSA: core: sysfs: show components string To: alsa-devel@alsa-project.org, tiwai@suse.de, broonie@kernel.org References: <20200323193623.3587-1-pierre-louis.bossart@linux.intel.com> <20200324015331.GA3679@workstation> From: Pierre-Louis Bossart Message-ID: Date: Mon, 23 Mar 2020 22:34:23 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200324015331.GA3679@workstation> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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 3/23/20 8:53 PM, Takashi Sakamoto wrote: > Hi, > > On Mon, Mar 23, 2020 at 02:36:23PM -0500, Pierre-Louis Bossart wrote: >> Add attribute and show the components string. This is useful to see >> what is provided to userspace and e.g. used by UCM to understand the >> card configuration: >> >> root@plb:~# more /sys/class/sound/card0/components >> HDA:8086280b,80860101,00100000 cfg-spk:2 hs:rt711 spk:rt1308 mic:rt715 >> >> Note that the style uses what's recommended by checkpatch.pl and is >> slightly different from other sysfs attributes. >> >> Signed-off-by: Pierre-Louis Bossart >> --- >> sound/core/init.c | 12 ++++++++++++ >> 1 file changed, 12 insertions(+) > > I have a concern about this patch in a point of userspace interface. > > The 'component' field of 'struct snd_ctl_card_info' is just defined to > have strings with space-separated chunks, and its actual value is not > so fine-documented, thus it's largely different depending of developers > of each driver. In case you missed it, the components are used by machine drivers to report e.g. number of speakers, mics, etc, so that UCM can find the right configuration. For a given family of products, the syntax will be fixed, e.g. hs stands for headset codec, etc. > $ cat include/uapi/sound/asound.h > ... > 941 struct snd_ctl_card_info { > ... > 950 unsigned char components[128]; /* card components / fine identification, delimited with one space (AC97 etc..) */ > 951 }; > > On the other hand, the node of sysfs is quite common in Linux because > it's tightly coupled to kernel objects. Let you see files under > 'Documentation/ABI/'. We can find efforts to maintain sysfs node so > safe and stable. Due to this reason, it's better to take more care when > adding new node. > > Would I request you the reason to add this node and the reason that > current ALSA control interface doesn't satisfy your requirement? simplicity for user support. Anyone can peak at a sysfs file, not everyone is familiar with the alsa control interface. We get lots of bug reports from people who are asking for configuration help, and the simpler the command is the better. >> diff --git a/sound/core/init.c b/sound/core/init.c >> index b02a99766351..decaf944a8ad 100644 >> --- a/sound/core/init.c >> +++ b/sound/core/init.c >> @@ -695,9 +695,21 @@ card_number_show_attr(struct device *dev, >> >> static DEVICE_ATTR(number, 0444, card_number_show_attr, NULL); >> >> +static ssize_t >> +components_show(struct device *dev, >> + struct device_attribute *attr, char *buf) >> +{ >> + struct snd_card *card = container_of(dev, struct snd_card, card_dev); >> + >> + return scnprintf(buf, PAGE_SIZE, "%s\n", card->components); >> +} >> + >> +static DEVICE_ATTR_RO(components); >> + >> static struct attribute *card_dev_attrs[] = { >> &dev_attr_id.attr, >> &dev_attr_number.attr, >> + &dev_attr_components.attr, >> NULL >> }; >> >> -- >> 2.20.1 > > > Regards > > Takashi Sakamoto >