blob: e2b51ec96ec62ab626c5d1c51798195d51308fb4 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Daniel Macke5779992010-03-04 19:46:13 +01002#ifndef __USBAUDIO_HELPER_H
3#define __USBAUDIO_HELPER_H
4
5unsigned int snd_usb_combine_bytes(unsigned char *bytes, int size);
6
7void *snd_usb_find_desc(void *descstart, int desclen, void *after, u8 dtype);
8void *snd_usb_find_csint_desc(void *descstart, int desclen, void *after, u8 dsubtype);
9
10int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe,
11 __u8 request, __u8 requesttype, __u16 value, __u16 index,
Clemens Ladisch17d900c2011-09-26 21:15:27 +020012 void *data, __u16 size);
Daniel Macke5779992010-03-04 19:46:13 +010013
14unsigned char snd_usb_parse_datainterval(struct snd_usb_audio *chip,
15 struct usb_host_interface *alts);
16
Takashi Iwaie42a09b2020-11-23 09:53:22 +010017struct usb_host_interface *
18snd_usb_get_host_interface(struct snd_usb_audio *chip, int ifnum, int altsetting);
19
Daniel Macke5779992010-03-04 19:46:13 +010020/*
21 * retrieve usb_interface descriptor from the host interface
22 * (conditional for compatibility with the older API)
23 */
Daniel Macke5779992010-03-04 19:46:13 +010024#define get_iface_desc(iface) (&(iface)->desc)
25#define get_endpoint(alt,ep) (&(alt)->endpoint[ep].desc)
26#define get_ep_desc(ep) (&(ep)->desc)
27#define get_cfg_desc(cfg) (&(cfg)->desc)
Daniel Macke5779992010-03-04 19:46:13 +010028
Daniel Macke5779992010-03-04 19:46:13 +010029#define snd_usb_get_speed(dev) ((dev)->speed)
Daniel Macke5779992010-03-04 19:46:13 +010030
Daniel Mack11bcbc42010-06-11 17:34:20 +020031static inline int snd_usb_ctrl_intf(struct snd_usb_audio *chip)
32{
33 return get_iface_desc(chip->ctrl_intf)->bInterfaceNumber;
34}
Daniel Macke5779992010-03-04 19:46:13 +010035
Takashi Iwai57f87702019-08-20 17:17:09 +020036/* in validate.c */
37bool snd_usb_validate_audio_desc(void *p, int protocol);
38bool snd_usb_validate_midi_desc(void *p);
39
Daniel Macke5779992010-03-04 19:46:13 +010040#endif /* __USBAUDIO_HELPER_H */