summaryrefslogtreecommitdiff
path: root/Kernel/Devices/Audio
AgeCommit message (Collapse)Author
2022-03-18Kernel: Default initialize AC97::m_codec_revisionBrian Gianforcaro
Found by PVS-Studio.
2022-03-17Kernel: Use default constructors/destructorsLenny Maiorani
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
2022-03-14Kernel/PCI: Don't hold spinlocks when doing fast device enumerationLiav A
Instead, hold the lock while we copy the contents to a stack-based Vector then iterate on it without any locking. Because we rely on heap allocations, we need to propagate errors back in case of OOM condition, therefore, both PCI::enumerate API function and PCI::Access::add_host_controller_and_enumerate_attached_devices use now a ErrorOr<void> return value to propagate errors. OOM Error can only occur when enumerating the m_device_identifiers vector under a spinlock and trying to expand the temporary Vector which will be used locklessly to actually iterate over the PCI::DeviceIdentifiers objects.
2022-03-04Kernel: Report AC'97 vendor and device IDJelle Raaijmakers
2022-03-02Kernel/Audio: Don't try to enumerate PCI adapters if PCI is disabledLiav A
2022-02-27Kernel: Whitespace and `Error` cleanup in `AC97`Jelle Raaijmakers
No functional changes.
2022-02-27Kernel: Do not reset AC'97 PCM out on buffer completionJelle Raaijmakers
We now only reset the PCM out channel during initialization, and handle the case where the channel's current index has passed the last valid index properly. This fixes issues with stuttering audio between multiple subsequent `aplay` invocations, for example.
2022-02-27Kernel: Read and report AC'97 codec revisionJelle Raaijmakers
This might help with debugging on bare metal. Since the minimum version that can be specified is revision 2.1, and we do not use any feature from revision 2.2 or newer, this is merely future-proofing ourselves for new features yet to be built. Additionally, removing the `VERIFY()` ensures we will not crash on cards that only support earlier revisions.
2022-02-27Kernel: Make AC'97 initialization fallibleJelle Raaijmakers
Let's not crash in `AudioManagement` if we run into trouble.
2022-02-26Kernel: Allow setting AC'97 sample rate during playbackJelle Raaijmakers
The Qemu AC'97 device stops its PCM channel's DMA engine when it is running and the sample rate is changed. We now make sure the DMA engine is restarted after changing the sample rate, allowing you to e.g. run `asctl set r 22050` during `aplay` playback.
2022-02-26Kernel: Clean up AC'97 driver code styleJelle Raaijmakers
* Remove braces from single-line conditionals * Use aggregate initialization style for member variables
2022-02-24Kernel/Audio: Remove the SB16 driverLiav A
This driver is not tested and probably not used on any modern hardware machine, because it is plugged into the ISA bus and not the PCI bus. Also, the run script doesn't utilize this device anymore, making it more hard to test this driver and to ensure it doesn't rot.
2022-02-14Kernel/Audio: Ignore buffers with more than 4096 bytes of data in SB16Liav A
The SB16 card driver doesn't swallow more than 4096 bytes of data at once, so instead of asserting just return ENOSPC for now. To test this, either play normal sound or just this (very!) loud noise: dd if=/dev/random of=/dev/audio/0 bs=4096
2022-02-14Kernel/Audio: Introduce a new design architecture for the subsystemLiav A
We have 3 new components: 1. The AudioManagement singleton. This class like in other subsystems, is responsible to find hardware audio controllers and keep a reference to them. 2. AudioController class - this class is the parent class for hardware controllers like the Sound Blaster 16 or Intel 82801AA (AC97). For now, this class has simple interface for getting and controlling sample rate of audio channels, as well a write interface for specific audio channel but not reading from it. One AudioController object might have multiple AudioChannel "child" objects to hold with reference counting. 3. AudioChannel class - this is based on the CharacterDevice class, and represents hardware PCM audio channel. It facilitates an ioctl interface which should be consistent across all supported hardware currently. It has a weak reference to a parent AudioController, and when trying to write to a channel, it redirects the data to the parent AudioController. Each audio channel device should be added into a new directory under the /dev filesystem called "audio".
2022-01-25Kernel: Use u64 instead of size_t for File::can_write offsetIdan Horowitz
This ensures offsets will not be truncated on large files on i686.
2022-01-25Kernel: Use u64 instead of size_t for File::can_read offsetIdan Horowitz
This ensures offsets will not be truncated on large files on i686.
2022-01-09Kernel: Page-align AC'97 audio buffer descriptor listJelle Raaijmakers
This was broken in commit 0a1b34c753 / PR #11687 since the buffer descriptor list size was not page-aligned, and the new `MM.allocate_dma_buffer_pages` expects a page-aligned size.
2022-01-09Kernel: Use DMA helper everywherePankaj Raghav
Port UCHI, AC97, SB16, BMIDEChannel and AHCIPort to use the helper to allocate DMA buffers.
2021-12-28Kernel: Propagate overflow errors from Memory::page_round_upGuilherme Goncalves
Fixes #11402.
2021-11-28Kernel: Ignore AC97 non-completion interruptsJelle Raaijmakers
Fixes #11094
2021-11-28Kernel: Add AC97_DEBUG macroJelle Raaijmakers
2021-11-27Kernel/Audio: Implement 2 correctness fixes in AC97Liav A
The fixes are: 1. Don't copy PCI::DeviceIdentifier during construction. This is a heavy structure to copy so we definitely don't want to do that. Instead, use a const reference to it like what happens in other parts in the Kernel. 2. Declare the constructor as explicit to avoid construction errors.
2021-11-26Kernel: Implement variable rate audio support for AC97 devicesJelle Raaijmakers
Previously we `VERIFY()`ed that the device supports variable-rate audio (VRA). Now, we query the VRA bit and if VRA is not supported, we do not enable double-rate audio and disallow setting any sample rate except the fixed 48kHz rate as defined by the AC'97 specification. This should allow the driver to function on a wider array of hardware. Note that in the AC'97 specification, DRA without VRA is allowed when supported: this effectively doubles the sample rate to 96kHZ. For now, we ignore that possibility and let it default to 48kHZ.
2021-11-24Kernel: Allow higher audio sample rates than 65kHZ (`u16`)Jelle Raaijmakers
Executing `asctl set r 96000` no longer results in weird sample rates being set on the audio devices. SB16 checks for a sample rate between 1 and 44100 Hz, while AC97 implements double-rate support which allows sample rates between 8kHz and 96kHZ.
2021-11-23Kernel: Allow writes larger than `PAGE_SIZE` to AC97 deviceJelle Raaijmakers
Previously, `cat /dev/random > /dev/audio` would crash Serenity. Fix this by splitting up the written data into `PAGE_SIZE` chunks.
2021-11-23Kernel: Add generic channel support to AC97Jelle Raaijmakers
This factors out some hardcoded PCMOut registers into a new private class called AC97Channel, which wraps around a channel's registers and provides some shared functionality. No functional changes.
2021-11-23Kernel: Implement AC97 audio device driverJelle Raaijmakers
2021-11-23Kernel: Teach DeviceManagement to handle multiple audio devicesJelle Raaijmakers
2021-11-23Kernel: Move SB16 to Audio subdirectoryJelle Raaijmakers