pcm.h 1.9 KB

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