1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 19:17:35 +00:00

Kernel: Add support for Intel HDA

This is an implementation that tries to follow the spec as closely as
possible, and works with Qemu's Intel HDA and some bare metal HDA
controllers out there. Compiling with `INTEL_HDA_DEBUG=on` will provide
a lot of detailed information that could help us getting this to work
on more bare metal controllers as well :^)

Output format is limited to `i16` samples for now.
This commit is contained in:
Jelle Raaijmakers 2023-03-10 20:10:06 +01:00
parent c530f74e2f
commit dd8fa73da1
17 changed files with 2627 additions and 20 deletions

View file

@ -0,0 +1,30 @@
/*
* Copyright (c) 2023, Jelle Raaijmakers <jelle@gmta.nl>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Error.h>
#include <AK/Function.h>
namespace Kernel::Audio::IntelHDA {
// We define an arbitrary controller timeout of 300ms for most actions.
constexpr size_t controller_timeout_in_microseconds = 300'000;
consteval u32 frame_delay_in_microseconds(u32 frames)
{
// NOTE: the link operates at this _fixed_ frequency and is independent of the streams' rates.
constexpr u32 link_frame_frequency_hz = 48'000;
// 2.2: Streams and Channels
// A new frame starts exactly every 20.83 μs, corresponding to the common 48-kHz sample rate.
VERIFY(frames <= 4294);
return frames * 1'000'000u / link_frame_frequency_hz + 1u;
}
ErrorOr<void> wait_until(size_t delay_in_microseconds, size_t timeout_in_microseconds, Function<ErrorOr<bool>()> condition);
}