2 * Driver for Digigram miXart soundcards
6 * Copyright (c) 2003 by Digigram <alsa@digigram.com>
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.
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.
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
23 #ifndef __SOUND_MIXART_H
24 #define __SOUND_MIXART_H
26 #include <linux/interrupt.h>
27 #include <sound/pcm.h>
29 #define MIXART_DRIVER_VERSION 0x000100 /* 0.1.0 */
35 #define mixart_t_magic 0xa17a3e01
36 #define mixart_mgr_t_magic 0xa17a3e02
38 typedef struct snd_mixart mixart_t;
39 typedef struct snd_mixart_mgr mixart_mgr_t;
41 typedef struct snd_mixart_stream mixart_stream_t;
42 typedef struct snd_mixart_pipe mixart_pipe_t;
44 typedef struct mixart_bufferinfo mixart_bufferinfo_t;
45 typedef struct mixart_flowinfo mixart_flowinfo_t;
46 typedef struct mixart_uid mixart_uid_t;
61 typedef struct mixart_route mixart_route_t;
63 unsigned char connected;
64 unsigned char phase_inv;
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 */
75 #define MIXART_MAX_CARDS 4
76 #define MSG_FIFO_SIZE 16
78 #define MIXART_MAX_PHYS_CONNECTORS (MIXART_MAX_CARDS * 2 * 2) /* 4 * stereo * (analog+digital) */
80 struct snd_mixart_mgr {
81 unsigned int num_cards;
82 mixart_t *chip[MIXART_MAX_CARDS];
89 struct mem_area mem[2];
92 char shortname[32]; /* short name of this soundcard */
93 char longname[80]; /* name of this soundcard */
96 struct tasklet_struct msg_taskq;
98 /* one and only blocking message or notification may be pending */
100 wait_queue_head_t msg_sleep;
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 */
108 spinlock_t lock; /* interrupt spinlock */
109 spinlock_t msg_lock; /* mailbox spinlock */
110 struct semaphore msg_mutex; /* mutex for blocking_requests */
112 struct semaphore setup_mutex; /* mutex used in hw_params, open and close */
114 /* hardware interface */
116 unsigned int board_type; /* read from embedded once elf file is loaded, 250 = miXart8, 251 = with AES, 252 = with Cobranet */
118 struct snd_dma_device dma_dev;
119 struct snd_dma_buffer flowinfo;
120 struct snd_dma_buffer bufferinfo;
122 mixart_uid_t uid_console_manager;
126 struct semaphore mixer_mutex; /* mutex for mixer */
131 #define MIXART_STREAM_STATUS_FREE 0
132 #define MIXART_STREAM_STATUS_OPEN 1
133 #define MIXART_STREAM_STATUS_RUNNING 2
134 #define MIXART_STREAM_STATUS_DRAINING 3
135 #define MIXART_STREAM_STATUS_PAUSE 4
137 #define MIXART_PLAYBACK_STREAMS 4
138 #define MIXART_CAPTURE_STREAMS 1
140 #define MIXART_PCM_ANALOG 0
141 #define MIXART_PCM_DIGITAL 1
142 #define MIXART_PCM_TOTAL 2
144 #define MIXART_MAX_STREAM_PER_CARD (MIXART_PCM_TOTAL * (MIXART_PLAYBACK_STREAMS + MIXART_CAPTURE_STREAMS) )
147 #define MIXART_NOTIFY_CARD_MASK 0xF000
148 #define MIXART_NOTIFY_CARD_OFFSET 12
149 #define MIXART_NOTIFY_PCM_MASK 0x0F00
150 #define MIXART_NOTIFY_PCM_OFFSET 8
151 #define MIXART_NOTIFY_CAPT_MASK 0x0080
152 #define MIXART_NOTIFY_SUBS_MASK 0x007F
155 struct snd_mixart_stream {
156 snd_pcm_substream_t *substream;
160 int status; /* nothing, running, draining */
162 u64 abs_period_elapsed; /* last absolute stream position where period_elapsed was called (multiple of runtime->period_size) */
163 u32 buf_periods; /* periods counter in the buffer (< runtime->periods) */
164 u32 buf_period_frag; /* defines with buf_period_pos the exact position in the buffer (< runtime->period_size) */
170 enum mixart_pipe_status {
177 struct snd_mixart_pipe {
178 mixart_uid_t group_uid; /* id of the pipe, as returned by embedded */
180 mixart_uid_t uid_left_connector; /* UID's for the audio connectors */
181 mixart_uid_t uid_right_connector;
182 enum mixart_pipe_status status;
183 int references; /* number of subs openned */
184 int monitoring; /* pipe used for monitoring issue */
191 int chip_idx; /* zero based */
192 snd_hwdep_t *hwdep; /* DSP loader, only for the first card */
194 snd_pcm_t *pcm; /* PCM analog i/o */
195 snd_pcm_t *pcm_dig; /* PCM digital i/o */
197 /* allocate stereo pipe for instance */
198 mixart_pipe_t pipe_in_ana;
199 mixart_pipe_t pipe_out_ana;
201 /* if AES/EBU daughter board is available, additional pipes possible on pcm_dig */
202 mixart_pipe_t pipe_in_dig;
203 mixart_pipe_t pipe_out_dig;
205 mixart_stream_t playback_stream[MIXART_PCM_TOTAL][MIXART_PLAYBACK_STREAMS]; /* 0 = pcm, 1 = pcm_dig */
206 mixart_stream_t capture_stream[MIXART_PCM_TOTAL]; /* 0 = pcm, 1 = pcm_dig */
208 /* UID's for the physical io's */
209 mixart_uid_t uid_out_analog_physio;
210 mixart_uid_t uid_in_analog_physio;
212 int analog_playback_active[2]; /* Mixer : Master Playback active (!mute) */
213 int analog_playback_volume[2]; /* Mixer : Master Playback Volume */
214 int analog_capture_volume[2]; /* Mixer : Master Capture Volume */
215 int digital_playback_active[2*MIXART_PLAYBACK_STREAMS][2]; /* Mixer : Digital Playback Active [(analog+AES output)*streams][stereo]*/
216 int digital_playback_volume[2*MIXART_PLAYBACK_STREAMS][2]; /* Mixer : Digital Playback Volume [(analog+AES output)*streams][stereo]*/
217 int digital_capture_volume[2][2]; /* Mixer : Digital Capture Volume [analog+AES output][stereo] */
218 int monitoring_active[2]; /* Mixer : Monitoring Active */
219 int monitoring_volume[2]; /* Mixer : Monitoring Volume */
222 struct mixart_bufferinfo
226 u32 available_length;
230 struct mixart_flowinfo
232 u32 bufferinfo_array_phy_address;
234 u32 bufferinfo_count;
239 int snd_mixart_create_pcm(mixart_t* chip);
240 mixart_pipe_t* snd_mixart_add_ref_pipe( mixart_t *chip, int pcm_number, int capture, int monitoring);
241 int snd_mixart_kill_ref_pipe( mixart_mgr_t *mgr, mixart_pipe_t *pipe, int monitoring);
243 #endif /* __SOUND_MIXART_H */