#define SCARLETT2_USB_NOTIFY_MONITOR 0x00400000
/* Commands for sending/receiving requests/responses */
+#define SCARLETT2_USB_CMD_INIT 0
#define SCARLETT2_USB_CMD_REQ 2
#define SCARLETT2_USB_CMD_RESP 3
-#define SCARLETT2_USB_INIT_SEQ 0x00000000
+#define SCARLETT2_USB_INIT_1 0x00000000
+#define SCARLETT2_USB_INIT_2 0x00000002
#define SCARLETT2_USB_GET_METER 0x00001001
#define SCARLETT2_USB_GET_MIX 0x00002001
#define SCARLETT2_USB_SET_MIX 0x00002002
if (err != resp_buf_size) {
usb_audio_err(
mixer->chip,
- "Scarlett Gen 2 USB response result cmd %x was %d\n",
- cmd, err);
+ "Scarlett Gen 2 USB response result cmd %x was %d "
+ "expected %d\n",
+ cmd, err, resp_buf_size);
err = -EINVAL;
goto unlock;
}
+ /* cmd/seq/size should match except when initialising
+ * seq sent = 1, response = 0
+ */
if (resp->cmd != req->cmd ||
- resp->seq != req->seq ||
+ (resp->seq != req->seq &&
+ (le16_to_cpu(req->seq) != 1 || resp->seq != 0)) ||
resp_size != le16_to_cpu(resp->size) ||
resp->error ||
resp->pad) {
goto unlock;
}
- if (resp_size > 0)
+ if (resp_data && resp_size > 0)
memcpy(resp_data, resp->data, resp_size);
unlock:
return -EINVAL;
}
-/* Initialise private data, sequence number, and get the USB data */
+/* Initialise private data */
static int scarlett2_init_private(struct usb_mixer_interface *mixer,
const struct scarlett2_device_info *info)
{
struct scarlett2_data *private =
kzalloc(sizeof(struct scarlett2_data), GFP_KERNEL);
- int err;
if (!private)
return -ENOMEM;
private->scarlett2_seq = 0;
private->mixer = mixer;
- err = scarlett2_find_fc_interface(mixer->chip->dev, private);
+ return scarlett2_find_fc_interface(mixer->chip->dev, private);
+}
+
+/* Cargo cult proprietary initialisation sequence */
+static int scarlett2_usb_init(struct usb_mixer_interface *mixer)
+{
+ struct usb_device *dev = mixer->chip->dev;
+ struct scarlett2_data *private = mixer->private_data;
+ u8 buf[24];
+ int err;
+
+ if (usb_pipe_type_check(dev, usb_sndctrlpipe(dev, 0)))
+ return -EINVAL;
+
+ /* step 0 */
+ err = scarlett2_usb_rx(dev, private->bInterfaceNumber,
+ SCARLETT2_USB_CMD_INIT, buf, sizeof(buf));
if (err < 0)
return err;
- /* Initialise the sequence number used for the proprietary commands */
- return scarlett2_usb(mixer, SCARLETT2_USB_INIT_SEQ, NULL, 0, NULL, 0);
+ /* step 1 */
+ private->scarlett2_seq = 1;
+ err = scarlett2_usb(mixer, SCARLETT2_USB_INIT_1, NULL, 0, NULL, 0);
+ if (err < 0)
+ return err;
+
+ /* step 2 */
+ private->scarlett2_seq = 1;
+ return scarlett2_usb(mixer, SCARLETT2_USB_INIT_2, NULL, 0, NULL, 84);
}
/* Read configuration from the interface on start */
{
int err;
- /* Initialise private data, sequence number, and get the USB data */
+ /* Initialise private data */
err = scarlett2_init_private(mixer, info);
if (err < 0)
return err;
+ /* Send proprietary USB initialisation sequence */
+ err = scarlett2_usb_init(mixer);
+ if (err < 0)
+ return err;
+
/* Read volume levels and controls from the interface */
err = scarlett2_read_configs(mixer);
if (err < 0)