2 * u_audio.h -- interface to USB gadget "ALSA sound card" utilities
5 * Author: Ruslan Bilovol <ruslan.bilovol@gmail.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
22 #include <linux/usb/composite.h>
26 int p_chmask; /* channel mask */
27 int p_srate; /* rate in Hz */
28 int p_ssize; /* sample size */
31 int c_chmask; /* channel mask */
32 int c_srate; /* rate in Hz */
33 int c_ssize; /* sample size */
35 int req_number; /* number of preallocated requests */
39 struct usb_function func;
40 struct usb_gadget *gadget;
43 struct usb_ep *out_ep;
45 /* Max packet size for all in_ep possible speeds */
46 unsigned int in_ep_maxpsize;
47 /* Max packet size for all out_ep possible speeds */
48 unsigned int out_ep_maxpsize;
50 /* The ALSA Sound Card it represents on the USB-Client side */
51 struct snd_uac_chip *uac;
53 struct uac_params params;
56 static inline struct g_audio *func_to_g_audio(struct usb_function *f)
58 return container_of(f, struct g_audio, func);
61 static inline uint num_channels(uint chanmask)
66 num += (chanmask & 1);
74 * g_audio_setup - initialize one virtual ALSA sound card
75 * @g_audio: struct with filled params, in_ep_maxpsize, out_ep_maxpsize
76 * @pcm_name: the id string for a PCM instance of this sound card
77 * @card_name: name of this soundcard
79 * This sets up the single virtual ALSA sound card that may be exported by a
80 * gadget driver using this framework.
84 * Returns zero on success, or a negative error on failure.
86 int g_audio_setup(struct g_audio *g_audio, const char *pcm_name,
87 const char *card_name);
88 void g_audio_cleanup(struct g_audio *g_audio);
90 int u_audio_start_capture(struct g_audio *g_audio);
91 void u_audio_stop_capture(struct g_audio *g_audio);
92 int u_audio_start_playback(struct g_audio *g_audio);
93 void u_audio_stop_playback(struct g_audio *g_audio);
95 #endif /* __U_AUDIO_H */