1
2 #ifndef __USBAUDIO_CARD_H
3 #define __USBAUDIO_CARD_H
4
5 #define MAX_NR_RATES 1024
6 #define MAX_PACKS 6
7 #define MAX_PACKS_HS (MAX_PACKS * 8)
8 #define MAX_URBS 12
9 #define SYNC_URBS 4
10 #define MAX_QUEUE 18
11
12 struct audioformat {
13 struct list_head list;
14 u64 formats;
15 unsigned int channels;
16 unsigned int fmt_type;
17 unsigned int fmt_bits;
18 unsigned int frame_size;
19 int iface;
20 unsigned char altsetting;
21 unsigned char altset_idx;
22 unsigned char attributes;
23 unsigned char endpoint;
24 unsigned char ep_attr;
25 unsigned char datainterval;
26 unsigned char protocol;
27 unsigned int maxpacksize;
28 unsigned int rates;
29 unsigned int rate_min, rate_max;
30 unsigned int nr_rates;
31 unsigned int *rate_table;
32 unsigned char clock;
33 struct snd_pcm_chmap_elem *chmap;
34 bool dsd_dop;
35 bool dsd_bitrev;
36 bool dsd_raw;
37 };
38
39 struct snd_usb_substream;
40 struct snd_usb_endpoint;
41 struct snd_usb_power_domain;
42
43 struct snd_urb_ctx {
44 struct urb *urb;
45 unsigned int buffer_size;
46 struct snd_usb_substream *subs;
47 struct snd_usb_endpoint *ep;
48 int index;
49 int packets;
50 int packet_size[MAX_PACKS_HS];
51 struct list_head ready_list;
52 };
53
54 struct snd_usb_endpoint {
55 struct snd_usb_audio *chip;
56
57 int use_count;
58 int ep_num;
59 int type;
60 unsigned long flags;
61
62 void (*prepare_data_urb) (struct snd_usb_substream *subs,
63 struct urb *urb);
64 void (*retire_data_urb) (struct snd_usb_substream *subs,
65 struct urb *urb);
66
67 struct snd_usb_substream *data_subs;
68 struct snd_usb_endpoint *sync_master;
69 struct snd_usb_endpoint *sync_slave;
70
71 struct snd_urb_ctx urb[MAX_URBS];
72
73 struct snd_usb_packet_info {
74 uint32_t packet_size[MAX_PACKS_HS];
75 int packets;
76 } next_packet[MAX_URBS];
77 int next_packet_read_pos, next_packet_write_pos;
78 struct list_head ready_playback_urbs;
79
80 unsigned int nurbs;
81 unsigned long active_mask;
82 unsigned long unlink_mask;
83 char *syncbuf;
84 dma_addr_t sync_dma;
85
86 unsigned int pipe;
87 unsigned int freqn;
88 unsigned int freqm;
89 int freqshift;
90 unsigned int freqmax;
91 unsigned int phase;
92 unsigned int maxpacksize;
93 unsigned int maxframesize;
94 unsigned int max_urb_frames;
95 unsigned int curpacksize;
96 unsigned int curframesize;
97 unsigned int syncmaxsize;
98 unsigned int fill_max:1;
99 unsigned int tenor_fb_quirk:1;
100 unsigned int datainterval;
101 unsigned int syncinterval;
102 unsigned char silence_value;
103 unsigned int stride;
104 int iface, altsetting;
105 int skip_packets;
106
107
108 spinlock_t lock;
109 struct list_head list;
110 };
111
112 struct media_ctl;
113
114 struct snd_usb_substream {
115 struct snd_usb_stream *stream;
116 struct usb_device *dev;
117 struct snd_pcm_substream *pcm_substream;
118 int direction;
119 int interface;
120 int endpoint;
121 struct audioformat *cur_audiofmt;
122 struct snd_usb_power_domain *str_pd;
123 snd_pcm_format_t pcm_format;
124 unsigned int channels;
125 unsigned int channels_max;
126 unsigned int cur_rate;
127 unsigned int period_bytes;
128 unsigned int period_frames;
129 unsigned int buffer_periods;
130 unsigned int altset_idx;
131 unsigned int txfr_quirk:1;
132 unsigned int tx_length_quirk:1;
133 unsigned int fmt_type;
134 unsigned int pkt_offset_adj;
135
136 unsigned int running: 1;
137
138 unsigned int hwptr_done;
139 unsigned int transfer_done;
140 unsigned int frame_limit;
141
142
143 unsigned int ep_num;
144 struct snd_usb_endpoint *data_endpoint;
145 struct snd_usb_endpoint *sync_endpoint;
146 unsigned long flags;
147 bool need_setup_ep;
148 bool need_setup_fmt;
149 unsigned int speed;
150
151 u64 formats;
152 unsigned int num_formats;
153 struct list_head fmt_list;
154 struct snd_pcm_hw_constraint_list rate_list;
155 spinlock_t lock;
156
157 int last_frame_number;
158 int last_delay;
159
160 struct {
161 int marker;
162 int channel;
163 int byte_idx;
164 } dsd_dop;
165
166 bool trigger_tstamp_pending_update;
167 struct media_ctl *media_ctl;
168 };
169
170 struct snd_usb_stream {
171 struct snd_usb_audio *chip;
172 struct snd_pcm *pcm;
173 int pcm_index;
174 unsigned int fmt_type;
175 struct snd_usb_substream substream[2];
176 struct list_head list;
177 };
178
179 #endif