1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 #ifndef USB6FIRE_PCM_H
  11 #define USB6FIRE_PCM_H
  12 
  13 #include <sound/pcm.h>
  14 #include <linux/mutex.h>
  15 
  16 #include "common.h"
  17 
  18 enum 
  19 {
  20         
  21         PCM_N_URBS = 16, PCM_N_PACKETS_PER_URB = 8, PCM_MAX_PACKET_SIZE = 604
  22 };
  23 
  24 struct pcm_urb {
  25         struct sfire_chip *chip;
  26 
  27         
  28         struct urb instance;
  29         struct usb_iso_packet_descriptor packets[PCM_N_PACKETS_PER_URB];
  30         
  31         u8 *buffer;
  32 
  33         struct pcm_urb *peer;
  34 };
  35 
  36 struct pcm_substream {
  37         spinlock_t lock;
  38         struct snd_pcm_substream *instance;
  39 
  40         bool active;
  41 
  42         snd_pcm_uframes_t dma_off; 
  43         snd_pcm_uframes_t period_off; 
  44 };
  45 
  46 struct pcm_runtime {
  47         struct sfire_chip *chip;
  48         struct snd_pcm *instance;
  49 
  50         struct pcm_substream playback;
  51         struct pcm_substream capture;
  52         bool panic; 
  53 
  54         struct pcm_urb in_urbs[PCM_N_URBS];
  55         struct pcm_urb out_urbs[PCM_N_URBS];
  56         int in_packet_size;
  57         int out_packet_size;
  58         int in_n_analog; 
  59         int out_n_analog; 
  60 
  61         struct mutex stream_mutex;
  62         u8 stream_state; 
  63         u8 rate; 
  64         wait_queue_head_t stream_wait_queue;
  65         bool stream_wait_cond;
  66 };
  67 
  68 int usb6fire_pcm_init(struct sfire_chip *chip);
  69 void usb6fire_pcm_abort(struct sfire_chip *chip);
  70 void usb6fire_pcm_destroy(struct sfire_chip *chip);
  71 #endif