3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 This file implements DXE for Legacy Speaker.
24 #include "LegacySpeaker.h"
28 This function will enable the speaker to generate beep
38 Data
= IoRead8 (EFI_SPEAKER_CONTROL_PORT
);
40 IoWrite8(EFI_SPEAKER_CONTROL_PORT
, Data
);
46 This function will stop beep from speaker.
57 Data
= IoRead8 (EFI_SPEAKER_CONTROL_PORT
);
59 IoWrite8(EFI_SPEAKER_CONTROL_PORT
, Data
);
64 Generate beep sound based upon number of beeps and duration of the beep
66 @param NumberOfBeeps Number of beeps which user want to produce
67 @param BeepDuration Duration for speaker gate need to be enabled
68 @param TimeInterval Interval between each beep
70 @retval Does not return if the reset takes place.
71 EFI_INVALID_PARAMETER If ResetType is invalid.
76 IN UINTN NumberOfBeep
,
77 IN UINTN BeepDuration
,
83 for (Num
=0; Num
< NumberOfBeep
; Num
++) {
86 // wait some time,at least 120us
88 gBS
->Stall (BeepDuration
);
90 gBS
->Stall (TimeInterval
);
97 This function will program the speaker tone frequency. The value should be with 64k
98 boundary since it takes only 16 bit value which gets programmed in two step IO opearattion
100 @param Frequency A value which should be 16 bit only.
107 ProgramToneFrequency (
108 IN EFI_SPEAKER_IF_PROTOCOL
* This
,
115 IoWrite8(EFI_TIMER_CONTROL_PORT
, Data
);
117 Data
= (UINT8
)(Frequency
& 0x00FF);
118 IoWrite8(EFI_TIMER_2_PORT
, Data
);
119 Data
= (UINT8
)((Frequency
& 0xFF00) >> 8);
120 IoWrite8(EFI_TIMER_2_PORT
, Data
);
125 This function will generate the beep for specified duration.
127 @param NumberOfBeeps Number of beeps which user want to produce
128 @param BeepDuration Duration for speaker gate need to be enabled
129 @param TimeInterval Interval between each beep
137 IN EFI_SPEAKER_IF_PROTOCOL
* This
,
138 IN UINTN NumberOfBeeps
,
139 IN UINTN BeepDuration
,
140 IN UINTN TimeInterval
144 if ((NumberOfBeeps
== 1) && (BeepDuration
== 0) && (TimeInterval
== 0)) {
149 if ((NumberOfBeeps
== 0) && (BeepDuration
== 0) && (TimeInterval
== 0)) {
154 if (BeepDuration
== 0) {
155 BeepDuration
= EFI_DEFAULT_SHORT_BEEP_DURATION
;
158 if (TimeInterval
== 0) {
159 TimeInterval
= EFI_DEFAULT_BEEP_TIME_INTERVAL
;
162 OutputBeep (NumberOfBeeps
, BeepDuration
, TimeInterval
);