Commit 02de698c authored by Ruslan Bilovol's avatar Ruslan Bilovol Committed by Greg Kroah-Hartman

usb: gadget: u_audio: add bi-directional volume and mute support

USB Audio Class 1/2 have ability to change device's
volume and mute by USB Host through class-specific control
requests. Device also can notify Host about volume/mute
change on its side through optional interrupt endpoint.

This patch adds Volume and Mute ALSA controls which can be
used by user to send and receive notifications to/from
the USB Host about Volume and Mute change.

These params come from f_uac* so volume and mute controls
will be created only if the function support and enable
each explicitly
Signed-off-by: default avatarRuslan Bilovol <ruslan.bilovol@gmail.com>
Signed-off-by: default avatarPavel Hofman <pavel.hofman@ivitera.com>
Link: https://lore.kernel.org/r/20210712125529.76070-3-pavel.hofman@ivitera.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b48f8939
This diff is collapsed.
......@@ -19,16 +19,30 @@
*/
#define FBACK_SLOW_MAX 250
/* Feature Unit parameters */
struct uac_fu_params {
int id; /* Feature Unit ID */
bool mute_present; /* mute control enable */
bool volume_present; /* volume control enable */
s16 volume_min; /* min volume in 1/256 dB */
s16 volume_max; /* max volume in 1/256 dB */
s16 volume_res; /* volume resolution in 1/256 dB */
};
struct uac_params {
/* playback */
int p_chmask; /* channel mask */
int p_srate; /* rate in Hz */
int p_ssize; /* sample size */
struct uac_fu_params p_fu; /* Feature Unit parameters */
/* capture */
int c_chmask; /* channel mask */
int c_srate; /* rate in Hz */
int c_ssize; /* sample size */
struct uac_fu_params c_fu; /* Feature Unit parameters */
int req_number; /* number of preallocated requests */
int fb_max; /* upper frequency drift feedback limit per-mil */
......@@ -49,6 +63,9 @@ struct g_audio {
/* Max packet size for all out_ep possible speeds */
unsigned int out_ep_maxpsize;
/* Notify UAC driver about control change */
int (*notify)(struct g_audio *g_audio, int unit_id, int cs);
/* The ALSA Sound Card it represents on the USB-Client side */
struct snd_uac_chip *uac;
......@@ -94,4 +111,9 @@ void u_audio_stop_capture(struct g_audio *g_audio);
int u_audio_start_playback(struct g_audio *g_audio);
void u_audio_stop_playback(struct g_audio *g_audio);
int u_audio_get_volume(struct g_audio *g_audio, int playback, s16 *val);
int u_audio_set_volume(struct g_audio *g_audio, int playback, s16 val);
int u_audio_get_mute(struct g_audio *g_audio, int playback, int *val);
int u_audio_set_mute(struct g_audio *g_audio, int playback, int val);
#endif /* __U_AUDIO_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment