2 emu10kx.audio - AHI driver for SoundBlaster Live! series
3 Copyright (C) 2002-2005 Martin Blom <martin@blom.org>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef AHI_Drivers_EMU10kx_DriverData_h
21 #define AHI_Drivers_EMU10kx_DriverData_h
23 #include <exec/types.h>
24 #include <exec/interrupts.h>
25 #include <devices/ahi.h>
27 #include "emu10kx-ac97.h"
28 #include "emu10kx-camd.h"
32 /** Make the common library code initialize a global SysBase for us.
33 It's required for hwaccess.c */
35 #define DRIVER_NEEDS_GLOBAL_EXECBASE
36 #include "DriverBase.h"
42 /** Skeleton's variables *************************************************/
44 struct DriverBase driverbase
;
47 /** The driver's global data *********************************************/
50 /** A sempahore used for locking */
51 struct SignalSemaphore semaphore
;
53 /** The number of cards found */
56 /** A EMU10kxData structure for each card found */
57 struct EMU10kxData
** driverdatas
;
59 /** The public CAMD interface */
60 struct EMU10kxCamd camd
;
62 /** The public AC97 interface */
63 struct EMU10kxAC97 ac97
;
65 /** TRUE if the DMA buffers have to be flushed before played etc. */
69 #define DRIVERBASE_SIZEOF (sizeof (struct EMU10kxBase))
71 #define RECORD_BUFFER_SAMPLES 4096
72 #define RECORD_BUFFER_SIZE_VALUE ADCBS_BUFSIZE_16384
74 #define TIMER_INTERRUPT_FREQUENCY 1000
76 #define TIMER_INTERRUPT_FREQUENCY 80
82 /** Skeleton's variables *************************************************/
84 struct DriverData driverdata
;
86 /*** PCI/EMU10kx initialization progress *********************************/
88 /** TRUE if bus mastering is activated */
89 BOOL pci_master_enabled
;
91 /** TRUE if the EMU10kx chip has been initialized */
92 BOOL emu10k1_initialized
;
94 /*** The driverbase ******************************************************/
96 /** This field is also used as a lock and access to is is
97 * semaphore protected. */
98 struct DriverBase
* ahisubbase
;
100 /*** The AudioCtrl currently using this DriverData structure *************/
102 struct AHIAudioCtrlDrv
* audioctrl
;
104 /*** Playback/recording interrupts ***************************************/
106 /** TRUE when playback is enabled */
109 /** TRUE when recording is enabled */
112 /** The main (hardware) interrupt */
113 struct Interrupt interrupt
;
115 /** TRUE if the hardware interrupt has been added to the PCI subsystem */
116 BOOL interrupt_added
;
118 /** The playback software interrupt */
119 struct Interrupt playback_interrupt
;
121 /** TRUE if the hardware interrupt may Cause() playback_interrupt */
122 BOOL playback_interrupt_enabled
;
124 /** The recording software interrupt */
125 struct Interrupt record_interrupt
;
127 /** TRUE if the hardware interrupt may Cause() playback_interrupt */
128 BOOL record_interrupt_enabled
;
130 /*** CAMD support functions **********************************************/
132 /** CAMD transmitter function wrapped as a Hook */
133 struct Hook
* camd_transmitfunc
;
135 /** CAMD receiver function wrapped as a Hook */
136 struct Hook
* camd_receivefunc
;
138 /** True if CMAD V40 mode */
141 /*** EMU10kx structures **************************************************/
143 struct emu10k1_card card
;
144 struct emu_voice voices
[4];
146 UWORD voice_buffers_allocated
;
147 UWORD voices_allocated
;
148 UWORD voices_started
;
152 /*** Playback interrupt variables ****************************************/
154 /** The mixing buffer (a cyclic buffer filled by AHI) */
157 /** The length of each playback buffer in sample frames */
158 ULONG current_length
;
160 /** The length of each playback buffer in sample bytes */
163 /** Where (inside the cyclic buffer) we're currently writing */
164 APTR current_buffers
[4];
166 /** The offset (inside the cyclic buffer) we're currently writing */
167 ULONG current_position
;
170 /*** Recording interrupt variables ***************************************/
172 /** The recording buffer (simple double buffering is used */
175 /** The DMA handle for the record buffer */
176 dma_addr_t record_dma_handle
;
178 /** Were (inside the recording buffer) the current data is */
179 APTR current_record_buffer
;
181 /** Analog mixer variables ***********************************************/
183 /** The currently selected input */
186 /** The currently selected output */
189 /** The current (recording) monitor volume */
190 Fixed monitor_volume
;
192 /** The current (recording) input gain */
195 /** The current (playback) output volume */
198 /** The hardware register value corresponding to monitor_volume */
199 UWORD monitor_volume_bits
;
201 /** The hardware register value corresponding to input_gain */
202 UWORD input_gain_bits
;
204 /** The hardware register value corresponding to output_volume */
205 UWORD output_volume_bits
;
207 /** Saved state for AC97 mike */
210 /** Saved state for AC97 cd */
213 /** Saved state for AC97 vide */
216 /** Saved state for AC97 aux */
219 /** Saved state for AC97 line in */
222 /** Saved state for AC97 phone */
226 #endif /* AHI_Drivers_EMU10kx_DriverData_h */