0001
0002 #ifndef __USBAUDIO_CARD_H
0003 #define __USBAUDIO_CARD_H
0004
0005 #define MAX_NR_RATES 1024
0006 #define MAX_PACKS 6
0007 #define MAX_PACKS_HS (MAX_PACKS * 8)
0008 #define MAX_URBS 12
0009 #define SYNC_URBS 4
0010 #define MAX_QUEUE 18
0011
0012 struct audioformat {
0013 struct list_head list;
0014 u64 formats;
0015 unsigned int channels;
0016 unsigned int fmt_type;
0017 unsigned int fmt_bits;
0018 unsigned int frame_size;
0019 unsigned char iface;
0020 unsigned char altsetting;
0021 unsigned char ep_idx;
0022 unsigned char altset_idx;
0023 unsigned char attributes;
0024 unsigned char endpoint;
0025 unsigned char ep_attr;
0026 bool implicit_fb;
0027 unsigned char sync_ep;
0028 unsigned char sync_iface;
0029 unsigned char sync_altsetting;
0030 unsigned char sync_ep_idx;
0031 unsigned char datainterval;
0032 unsigned char protocol;
0033 unsigned int maxpacksize;
0034 unsigned int rates;
0035 unsigned int rate_min, rate_max;
0036 unsigned int nr_rates;
0037 unsigned int *rate_table;
0038 unsigned char clock;
0039 struct snd_pcm_chmap_elem *chmap;
0040 bool dsd_dop;
0041 bool dsd_bitrev;
0042 bool dsd_raw;
0043 };
0044
0045 struct snd_usb_substream;
0046 struct snd_usb_iface_ref;
0047 struct snd_usb_clock_ref;
0048 struct snd_usb_endpoint;
0049 struct snd_usb_power_domain;
0050
0051 struct snd_urb_ctx {
0052 struct urb *urb;
0053 unsigned int buffer_size;
0054 struct snd_usb_substream *subs;
0055 struct snd_usb_endpoint *ep;
0056 int index;
0057 int packets;
0058 int queued;
0059 int packet_size[MAX_PACKS_HS];
0060 struct list_head ready_list;
0061 };
0062
0063 struct snd_usb_endpoint {
0064 struct snd_usb_audio *chip;
0065 struct snd_usb_iface_ref *iface_ref;
0066 struct snd_usb_clock_ref *clock_ref;
0067
0068 int opened;
0069 atomic_t running;
0070 int ep_num;
0071 int type;
0072
0073 unsigned char iface;
0074 unsigned char altsetting;
0075 unsigned char ep_idx;
0076
0077 atomic_t state;
0078
0079 int (*prepare_data_urb) (struct snd_usb_substream *subs,
0080 struct urb *urb,
0081 bool in_stream_lock);
0082 void (*retire_data_urb) (struct snd_usb_substream *subs,
0083 struct urb *urb);
0084
0085 struct snd_usb_substream *data_subs;
0086 struct snd_usb_endpoint *sync_source;
0087 struct snd_usb_endpoint *sync_sink;
0088
0089 struct snd_urb_ctx urb[MAX_URBS];
0090
0091 struct snd_usb_packet_info {
0092 uint32_t packet_size[MAX_PACKS_HS];
0093 int packets;
0094 } next_packet[MAX_URBS];
0095 unsigned int next_packet_head;
0096 unsigned int next_packet_queued;
0097 struct list_head ready_playback_urbs;
0098
0099 unsigned int nurbs;
0100 unsigned long active_mask;
0101 unsigned long unlink_mask;
0102 atomic_t submitted_urbs;
0103 char *syncbuf;
0104 dma_addr_t sync_dma;
0105
0106 unsigned int pipe;
0107 unsigned int packsize[2];
0108 unsigned int sample_rem;
0109 unsigned int sample_accum;
0110 unsigned int pps;
0111 unsigned int freqn;
0112 unsigned int freqm;
0113 int freqshift;
0114 unsigned int freqmax;
0115 unsigned int phase;
0116 unsigned int maxpacksize;
0117 unsigned int maxframesize;
0118 unsigned int max_urb_frames;
0119 unsigned int curpacksize;
0120 unsigned int curframesize;
0121 unsigned int syncmaxsize;
0122 unsigned int fill_max:1;
0123 unsigned int tenor_fb_quirk:1;
0124 unsigned int datainterval;
0125 unsigned int syncinterval;
0126 unsigned char silence_value;
0127 unsigned int stride;
0128 int skip_packets;
0129
0130 bool implicit_fb_sync;
0131 bool lowlatency_playback;
0132 bool need_setup;
0133
0134
0135 const struct audioformat *cur_audiofmt;
0136 unsigned int cur_rate;
0137 snd_pcm_format_t cur_format;
0138 unsigned int cur_channels;
0139 unsigned int cur_frame_bytes;
0140 unsigned int cur_period_frames;
0141 unsigned int cur_period_bytes;
0142 unsigned int cur_buffer_periods;
0143
0144 spinlock_t lock;
0145 struct list_head list;
0146 };
0147
0148 struct media_ctl;
0149
0150 struct snd_usb_substream {
0151 struct snd_usb_stream *stream;
0152 struct usb_device *dev;
0153 struct snd_pcm_substream *pcm_substream;
0154 int direction;
0155 int endpoint;
0156 const struct audioformat *cur_audiofmt;
0157 struct snd_usb_power_domain *str_pd;
0158 unsigned int channels_max;
0159 unsigned int txfr_quirk:1;
0160 unsigned int tx_length_quirk:1;
0161 unsigned int fmt_type;
0162 unsigned int pkt_offset_adj;
0163 unsigned int stream_offset_adj;
0164
0165 unsigned int running: 1;
0166 unsigned int period_elapsed_pending;
0167
0168 unsigned int buffer_bytes;
0169 unsigned int inflight_bytes;
0170 unsigned int hwptr_done;
0171 unsigned int transfer_done;
0172 unsigned int frame_limit;
0173
0174
0175 unsigned int ep_num;
0176 struct snd_usb_endpoint *data_endpoint;
0177 struct snd_usb_endpoint *sync_endpoint;
0178 unsigned long flags;
0179 unsigned int speed;
0180
0181 u64 formats;
0182 unsigned int num_formats;
0183 struct list_head fmt_list;
0184 spinlock_t lock;
0185
0186 unsigned int last_frame_number;
0187
0188 struct {
0189 int marker;
0190 int channel;
0191 int byte_idx;
0192 } dsd_dop;
0193
0194 bool trigger_tstamp_pending_update;
0195 bool lowlatency_playback;
0196 struct media_ctl *media_ctl;
0197 };
0198
0199 struct snd_usb_stream {
0200 struct snd_usb_audio *chip;
0201 struct snd_pcm *pcm;
0202 int pcm_index;
0203 unsigned int fmt_type;
0204 struct snd_usb_substream substream[2];
0205 struct list_head list;
0206 };
0207
0208 #endif