| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> | 
| Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 27 | #include <linux/mutex.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <sound/pcm.h> | 
|  | 29 |  | 
|  | 30 | #define MIXART_DRIVER_VERSION	0x000100	/* 0.1.0 */ | 
|  | 31 |  | 
|  | 32 |  | 
|  | 33 | /* | 
|  | 34 | */ | 
|  | 35 |  | 
| Takashi Iwai | 67b48b8 | 2005-11-17 15:01:08 +0100 | [diff] [blame] | 36 | struct mixart_uid { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | u32 object_id; | 
|  | 38 | u32 desc; | 
|  | 39 | }; | 
|  | 40 |  | 
|  | 41 | struct mem_area { | 
|  | 42 | unsigned long phys; | 
|  | 43 | void __iomem *virt; | 
|  | 44 | struct resource *res; | 
|  | 45 | }; | 
|  | 46 |  | 
|  | 47 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | struct mixart_route { | 
|  | 49 | unsigned char connected; | 
|  | 50 | unsigned char phase_inv; | 
|  | 51 | int volume; | 
|  | 52 | }; | 
|  | 53 |  | 
|  | 54 |  | 
|  | 55 | /* firmware status codes  */ | 
|  | 56 | #define MIXART_MOTHERBOARD_XLX_INDEX  0 | 
|  | 57 | #define MIXART_MOTHERBOARD_ELF_INDEX  1 | 
|  | 58 | #define MIXART_AESEBUBOARD_XLX_INDEX  2 | 
|  | 59 | #define MIXART_HARDW_FILES_MAX_INDEX  3  /* xilinx, elf, AESEBU xilinx */ | 
|  | 60 |  | 
|  | 61 | #define MIXART_MAX_CARDS	4 | 
|  | 62 | #define MSG_FIFO_SIZE           16 | 
|  | 63 |  | 
|  | 64 | #define MIXART_MAX_PHYS_CONNECTORS  (MIXART_MAX_CARDS * 2 * 2) /* 4 * stereo * (analog+digital) */ | 
|  | 65 |  | 
| Takashi Iwai | 67b48b8 | 2005-11-17 15:01:08 +0100 | [diff] [blame] | 66 | struct mixart_mgr { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | unsigned int num_cards; | 
| Takashi Iwai | 67b48b8 | 2005-11-17 15:01:08 +0100 | [diff] [blame] | 68 | struct snd_mixart *chip[MIXART_MAX_CARDS]; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 |  | 
|  | 70 | struct pci_dev *pci; | 
|  | 71 |  | 
|  | 72 | int irq; | 
|  | 73 |  | 
|  | 74 | /* memory-maps */ | 
|  | 75 | struct mem_area mem[2]; | 
|  | 76 |  | 
|  | 77 | /* share the name */ | 
|  | 78 | char shortname[32];         /* short name of this soundcard */ | 
|  | 79 | char longname[80];          /* name of this soundcard */ | 
|  | 80 |  | 
|  | 81 | /* message tasklet */ | 
|  | 82 | struct tasklet_struct msg_taskq; | 
|  | 83 |  | 
|  | 84 | /* one and only blocking message or notification may be pending  */ | 
|  | 85 | u32 pending_event; | 
|  | 86 | wait_queue_head_t msg_sleep; | 
|  | 87 |  | 
|  | 88 | /* messages stored for tasklet */ | 
|  | 89 | u32 msg_fifo[MSG_FIFO_SIZE]; | 
|  | 90 | int msg_fifo_readptr; | 
|  | 91 | int msg_fifo_writeptr; | 
|  | 92 | atomic_t msg_processed;       /* number of messages to be processed in takslet */ | 
|  | 93 |  | 
|  | 94 | spinlock_t lock;              /* interrupt spinlock */ | 
|  | 95 | spinlock_t msg_lock;          /* mailbox spinlock */ | 
| Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 96 | struct mutex msg_mutex;   /* mutex for blocking_requests */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 |  | 
| Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 98 | struct mutex setup_mutex; /* mutex used in hw_params, open and close */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 |  | 
|  | 100 | /* hardware interface */ | 
|  | 101 | unsigned int dsp_loaded;      /* bit flags of loaded dsp indices */ | 
|  | 102 | unsigned int board_type;      /* read from embedded once elf file is loaded, 250 = miXart8, 251 = with AES, 252 = with Cobranet */ | 
|  | 103 |  | 
|  | 104 | struct snd_dma_buffer flowinfo; | 
|  | 105 | struct snd_dma_buffer bufferinfo; | 
|  | 106 |  | 
| Takashi Iwai | 67b48b8 | 2005-11-17 15:01:08 +0100 | [diff] [blame] | 107 | struct mixart_uid         uid_console_manager; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | int sample_rate; | 
|  | 109 | int ref_count_rate; | 
|  | 110 |  | 
| Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 111 | struct mutex mixer_mutex; /* mutex for mixer */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 |  | 
|  | 113 | }; | 
|  | 114 |  | 
|  | 115 |  | 
|  | 116 | #define MIXART_STREAM_STATUS_FREE	0 | 
|  | 117 | #define MIXART_STREAM_STATUS_OPEN	1 | 
|  | 118 | #define MIXART_STREAM_STATUS_RUNNING	2 | 
|  | 119 | #define MIXART_STREAM_STATUS_DRAINING	3 | 
|  | 120 | #define MIXART_STREAM_STATUS_PAUSE	4 | 
|  | 121 |  | 
|  | 122 | #define MIXART_PLAYBACK_STREAMS		4 | 
|  | 123 | #define MIXART_CAPTURE_STREAMS		1 | 
|  | 124 |  | 
|  | 125 | #define MIXART_PCM_ANALOG		0 | 
|  | 126 | #define MIXART_PCM_DIGITAL		1 | 
|  | 127 | #define MIXART_PCM_TOTAL		2 | 
|  | 128 |  | 
|  | 129 | #define MIXART_MAX_STREAM_PER_CARD  (MIXART_PCM_TOTAL * (MIXART_PLAYBACK_STREAMS + MIXART_CAPTURE_STREAMS) ) | 
|  | 130 |  | 
|  | 131 |  | 
|  | 132 | #define MIXART_NOTIFY_CARD_MASK		0xF000 | 
|  | 133 | #define MIXART_NOTIFY_CARD_OFFSET	12 | 
|  | 134 | #define MIXART_NOTIFY_PCM_MASK		0x0F00 | 
|  | 135 | #define MIXART_NOTIFY_PCM_OFFSET	8 | 
|  | 136 | #define MIXART_NOTIFY_CAPT_MASK		0x0080 | 
|  | 137 | #define MIXART_NOTIFY_SUBS_MASK		0x007F | 
|  | 138 |  | 
|  | 139 |  | 
| Takashi Iwai | 67b48b8 | 2005-11-17 15:01:08 +0100 | [diff] [blame] | 140 | struct mixart_stream { | 
|  | 141 | struct snd_pcm_substream *substream; | 
|  | 142 | struct mixart_pipe *pipe; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | int pcm_number; | 
|  | 144 |  | 
|  | 145 | int status;      /* nothing, running, draining */ | 
|  | 146 |  | 
|  | 147 | u64  abs_period_elapsed;  /* last absolute stream position where period_elapsed was called (multiple of runtime->period_size) */ | 
|  | 148 | u32  buf_periods;         /* periods counter in the buffer (< runtime->periods) */ | 
|  | 149 | u32  buf_period_frag;     /* defines with buf_period_pos the exact position in the buffer (< runtime->period_size) */ | 
|  | 150 |  | 
|  | 151 | int channels; | 
|  | 152 | }; | 
|  | 153 |  | 
|  | 154 |  | 
|  | 155 | enum mixart_pipe_status { | 
|  | 156 | PIPE_UNDEFINED, | 
|  | 157 | PIPE_STOPPED, | 
|  | 158 | PIPE_RUNNING, | 
|  | 159 | PIPE_CLOCK_SET | 
|  | 160 | }; | 
|  | 161 |  | 
| Takashi Iwai | 67b48b8 | 2005-11-17 15:01:08 +0100 | [diff] [blame] | 162 | struct mixart_pipe { | 
|  | 163 | struct mixart_uid group_uid;			/* id of the pipe, as returned by embedded */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | int          stream_count; | 
| Takashi Iwai | 67b48b8 | 2005-11-17 15:01:08 +0100 | [diff] [blame] | 165 | struct mixart_uid uid_left_connector;	/* UID's for the audio connectors */ | 
|  | 166 | struct mixart_uid uid_right_connector; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | enum mixart_pipe_status status; | 
|  | 168 | int references;             /* number of subs openned */ | 
|  | 169 | int monitoring;             /* pipe used for monitoring issue */ | 
|  | 170 | }; | 
|  | 171 |  | 
|  | 172 |  | 
|  | 173 | struct snd_mixart { | 
| Takashi Iwai | 67b48b8 | 2005-11-17 15:01:08 +0100 | [diff] [blame] | 174 | struct snd_card *card; | 
|  | 175 | struct mixart_mgr *mgr; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | int chip_idx;               /* zero based */ | 
| Takashi Iwai | 67b48b8 | 2005-11-17 15:01:08 +0100 | [diff] [blame] | 177 | struct snd_hwdep *hwdep;	    /* DSP loader, only for the first card */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 |  | 
| Takashi Iwai | 67b48b8 | 2005-11-17 15:01:08 +0100 | [diff] [blame] | 179 | struct snd_pcm *pcm;             /* PCM analog i/o */ | 
|  | 180 | struct snd_pcm *pcm_dig;         /* PCM digital i/o */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 |  | 
|  | 182 | /* allocate stereo pipe for instance */ | 
| Takashi Iwai | 67b48b8 | 2005-11-17 15:01:08 +0100 | [diff] [blame] | 183 | struct mixart_pipe pipe_in_ana; | 
|  | 184 | struct mixart_pipe pipe_out_ana; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 |  | 
|  | 186 | /* if AES/EBU daughter board is available, additional pipes possible on pcm_dig */ | 
| Takashi Iwai | 67b48b8 | 2005-11-17 15:01:08 +0100 | [diff] [blame] | 187 | struct mixart_pipe pipe_in_dig; | 
|  | 188 | struct mixart_pipe pipe_out_dig; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 |  | 
| Takashi Iwai | 67b48b8 | 2005-11-17 15:01:08 +0100 | [diff] [blame] | 190 | struct mixart_stream playback_stream[MIXART_PCM_TOTAL][MIXART_PLAYBACK_STREAMS]; /* 0 = pcm, 1 = pcm_dig */ | 
|  | 191 | struct mixart_stream capture_stream[MIXART_PCM_TOTAL];                           /* 0 = pcm, 1 = pcm_dig */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 |  | 
|  | 193 | /* UID's for the physical io's */ | 
| Takashi Iwai | 67b48b8 | 2005-11-17 15:01:08 +0100 | [diff] [blame] | 194 | struct mixart_uid uid_out_analog_physio; | 
|  | 195 | struct mixart_uid uid_in_analog_physio; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 |  | 
|  | 197 | int analog_playback_active[2];		/* Mixer : Master Playback active (!mute) */ | 
|  | 198 | int analog_playback_volume[2];		/* Mixer : Master Playback Volume */ | 
|  | 199 | int analog_capture_volume[2];		/* Mixer : Master Capture Volume */ | 
|  | 200 | int digital_playback_active[2*MIXART_PLAYBACK_STREAMS][2];	/* Mixer : Digital Playback Active [(analog+AES output)*streams][stereo]*/ | 
|  | 201 | int digital_playback_volume[2*MIXART_PLAYBACK_STREAMS][2];	/* Mixer : Digital Playback Volume [(analog+AES output)*streams][stereo]*/ | 
|  | 202 | int digital_capture_volume[2][2];	/* Mixer : Digital Capture Volume [analog+AES output][stereo] */ | 
|  | 203 | int monitoring_active[2];		/* Mixer : Monitoring Active */ | 
|  | 204 | int monitoring_volume[2];		/* Mixer : Monitoring Volume */ | 
|  | 205 | }; | 
|  | 206 |  | 
|  | 207 | struct mixart_bufferinfo | 
|  | 208 | { | 
|  | 209 | u32 buffer_address; | 
|  | 210 | u32 reserved[5]; | 
|  | 211 | u32 available_length; | 
|  | 212 | u32 buffer_id; | 
|  | 213 | }; | 
|  | 214 |  | 
|  | 215 | struct mixart_flowinfo | 
|  | 216 | { | 
|  | 217 | u32 bufferinfo_array_phy_address; | 
|  | 218 | u32 reserved[11]; | 
|  | 219 | u32 bufferinfo_count; | 
|  | 220 | u32 capture; | 
|  | 221 | }; | 
|  | 222 |  | 
|  | 223 | /* exported */ | 
| Takashi Iwai | 67b48b8 | 2005-11-17 15:01:08 +0100 | [diff] [blame] | 224 | int snd_mixart_create_pcm(struct snd_mixart * chip); | 
|  | 225 | struct mixart_pipe *snd_mixart_add_ref_pipe(struct snd_mixart *chip, int pcm_number, int capture, int monitoring); | 
|  | 226 | int snd_mixart_kill_ref_pipe(struct mixart_mgr *mgr, struct mixart_pipe *pipe, int monitoring); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 |  | 
|  | 228 | #endif /* __SOUND_MIXART_H */ |