ALSA: dice: optimize reading of consecutive registers
authorClemens Ladisch <clemens@ladisch.de>
Sun, 4 Sep 2011 20:17:31 +0000 (22:17 +0200)
committerClemens Ladisch <clemens@ladisch.de>
Sun, 20 Oct 2013 20:07:57 +0000 (22:07 +0200)
Instead of reading two consecutive register with two quadlet requests,
use one block read request.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
sound/firewire/dice.c

index 8804e42a96c691062c363570a2f2901bedbb53ab..e1d8dff2339711d0cbb41eaa5880b8dc237f1b9c 100644 (file)
@@ -374,8 +374,8 @@ static int dice_open(struct snd_pcm_substream *substream)
        };
        struct dice *dice = substream->private_data;
        struct snd_pcm_runtime *runtime = substream->runtime;
-       __be32 clock_sel, number_audio, number_midi;
-       unsigned int rate_index, rate;
+       __be32 clock_sel, data[2];
+       unsigned int rate_index, number_audio, number_midi;
        int err;
 
        err = dice_try_lock(dice);
@@ -393,30 +393,25 @@ static int dice_open(struct snd_pcm_substream *substream)
                err = -ENXIO;
                goto err_lock;
        }
-       rate = dice_rates[rate_index];
 
-       err = snd_fw_transaction(dice->unit, TCODE_READ_QUADLET_REQUEST,
+       err = snd_fw_transaction(dice->unit, TCODE_READ_BLOCK_REQUEST,
                                 rx_address(dice, RX_NUMBER_AUDIO),
-                                &number_audio, 4);
-       if (err < 0)
-               goto err_lock;
-       err = snd_fw_transaction(dice->unit, TCODE_READ_QUADLET_REQUEST,
-                                rx_address(dice, RX_NUMBER_MIDI),
-                                &number_midi, 4);
+                                data, 2 * 4);
        if (err < 0)
                goto err_lock;
+       number_audio = be32_to_cpu(data[0]);
+       number_midi = be32_to_cpu(data[1]);
 
        runtime->hw = hardware;
 
-       runtime->hw.rates = snd_pcm_rate_to_rate_bit(rate);
+       runtime->hw.rates = snd_pcm_rate_to_rate_bit(dice_rates[rate_index]);
        snd_pcm_limit_hw_rates(runtime);
 
-       runtime->hw.channels_min = be32_to_cpu(number_audio);
-       runtime->hw.channels_max = be32_to_cpu(number_audio);
+       runtime->hw.channels_min = number_audio;
+       runtime->hw.channels_max = number_audio;
 
-       amdtp_out_stream_set_parameters(&dice->stream, rate,
-                                       be32_to_cpu(number_audio),
-                                       be32_to_cpu(number_midi));
+       amdtp_out_stream_set_parameters(&dice->stream, dice_rates[rate_index],
+                                       number_audio, number_midi);
 
        err = snd_pcm_hw_constraint_step(runtime, 0,
                                         SNDRV_PCM_HW_PARAM_PERIOD_SIZE,