4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
29 #pragma ident "%Z%%M% %I% %E% SMI"
31 #include <sys/mutex.h>
34 * Interface to the system beeper.
36 * (This is the API, not the hardware interface.)
45 /* beep_entry structure */
47 typedef struct beep_entry
{
48 unsigned short frequency
;
49 unsigned short duration
;
52 typedef void (*beep_on_func_t
)(void *arg
);
54 typedef void (*beep_off_func_t
)(void *arg
);
56 typedef void (*beep_freq_func_t
)(void *arg
, int freq
);
58 /* beep_state structure */
60 typedef struct beep_state
{
62 /* Private data for beep_freq, beep_on, and beep_off functions */
65 /* Indicates if a beep command is already in progress */
66 enum {BEEP_UNINIT
= 0, BEEP_OFF
= 1,
67 BEEP_TIMED
= 2, BEEP_ON
= 3} mode
;
69 /* Address of the hw-dependent beep_freq function */
70 beep_freq_func_t beep_freq
;
72 /* Address of the hw-dependent beep_on function */
73 beep_on_func_t beep_on
;
75 /* Address of the hw-dependent beep_off function */
76 beep_off_func_t beep_off
;
78 /* Timeout id for the beep_timeout() function */
79 timeout_id_t timeout_id
;
81 /* Mutex protecting mode, timeout_id, queue_head, queue_tail, */
85 /* Index of head of queue */
88 /* Index of tail of queue */
94 /* Circular ring buffer */
98 #define BEEP_QUEUE_SIZE 1000
100 /* BEEP_DEFAULT is a sentinel for the beep_param table. */
101 enum beep_type
{ BEEP_DEFAULT
= 0, BEEP_CONSOLE
= 1, BEEP_TYPE4
= 2 };
103 typedef struct beep_params
{
105 int frequency
; /* Hz */
106 int duration
; /* milliseconds */
110 extern int beep_init(void *arg
,
111 beep_on_func_t beep_on_func
,
112 beep_off_func_t beep_off_func
,
113 beep_freq_func_t beep_freq_func
);
115 extern int beep_fini(void);
117 extern int beeper_off(void);
119 extern int beeper_freq(enum beep_type type
, int freq
);
121 extern int beep(enum beep_type type
);
123 extern int beep_polled(enum beep_type type
);
125 extern int beeper_on(enum beep_type type
);
127 extern int beep_mktone(int frequency
, int duration
);
129 extern void beep_timeout(void *arg
);
131 extern int beep_busy(void);
139 #endif /* _SYS_BEEP_H */