forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/usb/usbaudio.h
....@@ -1,41 +1,35 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 #ifndef __USBAUDIO_H
23 #define __USBAUDIO_H
34 /*
45 * (Tentative) USB Audio Driver for ALSA
56 *
67 * 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
228 */
239
2410 /* 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))
2612 #define USB_ID_VENDOR(id) ((id) >> 16)
2713 #define USB_ID_PRODUCT(id) ((u16)(id))
14
+
15
+#include <linux/android_kabi.h>
2816
2917 /*
3018 *
3119 */
3220
21
+struct media_device;
22
+struct media_intf_devnode;
23
+
24
+#define MAX_CARD_INTERFACES 16
25
+
3326 struct snd_usb_audio {
3427 int index;
3528 struct usb_device *dev;
3629 struct snd_card *card;
37
- struct usb_interface *pm_intf;
30
+ struct usb_interface *intf[MAX_CARD_INTERFACES];
3831 u32 usb_id;
32
+ uint16_t quirk_type;
3933 struct mutex mutex;
4034 unsigned int system_suspend;
4135 atomic_t active;
....@@ -45,6 +39,7 @@
4539 unsigned int txfr_quirk:1; /* Subframe boundaries on transfers */
4640 unsigned int tx_length_quirk:1; /* Put length specifier in transfers */
4741 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 */
4843 int num_interfaces;
4944 int num_suspended_intf;
5045 int sample_rate_read_error;
....@@ -66,9 +61,16 @@
6661 */
6762
6863 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;
6966 struct mutex dev_lock; /* to protect any race with disconnect */
7067 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);
7274 };
7375
7476 #define USB_AUDIO_IFACE_UNUSED ((void *)-1L)
....@@ -113,6 +115,7 @@
113115 QUIRK_AUDIO_ALIGN_TRANSFER,
114116 QUIRK_AUDIO_STANDARD_MIXER,
115117 QUIRK_SETUP_FMT_AFTER_RESUME,
118
+ QUIRK_SETUP_DISABLE_AUTOSUSPEND,
116119
117120 QUIRK_TYPE_COUNT
118121 };
....@@ -120,9 +123,9 @@
120123 struct snd_usb_audio_quirk {
121124 const char *vendor_name;
122125 const char *product_name;
123
- const char *profile_name; /* override the card->longname */
124126 int16_t ifnum;
125127 uint16_t type;
128
+ bool shares_media_device;
126129 const void *data;
127130 };
128131
....@@ -134,5 +137,55 @@
134137 void snd_usb_unlock_shutdown(struct snd_usb_audio *chip);
135138
136139 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
+};
137190
138191 #endif /* __USBAUDIO_H */