xref: /titanic_52/usr/src/uts/common/sys/beep.h (revision bfed486ad8de8b8ebc6345a8e10accae08bf2f45)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_BEEP_H
27 #define	_SYS_BEEP_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/mutex.h>
32 
33 /*
34  * Interface to the system beeper.
35  *
36  * (This is the API, not the hardware interface.)
37  */
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 #if	defined(_KERNEL)
44 
45 /* beep_entry structure */
46 
47 typedef struct beep_entry {
48 	unsigned short  frequency;
49 	unsigned short  duration;
50 } beep_entry_t;
51 
52 typedef void (*beep_on_func_t)(void *arg);
53 
54 typedef void (*beep_off_func_t)(void *arg);
55 
56 typedef void (*beep_freq_func_t)(void *arg, int freq);
57 
58 /* beep_state structure */
59 
60 typedef struct beep_state {
61 
62 	/* Private data for beep_freq, beep_on, and beep_off functions */
63 	void		*arg;
64 
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;
68 
69 	/* Address of the hw-dependent beep_freq function */
70 	beep_freq_func_t beep_freq;
71 
72 	/* Address of the hw-dependent beep_on function */
73 	beep_on_func_t	beep_on;
74 
75 	/* Address of the hw-dependent beep_off function */
76 	beep_off_func_t	beep_off;
77 
78 	/* Timeout id for the beep_timeout() function */
79 	timeout_id_t	timeout_id;
80 
81 	/* Mutex protecting mode, timeout_id, queue_head, queue_tail, */
82 	/* and queue */
83 	kmutex_t	mutex;
84 
85 	/* Index of head of queue */
86 	int		queue_head;
87 
88 	/* Index of tail of queue */
89 	int		queue_tail;
90 
91 	/* Max queue size */
92 	int		queue_size;
93 
94 	/* Circular ring buffer */
95 	beep_entry_t	*queue;
96 } beep_state_t;
97 
98 #define	BEEP_QUEUE_SIZE	1000
99 
100 /* BEEP_DEFAULT is a sentinel for the beep_param table. */
101 enum beep_type { BEEP_DEFAULT = 0, BEEP_CONSOLE = 1, BEEP_TYPE4 = 2 };
102 
103 typedef struct beep_params {
104 	enum beep_type	type;
105 	int		frequency;	/* Hz */
106 	int		duration;	/* milliseconds */
107 } beep_params_t;
108 
109 
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);
114 
115 extern int beep_fini(void);
116 
117 extern int beeper_off(void);
118 
119 extern int beeper_freq(enum beep_type type, int freq);
120 
121 extern int beep(enum beep_type type);
122 
123 extern int beep_polled(enum beep_type type);
124 
125 extern int beeper_on(enum beep_type type);
126 
127 extern int beep_mktone(int frequency, int duration);
128 
129 extern void beep_timeout(void *arg);
130 
131 extern int beep_busy(void);
132 
133 #endif	/* _KERNEL */
134 
135 #ifdef __cplusplus
136 }
137 #endif
138 
139 #endif /* _SYS_BEEP_H */
140