1 /* SPDX-License-Identifier: GPL-2.0 */ 1 2 #ifndef __USBAUDIO_CARD_H 3 #define __USBAUDIO_CARD_H 4 5 #define MAX_NR_RATES 1024 6 #define MAX_PACKS 6 /* per 7 #define MAX_PACKS_HS (MAX_PACKS * 8) /* in 8 #define MAX_URBS 12 9 #define SYNC_URBS 4 /* always four 10 #define MAX_QUEUE 18 /* try not to 11 12 struct audioformat { 13 struct list_head list; 14 u64 formats; /* ALS 15 unsigned int channels; /* # c 16 unsigned int fmt_type; /* USB 17 unsigned int fmt_bits; /* num 18 unsigned int frame_size; /* sam 19 unsigned char iface; /* int 20 unsigned char altsetting; /* cor 21 unsigned char ep_idx; /* end 22 unsigned char altset_idx; /* arr 23 unsigned char attributes; /* cor 24 unsigned char endpoint; /* end 25 unsigned char ep_attr; /* end 26 bool implicit_fb; /* imp 27 unsigned char sync_ep; /* syn 28 unsigned char sync_iface; /* syn 29 unsigned char sync_altsetting; /* syn 30 unsigned char sync_ep_idx; /* syn 31 unsigned char datainterval; /* log 32 unsigned char protocol; /* UAC 33 unsigned int maxpacksize; /* max 34 unsigned int rates; /* rat 35 unsigned int rate_min, rate_max; 36 unsigned int nr_rates; /* num 37 unsigned int *rate_table; /* rat 38 unsigned char clock; /* ass 39 struct snd_pcm_chmap_elem *chmap; /* ( 40 bool dsd_dop; /* add 41 bool dsd_bitrev; /* rev 42 bool dsd_raw; /* alt 43 }; 44 45 struct snd_usb_substream; 46 struct snd_usb_iface_ref; 47 struct snd_usb_clock_ref; 48 struct snd_usb_endpoint; 49 struct snd_usb_power_domain; 50 51 struct snd_urb_ctx { 52 struct urb *urb; 53 unsigned int buffer_size; /* siz 54 struct snd_usb_substream *subs; 55 struct snd_usb_endpoint *ep; 56 int index; /* index for urb array 57 int packets; /* number of packets p 58 int queued; /* queued data bytes b 59 int packet_size[MAX_PACKS_HS]; /* size 60 struct list_head ready_list; 61 }; 62 63 struct snd_usb_endpoint { 64 struct snd_usb_audio *chip; 65 struct snd_usb_iface_ref *iface_ref; 66 struct snd_usb_clock_ref *clock_ref; 67 68 int opened; /* open refcou 69 atomic_t running; /* running sta 70 int ep_num; /* the referen 71 int type; /* SND_USB_END 72 73 unsigned char iface; /* int 74 unsigned char altsetting; /* cor 75 unsigned char ep_idx; /* end 76 77 atomic_t state; /* running sta 78 79 int (*prepare_data_urb) (struct snd_us 80 struct urb *u 81 bool in_strea 82 void (*retire_data_urb) (struct snd_us 83 struct urb *u 84 85 struct snd_usb_substream *data_subs; 86 struct snd_usb_endpoint *sync_source; 87 struct snd_usb_endpoint *sync_sink; 88 89 struct snd_urb_ctx urb[MAX_URBS]; 90 91 struct snd_usb_packet_info { 92 uint32_t packet_size[MAX_PACKS 93 int packets; 94 } next_packet[MAX_URBS]; 95 unsigned int next_packet_head; /* rin 96 unsigned int next_packet_queued; /* qu 97 struct list_head ready_playback_urbs; 98 99 unsigned int nurbs; /* # u 100 unsigned long active_mask; /* bit 101 unsigned long unlink_mask; /* bit 102 atomic_t submitted_urbs; /* cur 103 char *syncbuf; /* syn 104 dma_addr_t sync_dma; /* DMA 105 106 unsigned int pipe; /* the 107 unsigned int packsize[2]; /* sma 108 unsigned int sample_rem; /* rem 109 unsigned int sample_accum; /* sam 110 unsigned int pps; /* pac 111 unsigned int freqn; /* nom 112 unsigned int freqm; /* mom 113 int freqshift; /* how 114 unsigned int freqmax; /* max 115 unsigned int phase; /* pha 116 unsigned int maxpacksize; /* max 117 unsigned int maxframesize; /* max 118 unsigned int max_urb_frames; /* max 119 unsigned int curpacksize; /* cur 120 unsigned int curframesize; /* cur 121 unsigned int syncmaxsize; /* syn 122 unsigned int fill_max:1; /* fil 123 unsigned int tenor_fb_quirk:1; /* cor 124 unsigned int datainterval; /* log 125 unsigned int syncinterval; /* P f 126 unsigned char silence_value; 127 unsigned int stride; 128 int skip_packets; /* qui 129 in 130 bool implicit_fb_sync; /* syn 131 bool lowlatency_playback; /* low 132 bool need_setup; /* (re 133 bool need_prepare; /* (re 134 bool fixed_rate; /* ski 135 136 /* for hw constraints */ 137 const struct audioformat *cur_audiofmt 138 unsigned int cur_rate; 139 snd_pcm_format_t cur_format; 140 unsigned int cur_channels; 141 unsigned int cur_frame_bytes; 142 unsigned int cur_period_frames; 143 unsigned int cur_period_bytes; 144 unsigned int cur_buffer_periods; 145 146 spinlock_t lock; 147 struct list_head list; 148 }; 149 150 struct media_ctl; 151 152 struct snd_usb_substream { 153 struct snd_usb_stream *stream; 154 struct usb_device *dev; 155 struct snd_pcm_substream *pcm_substrea 156 int direction; /* playback or capture 157 int endpoint; /* assigned endpoint * 158 const struct audioformat *cur_audiofmt 159 struct snd_usb_power_domain *str_pd; 160 unsigned int channels_max; /* max 161 unsigned int txfr_quirk:1; /* all 162 unsigned int tx_length_quirk:1; /* add 163 unsigned int fmt_type; /* USB 164 unsigned int pkt_offset_adj; /* Byt 165 unsigned int stream_offset_adj; /* Byt 166 167 unsigned int running: 1; /* run 168 unsigned int period_elapsed_pending; 169 170 unsigned int buffer_bytes; /* buf 171 unsigned int inflight_bytes; /* in- 172 unsigned int hwptr_done; /* pro 173 unsigned int transfer_done; /* pro 174 unsigned int frame_limit; /* lim 175 176 /* data and sync endpoints for this st 177 unsigned int ep_num; /* the 178 struct snd_usb_endpoint *data_endpoint 179 struct snd_usb_endpoint *sync_endpoint 180 unsigned long flags; 181 unsigned int speed; /* USB 182 183 u64 formats; /* for 184 unsigned int num_formats; 185 struct list_head fmt_list; /* for 186 spinlock_t lock; 187 188 unsigned int last_frame_number; /* sto 189 190 struct { 191 int marker; 192 int channel; 193 int byte_idx; 194 } dsd_dop; 195 196 bool trigger_tstamp_pending_update; /* 197 bool lowlatency_playback; /* low 198 struct media_ctl *media_ctl; 199 }; 200 201 struct snd_usb_stream { 202 struct snd_usb_audio *chip; 203 struct snd_pcm *pcm; 204 int pcm_index; 205 unsigned int fmt_type; /* USB 206 struct snd_usb_substream substream[2]; 207 struct list_head list; 208 }; 209 210 #endif /* __USBAUDIO_CARD_H */ 211
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.