helper.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __USBAUDIO_HELPER_H
  3. #define __USBAUDIO_HELPER_H
  4. unsigned int snd_usb_combine_bytes(unsigned char *bytes, int size);
  5. void *snd_usb_find_desc(void *descstart, int desclen, void *after, u8 dtype);
  6. void *snd_usb_find_csint_desc(void *descstart, int desclen, void *after, u8 dsubtype);
  7. int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe,
  8. __u8 request, __u8 requesttype, __u16 value, __u16 index,
  9. void *data, __u16 size);
  10. unsigned char snd_usb_parse_datainterval(struct snd_usb_audio *chip,
  11. struct usb_host_interface *alts);
  12. struct usb_host_interface *
  13. snd_usb_get_host_interface(struct snd_usb_audio *chip, int ifnum, int altsetting);
  14. int snd_usb_add_ctrl_interface_link(struct snd_usb_audio *chip, int ifnum,
  15. int ctrlif);
  16. struct usb_host_interface *snd_usb_find_ctrl_interface(struct snd_usb_audio *chip,
  17. int ifnum);
  18. /*
  19. * retrieve usb_interface descriptor from the host interface
  20. * (conditional for compatibility with the older API)
  21. */
  22. #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)
  26. #define snd_usb_get_speed(dev) ((dev)->speed)
  27. static inline int snd_usb_ctrl_intf(struct usb_host_interface *ctrl_intf)
  28. {
  29. return get_iface_desc(ctrl_intf)->bInterfaceNumber;
  30. }
  31. /* in validate.c */
  32. bool snd_usb_validate_audio_desc(void *p, int protocol);
  33. bool snd_usb_validate_midi_desc(void *p);
  34. #endif /* __USBAUDIO_HELPER_H */