Importing CMI8738-20072011
[AROS.git] / workbench / devs / AHI / Drivers / CMI8738 / DriverData.h
blob44f46c399a538b7abe0d8e5b5509c7f3056d15bd
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_NEED_GLOBAL_EXECBASE
21 #include "DriverBase.h"
23 struct CardData;
25 struct tester
27 unsigned long diff;
28 int flip;
29 int oldflip;
30 int A;
31 int Missed;
34 struct CardBase
36 /** Skeleton's variables *************************************************/
38 struct DriverBase driverbase;
41 /** A sempahore used for locking */
42 struct SignalSemaphore semaphore;
44 /** The number of cards found */
45 int cards_found;
47 /** A CardData structure for each card found */
48 struct CardData** driverdatas;
51 #define RECORD_BUFFER_SAMPLES 1024
54 struct CardData
56 /*** PCI/Card initialization progress *********************************/
58 struct PCIDevice *pci_dev;
59 unsigned long iobase;
60 unsigned long length;
61 unsigned short model;
62 unsigned char chiprev;
63 unsigned int irq;
65 /** TRUE if bus mastering is activated */
66 BOOL pci_master_enabled;
68 /** TRUE if the Card chip has been initialized */
69 BOOL card_initialized;
73 /*** The driverbase ******************************************************/
75 /** This field is also used as a lock and access to is is
76 * semaphore protected. */
77 struct DriverBase* ahisubbase;
80 /*** The AudioCtrl currently using this DriverData structure *************/
82 struct AHIAudioCtrlDrv* audioctrl;
86 /*** Playback/recording interrupts ***************************************/
88 /** TRUE when playback is enabled */
89 BOOL is_playing;
91 /** TRUE when recording is enabled */
92 BOOL is_recording;
94 /** The main (hardware) interrupt */
95 struct Interrupt interrupt;
97 /** TRUE if the hardware interrupt has been added to the PCI subsystem */
98 BOOL interrupt_added;
100 /** The playback software interrupt */
101 struct Interrupt playback_interrupt;
103 /** TRUE if the hardware interrupt may Cause() playback_interrupt */
104 BOOL playback_interrupt_enabled;
106 /** The recording software interrupt */
107 struct Interrupt record_interrupt;
109 /** TRUE if the hardware interrupt may Cause() playback_interrupt */
110 BOOL record_interrupt_enabled;
114 /*** CAMD support functions **********************************************/
116 /** CAMD transmitter function wrapped as a Hook */
117 struct Hook* camd_transmitfunc;
119 /** CAMD receiver function wrapped as a Hook */
120 struct Hook* camd_receivefunc;
122 /** True if CMAD V40 mode */
123 ULONG camd_v40;
127 /*** Playback interrupt variables ****************************************/
129 APTR playback_buffer;
130 APTR playback_buffer_nonaligned;
131 APTR playback_buffer_phys;
133 /** The mixing buffer (a cyclic buffer filled by AHI) */
134 APTR mix_buffer;
136 /** The length of each playback buffer in sample frames */
137 ULONG current_frames;
139 /** The length of each playback buffer in sample bytes */
140 ULONG current_bytesize;
142 /** Where (inside the cyclic buffer) we're currently writing */
143 APTR current_buffer;
145 int flip;
146 int oldflip;
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 unsigned char mixerstate;
172 /** The currently selected input */
173 UWORD input;
175 /** The currently selected output */
176 UWORD output;
178 /** The current (recording) monitor volume */
179 Fixed monitor_volume;
181 /** The current (recording) input gain */
182 Fixed input_gain;
184 /** The current (playback) output volume */
185 Fixed output_volume;
187 /** The hardware register value corresponding to monitor_volume */
188 UWORD monitor_volume_bits;
190 /** The hardware register value corresponding to input_gain */
191 UWORD input_gain_bits;
193 /** The hardware register value corresponding to output_volume */
194 UWORD output_volume_bits;
196 /** Saved state for AC97 mike */
197 UWORD ac97_mic;
199 /** Saved state for AC97 cd */
200 UWORD ac97_cd;
202 /** Saved state for AC97 vide */
203 UWORD ac97_video;
205 /** Saved state for AC97 aux */
206 UWORD ac97_aux;
208 /** Saved state for AC97 line in */
209 UWORD ac97_linein;
211 /** Saved state for AC97 phone */
212 UWORD ac97_phone;
215 #endif /* AHI_Drivers_Card_DriverData_h */