diff options
author | Stefan Reinauer <reinauer@chromium.org> | 2011-10-25 14:15:57 -0700 |
---|---|---|
committer | Patrick Georgi <patrick@georgi-clan.de> | 2011-10-27 10:49:41 +0200 |
commit | bbfc9c449f61fc553bdea797b2f77af9d9420ccf (patch) | |
tree | 27b3e6bf005de6b0a3ec3d9b80e065d810d768cb /payloads/libpayload | |
parent | 6eb8bef25e6ab4d44b0f0549a12b05bde943dcae (diff) | |
download | coreboot-bbfc9c449f61fc553bdea797b2f77af9d9420ccf.tar.xz |
Fix libpayload speaker driver
The frequency for the PC speaker has to be specified as
1193180 / frequency according to http://wiki.osdev.org/PC_Speaker
Change-Id: Iaca9d45807e080efe834611e719b350680b5fb90
Signed-off-by: Stefan Reinauer <reinauer@google.com>
Reviewed-on: http://review.coreboot.org/337
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
Diffstat (limited to 'payloads/libpayload')
-rw-r--r-- | payloads/libpayload/drivers/speaker.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/payloads/libpayload/drivers/speaker.c b/payloads/libpayload/drivers/speaker.c index 3b3a750318..3a561bcbfa 100644 --- a/payloads/libpayload/drivers/speaker.c +++ b/payloads/libpayload/drivers/speaker.c @@ -60,13 +60,15 @@ */ void speaker_enable(u16 freq) { + u16 reg16 = 1193180 / freq; + /* Select counter 2. Read/write LSB first, then MSB. Use mode 3 (square wave generator). Use a 16bit binary counter. */ outb(0xb6, I82C54_CONTROL_WORD_REGISTER); /* Set the desired tone frequency. */ - outb((u8)(freq & 0x00ff), I82C54_COUNTER2); /* LSB. */ - outb((u8)(freq >> 8), I82C54_COUNTER2); /* MSB. */ + outb((u8)(reg16 & 0x00ff), I82C54_COUNTER2); /* LSB. */ + outb((u8)(reg16 >> 8), I82C54_COUNTER2); /* MSB. */ /* Enable the PC speaker (set bits 0 and 1). */ outb(inb(PC_SPEAKER_PORT) | 0x03, PC_SPEAKER_PORT); |