revert between 56095 -> 55830 in arch
[AROS.git] / workbench / devs / AHI / Drivers / HDAudio / DriverData.h
blobf7188fd2742fd0557337f4727b283370cb30d1b8
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 #include "DriverBase.h"
18 struct HDAudioChip;
20 struct HDAudioBase
22 struct DriverBase driverbase;
25 /** A sempahore used for locking */
26 struct SignalSemaphore semaphore;
28 /** The number of cards found */
29 int cards_found;
31 /** A HDAudioChip structure for each card found */
32 struct HDAudioChip** driverdatas;
35 #define DRIVERBASE_SIZEOF (sizeof (struct HDAudioBase))
37 #define RECORD_BUFFER_SAMPLES 1024
38 #define RECORD_BUFFER_SIZE_VALUE ADCBS_BUFSIZE_4096
42 struct BDLE // Buffer Descriptor List (3.6.2)
44 ULONG lower_address; // address for 32-bit systems
45 ULONG upper_address; // only for use with 64-bit systems
46 ULONG length; // in bytes
47 ULONG reserved_ioc; // bit 0 is Interrupt on Completion
50 struct Stream
52 struct BDLE *bdl;
53 APTR bdl_nonaligned;
54 APTR *bdl_nonaligned_addresses;
56 ULONG sd_reg_offset; // 3.3.35 offset 0x80 + (ISS) * 0x20
57 ULONG index;
58 ULONG tag; // index + 1
59 UWORD fifo_size;
63 // Verb - Set Converter Format (Verb ID=2h)
64 struct Freq
66 ULONG frequency;
67 UBYTE base44100; // 1 if base= 44.1kHz, 0 if base=48kHz
68 UBYTE mult; // multiplier 3 bits
69 UBYTE div; // divisor 3 bits
74 struct HDAudioChip
76 struct PCIDevice *pci_dev;
77 APTR iobase;
78 unsigned long length;
79 unsigned short model;
80 int flip;
81 int recflip;
82 unsigned char chiprev;
84 UWORD codecbits;
85 UWORD codecnr;
87 ULONG *corb;
88 ULONG corb_entries;
89 ULONG *rirb;
90 ULONG rirb_entries;
91 ULONG rirb_rp; // software read pointer
92 LONG rirb_irq;
94 APTR dma_position_buffer;
96 struct Stream *streams;
97 UBYTE nr_of_streams;
98 UBYTE nr_of_input_streams;
99 UBYTE nr_of_output_streams;
101 // important node IDs
102 UBYTE function_group;
103 UBYTE dac_nid; // front L&R
104 UBYTE adc_nid;
105 UBYTE adc_mixer_nid;
106 BOOL adc_mixer_is_mux;
107 UBYTE dac_volume_nids[10];
108 UBYTE dac_volume_count;
109 UBYTE speaker_nid;
110 UBYTE headphone_nid;
112 BOOL speaker_active;
114 UBYTE line_in_nid;
115 UBYTE mic1_nid;
116 UBYTE mic2_nid;
117 UBYTE cd_nid;
119 UBYTE adc_mixer_indices[5]; //0 = Line in, 1 = Mic in 1, 2 = Mic in 2, 3 = CD, 4 = Monitor Mixer
121 float adc_min_gain;
122 float adc_max_gain;
123 float adc_step_gain;
124 float dac_min_gain;
125 float dac_max_gain;
126 float dac_step_gain;
128 // sample rate
129 struct Freq *frequencies;
130 ULONG nr_of_frequencies;
131 ULONG selected_freq_index;
133 UBYTE eapd_gpio_mask;
135 /*** PCI/Card initialization progress *********************************/
137 /** TRUE if bus mastering is activated */
138 BOOL pci_master_enabled;
140 /** TRUE if the Card chip has been initialized */
141 BOOL card_initialized;
143 /*** The driverbase ******************************************************/
145 /** This field is also used as a lock and access to is is
146 * semaphore protected. */
147 struct DriverBase* ahisubbase;
149 /*** The AudioCtrl currently using this DriverData structure *************/
151 struct AHIAudioCtrlDrv* audioctrl;
153 /*** Playback/recording interrupts ***************************************/
155 /** TRUE when playback is enabled */
156 BOOL is_playing;
158 /** TRUE when recording is enabled */
159 BOOL is_recording;
161 /** The main (hardware) interrupt */
162 struct Interrupt interrupt;
164 /** TRUE if the hardware interrupt has been added to the PCI subsystem */
165 BOOL interrupt_added;
167 /** The playback software interrupt */
168 struct Interrupt playback_interrupt;
170 /** The recording software interrupt */
171 struct Interrupt record_interrupt;
173 /*** Card structures **************************************************/
175 APTR playback_buffer1;
176 APTR playback_buffer2;
178 /*** Playback interrupt variables ****************************************/
180 /** The mixing buffer (a cyclic buffer filled by AHI) */
181 APTR mix_buffer;
183 /** The length of each playback buffer in sample frames */
184 ULONG current_frames;
186 /** The length of each playback buffer in sample bytes */
187 ULONG current_bytesize;
189 /** Where (inside the cyclic buffer) we're currently writing */
190 APTR current_buffer;
194 /*** Recording interrupt variables ***************************************/
196 /** The recording buffer (simple double buffering is used */
197 APTR record_buffer1;
198 APTR record_buffer2;
199 APTR record_buffer1_nonaligned;
200 APTR record_buffer2_nonaligned;
202 /** Were (inside the recording buffer) the current data is */
203 APTR current_record_buffer;
205 /** The length of each record buffer in sample bytes */
206 ULONG current_record_bytesize;
208 /** Analog mixer variables ***********************************************/
210 /** The currently selected input */
211 UWORD input;
215 /** The currently selected output */
216 UWORD output;
218 /** The current (recording) monitor volume */
219 Fixed monitor_volume;
221 /** The current (recording) input gain */
222 Fixed input_gain;
224 /** The current (playback) output volume */
225 Fixed output_volume;
229 #endif /* AHI_Drivers_Card_DriverData_h */