change init code to support multiple cards. small fixes and corrections to code.
[AROS.git] / workbench / devs / AHI / Drivers / CMI8738 / DriverData.h
blob351a65be61851a0c3b303d8a0a28325617a6a94e
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_CMI8738_DriverData_h
13 #define AHI_Drivers_CMI8738_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 char chipvers;
75 unsigned int channels;
76 unsigned int irq;
78 /** TRUE if bus mastering is activated */
79 BOOL pci_master_enabled;
81 /** TRUE if the Card chip has been initialized */
82 BOOL card_initialized;
86 /*** The driverbase ******************************************************/
88 /** This field is also used as a lock and access to is is
89 * semaphore protected. */
90 struct DriverBase* ahisubbase;
93 /*** The AudioCtrl currently using this DriverData structure *************/
95 struct AHIAudioCtrlDrv* audioctrl;
99 /*** Playback/recording interrupts ***************************************/
101 /** TRUE when playback is enabled */
102 BOOL is_playing;
104 /** TRUE when recording is enabled */
105 BOOL is_recording;
107 /** The main (hardware) interrupt */
108 struct Interrupt interrupt;
110 /** TRUE if the hardware interrupt has been added to the PCI subsystem */
111 BOOL interrupt_added;
113 /** The playback software interrupt */
114 struct Interrupt playback_interrupt;
116 /** TRUE if the hardware interrupt may Cause() playback_interrupt */
117 BOOL playback_interrupt_enabled;
119 /** The recording software interrupt */
120 struct Interrupt record_interrupt;
122 /** TRUE if the hardware interrupt may Cause() playback_interrupt */
123 BOOL record_interrupt_enabled;
127 /*** CAMD support functions **********************************************/
129 /** CAMD transmitter function wrapped as a Hook */
130 struct Hook* camd_transmitfunc;
132 /** CAMD receiver function wrapped as a Hook */
133 struct Hook* camd_receivefunc;
135 /** True if CMAD V40 mode */
136 ULONG camd_v40;
140 /*** Playback interrupt variables ****************************************/
142 APTR playback_buffer;
143 APTR playback_buffer_nonaligned;
144 APTR playback_buffer_phys;
146 /** The mixing buffer (a cyclic buffer filled by AHI) */
147 APTR mix_buffer;
149 /** The length of each playback buffer in sample frames */
150 ULONG current_frames;
152 /** The length of each playback buffer in sample bytes */
153 ULONG current_bytesize;
155 /** Where (inside the cyclic buffer) we're currently writing */
156 APTR current_buffer;
158 int flip;
159 int oldflip;
163 /*** Recording interrupt variables ***************************************/
165 /** The recording buffer (simple double buffering is used */
166 APTR record_buffer;
167 APTR record_buffer_nonaligned;
168 APTR record_buffer_phys;
170 /** Were (inside the recording buffer) the current data is */
171 APTR current_record_buffer;
173 /** The length of each record buffer in sample bytes */
174 ULONG current_record_bytesize;
176 int recflip;
180 /** Analog mixer variables ***********************************************/
182 unsigned char mixerstate;
185 /** The currently selected input */
186 UWORD input;
188 /** The currently selected output */
189 UWORD output;
191 /** The current (recording) monitor volume */
192 Fixed monitor_volume;
194 /** The current (recording) input gain */
195 Fixed input_gain;
197 /** The current (playback) output volume */
198 Fixed output_volume;
200 /** The hardware register value corresponding to monitor_volume */
201 UWORD monitor_volume_bits;
203 /** The hardware register value corresponding to input_gain */
204 UWORD input_gain_bits;
206 /** The hardware register value corresponding to output_volume */
207 UWORD output_volume_bits;
209 /** Saved state for AC97 mike */
210 UWORD ac97_mic;
212 /** Saved state for AC97 cd */
213 UWORD ac97_cd;
215 /** Saved state for AC97 vide */
216 UWORD ac97_video;
218 /** Saved state for AC97 aux */
219 UWORD ac97_aux;
221 /** Saved state for AC97 line in */
222 UWORD ac97_linein;
224 /** Saved state for AC97 phone */
225 UWORD ac97_phone;
228 #endif /* AHI_Drivers_CMI8738_DriverData_h */