ALSA: firewire-tascam: add new hwdep ioctl command to get state image
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Fri, 23 Nov 2018 04:13:04 +0000 (13:13 +0900)
committerTakashi Iwai <tiwai@suse.de>
Fri, 23 Nov 2018 14:31:10 +0000 (15:31 +0100)
In a previous commit, ALSA firewire-tascam driver stores state image
from tx isochronous packets. This image includes states of knob, fader,
button of control surface, level of gain/volume of each physical
inputs/outputs, and so on. It's useful for userspace applications to
read whole of the image.

This commit adds a unique ioctl command for ALSA hwdep interface for the
purpose. For actual meaning of each bits in this image, please refer to
discussion in alsa-devel[1].

[1] http://mailman.alsa-project.org/pipermail/alsa-devel/2018-October/140785.html

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/uapi/sound/firewire.h
sound/firewire/tascam/tascam-hwdep.c

index b9bc4bb1756b5a7823aedace751e1ed47a1e06ea..012f81bf47500179e5c55cfa48d42136085a6d6a 100644 (file)
@@ -66,6 +66,7 @@ union snd_firewire_event {
 #define SNDRV_FIREWIRE_IOCTL_GET_INFO _IOR('H', 0xf8, struct snd_firewire_get_info)
 #define SNDRV_FIREWIRE_IOCTL_LOCK      _IO('H', 0xf9)
 #define SNDRV_FIREWIRE_IOCTL_UNLOCK    _IO('H', 0xfa)
+#define SNDRV_FIREWIRE_IOCTL_TASCAM_STATE _IOR('H', 0xfb, struct snd_firewire_tascam_state)
 
 #define SNDRV_FIREWIRE_TYPE_DICE       1
 #define SNDRV_FIREWIRE_TYPE_FIREWORKS  2
@@ -90,4 +91,8 @@ struct snd_firewire_get_info {
 
 #define SNDRV_FIREWIRE_TASCAM_STATE_COUNT      64
 
+struct snd_firewire_tascam_state {
+       __be32 data[SNDRV_FIREWIRE_TASCAM_STATE_COUNT];
+};
+
 #endif /* _UAPI_SOUND_FIREWIRE_H_INCLUDED */
index 4e4c1e9020e8cb3e930828513949a07c087cf717..a80397116c48dae895e159457adba62f1e0bc0fa 100644 (file)
@@ -123,6 +123,14 @@ static int hwdep_unlock(struct snd_tscm *tscm)
        return err;
 }
 
+static int tscm_hwdep_state(struct snd_tscm *tscm, void __user *arg)
+{
+       if (copy_to_user(arg, tscm->state, sizeof(tscm->state)))
+               return -EFAULT;
+
+       return 0;
+}
+
 static int hwdep_release(struct snd_hwdep *hwdep, struct file *file)
 {
        struct snd_tscm *tscm = hwdep->private_data;
@@ -147,6 +155,8 @@ static int hwdep_ioctl(struct snd_hwdep *hwdep, struct file *file,
                return hwdep_lock(tscm);
        case SNDRV_FIREWIRE_IOCTL_UNLOCK:
                return hwdep_unlock(tscm);
+       case SNDRV_FIREWIRE_IOCTL_TASCAM_STATE:
+               return tscm_hwdep_state(tscm, (void __user *)arg);
        default:
                return -ENOIOCTLCMD;
        }