3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
15 This file implements DXE for Legacy Speaker.
19 #include "LegacySpeaker.h"
23 This function will enable the speaker to generate beep
33 Data
= IoRead8 (EFI_SPEAKER_CONTROL_PORT
);
35 IoWrite8(EFI_SPEAKER_CONTROL_PORT
, Data
);
41 This function will stop beep from speaker.
52 Data
= IoRead8 (EFI_SPEAKER_CONTROL_PORT
);
54 IoWrite8(EFI_SPEAKER_CONTROL_PORT
, Data
);
59 Generate beep sound based upon number of beeps and duration of the beep
61 @param NumberOfBeeps Number of beeps which user want to produce
62 @param BeepDuration Duration for speaker gate need to be enabled
63 @param TimeInterval Interval between each beep
65 @retval Does not return if the reset takes place.
66 EFI_INVALID_PARAMETER If ResetType is invalid.
71 IN UINTN NumberOfBeep
,
72 IN UINTN BeepDuration
,
78 for (Num
=0; Num
< NumberOfBeep
; Num
++) {
81 // wait some time,at least 120us
83 gBS
->Stall (BeepDuration
);
85 gBS
->Stall (TimeInterval
);
92 This function will program the speaker tone frequency. The value should be with 64k
93 boundary since it takes only 16 bit value which gets programmed in two step IO opearattion
95 @param Frequency A value which should be 16 bit only.
102 ProgramToneFrequency (
103 IN EFI_SPEAKER_IF_PROTOCOL
* This
,
110 IoWrite8(EFI_TIMER_CONTROL_PORT
, Data
);
112 Data
= (UINT8
)(Frequency
& 0x00FF);
113 IoWrite8(EFI_TIMER_2_PORT
, Data
);
114 Data
= (UINT8
)((Frequency
& 0xFF00) >> 8);
115 IoWrite8(EFI_TIMER_2_PORT
, Data
);
120 This function will generate the beep for specified duration.
122 @param NumberOfBeeps Number of beeps which user want to produce
123 @param BeepDuration Duration for speaker gate need to be enabled
124 @param TimeInterval Interval between each beep
132 IN EFI_SPEAKER_IF_PROTOCOL
* This
,
133 IN UINTN NumberOfBeeps
,
134 IN UINTN BeepDuration
,
135 IN UINTN TimeInterval
139 if ((NumberOfBeeps
== 1) && (BeepDuration
== 0) && (TimeInterval
== 0)) {
144 if ((NumberOfBeeps
== 0) && (BeepDuration
== 0) && (TimeInterval
== 0)) {
149 if (BeepDuration
== 0) {
150 BeepDuration
= EFI_DEFAULT_SHORT_BEEP_DURATION
;
153 if (TimeInterval
== 0) {
154 TimeInterval
= EFI_DEFAULT_BEEP_TIME_INTERVAL
;
157 OutputBeep (NumberOfBeeps
, BeepDuration
, TimeInterval
);