summaryrefslogtreecommitdiff
path: root/Kernel/Devices/SB16.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-07-13 21:28:35 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-07-13 21:28:35 +0200
commit983245113afe1961376f5381ea4a77e4364b9d2d (patch)
tree16dcdba6109725f76ec59b41405df61dd7614248 /Kernel/Devices/SB16.cpp
parentec7b98f07984f492e4a3c567bad4d05ff02499ca (diff)
downloadserenity-983245113afe1961376f5381ea4a77e4364b9d2d.zip
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.
Diffstat (limited to 'Kernel/Devices/SB16.cpp')
-rw-r--r--Kernel/Devices/SB16.cpp11
1 files 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)