1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:48:11 +00:00

Kernel: Decouple Intel HDA interrupt handling from controller

The driver would crash if it was unable to find an output route, and
subsequently the destruction of controller did not invoke
`GenericInterruptHandler::will_be_destroyed()` because on the level of
`AudioController`, that method is unavailable.

By decoupling the interrupt handling from the controller, we get a new
refcounted class that correctly cleans up after itself :^)
This commit is contained in:
Jelle Raaijmakers 2023-07-04 11:18:05 +02:00
parent c9af6c87bf
commit 859ac200b7
5 changed files with 76 additions and 17 deletions

View file

@ -0,0 +1,29 @@
/*
* Copyright (c) 2023, Jelle Raaijmakers <jelle@gmta.nl>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Devices/Audio/IntelHDA/Controller.h>
#include <Kernel/Devices/Audio/IntelHDA/InterruptHandler.h>
namespace Kernel::Audio::IntelHDA {
InterruptHandler::InterruptHandler(Controller& controller)
: PCIIRQHandler(controller, controller.device_identifier().interrupt_line().value())
, m_controller(controller)
{
enable_irq();
}
bool InterruptHandler::handle_irq(RegisterState const&)
{
auto result_or_error = m_controller.handle_interrupt({});
if (result_or_error.is_error()) {
dmesgln("IntelHDA: Error during interrupt handling: {}", result_or_error.release_error());
return false;
}
return result_or_error.release_value();
}
}