@@ -6043,23 +6043,30 @@ hdspm_hw_constraints_aes32_sample_rates = {
6043
6043
.mask = 0
6044
6044
};
6045
6045
6046
- static int snd_hdspm_playback_open (struct snd_pcm_substream * substream )
6046
+ static int snd_hdspm_open (struct snd_pcm_substream * substream )
6047
6047
{
6048
6048
struct hdspm * hdspm = snd_pcm_substream_chip (substream );
6049
6049
struct snd_pcm_runtime * runtime = substream -> runtime ;
6050
+ bool playback = (substream -> stream == SNDRV_PCM_STREAM_PLAYBACK );
6050
6051
6051
6052
spin_lock_irq (& hdspm -> lock );
6052
-
6053
6053
snd_pcm_set_sync (substream );
6054
+ runtime -> hw = (playback ) ? snd_hdspm_playback_subinfo :
6055
+ snd_hdspm_capture_subinfo ;
6054
6056
6057
+ if (playback ) {
6058
+ if (hdspm -> capture_substream == NULL )
6059
+ hdspm_stop_audio (hdspm );
6055
6060
6056
- runtime -> hw = snd_hdspm_playback_subinfo ;
6057
-
6058
- if (hdspm -> capture_substream == NULL )
6059
- hdspm_stop_audio (hdspm );
6061
+ hdspm -> playback_pid = current -> pid ;
6062
+ hdspm -> playback_substream = substream ;
6063
+ } else {
6064
+ if (hdspm -> playback_substream == NULL )
6065
+ hdspm_stop_audio (hdspm );
6060
6066
6061
- hdspm -> playback_pid = current -> pid ;
6062
- hdspm -> playback_substream = substream ;
6067
+ hdspm -> capture_pid = current -> pid ;
6068
+ hdspm -> capture_substream = substream ;
6069
+ }
6063
6070
6064
6071
spin_unlock_irq (& hdspm -> lock );
6065
6072
@@ -6094,16 +6101,20 @@ static int snd_hdspm_playback_open(struct snd_pcm_substream *substream)
6094
6101
& hdspm_hw_constraints_aes32_sample_rates );
6095
6102
} else {
6096
6103
snd_pcm_hw_rule_add (runtime , 0 , SNDRV_PCM_HW_PARAM_RATE ,
6097
- snd_hdspm_hw_rule_rate_out_channels , hdspm ,
6104
+ (playback ?
6105
+ snd_hdspm_hw_rule_rate_out_channels :
6106
+ snd_hdspm_hw_rule_rate_in_channels ), hdspm ,
6098
6107
SNDRV_PCM_HW_PARAM_CHANNELS , -1 );
6099
6108
}
6100
6109
6101
6110
snd_pcm_hw_rule_add (runtime , 0 , SNDRV_PCM_HW_PARAM_CHANNELS ,
6102
- snd_hdspm_hw_rule_out_channels , hdspm ,
6111
+ (playback ? snd_hdspm_hw_rule_out_channels :
6112
+ snd_hdspm_hw_rule_in_channels ), hdspm ,
6103
6113
SNDRV_PCM_HW_PARAM_CHANNELS , -1 );
6104
6114
6105
6115
snd_pcm_hw_rule_add (runtime , 0 , SNDRV_PCM_HW_PARAM_CHANNELS ,
6106
- snd_hdspm_hw_rule_out_channels_rate , hdspm ,
6116
+ (playback ? snd_hdspm_hw_rule_out_channels_rate :
6117
+ snd_hdspm_hw_rule_in_channels_rate ), hdspm ,
6107
6118
SNDRV_PCM_HW_PARAM_RATE , -1 );
6108
6119
6109
6120
return 0 ;
@@ -6123,69 +6134,6 @@ static int snd_hdspm_playback_release(struct snd_pcm_substream *substream)
6123
6134
return 0 ;
6124
6135
}
6125
6136
6126
-
6127
- static int snd_hdspm_capture_open (struct snd_pcm_substream * substream )
6128
- {
6129
- struct hdspm * hdspm = snd_pcm_substream_chip (substream );
6130
- struct snd_pcm_runtime * runtime = substream -> runtime ;
6131
-
6132
- spin_lock_irq (& hdspm -> lock );
6133
- snd_pcm_set_sync (substream );
6134
- runtime -> hw = snd_hdspm_capture_subinfo ;
6135
-
6136
- if (hdspm -> playback_substream == NULL )
6137
- hdspm_stop_audio (hdspm );
6138
-
6139
- hdspm -> capture_pid = current -> pid ;
6140
- hdspm -> capture_substream = substream ;
6141
-
6142
- spin_unlock_irq (& hdspm -> lock );
6143
-
6144
- snd_pcm_hw_constraint_msbits (runtime , 0 , 32 , 24 );
6145
- snd_pcm_hw_constraint_pow2 (runtime , 0 , SNDRV_PCM_HW_PARAM_PERIOD_SIZE );
6146
-
6147
- switch (hdspm -> io_type ) {
6148
- case AIO :
6149
- case RayDAT :
6150
- snd_pcm_hw_constraint_minmax (runtime ,
6151
- SNDRV_PCM_HW_PARAM_PERIOD_SIZE ,
6152
- 32 , 4096 );
6153
- snd_pcm_hw_constraint_minmax (runtime ,
6154
- SNDRV_PCM_HW_PARAM_BUFFER_SIZE ,
6155
- 16384 , 16384 );
6156
- break ;
6157
-
6158
- default :
6159
- snd_pcm_hw_constraint_minmax (runtime ,
6160
- SNDRV_PCM_HW_PARAM_PERIOD_SIZE ,
6161
- 64 , 8192 );
6162
- snd_pcm_hw_constraint_minmax (runtime ,
6163
- SNDRV_PCM_HW_PARAM_PERIODS ,
6164
- 2 , 2 );
6165
- break ;
6166
- }
6167
-
6168
- if (AES32 == hdspm -> io_type ) {
6169
- runtime -> hw .rates |= SNDRV_PCM_RATE_KNOT ;
6170
- snd_pcm_hw_constraint_list (runtime , 0 , SNDRV_PCM_HW_PARAM_RATE ,
6171
- & hdspm_hw_constraints_aes32_sample_rates );
6172
- } else {
6173
- snd_pcm_hw_rule_add (runtime , 0 , SNDRV_PCM_HW_PARAM_RATE ,
6174
- snd_hdspm_hw_rule_rate_in_channels , hdspm ,
6175
- SNDRV_PCM_HW_PARAM_CHANNELS , -1 );
6176
- }
6177
-
6178
- snd_pcm_hw_rule_add (runtime , 0 , SNDRV_PCM_HW_PARAM_CHANNELS ,
6179
- snd_hdspm_hw_rule_in_channels , hdspm ,
6180
- SNDRV_PCM_HW_PARAM_CHANNELS , -1 );
6181
-
6182
- snd_pcm_hw_rule_add (runtime , 0 , SNDRV_PCM_HW_PARAM_CHANNELS ,
6183
- snd_hdspm_hw_rule_in_channels_rate , hdspm ,
6184
- SNDRV_PCM_HW_PARAM_RATE , -1 );
6185
-
6186
- return 0 ;
6187
- }
6188
-
6189
6137
static int snd_hdspm_capture_release (struct snd_pcm_substream * substream )
6190
6138
{
6191
6139
struct hdspm * hdspm = snd_pcm_substream_chip (substream );
@@ -6414,7 +6362,7 @@ static int snd_hdspm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
6414
6362
}
6415
6363
6416
6364
static struct snd_pcm_ops snd_hdspm_playback_ops = {
6417
- .open = snd_hdspm_playback_open ,
6365
+ .open = snd_hdspm_open ,
6418
6366
.close = snd_hdspm_playback_release ,
6419
6367
.ioctl = snd_hdspm_ioctl ,
6420
6368
.hw_params = snd_hdspm_hw_params ,
@@ -6426,7 +6374,7 @@ static struct snd_pcm_ops snd_hdspm_playback_ops = {
6426
6374
};
6427
6375
6428
6376
static struct snd_pcm_ops snd_hdspm_capture_ops = {
6429
- .open = snd_hdspm_capture_open ,
6377
+ .open = snd_hdspm_open ,
6430
6378
.close = snd_hdspm_capture_release ,
6431
6379
.ioctl = snd_hdspm_ioctl ,
6432
6380
.hw_params = snd_hdspm_hw_params ,
0 commit comments