aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2011-08-15 04:45:42 -0400
committerTakashi Iwai <tiwai@suse.de>2011-08-15 07:37:03 -0400
commitd877681d2eab28ae2a7ff08bec9a6fe3b65973fb (patch)
treebec22bea49d58ad18f5326865285e0bf684413d6 /sound/pci
parent3fa9e3d230911272eaf1c3856f5483b0af3903f3 (diff)
ALSA: hdspm - Simplify with snd_pcm_hw_constraint_pow2()
Refactoring the code using snd_pcm_hw_constraint_pow2() helper function. Tested-by: Adrian Knoth <adi@drcomp.erfurt.thur.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/rme9652/hdspm.c76
1 files changed, 25 insertions, 51 deletions
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index 4add485e6b1..214110d6a2b 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -5705,19 +5705,6 @@ static int snd_hdspm_prepare(struct snd_pcm_substream *substream)
5705 return 0; 5705 return 0;
5706} 5706}
5707 5707
5708static unsigned int period_sizes_old[] = {
5709 64, 128, 256, 512, 1024, 2048, 4096, 8192
5710};
5711
5712static unsigned int period_sizes_new[] = {
5713 64, 128, 256, 512, 1024, 2048, 4096, 32
5714};
5715
5716/* RayDAT and AIO always have a buffer of 16384 samples per channel */
5717static unsigned int raydat_aio_buffer_sizes[] = {
5718 16384
5719};
5720
5721static struct snd_pcm_hardware snd_hdspm_playback_subinfo = { 5708static struct snd_pcm_hardware snd_hdspm_playback_subinfo = {
5722 .info = (SNDRV_PCM_INFO_MMAP | 5709 .info = (SNDRV_PCM_INFO_MMAP |
5723 SNDRV_PCM_INFO_MMAP_VALID | 5710 SNDRV_PCM_INFO_MMAP_VALID |
@@ -5768,24 +5755,6 @@ static struct snd_pcm_hardware snd_hdspm_capture_subinfo = {
5768 .fifo_size = 0 5755 .fifo_size = 0
5769}; 5756};
5770 5757
5771static struct snd_pcm_hw_constraint_list hw_constraints_period_sizes_old = {
5772 .count = ARRAY_SIZE(period_sizes_old),
5773 .list = period_sizes_old,
5774 .mask = 0
5775};
5776
5777static struct snd_pcm_hw_constraint_list hw_constraints_period_sizes_new = {
5778 .count = ARRAY_SIZE(period_sizes_new),
5779 .list = period_sizes_new,
5780 .mask = 0
5781};
5782
5783static struct snd_pcm_hw_constraint_list hw_constraints_raydat_io_buffer = {
5784 .count = ARRAY_SIZE(raydat_aio_buffer_sizes),
5785 .list = raydat_aio_buffer_sizes,
5786 .mask = 0
5787};
5788
5789static int snd_hdspm_hw_rule_in_channels_rate(struct snd_pcm_hw_params *params, 5758static int snd_hdspm_hw_rule_in_channels_rate(struct snd_pcm_hw_params *params,
5790 struct snd_pcm_hw_rule *rule) 5759 struct snd_pcm_hw_rule *rule)
5791{ 5760{
@@ -5986,23 +5955,25 @@ static int snd_hdspm_playback_open(struct snd_pcm_substream *substream)
5986 spin_unlock_irq(&hdspm->lock); 5955 spin_unlock_irq(&hdspm->lock);
5987 5956
5988 snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); 5957 snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
5958 snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE);
5989 5959
5990 switch (hdspm->io_type) { 5960 switch (hdspm->io_type) {
5991 case AIO: 5961 case AIO:
5992 case RayDAT: 5962 case RayDAT:
5993 snd_pcm_hw_constraint_list(runtime, 0, 5963 snd_pcm_hw_constraint_minmax(runtime,
5994 SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 5964 SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
5995 &hw_constraints_period_sizes_new); 5965 32, 4096);
5996 snd_pcm_hw_constraint_list(runtime, 0, 5966 /* RayDAT & AIO have a fixed buffer of 16384 samples per channel */
5997 SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 5967 snd_pcm_hw_constraint_minmax(runtime,
5998 &hw_constraints_raydat_io_buffer); 5968 SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
5999 5969 16384, 16384);
6000 break; 5970 break;
6001 5971
6002 default: 5972 default:
6003 snd_pcm_hw_constraint_list(runtime, 0, 5973 snd_pcm_hw_constraint_minmax(runtime,
6004 SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 5974 SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
6005 &hw_constraints_period_sizes_old); 5975 64, 8192);
5976 break;
6006 } 5977 }
6007 5978
6008 if (AES32 == hdspm->io_type) { 5979 if (AES32 == hdspm->io_type) {
@@ -6059,21 +6030,24 @@ static int snd_hdspm_capture_open(struct snd_pcm_substream *substream)
6059 spin_unlock_irq(&hdspm->lock); 6030 spin_unlock_irq(&hdspm->lock);
6060 6031
6061 snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); 6032 snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
6033 snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE);
6034
6062 switch (hdspm->io_type) { 6035 switch (hdspm->io_type) {
6063 case AIO: 6036 case AIO:
6064 case RayDAT: 6037 case RayDAT:
6065 snd_pcm_hw_constraint_list(runtime, 0, 6038 snd_pcm_hw_constraint_minmax(runtime,
6066 SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 6039 SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
6067 &hw_constraints_period_sizes_new); 6040 32, 4096);
6068 snd_pcm_hw_constraint_list(runtime, 0, 6041 snd_pcm_hw_constraint_minmax(runtime,
6069 SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 6042 SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
6070 &hw_constraints_raydat_io_buffer); 6043 16384, 16384);
6071 break; 6044 break;
6072 6045
6073 default: 6046 default:
6074 snd_pcm_hw_constraint_list(runtime, 0, 6047 snd_pcm_hw_constraint_minmax(runtime,
6075 SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 6048 SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
6076 &hw_constraints_period_sizes_old); 6049 64, 8192);
6050 break;
6077 } 6051 }
6078 6052
6079 if (AES32 == hdspm->io_type) { 6053 if (AES32 == hdspm->io_type) {