Template Version: @(#)sac_nextcase 1.68 02/23/09 SMI This information is Copyright 2009 Sun Microsystems 1. Introduction 1.1. Project/Component Working Name: HIDIOCKM[GS]DIRECT ioctls for the USB HID driver 1.2. Name of Document Author/Supplier: Author: Aaron Zang 1.3 Date of This Document: 31 May, 2009 4. Technical Description HIDIOCKM[GS]DIRECT ioctls for the USB HID driver
1. Introduction 1.1 Project/Component Working Name: HIDIOCKM[GS]DIRECT ioctls for the USB HID driver 1.2 Name of Document Author/Supplier: Aaron Zang 1.3 Date of This Document: 05/25/09 2. Background The USB HID STREAMS driver exports 2 device nodes for each USB keyboard/mouse device instance. One is for the internal use of kernel under the name of "internal-keyboard" or "internal-mouse". The other is for the external use of user land applications under the name of "keyboard" or "mouse". If a keyboard/mouse device node is opened, a stream is established for the I/O of that node. The relationship of the internal node (stream), external node (stream), virtual keyboard mouse, console and applications are shown by the below diagram. "/dev/console" "/dev/kbd" "/dev/usb/hid%d" "/dev/vt/%d" "/dev/mouse" | | | Uesr Land ----------+---------+-----------+-------------- | | | Kernel +---------+ | | | console | | | +----+----+ | | | | | +----+---------+--+ | | virtual keyboard| | | mouse | | +----------+------+ | <--- (HID external stream) | | | | +---------+ | | | (HID interal stream) ---> | | +--------+--+ | HID | +-----------+ >From the diagram we can see, the internal stream is used by console. The external stream is used by applications which open the "/dev/usb/hid%d" device nodes directly. Since XOrg 1.5, the XOrg server opens hid deivces (/dev/usb/hid%d) by default instead of "/dev/kbd" or "/dev/mouse". Even before XOrg 1.5, it still can be configured to open the hid devices directly. 3. Problem When both of the internal and external node are opened, 2 streams are set up for both of them. But only one can get the the input from the hardware at one time. The internal stream usually gets the input first since the conskbd (virtual keyboard) driver opens the internal node when system boots. The current solution is that the input goes to the external stream when the external node is opened by some application, and the input gets switched back to the internal stream when the external stream was disassembled. When working on the XOrg support for Solaris Virtual Console, the project team found the console would lose input if switched back from one of the X sessions. It is because the XOrg server still opens the HID external node which causes the input still direct to the external stream. 4. Proposal To solve the above problem, two new HID ioctls are introduced: Exported Interface Stability Comments Name Classification ------------------ -------------- ---------- HIDIOCKMGDIRECT Committed See hid.7D HIDIOCKMSDIRECT Committed See hid.7D HIDIOCKMGDIRECT is used to get the information of which stream gets the input at the moment. A return value of 0 means the internal stream gets the input, and a return value of 1 means the external stream gets the input. HIDIOCKMSDIRECT is used to set the directing of the streams. An argument of 0 directs the input to the internal stream and an argument of 1 directs the input to the external stream. The existing behavior remains by the lasted opened stream gets the input automatically. 5. References PSARC/2006/591 Virtual Console PSARC/2004/717 Virtual Keyboard/Mouse hid(7D) 6. Resources and Schedule 6.4. Steering Committee requested information 6.4.1. Consolidation C-team Name: ON 6.5. ARC review type: FastTrack 6.6. ARC Exposure: open