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 58ffc942dSrz201010 * Common Development and Distribution License (the "License"). 68ffc942dSrz201010 * 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 /* 228ffc942dSrz201010 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 238ffc942dSrz201010 * 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 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 31*c35aa225Smarx #include <sys/mutex.h> 32*c35aa225Smarx 337c478bd9Sstevel@tonic-gate /* 347c478bd9Sstevel@tonic-gate * Interface to the system beeper. 357c478bd9Sstevel@tonic-gate * 367c478bd9Sstevel@tonic-gate * (This is the API, not the hardware interface.) 377c478bd9Sstevel@tonic-gate */ 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #ifdef __cplusplus 407c478bd9Sstevel@tonic-gate extern "C" { 417c478bd9Sstevel@tonic-gate #endif 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #if defined(_KERNEL) 44*c35aa225Smarx 45*c35aa225Smarx /* beep_entry structure */ 46*c35aa225Smarx 47*c35aa225Smarx typedef struct beep_entry { 48*c35aa225Smarx unsigned short frequency; 49*c35aa225Smarx unsigned short duration; 50*c35aa225Smarx } beep_entry_t; 51*c35aa225Smarx 52*c35aa225Smarx typedef void (*beep_on_func_t)(void *arg); 53*c35aa225Smarx 54*c35aa225Smarx typedef void (*beep_off_func_t)(void *arg); 55*c35aa225Smarx 56*c35aa225Smarx typedef void (*beep_freq_func_t)(void *arg, int freq); 57*c35aa225Smarx 58*c35aa225Smarx /* beep_state structure */ 59*c35aa225Smarx 60*c35aa225Smarx typedef struct beep_state { 61*c35aa225Smarx 62*c35aa225Smarx /* Private data for beep_freq, beep_on, and beep_off functions */ 63*c35aa225Smarx void *arg; 64*c35aa225Smarx 65*c35aa225Smarx /* Indicates if a beep command is already in progress */ 66*c35aa225Smarx enum {BEEP_UNINIT = 0, BEEP_OFF = 1, 67*c35aa225Smarx BEEP_TIMED = 2, BEEP_ON = 3} mode; 68*c35aa225Smarx 69*c35aa225Smarx /* Address of the hw-dependent beep_freq function */ 70*c35aa225Smarx beep_freq_func_t beep_freq; 71*c35aa225Smarx 72*c35aa225Smarx /* Address of the hw-dependent beep_on function */ 73*c35aa225Smarx beep_on_func_t beep_on; 74*c35aa225Smarx 75*c35aa225Smarx /* Address of the hw-dependent beep_off function */ 76*c35aa225Smarx beep_off_func_t beep_off; 77*c35aa225Smarx 78*c35aa225Smarx /* Timeout id for the beep_timeout() function */ 79*c35aa225Smarx timeout_id_t timeout_id; 80*c35aa225Smarx 81*c35aa225Smarx /* Mutex protecting mode, timeout_id, queue_head, queue_tail, */ 82*c35aa225Smarx /* and queue */ 83*c35aa225Smarx kmutex_t mutex; 84*c35aa225Smarx 85*c35aa225Smarx /* Index of head of queue */ 86*c35aa225Smarx int queue_head; 87*c35aa225Smarx 88*c35aa225Smarx /* Index of tail of queue */ 89*c35aa225Smarx int queue_tail; 90*c35aa225Smarx 91*c35aa225Smarx /* Max queue size */ 92*c35aa225Smarx int queue_size; 93*c35aa225Smarx 94*c35aa225Smarx /* Circular ring buffer */ 95*c35aa225Smarx beep_entry_t *queue; 96*c35aa225Smarx } beep_state_t; 97*c35aa225Smarx 98*c35aa225Smarx #define BEEP_QUEUE_SIZE 1000 99*c35aa225Smarx 100*c35aa225Smarx /* BEEP_DEFAULT is a sentinel for the beep_param table. */ 1017c478bd9Sstevel@tonic-gate enum beep_type { BEEP_DEFAULT = 0, BEEP_CONSOLE = 1, BEEP_TYPE4 = 2 }; 1027c478bd9Sstevel@tonic-gate 103*c35aa225Smarx typedef struct beep_params { 104*c35aa225Smarx enum beep_type type; 105*c35aa225Smarx int frequency; /* Hz */ 106*c35aa225Smarx int duration; /* milliseconds */ 107*c35aa225Smarx } beep_params_t; 108*c35aa225Smarx 109*c35aa225Smarx 110*c35aa225Smarx extern int beep_init(void *arg, 111*c35aa225Smarx beep_on_func_t beep_on_func, 112*c35aa225Smarx beep_off_func_t beep_off_func, 113*c35aa225Smarx beep_freq_func_t beep_freq_func); 114*c35aa225Smarx 115*c35aa225Smarx extern int beep_fini(void); 116*c35aa225Smarx 117*c35aa225Smarx extern int beeper_off(void); 118*c35aa225Smarx 119*c35aa225Smarx extern int beeper_freq(enum beep_type type, int freq); 120*c35aa225Smarx 121*c35aa225Smarx extern int beep(enum beep_type type); 122*c35aa225Smarx 123*c35aa225Smarx extern int beep_polled(enum beep_type type); 124*c35aa225Smarx 125*c35aa225Smarx extern int beeper_on(enum beep_type type); 126*c35aa225Smarx 127*c35aa225Smarx extern int beep_mktone(int frequency, int duration); 128*c35aa225Smarx 129*c35aa225Smarx extern void beep_timeout(void *arg); 130*c35aa225Smarx 131*c35aa225Smarx extern int beep_busy(void); 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1367c478bd9Sstevel@tonic-gate } 1377c478bd9Sstevel@tonic-gate #endif 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate #endif /* _SYS_BEEP_H */ 140