ReactOS 0.4.15-dev-7928-g68a8619
driver.h
Go to the documentation of this file.
1/*
2 * Copyright 2007-2012, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 * Ithamar Adema, ithamar AT unet DOT nl
7 * Axel Dörfler, axeld@pinc-software.de
8 */
9#ifndef _HDA_H_
10#define _HDA_H_
11
12#ifndef __REACTOS__
13#include <KernelExport.h>
14#include <Drivers.h>
15#include <PCI.h>
16#include <PCI_x86.h>
17
18#include <string.h>
19#include <stdlib.h>
20
21#ifndef HAIKU_TARGET_PLATFORM_HAIKU
22# define DEVFS_PATH_FORMAT "audio/multi/hda/%lu"
23# include <multi_audio.h>
24#else
25# define DEVFS_PATH_FORMAT "audio/hmulti/hda/%lu"
26# include <hmulti_audio.h>
27#endif
28#endif
29
30#include "hda_controller_defs.h"
31#include "hda_codec_defs.h"
32
33#define MAX_CARDS 4
34
35/* values for the class_sub field for class_base = 0x04 (multimedia device) */
36#ifndef __HAIKU__
37# define PCI_hd_audio 3
38#endif
39
40#define HDA_MAX_AUDIO_GROUPS 15
41#define HDA_MAX_CODECS 15
42#define HDA_MAX_STREAMS 16
43#define MAX_CODEC_RESPONSES 16
44#define MAX_CODEC_UNSOL_RESPONSES 16
45#define MAX_INPUTS 32
46#define MAX_IO_WIDGETS 8
47#define MAX_ASSOCIATIONS 16
48#define MAX_ASSOCIATION_PINS 16
49
50#define STREAM_MAX_BUFFERS 10
51#define STREAM_MIN_BUFFERS 2
52
53
54enum {
57};
58
59struct hda_codec;
60struct hda_stream;
61struct hda_multi;
62
68#ifndef __REACTOS__
72 const char* devfs_path;
73
74 area_id regs_area;
75 vuint8* regs;
77 bool msi;
79
84
93
97
100
102 {
103 return *(regs + reg);
104 }
105
107 {
108 return *(vuint16*)(regs + reg);
109 }
110
112 {
113 return *(vuint32*)(regs + reg);
114 }
115
117 {
118 *(regs + reg) = value;
119 }
120
122 {
123 *(vuint16*)(regs + reg) = value;
124 }
125
127 {
128 *(vuint32*)(regs + reg) = value;
129 }
130
132 {
133 uint8 temp = Read8(reg);
134 temp &= ~mask;
135 temp |= value;
136 Write8(reg, temp);
137 }
138
140 {
142 temp &= ~mask;
143 temp |= value;
144 Write16(reg, temp);
145 }
146
148 {
150 temp &= ~mask;
151 temp |= value;
152 Write32(reg, temp);
153 }
154};
155
160 uint32 id; /* HDA controller stream # */
161 uint32 offset; /* HDA I/O/B descriptor offset */
163 spinlock lock; /* Write lock */
165
167
168 uint32 pin_widget; /* PIN Widget ID */
169 uint32 io_widgets[MAX_IO_WIDGETS]; /* Input/Output Converter Widget ID */
171
174
177 uint32 buffer_length; /* size of buffer in samples */
178 uint32 buffer_size; /* actual (aligned) size of buffer in bytes */
181 /* Virtual addresses for buffer */
183 /* Physical addresses for buffer */
184
185 volatile bigtime_t real_time;
189
190 uint32 rate, bps; /* Samplerate & bits per sample */
191
192 area_id buffer_area;
194 phys_addr_t physical_buffer_descriptors; /* BDL physical address */
195
198
200 {
202 }
203
205 {
207 }
208
210 {
212 }
213
215 {
217 }
218
220 {
221 *(vuint16*)(controller->regs + HDAC_STREAM_BASE + offset + reg) = value;
222 }
223
225 {
226 *(vuint32*)(controller->regs + HDAC_STREAM_BASE + offset + reg) = value;
227 }
228};
229
232
237
240
241 struct {
246
247 union {
248 struct {
251 } io;
252 struct {
254 struct {
258 } d;
259};
260
266};
267#endif
268
269#define WIDGET_FLAG_OUTPUT_PATH 0x01
270#define WIDGET_FLAG_INPUT_PATH 0x02
271#define WIDGET_FLAG_WIDGET_PATH 0x04
272
278#ifndef __REACTOS__
282
283 /* Multi Audio API data */
286
289
292
295
297};
298
306struct hda_codec {
314
316
320
325
328
330};
331
332
333#define MULTI_CONTROL_FIRSTID 1024
334#define MULTI_CONTROL_MASTERID 0
335#define MULTI_MAX_CONTROLS 128
336#define MULTI_MAX_CHANNELS 128
337
342 bool input;
347 multi_mix_control mix_control;
348};
349
350
351struct hda_multi {
355
356 multi_channel_info chans[MULTI_MAX_CHANNELS];
362};
363
364
365/* driver.c */
366extern device_hooks gDriverHooks;
367extern pci_module_info* gPci;
368extern pci_x86_module_info* gPCIx86Module;
370extern uint32 gNumCards;
371
372/* hda_codec.c */
375
380
381/* hda_multi_audio.c */
382status_t multi_audio_control(void* cookie, uint32 op, void* arg, size_t length);
383
384/* hda_controller.c: Basic controller support */
385status_t hda_hw_init(hda_controller* controller);
386void hda_hw_stop(hda_controller* controller);
388status_t hda_send_verbs(hda_codec* codec, corb_t* verbs, uint32* responses,
389 uint32 count);
390status_t hda_verb_write(hda_codec* codec, uint32 nid, uint32 vid, uint16 payload);
391status_t hda_verb_read(hda_codec* codec, uint32 nid, uint32 vid, uint32 *response);
392
393/* hda_controller.c: Stream support */
397 hda_stream* stream, const char* desc);
400#endif
401
402#endif /* _HDA_H_ */
unsigned short uint16
Definition: types.h:30
unsigned int uint32
Definition: types.h:32
unsigned char uint8
Definition: types.h:28
UINT op
Definition: effect.c:236
unsigned long long uint64
Definition: platform.h:18
long int32
Definition: platform.h:12
#define STREAM_MAX_BUFFERS
Definition: driver.h:50
status_t hda_audio_group_get_widgets(hda_audio_group *audioGroup, hda_stream *stream)
status_t hda_stream_stop(hda_controller *controller, hda_stream *stream)
void hda_stream_delete(hda_stream *stream)
hda_codec * hda_codec_new(hda_controller *controller, uint32 cad)
status_t hda_send_verbs(hda_codec *codec, corb_t *verbs, uint32 *responses, uint32 count)
#define MAX_ASSOCIATION_PINS
Definition: driver.h:48
hda_stream * hda_stream_new(hda_audio_group *audioGroup, int type)
#define MULTI_MAX_CHANNELS
Definition: driver.h:336
#define MULTI_MAX_CONTROLS
Definition: driver.h:335
void hda_hw_uninit(hda_controller *controller)
pci_x86_module_info * gPCIx86Module
#define HDA_MAX_AUDIO_GROUPS
Definition: driver.h:40
#define MAX_IO_WIDGETS
Definition: driver.h:46
#define MAX_CODEC_RESPONSES
Definition: driver.h:43
device_hooks gDriverHooks
status_t hda_verb_write(hda_codec *codec, uint32 nid, uint32 vid, uint16 payload)
hda_controller gCards[MAX_CARDS]
#define MAX_INPUTS
Definition: driver.h:45
status_t hda_stream_setup_buffers(hda_audio_group *audioGroup, hda_stream *stream, const char *desc)
status_t multi_audio_control(void *cookie, uint32 op, void *arg, size_t length)
status_t hda_verb_read(hda_codec *codec, uint32 nid, uint32 vid, uint32 *response)
status_t hda_stream_start(hda_controller *controller, hda_stream *stream)
#define HDA_MAX_CODECS
Definition: driver.h:41
#define MAX_CARDS
Definition: driver.h:33
void hda_codec_delete(hda_codec *codec)
hda_widget * hda_audio_group_get_widget(hda_audio_group *audioGroup, uint32 nodeID)
uint32 gNumCards
#define HDA_MAX_STREAMS
Definition: driver.h:42
void hda_hw_stop(hda_controller *controller)
status_t hda_hw_init(hda_controller *controller)
pci_module_info * gPci
#define MAX_ASSOCIATIONS
Definition: driver.h:47
@ STREAM_RECORD
Definition: driver.h:56
@ STREAM_PLAYBACK
Definition: driver.h:55
#define MAX_CODEC_UNSOL_RESPONSES
Definition: driver.h:44
const char * get_widget_location(uint32 location)
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLenum GLint GLuint mask
Definition: glext.h:6028
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
const GLuint * buffers
Definition: glext.h:5916
GLintptr offset
Definition: glext.h:5920
hda_widget_type
#define HDAC_STREAM_BASE
uint32 corb_t
static int reg
Definition: i386-dis.c:1290
NOTIFYICONDATA nid
Definition: magnifier.c:44
static const WCHAR desc[]
Definition: protectdata.c:36
static DWORD thread_id
Definition: protocol.c:159
static calc_node_t temp
Definition: rpn_ieee.c:38
Definition: cookie.c:34
bool enabled
Definition: driver.h:263
uint32 pin_count
Definition: driver.h:264
uint32 pins[MAX_ASSOCIATION_PINS]
Definition: driver.h:265
uint32 index
Definition: driver.h:262
hda_widget widget
Definition: driver.h:281
hda_stream * record_stream
Definition: driver.h:285
uint32 widget_count
Definition: driver.h:288
hda_codec * codec
Definition: driver.h:280
uint32 association_count
Definition: driver.h:290
uint32 widget_start
Definition: driver.h:287
hda_association associations[MAX_ASSOCIATIONS]
Definition: driver.h:294
hda_widget * widgets
Definition: driver.h:293
hda_stream * playback_stream
Definition: driver.h:284
uint32 gpio
Definition: driver.h:291
hda_multi * multi
Definition: driver.h:296
thread_id unsol_response_thread
Definition: driver.h:322
uint32 unsol_responses[MAX_CODEC_UNSOL_RESPONSES]
Definition: driver.h:323
uint32 unsol_response_read
Definition: driver.h:324
uint8 addr
Definition: driver.h:313
uint8 minor
Definition: driver.h:310
uint8 major
Definition: driver.h:309
uint8 revision
Definition: driver.h:311
uint16 product_id
Definition: driver.h:308
sem_id unsol_response_sem
Definition: driver.h:321
struct hda_controller * controller
Definition: driver.h:329
uint32 responses[MAX_CODEC_RESPONSES]
Definition: driver.h:318
hda_audio_group * audio_groups[HDA_MAX_AUDIO_GROUPS]
Definition: driver.h:326
sem_id response_sem
Definition: driver.h:317
uint16 vendor_id
Definition: driver.h:307
uint32 quirks
Definition: driver.h:315
uint32 num_audio_groups
Definition: driver.h:327
uint32 response_count
Definition: driver.h:319
uint8 stepping
Definition: driver.h:312
uint32 unsol_response_write
Definition: driver.h:324
struct pci_info pci_info
Definition: driver.h:70
void Write8(uint32 reg, uint8 value)
Definition: driver.h:116
int32 opened
Definition: driver.h:71
uint32 num_bidir_streams
Definition: driver.h:83
rirb_t * rirb
Definition: driver.h:91
uint32 num_codecs
Definition: driver.h:96
uint32 * stream_positions
Definition: driver.h:92
uint32 Read32(uint32 reg)
Definition: driver.h:111
bool msi
Definition: driver.h:77
sem_id buffer_ready_sem
Definition: driver.h:99
area_id regs_area
Definition: driver.h:74
void ReadModifyWrite8(uint32 reg, uint8 mask, uint8 value)
Definition: driver.h:131
vuint8 * regs
Definition: driver.h:75
uint16 codec_status
Definition: driver.h:80
void Write32(uint32 reg, uint32 value)
Definition: driver.h:126
uint32 rirb_length
Definition: driver.h:86
corb_t * corb
Definition: driver.h:90
uint32 num_input_streams
Definition: driver.h:81
bool dma_snooping
Definition: driver.h:78
uint8 Read8(uint32 reg)
Definition: driver.h:101
uint32 rirb_read_pos
Definition: driver.h:87
void ReadModifyWrite16(uint32 reg, uint16 mask, uint16 value)
Definition: driver.h:139
void ReadModifyWrite32(uint32 reg, uint32 mask, uint32 value)
Definition: driver.h:147
void Write16(uint32 reg, uint16 value)
Definition: driver.h:121
area_id corb_rirb_pos_area
Definition: driver.h:89
const char * devfs_path
Definition: driver.h:72
uint32 corb_write_pos
Definition: driver.h:88
hda_codec * codecs[HDA_MAX_CODECS+1]
Definition: driver.h:94
uint32 corb_length
Definition: driver.h:85
hda_codec * active_codec
Definition: driver.h:95
uint32 irq
Definition: driver.h:76
uint16 Read16(uint32 reg)
Definition: driver.h:106
hda_stream * streams[HDA_MAX_STREAMS]
Definition: driver.h:98
uint32 num_output_streams
Definition: driver.h:82
hda_multi * multi
Definition: driver.h:339
multi_mix_control mix_control
Definition: driver.h:347
multi_channel_info chans[MULTI_MAX_CHANNELS]
Definition: driver.h:356
uint32 aux_bus_channel_count
Definition: driver.h:361
hda_multi_mixer_control controls[MULTI_MAX_CONTROLS]
Definition: driver.h:353
hda_audio_group * group
Definition: driver.h:352
uint32 input_bus_channel_count
Definition: driver.h:360
uint32 output_channel_count
Definition: driver.h:357
uint32 output_bus_channel_count
Definition: driver.h:359
uint32 input_channel_count
Definition: driver.h:358
uint32 control_count
Definition: driver.h:354
uint32 num_channels
Definition: driver.h:176
void Write16(uint32 reg, uint16 value)
Definition: driver.h:219
uint32 type
Definition: driver.h:164
uint32 sample_format
Definition: driver.h:173
volatile int32 buffer_cycle
Definition: driver.h:188
uint32 bps
Definition: driver.h:190
bool use_dma_position
Definition: driver.h:197
uint32 io_widgets[MAX_IO_WIDGETS]
Definition: driver.h:169
volatile bigtime_t real_time
Definition: driver.h:185
uint16 Read16(uint32 reg)
Definition: driver.h:204
area_id buffer_area
Definition: driver.h:192
uint32 sample_rate
Definition: driver.h:172
uint32 buffer_length
Definition: driver.h:177
uint32 last_link_frame_position
Definition: driver.h:187
void Write32(uint32 reg, uint32 value)
Definition: driver.h:224
area_id buffer_descriptors_area
Definition: driver.h:193
bool running
Definition: driver.h:162
uint32 buffer_size
Definition: driver.h:178
phys_addr_t physical_buffer_descriptors
Definition: driver.h:194
spinlock lock
Definition: driver.h:163
uint32 Read32(uint32 reg)
Definition: driver.h:209
uint32 sample_size
Definition: driver.h:179
uint32 rate
Definition: driver.h:190
uint32 pin_widget
Definition: driver.h:168
void Write8(uint32 reg, uint8 value)
Definition: driver.h:214
volatile uint64 frames_count
Definition: driver.h:186
phys_addr_t physical_buffers[STREAM_MAX_BUFFERS]
Definition: driver.h:182
hda_controller * controller
Definition: driver.h:166
uint32 num_io_widgets
Definition: driver.h:170
uint8 Read8(uint32 reg)
Definition: driver.h:199
int32 incorrect_position_count
Definition: driver.h:196
uint32 offset
Definition: driver.h:161
uint32 num_buffers
Definition: driver.h:175
uint32 id
Definition: driver.h:160
uint32 num_inputs
Definition: driver.h:233
uint32 node_id
Definition: driver.h:231
uint32 formats
Definition: driver.h:249
uint32 capabilities
Definition: driver.h:255
hda_widget_type type
Definition: driver.h:238
uint32 inputs[MAX_INPUTS]
Definition: driver.h:235
struct hda_widget::@1453::@1456 pin
struct hda_widget::@1452 capabilities
int32 active_input
Definition: driver.h:234
struct hda_widget::@1453::@1455 mixer
uint32 flags
Definition: driver.h:236
uint32 rates
Definition: driver.h:250
union hda_widget::@1453 d
uint32 config
Definition: driver.h:256
uint32 input_amplifier
Definition: driver.h:244
uint32 output_amplifier
Definition: driver.h:243
struct hda_widget::@1453::@1454 io
uint32 audio
Definition: driver.h:242
uint32 pm
Definition: driver.h:239
Definition: parse.h:23
Definition: pdh_main.c:94