mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:37:45 +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:
parent
c9af6c87bf
commit
859ac200b7
5 changed files with 76 additions and 17 deletions
37
Kernel/Devices/Audio/IntelHDA/InterruptHandler.h
Normal file
37
Kernel/Devices/Audio/IntelHDA/InterruptHandler.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Jelle Raaijmakers <jelle@gmta.nl>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <Kernel/Interrupts/PCIIRQHandler.h>
|
||||
|
||||
namespace Kernel::Audio::IntelHDA {
|
||||
|
||||
class Controller;
|
||||
|
||||
class InterruptHandler
|
||||
: public PCIIRQHandler
|
||||
, public RefCounted<InterruptHandler> {
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<InterruptHandler>> create(Controller& controller)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) InterruptHandler(controller));
|
||||
}
|
||||
|
||||
// ^PCIIRQHandler
|
||||
virtual StringView purpose() const override { return "IntelHDA IRQ Handler"sv; }
|
||||
|
||||
private:
|
||||
InterruptHandler(Controller& controller);
|
||||
|
||||
// ^PCIIRQHandler
|
||||
virtual bool handle_irq(RegisterState const&) override;
|
||||
|
||||
Controller& m_controller;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue