aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/mixart/mixart.h
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/mixart/mixart.h')
-rw-r--r--sound/pci/mixart/mixart.h242
1 files changed, 242 insertions, 0 deletions
diff --git a/sound/pci/mixart/mixart.h b/sound/pci/mixart/mixart.h
new file mode 100644
index 000000000000..f87152f94c0e
--- /dev/null
+++ b/sound/pci/mixart/mixart.h
@@ -0,0 +1,242 @@
1/*
2 * Driver for Digigram miXart soundcards
3 *
4 * main header file
5 *
6 * Copyright (c) 2003 by Digigram <alsa@digigram.com>
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 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#ifndef __SOUND_MIXART_H
24#define __SOUND_MIXART_H
25
26#include <linux/interrupt.h>
27#include <sound/pcm.h>
28
29#define MIXART_DRIVER_VERSION 0x000100 /* 0.1.0 */
30
31
32/*
33 */
34
35#define mixart_t_magic 0xa17a3e01
36#define mixart_mgr_t_magic 0xa17a3e02
37
38typedef struct snd_mixart mixart_t;
39typedef struct snd_mixart_mgr mixart_mgr_t;
40
41typedef struct snd_mixart_stream mixart_stream_t;
42typedef struct snd_mixart_pipe mixart_pipe_t;
43
44typedef struct mixart_bufferinfo mixart_bufferinfo_t;
45typedef struct mixart_flowinfo mixart_flowinfo_t;
46typedef struct mixart_uid mixart_uid_t;
47
48struct mixart_uid
49{
50 u32 object_id;
51 u32 desc;
52};
53
54struct mem_area {
55 unsigned long phys;
56 void __iomem *virt;
57 struct resource *res;
58};
59
60
61typedef struct mixart_route mixart_route_t;
62struct mixart_route {
63 unsigned char connected;
64 unsigned char phase_inv;
65 int volume;
66};
67
68
69/* firmware status codes */
70#define MIXART_MOTHERBOARD_XLX_INDEX 0
71#define MIXART_MOTHERBOARD_ELF_INDEX 1
72#define MIXART_AESEBUBOARD_XLX_INDEX 2
73#define MIXART_HARDW_FILES_MAX_INDEX 3 /* xilinx, elf, AESEBU xilinx */
74
75#define MIXART_MAX_CARDS 4
76#define MSG_FIFO_SIZE 16
77
78#define MIXART_MAX_PHYS_CONNECTORS (MIXART_MAX_CARDS * 2 * 2) /* 4 * stereo * (analog+digital) */
79
80struct snd_mixart_mgr {
81 unsigned int num_cards;
82 mixart_t *chip[MIXART_MAX_CARDS];
83
84 struct pci_dev *pci;
85
86 int irq;
87
88 /* memory-maps */
89 struct mem_area mem[2];
90
91 /* share the name */
92 char shortname[32]; /* short name of this soundcard */
93 char longname[80]; /* name of this soundcard */
94
95 /* message tasklet */
96 struct tasklet_struct msg_taskq;
97
98 /* one and only blocking message or notification may be pending */
99 u32 pending_event;
100 wait_queue_head_t msg_sleep;
101
102 /* messages stored for tasklet */
103 u32 msg_fifo[MSG_FIFO_SIZE];
104 int msg_fifo_readptr;
105 int msg_fifo_writeptr;
106 atomic_t msg_processed; /* number of messages to be processed in takslet */
107
108 spinlock_t lock; /* interrupt spinlock */
109 spinlock_t msg_lock; /* mailbox spinlock */
110 struct semaphore msg_mutex; /* mutex for blocking_requests */
111
112 struct semaphore setup_mutex; /* mutex used in hw_params, open and close */
113
114 /* hardware interface */
115 unsigned int dsp_loaded; /* bit flags of loaded dsp indices */
116 unsigned int board_type; /* read from embedded once elf file is loaded, 250 = miXart8, 251 = with AES, 252 = with Cobranet */
117
118 struct snd_dma_buffer flowinfo;
119 struct snd_dma_buffer bufferinfo;
120
121 mixart_uid_t uid_console_manager;
122 int sample_rate;
123 int ref_count_rate;
124
125 struct semaphore mixer_mutex; /* mutex for mixer */
126
127};
128
129
130#define MIXART_STREAM_STATUS_FREE 0
131#define MIXART_STREAM_STATUS_OPEN 1
132#define MIXART_STREAM_STATUS_RUNNING 2
133#define MIXART_STREAM_STATUS_DRAINING 3
134#define MIXART_STREAM_STATUS_PAUSE 4
135
136#define MIXART_PLAYBACK_STREAMS 4
137#define MIXART_CAPTURE_STREAMS 1
138
139#define MIXART_PCM_ANALOG 0
140#define MIXART_PCM_DIGITAL 1
141#define MIXART_PCM_TOTAL 2
142
143#define MIXART_MAX_STREAM_PER_CARD (MIXART_PCM_TOTAL * (MIXART_PLAYBACK_STREAMS + MIXART_CAPTURE_STREAMS) )
144
145
146#define MIXART_NOTIFY_CARD_MASK 0xF000
147#define MIXART_NOTIFY_CARD_OFFSET 12
148#define MIXART_NOTIFY_PCM_MASK 0x0F00
149#define MIXART_NOTIFY_PCM_OFFSET 8
150#define MIXART_NOTIFY_CAPT_MASK 0x0080
151#define MIXART_NOTIFY_SUBS_MASK 0x007F
152
153
154struct snd_mixart_stream {
155 snd_pcm_substream_t *substream;
156 mixart_pipe_t *pipe;
157 int pcm_number;
158
159 int status; /* nothing, running, draining */
160
161 u64 abs_period_elapsed; /* last absolute stream position where period_elapsed was called (multiple of runtime->period_size) */
162 u32 buf_periods; /* periods counter in the buffer (< runtime->periods) */
163 u32 buf_period_frag; /* defines with buf_period_pos the exact position in the buffer (< runtime->period_size) */
164
165 int channels;
166};
167
168
169enum mixart_pipe_status {
170 PIPE_UNDEFINED,
171 PIPE_STOPPED,
172 PIPE_RUNNING,
173 PIPE_CLOCK_SET
174};
175
176struct snd_mixart_pipe {
177 mixart_uid_t group_uid; /* id of the pipe, as returned by embedded */
178 int stream_count;
179 mixart_uid_t uid_left_connector; /* UID's for the audio connectors */
180 mixart_uid_t uid_right_connector;
181 enum mixart_pipe_status status;
182 int references; /* number of subs openned */
183 int monitoring; /* pipe used for monitoring issue */
184};
185
186
187struct snd_mixart {
188 snd_card_t *card;
189 mixart_mgr_t *mgr;
190 int chip_idx; /* zero based */
191 snd_hwdep_t *hwdep; /* DSP loader, only for the first card */
192
193 snd_pcm_t *pcm; /* PCM analog i/o */
194 snd_pcm_t *pcm_dig; /* PCM digital i/o */
195
196 /* allocate stereo pipe for instance */
197 mixart_pipe_t pipe_in_ana;
198 mixart_pipe_t pipe_out_ana;
199
200 /* if AES/EBU daughter board is available, additional pipes possible on pcm_dig */
201 mixart_pipe_t pipe_in_dig;
202 mixart_pipe_t pipe_out_dig;
203
204 mixart_stream_t playback_stream[MIXART_PCM_TOTAL][MIXART_PLAYBACK_STREAMS]; /* 0 = pcm, 1 = pcm_dig */
205 mixart_stream_t capture_stream[MIXART_PCM_TOTAL]; /* 0 = pcm, 1 = pcm_dig */
206
207 /* UID's for the physical io's */
208 mixart_uid_t uid_out_analog_physio;
209 mixart_uid_t uid_in_analog_physio;
210
211 int analog_playback_active[2]; /* Mixer : Master Playback active (!mute) */
212 int analog_playback_volume[2]; /* Mixer : Master Playback Volume */
213 int analog_capture_volume[2]; /* Mixer : Master Capture Volume */
214 int digital_playback_active[2*MIXART_PLAYBACK_STREAMS][2]; /* Mixer : Digital Playback Active [(analog+AES output)*streams][stereo]*/
215 int digital_playback_volume[2*MIXART_PLAYBACK_STREAMS][2]; /* Mixer : Digital Playback Volume [(analog+AES output)*streams][stereo]*/
216 int digital_capture_volume[2][2]; /* Mixer : Digital Capture Volume [analog+AES output][stereo] */
217 int monitoring_active[2]; /* Mixer : Monitoring Active */
218 int monitoring_volume[2]; /* Mixer : Monitoring Volume */
219};
220
221struct mixart_bufferinfo
222{
223 u32 buffer_address;
224 u32 reserved[5];
225 u32 available_length;
226 u32 buffer_id;
227};
228
229struct mixart_flowinfo
230{
231 u32 bufferinfo_array_phy_address;
232 u32 reserved[11];
233 u32 bufferinfo_count;
234 u32 capture;
235};
236
237/* exported */
238int snd_mixart_create_pcm(mixart_t* chip);
239mixart_pipe_t* snd_mixart_add_ref_pipe( mixart_t *chip, int pcm_number, int capture, int monitoring);
240int snd_mixart_kill_ref_pipe( mixart_mgr_t *mgr, mixart_pipe_t *pipe, int monitoring);
241
242#endif /* __SOUND_MIXART_H */