hidvar.h revision 5321cfb734b02bb580e9ecd9ec0e7f5e53571e23
1N/A/*
1N/A * CDDL HEADER START
1N/A *
1N/A * The contents of this file are subject to the terms of the
1N/A * Common Development and Distribution License (the "License").
1N/A * You may not use this file except in compliance with the License.
1N/A *
1N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1N/A * or http://www.opensolaris.org/os/licensing.
1N/A * See the License for the specific language governing permissions
1N/A * and limitations under the License.
1N/A *
1N/A * When distributing Covered Code, include this CDDL HEADER in each
1N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1N/A * If applicable, add the following below this CDDL HEADER, with the
1N/A * fields enclosed by brackets "[]" replaced with your own identifying
1N/A * information: Portions Copyright [yyyy] [name of copyright owner]
1N/A *
1N/A * CDDL HEADER END
1N/A */
1N/A
1N/A/*
1N/A * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
1N/A * Use is subject to license terms.
1N/A */
1N/A
1N/A#ifndef _SYS_USB_HIDVAR_H
1N/A#define _SYS_USB_HIDVAR_H
1N/A
1N/A
1N/A#ifdef __cplusplus
1N/Aextern "C" {
1N/A#endif
1N/A
1N/A#include <sys/usb/usba/usbai_private.h>
1N/A
1N/A/*
1N/A * HID : This header file contains the internal structures
1N/A * and variable definitions used in hid driver.
1N/A */
1N/A
1N/A/*
1N/A * HID USB device state management :
1N/A *
1N/A * ONLINE-----1--->SUSPENDED----2---->ONLINE
1N/A * |
1N/A * +-----3--->DISCONNECTED----4----->ONLINE
1N/A * |
1N/A * +-----7--->POWERED DOWN----8----->POWER CHANGE---9--->ONLINE
1N/A * |
1N/A * +---3--->DISCONNECTED
1N/A *
1N/A * POWERED DOWN----1--->SUSPENDED------2----->POWERED DOWN
1N/A * | | ^
1N/A * | 5 |
1N/A * | | 6
1N/A * | v |
1N/A * +---------3----->DISCONNECTED-------4----->POWERED DOWN
1N/A *
1N/A * 1 = CPR SUSPEND
1N/A * 2 = CPR RESUME (with original device)
1N/A * 3 = Device Unplug
1N/A * 4 = Original Device Plugged in
1N/A * 5 = CPR RESUME (with device disconnected or with a wrong device)
1N/A * 6 = CPR SUSPEND on a disconnected device
1N/A * 7 = Device idles for time T & transitions to low power state
1N/A * 8 = Remote wakeup by device OR Application kicking off IO to device
1N/A * This results in a Transistion state till PM calls the power
1N/A * entry point to raise the power level of the device
1N/A * 9 = Device entry point called to raise power level of the device
1N/A *
1N/A */
1N/A
1N/A
1N/A/* Boot Interface Subclass for HID devices */
1N/A#define BOOT_INTERFACE 0x01
1N/A
1N/A/* Boot protocol values for keyboard and mouse */
1N/A#define KEYBOARD_PROTOCOL 0x01 /* legacy keyboard */
1N/A#define MOUSE_PROTOCOL 0x02 /* legacy mouse */
1N/A#define NONE_PROTOCOL 0
1N/A/*
1N/A * If the hid descriptor is not valid, the following values are
1N/A * used.
1N/A */
1N/A#define USBKPSZ 8 /* keyboard packet size */
1N/A#define USBMSSZ 3 /* mouse packet size */
1N/A#define USB_KB_HID_DESCR_LENGTH 0x3f /* keyboard Report descr length */
1N/A#define USB_MS_HID_DESCR_LENGTH 0x32 /* mouse Report descr length */
1N/A
1N/A/*
1N/A * Flags for the default pipe.
1N/A */
1N/A#define HID_DEFAULT_PIPE_BUSY 0x01
1N/A
1N/A/*
1N/A * Hid interrupt pipe states. Interrupt pipe
1N/A * can be in only one of these states :
1N/A *
1N/A * open--1-->data_transferring--1-->open
1N/A * |
1N/A * |----2---->closed
1N/A *
1N/A * 1 = interrupt pipe callback
1N/A * 2 = hid_close
1N/A */
1N/A#define HID_INTERRUPT_PIPE_CLOSED 0x00 /* Int. pipe is closed */
1N/A#define HID_INTERRUPT_PIPE_OPEN 0x01 /* Int. pipe is opened */
1N/A
1N/A/* HID mctl processing return codes */
1N/A#define HID_SUCCESS 0 /* mctl processed successfully */
1N/A#define HID_INPROGRESS 1 /* mctl queued/deferred for execution */
1N/A#define HID_ENQUEUE 2 /* mctl queued/deferred for execution */
1N/A#define HID_FAILURE -1 /* mctl processing failed */
1N/A
1N/A/* Data is being sent up */
1N/A#define HID_INTERRUPT_PIPE_DATA_TRANSFERRING 0x03
1N/A
1N/A/* Attach/detach states */
1N/A#define HID_LOCK_INIT 0x01 /* Initial attach state */
1N/A#define HID_MINOR_NODES 0x02 /* Set after minor node is created */
1N/A
1N/A/* HID Protocol Requests */
1N/A#define SET_IDLE 0x0a /* bRequest value to set idle request */
1N/A#define DURATION (0<<8) /* no. of repeat reports (HID 7.2.4) */
1N/A#define SET_PROTOCOL 0x0b /* bRequest value for boot protocol */
1N/A
1N/A/* Hid PM scheme */
1N/Atypedef enum {
1N/A HID_PM_ACTIVITY, /* device is power managed by idleness */
1N/A HID_PM_OPEN_CLOSE, /* device is busy on open, idle on close */
1N/A HID_PM_APPLICATION /* device is power managed by application */
1N/A} hid_pm_scheme_t;
1N/A
1N/Atypedef struct hid_power {
1N/A
1N/A void *hid_state; /* points back to hid_state */
1N/A
1N/A int hid_pm_busy; /* device busy accounting */
1N/A
1N/A hid_pm_scheme_t hid_pm_strategy; /* device PM */
1N/A
1N/A uint8_t hid_wakeup_enabled;
1N/A
1N/A /* this is the bit mask of the power states that device has */
1N/A uint8_t hid_pwr_states;
1N/A
1N/A /* wakeup and power transistion capabilites of an interface */
1N/A uint8_t hid_pm_capabilities;
1N/A
1N/A /* flag to indicate if driver is about to raise power level */
1N/A boolean_t hid_raise_power;
1N/A
1N/A /* current power level the device is in */
1N/A uint8_t hid_current_power;
1N/A
1N/A /* mblk indicating that the device has powered up */
1N/A mblk_t *hid_pm_pwrup;
1N/A} hid_power_t;
1N/A
1N/A_NOTE(DATA_READABLE_WITHOUT_LOCK(hid_power_t::hid_state))
1N/A_NOTE(DATA_READABLE_WITHOUT_LOCK(hid_power_t::hid_pm_strategy))
1N/A_NOTE(DATA_READABLE_WITHOUT_LOCK(hid_power_t::hid_wakeup_enabled))
1N/A_NOTE(DATA_READABLE_WITHOUT_LOCK(hid_power_t::hid_pwr_states))
1N/A_NOTE(DATA_READABLE_WITHOUT_LOCK(hid_power_t::hid_pm_capabilities))
1N/A
1N/A/*
1N/A * multiple queue support
1N/A */
1N/Astruct hid_state;
1N/Atypedef struct hid_queue {
1N/A struct hid_state *hidq_statep;
1N/A queue_t *hidq_queue;
1N/A minor_t hidq_minor;
1N/A struct hid_queue *hidq_next;
1N/A} hid_queue_t;
1N/A
1N/Atypedef struct hid_state {
1N/A dev_info_t *hid_dip; /* per-device info handle */
1N/A kmutex_t hid_mutex; /* for general locking */
1N/A int hid_instance; /* instance number */
1N/A
1N/A /* Attach/detach flags */
1N/A int hid_attach_flags;
1N/A
1N/A /* device state flag */
1N/A int hid_dev_state;
1N/A
1N/A /* outstanding requests on the default pipe */
1N/A int hid_default_pipe_req;
1N/A
1N/A hid_power_t *hid_pm; /* ptr to power struct */
1N/A
1N/A usb_client_dev_data_t *hid_dev_data; /* ptr to usb reg struct */
1N/A
1N/A usb_dev_descr_t *hid_dev_descr; /* device descriptor. */
1N/A
1N/A /* hid driver is attached to this interface */
1N/A int hid_interfaceno;
1N/A
1N/A usb_if_descr_t hid_if_descr; /* interface descr */
1N/A usb_hid_descr_t hid_hid_descr; /* hid descriptor */
1N/A usb_ep_descr_t hid_ep_intr_descr;
1N/A hidparser_handle_t hid_report_descr; /* report descr */
1N/A
1N/A usb_pipe_handle_t hid_default_pipe; /* default pipe */
1N/A usb_pipe_handle_t hid_interrupt_pipe; /* intr pipe handle */
1N/A
1N/A int hid_streams_flags; /* see below */
1N/A int hid_packet_size; /* data packet size */
1N/A
1N/A /* Pipe policy for the interrupt pipe is saved here */
1N/A usb_pipe_policy_t hid_intr_pipe_policy;
1N/A
1N/A /*
1N/A * This field is only used if the device provides polled input
1N/A * This is state information for the usba layer.
1N/A */
1N/A usb_console_info_t hid_polled_console_info;
1N/A
1N/A /*
1N/A * This is the buffer that the raw characters are stored in.
1N/A * for polled mode.
1N/A */
1N/A uchar_t *hid_polled_raw_buf;
1N/A
1N/A /* handle for outputting messages */
1N/A usb_log_handle_t hid_log_handle;
1N/A
1N/A /*
1N/A * This is the list of STREAMS queues built upon the device. Only
1N/A * one queue on this list is active at any time - the list head.
1N/A * Once the active queue is closed, the next one on the list
1N/A * will be activated. The USB pipes will be closed if all queues
1N/A * have been closed.
1N/A */
1N/A hid_queue_t *hid_queue_list;
1N/A} hid_state_t;
1N/A
1N/A/* warlock directives, stable data */
1N/A_NOTE(MUTEX_PROTECTS_DATA(hid_state_t::hid_mutex, hid_state_t))
1N/A_NOTE(MUTEX_PROTECTS_DATA(hid_state_t::hid_mutex, hid_power_t))
1N/A_NOTE(DATA_READABLE_WITHOUT_LOCK(hid_state_t::hid_dip))
1N/A_NOTE(DATA_READABLE_WITHOUT_LOCK(hid_state_t::hid_pm))
1N/A_NOTE(DATA_READABLE_WITHOUT_LOCK(hid_state_t::hid_dev_data))
1N/A_NOTE(DATA_READABLE_WITHOUT_LOCK(hid_state_t::hid_instance))
1N/A_NOTE(DATA_READABLE_WITHOUT_LOCK(hid_state_t::hid_interrupt_pipe))
1N/A_NOTE(DATA_READABLE_WITHOUT_LOCK(hid_state_t::hid_ep_intr_descr))
1N/A_NOTE(DATA_READABLE_WITHOUT_LOCK(hid_state_t::hid_default_pipe))
1N/A_NOTE(DATA_READABLE_WITHOUT_LOCK(hid_state_t::hid_log_handle))
1N/A_NOTE(DATA_READABLE_WITHOUT_LOCK(hid_state_t::hid_if_descr))
1N/A_NOTE(DATA_READABLE_WITHOUT_LOCK(hid_state_t::hid_dev_data))
1N/A_NOTE(DATA_READABLE_WITHOUT_LOCK(hid_state_t::hid_dev_descr))
1N/A_NOTE(SCHEME_PROTECTS_DATA("stable data", usb_ep_descr))
1N/A_NOTE(SCHEME_PROTECTS_DATA("stable data", hid_queue_t::hidq_queue))
1N/A_NOTE(SCHEME_PROTECTS_DATA("stable data", hid_queue_t::hidq_statep))
1N/A_NOTE(SCHEME_PROTECTS_DATA("stable data", hid_queue_t::hidq_minor))
1N/A
1N/A
1N/A/*
1N/A * The hid_polled_console_info field is a handle from usba. The
1N/A * handle is used when the kernel is in the single thread mode
1N/A * so the field is tagged with this note.
1N/A */
1N/A_NOTE(SCHEME_PROTECTS_DATA("unique per call",
1N/A hid_state_t::hid_polled_console_info))
1N/A
1N/A/*
1N/A * structure for argument for callback routine for async
1N/A * data transfer through default pipe.
1N/A */
1N/Atypedef struct hid_default_pipe_argument {
1N/A /* Pointer to the write queue from which the message comes from */
1N/A queue_t *hid_default_pipe_arg_queue;
1N/A
1N/A /* Message to be sent up to the stream */
1N/A struct iocblk hid_default_pipe_arg_mctlmsg;
1N/A
1N/A /* Pointer to the original mblk_t received from hid_wput() */
1N/A mblk_t *hid_default_pipe_arg_mblk;
1N/A
1N/A /* Request that caused this callback to happen */
1N/A uchar_t hid_default_pipe_arg_bRequest;
1N/A
1N/A} hid_default_pipe_arg_t;
1N/A
1N/A/*
1N/A * An instance of this structure is created per command down to the
1N/A * device. The control callback is not executed until the call is
1N/A * made into usba, so there is no danger of a callback happening when
1N/A * the fields of the structure are being set.
1N/A */
1N/A_NOTE(SCHEME_PROTECTS_DATA("unique per call", hid_default_pipe_arg_t))
1N/A
1N/A/*
1N/A * An instance of this structure is created per command down to the
1N/A * device. The callback is not executed until the call is
1N/A * made into usba, so there is no danger of a callback happening when
1N/A * the fields of the structure are being set.
1N/A */
1N/A
1N/A/* Value for hid_streams_flags */
1N/A#define HID_STREAMS_OPEN 0x00000001 /* Streams are open */
1N/A#define HID_STREAMS_DISMANTLING 0x00000002 /* In hid_close() */
1N/A
1N/A#define HID_BAD_DESCR 0x01 /* Bad hid report descriptor */
1N/A
1N/A#define HID_MINOR_NAME_LEN 20 /* Max length of minor_name string */
1N/A
1N/A/* hid_close will wait 60 secons for callbacks to be over */
1N/A#define HID_CLOSE_WAIT_TIMEOUT 10
1N/A
1N/A/* define a timeout for draining requests on the default control pipe */
1N/A#define HID_DEFAULT_PIPE_DRAIN_TIMEOUT 5
1N/A
1N/A/* To support PM on SUN mice of later revisions */
1N/A#define HID_SUN_MOUSE_VENDOR_ID 0x0430
1N/A#define HID_SUN_MOUSE_PROD_ID 0x0100
1N/A#define HID_SUN_MOUSE_BCDDEVICE 0x0105 /* and later revisions */
1N/A
1N/A
1N/A/*
1N/A * Debug message Masks
1N/A */
1N/A#define PRINT_MASK_ATTA 0x00000001
1N/A#define PRINT_MASK_OPEN 0x00000002
1N/A#define PRINT_MASK_CLOSE 0x00000004
1N/A#define PRINT_MASK_EVENTS 0x00000008
1N/A#define PRINT_MASK_PM 0x00000010
1N/A#define PRINT_MASK_ALL 0xFFFFFFFF
1N/A
1N/A/*
1N/A * Define states local to hid driver
1N/A */
1N/A#define USB_DEV_HID_POWER_CHANGE 0x80
1N/A
1N/A/* define for retrying control requests */
1N/A#define HID_RETRY 10
1N/A
1N/A#ifdef __cplusplus
1N/A}
1N/A#endif
1N/A
1N/A#endif /* _SYS_USB_HIDVAR_H */
1N/A