Commit d877681d authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hdspm - Simplify with snd_pcm_hw_constraint_pow2()

Refactoring the code using snd_pcm_hw_constraint_pow2() helper function.
Tested-by: default avatarAdrian Knoth <adi@drcomp.erfurt.thur.de>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 3fa9e3d2
...@@ -5705,19 +5705,6 @@ static int snd_hdspm_prepare(struct snd_pcm_substream *substream) ...@@ -5705,19 +5705,6 @@ static int snd_hdspm_prepare(struct snd_pcm_substream *substream)
return 0; return 0;
} }
static unsigned int period_sizes_old[] = {
64, 128, 256, 512, 1024, 2048, 4096, 8192
};
static unsigned int period_sizes_new[] = {
64, 128, 256, 512, 1024, 2048, 4096, 32
};
/* RayDAT and AIO always have a buffer of 16384 samples per channel */
static unsigned int raydat_aio_buffer_sizes[] = {
16384
};
static struct snd_pcm_hardware snd_hdspm_playback_subinfo = { static struct snd_pcm_hardware snd_hdspm_playback_subinfo = {
.info = (SNDRV_PCM_INFO_MMAP | .info = (SNDRV_PCM_INFO_MMAP |
SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_MMAP_VALID |
...@@ -5768,24 +5755,6 @@ static struct snd_pcm_hardware snd_hdspm_capture_subinfo = { ...@@ -5768,24 +5755,6 @@ static struct snd_pcm_hardware snd_hdspm_capture_subinfo = {
.fifo_size = 0 .fifo_size = 0
}; };
static struct snd_pcm_hw_constraint_list hw_constraints_period_sizes_old = {
.count = ARRAY_SIZE(period_sizes_old),
.list = period_sizes_old,
.mask = 0
};
static struct snd_pcm_hw_constraint_list hw_constraints_period_sizes_new = {
.count = ARRAY_SIZE(period_sizes_new),
.list = period_sizes_new,
.mask = 0
};
static struct snd_pcm_hw_constraint_list hw_constraints_raydat_io_buffer = {
.count = ARRAY_SIZE(raydat_aio_buffer_sizes),
.list = raydat_aio_buffer_sizes,
.mask = 0
};
static int snd_hdspm_hw_rule_in_channels_rate(struct snd_pcm_hw_params *params, static int snd_hdspm_hw_rule_in_channels_rate(struct snd_pcm_hw_params *params,
struct snd_pcm_hw_rule *rule) struct snd_pcm_hw_rule *rule)
{ {
...@@ -5986,23 +5955,25 @@ static int snd_hdspm_playback_open(struct snd_pcm_substream *substream) ...@@ -5986,23 +5955,25 @@ static int snd_hdspm_playback_open(struct snd_pcm_substream *substream)
spin_unlock_irq(&hdspm->lock); spin_unlock_irq(&hdspm->lock);
snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE);
switch (hdspm->io_type) { switch (hdspm->io_type) {
case AIO: case AIO:
case RayDAT: case RayDAT:
snd_pcm_hw_constraint_list(runtime, 0, snd_pcm_hw_constraint_minmax(runtime,
SNDRV_PCM_HW_PARAM_PERIOD_SIZE, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
&hw_constraints_period_sizes_new); 32, 4096);
snd_pcm_hw_constraint_list(runtime, 0, /* RayDAT & AIO have a fixed buffer of 16384 samples per channel */
SNDRV_PCM_HW_PARAM_BUFFER_SIZE, snd_pcm_hw_constraint_minmax(runtime,
&hw_constraints_raydat_io_buffer); SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
16384, 16384);
break; break;
default: default:
snd_pcm_hw_constraint_list(runtime, 0, snd_pcm_hw_constraint_minmax(runtime,
SNDRV_PCM_HW_PARAM_PERIOD_SIZE, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
&hw_constraints_period_sizes_old); 64, 8192);
break;
} }
if (AES32 == hdspm->io_type) { if (AES32 == hdspm->io_type) {
...@@ -6059,21 +6030,24 @@ static int snd_hdspm_capture_open(struct snd_pcm_substream *substream) ...@@ -6059,21 +6030,24 @@ static int snd_hdspm_capture_open(struct snd_pcm_substream *substream)
spin_unlock_irq(&hdspm->lock); spin_unlock_irq(&hdspm->lock);
snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE);
switch (hdspm->io_type) { switch (hdspm->io_type) {
case AIO: case AIO:
case RayDAT: case RayDAT:
snd_pcm_hw_constraint_list(runtime, 0, snd_pcm_hw_constraint_minmax(runtime,
SNDRV_PCM_HW_PARAM_PERIOD_SIZE, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
&hw_constraints_period_sizes_new); 32, 4096);
snd_pcm_hw_constraint_list(runtime, 0, snd_pcm_hw_constraint_minmax(runtime,
SNDRV_PCM_HW_PARAM_BUFFER_SIZE, SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
&hw_constraints_raydat_io_buffer); 16384, 16384);
break; break;
default: default:
snd_pcm_hw_constraint_list(runtime, 0, snd_pcm_hw_constraint_minmax(runtime,
SNDRV_PCM_HW_PARAM_PERIOD_SIZE, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
&hw_constraints_period_sizes_old); 64, 8192);
break;
} }
if (AES32 == hdspm->io_type) { if (AES32 == hdspm->io_type) {
......
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