xref: /illumos-gate/usr/src/uts/common/sys/beep.h (revision 2d6eb4a5)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
58ffc942dSrz  * Common Development and Distribution License (the "License").
68ffc942dSrz  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
228ffc942dSrz  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
238ffc942dSrz  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef _SYS_BEEP_H
277c478bd9Sstevel@tonic-gate #define	_SYS_BEEP_H
287c478bd9Sstevel@tonic-gate 
29*c35aa225Smarx #include <sys/mutex.h>
30*c35aa225Smarx 
317c478bd9Sstevel@tonic-gate /*
327c478bd9Sstevel@tonic-gate  * Interface to the system beeper.
337c478bd9Sstevel@tonic-gate  *
347c478bd9Sstevel@tonic-gate  * (This is the API, not the hardware interface.)
357c478bd9Sstevel@tonic-gate  */
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #ifdef __cplusplus
387c478bd9Sstevel@tonic-gate extern "C" {
397c478bd9Sstevel@tonic-gate #endif
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #if	defined(_KERNEL)
42*c35aa225Smarx 
43*c35aa225Smarx /* beep_entry structure */
44*c35aa225Smarx 
45*c35aa225Smarx typedef struct beep_entry {
46*c35aa225Smarx 	unsigned short  frequency;
47*c35aa225Smarx 	unsigned short  duration;
48*c35aa225Smarx } beep_entry_t;
49*c35aa225Smarx 
50*c35aa225Smarx typedef void (*beep_on_func_t)(void *arg);
51*c35aa225Smarx 
52*c35aa225Smarx typedef void (*beep_off_func_t)(void *arg);
53*c35aa225Smarx 
54*c35aa225Smarx typedef void (*beep_freq_func_t)(void *arg, int freq);
55*c35aa225Smarx 
56*c35aa225Smarx /* beep_state structure */
57*c35aa225Smarx 
58*c35aa225Smarx typedef struct beep_state {
59*c35aa225Smarx 
60*c35aa225Smarx 	/* Private data for beep_freq, beep_on, and beep_off functions */
61*c35aa225Smarx 	void		*arg;
62*c35aa225Smarx 
63*c35aa225Smarx 	/* Indicates if a beep command is already in progress */
64*c35aa225Smarx 	enum		{BEEP_UNINIT = 0, BEEP_OFF = 1,
65*c35aa225Smarx 			    BEEP_TIMED = 2, BEEP_ON = 3} mode;
66*c35aa225Smarx 
67*c35aa225Smarx 	/* Address of the hw-dependent beep_freq function */
68*c35aa225Smarx 	beep_freq_func_t beep_freq;
69*c35aa225Smarx 
70*c35aa225Smarx 	/* Address of the hw-dependent beep_on function */
71*c35aa225Smarx 	beep_on_func_t	beep_on;
72*c35aa225Smarx 
73*c35aa225Smarx 	/* Address of the hw-dependent beep_off function */
74*c35aa225Smarx 	beep_off_func_t	beep_off;
75*c35aa225Smarx 
76*c35aa225Smarx 	/* Timeout id for the beep_timeout() function */
77*c35aa225Smarx 	timeout_id_t	timeout_id;
78*c35aa225Smarx 
79*c35aa225Smarx 	/* Mutex protecting mode, timeout_id, queue_head, queue_tail, */
80*c35aa225Smarx 	/* and queue */
81*c35aa225Smarx 	kmutex_t	mutex;
82*c35aa225Smarx 
83*c35aa225Smarx 	/* Index of head of queue */
84*c35aa225Smarx 	int		queue_head;
85*c35aa225Smarx 
86*c35aa225Smarx 	/* Index of tail of queue */
87*c35aa225Smarx 	int		queue_tail;
88*c35aa225Smarx 
89*c35aa225Smarx 	/* Max queue size */
90*c35aa225Smarx 	int		queue_size;
91*c35aa225Smarx 
92*c35aa225Smarx 	/* Circular ring buffer */
93*c35aa225Smarx 	beep_entry_t	*queue;
94*c35aa225Smarx } beep_state_t;
95*c35aa225Smarx 
96*c35aa225Smarx #define	BEEP_QUEUE_SIZE	1000
97*c35aa225Smarx 
98*c35aa225Smarx /* BEEP_DEFAULT is a sentinel for the beep_param table. */
997c478bd9Sstevel@tonic-gate enum beep_type { BEEP_DEFAULT = 0, BEEP_CONSOLE = 1, BEEP_TYPE4 = 2 };
1007c478bd9Sstevel@tonic-gate 
101*c35aa225Smarx typedef struct beep_params {
102*c35aa225Smarx 	enum beep_type	type;
103*c35aa225Smarx 	int		frequency;	/* Hz */
104*c35aa225Smarx 	int		duration;	/* milliseconds */
105*c35aa225Smarx } beep_params_t;
106*c35aa225Smarx 
107*c35aa225Smarx 
108*c35aa225Smarx extern int beep_init(void *arg,
109*c35aa225Smarx     beep_on_func_t beep_on_func,
110*c35aa225Smarx     beep_off_func_t beep_off_func,
111*c35aa225Smarx     beep_freq_func_t beep_freq_func);
112*c35aa225Smarx 
113*c35aa225Smarx extern int beep_fini(void);
114*c35aa225Smarx 
115*c35aa225Smarx extern int beeper_off(void);
116*c35aa225Smarx 
117*c35aa225Smarx extern int beeper_freq(enum beep_type type, int freq);
118*c35aa225Smarx 
119*c35aa225Smarx extern int beep(enum beep_type type);
120*c35aa225Smarx 
121*c35aa225Smarx extern int beep_polled(enum beep_type type);
122*c35aa225Smarx 
123*c35aa225Smarx extern int beeper_on(enum beep_type type);
124*c35aa225Smarx 
125*c35aa225Smarx extern int beep_mktone(int frequency, int duration);
126*c35aa225Smarx 
127*c35aa225Smarx extern void beep_timeout(void *arg);
128*c35aa225Smarx 
129*c35aa225Smarx extern int beep_busy(void);
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1347c478bd9Sstevel@tonic-gate }
1357c478bd9Sstevel@tonic-gate #endif
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate #endif /* _SYS_BEEP_H */
138