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 /* Default value used for nr of packs per urb. 11 * 1 to 4 have been tested ok on uhci. 12 * To use 3 on ohci, you'd need a patch: 13 * look for "0000425-linux-2.6.9-rc4-mm1_ohci-hcd.patch.gz" on 14 * "https://bugtrack.alsa-project.org/alsa-bug/bug_view_page.php?bug_id=0000425" 15 * 16 * 1, 2 and 4 work out of the box on ohci, if I recall correctly. 17 * Bigger is safer operation, smaller gives lower latencies. 18 */ 19 #define USX2Y_NRPACKS 4 20 21 #define USX2Y_NRPACKS_MAX 1024 22 23 /* If your system works ok with this module's parameter 24 * nrpacks set to 1, you might as well comment 25 * this define out, and thereby produce smaller, faster code. 26 * You'd also set USX2Y_NRPACKS to 1 then. 27 */ 28 #define USX2Y_NRPACKS_VARIABLE 1 29 30 #ifdef USX2Y_NRPACKS_VARIABLE 31 extern int nrpacks; 32 #define nr_of_packs() nrpacks 33 #else 34 #define nr_of_packs() USX2Y_NRPACKS 35 #endif 36 37 #define URBS_ASYNC_SEQ 10 38 #define URB_DATA_LEN_ASYNC_SEQ 32 39 struct snd_usx2y_async_seq { 40 struct urb *urb[URBS_ASYNC_SEQ]; 41 char *buffer; 42 }; 43 44 struct snd_usx2y_urb_seq { 45 int submitted; 46 int len; 47 struct urb *urb[] __counted_by(len); 48 }; 49 50 #include "usx2yhwdeppcm.h" 51 52 struct usx2ydev { 53 struct usb_device *dev; 54 int card_index; 55 int stride; 56 struct urb *in04_urb; 57 void *in04_buf; 58 char in04_last[24]; 59 unsigned int in04_int_calls; 60 struct snd_usx2y_urb_seq *us04; 61 wait_queue_head_t in04_wait_queue; 62 struct snd_usx2y_async_seq as04; 63 unsigned int rate, 64 format; 65 int chip_status; 66 struct mutex pcm_mutex; 67 struct us428ctls_sharedmem *us428ctls_sharedmem; 68 int wait_iso_frame; 69 wait_queue_head_t us428ctls_wait_queue_head; 70 struct snd_usx2y_hwdep_pcm_shm *hwdep_pcm_shm; 71 struct snd_usx2y_substream *subs[4]; 72 struct snd_usx2y_substream * volatile prepare_subs; 73 wait_queue_head_t prepare_wait_queue; 74 struct list_head midi_list; 75 int pcm_devs; 76 }; 77 78 79 struct snd_usx2y_substream { 80 struct usx2ydev *usx2y; 81 struct snd_pcm_substream *pcm_substream; 82 83 int endpoint; 84 unsigned int maxpacksize; /* max packet size in bytes */ 85 86 atomic_t state; 87 #define STATE_STOPPED 0 88 #define STATE_STARTING1 1 89 #define STATE_STARTING2 2 90 #define STATE_STARTING3 3 91 #define STATE_PREPARED 4 92 #define STATE_PRERUNNING 6 93 #define STATE_RUNNING 8 94 95 int hwptr; /* free frame position in the buffer (only for playback) */ 96 int hwptr_done; /* processed frame position in the buffer */ 97 int transfer_done; /* processed frames since last period update */ 98 99 struct urb *urb[NRURBS]; /* data urb table */ 100 struct urb *completed_urb; 101 char *tmpbuf; /* temporary buffer for playback */ 102 }; 103 104 105 #define usx2y(c) ((struct usx2ydev *)(c)->private_data) 106 107 int usx2y_audio_create(struct snd_card *card); 108 109 int usx2y_async_seq04_init(struct usx2ydev *usx2y); 110 int usx2y_in04_init(struct usx2ydev *usx2y); 111 112 #define NAME_ALLCAPS "US-X2Y" 113 114 #endif 115