blob: 5e8a18b4e7b96812778dd15da1f94f0c25695777 [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
Takashi Iwai801ebf12019-06-24 15:08:28 +020010int snd_usb_pipe_sanity_check(struct usb_device *dev, unsigned int pipe);
Daniel Macke5779992010-03-04 19:46:13 +010011int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe,
12 __u8 request, __u8 requesttype, __u16 value, __u16 index,
Clemens Ladisch17d900c2011-09-26 21:15:27 +020013 void *data, __u16 size);
Daniel Macke5779992010-03-04 19:46:13 +010014
15unsigned char snd_usb_parse_datainterval(struct snd_usb_audio *chip,
16 struct usb_host_interface *alts);
17
18/*
19 * retrieve usb_interface descriptor from the host interface
20 * (conditional for compatibility with the older API)
21 */
Daniel Macke5779992010-03-04 19:46:13 +010022#define get_iface_desc(iface) (&(iface)->desc)
23#define get_endpoint(alt,ep) (&(alt)->endpoint[ep].desc)
24#define get_ep_desc(ep) (&(ep)->desc)
25#define get_cfg_desc(cfg) (&(cfg)->desc)
Daniel Macke5779992010-03-04 19:46:13 +010026
Daniel Macke5779992010-03-04 19:46:13 +010027#define snd_usb_get_speed(dev) ((dev)->speed)
Daniel Macke5779992010-03-04 19:46:13 +010028
Daniel Mack11bcbc42010-06-11 17:34:20 +020029static inline int snd_usb_ctrl_intf(struct snd_usb_audio *chip)
30{
31 return get_iface_desc(chip->ctrl_intf)->bInterfaceNumber;
32}
Daniel Macke5779992010-03-04 19:46:13 +010033
Takashi Iwai57f87702019-08-20 17:17:09 +020034/* in validate.c */
35bool snd_usb_validate_audio_desc(void *p, int protocol);
36bool snd_usb_validate_midi_desc(void *p);
37
Daniel Macke5779992010-03-04 19:46:13 +010038#endif /* __USBAUDIO_HELPER_H */