grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / devs / AHI / Drivers / HDAudio / DriverData.h
blob1130eb2cc382c7be58463ad56cf95501eb1861bb
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 ID's
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;
111 BOOL speaker_active;
113 UBYTE line_in_nid;
114 UBYTE mic1_nid;
115 UBYTE mic2_nid;
116 UBYTE cd_nid;
118 UBYTE adc_mixer_indices[5]; //0 = Line in, 1 = Mic in 1, 2 = Mic in 2, 3 = CD, 4 = Monitor Mixer
120 float adc_min_gain;
121 float adc_max_gain;
122 float adc_step_gain;
123 float dac_min_gain;
124 float dac_max_gain;
125 float dac_step_gain;
127 // sample rate
128 struct Freq *frequencies;
129 ULONG nr_of_frequencies;
130 ULONG selected_freq_index;
132 UBYTE eapd_gpio_mask;
134 /*** PCI/Card initialization progress *********************************/
136 /** TRUE if bus mastering is activated */
137 BOOL pci_master_enabled;
139 /** TRUE if the Card chip has been initialized */
140 BOOL card_initialized;
142 /*** The driverbase ******************************************************/
144 /** This field is also used as a lock and access to is is
145 * semaphore protected. */
146 struct DriverBase* ahisubbase;
148 /*** The AudioCtrl currently using this DriverData structure *************/
150 struct AHIAudioCtrlDrv* audioctrl;
152 /*** Playback/recording interrupts ***************************************/
154 /** TRUE when playback is enabled */
155 BOOL is_playing;
157 /** TRUE when recording is enabled */
158 BOOL is_recording;
160 /** The main (hardware) interrupt */
161 struct Interrupt interrupt;
163 /** TRUE if the hardware interrupt has been added to the PCI subsystem */
164 BOOL interrupt_added;
166 /** The playback software interrupt */
167 struct Interrupt playback_interrupt;
169 /** The recording software interrupt */
170 struct Interrupt record_interrupt;
172 /*** Card structures **************************************************/
174 APTR playback_buffer1;
175 APTR playback_buffer2;
177 /*** Playback interrupt variables ****************************************/
179 /** The mixing buffer (a cyclic buffer filled by AHI) */
180 APTR mix_buffer;
182 /** The length of each playback buffer in sample frames */
183 ULONG current_frames;
185 /** The length of each playback buffer in sample bytes */
186 ULONG current_bytesize;
188 /** Where (inside the cyclic buffer) we're currently writing */
189 APTR current_buffer;
193 /*** Recording interrupt variables ***************************************/
195 /** The recording buffer (simple double buffering is used */
196 APTR record_buffer1;
197 APTR record_buffer2;
198 APTR record_buffer1_nonaligned;
199 APTR record_buffer2_nonaligned;
201 /** Were (inside the recording buffer) the current data is */
202 APTR current_record_buffer;
204 /** The length of each record buffer in sample bytes */
205 ULONG current_record_bytesize;
207 /** Analog mixer variables ***********************************************/
209 /** The currently selected input */
210 UWORD input;
214 /** The currently selected output */
215 UWORD output;
217 /** The current (recording) monitor volume */
218 Fixed monitor_volume;
220 /** The current (recording) input gain */
221 Fixed input_gain;
223 /** The current (playback) output volume */
224 Fixed output_volume;
228 #endif /* AHI_Drivers_Card_DriverData_h */