Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/native/kernel/dev/virtio_snd.h # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / native / kernel / dev / virtio_snd.h` 57 lines ยท 2723 bytes Raw Blame History 1 /* virtio_snd.h -- virtio-sound PCM output (virtio 1.x section 5.14), polled, 2 * for the boot sequence's chirp in a VM (QEMU virtio-sound-pci, the 3 * aienos-run window's speakers). One output stream, 2 channels, S16, 48 kHz: 4 * the chirp's own format (ui/chirp.h), so the samples go out as made. The 5 * stream is started just before the chirp and fed from the night's clock 6 * (ui/boot_show.h), so the sound lands on the merger. Layouts follow the 7 * spec (checked against the Linux UAPI copy, linux/virtio_snd.h, in the host 8 * test); builders are pure, the device goes through virtio_q.h. */ 9 #ifndef AIENOS_CK_VIRTIO_SND_H 10 #define AIENOS_CK_VIRTIO_SND_H 11 #include 12 #include 13 #include "virtio_q.h" 14 15 #define VSND_R_PCM_INFO 0x0100u 16 #define VSND_R_PCM_SET_PARAMS 0x0101u 17 #define VSND_R_PCM_PREPARE 0x0102u 18 #define VSND_R_PCM_RELEASE 0x0103u 19 #define VSND_R_PCM_START 0x0104u 20 #define VSND_R_PCM_STOP 0x0105u 21 #define VSND_S_OK 0x8000u 22 #define VSND_D_OUTPUT 0u 23 #define VSND_FMT_S16 5u 24 #define VSND_RATE_48000 7u 25 #define VSND_VQ_CONTROL 0u 26 #define VSND_VQ_TX 2u 27 #define VSND_INFO_BYTES 32u /* struct virtio_snd_pcm_info */ 28 29 size_t vsnd_cmd_query(uint8_t *out, size_t cap, uint32_t code, uint32_t start, uint32_t count, uint32_t size); 30 size_t vsnd_cmd_set_params(uint8_t *out, size_t cap, uint32_t stream, uint32_t buffer_bytes, uint32_t period_bytes, 31 uint8_t channels, uint8_t format, uint8_t rate); 32 /* PREPARE, RELEASE, START, STOP: struct virtio_snd_pcm_hdr */ 33 size_t vsnd_cmd_pcm(uint8_t *out, size_t cap, uint32_t code, uint32_t stream); 34 /* The first output stream in a PCM_INFO reply of n entries that takes 35 * stereo S16 at 48 kHz; -1 if none. */ 36 int vsnd_pick_output(const uint8_t *resp, size_t len, uint32_t n); 37 38 #ifndef CK_HOSTED 39 /* Kernel side. DMA bytes the driver needs after the rings (command, reply, 40 * four 100 ms periods). */ 41 #define VSND_EXTRA_BYTES (2u * 4096u + 4u * 20480u) 42 /* Prepares the stream on a device the caller brought up with 3 queues 43 * (control, event, tx), before DRIVER_OK; mem/bus = VSND_EXTRA_BYTES after the 44 * rings. 0 and a "virtio_snd: ..." line, or < 0 with a line saying why not. */ 45 int ck_vsnd_attach(vq_dev *dev, uint8_t *mem, uint64_t bus); 46 #ifndef CK_X86 47 #include "pci.h" 48 /* aarch64: finds the virtio-sound PCI function, confines its DMA (virtio_bind.h) 49 * and attaches. No device: < 0, and the night plays silent. */ 50 int ck_vsnd_open(const pci_system *pci); 51 #endif 52 /* Called every turn of the boot loop with the night's clock: starts the 53 * stream just before the chirp, keeps it fed, stops it after. Returns 1 54 * while it still has work, 0 when done or off. */ 55 int ck_vsnd_step(uint32_t night_ms, uint32_t audio_frame); 56 #endif 57 #endif