From 983245113afe1961376f5381ea4a77e4364b9d2d Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 13 Jul 2019 21:28:35 +0200 Subject: [PATCH] SB16: Write the correct DMA buffer offset for 16-bit samples. Also switch to using single-cycle mode for now. It would be nice to add support for auto-initialized mode but this works okay at the moment. --- Kernel/Devices/SB16.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Kernel/Devices/SB16.cpp b/Kernel/Devices/SB16.cpp index a5d602b47a..67be19922b 100644 --- a/Kernel/Devices/SB16.cpp +++ b/Kernel/Devices/SB16.cpp @@ -123,8 +123,9 @@ void SB16::dma_start(uint32_t length) IO::out8(0xd6, (channel % 4) | mode); // Write the offset of the buffer - IO::out8(0xc4, (u8)addr); - IO::out8(0xc4, (u8)(addr >> 8)); + u16 offset = (addr / 2) % 65536; + IO::out8(0xc4, (u8)offset); + IO::out8(0xc4, (u8)(offset >> 8)); // Write the transfer length IO::out8(0xc6, (u8)(length - 1)); @@ -175,9 +176,9 @@ ssize_t SB16::write(FileDescription&, const u8* data, ssize_t length) memcpy(m_dma_buffer_page->paddr().as_ptr(), data, length); dma_start(length); - u8 command = 0x06; - // Send 16-bit samples. - command |= 0xb0; + // 16-bit single-cycle output. + // FIXME: Implement auto-initialized output. + u8 command = 0xb0; u16 sample_count = length / sizeof(i16); if (mode & (u8)SampleFormat::Stereo)