pcm.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Linux driver for TerraTec DMX 6Fire USB
  3. *
  4. * Author: Torsten Schenk <torsten.schenk@zoho.com>
  5. * Created: Jan 01, 2011
  6. * Version: 0.3.0
  7. * Copyright: (C) Torsten Schenk
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. */
  14. #ifndef USB6FIRE_PCM_H
  15. #define USB6FIRE_PCM_H
  16. #include <sound/pcm.h>
  17. #include <linux/mutex.h>
  18. #include "common.h"
  19. enum /* settings for pcm */
  20. {
  21. /* maximum of EP_W_MAX_PACKET_SIZE[] (see firmware.c) */
  22. PCM_N_URBS = 16, PCM_N_PACKETS_PER_URB = 8, PCM_MAX_PACKET_SIZE = 604
  23. };
  24. struct pcm_urb {
  25. struct sfire_chip *chip;
  26. /* BEGIN DO NOT SEPARATE */
  27. struct urb instance;
  28. struct usb_iso_packet_descriptor packets[PCM_N_PACKETS_PER_URB];
  29. /* END DO NOT SEPARATE */
  30. u8 buffer[PCM_N_PACKETS_PER_URB * PCM_MAX_PACKET_SIZE];
  31. struct pcm_urb *peer;
  32. };
  33. struct pcm_substream {
  34. spinlock_t lock;
  35. struct snd_pcm_substream *instance;
  36. bool active;
  37. snd_pcm_uframes_t dma_off; /* current position in alsa dma_area */
  38. snd_pcm_uframes_t period_off; /* current position in current period */
  39. };
  40. struct pcm_runtime {
  41. struct sfire_chip *chip;
  42. struct snd_pcm *instance;
  43. struct pcm_substream playback;
  44. struct pcm_substream capture;
  45. bool panic; /* if set driver won't do anymore pcm on device */
  46. struct pcm_urb in_urbs[PCM_N_URBS];
  47. struct pcm_urb out_urbs[PCM_N_URBS];
  48. int in_packet_size;
  49. int out_packet_size;
  50. int in_n_analog; /* number of analog channels soundcard sends */
  51. int out_n_analog; /* number of analog channels soundcard receives */
  52. struct mutex stream_mutex;
  53. u8 stream_state; /* one of STREAM_XXX (pcm.c) */
  54. u8 rate; /* one of PCM_RATE_XXX */
  55. wait_queue_head_t stream_wait_queue;
  56. bool stream_wait_cond;
  57. };
  58. int __devinit usb6fire_pcm_init(struct sfire_chip *chip);
  59. void usb6fire_pcm_abort(struct sfire_chip *chip);
  60. void usb6fire_pcm_destroy(struct sfire_chip *chip);
  61. #endif /* USB6FIRE_PCM_H */