^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * tascam-hwdep.c - a part of driver for TASCAM FireWire series
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 2015 Takashi Sakamoto
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * This codes give three functionality.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * 1.get firewire node information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * 2.get notification about starting/stopping stream
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * 3.lock/unlock stream
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include "tascam.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) static long tscm_hwdep_read_locked(struct snd_tscm *tscm, char __user *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) long count, loff_t *offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) __releases(&tscm->lock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct snd_firewire_event_lock_status event = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) .type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) event.status = (tscm->dev_lock_count > 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) tscm->dev_lock_changed = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) count = min_t(long, count, sizeof(event));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) spin_unlock_irq(&tscm->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) if (copy_to_user(buf, &event, count))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static long tscm_hwdep_read_queue(struct snd_tscm *tscm, char __user *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) long remained, loff_t *offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) __releases(&tscm->lock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) char __user *pos = buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) unsigned int type = SNDRV_FIREWIRE_EVENT_TASCAM_CONTROL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) struct snd_firewire_tascam_change *entries = tscm->queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) long count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) // At least, one control event can be copied.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) if (remained < sizeof(type) + sizeof(*entries)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) spin_unlock_irq(&tscm->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) // Copy the type field later.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) count = sizeof(type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) remained -= sizeof(type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) pos += sizeof(type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) while (true) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) unsigned int head_pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) unsigned int tail_pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) unsigned int length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) if (tscm->pull_pos == tscm->push_pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) else if (tscm->pull_pos < tscm->push_pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) tail_pos = tscm->push_pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) tail_pos = SND_TSCM_QUEUE_COUNT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) head_pos = tscm->pull_pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) length = (tail_pos - head_pos) * sizeof(*entries);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) if (remained < length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) length = rounddown(remained, sizeof(*entries));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) if (length == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) spin_unlock_irq(&tscm->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) if (copy_to_user(pos, &entries[head_pos], length))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) spin_lock_irq(&tscm->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) tscm->pull_pos = tail_pos % SND_TSCM_QUEUE_COUNT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) count += length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) remained -= length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) pos += length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) spin_unlock_irq(&tscm->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) if (copy_to_user(buf, &type, sizeof(type)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) static long hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) loff_t *offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct snd_tscm *tscm = hwdep->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) DEFINE_WAIT(wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) spin_lock_irq(&tscm->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) while (!tscm->dev_lock_changed && tscm->push_pos == tscm->pull_pos) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) prepare_to_wait(&tscm->hwdep_wait, &wait, TASK_INTERRUPTIBLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) spin_unlock_irq(&tscm->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) schedule();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) finish_wait(&tscm->hwdep_wait, &wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) if (signal_pending(current))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) return -ERESTARTSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) spin_lock_irq(&tscm->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) // NOTE: The acquired lock should be released in callee side.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) if (tscm->dev_lock_changed) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) count = tscm_hwdep_read_locked(tscm, buf, count, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) } else if (tscm->push_pos != tscm->pull_pos) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) count = tscm_hwdep_read_queue(tscm, buf, count, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) spin_unlock_irq(&tscm->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) static __poll_t hwdep_poll(struct snd_hwdep *hwdep, struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) poll_table *wait)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) struct snd_tscm *tscm = hwdep->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) __poll_t events;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) poll_wait(file, &tscm->hwdep_wait, wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) spin_lock_irq(&tscm->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) if (tscm->dev_lock_changed || tscm->push_pos != tscm->pull_pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) events = EPOLLIN | EPOLLRDNORM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) events = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) spin_unlock_irq(&tscm->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) return events;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) static int hwdep_get_info(struct snd_tscm *tscm, void __user *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) struct fw_device *dev = fw_parent_device(tscm->unit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) struct snd_firewire_get_info info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) memset(&info, 0, sizeof(info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) info.type = SNDRV_FIREWIRE_TYPE_TASCAM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) info.card = dev->card->index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) *(__be32 *)&info.guid[0] = cpu_to_be32(dev->config_rom[3]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) *(__be32 *)&info.guid[4] = cpu_to_be32(dev->config_rom[4]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) strlcpy(info.device_name, dev_name(&dev->device),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) sizeof(info.device_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) if (copy_to_user(arg, &info, sizeof(info)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) static int hwdep_lock(struct snd_tscm *tscm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) spin_lock_irq(&tscm->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) if (tscm->dev_lock_count == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) tscm->dev_lock_count = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) err = -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) spin_unlock_irq(&tscm->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) static int hwdep_unlock(struct snd_tscm *tscm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) spin_lock_irq(&tscm->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) if (tscm->dev_lock_count == -1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) tscm->dev_lock_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) err = -EBADFD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) spin_unlock_irq(&tscm->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) static int tscm_hwdep_state(struct snd_tscm *tscm, void __user *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) if (copy_to_user(arg, tscm->state, sizeof(tscm->state)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) static int hwdep_release(struct snd_hwdep *hwdep, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) struct snd_tscm *tscm = hwdep->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) spin_lock_irq(&tscm->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) if (tscm->dev_lock_count == -1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) tscm->dev_lock_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) spin_unlock_irq(&tscm->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) static int hwdep_ioctl(struct snd_hwdep *hwdep, struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) unsigned int cmd, unsigned long arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) struct snd_tscm *tscm = hwdep->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) switch (cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) case SNDRV_FIREWIRE_IOCTL_GET_INFO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) return hwdep_get_info(tscm, (void __user *)arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) case SNDRV_FIREWIRE_IOCTL_LOCK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) return hwdep_lock(tscm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) case SNDRV_FIREWIRE_IOCTL_UNLOCK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) return hwdep_unlock(tscm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) case SNDRV_FIREWIRE_IOCTL_TASCAM_STATE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) return tscm_hwdep_state(tscm, (void __user *)arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) return -ENOIOCTLCMD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) #ifdef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) static int hwdep_compat_ioctl(struct snd_hwdep *hwdep, struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) unsigned int cmd, unsigned long arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) return hwdep_ioctl(hwdep, file, cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) (unsigned long)compat_ptr(arg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) #define hwdep_compat_ioctl NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) int snd_tscm_create_hwdep_device(struct snd_tscm *tscm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) static const struct snd_hwdep_ops ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) .read = hwdep_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) .release = hwdep_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) .poll = hwdep_poll,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) .ioctl = hwdep_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) .ioctl_compat = hwdep_compat_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) struct snd_hwdep *hwdep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) err = snd_hwdep_new(tscm->card, "Tascam", 0, &hwdep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) strcpy(hwdep->name, "Tascam");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) hwdep->iface = SNDRV_HWDEP_IFACE_FW_TASCAM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) hwdep->ops = ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) hwdep->private_data = tscm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) hwdep->exclusive = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) tscm->hwdep = hwdep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) }