|
ginnOS
The reference: libc, the libraries and the kernel
|
#include "ac97.h"#include "arch/x86/cpu/io.h"#include "common/memory.h"#include "drivers/pci/pci.h"#include "drivers/pci/pci_irq.h"#include "kernel/audio/audio.h"#include "kernel/klog/klog.h"#include "kernel/memory/page.h"#include "kernel/memory/pmm.h"#include "kernel/time/timer.h"Data Structures | |
| struct | __attribute__ |
| ELF32 file header. More... | |
Macros | |
| #define | NAM_RESET 0x00 |
| the AC'97 driver (Intel I/O Controller Hub 82801AA AC'97 programmer's reference; AC'97 component specification 2.3). | |
| #define | NAM_MASTER 0x02 |
| #define | NAM_PCM_OUT 0x18 |
| #define | NAM_EXT_ID 0x28 |
| #define | NAM_EXT_CTRL 0x2A |
| #define | NAM_FRONT_RATE 0x2C |
| #define | NAM_VENDOR_ID1 0x7C |
| #define | NAM_VENDOR_ID2 0x7E |
| #define | EXT_VRA 0x0001u |
| #define | VOLUME_MUTE 0x8000u |
| #define | PCM_OUT_0DB 0x0808u |
| #define | PO_BDBAR 0x10 |
| #define | PO_CIV 0x14 |
| #define | PO_LVI 0x15 |
| #define | PO_SR 0x16 |
| #define | PO_CR 0x1B |
| #define | GLOB_CNT 0x2C |
| #define | GLOB_STA 0x30 |
| #define | CR_RUN 0x01u |
| #define | CR_RESET 0x02u |
| #define | CR_IOCE 0x10u |
| #define | SR_DCH 0x01u |
| #define | SR_LVBCI 0x04u |
| #define | SR_BCIS 0x08u |
| #define | SR_FIFOE 0x10u |
| #define | SR_CLEAR (SR_LVBCI | SR_BCIS | SR_FIFOE) |
| #define | GLOB_COLD_RESET_OFF 0x02u |
| #define | GLOB_CODEC_READY 0x100u |
| #define | BDL_ENTRIES 32u |
| #define | BDL_IOC 0x8000u |
| #define | BDL_BUP 0x4000u |
| #define | PERIODS 4u |
| #define | PERIOD_BYTES 2048u |
| #define | SPIN_LIMIT 10000000u |
| #define | BUFFERS_OFFSET 0x400u |
Functions | |
| bool | ac97_init (void) |
| find the first AC'97 controller and register it as the sound device. | |
| #define NAM_RESET 0x00 |
the AC'97 driver (Intel I/O Controller Hub 82801AA AC'97 programmer's reference; AC'97 component specification 2.3).
the PCM out channel reads a buffer descriptor list (BDL) of 32 entries; each entry points to a buffer and gives its length in samples. the controller plays the entries in a circle and stops after the last valid index (LVI). the driver uses PERIODS buffers: entry e plays buffer e % PERIODS. when an entry has played, the driver fills its buffer again from the audio core and moves the LVI forward, so the controller never reaches it while sound is queued.
the refill runs from the controller interrupt and from the timer (the controller has no MSI, and its INTx line may not be routed on a real machine with the I/O APIC). both run with interrupts off, so they never overlap.
| #define NAM_MASTER 0x02 |
| #define NAM_PCM_OUT 0x18 |
| #define NAM_EXT_ID 0x28 |
| #define NAM_EXT_CTRL 0x2A |
| #define NAM_FRONT_RATE 0x2C |
| #define NAM_VENDOR_ID1 0x7C |
| #define NAM_VENDOR_ID2 0x7E |
| #define EXT_VRA 0x0001u |
| #define VOLUME_MUTE 0x8000u |
| #define PCM_OUT_0DB 0x0808u |
| #define PO_BDBAR 0x10 |
| #define PO_CIV 0x14 |
| #define PO_LVI 0x15 |
| #define PO_SR 0x16 |
| #define PO_CR 0x1B |
| #define GLOB_CNT 0x2C |
| #define GLOB_STA 0x30 |
| #define CR_RUN 0x01u |
| #define CR_RESET 0x02u |
| #define CR_IOCE 0x10u |
| #define SR_DCH 0x01u |
| #define SR_LVBCI 0x04u |
| #define SR_BCIS 0x08u |
| #define SR_FIFOE 0x10u |
| #define GLOB_COLD_RESET_OFF 0x02u |
| #define GLOB_CODEC_READY 0x100u |
| #define BDL_ENTRIES 32u |
| #define BDL_IOC 0x8000u |
| #define BDL_BUP 0x4000u |
| #define PERIODS 4u |
| #define PERIOD_BYTES 2048u |
| #define SPIN_LIMIT 10000000u |
| #define BUFFERS_OFFSET 0x400u |
| bool ac97_init | ( | void | ) |
find the first AC'97 controller and register it as the sound device.
call after pci_init and apic_init.