Skip to content

Commit

Permalink
ALSA: dice: optimize reading of consecutive registers
Browse files Browse the repository at this point in the history
Instead of reading two consecutive register with two quadlet requests,
use one block read request.

Signed-off-by: Clemens Ladisch <[email protected]>
  • Loading branch information
cladisch committed Oct 20, 2013
1 parent a7304e3 commit a644a94
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions sound/firewire/dice.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
Expand Down

0 comments on commit a644a94

Please sign in to comment.