Import SB128-v5.24 to main branch
[AROS.git] / workbench / devs / AHI / Drivers / SB128 / DriverData.h
blobcbb497e5149004a454757b67071d70c95de24371
1 /*
3 The contents of this file are subject to the AROS Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
4 http://www.aros.org/license.html
6 Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
7 ANY KIND, either express or implied. See the License for the specific language governing rights and
8 limitations under the License.
10 The Original Code is (C) Copyright 2004-2011 Ross Vumbaca.
12 The Initial Developer of the Original Code is Ross Vumbaca.
14 All Rights Reserved.
18 #ifndef AHI_Drivers_Card_DriverData_h
19 #define AHI_Drivers_Card_DriverData_h
21 #include <exec/types.h>
22 #include <exec/interrupts.h>
23 #include <devices/ahi.h>
25 #define DRIVER "sb128.audio"
26 #define DRIVER_NEED_GLOBAL_EXECBASE
27 #include "DriverBase.h"
29 struct CardData;
31 struct CardBase
33 /** Skeleton's variables *************************************************/
35 struct DriverBase driverbase;
38 /** A sempahore used for locking */
39 struct SignalSemaphore semaphore;
41 /** The number of cards found */
42 int cards_found;
44 /** A CardData structure for each card found */
45 struct CardData** driverdatas;
48 #define RECORD_BUFFER_SAMPLES 1024
51 struct CardData
53 /*** PCI/Card initialization progress *********************************/
55 struct PCIDevice *pci_dev;
56 unsigned long iobase;
57 unsigned long length;
58 unsigned short model;
59 unsigned char chiprev;
60 unsigned int irq;
62 /** TRUE if bus mastering is activated */
63 BOOL pci_master_enabled;
65 /** TRUE if the Card chip has been initialized */
66 BOOL card_initialized;
68 /** TRUE if the card is an ES1370 */
69 BOOL es1370;
71 /** A semaphore used for hardware access serialisation *******************/
72 struct SignalSemaphore sb128_semaphore;
75 /*** The driverbase ******************************************************/
77 /** This field is also used as a lock and access to it is
78 * semaphore protected. */
79 struct DriverBase* ahisubbase;
82 /*** The AudioCtrl currently using this DriverData structure *************/
84 struct AHIAudioCtrlDrv* audioctrl;
87 /*** Playback/recording interrupts ***************************************/
89 /** TRUE when playback is enabled */
90 BOOL is_playing;
92 /** TRUE when recording is enabled */
93 BOOL is_recording;
95 /** The main (hardware) interrupt */
96 struct Interrupt interrupt;
98 /** TRUE if the hardware interrupt has been added to the PCI subsystem */
99 BOOL interrupt_added;
101 /** The playback software interrupt */
102 struct Interrupt playback_interrupt;
104 /** TRUE if the hardware interrupt may Cause() playback_interrupt */
105 BOOL playback_interrupt_enabled;
107 /** The recording software interrupt */
108 struct Interrupt record_interrupt;
110 /** TRUE if the hardware interrupt may Cause() playback_interrupt */
111 BOOL record_interrupt_enabled;
115 /*** CAMD support functions **********************************************/
117 /** CAMD transmitter function wrapped as a Hook */
118 struct Hook* camd_transmitfunc;
120 /** CAMD receiver function wrapped as a Hook */
121 struct Hook* camd_receivefunc;
123 /** True if CMAD V40 mode */
124 ULONG camd_v40;
128 /*** Playback interrupt variables ****************************************/
130 APTR playback_buffer;
131 APTR playback_buffer_nonaligned;
132 APTR playback_buffer_phys;
134 /** The mixing buffer (a cyclic buffer filled by AHI) */
135 APTR mix_buffer;
137 /** The length of each playback buffer in sample frames */
138 ULONG current_frames;
140 /** The length of each playback buffer in sample bytes */
141 ULONG current_bytesize;
143 /** Where (inside the cyclic buffer) we're currently writing */
144 APTR current_buffer;
146 int flip;
150 /*** Recording interrupt variables ***************************************/
152 /** The recording buffer (simple double buffering is used */
153 APTR record_buffer;
154 APTR record_buffer_nonaligned;
155 APTR record_buffer_phys;
157 /** Were (inside the recording buffer) the current data is */
158 APTR current_record_buffer;
160 /** The length of each record buffer in sample bytes */
161 ULONG current_record_bytesize;
163 int recflip;
167 /** Analog mixer variables ***********************************************/
169 /** The currently selected input */
170 UWORD input;
172 /** The currently selected output */
173 UWORD output;
175 /** The current (recording) monitor volume */
176 Fixed monitor_volume;
178 /** The current (recording) input gain */
179 Fixed input_gain;
181 /** The current (playback) output volume */
182 Fixed output_volume;
184 /** The hardware register value corresponding to monitor_volume */
185 UWORD monitor_volume_bits;
187 /** The hardware register value corresponding to input_gain */
188 UWORD input_gain_bits;
190 /** The hardware register value corresponding to output_volume */
191 UWORD output_volume_bits;
193 /** Saved state for AC97 mike */
194 UWORD ac97_mic;
196 /** Saved state for AC97 cd */
197 UWORD ac97_cd;
199 /** Saved state for AC97 video */
200 UWORD ac97_video;
202 /** Saved state for AC97 aux */
203 UWORD ac97_aux;
205 /** Saved state for AC97 line in */
206 UWORD ac97_linein;
208 /** Saved state for AC97 phone */
209 UWORD ac97_phone;
211 /** Saved state of AK4531 Output Register 1 */
212 char ak4531_output_1;
214 /** Saved state of AK4531 Output Register 1 */
215 char ak4531_output_2;
217 /** The current Playback Frequency */
218 int currentPlayFreq;
220 /** The current Record Frequency */
221 int currentRecFreq;
224 #endif /* AHI_Drivers_Card_DriverData_h */