XenevaOS
Loading...
Searching...
No Matches
ihda.h
Go to the documentation of this file.
1
30#ifndef __IHDA_H__
31#define __IHDA_H__
32
33#include <stdint.h>
34#include <Hal\serial.h>
35#include "widget.h"
36
38#define GCAP 0x00 //Global Capabilities
39#define VMIN 0x02 //Minor Version
40#define VMAJ 0x03 //Major Version
41#define OUTPAY 0x04 //Output Payload Capability
42#define INPAY 0x06 //Input Payload Capability
43#define GCTL 0x08 //Global Control
44#define WAKEEN 0x0C //Wake Enable
45#define STATESTS 0x0E //Wake Status
46#define GSTS 0x10 //Global Status
47#define OUTSTRMPAY 0x18 //Output Stream Payload Capability
48#define INSTRMPAY 0x1A //Input Stream Payload Capability
49#define INTCTL 0x20 //Interrupt Control
50#define INTSTS 0x24 //Interrupt Status
51#define WALCLK 0x30 //Wall Clock Counter
52#define SSYNC 0x38 //Stream Synchronization
53#define CORBLBASE 0x40 //CORB Lower Base Address
54#define CORBUBASE 0x44 //CORB Upper Base Address
55#define CORBWP 0x48 //CORB Write Pointer
56#define CORBRP 0x4A //CORB Read Pointer
57#define CORBCTL 0x4C //CORB Control
58#define CORBSTS 0x4D //CORB Status
59#define CORBSIZE 0x4E //CORB Size
60#define RIRBLBASE 0x50 //RIRB Lower Base Address
61#define RIRBUBASE 0x54 //RIRB Upper Base Address
62#define RIRBWP 0x58 //RIRB Write Pointer
63#define RINTCNT 0x5A //Response Interrupt Count
64#define RIRBCTL 0x5C //RIRB Control
65#define RIRBSTS 0x5D //RIRB Status
66#define RIRBSIZE 0x5E //RIRB Size
67#define ICOI 0x60 //Immediate Command Output Interface
68#define ICII 0x64 //Immediate Command Input Interface
69#define ICIS 0x68 //Immediate Command Status
70#define DPIBLBASE 0x70 //DMA Position Buffer Lower Base
71#define DPIBUBASE 0x74 //DMA Position Buffer Upper Base
72#define SD0CTL 0x80 //Input Stream Descriptor 0 control
73#define SD0STS 0x83 //ISD0 Status
74#define SD0LPIB 0x84 //ISD0 Link position in current buffer
75#define SD0CBL 0x88 //ISD0 Cyclic Buffer Length
76#define SD0LVI 0x8C //ISD0 Last valid index
77#define SD0FIFOD 0x90 //ISD0 FIFO Size
78#define SD0FMT 0x92 //ISD0 Format
79#define SDBDPL 0x98
80#define SDBDPU 0x9C
81
82
83#define REG_O0_CTLL 0x100
84#define REG_O0_CTLU 0x102
85#define REG_O0_STS 0x103
86#define REG_O0_CBL 0x108
87#define REG_O0_STLVI 0x10c
88#define REG_O0_FIFOD 0x110
89#define REG_O0_FMT 0x112
90#define REG_O0_BDLPL 0x118
91#define REG_O0_BDLPU 0x11c
92
93#define REG_I0_CTLL 0x80
94#define REG_I0_STS 0x83
95#define REG_I0_LPIB 0x84
96#define REG_I0_CBL 0x88
97#define REG_I0_LVI 0x8C
98#define REG_I0_FIFOD 0x90
99#define REG_I0_FMT 0x92
100#define REG_I0_BDPL 0x98
101#define REG_I0_BDPU 0x9C
102
103
104/* Here: BDL_SIZE*BUFFER_SIZE should not cross
105* 4K, else we will have some noise comming out
106* while jumping from one 4k block to other
107*/
108#define BDL_SIZE 4
109#define BUFFER_SIZE 1024
110
111
112#define HDA_GCAP_OSS_MASK 0xf000
113#define HDA_GCAP_OSS_SHIFT 12
114#define HDA_GCAP_ISS_SHIFT 8
115#define HDA_GCAP_ISS_MASK 0x0f00
116#define HDA_GCAP_BSS_SHIFT 3
117#define HDA_GCAP_BSS_MASK 0x00f8
118#define HDA_GCAP_NSD0_SHIFT 1
119#define HDA_GCAP_NSD0_MASK 0x0006
120
121#define HDA_GCAP_BSS(gcap) (((gcap) & HDA_GCAP_BSS_MASK) >> HDA_GCAP_BSS_SHIFT)
122#define HDA_GCAP_ISS(gcap) (((gcap) & HDA_GCAP_ISS_MASK) >> HDA_GCAP_ISS_SHIFT)
123#define HDA_GCAP_OSS(gcap) (((gcap) & HDA_GCAP_OSS_MASK) >> HDA_GCAP_OSS_SHIFT)
124
125#define HDA_INTCTL_CIE 0x40000000
126#define HDA_INTCTL_GIE 0x80000000
127
128#define HDAC_SDCTL_RUN 0x000002
129#define HDAC_SDCTL_IOCE 0x000004
130#define HDAC_SDCTL_FEIE 0x000008
131#define HDAC_SDCTL_DEIE 0x000010
132
133#define HDAC_SDSTS_DESE (1<<4)
134#define HDAC_SDSTS_FIFOE (1<<3)
135#define HDAC_SDSTS_BCIS (1<<2)
136
137/* GCTL bits */
139 GCTL_RESET = (1 << 0),
140};
141
142/* CORBCTL bits */
144 CORBCTL_CORBRUN = (1 << 1),
145};
146
147/* RIRBCTL bits */
149 RIRBCTL_RIRBRUN = (1 << 1),
150};
151
152
176
187
191
203
210
212 PIN_CAP_OUTPUT = (1 << 4),
213 PIN_CAP_INPUT = (1 << 5),
214};
215
224
226 SR_48_KHZ = (0 << 14),
227 SR_44_KHZ = (1 << 14),
228 BITS_32 = (4 << 4),
229 BITS_16 = (1 << 4),
230 BITS_24 = (3 << 4),
231 BITS_8 = (0 << 4),
232};
233
234
235#pragma pack (push,1)
241#pragma pack(pop)
242
243#pragma pack(push,1)
258#pragma pack(pop)
259
260/*
261* _aud_inb_ -- reads a value from mmio register in byte
262* @param reg -- register
263*/
264extern uint8_t _aud_inb_(int reg);
265
266/*
267* _aud_outb_ -- writes a value to mmio register in byte
268* @param reg -- register
269* @param value -- value to write
270*/
271extern void _aud_outb_(int reg, uint8_t value);
272
273/*
274* _aud_inw_ -- reads a value from mmio register in word
275* @param reg -- register
276*/
277extern uint16_t _aud_inw_(int reg);
278
279/*
280* _aud_outw_ -- writes a value to mmio register in word
281* @param reg -- register
282* @param value -- value to write
283*/
284extern void _aud_outw_(int reg, uint16_t value);
285
286/*
287* _aud_inl_ -- reads a value from mmio register in dword
288* @param reg -- register
289*/
290extern uint32_t _aud_inl_(int reg);
291
292/*
293* _aud_outl_ -- writes a value to mmio register in dword
294* @param reg -- register
295* @param value -- value to write
296*/
297extern void _aud_outl_(int reg, uint32_t value);
298
299
300extern void HDAudioSetDMAPos(uint64_t dma_buff);
302extern void HDAudioSetSampleBuffer(uint64_t buffer);
303
304/*
305* CORBWrite -- write verb to corb
306* @param verb -- verb to write
307*/
308extern void CORBWrite(uint32_t verb);
309
314extern void RIRBRead(uint64_t *response);
315
316/*
317* HDAAddPath -- adds widget to widget list
318* @param path -- pointer to path object
319*/
320extern void HDAAddPath(HDAAudioPath *path);
321
322
323/*
324* HDASetVolumeFunc -- sets function pointer to each codecs volume
325* function
326*/
327extern void HDASetVolumeFunc(void(*set_vol) (uint8_t volume, int codec));
328
329/*
330* hda_set_codec_init_func -- sets function pointer to each codecs
331* initialisation code
332*/
333extern void HDASetCodecInitFunc(void(*init_func)(int codec, int nid));
334
335/*
336* HDASetVolume -- sets volume to output codec
337* @param volume -- volume level
338*/
339extern void HDASetVolume(uint8_t volume);
340
341#endif
unsigned uintptr_t
Definition stdint.h:95
char * path
Definition main.cpp:62
unsigned int uint32_t
Definition acefiex.h:163
unsigned char uint8_t
Definition acefiex.h:161
COMPILER_DEPENDENT_UINT64 uint64_t
Definition acefiex.h:165
unsigned short int uint16_t
Definition acefiex.h:162
uint64_t HDAudioGetDMAPos()
Definition ihda.cpp:523
void _aud_outl_(int reg, uint32_t value)
Definition ihda.cpp:64
void _aud_outw_(int reg, uint16_t value)
Definition ihda.cpp:83
void _aud_outb_(int reg, uint8_t value)
Definition ihda.cpp:102
codec_parameters
Definition ihda.h:177
@ PARAM_AUDIO_WID_CAP
Definition ihda.h:182
@ PARAM_OUT_AMP_CAP
Definition ihda.h:185
@ PARAM_FN_GROUP_TYPE
Definition ihda.h:181
@ PARAM_PIN_CAP
Definition ihda.h:183
@ PARAM_REV_ID
Definition ihda.h:179
@ PARAM_NODE_COUNT
Definition ihda.h:180
@ PARAM_VENDOR_ID
Definition ihda.h:178
@ PARAM_CONN_LIST_LEN
Definition ihda.h:184
void HDAAddPath(HDAAudioPath *path)
Definition ihda.cpp:535
pin_ctl_flags
Definition ihda.h:216
@ PIN_CTL_ENABLE_OUTPUT
Definition ihda.h:218
@ PIN_CTL_ENABLE_VREFEN
Definition ihda.h:220
@ PIN_CTL_ENABLE_VREF_EN
Definition ihda.h:221
@ PIN_CTL_ENABLE_INPUT
Definition ihda.h:219
@ PIN_CTL_ENABLE_HPHN
Definition ihda.h:217
@ PIN_CTL_ENABLE_VREF_EN2
Definition ihda.h:222
void HDAudioSetSampleBuffer(uint64_t buffer)
Definition ihda.cpp:527
codec_verbs
Definition ihda.h:153
@ VERB_SET_BEEP_GEN
Definition ihda.h:170
@ VERB_SET_STREAM_CHANNEL
Definition ihda.h:156
@ VERB_GET_VOLUME_CONTROL
Definition ihda.h:173
@ VERB_GET_AMP_GAIN_MUTE
Definition ihda.h:158
@ VERB_GET_CONN_SELECT
Definition ihda.h:162
@ VERB_SET_EAPD_BTL
Definition ihda.h:167
@ VERB_GET_CONN_LIST
Definition ihda.h:161
@ VERB_GET_PIN_CONTROL
Definition ihda.h:164
@ VERB_GET_POWER_STATE
Definition ihda.h:168
@ VERB_SET_CONN_SELECT
Definition ihda.h:163
@ VERB_SET_AMP_GAIN_MUTE
Definition ihda.h:159
@ VERB_SET_FORMAT
Definition ihda.h:157
@ VERB_SET_PIN_CONTROL
Definition ihda.h:165
@ VERB_SET_CONV_CHANNEL_COUNT
Definition ihda.h:172
@ VERB_GET_PARAMETER
Definition ihda.h:154
@ VERB_GET_STREAM_CHANNEL
Definition ihda.h:155
@ VERB_SET_VOLUME_CONTROL
Definition ihda.h:174
@ VERB_GET_CONFIG_DEFAULT
Definition ihda.h:160
@ VERB_GET_CONV_CHANNEL_COUNT
Definition ihda.h:171
@ VERB_SET_POWER_STATE
Definition ihda.h:169
@ VERB_GET_EAPD_BTL
Definition ihda.h:166
void RIRBRead(uint64_t *response)
Definition ihda.cpp:252
void HDASetVolume(uint8_t volume)
Definition ihda.cpp:553
struct _bdl_ HDABDLEntry
sample_format
Definition ihda.h:225
@ BITS_24
Definition ihda.h:230
@ SR_48_KHZ
Definition ihda.h:226
@ SR_44_KHZ
Definition ihda.h:227
@ BITS_32
Definition ihda.h:228
@ BITS_16
Definition ihda.h:229
@ BITS_8
Definition ihda.h:231
reg_corbctl
Definition ihda.h:143
@ CORBCTL_CORBRUN
Definition ihda.h:144
struct _hd_audio_ HDAudio
void HDASetVolumeFunc(void(*set_vol)(uint8_t volume, int codec))
Definition ihda.cpp:513
fn_group_type
Definition ihda.h:188
@ FN_GROUP_AUDIO
Definition ihda.h:189
reg_rirbctl
Definition ihda.h:148
@ RIRBCTL_RIRBRUN
Definition ihda.h:149
void CORBWrite(uint32_t verb)
Definition ihda.cpp:220
void HDAudioSetDMAPos(uint64_t dma_buff)
Definition ihda.cpp:519
void HDASetCodecInitFunc(void(*init_func)(int codec, int nid))
Definition ihda.cpp:503
uint16_t _aud_inw_(int reg)
Definition ihda.cpp:92
uint8_t _aud_inb_(int reg)
Definition ihda.cpp:112
widget_capabilities
Definition ihda.h:204
@ WIDGET_CAP_TYPE_MASK
Definition ihda.h:208
@ WIDGET_CAP_POWER_CNTRL
Definition ihda.h:205
@ WIDGET_CAP_TYPE_SHIFT
Definition ihda.h:207
reg_gctl
Definition ihda.h:138
@ GCTL_RESET
Definition ihda.h:139
uint32_t _aud_inl_(int reg)
Definition ihda.cpp:73
pin_capabilities
Definition ihda.h:211
@ PIN_CAP_INPUT
Definition ihda.h:213
@ PIN_CAP_OUTPUT
Definition ihda.h:212
widget_type
Definition ihda.h:192
@ WIDGET_POWER
Definition ihda.h:198
@ WIDGET_SELECTOR
Definition ihda.h:196
@ WIDGET_PIN
Definition ihda.h:197
@ WIDGET_VOLUME_KNOB
Definition ihda.h:199
@ WIDGET_INPUT
Definition ihda.h:194
@ WIDGET_VENDOR_DEFINED
Definition ihda.h:201
@ WIDGET_BEEP_GEN
Definition ihda.h:200
@ WIDGET_MIXER
Definition ihda.h:195
@ WIDGET_OUTPUT
Definition ihda.h:193
Definition widget.h:62
Definition ihda.h:236
uint32_t length
Definition ihda.h:238
uint32_t flags
Definition ihda.h:239
uint64_t paddr
Definition ihda.h:237
Definition ihda.h:244
uint64_t sample_buffer
Definition ihda.h:248
uint32_t * corb
Definition ihda.h:246
uintptr_t output_ptr
Definition ihda.h:255
uint64_t dma_pos_buff
Definition ihda.h:256
bool immediate_use
Definition ihda.h:254
uint32_t rirb_entries
Definition ihda.h:249
uint16_t num_iss
Definition ihda.h:251
uint64_t mmio
Definition ihda.h:245
uint16_t num_oss
Definition ihda.h:252
uint64_t * rirb
Definition ihda.h:247
uint32_t corb_entries
Definition ihda.h:250
uint8_t irq
Definition ihda.h:253