> compile NEMU
221220000 张三 Linux zzy 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux 20:49:41 up 3 days, 15:55, 1 user, load average: 0.79, 0.71, 0.56
This commit is contained in:
@ -8,19 +8,41 @@
|
||||
#define AUDIO_INIT_ADDR (AUDIO_ADDR + 0x10)
|
||||
#define AUDIO_COUNT_ADDR (AUDIO_ADDR + 0x14)
|
||||
|
||||
static size_t audio_write = 0;
|
||||
static size_t audio_sbuf_size;
|
||||
|
||||
void __am_audio_init() {
|
||||
}
|
||||
|
||||
void __am_audio_config(AM_AUDIO_CONFIG_T *cfg) {
|
||||
cfg->present = false;
|
||||
cfg->present = true;
|
||||
cfg->bufsize = inl(AUDIO_SBUF_SIZE_ADDR);
|
||||
audio_sbuf_size = cfg->bufsize;
|
||||
}
|
||||
|
||||
void __am_audio_ctrl(AM_AUDIO_CTRL_T *ctrl) {
|
||||
if (inl(AUDIO_INIT_ADDR) == 1) {
|
||||
panic("audio initialized");
|
||||
}
|
||||
outl(AUDIO_CHANNELS_ADDR, ctrl->channels);
|
||||
outl(AUDIO_SAMPLES_ADDR, ctrl->samples);
|
||||
outl(AUDIO_FREQ_ADDR, ctrl->freq);
|
||||
outl(AUDIO_INIT_ADDR, 1);
|
||||
}
|
||||
|
||||
void __am_audio_status(AM_AUDIO_STATUS_T *stat) {
|
||||
stat->count = 0;
|
||||
stat->count = inl(AUDIO_COUNT_ADDR);
|
||||
}
|
||||
|
||||
void __am_audio_play(AM_AUDIO_PLAY_T *ctl) {
|
||||
for (int i = 0; i < ctl->buf.end - ctl->buf.start; i++) {
|
||||
if (inl(AUDIO_COUNT_ADDR) == audio_sbuf_size) {
|
||||
i--;
|
||||
continue;
|
||||
} else {
|
||||
outl(AUDIO_COUNT_ADDR, inl(AUDIO_COUNT_ADDR) + 1);
|
||||
}
|
||||
outb(AUDIO_SBUF_ADDR + audio_write, ((uint8_t*)ctl->buf.start)[i]);
|
||||
audio_write = (audio_write + 1) % audio_sbuf_size;
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ void __am_gpu_fbdraw(AM_GPU_FBDRAW_T *ctl) {
|
||||
}
|
||||
}
|
||||
if (ctl->sync) {
|
||||
while (inl(SYNC_ADDR) != 0) ;
|
||||
outl(SYNC_ADDR, 1);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user