diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2015-10-01 22:02:17 +0900 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2015-10-02 18:17:04 +0200 |
commit | e5e0c3dd257bf34cf001e10422943f90437f0f1b (patch) | |
tree | 3a4dfafb1815f996d9bf0366c2f9b95353a09199 /sound/firewire/tascam/tascam-stream.c | |
parent | e453df44f0d6574e99fae990c89a22c6ec6bbb62 (diff) |
ALSA: firewire-tascam: add hwdep interface
This commit adds hwdep interface so as the other IEEE 1394 sound devices
has.
This interface is designed for mixer/control applications. By using this
interface, an 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/tascam/tascam-stream.c')
-rw-r--r-- | sound/firewire/tascam/tascam-stream.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/sound/firewire/tascam/tascam-stream.c b/sound/firewire/tascam/tascam-stream.c index 0732f7f0c736..0e6dd5c61f53 100644 --- a/sound/firewire/tascam/tascam-stream.c +++ b/sound/firewire/tascam/tascam-stream.c @@ -455,3 +455,42 @@ void snd_tscm_stream_stop_duplex(struct snd_tscm *tscm) finish_session(tscm); release_resources(tscm); } + +void snd_tscm_stream_lock_changed(struct snd_tscm *tscm) +{ + tscm->dev_lock_changed = true; + wake_up(&tscm->hwdep_wait); +} + +int snd_tscm_stream_lock_try(struct snd_tscm *tscm) +{ + int err; + + spin_lock_irq(&tscm->lock); + + /* user land lock this */ + if (tscm->dev_lock_count < 0) { + err = -EBUSY; + goto end; + } + + /* this is the first time */ + if (tscm->dev_lock_count++ == 0) + snd_tscm_stream_lock_changed(tscm); + err = 0; +end: + spin_unlock_irq(&tscm->lock); + return err; +} + +void snd_tscm_stream_lock_release(struct snd_tscm *tscm) +{ + spin_lock_irq(&tscm->lock); + + if (WARN_ON(tscm->dev_lock_count <= 0)) + goto end; + if (--tscm->dev_lock_count == 0) + snd_tscm_stream_lock_changed(tscm); +end: + spin_unlock_irq(&tscm->lock); +} |