usbaudio.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. #ifndef __USBAUDIO_H
  2. #define __USBAUDIO_H
  3. /*
  4. * (Tentative) USB Audio Driver for ALSA
  5. *
  6. * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de>
  7. *
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. /* maximum number of endpoints per interface */
  24. #define MIDI_MAX_ENDPOINTS 2
  25. /* handling of USB vendor/product ID pairs as 32-bit numbers */
  26. #define USB_ID(vendor, product) (((vendor) << 16) | (product))
  27. #define USB_ID_VENDOR(id) ((id) >> 16)
  28. #define USB_ID_PRODUCT(id) ((u16)(id))
  29. /*
  30. */
  31. struct snd_usb_audio {
  32. int index;
  33. struct usb_device *dev;
  34. struct snd_card *card;
  35. u32 usb_id;
  36. int shutdown;
  37. unsigned int txfr_quirk:1; /* Subframe boundaries on transfers */
  38. int num_interfaces;
  39. int num_suspended_intf;
  40. /* for audio class v2 */
  41. int clock_id;
  42. struct list_head pcm_list; /* list of pcm streams */
  43. int pcm_devs;
  44. struct list_head midi_list; /* list of midi interfaces */
  45. struct list_head mixer_list; /* list of mixer interfaces */
  46. };
  47. /*
  48. * Information about devices with broken descriptors
  49. */
  50. /* special values for .ifnum */
  51. #define QUIRK_NO_INTERFACE -2
  52. #define QUIRK_ANY_INTERFACE -1
  53. enum quirk_type {
  54. QUIRK_IGNORE_INTERFACE,
  55. QUIRK_COMPOSITE,
  56. QUIRK_MIDI_STANDARD_INTERFACE,
  57. QUIRK_MIDI_FIXED_ENDPOINT,
  58. QUIRK_MIDI_YAMAHA,
  59. QUIRK_MIDI_MIDIMAN,
  60. QUIRK_MIDI_NOVATION,
  61. QUIRK_MIDI_FASTLANE,
  62. QUIRK_MIDI_EMAGIC,
  63. QUIRK_MIDI_CME,
  64. QUIRK_MIDI_US122L,
  65. QUIRK_AUDIO_STANDARD_INTERFACE,
  66. QUIRK_AUDIO_FIXED_ENDPOINT,
  67. QUIRK_AUDIO_EDIROL_UAXX,
  68. QUIRK_AUDIO_ALIGN_TRANSFER,
  69. QUIRK_TYPE_COUNT
  70. };
  71. struct snd_usb_audio_quirk {
  72. const char *vendor_name;
  73. const char *product_name;
  74. int16_t ifnum;
  75. uint16_t type;
  76. const void *data;
  77. };
  78. /* data for QUIRK_MIDI_FIXED_ENDPOINT */
  79. struct snd_usb_midi_endpoint_info {
  80. int8_t out_ep; /* ep number, 0 autodetect */
  81. uint8_t out_interval; /* interval for interrupt endpoints */
  82. int8_t in_ep;
  83. uint8_t in_interval;
  84. uint16_t out_cables; /* bitmask */
  85. uint16_t in_cables; /* bitmask */
  86. };
  87. /* for QUIRK_MIDI_YAMAHA, data is NULL */
  88. /* for QUIRK_MIDI_MIDIMAN, data points to a snd_usb_midi_endpoint_info
  89. * structure (out_cables and in_cables only) */
  90. /* for QUIRK_COMPOSITE, data points to an array of snd_usb_audio_quirk
  91. * structures, terminated with .ifnum = -1 */
  92. /* for QUIRK_AUDIO_FIXED_ENDPOINT, data points to an audioformat structure */
  93. /* for QUIRK_AUDIO/MIDI_STANDARD_INTERFACE, data is NULL */
  94. /* for QUIRK_AUDIO_EDIROL_UAXX, data is NULL */
  95. /* for QUIRK_IGNORE_INTERFACE, data is NULL */
  96. /* for QUIRK_MIDI_NOVATION and _RAW, data is NULL */
  97. /* for QUIRK_MIDI_EMAGIC, data points to a snd_usb_midi_endpoint_info
  98. * structure (out_cables and in_cables only) */
  99. /* for QUIRK_MIDI_CME, data is NULL */
  100. /*
  101. */
  102. /*E-mu USB samplerate control quirk*/
  103. enum {
  104. EMU_QUIRK_SR_44100HZ = 0,
  105. EMU_QUIRK_SR_48000HZ,
  106. EMU_QUIRK_SR_88200HZ,
  107. EMU_QUIRK_SR_96000HZ,
  108. EMU_QUIRK_SR_176400HZ,
  109. EMU_QUIRK_SR_192000HZ
  110. };
  111. #define combine_word(s) ((*(s)) | ((unsigned int)(s)[1] << 8))
  112. #define combine_triple(s) (combine_word(s) | ((unsigned int)(s)[2] << 16))
  113. #define combine_quad(s) (combine_triple(s) | ((unsigned int)(s)[3] << 24))
  114. unsigned int snd_usb_combine_bytes(unsigned char *bytes, int size);
  115. void *snd_usb_find_desc(void *descstart, int desclen, void *after, u8 dtype);
  116. void *snd_usb_find_csint_desc(void *descstart, int desclen, void *after, u8 dsubtype);
  117. int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe,
  118. __u8 request, __u8 requesttype, __u16 value, __u16 index,
  119. void *data, __u16 size, int timeout);
  120. int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif,
  121. int ignore_error);
  122. void snd_usb_mixer_disconnect(struct list_head *p);
  123. int snd_usbmidi_create(struct snd_card *card,
  124. struct usb_interface *iface,
  125. struct list_head *midi_list,
  126. const struct snd_usb_audio_quirk *quirk);
  127. void snd_usbmidi_input_stop(struct list_head* p);
  128. void snd_usbmidi_input_start(struct list_head* p);
  129. void snd_usbmidi_disconnect(struct list_head *p);
  130. void snd_emuusb_set_samplerate(struct snd_usb_audio *chip,
  131. unsigned char samplerate_id);
  132. /*
  133. * retrieve usb_interface descriptor from the host interface
  134. * (conditional for compatibility with the older API)
  135. */
  136. #ifndef get_iface_desc
  137. #define get_iface_desc(iface) (&(iface)->desc)
  138. #define get_endpoint(alt,ep) (&(alt)->endpoint[ep].desc)
  139. #define get_ep_desc(ep) (&(ep)->desc)
  140. #define get_cfg_desc(cfg) (&(cfg)->desc)
  141. #endif
  142. #ifndef snd_usb_get_speed
  143. #define snd_usb_get_speed(dev) ((dev)->speed)
  144. #endif
  145. #endif /* __USBAUDIO_H */