|
XenevaOS
|
#include <aurora.h>#include <Drivers/uart.h>#include <aucon.h>#include <stdint.h>#include <pcie.h>#include <Hal/AA64/aa64lowlevel.h>#include <Mm/vmmngr.h>#include <audrv.h>#include <Drivers/virtio.h>#include <Mm/pmmngr.h>#include <Hal/AA64/gic.h>#include <string.h>#include <_null.h>#include <Sound/sound.h>#include <Mm/kmalloc.h>
Classes | |
| struct | virtio_snd_config |
| struct | virtio_snd_hdr |
| struct | virtio_snd_info |
| struct | _virtio_snd_query_info_ |
| struct | virtio_snd_event |
| struct | virtio_snd_jack_info |
| struct | virtio_snd_pcm_hdr |
| struct | virtio_snd_pcm_info |
| struct | virtio_snd_pcm_set_params |
| struct | _snd_xfer_ |
| struct | virtio_snd_pcm_status |
Macros | |
| #define | VIRTIO_F_VERSION_1 (1ull << 32) |
| #define | VIRTIO_PCI_CAP_ID 0x09 |
| #define | VIRTIO_PCI_CAP_COMMON_CFG 1 |
| #define | VIRTIO_PCI_CAP_DEVICE_CFG 4 |
| #define | VIRTQ_DESC_F_NEXT 1 |
| #define | VIRTQ_DESC_F_WRITE 2 |
| #define | VIRTIO_PCM_PERIOD 2048 |
| #define | VIRTIO_PCM_BUFFER (VIRTIO_PCM_PERIOD * 4) |
Typedefs | |
| typedef struct _virtio_snd_query_info_ | virtio_snd_query_info |
| typedef struct _snd_xfer_ | virtio_snd_pcm_xfer |
Functions | |
| AU_DRIVER_FLAGS (AU_DRV_FLAG_UNLOADABLE) | |
| AU_EXTERN AU_EXPORT int | AuDriverUnload () |
| int | virtio_snd_write (uint8_t *buffer, size_t len) |
| int | virtio_snd_read (uint8_t *buffer, size_t len) |
| int | virtio_snd_output_stop () |
| int | virtio_snd_output_start () |
| int | virtio_snd_set_vol (uint8_t vol) |
| AU_EXTERN AU_EXPORT int | AuDriverMain (AuDriver *drv) |
| #define VIRTIO_F_VERSION_1 (1ull << 32) |
BSD 2-Clause License
Copyright (c) 2022-2026, Manas Kamal Choudhury All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
| #define VIRTIO_PCI_CAP_COMMON_CFG 1 |
| #define VIRTIO_PCI_CAP_DEVICE_CFG 4 |
| #define VIRTIO_PCI_CAP_ID 0x09 |
| #define VIRTIO_PCM_BUFFER (VIRTIO_PCM_PERIOD * 4) |
| #define VIRTIO_PCM_PERIOD 2048 |
| Low Latency | 128 frame | 3 Period | 512 (period_bytes) | 1,536 (buffer_bytes) | General | 512 frame | 4 period | 2048 (period_bytes) | 8,192 (buffer_bytes)
Latency profiles |-----------------------------— | Low latency | 8ms | 1 Page | General | 43 ms | 2 page |Media/Battery| 128 ms | 6 Pages |------------------------------—
Formulas: frame_bytes = channels (2=stereo) x bytes_per_sample period_bytes = period_frames x frame_bytes byffer_bytes = period_bytes x N_periods latency = buffer_bytes / (rate x frame_bytes) = N x period_frames / rate) period_frames = rate x target_latency / N
Sample bytes value U8/S8 = 1 bytes S16 = 2 bytes S24 = 3 bytes S24 in 32_BIT Container = 4 bytes S32/FLOAT32 = 4 bytes FLOAT64 = 8 bytes
Let's choose General profile
| #define VIRTQ_DESC_F_NEXT 1 |
| #define VIRTQ_DESC_F_WRITE 2 |
| typedef struct _snd_xfer_ virtio_snd_pcm_xfer |
| typedef struct _virtio_snd_query_info_ virtio_snd_query_info |
| anonymous enum |
| anonymous enum |
| anonymous enum |
| anonymous enum |
| AU_DRIVER_FLAGS | ( | AU_DRV_FLAG_UNLOADABLE | ) |
| int virtio_snd_output_start | ( | ) |
| int virtio_snd_output_stop | ( | ) |
| int virtio_snd_set_vol | ( | uint8_t | vol | ) |