hidvar.h revision 0fc2d9264767f09b82ca39f5ca9eaa84137a5f27
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_USB_HIDVAR_H
#define _SYS_USB_HIDVAR_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/*
* HID : This header file contains the internal structures
* and variable definitions used in hid driver.
*/
/*
* HID USB device state management :
*
* ONLINE-----1--->SUSPENDED----2---->ONLINE
* |
* +-----3--->DISCONNECTED----4----->ONLINE
* |
* +-----7--->POWERED DOWN----8----->POWER CHANGE---9--->ONLINE
* |
* +---3--->DISCONNECTED
*
* POWERED DOWN----1--->SUSPENDED------2----->POWERED DOWN
* | | ^
* | 5 |
* | | 6
* | v |
* +---------3----->DISCONNECTED-------4----->POWERED DOWN
*
* 1 = CPR SUSPEND
* 2 = CPR RESUME (with original device)
* 3 = Device Unplug
* 4 = Original Device Plugged in
* 5 = CPR RESUME (with device disconnected or with a wrong device)
* 6 = CPR SUSPEND on a disconnected device
* 7 = Device idles for time T & transitions to low power state
* 8 = Remote wakeup by device OR Application kicking off IO to device
* This results in a Transistion state till PM calls the power
* entry point to raise the power level of the device
* 9 = Device entry point called to raise power level of the device
*
*/
/* Boot Interface Subclass for HID devices */
#define BOOT_INTERFACE 0x01
/* Boot protocol values for keyboard and mouse */
#define NONE_PROTOCOL 0
/*
* If the hid descriptor is not valid, the following values are
* used.
*/
/*
* Flags for the default pipe.
*/
#define HID_DEFAULT_PIPE_BUSY 0x01
/*
* Hid interrupt pipe states. Interrupt pipe
* can be in only one of these states :
*
* open--1-->data_transferring--1-->open
* |
* |----2---->closed
*
* 1 = interrupt pipe callback
* 2 = hid_close
*/
/* HID mctl processing return codes */
#define HID_SUCCESS 0 /* mctl processed successfully */
/* Data is being sent up */
#define HID_INTERRUPT_PIPE_DATA_TRANSFERRING 0x03
/* HID Protocol Requests */
/* Hid PM scheme */
typedef enum {
HID_PM_ACTIVITY, /* device is power managed by idleness */
HID_PM_OPEN_CLOSE, /* device is busy on open, idle on close */
HID_PM_APPLICATION /* device is power managed by application */
typedef struct hid_power {
void *hid_state; /* points back to hid_state */
int hid_pm_busy; /* device busy accounting */
/* this is the bit mask of the power states that device has */
/* wakeup and power transistion capabilites of an interface */
/* flag to indicate if driver is about to raise power level */
/* current power level the device is in */
/* mblk indicating that the device has powered up */
} hid_power_t;
typedef struct hid_state {
int hid_instance; /* instance number */
int hid_attach_flags;
/* device state flag */
int hid_dev_state;
/* outstanding requests on the default pipe */
int hid_default_pipe_req;
/* hid driver is attached to this interface */
int hid_interfaceno;
int hid_streams_flags; /* see below */
int hid_packet_size; /* data packet size */
/* Pipe policy for the interrupt pipe is saved here */
/*
* This field is only used if the device provides polled input
* This is state information for the usba layer.
*/
/*
* This is the buffer that the raw characters are stored in.
* for polled mode.
*/
/* handle for outputting messages */
} hid_state_t;
/* warlock directives, stable data */
/*
* The hid_polled_console_info field is a handle from usba. The
* handle is used when the kernel is in the single thread mode
* so the field is tagged with this note.
*/
/*
* structure for argument for callback routine for async
* data transfer through default pipe.
*/
typedef struct hid_default_pipe_argument {
/* Message to be sent up to the stream */
struct iocblk hid_default_pipe_arg_mctlmsg;
/* Pointer to hid_state structure */
/* Pointer to the original mblk_t received from hid_wput() */
/* Request that caused this callback to happen */
/*
* An instance of this structure is created per command down to the
* device. The control callback is not executed until the call is
* made into usba, so there is no danger of a callback happening when
* the fields of the structure are being set.
*/
/*
* An instance of this structure is created per command down to the
* device. The callback is not executed until the call is
* made into usba, so there is no danger of a callback happening when
* the fields of the structure are being set.
*/
/* Value for hid_streams_flags */
/* hid_close will wait 60 secons for callbacks to be over */
#define HID_CLOSE_WAIT_TIMEOUT 10
/* define a timeout for draining requests on the default control pipe */
#define HID_DEFAULT_PIPE_DRAIN_TIMEOUT 5
/* To support PM on SUN mice of later revisions */
#define HID_SUN_MOUSE_VENDOR_ID 0x0430
#define HID_SUN_MOUSE_PROD_ID 0x0100
/*
* Debug message Masks
*/
#define PRINT_MASK_ATTA 0x00000001
#define PRINT_MASK_OPEN 0x00000002
#define PRINT_MASK_CLOSE 0x00000004
#define PRINT_MASK_EVENTS 0x00000008
#define PRINT_MASK_PM 0x00000010
#define PRINT_MASK_ALL 0xFFFFFFFF
/*
* Define states local to hid driver
*/
#define USB_DEV_HID_POWER_CHANGE 0x80
/* define for retrying control requests */
#define HID_RETRY 10
#ifdef __cplusplus
}
#endif
#endif /* _SYS_USB_HIDVAR_H */