pcspkr: accept -1 and 0 as special lengths

This commit is contained in:
K. Lange 2018-11-29 20:55:30 +09:00
parent 4788ff3cc8
commit 931d3d3b13

View File

@ -9,9 +9,16 @@
static void note(int length, int freq) { static void note(int length, int freq) {
uint32_t div = 11931800 / freq;
uint8_t t; uint8_t t;
if (length == 0) {
t = inportb(0x61) & 0xFC;
outportb(0x61, t);
return;
}
uint32_t div = 11931800 / freq;
outportb(0x43, 0xb6); outportb(0x43, 0xb6);
outportb(0x42, (uint8_t)(div)); outportb(0x42, (uint8_t)(div));
outportb(0x42, (uint8_t)(div >> 8)); outportb(0x42, (uint8_t)(div >> 8));
@ -19,13 +26,15 @@ static void note(int length, int freq) {
t = inportb(0x61); t = inportb(0x61);
outportb(0x61, t | 0x3); outportb(0x61, t | 0x3);
unsigned long s, ss; if (length > 0) {
relative_time(length / 1000, length % 1000, &s, &ss); unsigned long s, ss;
sleep_until((process_t *)current_process, s, ss); relative_time(length / 1000, length % 1000, &s, &ss);
switch_task(0); sleep_until((process_t *)current_process, s, ss);
switch_task(0);
t = inportb(0x61) & 0xFC; t = inportb(0x61) & 0xFC;
outportb(0x61, t); outportb(0x61, t);
}
} }