xref: /openbmc/linux/sound/usb/usx2y/usbusx2y.h (revision 99a15348)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef USBUSX2Y_H
3 #define USBUSX2Y_H
4 #include "../usbaudio.h"
5 #include "../midi.h"
6 #include "usbus428ctldefs.h"
7 
8 #define NRURBS	        2
9 
10 
11 #define URBS_ASYNC_SEQ 10
12 #define URB_DATA_LEN_ASYNC_SEQ 32
13 struct snd_usx2y_async_seq {
14 	struct urb	*urb[URBS_ASYNC_SEQ];
15 	char		*buffer;
16 };
17 
18 struct snd_usx2y_urb_seq {
19 	int	submitted;
20 	int	len;
21 	struct urb	*urb[];
22 };
23 
24 #include "usx2yhwdeppcm.h"
25 
26 struct usx2ydev {
27 	struct usb_device	*dev;
28 	int			card_index;
29 	int			stride;
30 	struct urb		*in04_urb;
31 	void			*in04_buf;
32 	char			in04_last[24];
33 	unsigned int		in04_int_calls;
34 	struct snd_usx2y_urb_seq	*us04;
35 	wait_queue_head_t	in04_wait_queue;
36 	struct snd_usx2y_async_seq	as04;
37 	unsigned int		rate,
38 				format;
39 	int			chip_status;
40 	struct mutex		pcm_mutex;
41 	struct us428ctls_sharedmem	*us428ctls_sharedmem;
42 	int			wait_iso_frame;
43 	wait_queue_head_t	us428ctls_wait_queue_head;
44 	struct snd_usx2y_hwdep_pcm_shm	*hwdep_pcm_shm;
45 	struct snd_usx2y_substream	*subs[4];
46 	struct snd_usx2y_substream	* volatile  prepare_subs;
47 	wait_queue_head_t	prepare_wait_queue;
48 	struct list_head	midi_list;
49 	int			pcm_devs;
50 };
51 
52 
53 struct snd_usx2y_substream {
54 	struct usx2ydev	*usx2y;
55 	struct snd_pcm_substream *pcm_substream;
56 
57 	int			endpoint;
58 	unsigned int		maxpacksize;		/* max packet size in bytes */
59 
60 	atomic_t		state;
61 #define STATE_STOPPED	0
62 #define STATE_STARTING1 1
63 #define STATE_STARTING2 2
64 #define STATE_STARTING3 3
65 #define STATE_PREPARED	4
66 #define STATE_PRERUNNING  6
67 #define STATE_RUNNING	8
68 
69 	int			hwptr;			/* free frame position in the buffer (only for playback) */
70 	int			hwptr_done;		/* processed frame position in the buffer */
71 	int			transfer_done;		/* processed frames since last period update */
72 
73 	struct urb		*urb[NRURBS];	/* data urb table */
74 	struct urb		*completed_urb;
75 	char			*tmpbuf;			/* temporary buffer for playback */
76 };
77 
78 
79 #define usx2y(c) ((struct usx2ydev *)(c)->private_data)
80 
81 int usx2y_audio_create(struct snd_card *card);
82 
83 int usx2y_async_seq04_init(struct usx2ydev *usx2y);
84 int usx2y_in04_init(struct usx2ydev *usx2y);
85 
86 #define NAME_ALLCAPS "US-X2Y"
87 
88 #endif
89