Commit 1f7fa6e5 authored by Geoffrey D. Bennett's avatar Geoffrey D. Bennett Committed by Takashi Iwai

ALSA: usb-audio: scarlett2: Add usb_tx/rx functions

Pull out snd_usb_ctl_msg() calls from scarlett2_usb() and put into
scarlett2_usb_tx() and scarlett2_usb_rx() functions.
Signed-off-by: default avatarGeoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/720d1d6f227fc8f5d7d6191a8de62db796940235.1624294591.git.g@b4.vuSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 0f7c9565
...@@ -453,8 +453,8 @@ static int scarlett2_get_port_start_num(const struct scarlett2_ports *ports, ...@@ -453,8 +453,8 @@ static int scarlett2_get_port_start_num(const struct scarlett2_ports *ports,
#define SCARLETT2_USB_NOTIFY_MONITOR 0x00400000 #define SCARLETT2_USB_NOTIFY_MONITOR 0x00400000
/* Commands for sending/receiving requests/responses */ /* Commands for sending/receiving requests/responses */
#define SCARLETT2_USB_VENDOR_SPECIFIC_CMD_REQ 2 #define SCARLETT2_USB_CMD_REQ 2
#define SCARLETT2_USB_VENDOR_SPECIFIC_CMD_RESP 3 #define SCARLETT2_USB_CMD_RESP 3
#define SCARLETT2_USB_INIT_SEQ 0x00000000 #define SCARLETT2_USB_INIT_SEQ 0x00000000
#define SCARLETT2_USB_GET_METER 0x00001001 #define SCARLETT2_USB_GET_METER 0x00001001
...@@ -576,12 +576,31 @@ static void scarlett2_fill_request_header(struct scarlett2_data *private, ...@@ -576,12 +576,31 @@ static void scarlett2_fill_request_header(struct scarlett2_data *private,
req->pad = 0; req->pad = 0;
} }
static int scarlett2_usb_tx(struct usb_device *dev, int interface,
void *buf, u16 size)
{
return snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0),
SCARLETT2_USB_CMD_REQ,
USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
0, interface, buf, size);
}
static int scarlett2_usb_rx(struct usb_device *dev, int interface,
u32 usb_req, void *buf, u16 size)
{
return snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0),
usb_req,
USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
0, interface, buf, size);
}
/* Send a proprietary format request to the Scarlett interface */ /* Send a proprietary format request to the Scarlett interface */
static int scarlett2_usb( static int scarlett2_usb(
struct usb_mixer_interface *mixer, u32 cmd, struct usb_mixer_interface *mixer, u32 cmd,
void *req_data, u16 req_size, void *resp_data, u16 resp_size) void *req_data, u16 req_size, void *resp_data, u16 resp_size)
{ {
struct scarlett2_data *private = mixer->private_data; struct scarlett2_data *private = mixer->private_data;
struct usb_device *dev = mixer->chip->dev;
u16 req_buf_size = sizeof(struct scarlett2_usb_packet) + req_size; u16 req_buf_size = sizeof(struct scarlett2_usb_packet) + req_size;
u16 resp_buf_size = sizeof(struct scarlett2_usb_packet) + resp_size; u16 resp_buf_size = sizeof(struct scarlett2_usb_packet) + resp_size;
struct scarlett2_usb_packet *req, *resp = NULL; struct scarlett2_usb_packet *req, *resp = NULL;
...@@ -608,14 +627,8 @@ static int scarlett2_usb( ...@@ -608,14 +627,8 @@ static int scarlett2_usb(
if (req_size) if (req_size)
memcpy(req->data, req_data, req_size); memcpy(req->data, req_data, req_size);
err = snd_usb_ctl_msg(mixer->chip->dev, err = scarlett2_usb_tx(dev, private->bInterfaceNumber,
usb_sndctrlpipe(mixer->chip->dev, 0), req, req_buf_size);
SCARLETT2_USB_VENDOR_SPECIFIC_CMD_REQ,
USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
0,
private->bInterfaceNumber,
req,
req_buf_size);
if (err != req_buf_size) { if (err != req_buf_size) {
usb_audio_err( usb_audio_err(
...@@ -628,14 +641,9 @@ static int scarlett2_usb( ...@@ -628,14 +641,9 @@ static int scarlett2_usb(
/* send a second message to get the response */ /* send a second message to get the response */
err = snd_usb_ctl_msg(mixer->chip->dev, err = scarlett2_usb_rx(dev, private->bInterfaceNumber,
usb_rcvctrlpipe(mixer->chip->dev, 0), SCARLETT2_USB_CMD_RESP,
SCARLETT2_USB_VENDOR_SPECIFIC_CMD_RESP, resp, resp_buf_size);
USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
0,
private->bInterfaceNumber,
resp,
resp_buf_size);
/* validate the response */ /* validate the response */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment