| 
									
										
										
										
											2009-06-03 09:17:58 -04:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2012-02-02 21:59:53 +05:30
										 |  |  |  * u_uac1.h -- interface to USB gadget "ALSA AUDIO" utilities | 
					
						
							| 
									
										
										
										
											2009-06-03 09:17:58 -04:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Copyright (C) 2008 Bryan Wu <cooloney@kernel.org> | 
					
						
							|  |  |  |  * Copyright (C) 2008 Analog Devices, Inc | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Enter bugs at http://blackfin.uclinux.org/
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Licensed under the GPL-2 or later. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef __U_AUDIO_H
 | 
					
						
							|  |  |  | #define __U_AUDIO_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <linux/device.h>
 | 
					
						
							|  |  |  | #include <linux/err.h>
 | 
					
						
							|  |  |  | #include <linux/usb/audio.h>
 | 
					
						
							|  |  |  | #include <linux/usb/composite.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <sound/core.h>
 | 
					
						
							|  |  |  | #include <sound/pcm.h>
 | 
					
						
							|  |  |  | #include <sound/pcm_params.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "gadget_chips.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-22 19:58:42 +02:00
										 |  |  | #define FILE_PCM_PLAYBACK	"/dev/snd/pcmC0D0p"
 | 
					
						
							|  |  |  | #define FILE_PCM_CAPTURE	"/dev/snd/pcmC0D0c"
 | 
					
						
							|  |  |  | #define FILE_CONTROL		"/dev/snd/controlC0"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define UAC1_OUT_EP_MAX_PACKET_SIZE	200
 | 
					
						
							|  |  |  | #define UAC1_REQ_COUNT			256
 | 
					
						
							|  |  |  | #define UAC1_AUDIO_BUF_SIZE		48000
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-03 09:17:58 -04:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * This represents the USB side of an audio card device, managed by a USB | 
					
						
							|  |  |  |  * function which provides control and stream interfaces. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct gaudio_snd_dev { | 
					
						
							|  |  |  | 	struct gaudio			*card; | 
					
						
							|  |  |  | 	struct file			*filp; | 
					
						
							|  |  |  | 	struct snd_pcm_substream	*substream; | 
					
						
							|  |  |  | 	int				access; | 
					
						
							|  |  |  | 	int				format; | 
					
						
							|  |  |  | 	int				channels; | 
					
						
							|  |  |  | 	int				rate; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct gaudio { | 
					
						
							|  |  |  | 	struct usb_function		func; | 
					
						
							|  |  |  | 	struct usb_gadget		*gadget; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* ALSA sound device interfaces */ | 
					
						
							|  |  |  | 	struct gaudio_snd_dev		control; | 
					
						
							|  |  |  | 	struct gaudio_snd_dev		playback; | 
					
						
							|  |  |  | 	struct gaudio_snd_dev		capture; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* TODO */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-22 19:58:38 +02:00
										 |  |  | struct f_uac1_opts { | 
					
						
							|  |  |  | 	struct usb_function_instance	func_inst; | 
					
						
							|  |  |  | 	int				req_buf_size; | 
					
						
							|  |  |  | 	int				req_count; | 
					
						
							|  |  |  | 	int				audio_buf_size; | 
					
						
							|  |  |  | 	char				*fn_play; | 
					
						
							|  |  |  | 	char				*fn_cap; | 
					
						
							|  |  |  | 	char				*fn_cntl; | 
					
						
							| 
									
										
										
										
											2014-07-22 19:58:43 +02:00
										 |  |  | 	unsigned			bound:1; | 
					
						
							|  |  |  | 	unsigned			fn_play_alloc:1; | 
					
						
							|  |  |  | 	unsigned			fn_cap_alloc:1; | 
					
						
							|  |  |  | 	unsigned			fn_cntl_alloc:1; | 
					
						
							| 
									
										
										
										
											2014-07-22 19:58:38 +02:00
										 |  |  | 	struct gaudio			*card; | 
					
						
							| 
									
										
										
										
											2014-07-22 19:58:43 +02:00
										 |  |  | 	struct mutex			lock; | 
					
						
							|  |  |  | 	int				refcnt; | 
					
						
							| 
									
										
										
										
											2014-07-22 19:58:38 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-03 09:17:58 -04:00
										 |  |  | int gaudio_setup(struct gaudio *card); | 
					
						
							| 
									
										
										
										
											2014-07-22 19:58:38 +02:00
										 |  |  | void gaudio_cleanup(struct gaudio *the_card); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | size_t u_audio_playback(struct gaudio *card, void *buf, size_t count); | 
					
						
							|  |  |  | int u_audio_get_playback_channels(struct gaudio *card); | 
					
						
							|  |  |  | int u_audio_get_playback_rate(struct gaudio *card); | 
					
						
							| 
									
										
										
										
											2009-06-03 09:17:58 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif /* __U_AUDIO_H */
 |