Merge remote-tracking branch 'tmem/linux-next'
[linux-2.6/next.git] / sound / usb / 6fire / pcm.h
blob2bee81374002f6e65eb532e797196dae6ac7712f
1 /*
2 * Linux driver for TerraTec DMX 6Fire USB
4 * Author: Torsten Schenk <torsten.schenk@zoho.com>
5 * Created: Jan 01, 2011
6 * Version: 0.3.0
7 * Copyright: (C) Torsten Schenk
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.
15 #ifndef USB6FIRE_PCM_H
16 #define USB6FIRE_PCM_H
18 #include <sound/pcm.h>
19 #include <linux/mutex.h>
21 #include "common.h"
23 enum /* settings for pcm */
25 /* maximum of EP_W_MAX_PACKET_SIZE[] (see firmware.c) */
26 PCM_N_URBS = 16, PCM_N_PACKETS_PER_URB = 8, PCM_MAX_PACKET_SIZE = 604
29 struct pcm_urb {
30 struct sfire_chip *chip;
32 /* BEGIN DO NOT SEPARATE */
33 struct urb instance;
34 struct usb_iso_packet_descriptor packets[PCM_N_PACKETS_PER_URB];
35 /* END DO NOT SEPARATE */
36 u8 buffer[PCM_N_PACKETS_PER_URB * PCM_MAX_PACKET_SIZE];
38 struct pcm_urb *peer;
41 struct pcm_substream {
42 spinlock_t lock;
43 struct snd_pcm_substream *instance;
45 bool active;
47 snd_pcm_uframes_t dma_off; /* current position in alsa dma_area */
48 snd_pcm_uframes_t period_off; /* current position in current period */
51 struct pcm_runtime {
52 struct sfire_chip *chip;
53 struct snd_pcm *instance;
55 struct pcm_substream playback;
56 struct pcm_substream capture;
57 bool panic; /* if set driver won't do anymore pcm on device */
59 struct pcm_urb in_urbs[PCM_N_URBS];
60 struct pcm_urb out_urbs[PCM_N_URBS];
61 int in_packet_size;
62 int out_packet_size;
63 int in_n_analog; /* number of analog channels soundcard sends */
64 int out_n_analog; /* number of analog channels soundcard receives */
66 struct mutex stream_mutex;
67 u8 stream_state; /* one of STREAM_XXX (pcm.c) */
68 u8 rate; /* one of PCM_RATE_XXX */
69 wait_queue_head_t stream_wait_queue;
70 bool stream_wait_cond;
73 int __devinit usb6fire_pcm_init(struct sfire_chip *chip);
74 void usb6fire_pcm_abort(struct sfire_chip *chip);
75 void usb6fire_pcm_destroy(struct sfire_chip *chip);
76 #endif /* USB6FIRE_PCM_H */