Commit f6dbe1be authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Takashi Iwai

ALSA: snd_pcm_oss_period_size: Use round{up,down}_pow_of_two()

Instead of opencoding them use the standard roundup_pow_of_two() and
rounddown_pow_of_two() helper functions. This gets rids one of the few users
of the custom ld2() function and also makes it a bit more obvious what the
code does.
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 599ee329
...@@ -719,7 +719,7 @@ static int snd_pcm_oss_period_size(struct snd_pcm_substream *substream, ...@@ -719,7 +719,7 @@ static int snd_pcm_oss_period_size(struct snd_pcm_substream *substream,
oss_buffer_size = snd_pcm_plug_client_size(substream, oss_buffer_size = snd_pcm_plug_client_size(substream,
snd_pcm_hw_param_value_max(slave_params, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, NULL)) * oss_frame_size; snd_pcm_hw_param_value_max(slave_params, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, NULL)) * oss_frame_size;
oss_buffer_size = 1 << ld2(oss_buffer_size); oss_buffer_size = rounddown_pow_of_two(oss_buffer_size);
if (atomic_read(&substream->mmap_count)) { if (atomic_read(&substream->mmap_count)) {
if (oss_buffer_size > runtime->oss.mmap_bytes) if (oss_buffer_size > runtime->oss.mmap_bytes)
oss_buffer_size = runtime->oss.mmap_bytes; oss_buffer_size = runtime->oss.mmap_bytes;
...@@ -755,14 +755,14 @@ static int snd_pcm_oss_period_size(struct snd_pcm_substream *substream, ...@@ -755,14 +755,14 @@ static int snd_pcm_oss_period_size(struct snd_pcm_substream *substream,
min_period_size = snd_pcm_plug_client_size(substream, min_period_size = snd_pcm_plug_client_size(substream,
snd_pcm_hw_param_value_min(slave_params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, NULL)); snd_pcm_hw_param_value_min(slave_params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, NULL));
min_period_size *= oss_frame_size; min_period_size *= oss_frame_size;
min_period_size = 1 << (ld2(min_period_size - 1) + 1); min_period_size = roundup_pow_of_two(min_period_size);
if (oss_period_size < min_period_size) if (oss_period_size < min_period_size)
oss_period_size = min_period_size; oss_period_size = min_period_size;
max_period_size = snd_pcm_plug_client_size(substream, max_period_size = snd_pcm_plug_client_size(substream,
snd_pcm_hw_param_value_max(slave_params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, NULL)); snd_pcm_hw_param_value_max(slave_params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, NULL));
max_period_size *= oss_frame_size; max_period_size *= oss_frame_size;
max_period_size = 1 << ld2(max_period_size); max_period_size = rounddown_pow_of_two(max_period_size);
if (oss_period_size > max_period_size) if (oss_period_size > max_period_size)
oss_period_size = max_period_size; oss_period_size = max_period_size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment