.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | #ifndef __USBAUDIO_H |
---|
2 | 3 | #define __USBAUDIO_H |
---|
3 | 4 | /* |
---|
4 | 5 | * (Tentative) USB Audio Driver for ALSA |
---|
5 | 6 | * |
---|
6 | 7 | * 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 | 8 | */ |
---|
23 | 9 | |
---|
24 | 10 | /* handling of USB vendor/product ID pairs as 32-bit numbers */ |
---|
25 | | -#define USB_ID(vendor, product) (((vendor) << 16) | (product)) |
---|
| 11 | +#define USB_ID(vendor, product) (((unsigned int)(vendor) << 16) | (product)) |
---|
26 | 12 | #define USB_ID_VENDOR(id) ((id) >> 16) |
---|
27 | 13 | #define USB_ID_PRODUCT(id) ((u16)(id)) |
---|
| 14 | + |
---|
| 15 | +#include <linux/android_kabi.h> |
---|
28 | 16 | |
---|
29 | 17 | /* |
---|
30 | 18 | * |
---|
31 | 19 | */ |
---|
32 | 20 | |
---|
| 21 | +struct media_device; |
---|
| 22 | +struct media_intf_devnode; |
---|
| 23 | + |
---|
| 24 | +#define MAX_CARD_INTERFACES 16 |
---|
| 25 | + |
---|
33 | 26 | struct snd_usb_audio { |
---|
34 | 27 | int index; |
---|
35 | 28 | struct usb_device *dev; |
---|
36 | 29 | struct snd_card *card; |
---|
37 | | - struct usb_interface *pm_intf; |
---|
| 30 | + struct usb_interface *intf[MAX_CARD_INTERFACES]; |
---|
38 | 31 | u32 usb_id; |
---|
| 32 | + uint16_t quirk_type; |
---|
39 | 33 | struct mutex mutex; |
---|
40 | 34 | unsigned int system_suspend; |
---|
41 | 35 | atomic_t active; |
---|
.. | .. |
---|
45 | 39 | unsigned int txfr_quirk:1; /* Subframe boundaries on transfers */ |
---|
46 | 40 | unsigned int tx_length_quirk:1; /* Put length specifier in transfers */ |
---|
47 | 41 | unsigned int setup_fmt_after_resume_quirk:1; /* setup the format to interface after resume */ |
---|
| 42 | + unsigned int need_delayed_register:1; /* warn for delayed registration */ |
---|
48 | 43 | int num_interfaces; |
---|
49 | 44 | int num_suspended_intf; |
---|
50 | 45 | int sample_rate_read_error; |
---|
.. | .. |
---|
66 | 61 | */ |
---|
67 | 62 | |
---|
68 | 63 | struct usb_host_interface *ctrl_intf; /* the audio control interface */ |
---|
| 64 | + struct media_device *media_dev; |
---|
| 65 | + struct media_intf_devnode *ctl_intf_media_devnode; |
---|
69 | 66 | struct mutex dev_lock; /* to protect any race with disconnect */ |
---|
70 | 67 | int card_num; /* cache pcm card number to use upon disconnect */ |
---|
71 | | - void (*disconnect_cb)(struct snd_usb_audio *chip); /* callback to cleanup on disconnect */ |
---|
| 68 | + void (*disconnect_cb)(struct snd_usb_audio *chip); |
---|
| 69 | + |
---|
| 70 | + ANDROID_KABI_RESERVE(1); |
---|
| 71 | + ANDROID_KABI_RESERVE(2); |
---|
| 72 | + ANDROID_KABI_RESERVE(3); |
---|
| 73 | + ANDROID_KABI_RESERVE(4); |
---|
72 | 74 | }; |
---|
73 | 75 | |
---|
74 | 76 | #define USB_AUDIO_IFACE_UNUSED ((void *)-1L) |
---|
.. | .. |
---|
113 | 115 | QUIRK_AUDIO_ALIGN_TRANSFER, |
---|
114 | 116 | QUIRK_AUDIO_STANDARD_MIXER, |
---|
115 | 117 | QUIRK_SETUP_FMT_AFTER_RESUME, |
---|
| 118 | + QUIRK_SETUP_DISABLE_AUTOSUSPEND, |
---|
116 | 119 | |
---|
117 | 120 | QUIRK_TYPE_COUNT |
---|
118 | 121 | }; |
---|
.. | .. |
---|
120 | 123 | struct snd_usb_audio_quirk { |
---|
121 | 124 | const char *vendor_name; |
---|
122 | 125 | const char *product_name; |
---|
123 | | - const char *profile_name; /* override the card->longname */ |
---|
124 | 126 | int16_t ifnum; |
---|
125 | 127 | uint16_t type; |
---|
| 128 | + bool shares_media_device; |
---|
126 | 129 | const void *data; |
---|
127 | 130 | }; |
---|
128 | 131 | |
---|
.. | .. |
---|
134 | 137 | void snd_usb_unlock_shutdown(struct snd_usb_audio *chip); |
---|
135 | 138 | |
---|
136 | 139 | extern bool snd_usb_use_vmalloc; |
---|
| 140 | +extern bool snd_usb_skip_validation; |
---|
| 141 | + |
---|
| 142 | +struct audioformat; |
---|
| 143 | + |
---|
| 144 | +enum snd_vendor_pcm_open_close { |
---|
| 145 | + SOUND_PCM_CLOSE = 0, |
---|
| 146 | + SOUND_PCM_OPEN, |
---|
| 147 | +}; |
---|
| 148 | + |
---|
| 149 | +/** |
---|
| 150 | + * struct snd_usb_audio_vendor_ops - function callbacks for USB audio accelerators |
---|
| 151 | + * @connect: called when a new interface is found |
---|
| 152 | + * @disconnect: called when an interface is removed |
---|
| 153 | + * @set_interface: called when an interface is initialized |
---|
| 154 | + * @set_rate: called when the rate is set |
---|
| 155 | + * @set_pcm_buf: called when the pcm buffer is set |
---|
| 156 | + * @set_pcm_intf: called when the pcm interface is set |
---|
| 157 | + * @set_pcm_connection: called when pcm is opened/closed |
---|
| 158 | + * @set_pcm_binterval: called when the pcm binterval is set |
---|
| 159 | + * @usb_add_ctls: called when USB controls are added |
---|
| 160 | + * |
---|
| 161 | + * Set of callbacks for some accelerated USB audio streaming hardware. |
---|
| 162 | + * |
---|
| 163 | + * TODO: make this USB host-controller specific, right now this only works for |
---|
| 164 | + * one USB controller in the system at a time, which is only realistic for |
---|
| 165 | + * self-contained systems like phones. |
---|
| 166 | + */ |
---|
| 167 | +struct snd_usb_audio_vendor_ops { |
---|
| 168 | + int (*connect)(struct usb_interface *intf); |
---|
| 169 | + void (*disconnect)(struct usb_interface *intf); |
---|
| 170 | + |
---|
| 171 | + int (*set_interface)(struct usb_device *udev, |
---|
| 172 | + struct usb_host_interface *alts, |
---|
| 173 | + int iface, int alt); |
---|
| 174 | + int (*set_rate)(struct usb_interface *intf, int iface, int rate, |
---|
| 175 | + int alt); |
---|
| 176 | + int (*set_pcm_buf)(struct usb_device *udev, int iface); |
---|
| 177 | + int (*set_pcm_intf)(struct usb_interface *intf, int iface, int alt, |
---|
| 178 | + int direction); |
---|
| 179 | + int (*set_pcm_connection)(struct usb_device *udev, |
---|
| 180 | + enum snd_vendor_pcm_open_close onoff, |
---|
| 181 | + int direction); |
---|
| 182 | + int (*set_pcm_binterval)(struct audioformat *fp, |
---|
| 183 | + struct audioformat *found, |
---|
| 184 | + int *cur_attr, int *attr); |
---|
| 185 | + int (*usb_add_ctls)(struct snd_usb_audio *chip); |
---|
| 186 | + |
---|
| 187 | + ANDROID_KABI_RESERVE(1); |
---|
| 188 | + ANDROID_KABI_RESERVE(2); |
---|
| 189 | +}; |
---|
137 | 190 | |
---|
138 | 191 | #endif /* __USBAUDIO_H */ |
---|