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 51662Sqz150045 * Common Development and Distribution License (the "License"). 61662Sqz150045 * 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_USBMS_H 270Sstevel@tonic-gate #define _SYS_USB_USBMS_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate 300Sstevel@tonic-gate 310Sstevel@tonic-gate #ifdef __cplusplus 320Sstevel@tonic-gate extern "C" { 330Sstevel@tonic-gate #endif 340Sstevel@tonic-gate 350Sstevel@tonic-gate 360Sstevel@tonic-gate struct usbmouseinfo { 370Sstevel@tonic-gate int mi_x; /* current X coordinate */ 380Sstevel@tonic-gate int mi_y; /* current Y coordinate */ 390Sstevel@tonic-gate int mi_z; /* current wheel */ 400Sstevel@tonic-gate int mi_buttons; /* current button status */ 410Sstevel@tonic-gate struct timeval32 mi_time; /* timestamp */ 420Sstevel@tonic-gate }; 430Sstevel@tonic-gate 440Sstevel@tonic-gate struct usbmousebuf { 450Sstevel@tonic-gate ushort_t mb_size; /* size (in usbmouseinfo units) of buf */ 460Sstevel@tonic-gate ushort_t mb_off; /* current offset in buffer */ 470Sstevel@tonic-gate struct usbmouseinfo *mb_info; /* current usbmouseinfo */ 480Sstevel@tonic-gate }; 490Sstevel@tonic-gate 500Sstevel@tonic-gate typedef struct usbms_input { 510Sstevel@tonic-gate uint_t xpos; /* X position in the sample info */ 520Sstevel@tonic-gate uint_t xlen; /* length of X coordinate */ 530Sstevel@tonic-gate uint_t xattr; /* attribute of X coordinate */ 540Sstevel@tonic-gate uint_t ypos; /* Y position in the sample info */ 550Sstevel@tonic-gate uint_t ylen; /* length of Y coordinate */ 560Sstevel@tonic-gate uint_t yattr; /* attribute of Y coordinate */ 570Sstevel@tonic-gate uint_t zpos; /* wheel data position in the sample info */ 580Sstevel@tonic-gate uint_t zlen; /* length of wheel data */ 590Sstevel@tonic-gate uint_t zattr; /* attribute of wheel data */ 600Sstevel@tonic-gate uint_t bpos; /* button data position in the sample info */ 610Sstevel@tonic-gate uint_t tlen; /* length of the sample info */ 620Sstevel@tonic-gate } usbms_idf; 630Sstevel@tonic-gate 640Sstevel@tonic-gate typedef struct usbms_state { 650Sstevel@tonic-gate queue_t *usbms_rq_ptr; /* pointer to read queue */ 660Sstevel@tonic-gate queue_t *usbms_wq_ptr; /* pointer to write queue */ 670Sstevel@tonic-gate 680Sstevel@tonic-gate /* Flag for mouse open/qwait status */ 690Sstevel@tonic-gate 700Sstevel@tonic-gate int usbms_flags; 710Sstevel@tonic-gate 720Sstevel@tonic-gate /* 730Sstevel@tonic-gate * Is an ioctl fails because an mblk wasn't 740Sstevel@tonic-gate * available, the mlbk is saved here. 750Sstevel@tonic-gate */ 760Sstevel@tonic-gate 770Sstevel@tonic-gate mblk_t *usbms_iocpending; 780Sstevel@tonic-gate 790Sstevel@tonic-gate /* mouse software structure from msreg.h */ 800Sstevel@tonic-gate 810Sstevel@tonic-gate struct ms_softc usbms_softc; 820Sstevel@tonic-gate 830Sstevel@tonic-gate /* Previous button byte */ 840Sstevel@tonic-gate 850Sstevel@tonic-gate char usbms_oldbutt; 860Sstevel@tonic-gate 870Sstevel@tonic-gate 880Sstevel@tonic-gate /* Report descriptor handle received from hid */ 890Sstevel@tonic-gate 900Sstevel@tonic-gate hidparser_handle_t usbms_report_descr_handle; 910Sstevel@tonic-gate 920Sstevel@tonic-gate /* 930Sstevel@tonic-gate * Max pixel delta of jitter controlled. As this number increases 940Sstevel@tonic-gate * the jumpiness of the msd increases, i.e., the coarser the motion 950Sstevel@tonic-gate * for mediumm speeds. 960Sstevel@tonic-gate * jitter_thresh is the maximum number of jitters suppressed. Thus, 970Sstevel@tonic-gate * hz/jitter_thresh is the maximum interval of jitters suppressed. As 980Sstevel@tonic-gate * jitter_thresh increases, a wider range of jitter is suppressed. 990Sstevel@tonic-gate * However, the more inertia the mouse seems to have, i.e., the slower 1000Sstevel@tonic-gate * the mouse is to react. 1010Sstevel@tonic-gate */ 1020Sstevel@tonic-gate 1030Sstevel@tonic-gate int usbms_jitter_thresh; 1040Sstevel@tonic-gate 1050Sstevel@tonic-gate /* Timeout used when mstimeout in effect */ 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate clock_t usbms_jittertimeout; 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate /* 1100Sstevel@tonic-gate * Measure how many (speed_count) msd deltas exceed threshold 1110Sstevel@tonic-gate * (speedlimit). If speedlaw then throw away deltas over speedlimit. 1120Sstevel@tonic-gate * This is to keep really bad mice that jump around from getting 1130Sstevel@tonic-gate * too far. 1140Sstevel@tonic-gate */ 1150Sstevel@tonic-gate 1160Sstevel@tonic-gate /* Threshold above which deltas are thrown out */ 1170Sstevel@tonic-gate 1180Sstevel@tonic-gate int usbms_speedlimit; 1190Sstevel@tonic-gate 1200Sstevel@tonic-gate int usbms_speedlaw; /* Whether to throw away deltas */ 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate /* No. of deltas exceeding spd. limit */ 1230Sstevel@tonic-gate 1240Sstevel@tonic-gate int usbms_speed_count; 1250Sstevel@tonic-gate 1260Sstevel@tonic-gate int usbms_iocid; /* ID of "ioctl" being waited for */ 1270Sstevel@tonic-gate short usbms_state; /* button state at last sample */ 1280Sstevel@tonic-gate short usbms_jitter; /* state counter for input routine */ 1290Sstevel@tonic-gate timeout_id_t usbms_timeout_id; /* id returned by timeout() */ 1300Sstevel@tonic-gate bufcall_id_t usbms_reioctl_id; /* id returned by bufcall() */ 1310Sstevel@tonic-gate bufcall_id_t usbms_resched_id; /* id returned by bufcall() */ 1320Sstevel@tonic-gate int32_t usbms_num_buttons; /* No. of buttons */ 1330Sstevel@tonic-gate int32_t usbms_num_wheels; /* No. of wheels */ 1340Sstevel@tonic-gate uchar_t usbms_protoerr; /* Error set proto */ 1350Sstevel@tonic-gate ushort_t usbms_wheel_state_bf; /* Wheel state bit field */ 1360Sstevel@tonic-gate ushort_t usbms_wheel_orient_bf; /* Wheel orientation */ 1370Sstevel@tonic-gate int32_t usbms_rptid; /* Report id of mouse app */ 1380Sstevel@tonic-gate int32_t usbms_logical_Xmax; /* X logical maximum */ 1390Sstevel@tonic-gate int32_t usbms_logical_Ymax; /* Y logical maximum */ 1400Sstevel@tonic-gate 1410Sstevel@tonic-gate /* Screen resolution for absolute mouse */ 1420Sstevel@tonic-gate 1430Sstevel@tonic-gate Ms_screen_resolution usbms_resolution; 1440Sstevel@tonic-gate 1451662Sqz150045 /* report the abs mouse event to upper level once */ 1461662Sqz150045 1471662Sqz150045 boolean_t usbms_rpt_abs; 1481662Sqz150045 1490Sstevel@tonic-gate usbms_idf usbms_idf; 1500Sstevel@tonic-gate struct usbmousebuf *usbms_buf; 1510Sstevel@tonic-gate } usbms_state_t; 1520Sstevel@tonic-gate 1530Sstevel@tonic-gate 1540Sstevel@tonic-gate #define USBMS_OPEN 0x00000001 /* mouse is open for business */ 1550Sstevel@tonic-gate #define USBMS_QWAIT 0x00000002 /* mouse is waiting for a response */ 1560Sstevel@tonic-gate 1570Sstevel@tonic-gate /* Macro to find absolute value */ 1580Sstevel@tonic-gate 1590Sstevel@tonic-gate #define USB_ABS(x) ((x) < 0 ? -(x) : (x)) 1600Sstevel@tonic-gate 1610Sstevel@tonic-gate /* 1620Sstevel@tonic-gate * Macro to restrict the value of x to lie between 127 & -127 : 1630Sstevel@tonic-gate * if x > 127 return 127 1640Sstevel@tonic-gate * else if x < -127 return -127 1650Sstevel@tonic-gate * else return x 1660Sstevel@tonic-gate */ 1670Sstevel@tonic-gate 1680Sstevel@tonic-gate #define USB_BYTECLIP(x) (char)((x) > 127 ? 127 : ((x) < -127 ? -127 : (x))) 1690Sstevel@tonic-gate 1700Sstevel@tonic-gate /* 1711418Sqz150045 * Default and MAX (supported) number of buttons 1720Sstevel@tonic-gate */ 1730Sstevel@tonic-gate 1740Sstevel@tonic-gate #define USB_MS_DEFAULT_BUTTON_NO 3 1751418Sqz150045 #define USB_MS_MAX_BUTTON_NO 8 1760Sstevel@tonic-gate 1770Sstevel@tonic-gate 1780Sstevel@tonic-gate /* 1790Sstevel@tonic-gate * Input routine states. See usbms_input(). 1800Sstevel@tonic-gate */ 1810Sstevel@tonic-gate #define USBMS_WAIT_BUTN 0 /* Button byte */ 1820Sstevel@tonic-gate #define USBMS_WAIT_X 1 /* Delta X byte */ 1830Sstevel@tonic-gate #define USBMS_WAIT_Y 2 /* Delta Y byte */ 1840Sstevel@tonic-gate #define USBMS_WAIT_WHEEL 3 /* Wheel Byte */ 1850Sstevel@tonic-gate 1861662Sqz150045 1870Sstevel@tonic-gate /* 1880Sstevel@tonic-gate * default resolution, 1024x768. 1890Sstevel@tonic-gate */ 1900Sstevel@tonic-gate #define USBMS_DEFAULT_RES_HEIGHT 768 1910Sstevel@tonic-gate #define USBMS_DEFAULT_RES_WIDTH 1024 1920Sstevel@tonic-gate /* 1930Sstevel@tonic-gate * USB buttons: 1940Sstevel@tonic-gate * How the device sends it: 1950Sstevel@tonic-gate * 0x01 - Left button position 1960Sstevel@tonic-gate * 0x02 - Right button position 1970Sstevel@tonic-gate * 0x04 - Middle button position 1980Sstevel@tonic-gate */ 1990Sstevel@tonic-gate 2000Sstevel@tonic-gate 2010Sstevel@tonic-gate #define USBMS_BUT(i) 1 << (i - 1) 2020Sstevel@tonic-gate 2030Sstevel@tonic-gate /* 2040Sstevel@tonic-gate * These defines are for converting USB button information to the 2050Sstevel@tonic-gate * format that Type 5 mouse sends upstream, which is what the xserver 2060Sstevel@tonic-gate * expects. 2070Sstevel@tonic-gate */ 2080Sstevel@tonic-gate 2090Sstevel@tonic-gate #define USB_NO_BUT_PRESSED 0xFF 2100Sstevel@tonic-gate #define USB_LEFT_BUT_PRESSED 0xFB 2110Sstevel@tonic-gate #define USB_RIGHT_BUT_PRESSED 0xFE 2120Sstevel@tonic-gate #define USB_MIDDLE_BUT_PRESSED 0xFD 2130Sstevel@tonic-gate 2140Sstevel@tonic-gate #define USB_BUT_PRESSED(i) ~(1 << (i - 1)) 2150Sstevel@tonic-gate 2160Sstevel@tonic-gate /* 2170Sstevel@tonic-gate * State structure used for transparent ioctls 2180Sstevel@tonic-gate */ 2190Sstevel@tonic-gate 2200Sstevel@tonic-gate typedef struct usbms_iocstate { 2210Sstevel@tonic-gate int ioc_state; 2220Sstevel@tonic-gate caddr_t u_addr; 2230Sstevel@tonic-gate } usbms_iocstate_t; 2240Sstevel@tonic-gate 2250Sstevel@tonic-gate /* 2260Sstevel@tonic-gate * Transparent ioctl states 2270Sstevel@tonic-gate */ 2280Sstevel@tonic-gate 2290Sstevel@tonic-gate #define USBMS_GETSTRUCT 1 2300Sstevel@tonic-gate #define USBMS_GETRESULT 2 2310Sstevel@tonic-gate 2320Sstevel@tonic-gate /* 2330Sstevel@tonic-gate * Private data are initialized to these values 2340Sstevel@tonic-gate */ 2350Sstevel@tonic-gate #define USBMS_JITTER_THRESH 0 /* Max no. of jitters suppressed */ 2360Sstevel@tonic-gate #define USBMS_SPEEDLIMIT 48 /* Threshold for msd deltas */ 2370Sstevel@tonic-gate #define USBMS_SPEEDLAW 0 /* Whether to throw away deltas */ 2380Sstevel@tonic-gate #define USBMS_SPEED_COUNT 0 /* No. of deltas exceeding spd. limit */ 2390Sstevel@tonic-gate #define USBMS_BUF_BYTES 4096 /* Mouse buffer size */ 2400Sstevel@tonic-gate #define USBMS_USAGE_PAGE_BUTTON 0x9 /* Usage Page data value : Button */ 2410Sstevel@tonic-gate 2420Sstevel@tonic-gate #define JITTERRATE 12 /* No of jitters before timeout */ 2430Sstevel@tonic-gate 2440Sstevel@tonic-gate /* Jitter Timeout while initialization */ 2450Sstevel@tonic-gate #define JITTER_TIMEOUT (hz/JITTERRATE) 2460Sstevel@tonic-gate 2470Sstevel@tonic-gate /* 2480Sstevel@tonic-gate * Masks for debug printing 2490Sstevel@tonic-gate */ 2500Sstevel@tonic-gate #define PRINT_MASK_ATTA 0x00000001 2510Sstevel@tonic-gate #define PRINT_MASK_OPEN 0x00000002 2520Sstevel@tonic-gate #define PRINT_MASK_CLOSE 0x00000004 2530Sstevel@tonic-gate #define PRINT_MASK_SERV 0x00000008 2540Sstevel@tonic-gate #define PRINT_MASK_IOCTL 0x00000010 2550Sstevel@tonic-gate #define PRINT_MASK_INPUT_INCR 0x00000020 2560Sstevel@tonic-gate #define PRINT_MASK_ALL 0xFFFFFFFF 2570Sstevel@tonic-gate 2580Sstevel@tonic-gate #ifdef __cplusplus 2590Sstevel@tonic-gate } 2600Sstevel@tonic-gate #endif 2610Sstevel@tonic-gate 2620Sstevel@tonic-gate #endif /* _SYS_USB_USBMS_H */ 263