mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-30 08:04:13 +08:00
3c53c6255d
This is a very big update, mainly thanks to Morimoto-san's refactoring work and some fairly large new drivers. - Lots more work on moving towards a component based framework from Morimoto-san. - Support for force disconnecting muxes from Jerome Brunet. - New drivers for Cirrus Logic CS47L35, CS47L85 and CS47L90, Conexant CX2072X, Realtek RT1011 and RT1308. -----BEGIN PGP SIGNATURE----- iQFHBAABCgAxFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAl0jGwUTHGJyb29uaWVA a2VybmVsLm9yZwAKCRAk1otyXVSH0LD4B/9AkutfS+vznOrk0V0wFb2SUfjwE4Pr +z/kAehohAOl/7pg9Dun/lmZYBWMyOM2aYmK81ahEo2DfO+uzwkwjCaXFjGVGwEK j7XpWkrIjKnou/z1FeALgVvt+crzdy5iNWC04AbKaP2WHCcI7zvPQIsBta/V0OJt lg+j0J7pagnTMcgV1+qJdaASmofy/hpoZ79Gv0PIfGC8hpJ/3mBgcNPCLQrJtD4R v+tzvCZNrZVqCanwLf3vouEm1bpWYOpI+Wdmu4u6rY7MhmCj72EJ2zyfdm/qtaxF e7whgCyOQFkWe7NgDn0G08aAT6LsaxOtPNr7H8tL8S8sw8425fqeOouV =n/HQ -----END PGP SIGNATURE----- Merge tag 'asoc-v5.3' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus ASoC: Updates for v5.3 This is a very big update, mainly thanks to Morimoto-san's refactoring work and some fairly large new drivers. - Lots more work on moving towards a component based framework from Morimoto-san. - Support for force disconnecting muxes from Jerome Brunet. - New drivers for Cirrus Logic CS47L35, CS47L85 and CS47L90, Conexant CX2072X, Realtek RT1011 and RT1308. Signed-off-by: Takashi Iwai <tiwai@suse.de>
138 lines
2.9 KiB
C
138 lines
2.9 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/usb.h>
|
|
|
|
#include "usbaudio.h"
|
|
#include "helper.h"
|
|
#include "quirks.h"
|
|
|
|
/*
|
|
* combine bytes and get an integer value
|
|
*/
|
|
unsigned int snd_usb_combine_bytes(unsigned char *bytes, int size)
|
|
{
|
|
switch (size) {
|
|
case 1: return *bytes;
|
|
case 2: return combine_word(bytes);
|
|
case 3: return combine_triple(bytes);
|
|
case 4: return combine_quad(bytes);
|
|
default: return 0;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* parse descriptor buffer and return the pointer starting the given
|
|
* descriptor type.
|
|
*/
|
|
void *snd_usb_find_desc(void *descstart, int desclen, void *after, u8 dtype)
|
|
{
|
|
u8 *p, *end, *next;
|
|
|
|
p = descstart;
|
|
end = p + desclen;
|
|
for (; p < end;) {
|
|
if (p[0] < 2)
|
|
return NULL;
|
|
next = p + p[0];
|
|
if (next > end)
|
|
return NULL;
|
|
if (p[1] == dtype && (!after || (void *)p > after)) {
|
|
return p;
|
|
}
|
|
p = next;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
/*
|
|
* find a class-specified interface descriptor with the given subtype.
|
|
*/
|
|
void *snd_usb_find_csint_desc(void *buffer, int buflen, void *after, u8 dsubtype)
|
|
{
|
|
unsigned char *p = after;
|
|
|
|
while ((p = snd_usb_find_desc(buffer, buflen, p,
|
|
USB_DT_CS_INTERFACE)) != NULL) {
|
|
if (p[0] >= 3 && p[2] == dsubtype)
|
|
return p;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
/* check the validity of pipe and EP types */
|
|
int snd_usb_pipe_sanity_check(struct usb_device *dev, unsigned int pipe)
|
|
{
|
|
static const int pipetypes[4] = {
|
|
PIPE_CONTROL, PIPE_ISOCHRONOUS, PIPE_BULK, PIPE_INTERRUPT
|
|
};
|
|
struct usb_host_endpoint *ep;
|
|
|
|
ep = usb_pipe_endpoint(dev, pipe);
|
|
if (usb_pipetype(pipe) != pipetypes[usb_endpoint_type(&ep->desc)])
|
|
return -EINVAL;
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* Wrapper for usb_control_msg().
|
|
* Allocates a temp buffer to prevent dmaing from/to the stack.
|
|
*/
|
|
int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
|
|
__u8 requesttype, __u16 value, __u16 index, void *data,
|
|
__u16 size)
|
|
{
|
|
int err;
|
|
void *buf = NULL;
|
|
int timeout;
|
|
|
|
if (snd_usb_pipe_sanity_check(dev, pipe))
|
|
return -EINVAL;
|
|
|
|
if (size > 0) {
|
|
buf = kmemdup(data, size, GFP_KERNEL);
|
|
if (!buf)
|
|
return -ENOMEM;
|
|
}
|
|
|
|
if (requesttype & USB_DIR_IN)
|
|
timeout = USB_CTRL_GET_TIMEOUT;
|
|
else
|
|
timeout = USB_CTRL_SET_TIMEOUT;
|
|
|
|
err = usb_control_msg(dev, pipe, request, requesttype,
|
|
value, index, buf, size, timeout);
|
|
|
|
if (size > 0) {
|
|
memcpy(data, buf, size);
|
|
kfree(buf);
|
|
}
|
|
|
|
snd_usb_ctl_msg_quirk(dev, pipe, request, requesttype,
|
|
value, index, data, size);
|
|
|
|
return err;
|
|
}
|
|
|
|
unsigned char snd_usb_parse_datainterval(struct snd_usb_audio *chip,
|
|
struct usb_host_interface *alts)
|
|
{
|
|
switch (snd_usb_get_speed(chip->dev)) {
|
|
case USB_SPEED_HIGH:
|
|
case USB_SPEED_WIRELESS:
|
|
case USB_SPEED_SUPER:
|
|
case USB_SPEED_SUPER_PLUS:
|
|
if (get_endpoint(alts, 0)->bInterval >= 1 &&
|
|
get_endpoint(alts, 0)->bInterval <= 4)
|
|
return get_endpoint(alts, 0)->bInterval - 1;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|