Build for AROS..
[AROS.git] / workbench / devs / AHI / Drivers / CMI8738 / DriverData.h
blob6861445845af7835137c6df3b9c8f6f85a701d19
1 /*
2 The contents of this file are subject to the AROS Public License Version 1.1 (the "License");
3 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
5 Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
6 ANY KIND, either express or implied. See the License for the specific language governing rights and
7 limitations under the License.
9 The Original Code is written by Davy Wentzler.
12 #ifndef AHI_Drivers_Card_DriverData_h
13 #define AHI_Drivers_Card_DriverData_h
15 #include <exec/types.h>
16 #include <exec/interrupts.h>
17 #include <devices/ahi.h>
19 #define DRIVER "cmi8738.audio"
20 #define DRIVER_NEEDS_GLOBAL_EXECBASE
22 #ifdef __AROS__
23 #define DRIVER_NEED_GLOBAL_EXECBASE
24 #endif
26 #ifdef __amigaos4__
27 #define DRIVER_NEED_GLOBAL_EXECBASE
28 #endif
30 #include "DriverBase.h"
32 struct CMI8738_DATA;
34 struct tester
36 unsigned long diff;
37 int flip;
38 int oldflip;
39 int A;
40 int Missed;
43 struct CMI8738Base
45 /** Skeleton's variables *************************************************/
47 struct DriverBase driverbase;
50 /** A sempahore used for locking */
51 struct SignalSemaphore semaphore;
53 /** The number of cards found */
54 int cards_found;
56 /** A CMI8738_DATA structure for each card found */
57 struct CMI8738_DATA** driverdatas;
60 #define DRIVERBASE_SIZEOF (sizeof (struct CMI8738Base))
62 #define RECORD_BUFFER_SAMPLES 1024
65 struct CMI8738_DATA
67 /*** PCI/Card initialization progress *********************************/
69 struct PCIDevice *pci_dev;
70 APTR iobase;
71 unsigned long length;
72 unsigned short model;
73 unsigned char chiprev;
74 unsigned int irq;
76 /** TRUE if bus mastering is activated */
77 BOOL pci_master_enabled;
79 /** TRUE if the Card chip has been initialized */
80 BOOL card_initialized;
84 /*** The driverbase ******************************************************/
86 /** This field is also used as a lock and access to is is
87 * semaphore protected. */
88 struct DriverBase* ahisubbase;
91 /*** The AudioCtrl currently using this DriverData structure *************/
93 struct AHIAudioCtrlDrv* audioctrl;
97 /*** Playback/recording interrupts ***************************************/
99 /** TRUE when playback is enabled */
100 BOOL is_playing;
102 /** TRUE when recording is enabled */
103 BOOL is_recording;
105 /** The main (hardware) interrupt */
106 struct Interrupt interrupt;
108 /** TRUE if the hardware interrupt has been added to the PCI subsystem */
109 BOOL interrupt_added;
111 /** The playback software interrupt */
112 struct Interrupt playback_interrupt;
114 /** TRUE if the hardware interrupt may Cause() playback_interrupt */
115 BOOL playback_interrupt_enabled;
117 /** The recording software interrupt */
118 struct Interrupt record_interrupt;
120 /** TRUE if the hardware interrupt may Cause() playback_interrupt */
121 BOOL record_interrupt_enabled;
125 /*** CAMD support functions **********************************************/
127 /** CAMD transmitter function wrapped as a Hook */
128 struct Hook* camd_transmitfunc;
130 /** CAMD receiver function wrapped as a Hook */
131 struct Hook* camd_receivefunc;
133 /** True if CMAD V40 mode */
134 ULONG camd_v40;
138 /*** Playback interrupt variables ****************************************/
140 APTR playback_buffer;
141 APTR playback_buffer_nonaligned;
142 APTR playback_buffer_phys;
144 /** The mixing buffer (a cyclic buffer filled by AHI) */
145 APTR mix_buffer;
147 /** The length of each playback buffer in sample frames */
148 ULONG current_frames;
150 /** The length of each playback buffer in sample bytes */
151 ULONG current_bytesize;
153 /** Where (inside the cyclic buffer) we're currently writing */
154 APTR current_buffer;
156 int flip;
157 int oldflip;
161 /*** Recording interrupt variables ***************************************/
163 /** The recording buffer (simple double buffering is used */
164 APTR record_buffer;
165 APTR record_buffer_nonaligned;
166 APTR record_buffer_phys;
168 /** Were (inside the recording buffer) the current data is */
169 APTR current_record_buffer;
171 /** The length of each record buffer in sample bytes */
172 ULONG current_record_bytesize;
174 int recflip;
178 /** Analog mixer variables ***********************************************/
180 unsigned char mixerstate;
183 /** The currently selected input */
184 UWORD input;
186 /** The currently selected output */
187 UWORD output;
189 /** The current (recording) monitor volume */
190 Fixed monitor_volume;
192 /** The current (recording) input gain */
193 Fixed input_gain;
195 /** The current (playback) output volume */
196 Fixed 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 */
208 UWORD ac97_mic;
210 /** Saved state for AC97 cd */
211 UWORD ac97_cd;
213 /** Saved state for AC97 vide */
214 UWORD ac97_video;
216 /** Saved state for AC97 aux */
217 UWORD ac97_aux;
219 /** Saved state for AC97 line in */
220 UWORD ac97_linein;
222 /** Saved state for AC97 phone */
223 UWORD ac97_phone;
226 #endif /* AHI_Drivers_Card_DriverData_h */