- Handle multiple nodes having output volume control.
[AROS.git] / workbench / devs / AHI / Drivers / Envy24HT / DriverData.h
blob3cc47daf8013243bd83ec56397ab1fd0c9f663c2
1 /*
2 Copyright © 2005-2013, Davy Wentzler. All rights reserved.
3 $Id$
4 */
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>
12 #include "ak_codec.h"
13 #include "I2C.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[];
42 struct CardData;
44 struct CardBase
46 /** Skeleton's variables *************************************************/
48 struct DriverBase driverbase;
51 /** A sempahore used for locking */
52 struct SignalSemaphore semaphore;
54 /** The number of cards found */
55 int 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
65 struct CardData
67 /*** PCI/Card initialization progress *********************************/
69 struct PCIDevice *pci_dev;
70 unsigned long iobase;
71 unsigned long mtbase;
72 unsigned short model;
73 unsigned char chiprev;
74 unsigned int irq;
75 BOOL input_is_24bits;
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;
84 enum Model SubType;
86 struct I2C_bit_ops *bit_ops;
87 unsigned int gpio_dir;
88 unsigned int gpio_data;
89 struct I2C *i2c;
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 */
109 BOOL is_playing;
111 /** TRUE when recording is enabled */
112 BOOL is_recording;
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 */
143 ULONG camd_v40;
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) */
157 APTR mix_buffer;
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 */
166 APTR current_buffer;
167 APTR spdif_out_current_buffer;
169 int flip;
173 /*** Recording interrupt variables ***************************************/
175 /** The recording buffer (simple double buffering is used */
176 APTR record_buffer;
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;
190 int recflip;
192 /** Analog mixer variables ***********************************************/
194 /** The currently selected input */
195 UWORD input;
197 /** The currently selected output */
198 UWORD output;
200 /** The current (recording) monitor volume */
201 Fixed monitor_volume;
203 /** The current (recording) input gain */
204 Fixed input_gain;
206 /** The current (playback) output volume */
207 Fixed 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 */
219 UWORD ac97_mic;
221 /** Saved state for AC97 cd */
222 UWORD ac97_cd;
224 /** Saved state for AC97 vide */
225 UWORD ac97_video;
227 /** Saved state for AC97 aux */
228 UWORD ac97_aux;
230 /** Saved state for AC97 line in */
231 UWORD ac97_linein;
233 /** Saved state for AC97 phone */
234 UWORD ac97_phone;
236 // For revo71
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 */