17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5d5007c14Sqz * Common Development and Distribution License (the "License"). 6d5007c14Sqz * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*d29f5a71Szhigang lu - Sun Microsystems - Beijing China * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_USB_USBMS_H 277c478bd9Sstevel@tonic-gate #define _SYS_USB_USBMS_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifdef __cplusplus 327c478bd9Sstevel@tonic-gate extern "C" { 337c478bd9Sstevel@tonic-gate #endif 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate struct usbmouseinfo { 377c478bd9Sstevel@tonic-gate int mi_x; /* current X coordinate */ 387c478bd9Sstevel@tonic-gate int mi_y; /* current Y coordinate */ 397c478bd9Sstevel@tonic-gate int mi_z; /* current wheel */ 407c478bd9Sstevel@tonic-gate int mi_buttons; /* current button status */ 417c478bd9Sstevel@tonic-gate struct timeval32 mi_time; /* timestamp */ 427c478bd9Sstevel@tonic-gate }; 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate struct usbmousebuf { 457c478bd9Sstevel@tonic-gate ushort_t mb_size; /* size (in usbmouseinfo units) of buf */ 467c478bd9Sstevel@tonic-gate ushort_t mb_off; /* current offset in buffer */ 477c478bd9Sstevel@tonic-gate struct usbmouseinfo *mb_info; /* current usbmouseinfo */ 487c478bd9Sstevel@tonic-gate }; 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate typedef struct usbms_input { 517c478bd9Sstevel@tonic-gate uint_t xpos; /* X position in the sample info */ 527c478bd9Sstevel@tonic-gate uint_t xlen; /* length of X coordinate */ 537c478bd9Sstevel@tonic-gate uint_t xattr; /* attribute of X coordinate */ 547c478bd9Sstevel@tonic-gate uint_t ypos; /* Y position in the sample info */ 557c478bd9Sstevel@tonic-gate uint_t ylen; /* length of Y coordinate */ 567c478bd9Sstevel@tonic-gate uint_t yattr; /* attribute of Y coordinate */ 577c478bd9Sstevel@tonic-gate uint_t zpos; /* wheel data position in the sample info */ 587c478bd9Sstevel@tonic-gate uint_t zlen; /* length of wheel data */ 597c478bd9Sstevel@tonic-gate uint_t zattr; /* attribute of wheel data */ 607c478bd9Sstevel@tonic-gate uint_t bpos; /* button data position in the sample info */ 617c478bd9Sstevel@tonic-gate uint_t tlen; /* length of the sample info */ 627c478bd9Sstevel@tonic-gate } usbms_idf; 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate typedef struct usbms_state { 657c478bd9Sstevel@tonic-gate queue_t *usbms_rq_ptr; /* pointer to read queue */ 667c478bd9Sstevel@tonic-gate queue_t *usbms_wq_ptr; /* pointer to write queue */ 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* Flag for mouse open/qwait status */ 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate int usbms_flags; 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate /* 737c478bd9Sstevel@tonic-gate * Is an ioctl fails because an mblk wasn't 747c478bd9Sstevel@tonic-gate * available, the mlbk is saved here. 757c478bd9Sstevel@tonic-gate */ 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate mblk_t *usbms_iocpending; 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate /* mouse software structure from msreg.h */ 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate struct ms_softc usbms_softc; 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate /* Previous button byte */ 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate char usbms_oldbutt; 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate /* Report descriptor handle received from hid */ 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate hidparser_handle_t usbms_report_descr_handle; 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate /* 937c478bd9Sstevel@tonic-gate * Max pixel delta of jitter controlled. As this number increases 947c478bd9Sstevel@tonic-gate * the jumpiness of the msd increases, i.e., the coarser the motion 957c478bd9Sstevel@tonic-gate * for mediumm speeds. 967c478bd9Sstevel@tonic-gate * jitter_thresh is the maximum number of jitters suppressed. Thus, 977c478bd9Sstevel@tonic-gate * hz/jitter_thresh is the maximum interval of jitters suppressed. As 987c478bd9Sstevel@tonic-gate * jitter_thresh increases, a wider range of jitter is suppressed. 997c478bd9Sstevel@tonic-gate * However, the more inertia the mouse seems to have, i.e., the slower 1007c478bd9Sstevel@tonic-gate * the mouse is to react. 1017c478bd9Sstevel@tonic-gate */ 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate int usbms_jitter_thresh; 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate /* Timeout used when mstimeout in effect */ 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate clock_t usbms_jittertimeout; 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate /* 1107c478bd9Sstevel@tonic-gate * Measure how many (speed_count) msd deltas exceed threshold 1117c478bd9Sstevel@tonic-gate * (speedlimit). If speedlaw then throw away deltas over speedlimit. 1127c478bd9Sstevel@tonic-gate * This is to keep really bad mice that jump around from getting 1137c478bd9Sstevel@tonic-gate * too far. 1147c478bd9Sstevel@tonic-gate */ 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate /* Threshold above which deltas are thrown out */ 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate int usbms_speedlimit; 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate int usbms_speedlaw; /* Whether to throw away deltas */ 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate /* No. of deltas exceeding spd. limit */ 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate int usbms_speed_count; 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate int usbms_iocid; /* ID of "ioctl" being waited for */ 1277c478bd9Sstevel@tonic-gate short usbms_state; /* button state at last sample */ 1287c478bd9Sstevel@tonic-gate short usbms_jitter; /* state counter for input routine */ 1297c478bd9Sstevel@tonic-gate timeout_id_t usbms_timeout_id; /* id returned by timeout() */ 1307c478bd9Sstevel@tonic-gate bufcall_id_t usbms_reioctl_id; /* id returned by bufcall() */ 1317c478bd9Sstevel@tonic-gate bufcall_id_t usbms_resched_id; /* id returned by bufcall() */ 1327c478bd9Sstevel@tonic-gate int32_t usbms_num_buttons; /* No. of buttons */ 1337c478bd9Sstevel@tonic-gate int32_t usbms_num_wheels; /* No. of wheels */ 1347c478bd9Sstevel@tonic-gate uchar_t usbms_protoerr; /* Error set proto */ 1357c478bd9Sstevel@tonic-gate ushort_t usbms_wheel_state_bf; /* Wheel state bit field */ 1367c478bd9Sstevel@tonic-gate ushort_t usbms_wheel_orient_bf; /* Wheel orientation */ 1377c478bd9Sstevel@tonic-gate int32_t usbms_rptid; /* Report id of mouse app */ 1387c478bd9Sstevel@tonic-gate int32_t usbms_logical_Xmax; /* X logical maximum */ 1397c478bd9Sstevel@tonic-gate int32_t usbms_logical_Ymax; /* Y logical maximum */ 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate /* Screen resolution for absolute mouse */ 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate Ms_screen_resolution usbms_resolution; 1447c478bd9Sstevel@tonic-gate 145d5007c14Sqz /* report the abs mouse event to upper level once */ 146d5007c14Sqz 147d5007c14Sqz boolean_t usbms_rpt_abs; 148d5007c14Sqz 1497c478bd9Sstevel@tonic-gate usbms_idf usbms_idf; 1507c478bd9Sstevel@tonic-gate struct usbmousebuf *usbms_buf; 1517c478bd9Sstevel@tonic-gate } usbms_state_t; 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate #define USBMS_OPEN 0x00000001 /* mouse is open for business */ 1557c478bd9Sstevel@tonic-gate #define USBMS_QWAIT 0x00000002 /* mouse is waiting for a response */ 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate /* Macro to find absolute value */ 1587c478bd9Sstevel@tonic-gate 1597c478bd9Sstevel@tonic-gate #define USB_ABS(x) ((x) < 0 ? -(x) : (x)) 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate /* 1627c478bd9Sstevel@tonic-gate * Macro to restrict the value of x to lie between 127 & -127 : 1637c478bd9Sstevel@tonic-gate * if x > 127 return 127 1647c478bd9Sstevel@tonic-gate * else if x < -127 return -127 1657c478bd9Sstevel@tonic-gate * else return x 1667c478bd9Sstevel@tonic-gate */ 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate #define USB_BYTECLIP(x) (char)((x) > 127 ? 127 : ((x) < -127 ? -127 : (x))) 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate /* 1710fc2d926Sqz * Default and MAX (supported) number of buttons 1727c478bd9Sstevel@tonic-gate */ 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate #define USB_MS_DEFAULT_BUTTON_NO 3 1750fc2d926Sqz #define USB_MS_MAX_BUTTON_NO 8 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate 1787c478bd9Sstevel@tonic-gate /* 1797c478bd9Sstevel@tonic-gate * Input routine states. See usbms_input(). 1807c478bd9Sstevel@tonic-gate */ 1817c478bd9Sstevel@tonic-gate #define USBMS_WAIT_BUTN 0 /* Button byte */ 1827c478bd9Sstevel@tonic-gate #define USBMS_WAIT_X 1 /* Delta X byte */ 1837c478bd9Sstevel@tonic-gate #define USBMS_WAIT_Y 2 /* Delta Y byte */ 1847c478bd9Sstevel@tonic-gate #define USBMS_WAIT_WHEEL 3 /* Wheel Byte */ 1857c478bd9Sstevel@tonic-gate 186d5007c14Sqz 1877c478bd9Sstevel@tonic-gate /* 1887c478bd9Sstevel@tonic-gate * default resolution, 1024x768. 1897c478bd9Sstevel@tonic-gate */ 1907c478bd9Sstevel@tonic-gate #define USBMS_DEFAULT_RES_HEIGHT 768 1917c478bd9Sstevel@tonic-gate #define USBMS_DEFAULT_RES_WIDTH 1024 1927c478bd9Sstevel@tonic-gate /* 1937c478bd9Sstevel@tonic-gate * USB buttons: 1947c478bd9Sstevel@tonic-gate * How the device sends it: 1957c478bd9Sstevel@tonic-gate * 0x01 - Left button position 1967c478bd9Sstevel@tonic-gate * 0x02 - Right button position 1977c478bd9Sstevel@tonic-gate * 0x04 - Middle button position 1987c478bd9Sstevel@tonic-gate */ 1997c478bd9Sstevel@tonic-gate 2007c478bd9Sstevel@tonic-gate 2017c478bd9Sstevel@tonic-gate #define USBMS_BUT(i) 1 << (i - 1) 2027c478bd9Sstevel@tonic-gate 2037c478bd9Sstevel@tonic-gate /* 2047c478bd9Sstevel@tonic-gate * These defines are for converting USB button information to the 2057c478bd9Sstevel@tonic-gate * format that Type 5 mouse sends upstream, which is what the xserver 2067c478bd9Sstevel@tonic-gate * expects. 2077c478bd9Sstevel@tonic-gate */ 2087c478bd9Sstevel@tonic-gate 2097c478bd9Sstevel@tonic-gate #define USB_NO_BUT_PRESSED 0xFF 2107c478bd9Sstevel@tonic-gate #define USB_LEFT_BUT_PRESSED 0xFB 2117c478bd9Sstevel@tonic-gate #define USB_RIGHT_BUT_PRESSED 0xFE 2127c478bd9Sstevel@tonic-gate #define USB_MIDDLE_BUT_PRESSED 0xFD 2137c478bd9Sstevel@tonic-gate 2147c478bd9Sstevel@tonic-gate #define USB_BUT_PRESSED(i) ~(1 << (i - 1)) 2157c478bd9Sstevel@tonic-gate 2167c478bd9Sstevel@tonic-gate /* 2177c478bd9Sstevel@tonic-gate * State structure used for transparent ioctls 2187c478bd9Sstevel@tonic-gate */ 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate typedef struct usbms_iocstate { 2217c478bd9Sstevel@tonic-gate int ioc_state; 2227c478bd9Sstevel@tonic-gate caddr_t u_addr; 2237c478bd9Sstevel@tonic-gate } usbms_iocstate_t; 2247c478bd9Sstevel@tonic-gate 2257c478bd9Sstevel@tonic-gate /* 2267c478bd9Sstevel@tonic-gate * Transparent ioctl states 2277c478bd9Sstevel@tonic-gate */ 2287c478bd9Sstevel@tonic-gate 2297c478bd9Sstevel@tonic-gate #define USBMS_GETSTRUCT 1 2307c478bd9Sstevel@tonic-gate #define USBMS_GETRESULT 2 2317c478bd9Sstevel@tonic-gate 2327c478bd9Sstevel@tonic-gate /* 2337c478bd9Sstevel@tonic-gate * Private data are initialized to these values 2347c478bd9Sstevel@tonic-gate */ 2357c478bd9Sstevel@tonic-gate #define USBMS_JITTER_THRESH 0 /* Max no. of jitters suppressed */ 2367c478bd9Sstevel@tonic-gate #define USBMS_SPEEDLIMIT 48 /* Threshold for msd deltas */ 2377c478bd9Sstevel@tonic-gate #define USBMS_SPEEDLAW 0 /* Whether to throw away deltas */ 2387c478bd9Sstevel@tonic-gate #define USBMS_SPEED_COUNT 0 /* No. of deltas exceeding spd. limit */ 2397c478bd9Sstevel@tonic-gate #define USBMS_BUF_BYTES 4096 /* Mouse buffer size */ 2407c478bd9Sstevel@tonic-gate #define USBMS_USAGE_PAGE_BUTTON 0x9 /* Usage Page data value : Button */ 2417c478bd9Sstevel@tonic-gate 2427c478bd9Sstevel@tonic-gate #define JITTERRATE 12 /* No of jitters before timeout */ 2437c478bd9Sstevel@tonic-gate 2447c478bd9Sstevel@tonic-gate /* Jitter Timeout while initialization */ 2457c478bd9Sstevel@tonic-gate #define JITTER_TIMEOUT (hz/JITTERRATE) 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate /* 2487c478bd9Sstevel@tonic-gate * Masks for debug printing 2497c478bd9Sstevel@tonic-gate */ 2507c478bd9Sstevel@tonic-gate #define PRINT_MASK_ATTA 0x00000001 2517c478bd9Sstevel@tonic-gate #define PRINT_MASK_OPEN 0x00000002 2527c478bd9Sstevel@tonic-gate #define PRINT_MASK_CLOSE 0x00000004 2537c478bd9Sstevel@tonic-gate #define PRINT_MASK_SERV 0x00000008 2547c478bd9Sstevel@tonic-gate #define PRINT_MASK_IOCTL 0x00000010 2557c478bd9Sstevel@tonic-gate #define PRINT_MASK_INPUT_INCR 0x00000020 2567c478bd9Sstevel@tonic-gate #define PRINT_MASK_ALL 0xFFFFFFFF 2577c478bd9Sstevel@tonic-gate 2587c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2597c478bd9Sstevel@tonic-gate } 2607c478bd9Sstevel@tonic-gate #endif 2617c478bd9Sstevel@tonic-gate 2627c478bd9Sstevel@tonic-gate #endif /* _SYS_USB_USBMS_H */ 263