mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-28 13:43:45 +03:00
60 lines
1.4 KiB
C++
60 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <AK/CircularQueue.h>
|
|
#include <Kernel/Alarm.h>
|
|
#include <Kernel/Devices/CharacterDevice.h>
|
|
#include <Kernel/IRQHandler.h>
|
|
#include <Kernel/VM/PhysicalAddress.h>
|
|
#include <Kernel/VM/PhysicalPage.h>
|
|
|
|
class SB16;
|
|
|
|
class SB16InterruptAlarm final : public Alarm {
|
|
public:
|
|
SB16InterruptAlarm(SB16& device)
|
|
: m_device(device)
|
|
{
|
|
}
|
|
virtual bool is_ringing() const override;
|
|
|
|
private:
|
|
SB16& m_device;
|
|
};
|
|
|
|
class SB16 final : public IRQHandler
|
|
, public CharacterDevice {
|
|
public:
|
|
SB16();
|
|
virtual ~SB16() override;
|
|
|
|
static SB16& the();
|
|
|
|
// ^CharacterDevice
|
|
virtual bool can_read(FileDescription&) const override;
|
|
virtual ssize_t read(FileDescription&, u8*, ssize_t) override;
|
|
virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
|
|
virtual bool can_write(FileDescription&) const override { return true; }
|
|
|
|
bool got_interrupt(Badge<SB16InterruptAlarm>) const { return m_interrupted; }
|
|
|
|
private:
|
|
// ^IRQHandler
|
|
virtual void handle_irq() override;
|
|
|
|
// ^CharacterDevice
|
|
virtual const char* class_name() const override { return "SB16"; }
|
|
|
|
void initialize();
|
|
void wait_for_irq();
|
|
void dma_start(uint32_t length);
|
|
void set_sample_rate(uint16_t hz);
|
|
void dsp_write(u8 value);
|
|
u8 dsp_read();
|
|
|
|
RefPtr<PhysicalPage> m_dma_buffer_page;
|
|
bool m_interrupted { false };
|
|
int m_major_version { 0 };
|
|
|
|
SB16InterruptAlarm m_interrupt_alarm;
|
|
};
|