SayoriOS  0.3.3
ac97.h
1 // AC'97 driver by NDRAEY (Drew Pavlenko >_)
2 
3 // FIXME: Not working in VirtualBox, only in QEMU
4 
5 #pragma once
6 
7 #include <lib/math.h>
8 #include <common.h>
9 
10 #define AC97_VENDOR 0x8086
11 #define AC97_DEVICE 0x2415
12 
13 typedef struct {
14  uint32_t reserved : 19;
15  uint8_t channel : 2;
16  uint8_t sample : 2;
18 
19 #define AC97_MIN_RATE 8000
20 #define AC97_MAX_RATE 48000
21 
22 #define NAM_RESET 0x00
23 #define NAM_SET_MASTER_VOLUME 0x02
24 #define NAM_SET_PCM_VOLUME 0x18
25 #define NAM_EXTENDED_ID 0x28
26 #define NAM_EXTENDED_AUDIO 0x2A
27 #define NAM_SAMPLE_RATE 0x2C
28 
29 #define NABM_PCM_OUT 0x10
30 #define NABM_GLOBAL_CONTROL 0x2C
31 #define NABM_GLOBAL_STATUS 0x30
32 
33 typedef struct {
34  void* memory_pos;
35  uint16_t sample_count;
36  uint16_t flags;
37 } AC97_BDL_t;
38 
39 // Volume in dB, not %
40 void ac97_set_master_volume(uint8_t left, uint8_t right, bool mute);
41 
42 // Volume in dB, not %
43 void ac97_set_pcm_volume(uint8_t right, uint8_t left, bool mute);
44 void ac97_set_pcm_sample_rate(uint16_t sample_rate);
45 void ac97_reset_channel();
46 void ac97_clear_status_register();
47 void ac97_update_bdl();
48 void ac97_update_lvi(uint8_t index);
49 void ac97_set_play_sound(bool play);
50 void ac97_init();
51 void ac97_FillBDLs();
52 void ac97_WriteAll(void* buffer, size_t size);
53 bool ac97_is_initialized();
Основные определения ядра