ALSA: core: sysfs: show components string
PATCH 1/1 ALSA: core: sysfs: show components string
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.
--- sound/core/init.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
sound/core/init.c +12 -0
@@ -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 };
Signature · 1 line
2.20.1
Quoted 6 lines · Pierre-Louis Bossart
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
Sysfs is supposed to be one value per file so this should be a directory with a file for each component I guess.
Quoted 10 lines · Mark Brown
Quoted 6 lines · Pierre-Louis Bossart
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:rt715Sysfs is supposed to be one value per file so this should be a directory with a file for each component I guess.
that's fair, but the 'value' is already a string here. There's no syntax or grammar that would define what the contents of the string would be, so it'd be difficult to define any sort of ABI. Are you saying sysfs can't be used here?
Quoted 11 lines · Mark Brown
Quoted 6 lines · Pierre-Louis Bossart
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:rt715Sysfs is supposed to be one value per file so this should be a directory with a file for each component I guess.
Well, the actual representation of components itself is CSV, so this can be OK, IMO.
Takashi
Hi,
Quoted 7 lines · Pierre-Louis Bossart
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
Quoted 7 lines
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 <[email protected]>--- 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.
$ 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?
Quoted 28 lines
sound/core/init.c +12
-0@@ -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 };Signature · 1 line
2.20.1
Regards
Takashi Sakamoto
Quoted 18 lines · Takashi Sakamoto
Hi,
Quoted 7 lines · Pierre-Louis Bossart
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:rt715Quoted 7 lines
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 <[email protected]>--- sound/core/init.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
Quoted 6 lines
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.
Quoted 7 lines
$ 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 };Quoted 8 lines
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.
Quoted 34 lines
Quoted 28 lines
sound/core/init.c +12
-0@@ -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 };Signature · 1 line
2.20.1Regards
Takashi Sakamoto
Quoted 25 lines · Pierre-Louis Bossart
Quoted 17 lines · Takashi Sakamoto
Hi,
Quoted 7 lines · Pierre-Louis Bossart
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:rt715Quoted 7 lines
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 <[email protected]>--- sound/core/init.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)Quoted 6 lines
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.
Quoted 4 lines
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.
Actually the syntax is just fixed to devices which a part of ALSA in-kernel driver supports. There's no specification widely used to all of ALSA in-kernel drivers.
(Of cource, it covers many of actual devices which assumed users own.)
Quoted 13 lines
Quoted 13 lines
$ 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.
Quoted 8 lines
Quoted 2 lines
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.
For my information, would I request you to disclose the part of such reports?
I need supplemental information about the reason to add the alternative path to expose it, especially the reason that no developers work to improve existent tool relevant to UCM and are going to wish to add the alternative without utilizing ALSA control character device.
Regards
Takashi Sakamoto
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
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.Quoted 8 lines
Quoted 2 lines
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.
Quoted 6 lines
For my information, would I request you to disclose the part of such reports?
I need supplemental information about the reason to add the alternative path to expose it, especially the reason that no developers work to improve existent tool relevant to UCM and are going to wish to add the alternative without utilizing ALSA control character device.
I don't understand your question, sorry. UCM already uses the control interface, it's not a matter of adding a new interface but making it easier to visualize the contents reported by the machine driver.
See for example https://github.com/alsa-project/alsa-ucm-conf/blob/4722f5b3859903521ba0f92a64d86af31083ca50/ucm2/sof-hda-dsp/HiFi.conf#L145
when people report that their microphone is not reported by PulseAudio/UCM, it's very helpful to know what UCM was supposed to use in the first place. We don't have a debugger or step-by-step mechanisms to figure out what the configurations are.
There is zero intent to advertise this sysfs node as a basis for applications to bypass the control interface, if that was what you thought I was promoting.
Quoted 4 lines · Pierre-Louis Bossart
when people report that their microphone is not reported by PulseAudio/UCM, it's very helpful to know what UCM was supposed to use in the first place. We don't have a debugger or step-by-step mechanisms to figure out what the configurations are.
If I get your intension correctly, the addition of sysfs node is just to investigate which use-case configuration is applied in cases that people get issues. If so, it's really exaggerative in a point of the concept of sysfs.
I have two alternatives. If it's possible to focus on ALSA SoC part only, addition of node to debugfs is reasonable for this purpose.
Another alternative is to change output of 'cards' node of procfs. The latter is commonly available for all cases. For example:
sound/core/init.c +2 -0
@@ -805,6 +805,8 @@ static void snd_card_info_read(struct snd_info_entry *entry, card->shortname);snd_iprintf (buffer," %s\n" , card->longname); +snd_iprintf (buffer," %s\n" , + card->component); }mutex_unlock (&snd_card_mutex); }
(If you're investigating to use rules of udevd for automated application of UCM-based operation, there's a space to investigate the merit to expose information via sysfs node. But actually you're not...)
Regards
Takashi Sakamoto
Quoted 11 lines · Takashi Sakamoto
Quoted 4 lines · Pierre-Louis Bossart
when people report that their microphone is not reported by PulseAudio/UCM, it's very helpful to know what UCM was supposed to use in the first place. We don't have a debugger or step-by-step mechanisms to figure out what the configurations are.
If I get your intension correctly, the addition of sysfs node is just to investigate which use-case configuration is applied in cases that people get issues. If so, it's really exaggerative in a point of the concept of sysfs.
Quoted 5 lines
I have two alternatives. If it's possible to focus on ALSA SoC part only, addition of node to debugfs is reasonable for this purpose.
Another alternative is to change output of 'cards' node of procfs. The latter is commonly available for all cases. For example:
I initially wanted to use /proc but thought it was a thing from the past so I looked at sysfs. If this is the recommendation I don't mind using it.
debugsfs is not something the average user is familiar with, and it's not available in all cases. I'd like to extend existing pieces of information than add new things.
Jaroslav Kysela
maintainerDne 24. 03. 20 v 14:15 Pierre-Louis Bossart napsal(a):
Quoted 20 lines · Takashi Sakamoto
Quoted 11 lines · Pierre-Louis Bossart
Quoted 4 lines
when people report that their microphone is not reported by PulseAudio/UCM, it's very helpful to know what UCM was supposed to use in the first place. We don't have a debugger or step-by-step mechanisms to figure out what the configurations are.
If I get your intension correctly, the addition of sysfs node is just to investigate which use-case configuration is applied in cases that people get issues. If so, it's really exaggerative in a point of the concept of sysfs.
Quoted 5 lines
I have two alternatives. If it's possible to focus on ALSA SoC part only, addition of node to debugfs is reasonable for this purpose.
Another alternative is to change output of 'cards' node of procfs. The latter is commonly available for all cases. For example:
Quoted 6 lines
I initially wanted to use /proc but thought it was a thing from the past so I looked at sysfs. If this is the recommendation I don't mind using it.
debugsfs is not something the average user is familiar with, and it's not available in all cases. I'd like to extend existing pieces of information than add new things.
I won't modify /proc/asound/cards in this case, but create a per card file like /proc/asound/card#/components .
Thanks,
Jaroslav
Signature · 2 lines
Jaroslav Kysela <[email protected]> Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
Quoted 18 lines · Pierre-Louis Bossart
Quoted 14 lines · Takashi Sakamoto
Quoted 4 lines · Pierre-Louis Bossart
when people report that their microphone is not reported by PulseAudio/UCM, it's very helpful to know what UCM was supposed to use in the first place. We don't have a debugger or step-by-step mechanisms to figure out what the configurations are.
If I get your intension correctly, the addition of sysfs node is just to investigate which use-case configuration is applied in cases that people get issues. If so, it's really exaggerative in a point of the concept of sysfs.
I have two alternatives. If it's possible to focus on ALSA SoC part only, addition of node to debugfs is reasonable for this purpose.
Quoted 6 lines
Quoted 2 lines
Another alternative is to change output of 'cards' node of procfs. The latter is commonly available for all cases. For example:
I initially wanted to use /proc but thought it was a thing from the past so I looked at sysfs. If this is the recommendation I don't mind using it.
procfs will practically never die, and it's already there, so I'm fine with that path, too, supposing that the primary purpose is for help debugging / analyzing. If it's used by UCM or whatever configuration tool, sysfs is the better choice, OTOH.
Quoted 3 lines
debugsfs is not something the average user is familiar with, and it's not available in all cases. I'd like to extend existing pieces of information than add new things.
Right, debugfs isn't available per card as default, so it's no good option.
Takashi
Quoted 26 lines
Quoted 14 lines
Quoted 14 lines
Quoted 5 lines
when people report that their microphone is not reported by PulseAudio/UCM, it's very helpful to know what UCM was supposed to use in the first place. We don't have a debugger or step-by-step mechanisms to figure out what the configurations are.
If I get your intension correctly, the addition of sysfs node is just to investigate which use-case configuration is applied in cases that people get issues. If so, it's really exaggerative in a point of the concept of sysfs.
I have two alternatives. If it's possible to focus on ALSA SoC part only, addition of node to debugfs is reasonable for this purpose.
Quoted 6 lines
Quoted 2 lines
Another alternative is to change output of 'cards' node of procfs. The latter is commonly available for all cases. For example:
I initially wanted to use /proc but thought it was a thing from the past so I looked at sysfs. If this is the recommendation I don't mind using it.
procfs will practically never die, and it's already there, so I'm fine with that path, too, supposing that the primary purpose is for help debugging / analyzing. If it's used by UCM or whatever configuration tool, sysfs is the better choice, OTOH.
Quoted 6 lines
Quoted 3 lines
debugsfs is not something the average user is familiar with, and it's not available in all cases. I'd like to extend existing pieces of information than add new things.
Right, debugfs isn't available per card as default, so it's no good option.
ok, let's go with procfs then, thanks for the feedback. I'll work on an update and resubmit. -Pierre
Quoted 4 lines · Pierre-Louis Bossart
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.
If that's what you're looking for it sounds like a richer sysfs ABI which has these things in it more directly would be a more idiomatic fit (or like Sakamoto-san says adding controls, though that is a barrier to things like udev and so on like you say).