xref: /openbmc/linux/sound/usb/usx2y/usbusx2y.h (revision 52cdded0)
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_AsyncSeq 10
12 #define URB_DataLen_AsyncSeq 32
13 struct snd_usX2Y_AsyncSeq {
14 	struct urb	*urb[URBS_AsyncSeq];
15 	char		*buffer;
16 };
17 
18 struct snd_usX2Y_urbSeq {
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		*In04urb;
31 	void			*In04Buf;
32 	char			In04Last[24];
33 	unsigned		In04IntCalls;
34 	struct snd_usX2Y_urbSeq	*US04;
35 	wait_queue_head_t	In04WaitQueue;
36 	struct snd_usX2Y_AsyncSeq	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 	struct list_head	pcm_list;
50 	int			pcm_devs;
51 };
52 
53 
54 struct snd_usX2Y_substream {
55 	struct usX2Ydev	*usX2Y;
56 	struct snd_pcm_substream *pcm_substream;
57 
58 	int			endpoint;
59 	unsigned int		maxpacksize;		/* max packet size in bytes */
60 
61 	atomic_t		state;
62 #define state_STOPPED	0
63 #define state_STARTING1 1
64 #define state_STARTING2 2
65 #define state_STARTING3 3
66 #define state_PREPARED	4
67 #define state_PRERUNNING  6
68 #define state_RUNNING	8
69 
70 	int			hwptr;			/* free frame position in the buffer (only for playback) */
71 	int			hwptr_done;		/* processed frame position in the buffer */
72 	int			transfer_done;		/* processed frames since last period update */
73 
74 	struct urb		*urb[NRURBS];	/* data urb table */
75 	struct urb		*completed_urb;
76 	char			*tmpbuf;			/* temporary buffer for playback */
77 };
78 
79 
80 #define usX2Y(c) ((struct usX2Ydev *)(c)->private_data)
81 
82 int usX2Y_audio_create(struct snd_card *card);
83 
84 int usX2Y_AsyncSeq04_init(struct usX2Ydev *usX2Y);
85 int usX2Y_In04_init(struct usX2Ydev *usX2Y);
86 
87 #define NAME_ALLCAPS "US-X2Y"
88 
89 #endif
90