From 4313fba2fb928f662a63b7566f235291dc1455f7 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Fri, 23 Sep 2011 14:42:26 -0700 Subject: [PATCH] VbExBeep() now returns VbError_t instead of void This enables us to support playing sounds in the background if the BIOS allows it, so we don't have to block while beeping is happening. The new declaration is: VbError_t VbExBeep(uint32_t msec, uint32_t frequency); If the audio codec can run in the background, then: zero frequency means OFF, non-zero frequency means ON zero msec means return immediately, non-zero msec means delay (and then OFF if needed) else: non-zero msec and non-zero frequency means ON, delay, OFF, return zero msec or zero frequency means do nothing and return immediately The return value is used by the caller to determine the capabilities. The implementation should always do the best it can if it cannot fully support all features - for example, beeping at a fixed frequency if frequency support is not available. At a minimum, it must delay for the specified non-zero duration. Currently, VbExBeep() is called only when displaying the dev-mode screen. BUG=none TEST=manual I've tested on x86 and ARM, all timeouts and noises work as before. Note that ARM and coreboot will require a corresponding change to their VbExBeep() implementations, which will have to be handled with separate, simultaneous CLs. Change-Id: I3417ae4b99d9d0aee63f2ccaeed39b61d4333e5d Reviewed-on: http://gerrit.chromium.org/gerrit/8234 Tested-by: Bill Richardson Reviewed-by: Stefan Reinauer --- firmware/include/vboot_api.h | 26 ++++++++++++++++++++------ firmware/lib/vboot_display.c | 2 +- firmware/stub/vboot_api_stub.c | 3 ++- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h index c468868f48..2703e05b5f 100644 --- a/firmware/include/vboot_api.h +++ b/firmware/include/vboot_api.h @@ -94,7 +94,11 @@ enum VbErrorPredefined_t { /* Simulated (test) error */ VBERROR_SIMULATED = 0x10016, /* Invalid parameter */ - VBERROR_INVALID_PARAMETER = 0x10017 + VBERROR_INVALID_PARAMETER = 0x10017, + /* VbExBeep() can't make sounds at all */ + VBERROR_NO_SOUND = 0x10018, + /* VbExBeep() can't make sound in the background */ + VBERROR_NO_BACKGROUND_SOUND = 0x10019 }; @@ -329,11 +333,21 @@ void VbExSleepMs(uint32_t msec); /* Play a beep tone of the specified frequency in Hz and duration in msec. * This is effectively a VbSleep() variant that makes noise. * - * The implementation should do the best it can if it cannot fully - * support this interface - for example, beeping at a fixed frequency - * if frequency support is not available. At a minimum, it must delay for - * the specified duration. */ -void VbExBeep(uint32_t msec, uint32_t frequency); + * If the audio codec can run in the background, then: + * zero frequency means OFF, non-zero frequency means ON + * zero msec means return immediately, non-zero msec means delay (and + * then OFF if needed) + * else: + * non-zero msec and non-zero frequency means ON, delay, OFF, return + * zero msec or zero frequency means do nothing and return immediately + * + * The return value is used by the caller to determine the capabilities. The + * implementation should always do the best it can if it cannot fully support + * all features - for example, beeping at a fixed frequency if frequency + * support is not available. At a minimum, it must delay for the specified + * non-zero duration. + */ +VbError_t VbExBeep(uint32_t msec, uint32_t frequency); /*****************************************************************************/ diff --git a/firmware/lib/vboot_display.c b/firmware/lib/vboot_display.c index bd2a93c8a8..b0166e8117 100644 --- a/firmware/lib/vboot_display.c +++ b/firmware/lib/vboot_display.c @@ -315,7 +315,7 @@ VbError_t VbDisplayScreenFromGBB(VbCommonParams* cparams, uint32_t screen, */ if (gbb->major_version == GBB_MAJOR_VER && gbb->minor_version >= 1 && (gbb->flags != 0)) { - (void)VbExDisplayDebugInfo("GBB.flags is nonzero"); + (void)VbExDisplayDebugInfo("gbb.flags is nonzero"); } diff --git a/firmware/stub/vboot_api_stub.c b/firmware/stub/vboot_api_stub.c index 8036830003..732facb9c5 100644 --- a/firmware/stub/vboot_api_stub.c +++ b/firmware/stub/vboot_api_stub.c @@ -64,7 +64,8 @@ void VbExSleepMs(uint32_t msec) { } -void VbExBeep(uint32_t msec, uint32_t frequency) { +VbError_t VbExBeep(uint32_t msec, uint32_t frequency) { + return VBERROR_SUCCESS; }