Changeset 38975 in vbox
- Timestamp:
- Oct 10, 2011 2:17:09 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-linux.c
r38769 r38975 25 25 *******************************************************************************/ 26 26 #define LOG_GROUP LOG_GROUP_SUP_DRV 27 27 28 #include "the-linux-kernel.h" 29 30 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 15) 31 # define VBOXGUEST_WITH_INPUT_DRIVER 32 #endif 33 28 34 #include "VBoxGuestInternal.h" 29 #include <linux/input.h> 35 #ifdef VBOXGUEST_WITH_INPUT_DRIVER 36 # include <linux/input.h> 37 #endif 30 38 #include <linux/miscdevice.h> 31 39 #include <linux/poll.h> … … 101 109 /** Asynchronous notification stuff. */ 102 110 static struct fasync_struct *g_pFAsyncQueue; 111 #ifdef VBOXGUEST_WITH_INPUT_DRIVER 103 112 /** Pre-allocated mouse status VMMDev request for use in the IRQ 104 113 * handler. */ 105 114 static VMMDevReqMouseStatus *g_pMouseStatusReq; 115 #endif 106 116 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) 107 117 /** Whether we've create the logger or not. */ … … 135 145 136 146 /** The input device handle */ 137 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 15) 138 static struct input_dev g_InputDevice; 139 #endif 147 #ifdef VBOXGUEST_WITH_INPUT_DRIVER 140 148 static struct input_dev *g_pInputDevice = NULL; 141 /** Is the input device registered? */ 142 static bool g_fInputDeviceRegistered = false; 149 #endif 143 150 144 151 /** The file_operations structure. */ … … 392 399 393 400 401 #ifdef VBOXGUEST_WITH_INPUT_DRIVER 394 402 /** Calls the kernel IOCtl to report mouse status to the host on behalf of 395 403 * our kernel session. */ … … 429 437 static int __init vboxguestLinuxCreateInputDevice(void) 430 438 { 431 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 29)432 # define INPUT_DEV_ID(val) id.val433 #else434 # define INPUT_DEV_ID(val) id##val435 #endif436 439 int rc; 437 440 … … 441 444 if (RT_FAILURE(rc)) 442 445 return -ENOMEM; 443 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 15)444 446 g_pInputDevice = input_allocate_device(); 445 447 if (!g_pInputDevice) … … 448 450 return -ENOMEM; 449 451 } 450 g_pInputDevice->INPUT_DEV_ID(bustype) = BUS_PCI; 451 #else 452 g_pInputDevice = &g_InputDevice; 453 g_pInputDevice->INPUT_DEV_ID(bus) = BUS_PCI; 454 #endif 455 g_pInputDevice->INPUT_DEV_ID(vendor) = VMMDEV_VENDORID; 456 g_pInputDevice->INPUT_DEV_ID(product) = VMMDEV_DEVICEID; 457 g_pInputDevice->INPUT_DEV_ID(version) = VBOX_SHORT_VERSION; 458 g_pInputDevice->open = vboxguestOpenInputDevice; 459 g_pInputDevice->close = vboxguestCloseInputDevice; 460 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 2) 461 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 15) 462 g_pInputDevice->dev->dev = &g_pPciDev->dev; 463 # elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) 464 g_pInputDevice->cdev.dev = &g_pPciDev->dev; 452 g_pInputDevice->id.bustype = BUS_PCI; 453 g_pInputDevice->id.vendor = VMMDEV_VENDORID; 454 g_pInputDevice->id.product = VMMDEV_DEVICEID; 455 g_pInputDevice->id.version = VBOX_SHORT_VERSION; 456 g_pInputDevice->open = vboxguestOpenInputDevice; 457 g_pInputDevice->close = vboxguestCloseInputDevice; 458 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) 459 g_pInputDevice->cdev.dev = &g_pPciDev->dev; 465 460 # else 466 g_pInputDevice->dev.parent = &g_pPciDev->dev; 467 #endif 468 #endif 469 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 15) 461 g_pInputDevice->dev.parent = &g_pPciDev->dev; 462 # endif 470 463 { 471 464 int rc = input_register_device(g_pInputDevice); … … 477 470 } 478 471 } 479 #else480 input_register_device(g_pInputDevice);481 #endif482 472 /* Do what one of our competitors apparently does as that works. */ 483 473 ASMBitSet(g_pInputDevice->evbit, EV_ABS); 484 474 ASMBitSet(g_pInputDevice->evbit, EV_KEY); 485 # ifdef EV_SYN475 # ifdef EV_SYN 486 476 ASMBitSet(g_pInputDevice->evbit, EV_SYN); 487 #endif 488 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 7) 477 # endif 489 478 input_set_abs_params(g_pInputDevice, ABS_X, RANGE_MIN, RANGE_MAX, 0, 0); 490 479 input_set_abs_params(g_pInputDevice, ABS_Y, RANGE_MIN, RANGE_MAX, 0, 0); 491 #else492 ASMBitSet(g_pInputDevice->absbit, ABS_X);493 ASMBitSet(g_pInputDevice->absbit, ABS_Y);494 g_pInputDevice->absmin[ABS_X] = g_pInputDevice->absmin[ABS_Y] = RANGE_MIN;495 g_pInputDevice->absmax[ABS_X] = g_pInputDevice->absmax[ABS_Y] = RANGE_MAX;496 #endif497 480 ASMBitSet(g_pInputDevice->keybit, BTN_MOUSE); 498 481 /** @todo this string should be in a header file somewhere. */ 499 482 g_pInputDevice->name = "VirtualBox mouse integration"; 500 483 return 0; 501 #undef INPUT_DEV_ID502 484 } 503 485 … … 510 492 VbglGRFree(&g_pMouseStatusReq->header); 511 493 input_unregister_device(g_pInputDevice); 512 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 15)513 494 input_free_device(g_pInputDevice); 514 #endif 515 } 495 } 496 #endif 516 497 517 498 … … 665 646 * Create the kernel input device. 666 647 */ 648 #ifdef VBOXGUEST_WITH_INPUT_DRIVER 667 649 rc = vboxguestLinuxCreateInputDevice(); 668 650 if (rc >= 0) 669 651 { 652 #endif 670 653 /* 671 654 * Finally, create the device nodes. … … 683 666 684 667 /* bail out */ 668 #ifdef VBOXGUEST_WITH_INPUT_DRIVER 685 669 vboxguestLinuxTermInputDevice(); 686 670 } … … 690 674 rc = RTErrConvertFromErrno(rc); 691 675 } 676 #endif 692 677 VBoxGuestCloseSession(&g_DevExt, g_pKernelSession); 693 678 } … … 724 709 */ 725 710 vboxguestLinuxTermDeviceNodes(); 711 #ifdef VBOXGUEST_WITH_INPUT_DRIVER 726 712 vboxguestLinuxTermInputDevice(); 713 #endif 727 714 VBoxGuestCloseSession(&g_DevExt, g_pKernelSession); 728 715 VBoxGuestDeleteDevExt(&g_DevExt); … … 945 932 void VBoxGuestNativeISRMousePollEvent(PVBOXGUESTDEVEXT pDevExt) 946 933 { 934 #ifdef VBOXGUEST_WITH_INPUT_DRIVER 947 935 int rc; 936 #endif 948 937 NOREF(pDevExt); 949 938 … … 956 945 Log(("VBoxGuestNativeISRMousePollEvent: kill_fasync\n")); 957 946 kill_fasync(&g_pFAsyncQueue, SIGIO, POLL_IN); 947 #ifdef VBOXGUEST_WITH_INPUT_DRIVER 958 948 /* Report events to the kernel input device */ 959 949 g_pMouseStatusReq->mouseFeatures = 0; … … 967 957 input_report_abs(g_pInputDevice, ABS_Y, 968 958 g_pMouseStatusReq->pointerYPos); 969 # ifdef EV_SYN959 # ifdef EV_SYN 970 960 input_sync(g_pInputDevice); 971 #endif 972 } 961 # endif 962 } 963 #endif 973 964 Log(("VBoxGuestNativeISRMousePollEvent: done\n")); 974 965 }
Note:
See TracChangeset
for help on using the changeset viewer.