summaryrefslogtreecommitdiff
path: root/sound/firewire
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2021-10-27 21:55:29 +0900
committerTakashi Iwai <tiwai@suse.de>2021-10-28 09:10:41 +0200
commit407359d44ed33974137b9158da356d53f999dcf2 (patch)
tree7283810d3c485c7646cc052ca50e5ab9ea696fed /sound/firewire
parent0f166e1257a1e24571381b857632b6c7c6ac3a0b (diff)
downloadlinux-rpi-407359d44ed33974137b9158da356d53f999dcf2.tar.gz
linux-rpi-407359d44ed33974137b9158da356d53f999dcf2.tar.bz2
linux-rpi-407359d44ed33974137b9158da356d53f999dcf2.zip
ALSA: firewire-motu: export meter information to userspace as float value
In command DSP models, one meter information consists of 4 bytes for IEEE 764 floating point (binary32). In previous patch, it is exported to userspace as 32 bit storage since the storage is also handled in ALSA firewire-motu driver as well in kernel space in which floating point arithmetic is not preferable. On the other hand, ALSA firewire-motu driver doesn't perform floating point calculation. The driver just gather meter information from isochronous packets and fill structure fields for userspace. In 'header' target of Kbuild, UAPI headers are processed before installed. In this timing, #ifdef macro with __KERNEL__ is removed. This mechanism is useful in the case so that the 32 bit storage can be accessible as u32 type in kernel space and float type in user space. We can see the same usage in ''struct acct_v3' in 'include/uapi/linux/acct.h'. This commit is for the above idea. Additionally, due to message protocol, meter information is filled with 0xffffffff in the end of period but 0xffffffff is invalid as binary32. To avoid confusion in userspace application, the last two elements are left without any assignment. Suggested-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20211027125529.54295-4-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire')
-rw-r--r--sound/firewire/motu/motu-command-dsp-message-parser.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sound/firewire/motu/motu-command-dsp-message-parser.c b/sound/firewire/motu/motu-command-dsp-message-parser.c
index 18689fcfb288..9efe4d364baf 100644
--- a/sound/firewire/motu/motu-command-dsp-message-parser.c
+++ b/sound/firewire/motu/motu-command-dsp-message-parser.c
@@ -141,12 +141,15 @@ void snd_motu_command_dsp_message_parser_parse(struct snd_motu *motu, const stru
++parser->fragment_pos;
if (parser->fragment_pos == 4) {
+ // Skip the last two quadlets since they could be
+ // invalid value (0xffffffff) as floating point
+ // number.
if (parser->value_index <
- SNDRV_FIREWIRE_MOTU_COMMAND_DSP_METER_COUNT) {
+ SNDRV_FIREWIRE_MOTU_COMMAND_DSP_METER_COUNT - 2) {
u32 val = (u32)(parser->value >> 32);
parser->meter.data[parser->value_index] = val;
- ++parser->value_index;
}
+ ++parser->value_index;
parser->fragment_pos = 0;
}