Use hardcoded settings for VIA VT1708S (they are reported to work
[AROS.git] / workbench / devs / AHI / Drivers / HDAudio / DriverData.h
bloba743a3d9cf9a833b61a39c478fbc016d5db45719
1 #ifndef AHI_Drivers_Card_DriverData_h
2 #define AHI_Drivers_Card_DriverData_h
4 #include <exec/types.h>
5 #include <exec/interrupts.h>
6 #include <devices/ahi.h>
9 /** Make the common library code initialize a global SysBase for us.
10 It's required for hwaccess.c */
12 #define DRIVER "hdaudio.audio"
13 #define DRIVER_NEEDS_GLOBAL_EXECBASE
14 #define INPUTS 5
16 #ifdef __AROS__
17 #define DRIVER_NEED_GLOBAL_EXECBASE
18 #endif
20 #ifdef __amigaos4__
21 #define DRIVER_NEED_GLOBAL_EXECBASE
22 #endif
24 #include "DriverBase.h"
26 struct HDAudioChip;
28 struct HDAudioBase
30 struct DriverBase driverbase;
33 /** A sempahore used for locking */
34 struct SignalSemaphore semaphore;
36 /** The number of cards found */
37 int cards_found;
39 /** A HDAudioChip structure for each card found */
40 struct HDAudioChip** driverdatas;
43 #define DRIVERBASE_SIZEOF (sizeof (struct HDAudioBase))
45 #define RECORD_BUFFER_SAMPLES 1024
46 #define RECORD_BUFFER_SIZE_VALUE ADCBS_BUFSIZE_4096
50 struct BDLE // Buffer Descriptor List (3.6.2)
52 ULONG lower_address; // address for 32-bit systems
53 ULONG upper_address; // only for use with 64-bit systems
54 ULONG length; // in bytes
55 ULONG reserved_ioc; // bit 0 is Interrupt on Completion
58 struct Stream
60 struct BDLE *bdl;
61 APTR bdl_nonaligned;
62 APTR *bdl_nonaligned_addresses;
64 ULONG sd_reg_offset; // 3.3.35 offset 0x80 + (ISS) * 0x20
65 ULONG index;
66 ULONG tag; // index + 1
67 UWORD fifo_size;
71 // Verb - Set Converter Format (Verb ID=2h)
72 struct Freq
74 ULONG frequency;
75 UBYTE base44100; // 1 if base= 44.1kHz, 0 if base=48kHz
76 UBYTE mult; // multiplier 3 bits
77 UBYTE div; // divisor 3 bits
82 struct HDAudioChip
84 struct PCIDevice *pci_dev;
85 APTR iobase;
86 unsigned long length;
87 unsigned short model;
88 unsigned int irq;
89 int flip;
90 int recflip;
91 unsigned char chiprev;
93 UWORD codecbits;
94 UWORD codecnr;
96 ULONG *corb;
97 ULONG corb_entries;
98 ULONG *rirb;
99 ULONG rirb_entries;
100 ULONG rirb_rp; // software read pointer
101 LONG rirb_irq;
103 APTR dma_position_buffer;
105 struct Stream *streams;
106 UBYTE nr_of_streams;
107 UBYTE nr_of_input_streams;
108 UBYTE nr_of_output_streams;
110 // important node ID's
111 UBYTE dac_nid; // front L&R
112 UBYTE adc_nid;
113 UBYTE adc_mixer_nid;
114 BOOL adc_mixer_is_mux;
115 UBYTE dac_volume_nid;
116 UBYTE speaker_nid;
117 UBYTE headphone_nid;
118 BOOL speaker_active;
121 UBYTE line_in_nid;
122 UBYTE mic1_nid;
123 UBYTE mic2_nid;
124 UBYTE cd_nid;
126 UBYTE adc_mixer_indices[5]; //0 = Line in, 1 = Mic in 1, 2 = Mic in 2, 3 = CD, 4 = Monitor Mixer
128 float adc_min_gain;
129 float adc_max_gain;
130 float adc_step_gain;
131 float dac_min_gain;
132 float dac_max_gain;
133 float dac_step_gain;
135 // sample rate
136 struct Freq *frequencies;
137 ULONG nr_of_frequencies;
138 ULONG selected_freq_index;
140 /*** PCI/Card initialization progress *********************************/
142 /** TRUE if bus mastering is activated */
143 BOOL pci_master_enabled;
145 /** TRUE if the Card chip has been initialized */
146 BOOL card_initialized;
148 /*** The driverbase ******************************************************/
150 /** This field is also used as a lock and access to is is
151 * semaphore protected. */
152 struct DriverBase* ahisubbase;
154 /*** The AudioCtrl currently using this DriverData structure *************/
156 struct AHIAudioCtrlDrv* audioctrl;
158 /*** Playback/recording interrupts ***************************************/
160 /** TRUE when playback is enabled */
161 BOOL is_playing;
163 /** TRUE when recording is enabled */
164 BOOL is_recording;
166 /** The main (hardware) interrupt */
167 struct Interrupt interrupt;
169 /** TRUE if the hardware interrupt has been added to the PCI subsystem */
170 BOOL interrupt_added;
172 /** The playback software interrupt */
173 struct Interrupt playback_interrupt;
175 /** The recording software interrupt */
176 struct Interrupt record_interrupt;
178 /*** Card structures **************************************************/
180 APTR playback_buffer1;
181 APTR playback_buffer2;
183 /*** Playback interrupt variables ****************************************/
185 /** The mixing buffer (a cyclic buffer filled by AHI) */
186 APTR mix_buffer;
188 /** The length of each playback buffer in sample frames */
189 ULONG current_frames;
191 /** The length of each playback buffer in sample bytes */
192 ULONG current_bytesize;
194 /** Where (inside the cyclic buffer) we're currently writing */
195 APTR current_buffer;
199 /*** Recording interrupt variables ***************************************/
201 /** The recording buffer (simple double buffering is used */
202 APTR record_buffer1;
203 APTR record_buffer2;
204 APTR record_buffer1_nonaligned;
205 APTR record_buffer2_nonaligned;
207 /** Were (inside the recording buffer) the current data is */
208 APTR current_record_buffer;
210 /** The length of each record buffer in sample bytes */
211 ULONG current_record_bytesize;
213 /** Analog mixer variables ***********************************************/
215 /** The currently selected input */
216 UWORD input;
220 /** The currently selected output */
221 UWORD output;
223 /** The current (recording) monitor volume */
224 Fixed monitor_volume;
226 /** The current (recording) input gain */
227 Fixed input_gain;
229 /** The current (playback) output volume */
230 Fixed output_volume;
234 #endif /* AHI_Drivers_Card_DriverData_h */