1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* 3 * Linux driver for TerraTec DMX 6Fire USB 4 * 5 * Author: Torsten Schenk <torsten.schenk@zoho.com> 6 * Created: Jan 01, 2011 7 * Copyright: (C) Torsten Schenk 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 /* 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 24 struct pcm_urb { 25 struct sfire_chip *chip; 26 27 struct urb *instance; 28 u8 *buffer; 29 30 struct pcm_urb *peer; 31 }; 32 33 struct pcm_substream { 34 spinlock_t lock; 35 struct snd_pcm_substream *instance; 36 37 bool active; 38 39 snd_pcm_uframes_t dma_off; /* current position in alsa dma_area */ 40 snd_pcm_uframes_t period_off; /* current position in current period */ 41 }; 42 43 struct pcm_runtime { 44 struct sfire_chip *chip; 45 struct snd_pcm *instance; 46 47 struct pcm_substream playback; 48 struct pcm_substream capture; 49 bool panic; /* if set driver won't do anymore pcm on device */ 50 51 struct pcm_urb in_urbs[PCM_N_URBS]; 52 struct pcm_urb out_urbs[PCM_N_URBS]; 53 int in_packet_size; 54 int out_packet_size; 55 int in_n_analog; /* number of analog channels soundcard sends */ 56 int out_n_analog; /* number of analog channels soundcard receives */ 57 58 struct mutex stream_mutex; 59 u8 stream_state; /* one of STREAM_XXX (pcm.c) */ 60 u8 rate; /* one of PCM_RATE_XXX */ 61 wait_queue_head_t stream_wait_queue; 62 bool stream_wait_cond; 63 }; 64 65 int usb6fire_pcm_init(struct sfire_chip *chip); 66 void usb6fire_pcm_abort(struct sfire_chip *chip); 67 void usb6fire_pcm_destroy(struct sfire_chip *chip); 68 #endif /* USB6FIRE_PCM_H */ 69