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 */
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 */
118 struct snd_dma_buffer flowinfo
;
119 struct snd_dma_buffer bufferinfo
;
121 mixart_uid_t uid_console_manager
;
125 struct semaphore mixer_mutex
; /* mutex for mixer */
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
136 #define MIXART_PLAYBACK_STREAMS 4
137 #define MIXART_CAPTURE_STREAMS 1
139 #define MIXART_PCM_ANALOG 0
140 #define MIXART_PCM_DIGITAL 1
141 #define MIXART_PCM_TOTAL 2
143 #define MIXART_MAX_STREAM_PER_CARD (MIXART_PCM_TOTAL * (MIXART_PLAYBACK_STREAMS + MIXART_CAPTURE_STREAMS) )
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
154 struct snd_mixart_stream
{
155 snd_pcm_substream_t
*substream
;
159 int status
; /* nothing, running, draining */
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) */
169 enum mixart_pipe_status
{
176 struct snd_mixart_pipe
{
177 mixart_uid_t group_uid
; /* id of the pipe, as returned by embedded */
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 */
190 int chip_idx
; /* zero based */
191 snd_hwdep_t
*hwdep
; /* DSP loader, only for the first card */
193 snd_pcm_t
*pcm
; /* PCM analog i/o */
194 snd_pcm_t
*pcm_dig
; /* PCM digital i/o */
196 /* allocate stereo pipe for instance */
197 mixart_pipe_t pipe_in_ana
;
198 mixart_pipe_t pipe_out_ana
;
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
;
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 */
207 /* UID's for the physical io's */
208 mixart_uid_t uid_out_analog_physio
;
209 mixart_uid_t uid_in_analog_physio
;
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 */
221 struct mixart_bufferinfo
225 u32 available_length
;
229 struct mixart_flowinfo
231 u32 bufferinfo_array_phy_address
;
233 u32 bufferinfo_count
;
238 int snd_mixart_create_pcm(mixart_t
* chip
);
239 mixart_pipe_t
* snd_mixart_add_ref_pipe( mixart_t
*chip
, int pcm_number
, int capture
, int monitoring
);
240 int snd_mixart_kill_ref_pipe( mixart_mgr_t
*mgr
, mixart_pipe_t
*pipe
, int monitoring
);
242 #endif /* __SOUND_MIXART_H */