1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 15:25:08 +00:00
serenity/Kernel/Devices/Audio/IntelHDA/InterruptHandler.cpp
Jelle Raaijmakers 859ac200b7 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 :^)
2023-07-04 16:24:04 +02:00

29 lines
797 B
C++

/*
* 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();
}
}