test,am-tests: add audio test
This commit is contained in:
parent
9e59fd2cba
commit
07c99a1e2a
5 changed files with 36 additions and 1 deletions
|
@ -1,3 +1,3 @@
|
||||||
NAME = amtest
|
NAME = amtest
|
||||||
SRCS = $(shell find src/ -name "*.c")
|
SRCS = $(shell find src/ -name "*.[cS]")
|
||||||
include $(AM_HOME)/Makefile
|
include $(AM_HOME)/Makefile
|
||||||
|
|
|
@ -11,6 +11,7 @@ static const char *tests[256] = {
|
||||||
['t'] = "real-time clock test",
|
['t'] = "real-time clock test",
|
||||||
['k'] = "readkey test",
|
['k'] = "readkey test",
|
||||||
['v'] = "display test",
|
['v'] = "display test",
|
||||||
|
['a'] = "audio test",
|
||||||
['p'] = "x86 virtual memory test",
|
['p'] = "x86 virtual memory test",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,6 +24,7 @@ int main(const char *args) {
|
||||||
CASE('t', rtc_test, IOE);
|
CASE('t', rtc_test, IOE);
|
||||||
CASE('k', keyboard_test, IOE);
|
CASE('k', keyboard_test, IOE);
|
||||||
CASE('v', video_test, IOE);
|
CASE('v', video_test, IOE);
|
||||||
|
CASE('a', audio_test, IOE);
|
||||||
CASE('p', vm_test, CTE(vm_handler), VME(simple_pgalloc, simple_pgfree));
|
CASE('p', vm_test, CTE(vm_handler), VME(simple_pgalloc, simple_pgfree));
|
||||||
case 'H':
|
case 'H':
|
||||||
default:
|
default:
|
||||||
|
|
27
tests/am-tests/src/tests/audio.c
Normal file
27
tests/am-tests/src/tests/audio.c
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#include <amtest.h>
|
||||||
|
|
||||||
|
void audio_test() {
|
||||||
|
if (!io_read(AM_AUDIO_CONFIG).present) {
|
||||||
|
printf("WARNING: %s does not support audio\n", TOSTRING(__ARCH__));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
io_write(AM_AUDIO_CTRL, 8000, 1, 1024, 8192);
|
||||||
|
|
||||||
|
extern uint8_t audio_payload, audio_payload_end;
|
||||||
|
uint32_t audio_len = &audio_payload_end - &audio_payload;
|
||||||
|
int nplay = 0;
|
||||||
|
Area sbuf;
|
||||||
|
sbuf.start = &audio_payload;
|
||||||
|
while (nplay < audio_len) {
|
||||||
|
int len = (audio_len - nplay > 4096 ? 4096 : audio_len - nplay);
|
||||||
|
sbuf.end = sbuf.start + len;
|
||||||
|
io_write(AM_AUDIO_PLAY, sbuf);
|
||||||
|
sbuf.start += len;
|
||||||
|
nplay += len;
|
||||||
|
printf("Already play %d/%d bytes of data\n", nplay, audio_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
// wait until the audio finishes
|
||||||
|
while (io_read(AM_AUDIO_STATUS).count > 0);
|
||||||
|
}
|
6
tests/am-tests/src/tests/audio/audio-data.S
Normal file
6
tests/am-tests/src/tests/audio/audio-data.S
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
.section .data
|
||||||
|
.global audio_payload, audio_payload_end
|
||||||
|
.p2align 3
|
||||||
|
audio_payload:
|
||||||
|
.incbin "src/tests/audio/little-star.pcm"
|
||||||
|
audio_payload_end:
|
BIN
tests/am-tests/src/tests/audio/little-star.pcm
Normal file
BIN
tests/am-tests/src/tests/audio/little-star.pcm
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue