diff options
author | Takashi Sakamoto | 2014-04-25 15:45:12 +0200 |
---|---|---|
committer | Takashi Iwai | 2014-05-26 14:28:41 +0200 |
commit | 594ddced821dee39a548efe46d7f834bae013505 (patch) | |
tree | c0abaae51d84ef71127c3db3797130eb61701001 /sound/firewire/fireworks/fireworks_stream.c | |
parent | ALSA: fireworks: Add PCM interface (diff) | |
download | kernel-qcow2-linux-594ddced821dee39a548efe46d7f834bae013505.tar.gz kernel-qcow2-linux-594ddced821dee39a548efe46d7f834bae013505.tar.xz kernel-qcow2-linux-594ddced821dee39a548efe46d7f834bae013505.zip |
ALSA: fireworks: Add hwdep interface
This interface is designed for mixer/control application. To use hwdep
interface, the application can get information about firewire node, can
lock/unlock kernel streaming and can get notification at starting/stopping
kernel streaming.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire/fireworks/fireworks_stream.c')
-rw-r--r-- | sound/firewire/fireworks/fireworks_stream.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/sound/firewire/fireworks/fireworks_stream.c b/sound/firewire/fireworks/fireworks_stream.c index 1860914a3e0f..eaab8f6bc8b6 100644 --- a/sound/firewire/fireworks/fireworks_stream.c +++ b/sound/firewire/fireworks/fireworks_stream.c @@ -331,3 +331,42 @@ void snd_efw_stream_destroy_duplex(struct snd_efw *efw) mutex_unlock(&efw->mutex); } + +void snd_efw_stream_lock_changed(struct snd_efw *efw) +{ + efw->dev_lock_changed = true; + wake_up(&efw->hwdep_wait); +} + +int snd_efw_stream_lock_try(struct snd_efw *efw) +{ + int err; + + spin_lock_irq(&efw->lock); + + /* user land lock this */ + if (efw->dev_lock_count < 0) { + err = -EBUSY; + goto end; + } + + /* this is the first time */ + if (efw->dev_lock_count++ == 0) + snd_efw_stream_lock_changed(efw); + err = 0; +end: + spin_unlock_irq(&efw->lock); + return err; +} + +void snd_efw_stream_lock_release(struct snd_efw *efw) +{ + spin_lock_irq(&efw->lock); + + if (WARN_ON(efw->dev_lock_count <= 0)) + goto end; + if (--efw->dev_lock_count == 0) + snd_efw_stream_lock_changed(efw); +end: + spin_unlock_irq(&efw->lock); +} |