xref: /onnv-gate/usr/src/uts/common/sys/usb/clients/hid/hidminor.h (revision 7492:2387323b838f)
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
5*7492SZhigang.Lu@Sun.COM  * Common Development and Distribution License (the "License").
6*7492SZhigang.Lu@Sun.COM  * 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 /*
22*7492SZhigang.Lu@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef _SYS_USB_HIDMINOR_H
270Sstevel@tonic-gate #define	_SYS_USB_HIDMINOR_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #ifdef	__cplusplus
310Sstevel@tonic-gate extern "C" {
320Sstevel@tonic-gate #endif
330Sstevel@tonic-gate 
340Sstevel@tonic-gate /*
350Sstevel@tonic-gate  * In order to support virtual keyboard/mouse, we should distinguish
360Sstevel@tonic-gate  * between internal virtual open and external physical open.
370Sstevel@tonic-gate  *
380Sstevel@tonic-gate  * When the physical devices are opened by application, they will
390Sstevel@tonic-gate  * be unlinked from the virtual device and their data stream will
400Sstevel@tonic-gate  * not be sent to the virtual device. When the opened physical
410Sstevel@tonic-gate  * devices are closed, they will be relinked to the virtual devices.
420Sstevel@tonic-gate  *
430Sstevel@tonic-gate  * All these automatic switch between virtual and physical are
440Sstevel@tonic-gate  * transparent.
450Sstevel@tonic-gate  *
460Sstevel@tonic-gate  * So we change minor node numbering scheme to be:
470Sstevel@tonic-gate  *	external node minor num == instance << 1
480Sstevel@tonic-gate  *	internal node minor num == instance << 1 | 0x1
490Sstevel@tonic-gate  * (There are only internal nodes for keyboard/mouse now.)
500Sstevel@tonic-gate  */
510Sstevel@tonic-gate #define	HID_MINOR_BITS_MASK		0x1
520Sstevel@tonic-gate #define	HID_MINOR_INSTANCE_MASK		~HID_MINOR_BITS_MASK
530Sstevel@tonic-gate #define	HID_MINOR_INSTANCE_SHIFT	1
540Sstevel@tonic-gate 
550Sstevel@tonic-gate #define	HID_MINOR_INTERNAL		0x1
560Sstevel@tonic-gate #define	HID_MINOR_MAKE_INTERNAL(minor) \
570Sstevel@tonic-gate 		((minor) | HID_MINOR_INTERNAL)
580Sstevel@tonic-gate 
590Sstevel@tonic-gate #define	HID_IS_INTERNAL_OPEN(minor) \
600Sstevel@tonic-gate 		(((minor) & HID_MINOR_INTERNAL))
610Sstevel@tonic-gate 
620Sstevel@tonic-gate #define	HID_MINOR_TO_INSTANCE(minor) \
630Sstevel@tonic-gate 		(((minor) & HID_MINOR_INSTANCE_MASK) >> \
640Sstevel@tonic-gate 		HID_MINOR_INSTANCE_SHIFT)
650Sstevel@tonic-gate 
660Sstevel@tonic-gate #define	HID_CONSTRUCT_INTERNAL_MINOR(inst) \
670Sstevel@tonic-gate 		(((inst) << HID_MINOR_INSTANCE_SHIFT) | \
680Sstevel@tonic-gate 		HID_MINOR_INTERNAL)
690Sstevel@tonic-gate 
700Sstevel@tonic-gate #define	HID_CONSTRUCT_EXTERNAL_MINOR(inst) \
710Sstevel@tonic-gate 		((inst) << HID_MINOR_INSTANCE_SHIFT)
720Sstevel@tonic-gate 
730Sstevel@tonic-gate #ifdef __cplusplus
740Sstevel@tonic-gate }
750Sstevel@tonic-gate #endif
760Sstevel@tonic-gate 
770Sstevel@tonic-gate #endif	/* _SYS_USB_HIDMINOR_H */
78