#ifndef __USBAUDIO_CARD_H1#define __USBAUDIO_CARD_H23#define MAX_PACKS 204#define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */5#define MAX_URBS 86#define SYNC_URBS 4 /* always four urbs for sync */7#define MAX_QUEUE 24 /* try not to exceed this queue length, in ms */89struct audioformat {10struct list_head list;11u64 formats; /* ALSA format bits */12unsigned int channels; /* # channels */13unsigned int fmt_type; /* USB audio format type (1-3) */14unsigned int frame_size; /* samples per frame for non-audio */15int iface; /* interface number */16unsigned char altsetting; /* corresponding alternate setting */17unsigned char altset_idx; /* array index of altenate setting */18unsigned char attributes; /* corresponding attributes of cs endpoint */19unsigned char endpoint; /* endpoint */20unsigned char ep_attr; /* endpoint attributes */21unsigned char datainterval; /* log_2 of data packet interval */22unsigned int maxpacksize; /* max. packet size */23unsigned int rates; /* rate bitmasks */24unsigned int rate_min, rate_max; /* min/max rates */25unsigned int nr_rates; /* number of rate table entries */26unsigned int *rate_table; /* rate table */27unsigned char clock; /* associated clock */28};2930struct snd_usb_substream;3132struct snd_urb_ctx {33struct urb *urb;34unsigned int buffer_size; /* size of data buffer, if data URB */35struct snd_usb_substream *subs;36int index; /* index for urb array */37int packets; /* number of packets per urb */38};3940struct snd_urb_ops {41int (*prepare)(struct snd_usb_substream *subs, struct snd_pcm_runtime *runtime, struct urb *u);42int (*retire)(struct snd_usb_substream *subs, struct snd_pcm_runtime *runtime, struct urb *u);43int (*prepare_sync)(struct snd_usb_substream *subs, struct snd_pcm_runtime *runtime, struct urb *u);44int (*retire_sync)(struct snd_usb_substream *subs, struct snd_pcm_runtime *runtime, struct urb *u);45};4647struct snd_usb_substream {48struct snd_usb_stream *stream;49struct usb_device *dev;50struct snd_pcm_substream *pcm_substream;51int direction; /* playback or capture */52int interface; /* current interface */53int endpoint; /* assigned endpoint */54struct audioformat *cur_audiofmt; /* current audioformat pointer (for hw_params callback) */55unsigned int cur_rate; /* current rate (for hw_params callback) */56unsigned int period_bytes; /* current period bytes (for hw_params callback) */57unsigned int altset_idx; /* USB data format: index of alternate setting */58unsigned int datapipe; /* the data i/o pipe */59unsigned int syncpipe; /* 1 - async out or adaptive in */60unsigned int datainterval; /* log_2 of data packet interval */61unsigned int syncinterval; /* P for adaptive mode, 0 otherwise */62unsigned int freqn; /* nominal sampling rate in fs/fps in Q16.16 format */63unsigned int freqm; /* momentary sampling rate in fs/fps in Q16.16 format */64int freqshift; /* how much to shift the feedback value to get Q16.16 */65unsigned int freqmax; /* maximum sampling rate, used for buffer management */66unsigned int phase; /* phase accumulator */67unsigned int maxpacksize; /* max packet size in bytes */68unsigned int maxframesize; /* max packet size in frames */69unsigned int curpacksize; /* current packet size in bytes (for capture) */70unsigned int curframesize; /* current packet size in frames (for capture) */71unsigned int syncmaxsize; /* sync endpoint packet size */72unsigned int fill_max: 1; /* fill max packet size always */73unsigned int txfr_quirk:1; /* allow sub-frame alignment */74unsigned int fmt_type; /* USB audio format type (1-3) */7576unsigned int running: 1; /* running status */7778unsigned int hwptr_done; /* processed byte position in the buffer */79unsigned int transfer_done; /* processed frames since last period update */80unsigned long active_mask; /* bitmask of active urbs */81unsigned long unlink_mask; /* bitmask of unlinked urbs */8283unsigned int nurbs; /* # urbs */84struct snd_urb_ctx dataurb[MAX_URBS]; /* data urb table */85struct snd_urb_ctx syncurb[SYNC_URBS]; /* sync urb table */86char *syncbuf; /* sync buffer for all sync URBs */87dma_addr_t sync_dma; /* DMA address of syncbuf */8889u64 formats; /* format bitmasks (all or'ed) */90unsigned int num_formats; /* number of supported audio formats (list) */91struct list_head fmt_list; /* format list */92struct snd_pcm_hw_constraint_list rate_list; /* limited rates */93spinlock_t lock;9495struct snd_urb_ops ops; /* callbacks (must be filled at init) */96};9798struct snd_usb_stream {99struct snd_usb_audio *chip;100struct snd_pcm *pcm;101int pcm_index;102unsigned int fmt_type; /* USB audio format type (1-3) */103struct snd_usb_substream substream[2];104struct list_head list;105};106107#endif /* __USBAUDIO_CARD_H */108109110