.. | .. |
---|
1 | | -// SPDX-License-Identifier: GPL-2.0+ |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ |
---|
2 | 2 | /* |
---|
3 | 3 | * u_audio.h -- interface to USB gadget "ALSA sound card" utilities |
---|
4 | 4 | * |
---|
.. | .. |
---|
10 | 10 | #define __U_AUDIO_H |
---|
11 | 11 | |
---|
12 | 12 | #include <linux/usb/composite.h> |
---|
| 13 | +#include "uac_common.h" |
---|
13 | 14 | |
---|
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 | + |
---|
20 | 41 | struct uac_params { |
---|
21 | 42 | /* playback */ |
---|
22 | | - int p_volume; |
---|
23 | | - int p_mute; |
---|
24 | 43 | 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) */ |
---|
27 | 45 | int p_ssize; /* sample size */ |
---|
| 46 | + struct uac_fu_params p_fu; /* Feature Unit parameters */ |
---|
28 | 47 | |
---|
29 | 48 | /* capture */ |
---|
30 | | - int c_volume; |
---|
31 | | - int c_mute; |
---|
32 | 49 | 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) */ |
---|
35 | 51 | int c_ssize; /* sample size */ |
---|
| 52 | + struct uac_fu_params c_fu; /* Feature Unit parameters */ |
---|
| 53 | + |
---|
| 54 | + /* rates are dynamic, in uac_rtd_params */ |
---|
36 | 55 | |
---|
37 | 56 | int ppm; /* difference between audio clk and usb clk */ |
---|
38 | 57 | |
---|
39 | 58 | int req_number; /* number of preallocated requests */ |
---|
| 59 | + int fb_max; /* upper frequency drift feedback limit per-mil */ |
---|
40 | 60 | }; |
---|
41 | 61 | |
---|
42 | 62 | enum usb_state_index { |
---|
.. | .. |
---|
79 | 99 | struct usb_gadget *gadget; |
---|
80 | 100 | |
---|
81 | 101 | struct usb_ep *in_ep; |
---|
| 102 | + |
---|
82 | 103 | struct usb_ep *out_ep; |
---|
| 104 | + /* feedback IN endpoint corresponding to out_ep */ |
---|
| 105 | + struct usb_ep *in_ep_fback; |
---|
83 | 106 | |
---|
84 | 107 | /* Max packet size for all in_ep possible speeds */ |
---|
85 | 108 | unsigned int in_ep_maxpsize; |
---|
86 | 109 | /* Max packet size for all out_ep possible speeds */ |
---|
87 | 110 | 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); |
---|
88 | 114 | |
---|
89 | 115 | /* The ALSA Sound Card it represents on the USB-Client side */ |
---|
90 | 116 | struct snd_uac_chip *uac; |
---|
.. | .. |
---|
130 | 156 | void u_audio_stop_capture(struct g_audio *g_audio); |
---|
131 | 157 | int u_audio_start_playback(struct g_audio *g_audio); |
---|
132 | 158 | 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); |
---|
133 | 161 | 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); |
---|
134 | 163 | 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); |
---|
137 | 171 | |
---|
138 | 172 | #endif /* __U_AUDIO_H */ |
---|