diff options
author | Bill Richardson <wfrichar@chromium.org> | 2012-01-19 15:20:12 -0800 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-01-19 16:46:43 -0800 |
commit | f62d7e764e2996e2dfdbcde1db2c09874310892a (patch) | |
tree | ac933c84e35c0ddf40105c14a6b5debacad76e4e /board | |
parent | 8e5c7395a763b90d82369b9949af1225fd6fb228 (diff) |
Enable frequency selection in VbExBeep().
BUG=none
TEST=manual
In dev-mode, press "Ctrl-U" with no USB stick inserted.
If "crossystem dev_boot_usb" is 0, you'll hear two 400Hz beeps.
If "crossystem dev_boot_usb" is 1, you'll hear one 200Hz beep.
Signed-off-by: Bill Richardson <wfrichar@google.com>
Change-Id: Ifd45a067ec8b922863331f13f3f4525ef40f7346
Reviewed-on: https://gerrit.chromium.org/gerrit/14529
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'board')
-rw-r--r-- | board/chromebook-x86/chromeos/hda_codec.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/board/chromebook-x86/chromeos/hda_codec.c b/board/chromebook-x86/chromeos/hda_codec.c index 21a0db5a566..e6f597fd842 100644 --- a/board/chromebook-x86/chromeos/hda_codec.c +++ b/board/chromebook-x86/chromeos/hda_codec.c @@ -10,17 +10,20 @@ /* Implementation of per-board codec beeping */ -#include <chromeos/hda_codec.h> #include <common.h> #include <asm/global_data.h> #include <asm/io.h> #include <pci.h> +#include <chromeos/hda_codec.h> #define HDA_CMD_REG 0x5C #define HDA_ICII_REG 0x64 #define HDA_ICII_BUSY (1 << 0) #define HDA_ICII_VALID (1 << 1) +#define BEEP_FREQ_MAGIC 0x00C70A00 +#define BEEP_FREQ_BASE 12000 + /** * Wait 50usec for the codec to indicate it is ready * no response would imply that the codec is non-operative @@ -116,24 +119,34 @@ static u32 get_hda_base(void) } static const u32 beep_cmd[] = { - 0x00170500, /* power up codec */ - 0x00270500, /* power up DAC */ - 0x00670500, /* power up speaker */ - 0x00670740, /* enable speaker output */ - 0x0023B04B, /* set DAC gain */ - 0x00C70A0C, /* enable beep generator 1 kHz */ -}; - -void enable_beep(void) + 0x00170500, /* power up codec */ + 0x00270500, /* power up DAC */ + 0x00670500, /* power up speaker */ + 0x00670740, /* enable speaker output */ + 0x0023B04B, /* set DAC gain */ +}; /* and follow with BEEP_FREQ_MAGIC */ + +void enable_beep(uint32_t frequency) { uint32_t base; + uint8_t divider_val; int i; + if (0 == frequency) + divider_val = 0; /* off */ + else if (frequency > BEEP_FREQ_BASE) + divider_val = 1; + else if (frequency < BEEP_FREQ_BASE / 0xFF) + divider_val = 0xff; + else + divider_val = (uint8_t)(0xFF & (BEEP_FREQ_BASE / frequency)); + base = get_hda_base(); for (i = 0; i < sizeof(beep_cmd)/sizeof(beep_cmd[0]); i++) { if (write_one_verb(base, beep_cmd[i])) return; } + write_one_verb(base, BEEP_FREQ_MAGIC|divider_val); } void disable_beep(void) |