VirtualBox

Changeset 38975 in vbox


Ignore:
Timestamp:
Oct 10, 2011 2:17:09 PM (13 years ago)
Author:
vboxsync
Message:

Additions/common/VBoxGuest: only build the input driver on Linux 2.6.15 and later

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-linux.c

    r38769 r38975  
    2525*******************************************************************************/
    2626#define LOG_GROUP LOG_GROUP_SUP_DRV
     27
    2728#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
    2834#include "VBoxGuestInternal.h"
    29 #include <linux/input.h>
     35#ifdef VBOXGUEST_WITH_INPUT_DRIVER
     36# include <linux/input.h>
     37#endif
    3038#include <linux/miscdevice.h>
    3139#include <linux/poll.h>
     
    101109/** Asynchronous notification stuff.  */
    102110static struct fasync_struct    *g_pFAsyncQueue;
     111#ifdef VBOXGUEST_WITH_INPUT_DRIVER
    103112/** Pre-allocated mouse status VMMDev request for use in the IRQ
    104113 * handler. */
    105114static VMMDevReqMouseStatus    *g_pMouseStatusReq;
     115#endif
    106116#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
    107117/** Whether we've create the logger or not. */
     
    135145
    136146/** 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
    140148static struct input_dev        *g_pInputDevice = NULL;
    141 /** Is the input device registered? */
    142 static bool                     g_fInputDeviceRegistered = false;
     149#endif
    143150
    144151/** The file_operations structure. */
     
    392399
    393400
     401#ifdef VBOXGUEST_WITH_INPUT_DRIVER
    394402/** Calls the kernel IOCtl to report mouse status to the host on behalf of
    395403 * our kernel session. */
     
    429437static int __init vboxguestLinuxCreateInputDevice(void)
    430438{
    431 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 29)
    432 # define INPUT_DEV_ID(val) id.val
    433 #else
    434 # define INPUT_DEV_ID(val) id##val
    435 #endif
    436439    int rc;
    437440
     
    441444    if (RT_FAILURE(rc))
    442445        return -ENOMEM;
    443 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 15)
    444446    g_pInputDevice = input_allocate_device();
    445447    if (!g_pInputDevice)
     
    448450        return -ENOMEM;
    449451    }
    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;
    465460# 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
    470463    {
    471464        int rc = input_register_device(g_pInputDevice);
     
    477470        }
    478471    }
    479 #else
    480     input_register_device(g_pInputDevice);
    481 #endif
    482472    /* Do what one of our competitors apparently does as that works. */
    483473    ASMBitSet(g_pInputDevice->evbit, EV_ABS);
    484474    ASMBitSet(g_pInputDevice->evbit, EV_KEY);
    485 #ifdef EV_SYN
     475# ifdef EV_SYN
    486476    ASMBitSet(g_pInputDevice->evbit, EV_SYN);
    487 #endif
    488 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 7)
     477# endif
    489478    input_set_abs_params(g_pInputDevice, ABS_X, RANGE_MIN, RANGE_MAX, 0, 0);
    490479    input_set_abs_params(g_pInputDevice, ABS_Y, RANGE_MIN, RANGE_MAX, 0, 0);
    491 #else
    492     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 #endif
    497480    ASMBitSet(g_pInputDevice->keybit, BTN_MOUSE);
    498481    /** @todo this string should be in a header file somewhere. */
    499482    g_pInputDevice->name = "VirtualBox mouse integration";
    500483    return 0;
    501 #undef INPUT_DEV_ID
    502484}
    503485
     
    510492    VbglGRFree(&g_pMouseStatusReq->header);
    511493    input_unregister_device(g_pInputDevice);
    512 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 15)
    513494    input_free_device(g_pInputDevice);
    514 #endif
    515 }
     495}
     496#endif
    516497
    517498
     
    665646                     * Create the kernel input device.
    666647                     */
     648#ifdef VBOXGUEST_WITH_INPUT_DRIVER
    667649                    rc = vboxguestLinuxCreateInputDevice();
    668650                    if (rc >= 0)
    669651                    {
     652#endif
    670653                        /*
    671654                         * Finally, create the device nodes.
     
    683666
    684667                        /* bail out */
     668#ifdef VBOXGUEST_WITH_INPUT_DRIVER
    685669                        vboxguestLinuxTermInputDevice();
    686670                    }
     
    690674                        rc = RTErrConvertFromErrno(rc);
    691675                    }
     676#endif
    692677                    VBoxGuestCloseSession(&g_DevExt, g_pKernelSession);
    693678                }
     
    724709     */
    725710    vboxguestLinuxTermDeviceNodes();
     711#ifdef VBOXGUEST_WITH_INPUT_DRIVER
    726712    vboxguestLinuxTermInputDevice();
     713#endif
    727714    VBoxGuestCloseSession(&g_DevExt, g_pKernelSession);
    728715    VBoxGuestDeleteDevExt(&g_DevExt);
     
    945932void VBoxGuestNativeISRMousePollEvent(PVBOXGUESTDEVEXT pDevExt)
    946933{
     934#ifdef VBOXGUEST_WITH_INPUT_DRIVER
    947935    int rc;
     936#endif
    948937    NOREF(pDevExt);
    949938
     
    956945    Log(("VBoxGuestNativeISRMousePollEvent: kill_fasync\n"));
    957946    kill_fasync(&g_pFAsyncQueue, SIGIO, POLL_IN);
     947#ifdef VBOXGUEST_WITH_INPUT_DRIVER
    958948    /* Report events to the kernel input device */
    959949    g_pMouseStatusReq->mouseFeatures = 0;
     
    967957        input_report_abs(g_pInputDevice, ABS_Y,
    968958                         g_pMouseStatusReq->pointerYPos);
    969 #ifdef EV_SYN
     959# ifdef EV_SYN
    970960        input_sync(g_pInputDevice);
    971 #endif
    972     }
     961# endif
     962    }
     963#endif
    973964    Log(("VBoxGuestNativeISRMousePollEvent: done\n"));
    974965}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette