@@ -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,108 +6101,42 @@ 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 ;
6110
6121
}
6111
6122
6112
- static int snd_hdspm_playback_release (struct snd_pcm_substream * substream )
6123
+ static int snd_hdspm_release (struct snd_pcm_substream * substream )
6113
6124
{
6114
6125
struct hdspm * hdspm = snd_pcm_substream_chip (substream );
6126
+ bool playback = (substream -> stream == SNDRV_PCM_STREAM_PLAYBACK );
6115
6127
6116
6128
spin_lock_irq (& hdspm -> lock );
6117
6129
6118
- hdspm -> playback_pid = -1 ;
6119
- hdspm -> playback_substream = NULL ;
6120
-
6121
- spin_unlock_irq (& hdspm -> lock );
6122
-
6123
- return 0 ;
6124
- }
6125
-
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 );
6130
+ if (playback ) {
6131
+ hdspm -> playback_pid = -1 ;
6132
+ hdspm -> playback_substream = NULL ;
6172
6133
} 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 );
6134
+ hdspm -> capture_pid = -1 ;
6135
+ hdspm -> capture_substream = NULL ;
6176
6136
}
6177
6137
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
- static int snd_hdspm_capture_release (struct snd_pcm_substream * substream )
6190
- {
6191
- struct hdspm * hdspm = snd_pcm_substream_chip (substream );
6192
-
6193
- spin_lock_irq (& hdspm -> lock );
6194
-
6195
- hdspm -> capture_pid = -1 ;
6196
- hdspm -> capture_substream = NULL ;
6197
-
6198
6138
spin_unlock_irq (& hdspm -> lock );
6139
+
6199
6140
return 0 ;
6200
6141
}
6201
6142
@@ -6413,21 +6354,9 @@ static int snd_hdspm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
6413
6354
return 0 ;
6414
6355
}
6415
6356
6416
- static struct snd_pcm_ops snd_hdspm_playback_ops = {
6417
- .open = snd_hdspm_playback_open ,
6418
- .close = snd_hdspm_playback_release ,
6419
- .ioctl = snd_hdspm_ioctl ,
6420
- .hw_params = snd_hdspm_hw_params ,
6421
- .hw_free = snd_hdspm_hw_free ,
6422
- .prepare = snd_hdspm_prepare ,
6423
- .trigger = snd_hdspm_trigger ,
6424
- .pointer = snd_hdspm_hw_pointer ,
6425
- .page = snd_pcm_sgbuf_ops_page ,
6426
- };
6427
-
6428
- static struct snd_pcm_ops snd_hdspm_capture_ops = {
6429
- .open = snd_hdspm_capture_open ,
6430
- .close = snd_hdspm_capture_release ,
6357
+ static struct snd_pcm_ops snd_hdspm_ops = {
6358
+ .open = snd_hdspm_open ,
6359
+ .close = snd_hdspm_release ,
6431
6360
.ioctl = snd_hdspm_ioctl ,
6432
6361
.hw_params = snd_hdspm_hw_params ,
6433
6362
.hw_free = snd_hdspm_hw_free ,
@@ -6521,9 +6450,9 @@ static int snd_hdspm_create_pcm(struct snd_card *card,
6521
6450
strcpy (pcm -> name , hdspm -> card_name );
6522
6451
6523
6452
snd_pcm_set_ops (pcm , SNDRV_PCM_STREAM_PLAYBACK ,
6524
- & snd_hdspm_playback_ops );
6453
+ & snd_hdspm_ops );
6525
6454
snd_pcm_set_ops (pcm , SNDRV_PCM_STREAM_CAPTURE ,
6526
- & snd_hdspm_capture_ops );
6455
+ & snd_hdspm_ops );
6527
6456
6528
6457
pcm -> info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX ;
6529
6458
0 commit comments