Merge tag 'pull-loongarch-20241016' of https://gitlab.com/gaosong/qemu into staging
[qemu/armbru.git] / include / hw / audio / asc.h
blob04fac270b6a8e5b8331cd3ae56ae9a8c863f5df4
1 /*
2 * QEMU Apple Sound Chip emulation
4 * Apple Sound Chip (ASC) 344S0063
5 * Enhanced Apple Sound Chip (EASC) 343S1063
7 * Copyright (c) 2012-2018 Laurent Vivier <laurent@vivier.eu>
8 * Copyright (c) 2022 Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
10 * SPDX-License-Identifier: GPL-2.0-or-later
13 #ifndef HW_AUDIO_ASC_H
14 #define HW_AUDIO_ASC_H
16 #include "hw/sysbus.h"
17 #include "audio/audio.h"
19 #define ASC_FREQ 22257
21 enum {
22 ASC_TYPE_ASC = 0, /* original discrete Apple Sound Chip */
23 ASC_TYPE_EASC = 1 /* discrete Enhanced Apple Sound Chip */
26 #define ASC_FIFO_OFFSET 0x0
27 #define ASC_FIFO_SIZE 0x400
29 #define ASC_REG_OFFSET 0x800
30 #define ASC_REG_SIZE 0x60
32 #define ASC_EXTREG_OFFSET 0xf00
33 #define ASC_EXTREG_SIZE 0x20
35 typedef struct ASCFIFOState {
36 int index;
38 MemoryRegion mem_fifo;
39 uint8_t fifo[ASC_FIFO_SIZE];
40 uint8_t int_status;
42 int cnt;
43 int wptr;
44 int rptr;
46 MemoryRegion mem_extregs;
47 uint8_t extregs[ASC_EXTREG_SIZE];
49 int xa_cnt;
50 uint8_t xa_val;
51 uint8_t xa_flags;
52 int16_t xa_last[2];
53 } ASCFIFOState;
55 struct ASCState {
56 SysBusDevice parent_obj;
58 uint8_t type;
59 MemoryRegion asc;
60 MemoryRegion mem_fifo;
61 MemoryRegion mem_regs;
62 MemoryRegion mem_extregs;
64 QEMUSoundCard card;
65 SWVoiceOut *voice;
66 uint8_t *mixbuf;
67 int samples;
68 int shift;
70 uint8_t *silentbuf;
72 /* Time when we were last able to generate samples */
73 int64_t fifo_empty_ns;
75 qemu_irq irq;
77 ASCFIFOState fifos[2];
79 uint8_t regs[ASC_REG_SIZE];
82 #define TYPE_ASC "apple-sound-chip"
83 OBJECT_DECLARE_SIMPLE_TYPE(ASCState, ASC)
85 #endif