1 #ifndef GRUB_SPEAKER_HEADER
2 #define GRUB_SPEAKER_HEADER 1
4 #include <grub/cpu/io.h>
5 #include <grub/i386/pit.h>
7 /* The frequency of the PIT clock. */
8 #define GRUB_SPEAKER_PIT_FREQUENCY 0x1234dd
11 grub_speaker_beep_off (void)
15 status
= grub_inb (GRUB_PIT_SPEAKER_PORT
);
16 grub_outb (status
& ~(GRUB_PIT_SPK_TMR2
| GRUB_PIT_SPK_DATA
),
17 GRUB_PIT_SPEAKER_PORT
);
21 grub_speaker_beep_on (grub_uint16_t pitch
)
28 else if (pitch
> 20000)
31 counter
= GRUB_SPEAKER_PIT_FREQUENCY
/ pitch
;
33 /* Program timer 2. */
34 grub_outb (GRUB_PIT_CTRL_SELECT_2
35 | GRUB_PIT_CTRL_READLOAD_WORD
36 | GRUB_PIT_CTRL_SQUAREWAVE_GEN
37 | GRUB_PIT_CTRL_COUNT_BINARY
, GRUB_PIT_CTRL
);
38 grub_outb (counter
& 0xff, GRUB_PIT_COUNTER_2
); /* LSB */
39 grub_outb ((counter
>> 8) & 0xff, GRUB_PIT_COUNTER_2
); /* MSB */
42 status
= grub_inb (GRUB_PIT_SPEAKER_PORT
);
43 grub_outb (status
| GRUB_PIT_SPK_TMR2
| GRUB_PIT_SPK_DATA
,
44 GRUB_PIT_SPEAKER_PORT
);