pcm.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Linux driver for TerraTec DMX 6Fire USB
  4. *
  5. * Author: Torsten Schenk <[email protected]>
  6. * Created: Jan 01, 2011
  7. * Copyright: (C) Torsten Schenk
  8. */
  9. #ifndef USB6FIRE_PCM_H
  10. #define USB6FIRE_PCM_H
  11. #include <sound/pcm.h>
  12. #include <linux/mutex.h>
  13. #include "common.h"
  14. enum /* settings for pcm */
  15. {
  16. /* maximum of EP_W_MAX_PACKET_SIZE[] (see firmware.c) */
  17. PCM_N_URBS = 16, PCM_N_PACKETS_PER_URB = 8, PCM_MAX_PACKET_SIZE = 604
  18. };
  19. struct pcm_urb {
  20. struct sfire_chip *chip;
  21. /* BEGIN DO NOT SEPARATE */
  22. struct urb instance;
  23. struct usb_iso_packet_descriptor packets[PCM_N_PACKETS_PER_URB];
  24. /* END DO NOT SEPARATE */
  25. u8 *buffer;
  26. struct pcm_urb *peer;
  27. };
  28. struct pcm_substream {
  29. spinlock_t lock;
  30. struct snd_pcm_substream *instance;
  31. bool active;
  32. snd_pcm_uframes_t dma_off; /* current position in alsa dma_area */
  33. snd_pcm_uframes_t period_off; /* current position in current period */
  34. };
  35. struct pcm_runtime {
  36. struct sfire_chip *chip;
  37. struct snd_pcm *instance;
  38. struct pcm_substream playback;
  39. struct pcm_substream capture;
  40. bool panic; /* if set driver won't do anymore pcm on device */
  41. struct pcm_urb in_urbs[PCM_N_URBS];
  42. struct pcm_urb out_urbs[PCM_N_URBS];
  43. int in_packet_size;
  44. int out_packet_size;
  45. int in_n_analog; /* number of analog channels soundcard sends */
  46. int out_n_analog; /* number of analog channels soundcard receives */
  47. struct mutex stream_mutex;
  48. u8 stream_state; /* one of STREAM_XXX (pcm.c) */
  49. u8 rate; /* one of PCM_RATE_XXX */
  50. wait_queue_head_t stream_wait_queue;
  51. bool stream_wait_cond;
  52. };
  53. int usb6fire_pcm_init(struct sfire_chip *chip);
  54. void usb6fire_pcm_abort(struct sfire_chip *chip);
  55. void usb6fire_pcm_destroy(struct sfire_chip *chip);
  56. #endif /* USB6FIRE_PCM_H */