1 /* SPDX-License-Identifier: MIT */ 1 2 /* 3 * kbdif.h -- Xen virtual keyboard/mouse 4 * 5 * Copyright (C) 2005 Anthony Liguori <aliguor 6 * Copyright (C) 2006 Red Hat, Inc., Markus Ar 7 */ 8 9 #ifndef __XEN_PUBLIC_IO_KBDIF_H__ 10 #define __XEN_PUBLIC_IO_KBDIF_H__ 11 12 /* 13 ********************************************* 14 * Feature and Parameter N 15 ********************************************* 16 * 17 * The two halves of a para-virtual driver uti 18 * XenStore to communicate capabilities and to 19 * This section enumerates these nodes which r 20 * backend portions of XenStore, following Xen 21 * 22 * All data in XenStore is stored as strings. 23 * values are encoded in decimal. Integer valu 24 * expressed as fixed sized integer types capa 25 * of a properly formated node string, without 26 * 27 ********************************************* 28 * Backend XenBus N 29 ********************************************* 30 * 31 *---------------------------- Features suppor 32 * 33 * Capable backend advertises supported featur 34 * corresponding entries in XenStore and puts 35 * If a feature is not supported then 0 must b 36 * 37 * feature-disable-keyboard 38 * Values: <uint> 39 * 40 * If there is no need to expose a virtua 41 * frontend then this must be set to 1. 42 * 43 * feature-disable-pointer 44 * Values: <uint> 45 * 46 * If there is no need to expose a virtua 47 * frontend then this must be set to 1. 48 * 49 * feature-abs-pointer 50 * Values: <uint> 51 * 52 * Backends, which support reporting of a 53 * device should set this to 1. 54 * 55 * feature-multi-touch 56 * Values: <uint> 57 * 58 * Backends, which support reporting of m 59 * should set this to 1. 60 * 61 * feature-raw-pointer 62 * Values: <uint> 63 * 64 * Backends, which support reporting raw 65 * for pointer devices should set this to 66 * a range of [0, 0x7fff]. 67 * 68 *----------------------- Device Instance Par 69 * 70 * unique-id 71 * Values: <string> 72 * 73 * After device instance initialization i 74 * so every instance of the frontend can 75 * by this ID. This can be UUID or such. 76 * 77 *------------------------- Pointer Device Par 78 * 79 * width 80 * Values: <uint> 81 * 82 * Maximum X coordinate (width) to be use 83 * while reporting input events, pixels, 84 * 85 * height 86 * Values: <uint> 87 * 88 * Maximum Y coordinate (height) to be us 89 * while reporting input events, pixels, 90 * 91 *----------------------- Multi-touch Device P 92 * 93 * multi-touch-num-contacts 94 * Values: <uint> 95 * 96 * Number of simultaneous touches reporte 97 * 98 * multi-touch-width 99 * Values: <uint> 100 * 101 * Width of the touch area to be used by 102 * while reporting input events, pixels, 103 * 104 * multi-touch-height 105 * Values: <uint> 106 * 107 * Height of the touch area to be used by 108 * while reporting input events, pixels, 109 * 110 ********************************************* 111 * Frontend XenBus 112 ********************************************* 113 * 114 *------------------------------ Feature reque 115 * 116 * Capable frontend requests features from bac 117 * entries to 1 in XenStore. Requests for feat 118 * by the backend have no effect. 119 * 120 * request-abs-pointer 121 * Values: <uint> 122 * 123 * Request backend to report absolute poi 124 * (XENKBD_TYPE_POS) instead of relative 125 * 126 * request-multi-touch 127 * Values: <uint> 128 * 129 * Request backend to report multi-touch 130 * 131 * request-raw-pointer 132 * Values: <uint> 133 * 134 * Request backend to report raw unscaled 135 * This option is only valid if request-a 136 * Raw unscaled coordinates have the rang 137 * 138 *----------------------- Request Transport Pa 139 * 140 * event-channel 141 * Values: <uint> 142 * 143 * The identifier of the Xen event channe 144 * in the ring buffer. 145 * 146 * page-gref 147 * Values: <uint> 148 * 149 * The Xen grant reference granting permi 150 * a sole page in a single page sized eve 151 * 152 * page-ref 153 * Values: <uint> 154 * 155 * OBSOLETE, not recommended for use. 156 * PFN of the shared page. 157 */ 158 159 /* 160 * EVENT CODES. 161 */ 162 163 #define XENKBD_TYPE_MOTION 1 164 #define XENKBD_TYPE_RESERVED 2 165 #define XENKBD_TYPE_KEY 3 166 #define XENKBD_TYPE_POS 4 167 #define XENKBD_TYPE_MTOUCH 5 168 169 /* Multi-touch event sub-codes */ 170 171 #define XENKBD_MT_EV_DOWN 0 172 #define XENKBD_MT_EV_UP 1 173 #define XENKBD_MT_EV_MOTION 2 174 #define XENKBD_MT_EV_SYN 3 175 #define XENKBD_MT_EV_SHAPE 4 176 #define XENKBD_MT_EV_ORIENT 5 177 178 /* 179 * CONSTANTS, XENSTORE FIELD AND PATH NAME STR 180 */ 181 182 #define XENKBD_DRIVER_NAME "vkbd" 183 184 #define XENKBD_FIELD_FEAT_DSBL_KEYBRD "featu 185 #define XENKBD_FIELD_FEAT_DSBL_POINTER "featu 186 #define XENKBD_FIELD_FEAT_ABS_POINTER "featu 187 #define XENKBD_FIELD_FEAT_RAW_POINTER "featu 188 #define XENKBD_FIELD_FEAT_MTOUCH "featu 189 #define XENKBD_FIELD_REQ_ABS_POINTER "reque 190 #define XENKBD_FIELD_REQ_RAW_POINTER "reque 191 #define XENKBD_FIELD_REQ_MTOUCH "reque 192 #define XENKBD_FIELD_RING_GREF "page- 193 #define XENKBD_FIELD_EVT_CHANNEL "event 194 #define XENKBD_FIELD_WIDTH "width 195 #define XENKBD_FIELD_HEIGHT "heigh 196 #define XENKBD_FIELD_MT_WIDTH "multi 197 #define XENKBD_FIELD_MT_HEIGHT "multi 198 #define XENKBD_FIELD_MT_NUM_CONTACTS "multi 199 #define XENKBD_FIELD_UNIQUE_ID "uniqu 200 201 /* OBSOLETE, not recommended for use */ 202 #define XENKBD_FIELD_RING_REF "page- 203 204 /* 205 ********************************************* 206 * Description of the protocol between fronten 207 ********************************************* 208 * 209 * The two halves of a Para-virtual driver com 210 * each other using a shared page and an event 211 * Shared page contains a ring with event stru 212 * 213 * All reserved fields in the structures below 214 * 215 ********************************************* 216 * Backend to fronte 217 ********************************************* 218 * 219 * Frontends should ignore unknown in events. 220 * All event packets have the same length (40 221 * All event packets have common header: 222 * 223 * 0 octet 224 * +-----------------+ 225 * | type | 226 * +-----------------+ 227 * type - uint8_t, event code, XENKBD_TYPE_??? 228 * 229 * 230 * Pointer relative movement event 231 * 0 1 232 * +----------------+----------------+-------- 233 * | _TYPE_MOTION | rese 234 * +----------------+----------------+-------- 235 * | rel_x 236 * +----------------+----------------+-------- 237 * | rel_y 238 * +----------------+----------------+-------- 239 * | rel_z 240 * +----------------+----------------+-------- 241 * | reserved 242 * +----------------+----------------+-------- 243 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ 244 * +----------------+----------------+-------- 245 * | reserved 246 * +----------------+----------------+-------- 247 * 248 * rel_x - int32_t, relative X motion 249 * rel_y - int32_t, relative Y motion 250 * rel_z - int32_t, relative Z motion (wheel) 251 */ 252 253 struct xenkbd_motion { 254 uint8_t type; 255 int32_t rel_x; 256 int32_t rel_y; 257 int32_t rel_z; 258 }; 259 260 /* 261 * Key event (includes pointer buttons) 262 * 0 1 263 * +----------------+----------------+-------- 264 * | _TYPE_KEY | pressed | 265 * +----------------+----------------+-------- 266 * | keycode 267 * +----------------+----------------+-------- 268 * | reserved 269 * +----------------+----------------+-------- 270 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ 271 * +----------------+----------------+-------- 272 * | reserved 273 * +----------------+----------------+-------- 274 * 275 * pressed - uint8_t, 1 if pressed; 0 otherwis 276 * keycode - uint32_t, KEY_* from linux/input. 277 */ 278 279 struct xenkbd_key { 280 uint8_t type; 281 uint8_t pressed; 282 uint32_t keycode; 283 }; 284 285 /* 286 * Pointer absolute position event 287 * 0 1 288 * +----------------+----------------+-------- 289 * | _TYPE_POS | rese 290 * +----------------+----------------+-------- 291 * | abs_x 292 * +----------------+----------------+-------- 293 * | abs_y 294 * +----------------+----------------+-------- 295 * | rel_z 296 * +----------------+----------------+-------- 297 * | reserved 298 * +----------------+----------------+-------- 299 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ 300 * +----------------+----------------+-------- 301 * | reserved 302 * +----------------+----------------+-------- 303 * 304 * abs_x - int32_t, absolute X position (in FB 305 * abs_y - int32_t, absolute Y position (in FB 306 * rel_z - int32_t, relative Z motion (wheel) 307 */ 308 309 struct xenkbd_position { 310 uint8_t type; 311 int32_t abs_x; 312 int32_t abs_y; 313 int32_t rel_z; 314 }; 315 316 /* 317 * Multi-touch event and its sub-types 318 * 319 * All multi-touch event packets have common h 320 * 321 * 0 1 322 * +----------------+----------------+-------- 323 * | _TYPE_MTOUCH | event_type | conta 324 * +----------------+----------------+-------- 325 * | reserved 326 * +----------------+----------------+-------- 327 * 328 * event_type - unt8_t, multi-touch event sub- 329 * contact_id - unt8_t, ID of the contact 330 * 331 * Touch interactions can consist of one or mo 332 * For each contact, a series of events is gen 333 * with a down event, followed by zero or more 334 * and ending with an up event. Events relatin 335 * contact point can be identified by the ID o 336 * Contact ID may be reused after XENKBD_MT_EV 337 * is in the [0; XENKBD_FIELD_NUM_CONTACTS - 1 338 * 339 * For further information please refer to doc 340 * Linux [2] and Windows [3] multi-touch suppo 341 * 342 * [1] https://cgit.freedesktop.org/wayland/wa 343 * [2] https://www.kernel.org/doc/Documentatio 344 * [3] https://msdn.microsoft.com/en-us/librar 345 * 346 * 347 * Multi-touch down event - sent when a new to 348 * a unique contact ID, sent with this and con 349 * to this touch. 350 * 0 1 351 * +----------------+----------------+-------- 352 * | _TYPE_MTOUCH | _MT_EV_DOWN | conta 353 * +----------------+----------------+-------- 354 * | reserved 355 * +----------------+----------------+-------- 356 * | abs_x 357 * +----------------+----------------+-------- 358 * | abs_y 359 * +----------------+----------------+-------- 360 * | reserved 361 * +----------------+----------------+-------- 362 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ 363 * +----------------+----------------+-------- 364 * | reserved 365 * +----------------+----------------+-------- 366 * 367 * abs_x - int32_t, absolute X position, in pi 368 * abs_y - int32_t, absolute Y position, in pi 369 * 370 * Multi-touch contact release event 371 * 0 1 372 * +----------------+----------------+-------- 373 * | _TYPE_MTOUCH | _MT_EV_UP | conta 374 * +----------------+----------------+-------- 375 * | reserved 376 * +----------------+----------------+-------- 377 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ 378 * +----------------+----------------+-------- 379 * | reserved 380 * +----------------+----------------+-------- 381 * 382 * Multi-touch motion event 383 * 0 1 384 * +----------------+----------------+-------- 385 * | _TYPE_MTOUCH | _MT_EV_MOTION | conta 386 * +----------------+----------------+-------- 387 * | reserved 388 * +----------------+----------------+-------- 389 * | abs_x 390 * +----------------+----------------+-------- 391 * | abs_y 392 * +----------------+----------------+-------- 393 * | reserved 394 * +----------------+----------------+-------- 395 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ 396 * +----------------+----------------+-------- 397 * | reserved 398 * +----------------+----------------+-------- 399 * 400 * abs_x - int32_t, absolute X position, in pi 401 * abs_y - int32_t, absolute Y position, in pi 402 * 403 * Multi-touch input synchronization event - s 404 * which logically belong together. 405 * 0 1 406 * +----------------+----------------+-------- 407 * | _TYPE_MTOUCH | _MT_EV_SYN | conta 408 * +----------------+----------------+-------- 409 * | reserved 410 * +----------------+----------------+-------- 411 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ 412 * +----------------+----------------+-------- 413 * | reserved 414 * +----------------+----------------+-------- 415 * 416 * Multi-touch shape event - touch point's sha 417 * Shape is approximated by an ellipse through 418 * lengths: major is the longer diameter of th 419 * shorter one. Center of the ellipse is repor 420 * XENKBD_MT_EV_DOWN/XENKBD_MT_EV_MOTION event 421 * 0 1 422 * +----------------+----------------+-------- 423 * | _TYPE_MTOUCH | _MT_EV_SHAPE | conta 424 * +----------------+----------------+-------- 425 * | reserved 426 * +----------------+----------------+-------- 427 * | major 428 * +----------------+----------------+-------- 429 * | minor 430 * +----------------+----------------+-------- 431 * | reserved 432 * +----------------+----------------+-------- 433 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ 434 * +----------------+----------------+-------- 435 * | reserved 436 * +----------------+----------------+-------- 437 * 438 * major - unt32_t, length of the major axis, 439 * minor - unt32_t, length of the minor axis, 440 * 441 * Multi-touch orientation event - touch point 442 * its orientation: calculated as a clockwise 443 * of the ellipse and positive Y axis in degre 444 * 0 1 445 * +----------------+----------------+-------- 446 * | _TYPE_MTOUCH | _MT_EV_ORIENT | conta 447 * +----------------+----------------+-------- 448 * | reserved 449 * +----------------+----------------+-------- 450 * | orientation | 451 * +----------------+----------------+-------- 452 * | reserved 453 * +----------------+----------------+-------- 454 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ 455 * +----------------+----------------+-------- 456 * | reserved 457 * +----------------+----------------+-------- 458 * 459 * orientation - int16_t, clockwise angle of t 460 */ 461 462 struct xenkbd_mtouch { 463 uint8_t type; /* XEN 464 uint8_t event_type; /* XEN 465 uint8_t contact_id; 466 uint8_t reserved[5]; /* res 467 union { 468 struct { 469 int32_t abs_x; /* abs 470 int32_t abs_y; /* abs 471 } pos; 472 struct { 473 uint32_t major; /* len 474 uint32_t minor; /* len 475 } shape; 476 int16_t orientation; /* clo 477 } u; 478 }; 479 480 #define XENKBD_IN_EVENT_SIZE 40 481 482 union xenkbd_in_event { 483 uint8_t type; 484 struct xenkbd_motion motion; 485 struct xenkbd_key key; 486 struct xenkbd_position pos; 487 struct xenkbd_mtouch mtouch; 488 char pad[XENKBD_IN_EVENT_SIZE]; 489 }; 490 491 /* 492 ********************************************* 493 * Frontend to back 494 ********************************************* 495 * 496 * Out events may be sent only when requested 497 * of an unknown out event is an error. 498 * No out events currently defined. 499 500 * All event packets have the same length (40 501 * All event packets have common header: 502 * 0 octet 503 * +-----------------+ 504 * | type | 505 * +-----------------+ 506 * type - uint8_t, event code 507 */ 508 509 #define XENKBD_OUT_EVENT_SIZE 40 510 511 union xenkbd_out_event { 512 uint8_t type; 513 char pad[XENKBD_OUT_EVENT_SIZE]; 514 }; 515 516 /* 517 ********************************************* 518 * Shared page 519 ********************************************* 520 */ 521 522 #define XENKBD_IN_RING_SIZE 2048 523 #define XENKBD_IN_RING_LEN (XENKBD_IN_RING_SIZ 524 #define XENKBD_IN_RING_OFFS 1024 525 #define XENKBD_IN_RING(page) \ 526 ((union xenkbd_in_event *)((char *)(pa 527 #define XENKBD_IN_RING_REF(page, idx) \ 528 (XENKBD_IN_RING((page))[(idx) % XENKBD 529 530 #define XENKBD_OUT_RING_SIZE 1024 531 #define XENKBD_OUT_RING_LEN (XENKBD_OUT_RING_S 532 #define XENKBD_OUT_RING_OFFS (XENKBD_IN_RING_O 533 #define XENKBD_OUT_RING(page) \ 534 ((union xenkbd_out_event *)((char *)(p 535 #define XENKBD_OUT_RING_REF(page, idx) \ 536 (XENKBD_OUT_RING((page))[(idx) % XENKB 537 538 struct xenkbd_page { 539 uint32_t in_cons, in_prod; 540 uint32_t out_cons, out_prod; 541 }; 542 543 #endif /* __XEN_PUBLIC_IO_KBDIF_H__ */ 544
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.