summaryrefslogtreecommitdiff
path: root/sound/usb
diff options
context:
space:
mode:
authorGeoffrey D. Bennett <g@b4.vu>2023-12-20 04:09:23 +1030
committerTakashi Iwai <tiwai@suse.de>2023-12-29 15:39:27 +0100
commit337b2f0e778f78f61972497994b70a05e8f6447d (patch)
tree2f8e677859e243d5d61d2566f7ebdfe41473c7c6 /sound/usb
parent34101a0fb1d47d8def145e50b4221201f5348cd0 (diff)
ALSA: scarlett2: Add skeleton hwdep/ioctl interface
Add skeleton hwdep/ioctl interface, beginning with SCARLETT2_IOCTL_PVERSION and SCARLETT2_IOCTL_REBOOT. Signed-off-by: Geoffrey D. Bennett <g@b4.vu> Link: https://lore.kernel.org/r/24ffcd47a8a02ebad3c8b2438104af8f0169164e.1703001053.git.g@b4.vu Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r--sound/usb/mixer_scarlett2.c67
1 files changed, 66 insertions, 1 deletions
diff --git a/sound/usb/mixer_scarlett2.c b/sound/usb/mixer_scarlett2.c
index b62fc0038671..d27628e4bda8 100644
--- a/sound/usb/mixer_scarlett2.c
+++ b/sound/usb/mixer_scarlett2.c
@@ -146,6 +146,9 @@
#include <sound/control.h>
#include <sound/tlv.h>
+#include <sound/hwdep.h>
+
+#include <uapi/sound/scarlett2.h>
#include "usbaudio.h"
#include "mixer.h"
@@ -1439,6 +1442,16 @@ static int scarlett2_usb(
/* validate the response */
if (err != resp_buf_size) {
+
+ /* ESHUTDOWN and EPROTO are valid responses to a
+ * reboot request
+ */
+ if (cmd == SCARLETT2_USB_REBOOT &&
+ (err == -ESHUTDOWN || err == -EPROTO)) {
+ err = 0;
+ goto unlock;
+ }
+
usb_audio_err(
mixer->chip,
"%s USB response result cmd %x was %d expected %zu\n",
@@ -4697,6 +4710,49 @@ static int snd_scarlett2_controls_create(
return 0;
}
+/*** hwdep interface ***/
+
+/* Reboot the device. */
+static int scarlett2_reboot(struct usb_mixer_interface *mixer)
+{
+ return scarlett2_usb(mixer, SCARLETT2_USB_REBOOT, NULL, 0, NULL, 0);
+}
+
+static int scarlett2_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
+ unsigned int cmd, unsigned long arg)
+{
+ struct usb_mixer_interface *mixer = hw->private_data;
+
+ switch (cmd) {
+
+ case SCARLETT2_IOCTL_PVERSION:
+ return put_user(SCARLETT2_HWDEP_VERSION,
+ (int __user *)arg) ? -EFAULT : 0;
+
+ case SCARLETT2_IOCTL_REBOOT:
+ return scarlett2_reboot(mixer);
+
+ default:
+ return -ENOIOCTLCMD;
+ }
+}
+
+static int scarlett2_hwdep_init(struct usb_mixer_interface *mixer)
+{
+ struct snd_hwdep *hw;
+ int err;
+
+ err = snd_hwdep_new(mixer->chip->card, "Focusrite Control", 0, &hw);
+ if (err < 0)
+ return err;
+
+ hw->private_data = mixer;
+ hw->exclusive = 1;
+ hw->ops.ioctl = scarlett2_hwdep_ioctl;
+
+ return 0;
+}
+
int snd_scarlett2_init(struct usb_mixer_interface *mixer)
{
struct snd_usb_audio *chip = mixer->chip;
@@ -4738,11 +4794,20 @@ int snd_scarlett2_init(struct usb_mixer_interface *mixer)
USB_ID_PRODUCT(chip->usb_id));
err = snd_scarlett2_controls_create(mixer, entry);
- if (err < 0)
+ if (err < 0) {
usb_audio_err(mixer->chip,
"Error initialising %s Mixer Driver: %d",
entry->series_name,
err);
+ return err;
+ }
+
+ err = scarlett2_hwdep_init(mixer);
+ if (err < 0)
+ usb_audio_err(mixer->chip,
+ "Error creating %s hwdep device: %d",
+ entry->series_name,
+ err);
return err;
}