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 #pragma ident "%Z%%M% %I% %E% SMI"
27
28 /*
29 * This is the Beep module for supporting keyboard beep for keyboards
30 * that do not have the beeping feature within themselves
31 *
32 */
33
34 #include <sys/types.h>
35 #include <sys/conf.h>
36
37 #include <sys/ddi.h>
38 #include <sys/sunddi.h>
39 #include <sys/modctl.h>
40 #include <sys/ddi_impldefs.h>
41 #include <sys/kmem.h>
42
43 #include <sys/beep.h>
44 #include <sys/inttypes.h>
45
46 /*
47 * Debug stuff
95 (unsigned long) beep_on_func,
96 (unsigned long) beep_off_func,
97 (unsigned long) beep_freq_func));
98
99 mutex_enter(&beep_state.mutex);
100
101 if (beep_state.mode != BEEP_UNINIT) {
102 mutex_exit(&beep_state.mutex);
103 BEEP_DEBUG((CE_WARN,
104 "beep_init : beep_state already initialized."));
105 return (DDI_SUCCESS);
106 }
107
108 queue = kmem_zalloc(sizeof (beep_entry_t) * beep_queue_size,
109 KM_SLEEP);
110
111 BEEP_DEBUG1((CE_CONT,
112 "beep_init : beep_queue kmem_zalloc(%d) = 0x%lx.",
113 (int)sizeof (beep_entry_t) * beep_queue_size,
114 (unsigned long)queue));
115
116 if (queue == NULL) {
117 BEEP_DEBUG((CE_WARN,
118 "beep_init : kmem_zalloc of beep_queue failed."));
119 return (DDI_FAILURE);
120 }
121
122 beep_state.arg = arg;
123 beep_state.mode = BEEP_OFF;
124 beep_state.beep_freq = beep_freq_func;
125 beep_state.beep_on = beep_on_func;
126 beep_state.beep_off = beep_off_func;
127 beep_state.timeout_id = 0;
128
129 beep_state.queue_head = 0;
130 beep_state.queue_tail = 0;
131 beep_state.queue_size = beep_queue_size;
132 beep_state.queue = queue;
133
134 mutex_exit(&beep_state.mutex);
135
136 BEEP_DEBUG1((CE_CONT, "beep_init : done."));
137 return (DDI_SUCCESS);
138 }
139
140
|
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 /*
27 * This is the Beep module for supporting keyboard beep for keyboards
28 * that do not have the beeping feature within themselves
29 *
30 */
31
32 #include <sys/types.h>
33 #include <sys/conf.h>
34
35 #include <sys/ddi.h>
36 #include <sys/sunddi.h>
37 #include <sys/modctl.h>
38 #include <sys/ddi_impldefs.h>
39 #include <sys/kmem.h>
40
41 #include <sys/beep.h>
42 #include <sys/inttypes.h>
43
44 /*
45 * Debug stuff
93 (unsigned long) beep_on_func,
94 (unsigned long) beep_off_func,
95 (unsigned long) beep_freq_func));
96
97 mutex_enter(&beep_state.mutex);
98
99 if (beep_state.mode != BEEP_UNINIT) {
100 mutex_exit(&beep_state.mutex);
101 BEEP_DEBUG((CE_WARN,
102 "beep_init : beep_state already initialized."));
103 return (DDI_SUCCESS);
104 }
105
106 queue = kmem_zalloc(sizeof (beep_entry_t) * beep_queue_size,
107 KM_SLEEP);
108
109 BEEP_DEBUG1((CE_CONT,
110 "beep_init : beep_queue kmem_zalloc(%d) = 0x%lx.",
111 (int)sizeof (beep_entry_t) * beep_queue_size,
112 (unsigned long)queue));
113
114 beep_state.arg = arg;
115 beep_state.mode = BEEP_OFF;
116 beep_state.beep_freq = beep_freq_func;
117 beep_state.beep_on = beep_on_func;
118 beep_state.beep_off = beep_off_func;
119 beep_state.timeout_id = 0;
120
121 beep_state.queue_head = 0;
122 beep_state.queue_tail = 0;
123 beep_state.queue_size = beep_queue_size;
124 beep_state.queue = queue;
125
126 mutex_exit(&beep_state.mutex);
127
128 BEEP_DEBUG1((CE_CONT, "beep_init : done."));
129 return (DDI_SUCCESS);
130 }
131
132
|