18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef USBUSX2Y_H
38c2ecf20Sopenharmony_ci#define USBUSX2Y_H
48c2ecf20Sopenharmony_ci#include "../usbaudio.h"
58c2ecf20Sopenharmony_ci#include "../midi.h"
68c2ecf20Sopenharmony_ci#include "usbus428ctldefs.h"
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#define NRURBS	        2
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#define URBS_ASYNC_SEQ 10
128c2ecf20Sopenharmony_ci#define URB_DATA_LEN_ASYNC_SEQ 32
138c2ecf20Sopenharmony_cistruct snd_usx2y_async_seq {
148c2ecf20Sopenharmony_ci	struct urb	*urb[URBS_ASYNC_SEQ];
158c2ecf20Sopenharmony_ci	char		*buffer;
168c2ecf20Sopenharmony_ci};
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_cistruct snd_usx2y_urb_seq {
198c2ecf20Sopenharmony_ci	int	submitted;
208c2ecf20Sopenharmony_ci	int	len;
218c2ecf20Sopenharmony_ci	struct urb	*urb[];
228c2ecf20Sopenharmony_ci};
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#include "usx2yhwdeppcm.h"
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cistruct usx2ydev {
278c2ecf20Sopenharmony_ci	struct usb_device	*dev;
288c2ecf20Sopenharmony_ci	int			card_index;
298c2ecf20Sopenharmony_ci	int			stride;
308c2ecf20Sopenharmony_ci	struct urb		*in04_urb;
318c2ecf20Sopenharmony_ci	void			*in04_buf;
328c2ecf20Sopenharmony_ci	char			in04_last[24];
338c2ecf20Sopenharmony_ci	unsigned		in04_int_calls;
348c2ecf20Sopenharmony_ci	struct snd_usx2y_urb_seq	*us04;
358c2ecf20Sopenharmony_ci	wait_queue_head_t	in04_wait_queue;
368c2ecf20Sopenharmony_ci	struct snd_usx2y_async_seq	as04;
378c2ecf20Sopenharmony_ci	unsigned int		rate,
388c2ecf20Sopenharmony_ci				format;
398c2ecf20Sopenharmony_ci	int			chip_status;
408c2ecf20Sopenharmony_ci	struct mutex		pcm_mutex;
418c2ecf20Sopenharmony_ci	struct us428ctls_sharedmem	*us428ctls_sharedmem;
428c2ecf20Sopenharmony_ci	int			wait_iso_frame;
438c2ecf20Sopenharmony_ci	wait_queue_head_t	us428ctls_wait_queue_head;
448c2ecf20Sopenharmony_ci	struct snd_usx2y_hwdep_pcm_shm	*hwdep_pcm_shm;
458c2ecf20Sopenharmony_ci	struct snd_usx2y_substream	*subs[4];
468c2ecf20Sopenharmony_ci	struct snd_usx2y_substream	* volatile  prepare_subs;
478c2ecf20Sopenharmony_ci	wait_queue_head_t	prepare_wait_queue;
488c2ecf20Sopenharmony_ci	struct list_head	midi_list;
498c2ecf20Sopenharmony_ci	struct list_head	pcm_list;
508c2ecf20Sopenharmony_ci	int			pcm_devs;
518c2ecf20Sopenharmony_ci};
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_cistruct snd_usx2y_substream {
558c2ecf20Sopenharmony_ci	struct usx2ydev	*usx2y;
568c2ecf20Sopenharmony_ci	struct snd_pcm_substream *pcm_substream;
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci	int			endpoint;
598c2ecf20Sopenharmony_ci	unsigned int		maxpacksize;		/* max packet size in bytes */
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci	atomic_t		state;
628c2ecf20Sopenharmony_ci#define STATE_STOPPED	0
638c2ecf20Sopenharmony_ci#define STATE_STARTING1 1
648c2ecf20Sopenharmony_ci#define STATE_STARTING2 2
658c2ecf20Sopenharmony_ci#define STATE_STARTING3 3
668c2ecf20Sopenharmony_ci#define STATE_PREPARED	4
678c2ecf20Sopenharmony_ci#define STATE_PRERUNNING  6
688c2ecf20Sopenharmony_ci#define STATE_RUNNING	8
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci	int			hwptr;			/* free frame position in the buffer (only for playback) */
718c2ecf20Sopenharmony_ci	int			hwptr_done;		/* processed frame position in the buffer */
728c2ecf20Sopenharmony_ci	int			transfer_done;		/* processed frames since last period update */
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci	struct urb		*urb[NRURBS];	/* data urb table */
758c2ecf20Sopenharmony_ci	struct urb		*completed_urb;
768c2ecf20Sopenharmony_ci	char			*tmpbuf;			/* temporary buffer for playback */
778c2ecf20Sopenharmony_ci};
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci#define usx2y(c) ((struct usx2ydev *)(c)->private_data)
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ciint usx2y_audio_create(struct snd_card *card);
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ciint usx2y_async_seq04_init(struct usx2ydev *usx2y);
858c2ecf20Sopenharmony_ciint usx2y_in04_init(struct usx2ydev *usx2y);
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci#define NAME_ALLCAPS "US-X2Y"
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci#endif
90