~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/hid/tests/test_ite_keyboard.py

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/env python3
  2 # SPDX-License-Identifier: GPL-2.0
  3 # -*- coding: utf-8 -*-
  4 #
  5 # Copyright (c) 2020 Benjamin Tissoires <benjamin.tissoires@gmail.com>
  6 # Copyright (c) 2020 Red Hat, Inc.
  7 #
  8 
  9 from .test_keyboard import ArrayKeyboard, TestArrayKeyboard
 10 from hidtools.util import BusType
 11 
 12 import libevdev
 13 import logging
 14 
 15 logger = logging.getLogger("hidtools.test.ite-keyboard")
 16 
 17 KERNEL_MODULE = ("itetech", "hid_ite")
 18 
 19 
 20 class KbdData(object):
 21     pass
 22 
 23 
 24 # The ITE keyboards have an issue regarding the Wifi key:
 25 # nothing comes in when pressing the key, but we get a null
 26 # event on the key release.
 27 # This test covers this case.
 28 class ITEKeyboard(ArrayKeyboard):
 29     # fmt: off
 30     report_descriptor = [
 31         0x06, 0x85, 0xff,              # Usage Page (Vendor Usage Page 0xff85)
 32         0x09, 0x95,                    # Usage (Vendor Usage 0x95)           3
 33         0xa1, 0x01,                    # Collection (Application)            5
 34         0x85, 0x5a,                    # .Report ID (90)                     7
 35         0x09, 0x01,                    # .Usage (Vendor Usage 0x01)          9
 36         0x15, 0x00,                    # .Logical Minimum (0)                11
 37         0x26, 0xff, 0x00,              # .Logical Maximum (255)              13
 38         0x75, 0x08,                    # .Report Size (8)                    16
 39         0x95, 0x10,                    # .Report Count (16)                  18
 40         0xb1, 0x00,                    # .Feature (Data,Arr,Abs)             20
 41         0xc0,                          # End Collection                      22
 42         0x05, 0x01,                    # Usage Page (Generic Desktop)        23
 43         0x09, 0x06,                    # Usage (Keyboard)                    25
 44         0xa1, 0x01,                    # Collection (Application)            27
 45         0x85, 0x01,                    # .Report ID (1)                      29
 46         0x75, 0x01,                    # .Report Size (1)                    31
 47         0x95, 0x08,                    # .Report Count (8)                   33
 48         0x05, 0x07,                    # .Usage Page (Keyboard)              35
 49         0x19, 0xe0,                    # .Usage Minimum (224)                37
 50         0x29, 0xe7,                    # .Usage Maximum (231)                39
 51         0x15, 0x00,                    # .Logical Minimum (0)                41
 52         0x25, 0x01,                    # .Logical Maximum (1)                43
 53         0x81, 0x02,                    # .Input (Data,Var,Abs)               45
 54         0x95, 0x01,                    # .Report Count (1)                   47
 55         0x75, 0x08,                    # .Report Size (8)                    49
 56         0x81, 0x03,                    # .Input (Cnst,Var,Abs)               51
 57         0x95, 0x05,                    # .Report Count (5)                   53
 58         0x75, 0x01,                    # .Report Size (1)                    55
 59         0x05, 0x08,                    # .Usage Page (LEDs)                  57
 60         0x19, 0x01,                    # .Usage Minimum (1)                  59
 61         0x29, 0x05,                    # .Usage Maximum (5)                  61
 62         0x91, 0x02,                    # .Output (Data,Var,Abs)              63
 63         0x95, 0x01,                    # .Report Count (1)                   65
 64         0x75, 0x03,                    # .Report Size (3)                    67
 65         0x91, 0x03,                    # .Output (Cnst,Var,Abs)              69
 66         0x95, 0x06,                    # .Report Count (6)                   71
 67         0x75, 0x08,                    # .Report Size (8)                    73
 68         0x15, 0x00,                    # .Logical Minimum (0)                75
 69         0x26, 0xff, 0x00,              # .Logical Maximum (255)              77
 70         0x05, 0x07,                    # .Usage Page (Keyboard)              80
 71         0x19, 0x00,                    # .Usage Minimum (0)                  82
 72         0x2a, 0xff, 0x00,              # .Usage Maximum (255)                84
 73         0x81, 0x00,                    # .Input (Data,Arr,Abs)               87
 74         0xc0,                          # End Collection                      89
 75         0x05, 0x0c,                    # Usage Page (Consumer Devices)       90
 76         0x09, 0x01,                    # Usage (Consumer Control)            92
 77         0xa1, 0x01,                    # Collection (Application)            94
 78         0x85, 0x02,                    # .Report ID (2)                      96
 79         0x19, 0x00,                    # .Usage Minimum (0)                  98
 80         0x2a, 0x3c, 0x02,              # .Usage Maximum (572)                100
 81         0x15, 0x00,                    # .Logical Minimum (0)                103
 82         0x26, 0x3c, 0x02,              # .Logical Maximum (572)              105
 83         0x75, 0x10,                    # .Report Size (16)                   108
 84         0x95, 0x01,                    # .Report Count (1)                   110
 85         0x81, 0x00,                    # .Input (Data,Arr,Abs)               112
 86         0xc0,                          # End Collection                      114
 87         0x05, 0x01,                    # Usage Page (Generic Desktop)        115
 88         0x09, 0x0c,                    # Usage (Wireless Radio Controls)     117
 89         0xa1, 0x01,                    # Collection (Application)            119
 90         0x85, 0x03,                    # .Report ID (3)                      121
 91         0x15, 0x00,                    # .Logical Minimum (0)                123
 92         0x25, 0x01,                    # .Logical Maximum (1)                125
 93         0x09, 0xc6,                    # .Usage (Wireless Radio Button)      127
 94         0x95, 0x01,                    # .Report Count (1)                   129
 95         0x75, 0x01,                    # .Report Size (1)                    131
 96         0x81, 0x06,                    # .Input (Data,Var,Rel)               133
 97         0x75, 0x07,                    # .Report Size (7)                    135
 98         0x81, 0x03,                    # .Input (Cnst,Var,Abs)               137
 99         0xc0,                          # End Collection                      139
100         0x05, 0x88,                    # Usage Page (Vendor Usage Page 0x88) 140
101         0x09, 0x01,                    # Usage (Vendor Usage 0x01)           142
102         0xa1, 0x01,                    # Collection (Application)            144
103         0x85, 0x04,                    # .Report ID (4)                      146
104         0x19, 0x00,                    # .Usage Minimum (0)                  148
105         0x2a, 0xff, 0xff,              # .Usage Maximum (65535)              150
106         0x15, 0x00,                    # .Logical Minimum (0)                153
107         0x26, 0xff, 0xff,              # .Logical Maximum (65535)            155
108         0x75, 0x08,                    # .Report Size (8)                    158
109         0x95, 0x02,                    # .Report Count (2)                   160
110         0x81, 0x02,                    # .Input (Data,Var,Abs)               162
111         0xc0,                          # End Collection                      164
112         0x05, 0x01,                    # Usage Page (Generic Desktop)        165
113         0x09, 0x80,                    # Usage (System Control)              167
114         0xa1, 0x01,                    # Collection (Application)            169
115         0x85, 0x05,                    # .Report ID (5)                      171
116         0x19, 0x81,                    # .Usage Minimum (129)                173
117         0x29, 0x83,                    # .Usage Maximum (131)                175
118         0x15, 0x00,                    # .Logical Minimum (0)                177
119         0x25, 0x01,                    # .Logical Maximum (1)                179
120         0x95, 0x08,                    # .Report Count (8)                   181
121         0x75, 0x01,                    # .Report Size (1)                    183
122         0x81, 0x02,                    # .Input (Data,Var,Abs)               185
123         0xc0,                          # End Collection                      187
124     ]
125     # fmt: on
126 
127     def __init__(
128         self,
129         rdesc=report_descriptor,
130         name=None,
131         input_info=(BusType.USB, 0x06CB, 0x2968),
132     ):
133         super().__init__(rdesc, name, input_info)
134 
135     def event(self, keys, reportID=None, application=None):
136         application = application or "Keyboard"
137         return super().event(keys, reportID, application)
138 
139 
140 class TestITEKeyboard(TestArrayKeyboard):
141     kernel_modules = [KERNEL_MODULE]
142 
143     def create_device(self):
144         return ITEKeyboard()
145 
146     def test_wifi_key(self):
147         uhdev = self.uhdev
148         syn_event = self.syn_event
149 
150         # the following sends a 'release' event on the Wifi key.
151         # the kernel is supposed to translate this into Wifi key
152         # down and up
153         r = [0x03, 0x00]
154         uhdev.call_input_event(r)
155         expected = [syn_event]
156         expected.append(libevdev.InputEvent(libevdev.EV_KEY.KEY_RFKILL, 1))
157         events = uhdev.next_sync_events()
158         self.debug_reports([r], uhdev, events)
159         self.assertInputEventsIn(expected, events)
160 
161         expected = [syn_event]
162         expected.append(libevdev.InputEvent(libevdev.EV_KEY.KEY_RFKILL, 0))
163         # the kernel sends the two down/up key events in a batch, no need to
164         # call events = uhdev.next_sync_events()
165         self.debug_reports([], uhdev, events)
166         self.assertInputEventsIn(expected, events)

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php