2 Copyright © 2005-2013, Davy Wentzler. All rights reserved.
6 #ifndef AHI_Drivers_Card_DriverData_h
7 #define AHI_Drivers_Card_DriverData_h
9 #include <exec/types.h>
10 #include <exec/interrupts.h>
11 #include <devices/ahi.h>
15 #define DRIVER "envy24ht.audio"
16 #define DRIVER_NEEDS_GLOBAL_EXECBASE
17 #include "DriverBase.h"
19 #define DATA_PORT CCS_UART_DATA
20 #define COMMAND_PORT CCS_UART_COMMAND
21 #define STATUS_PORT CCS_UART_COMMAND
23 #define STATUSF_OUTPUT 0x40
24 #define STATUSF_INPUT 0x80
26 #define COMMAND_RESET 0xff
27 #define DATA_ACKNOWLEDGE 0xfe
28 #define COMMAND_UART_MODE 0x3f
30 #define MPU401_OUTPUT_READY() ((INBYTE(card->iobase + STATUS_PORT) & STATUSF_OUTPUT) == 0)
31 #define MPU401_INPUT_READY() ((INBYTE(card->iobase + STATUS_PORT) & STATUSF_INPUT) == 0)
33 #define MPU401_CMD(c) OUTBYTE(card->iobase + COMMAND_PORT, c)
34 #define MPU401_STATUS() INBYTE(card->iobase + STATUS_PORT)
35 #define MPU401_READ() INBYTE(card->iobase + DATA_PORT )
36 #define MPU401_WRITE(v) OUTBYTE(card->iobase + DATA_PORT,v )
38 enum Model
{AUREON_SKY
, AUREON_SPACE
, PHASE28
, REVO51
, REVO71
, JULIA
, PHASE22
};
39 extern unsigned long Dirs
[];
46 /** Skeleton's variables *************************************************/
48 struct DriverBase driverbase
;
51 /** A sempahore used for locking */
52 struct SignalSemaphore semaphore
;
54 /** The number of cards found */
57 /** A CardData structure for each card found */
58 struct CardData
** driverdatas
;
61 #define DRIVERBASE_SIZEOF (sizeof (struct CardBase))
62 #define RECORD_BUFFER_SAMPLES 1764
67 /*** PCI/Card initialization progress *********************************/
69 struct PCIDevice
*pci_dev
;
73 unsigned char chiprev
;
76 unsigned long SavedDir
;
77 unsigned short SavedMask
;
79 /** TRUE if bus mastering is activated */
80 BOOL pci_master_enabled
;
82 /** TRUE if the Card chip has been initialized */
83 BOOL card_initialized
;
86 struct I2C_bit_ops
*bit_ops
;
87 unsigned int gpio_dir
;
88 unsigned int gpio_data
;
93 /*** The driverbase ******************************************************/
95 /** This field is also used as a lock and access to is is
96 * semaphore protected. */
97 struct DriverBase
* ahisubbase
;
100 /*** The AudioCtrl currently using this DriverData structure *************/
102 struct AHIAudioCtrlDrv
* audioctrl
;
106 /*** Playback/recording interrupts ***************************************/
108 /** TRUE when playback is enabled */
111 /** TRUE when recording is enabled */
114 /** The main (hardware) interrupt */
115 struct Interrupt interrupt
;
117 /** TRUE if the hardware interrupt has been added to the PCI subsystem */
118 BOOL interrupt_added
;
120 /** The playback software interrupt */
121 struct Interrupt playback_interrupt
;
123 /** TRUE if the hardware interrupt may Cause() playback_interrupt */
124 BOOL playback_interrupt_enabled
;
126 /** The recording software interrupt */
127 struct Interrupt record_interrupt
;
129 /** TRUE if the hardware interrupt may Cause() playback_interrupt */
130 BOOL record_interrupt_enabled
;
134 /*** CAMD support functions **********************************************/
136 /** CAMD transmitter function wrapped as a Hook */
137 struct Hook
* camd_transmitfunc
;
139 /** CAMD receiver function wrapped as a Hook */
140 struct Hook
* camd_receivefunc
;
142 /** True if CMAD V40 mode */
147 /*** Playback interrupt variables ****************************************/
149 APTR playback_buffer
;
150 APTR spdif_out_buffer
;
151 APTR playback_buffer_nonaligned
;
152 APTR spdif_out_buffer_nonaligned
;
153 APTR playback_buffer_phys
;
154 APTR spdif_out_buffer_phys
;
156 /** The mixing buffer (a cyclic buffer filled by AHI) */
159 /** The length of each playback buffer in sample frames */
160 ULONG current_frames
;
162 /** The length of each playback buffer in sample bytes */
163 ULONG current_bytesize
;
165 /** Where (inside the cyclic buffer) we're currently writing */
167 APTR spdif_out_current_buffer
;
173 /*** Recording interrupt variables ***************************************/
175 /** The recording buffer (simple double buffering is used */
177 APTR record_buffer_32bit
;
178 APTR record_buffer_nonaligned
;
179 APTR record_buffer_nonaligned_32bit
;
180 APTR record_buffer_phys
;
181 APTR record_buffer_32bit_phys
;
183 /** Were (inside the recording buffer) the current data is */
184 APTR current_record_buffer
;
185 APTR current_record_buffer_32bit
;
187 /** The length of each record buffer in sample bytes */
188 ULONG current_record_bytesize_32bit
;
192 /** Analog mixer variables ***********************************************/
194 /** The currently selected input */
197 /** The currently selected output */
200 /** The current (recording) monitor volume */
201 Fixed monitor_volume
;
203 /** The current (recording) input gain */
206 /** The current (playback) output volume */
209 /** The hardware register value corresponding to monitor_volume */
210 UWORD monitor_volume_bits
;
212 /** The hardware register value corresponding to input_gain */
213 UWORD input_gain_bits
;
215 /** The hardware register value corresponding to output_volume */
216 UWORD output_volume_bits
;
218 /** Saved state for AC97 mike */
221 /** Saved state for AC97 cd */
224 /** Saved state for AC97 vide */
227 /** Saved state for AC97 aux */
230 /** Saved state for AC97 line in */
233 /** Saved state for AC97 phone */
237 struct akm_codec
*RevoFrontCodec
;
238 struct akm_codec
*RevoSurroundCodec
;
239 struct akm_codec
*RevoRecCodec
;
241 struct akm_codec
*JuliaDAC
;
242 struct akm_codec
*JuliaRCV
; // digital receiver
245 #endif /* AHI_Drivers_Card_DriverData_h */