ALSA: firewire-motu: use table-based calculation of packet formats for stream management
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Tue, 19 May 2020 11:16:37 +0000 (20:16 +0900)
committerTakashi Iwai <tiwai@suse.de>
Fri, 22 May 2020 14:52:16 +0000 (16:52 +0200)
This commit uses table-based calculation of packet formats for stream
management.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20200519111641.123211-11-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/firewire/motu/amdtp-motu.c
sound/firewire/motu/motu-stream.c

index 17c9ea8..edb31ac 100644 (file)
@@ -76,15 +76,11 @@ int amdtp_motu_set_parameters(struct amdtp_stream *s, unsigned int rate,
        if (i == ARRAY_SIZE(snd_motu_clock_rates))
                return -EINVAL;
 
-       pcm_chunks = formats->fixed_part_pcm_chunks[mode] +
-                    formats->differed_part_pcm_chunks[mode];
+       // Each data block includes SPH in its head. Data chunks follow with
+       // 3 byte alignment. Padding follows with zero to conform to quadlet
+       // alignment.
+       pcm_chunks = formats->pcm_chunks[mode];
        data_chunks = formats->msg_chunks + pcm_chunks;
-
-       /*
-        * Each data block includes SPH in its head. Data chunks follow with
-        * 3 byte alignment. Padding follows with zero to conform to quadlet
-        * alignment.
-        */
        data_block_quadlets = 1 + DIV_ROUND_UP(data_chunks * 3, 4);
 
        err = amdtp_stream_set_parameters(s, rate, data_block_quadlets);
index 87a8d90..2028c54 100644 (file)
@@ -201,9 +201,9 @@ static int ensure_packet_formats(struct snd_motu *motu)
        data &= ~(TX_PACKET_EXCLUDE_DIFFERED_DATA_CHUNKS |
                  RX_PACKET_EXCLUDE_DIFFERED_DATA_CHUNKS|
                  TX_PACKET_TRANSMISSION_SPEED_MASK);
-       if (motu->tx_packet_formats.differed_part_pcm_chunks[0] == 0)
+       if (motu->spec->tx_fixed_pcm_chunks[0] == motu->tx_packet_formats.pcm_chunks[0])
                data |= TX_PACKET_EXCLUDE_DIFFERED_DATA_CHUNKS;
-       if (motu->rx_packet_formats.differed_part_pcm_chunks[0] == 0)
+       if (motu->spec->rx_fixed_pcm_chunks[0] == motu->rx_packet_formats.pcm_chunks[0])
                data |= RX_PACKET_EXCLUDE_DIFFERED_DATA_CHUNKS;
        data |= fw_parent_device(motu->unit)->max_speed;