ALSA: firewire-motu: refine parser for meter information in register DSP models
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Wed, 27 Oct 2021 12:55:28 +0000 (21:55 +0900)
committerTakashi Iwai <tiwai@suse.de>
Thu, 28 Oct 2021 07:10:34 +0000 (09:10 +0200)
After further investigation, I realize that the total number of elements
in array is not enough to store all of related messages from device.
This commit refines meter array and message parser.

In terms of channel identifier, register DSP models are classified to
two categories:

1. the target of output is selectable

828mk2, 896hd, and Traveler are in the category. They transfer messages
with channel identifier between 0x00 and 0x13 for input meters,
therefore 20 elements are needed to store.

On the other hand, they transfer messages with channel identifier for one
pair of output meters. The selection is done by asynchronous write
transaction to offset 0x'ffff'f000'0b2c. The table for relationship
between written value and available identifiers is below:

=============  ===============
written value  identifier pair
=============  ===============
0x00000b00     0x80/0x81
0x00000b01     0x82/0x83
...            ...
0x00000b0b     0x96/0x97
...            ...
0x00000b10     0xa0/0xa1
...            ...
0x00000b3f     0xfe/0xff
...            ...
greater        0xfe/0xff
=============  ===============

Actually in the above three models, 0x96/0x97 pair is the maximum. Thus
the number of available output meter is 24.

2. all of output is available

8 pre, Ultralite, Audio Express, and 4 pre are in the category. They
transfer messages for output meters without any selection. The table for
available identifier for each direction is below:

==============  =========  ==========
model           input      output
==============  =========  ==========
8 pre           0x00-0x0f  0x82-0x8d
Ultralite       0x00-0x09  0x82-0x8f
Audio Express   0x00-0x09  0x80-0x8d
4 pre           0x00-0x09  0x80-0x8d
==============  =========  ==========

Some of available identifiers might not be used for actual output meters.

Anyway, 24 plus 24 elements accommodate the input/output meters.

I note that isochronous packet from V3HD/V4HD deliver no message.
Notification by asynchronous transaction to registered address seems to be
used for the purpose as well as for change of mixer parameter.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20211027125529.54295-3-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/uapi/sound/firewire.h
sound/firewire/motu/motu-register-dsp-message-parser.c

index e52a97b3ceaadeff4b738d415c654bc1e82c9994..68eb0e43c052ca040d7428f193bb6ddf7f261729 100644 (file)
@@ -141,7 +141,10 @@ struct snd_firewire_tascam_state {
  * up to 12.
  */
 
-#define SNDRV_FIREWIRE_MOTU_REGISTER_DSP_METER_COUNT   40
+#define SNDRV_FIREWIRE_MOTU_REGISTER_DSP_METER_INPUT_COUNT     24
+#define SNDRV_FIREWIRE_MOTU_REGISTER_DSP_METER_OUTPUT_COUNT    24
+#define SNDRV_FIREWIRE_MOTU_REGISTER_DSP_METER_COUNT \
+       (SNDRV_FIREWIRE_MOTU_REGISTER_DSP_METER_INPUT_COUNT + SNDRV_FIREWIRE_MOTU_REGISTER_DSP_METER_OUTPUT_COUNT)
 
 /**
  * struct snd_firewire_motu_register_dsp_meter - the container for meter information in DSP
index cbc06b3b70f635c6080bb85a6ea2f9d443e9ab7a..0c587567540f22d1f6c77a647a4f015d86014a05 100644 (file)
@@ -335,11 +335,15 @@ void snd_motu_register_dsp_message_parser_parse(struct snd_motu *motu, const str
                                else
                                        pos = b[MSG_METER_IDX_POS_4PRE_AE];
 
-                               if (pos < 0x80)
-                                       pos &= 0x1f;
-                               else
-                                       pos = (pos & 0x1f) + 20;
-                               parser->meter.data[pos] = val;
+                               if (pos < SNDRV_FIREWIRE_MOTU_REGISTER_DSP_METER_INPUT_COUNT) {
+                                       parser->meter.data[pos] = val;
+                               } else if (pos >= 0x80) {
+                                       pos -= (0x80 - SNDRV_FIREWIRE_MOTU_REGISTER_DSP_METER_INPUT_COUNT);
+
+                                       if (pos < SNDRV_FIREWIRE_MOTU_REGISTER_DSP_METER_COUNT)
+                                               parser->meter.data[pos] = val;
+                               }
+
                                // The message for meter is interruptible to the series of other
                                // types of messages. Don't cache it.
                                fallthrough;