Compare commits
2 Commits
b2f795b1e1
...
1fcd72e578
| Author | SHA1 | Date | |
|---|---|---|---|
| 1fcd72e578 | |||
| 5e1b5c329b |
@@ -43,7 +43,7 @@ namespace Kernel
|
||||
BAN::ErrorOr<void> enable_output_path(uint8_t index);
|
||||
BAN::ErrorOr<void> disable_output_path(uint8_t index);
|
||||
|
||||
void reset_stream();
|
||||
BAN::ErrorOr<void> reset_stream();
|
||||
|
||||
BAN::ErrorOr<void> recurse_output_paths(const HDAudio::AFGWidget& widget, BAN::Vector<const HDAudio::AFGWidget*>& path);
|
||||
|
||||
|
||||
@@ -12,9 +12,6 @@ namespace Kernel
|
||||
virtual ~Device() = default;
|
||||
virtual void update() {}
|
||||
|
||||
virtual bool is_partition() const { return false; }
|
||||
virtual bool is_storage_device() const { return false; }
|
||||
|
||||
virtual BAN::ErrorOr<BAN::UniqPtr<MemoryRegion>> mmap_region(PageTable&, off_t offset, size_t len, AddressRange, MemoryRegion::Type, PageTable::flags_t, int status_flags)
|
||||
{
|
||||
(void)offset; (void)len; (void)status_flags;
|
||||
|
||||
@@ -62,10 +62,12 @@ namespace Kernel
|
||||
mode_t mode;
|
||||
};
|
||||
enum InodeKind : uint8_t {
|
||||
DEVICE = 0x1,
|
||||
EPOLL = 0x2,
|
||||
PIPE = 0x4,
|
||||
TTY = 0x8,
|
||||
DEVICE = 0x01,
|
||||
EPOLL = 0x02,
|
||||
PIPE = 0x04,
|
||||
TTY = 0x08,
|
||||
PARTITION = 0x10,
|
||||
STORAGE = 0x20,
|
||||
};
|
||||
public:
|
||||
virtual ~Inode() {}
|
||||
@@ -88,10 +90,12 @@ namespace Kernel
|
||||
dev_t dev() const { return m_dev; }
|
||||
dev_t rdev() const { return m_rdev; }
|
||||
|
||||
bool is_device() const { return m_kind & InodeKind::DEVICE; }
|
||||
bool is_epoll() const { return m_kind & InodeKind::EPOLL; }
|
||||
bool is_pipe() const { return m_kind & InodeKind::PIPE; }
|
||||
bool is_tty() const { return m_kind & InodeKind::TTY; }
|
||||
bool is_device() const { return m_kind & InodeKind::DEVICE; }
|
||||
bool is_epoll() const { return m_kind & InodeKind::EPOLL; }
|
||||
bool is_pipe() const { return m_kind & InodeKind::PIPE; }
|
||||
bool is_tty() const { return m_kind & InodeKind::TTY; }
|
||||
bool is_partition() const { return m_kind & InodeKind::PARTITION; }
|
||||
bool is_storage_device() const { return m_kind & InodeKind::STORAGE; }
|
||||
|
||||
virtual const FileSystem* filesystem() const = 0;
|
||||
|
||||
|
||||
@@ -42,9 +42,6 @@ namespace Kernel
|
||||
char m_label[36 * 4 + 1];
|
||||
const BAN::String m_name;
|
||||
|
||||
public:
|
||||
virtual bool is_partition() const override { return true; }
|
||||
|
||||
protected:
|
||||
virtual BAN::ErrorOr<size_t> read_impl(off_t, BAN::ByteSpan) override;
|
||||
|
||||
|
||||
@@ -14,7 +14,10 @@ namespace Kernel
|
||||
public:
|
||||
StorageDevice()
|
||||
: BlockDevice(0660, 0, 0)
|
||||
{ }
|
||||
{
|
||||
m_kind |= InodeKind::STORAGE;
|
||||
}
|
||||
|
||||
virtual ~StorageDevice();
|
||||
|
||||
BAN::ErrorOr<void> initialize_partitions(BAN::StringView name_prefix);
|
||||
@@ -35,7 +38,6 @@ namespace Kernel
|
||||
|
||||
size_t drop_disk_cache();
|
||||
BAN::ErrorOr<void> sync_disk_cache();
|
||||
virtual bool is_storage_device() const override { return true; }
|
||||
|
||||
protected:
|
||||
virtual BAN::ErrorOr<void> read_sectors_impl(uint64_t lba, uint64_t sector_count, BAN::ByteSpan) = 0;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <kernel/Audio/HDAudio/AudioFunctionGroup.h>
|
||||
#include <kernel/Audio/HDAudio/Registers.h>
|
||||
#include <kernel/FS/DevFS/FileSystem.h>
|
||||
#include <kernel/Timer/Timer.h>
|
||||
|
||||
#include <BAN/Sort.h>
|
||||
|
||||
@@ -202,12 +203,12 @@ namespace Kernel
|
||||
ASSERT(m_stream_index == 0xFF);
|
||||
m_stream_index = TRY(m_controller->allocate_stream(HDAudio::StreamType::Output, this));
|
||||
|
||||
reset_stream();
|
||||
TRY(reset_stream());
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void HDAudioFunctionGroup::reset_stream()
|
||||
BAN::ErrorOr<void> HDAudioFunctionGroup::reset_stream()
|
||||
{
|
||||
using Regs = HDAudio::Regs;
|
||||
|
||||
@@ -219,13 +220,23 @@ namespace Kernel
|
||||
// stop stream
|
||||
bar.write8(base + Regs::SDCTL, bar.read8(base + Regs::SDCTL) & 0xFD);
|
||||
|
||||
const auto timeout_ms = SystemTimer::get().ms_since_boot() + 100;
|
||||
|
||||
// reset stream
|
||||
bar.write8(base + Regs::SDCTL, (bar.read8(base + Regs::SDCTL) & 0xFE) | 1);
|
||||
while (!(bar.read8(base + Regs::SDCTL) & 1))
|
||||
{
|
||||
if (SystemTimer::get().ms_since_boot() > timeout_ms)
|
||||
return BAN::Error::from_errno(ETIMEDOUT);
|
||||
Processor::pause();
|
||||
}
|
||||
bar.write8(base + Regs::SDCTL, (bar.read8(base + Regs::SDCTL) & 0xFE));
|
||||
while ((bar.read8(base + Regs::SDCTL) & 1))
|
||||
{
|
||||
if (SystemTimer::get().ms_since_boot() > timeout_ms)
|
||||
return BAN::Error::from_errno(ETIMEDOUT);
|
||||
Processor::pause();
|
||||
}
|
||||
|
||||
// set bdl address, total size and lvi
|
||||
const paddr_t bdl_paddr = m_bdl_region->paddr() + bdl_offset();
|
||||
@@ -621,7 +632,13 @@ namespace Kernel
|
||||
|
||||
m_bdl_tail = (m_bdl_tail + 1) % m_bdl_entry_count;
|
||||
if (m_bdl_tail == m_bdl_head)
|
||||
reset_stream();
|
||||
{
|
||||
if (auto ret = reset_stream(); ret.is_error())
|
||||
{
|
||||
dwarnln("failed to reset HDA stream: {}", ret.error());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
queue_bdl_data();
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace Kernel
|
||||
, m_attributes(attr)
|
||||
, m_name(MUST(BAN::String::formatted("{}{}", name_prefix, index)))
|
||||
{
|
||||
m_kind |= InodeKind::PARTITION;
|
||||
m_rdev = makedev(major(device->rdev()), index);
|
||||
memcpy(m_label, label, sizeof(m_label));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user