]>
Commit | Line | Data |
---|---|---|
1a59d1b8 | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
1da177e4 LT |
2 | #ifndef __USBAUDIO_H |
3 | #define __USBAUDIO_H | |
4 | /* | |
5 | * (Tentative) USB Audio Driver for ALSA | |
6 | * | |
7 | * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de> | |
1da177e4 LT |
8 | */ |
9 | ||
27d10f56 CL |
10 | /* handling of USB vendor/product ID pairs as 32-bit numbers */ |
11 | #define USB_ID(vendor, product) (((vendor) << 16) | (product)) | |
12 | #define USB_ID_VENDOR(id) ((id) >> 16) | |
13 | #define USB_ID_PRODUCT(id) ((u16)(id)) | |
14 | ||
1da177e4 | 15 | /* |
e5779998 | 16 | * |
1da177e4 LT |
17 | */ |
18 | ||
66354f18 SK |
19 | struct media_device; |
20 | struct media_intf_devnode; | |
21 | ||
88d8822d TI |
22 | #define MAX_CARD_INTERFACES 16 |
23 | ||
1da177e4 LT |
24 | struct snd_usb_audio { |
25 | int index; | |
26 | struct usb_device *dev; | |
86e07d34 | 27 | struct snd_card *card; |
88d8822d | 28 | struct usb_interface *intf[MAX_CARD_INTERFACES]; |
27d10f56 | 29 | u32 usb_id; |
851b00ed | 30 | uint16_t quirk_type; |
596580d0 | 31 | struct mutex mutex; |
862b2509 | 32 | unsigned int system_suspend; |
47ab1545 TI |
33 | atomic_t active; |
34 | atomic_t shutdown; | |
35 | atomic_t usage_count; | |
36 | wait_queue_head_t shutdown_wait; | |
98e89f60 | 37 | unsigned int txfr_quirk:1; /* Subframe boundaries on transfers */ |
e0570446 | 38 | unsigned int tx_length_quirk:1; /* Put length specifier in transfers */ |
a4aad563 | 39 | unsigned int need_delayed_register:1; /* warn for delayed registration */ |
1da177e4 | 40 | int num_interfaces; |
f85bf29c | 41 | int num_suspended_intf; |
57dd5414 | 42 | int sample_rate_read_error; |
1da177e4 | 43 | |
17156f23 RB |
44 | int badd_profile; /* UAC3 BADD profile */ |
45 | ||
1da177e4 | 46 | struct list_head pcm_list; /* list of pcm streams */ |
8fdff6a3 | 47 | struct list_head ep_list; /* list of audio-related endpoints */ |
00272c61 | 48 | struct list_head iface_ref_list; /* list of interface refcounts */ |
1da177e4 LT |
49 | int pcm_devs; |
50 | ||
51 | struct list_head midi_list; /* list of midi interfaces */ | |
1da177e4 | 52 | |
84957a8a | 53 | struct list_head mixer_list; /* list of mixer interfaces */ |
e5779998 DM |
54 | |
55 | int setup; /* from the 'device_setup' module param */ | |
62abd092 | 56 | bool generic_implicit_fb; /* from the 'implicit_fb' module param */ |
ef02e29b | 57 | bool autoclock; /* from the 'autoclock' module param */ |
79f920fb DM |
58 | |
59 | struct usb_host_interface *ctrl_intf; /* the audio control interface */ | |
66354f18 SK |
60 | struct media_device *media_dev; |
61 | struct media_intf_devnode *ctl_intf_media_devnode; | |
1da177e4 LT |
62 | }; |
63 | ||
74a040e1 TI |
64 | #define USB_AUDIO_IFACE_UNUSED ((void *)-1L) |
65 | ||
0ba41d91 TI |
66 | #define usb_audio_err(chip, fmt, args...) \ |
67 | dev_err(&(chip)->dev->dev, fmt, ##args) | |
68 | #define usb_audio_warn(chip, fmt, args...) \ | |
69 | dev_warn(&(chip)->dev->dev, fmt, ##args) | |
70 | #define usb_audio_info(chip, fmt, args...) \ | |
71 | dev_info(&(chip)->dev->dev, fmt, ##args) | |
72 | #define usb_audio_dbg(chip, fmt, args...) \ | |
73 | dev_dbg(&(chip)->dev->dev, fmt, ##args) | |
74 | ||
1da177e4 LT |
75 | /* |
76 | * Information about devices with broken descriptors | |
77 | */ | |
78 | ||
79 | /* special values for .ifnum */ | |
80 | #define QUIRK_NO_INTERFACE -2 | |
81 | #define QUIRK_ANY_INTERFACE -1 | |
82 | ||
854af957 CL |
83 | enum quirk_type { |
84 | QUIRK_IGNORE_INTERFACE, | |
85 | QUIRK_COMPOSITE, | |
aafe77cc | 86 | QUIRK_AUTODETECT, |
854af957 CL |
87 | QUIRK_MIDI_STANDARD_INTERFACE, |
88 | QUIRK_MIDI_FIXED_ENDPOINT, | |
89 | QUIRK_MIDI_YAMAHA, | |
aafe77cc | 90 | QUIRK_MIDI_ROLAND, |
854af957 CL |
91 | QUIRK_MIDI_MIDIMAN, |
92 | QUIRK_MIDI_NOVATION, | |
c7f57216 | 93 | QUIRK_MIDI_RAW_BYTES, |
854af957 | 94 | QUIRK_MIDI_EMAGIC, |
cc7a59bd | 95 | QUIRK_MIDI_CME, |
4434ade8 | 96 | QUIRK_MIDI_AKAI, |
030a07e4 | 97 | QUIRK_MIDI_US122L, |
1ef0e0a0 | 98 | QUIRK_MIDI_FTDI, |
1ca8b201 | 99 | QUIRK_MIDI_CH345, |
854af957 CL |
100 | QUIRK_AUDIO_STANDARD_INTERFACE, |
101 | QUIRK_AUDIO_FIXED_ENDPOINT, | |
310e0dc0 | 102 | QUIRK_AUDIO_EDIROL_UAXX, |
52a7a583 | 103 | QUIRK_AUDIO_ALIGN_TRANSFER, |
014950b0 | 104 | QUIRK_AUDIO_STANDARD_MIXER, |
92adc96f | 105 | QUIRK_SETUP_FMT_AFTER_RESUME, |
1965c436 | 106 | QUIRK_SETUP_DISABLE_AUTOSUSPEND, |
854af957 CL |
107 | |
108 | QUIRK_TYPE_COUNT | |
109 | }; | |
1da177e4 | 110 | |
1da177e4 LT |
111 | struct snd_usb_audio_quirk { |
112 | const char *vendor_name; | |
113 | const char *product_name; | |
114 | int16_t ifnum; | |
854af957 | 115 | uint16_t type; |
66354f18 | 116 | bool shares_media_device; |
1da177e4 LT |
117 | const void *data; |
118 | }; | |
119 | ||
f4950882 | 120 | #define combine_word(s) ((*(s)) | ((unsigned int)(s)[1] << 8)) |
1da177e4 LT |
121 | #define combine_triple(s) (combine_word(s) | ((unsigned int)(s)[2] << 16)) |
122 | #define combine_quad(s) (combine_triple(s) | ((unsigned int)(s)[3] << 24)) | |
123 | ||
47ab1545 TI |
124 | int snd_usb_lock_shutdown(struct snd_usb_audio *chip); |
125 | void snd_usb_unlock_shutdown(struct snd_usb_audio *chip); | |
126 | ||
f274baa4 | 127 | extern bool snd_usb_use_vmalloc; |
f35ef592 | 128 | extern bool snd_usb_skip_validation; |
f274baa4 | 129 | |
1da177e4 | 130 | #endif /* __USBAUDIO_H */ |