oxfw-pcm.c (779f0dba0b99f32276315ba40e812648b6ceed34) oxfw-pcm.c (4a0a04729a44ea317270885e1722636b156cf620)
1/*
2 * oxfw_pcm.c - a part of driver for OXFW970/971 based devices
3 *
4 * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5 * Licensed under the terms of the GNU General Public License, version 2.
6 */
7
8#include "oxfw.h"

--- 206 unchanged lines hidden (view full) ---

215
216 err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
217 params_buffer_bytes(hw_params));
218 if (err < 0)
219 return err;
220
221 if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
222 mutex_lock(&oxfw->mutex);
1/*
2 * oxfw_pcm.c - a part of driver for OXFW970/971 based devices
3 *
4 * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5 * Licensed under the terms of the GNU General Public License, version 2.
6 */
7
8#include "oxfw.h"

--- 206 unchanged lines hidden (view full) ---

215
216 err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
217 params_buffer_bytes(hw_params));
218 if (err < 0)
219 return err;
220
221 if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
222 mutex_lock(&oxfw->mutex);
223 oxfw->capture_substreams++;
223 ++oxfw->substreams_count;
224 mutex_unlock(&oxfw->mutex);
225 }
226
227 return 0;
228}
229static int pcm_playback_hw_params(struct snd_pcm_substream *substream,
230 struct snd_pcm_hw_params *hw_params)
231{
232 struct snd_oxfw *oxfw = substream->private_data;
233 int err;
234
235 err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
236 params_buffer_bytes(hw_params));
237 if (err < 0)
238 return err;
239
240 if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
241 mutex_lock(&oxfw->mutex);
224 mutex_unlock(&oxfw->mutex);
225 }
226
227 return 0;
228}
229static int pcm_playback_hw_params(struct snd_pcm_substream *substream,
230 struct snd_pcm_hw_params *hw_params)
231{
232 struct snd_oxfw *oxfw = substream->private_data;
233 int err;
234
235 err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
236 params_buffer_bytes(hw_params));
237 if (err < 0)
238 return err;
239
240 if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
241 mutex_lock(&oxfw->mutex);
242 oxfw->playback_substreams++;
242 ++oxfw->substreams_count;
243 mutex_unlock(&oxfw->mutex);
244 }
245
246 return 0;
247}
248
249static int pcm_capture_hw_free(struct snd_pcm_substream *substream)
250{
251 struct snd_oxfw *oxfw = substream->private_data;
252
253 mutex_lock(&oxfw->mutex);
254
255 if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN)
243 mutex_unlock(&oxfw->mutex);
244 }
245
246 return 0;
247}
248
249static int pcm_capture_hw_free(struct snd_pcm_substream *substream)
250{
251 struct snd_oxfw *oxfw = substream->private_data;
252
253 mutex_lock(&oxfw->mutex);
254
255 if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN)
256 oxfw->capture_substreams--;
256 --oxfw->substreams_count;
257
258 snd_oxfw_stream_stop_duplex(oxfw);
259
260 mutex_unlock(&oxfw->mutex);
261
262 return snd_pcm_lib_free_vmalloc_buffer(substream);
263}
264static int pcm_playback_hw_free(struct snd_pcm_substream *substream)
265{
266 struct snd_oxfw *oxfw = substream->private_data;
267
268 mutex_lock(&oxfw->mutex);
269
270 if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN)
257
258 snd_oxfw_stream_stop_duplex(oxfw);
259
260 mutex_unlock(&oxfw->mutex);
261
262 return snd_pcm_lib_free_vmalloc_buffer(substream);
263}
264static int pcm_playback_hw_free(struct snd_pcm_substream *substream)
265{
266 struct snd_oxfw *oxfw = substream->private_data;
267
268 mutex_lock(&oxfw->mutex);
269
270 if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN)
271 oxfw->playback_substreams--;
271 --oxfw->substreams_count;
272
273 snd_oxfw_stream_stop_duplex(oxfw);
274
275 mutex_unlock(&oxfw->mutex);
276
277 return snd_pcm_lib_free_vmalloc_buffer(substream);
278}
279

--- 144 unchanged lines hidden ---
272
273 snd_oxfw_stream_stop_duplex(oxfw);
274
275 mutex_unlock(&oxfw->mutex);
276
277 return snd_pcm_lib_free_vmalloc_buffer(substream);
278}
279

--- 144 unchanged lines hidden ---