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, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _SYS_USB_HIDMINOR_H 28 #define _SYS_USB_HIDMINOR_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 /* 37 * In order to support virtual keyboard/mouse, we should distinguish 38 * between internal virtual open and external physical open. 39 * 40 * When the physical devices are opened by application, they will 41 * be unlinked from the virtual device and their data stream will 42 * not be sent to the virtual device. When the opened physical 43 * devices are closed, they will be relinked to the virtual devices. 44 * 45 * All these automatic switch between virtual and physical are 46 * transparent. 47 * 48 * So we change minor node numbering scheme to be: 49 * external node minor num == instance << 1 50 * internal node minor num == instance << 1 | 0x1 51 * (There are only internal nodes for keyboard/mouse now.) 52 */ 53 #define HID_MINOR_BITS_MASK 0x1 54 #define HID_MINOR_INSTANCE_MASK ~HID_MINOR_BITS_MASK 55 #define HID_MINOR_INSTANCE_SHIFT 1 56 57 #define HID_MINOR_INTERNAL 0x1 58 #define HID_MINOR_MAKE_INTERNAL(minor) \ 59 ((minor) | HID_MINOR_INTERNAL) 60 61 #define HID_IS_INTERNAL_OPEN(minor) \ 62 (((minor) & HID_MINOR_INTERNAL)) 63 64 #define HID_MINOR_TO_INSTANCE(minor) \ 65 (((minor) & HID_MINOR_INSTANCE_MASK) >> \ 66 HID_MINOR_INSTANCE_SHIFT) 67 68 #define HID_CONSTRUCT_INTERNAL_MINOR(inst) \ 69 (((inst) << HID_MINOR_INSTANCE_SHIFT) | \ 70 HID_MINOR_INTERNAL) 71 72 #define HID_CONSTRUCT_EXTERNAL_MINOR(inst) \ 73 ((inst) << HID_MINOR_INSTANCE_SHIFT) 74 75 #ifdef __cplusplus 76 } 77 #endif 78 79 #endif /* _SYS_USB_HIDMINOR_H */ 80