hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/usb/gadget/function/u_audio.h
....@@ -1,4 +1,4 @@
1
-// SPDX-License-Identifier: GPL-2.0+
1
+/* SPDX-License-Identifier: GPL-2.0+ */
22 /*
33 * u_audio.h -- interface to USB gadget "ALSA sound card" utilities
44 *
....@@ -10,33 +10,53 @@
1010 #define __U_AUDIO_H
1111
1212 #include <linux/usb/composite.h>
13
+#include "uac_common.h"
1314
14
-#define UAC_VOLUME_CUR 0x0000
15
-#define UAC_VOLUME_RES 0x0080 /* 0.5 dB */
16
-#define UAC_VOLUME_MAX 0x1900 /* 25 dB */
17
-#define UAC_VOLUME_MIN 0xE700 /* -25 dB */
18
-#define UAC_VOLUME_NEGATIVE_INFINITY 0x8000
19
-#define UAC_MAX_RATES 10
15
+/*
16
+ * Same maximum frequency deviation on the slower side as in
17
+ * sound/usb/endpoint.c. Value is expressed in per-mil deviation.
18
+ */
19
+#define FBACK_SLOW_MAX 250
20
+
21
+/*
22
+ * Maximum frequency deviation on the faster side, default value for UAC1/2.
23
+ * Value is expressed in per-mil deviation.
24
+ * UAC2 provides the value as a parameter as it impacts the endpoint required
25
+ * bandwidth.
26
+ */
27
+#define FBACK_FAST_MAX 5
28
+
29
+/* Feature Unit parameters */
30
+struct uac_fu_params {
31
+ int id; /* Feature Unit ID */
32
+
33
+ bool mute_present; /* mute control enable */
34
+
35
+ bool volume_present; /* volume control enable */
36
+ s16 volume_min; /* min volume in 1/256 dB */
37
+ s16 volume_max; /* max volume in 1/256 dB */
38
+ s16 volume_res; /* volume resolution in 1/256 dB */
39
+};
40
+
2041 struct uac_params {
2142 /* playback */
22
- int p_volume;
23
- int p_mute;
2443 int p_chmask; /* channel mask */
25
- int p_srate[UAC_MAX_RATES]; /* rate in Hz */
26
- int p_srate_active; /* selected rate in Hz */
44
+ int p_srates[UAC_MAX_RATES]; /* available rates in Hz (0 terminated list) */
2745 int p_ssize; /* sample size */
46
+ struct uac_fu_params p_fu; /* Feature Unit parameters */
2847
2948 /* capture */
30
- int c_volume;
31
- int c_mute;
3249 int c_chmask; /* channel mask */
33
- int c_srate[UAC_MAX_RATES]; /* rate in Hz */
34
- int c_srate_active; /* selected rate in Hz */
50
+ int c_srates[UAC_MAX_RATES]; /* available rates in Hz (0 terminated list) */
3551 int c_ssize; /* sample size */
52
+ struct uac_fu_params c_fu; /* Feature Unit parameters */
53
+
54
+ /* rates are dynamic, in uac_rtd_params */
3655
3756 int ppm; /* difference between audio clk and usb clk */
3857
3958 int req_number; /* number of preallocated requests */
59
+ int fb_max; /* upper frequency drift feedback limit per-mil */
4060 };
4161
4262 enum usb_state_index {
....@@ -79,12 +99,18 @@
7999 struct usb_gadget *gadget;
80100
81101 struct usb_ep *in_ep;
102
+
82103 struct usb_ep *out_ep;
104
+ /* feedback IN endpoint corresponding to out_ep */
105
+ struct usb_ep *in_ep_fback;
83106
84107 /* Max packet size for all in_ep possible speeds */
85108 unsigned int in_ep_maxpsize;
86109 /* Max packet size for all out_ep possible speeds */
87110 unsigned int out_ep_maxpsize;
111
+
112
+ /* Notify UAC driver about control change */
113
+ int (*notify)(struct g_audio *g_audio, int unit_id, int cs);
88114
89115 /* The ALSA Sound Card it represents on the USB-Client side */
90116 struct snd_uac_chip *uac;
....@@ -130,9 +156,17 @@
130156 void u_audio_stop_capture(struct g_audio *g_audio);
131157 int u_audio_start_playback(struct g_audio *g_audio);
132158 void u_audio_stop_playback(struct g_audio *g_audio);
159
+
160
+int u_audio_get_capture_srate(struct g_audio *audio_dev, u32 *val);
133161 int u_audio_set_capture_srate(struct g_audio *audio_dev, int srate);
162
+int u_audio_get_playback_srate(struct g_audio *audio_dev, u32 *val);
134163 int u_audio_set_playback_srate(struct g_audio *audio_dev, int srate);
135
-int u_audio_fu_set_cmd(struct usb_audio_control *con, u8 cmd, int value);
136
-int u_audio_fu_get_cmd(struct usb_audio_control *con, u8 cmd);
164
+
165
+int u_audio_get_volume(struct g_audio *g_audio, int playback, s16 *val);
166
+int u_audio_set_volume(struct g_audio *g_audio, int playback, s16 val);
167
+int u_audio_get_mute(struct g_audio *g_audio, int playback, int *val);
168
+int u_audio_set_mute(struct g_audio *g_audio, int playback, int val);
169
+
170
+void u_audio_suspend(struct g_audio *g_audio);
137171
138172 #endif /* __U_AUDIO_H */