xref: /onnv-gate/usr/src/uts/common/sys/beep.h (revision 5129:5dc46a0fd425)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
53497Srz201010  * Common Development and Distribution License (the "License").
63497Srz201010  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
223497Srz201010  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
233497Srz201010  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef _SYS_BEEP_H
270Sstevel@tonic-gate #define	_SYS_BEEP_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
31*5129Smarx #include <sys/mutex.h>
32*5129Smarx 
330Sstevel@tonic-gate /*
340Sstevel@tonic-gate  * Interface to the system beeper.
350Sstevel@tonic-gate  *
360Sstevel@tonic-gate  * (This is the API, not the hardware interface.)
370Sstevel@tonic-gate  */
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #ifdef __cplusplus
400Sstevel@tonic-gate extern "C" {
410Sstevel@tonic-gate #endif
420Sstevel@tonic-gate 
430Sstevel@tonic-gate #if	defined(_KERNEL)
44*5129Smarx 
45*5129Smarx /* beep_entry structure */
46*5129Smarx 
47*5129Smarx typedef struct beep_entry {
48*5129Smarx 	unsigned short  frequency;
49*5129Smarx 	unsigned short  duration;
50*5129Smarx } beep_entry_t;
51*5129Smarx 
52*5129Smarx typedef void (*beep_on_func_t)(void *arg);
53*5129Smarx 
54*5129Smarx typedef void (*beep_off_func_t)(void *arg);
55*5129Smarx 
56*5129Smarx typedef void (*beep_freq_func_t)(void *arg, int freq);
57*5129Smarx 
58*5129Smarx /* beep_state structure */
59*5129Smarx 
60*5129Smarx typedef struct beep_state {
61*5129Smarx 
62*5129Smarx 	/* Private data for beep_freq, beep_on, and beep_off functions */
63*5129Smarx 	void		*arg;
64*5129Smarx 
65*5129Smarx 	/* Indicates if a beep command is already in progress */
66*5129Smarx 	enum		{BEEP_UNINIT = 0, BEEP_OFF = 1,
67*5129Smarx 			    BEEP_TIMED = 2, BEEP_ON = 3} mode;
68*5129Smarx 
69*5129Smarx 	/* Address of the hw-dependent beep_freq function */
70*5129Smarx 	beep_freq_func_t beep_freq;
71*5129Smarx 
72*5129Smarx 	/* Address of the hw-dependent beep_on function */
73*5129Smarx 	beep_on_func_t	beep_on;
74*5129Smarx 
75*5129Smarx 	/* Address of the hw-dependent beep_off function */
76*5129Smarx 	beep_off_func_t	beep_off;
77*5129Smarx 
78*5129Smarx 	/* Timeout id for the beep_timeout() function */
79*5129Smarx 	timeout_id_t	timeout_id;
80*5129Smarx 
81*5129Smarx 	/* Mutex protecting mode, timeout_id, queue_head, queue_tail, */
82*5129Smarx 	/* and queue */
83*5129Smarx 	kmutex_t	mutex;
84*5129Smarx 
85*5129Smarx 	/* Index of head of queue */
86*5129Smarx 	int		queue_head;
87*5129Smarx 
88*5129Smarx 	/* Index of tail of queue */
89*5129Smarx 	int		queue_tail;
90*5129Smarx 
91*5129Smarx 	/* Max queue size */
92*5129Smarx 	int		queue_size;
93*5129Smarx 
94*5129Smarx 	/* Circular ring buffer */
95*5129Smarx 	beep_entry_t	*queue;
96*5129Smarx } beep_state_t;
97*5129Smarx 
98*5129Smarx #define	BEEP_QUEUE_SIZE	1000
99*5129Smarx 
100*5129Smarx /* BEEP_DEFAULT is a sentinel for the beep_param table. */
1010Sstevel@tonic-gate enum beep_type { BEEP_DEFAULT = 0, BEEP_CONSOLE = 1, BEEP_TYPE4 = 2 };
1020Sstevel@tonic-gate 
103*5129Smarx typedef struct beep_params {
104*5129Smarx 	enum beep_type	type;
105*5129Smarx 	int		frequency;	/* Hz */
106*5129Smarx 	int		duration;	/* milliseconds */
107*5129Smarx } beep_params_t;
108*5129Smarx 
109*5129Smarx 
110*5129Smarx extern int beep_init(void *arg,
111*5129Smarx     beep_on_func_t beep_on_func,
112*5129Smarx     beep_off_func_t beep_off_func,
113*5129Smarx     beep_freq_func_t beep_freq_func);
114*5129Smarx 
115*5129Smarx extern int beep_fini(void);
116*5129Smarx 
117*5129Smarx extern int beeper_off(void);
118*5129Smarx 
119*5129Smarx extern int beeper_freq(enum beep_type type, int freq);
120*5129Smarx 
121*5129Smarx extern int beep(enum beep_type type);
122*5129Smarx 
123*5129Smarx extern int beep_polled(enum beep_type type);
124*5129Smarx 
125*5129Smarx extern int beeper_on(enum beep_type type);
126*5129Smarx 
127*5129Smarx extern int beep_mktone(int frequency, int duration);
128*5129Smarx 
129*5129Smarx extern void beep_timeout(void *arg);
130*5129Smarx 
131*5129Smarx extern int beep_busy(void);
1320Sstevel@tonic-gate 
1330Sstevel@tonic-gate #endif	/* _KERNEL */
1340Sstevel@tonic-gate 
1350Sstevel@tonic-gate #ifdef __cplusplus
1360Sstevel@tonic-gate }
1370Sstevel@tonic-gate #endif
1380Sstevel@tonic-gate 
1390Sstevel@tonic-gate #endif /* _SYS_BEEP_H */
140