VirtualBox

Changeset 38759 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Sep 15, 2011 11:11:27 AM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
74040
Message:

Additions/common/VBoxGuest-linux: push the mouse position update into a work queue

File:
1 edited

Legend:

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

    r38722 r38759  
    6161#endif
    6262
     63/* The definition of work queue functions changed in Linux 2.6.20. */
     64#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
     65typedef struct work_struct *WQ_PARAM;
     66#else
     67typedef void *WQ_PARAM;
     68#endif
    6369
    6470/*******************************************************************************
     
    7884static unsigned int vboxguestPoll(struct file *pFile, poll_table *pPt);
    7985static ssize_t vboxguestRead(struct file *pFile, char *pbBuf, size_t cbRead, loff_t *poff);
     86static void vboxguestReportMousePosition(WQ_PARAM unused);
    8087
    8188
     
    99106/** Wait queue used by polling. */
    100107static wait_queue_head_t        g_PollEventQueue;
     108/** The IRQ bottom half work queue for reporting the mouse position */
     109static struct work_struct       g_MouseEventWQ;
    101110/** Asynchronous notification stuff.  */
    102111static struct fasync_struct    *g_pFAsyncQueue;
     
    346355
    347356/**
    348  * Registers the ISR and initializes the poll wait queue.
     357 * Registers the ISR and initializes the poll wait queue and the
     358 * bottom half work-queue for mouse reporting.
    349359 */
    350360static int __init vboxguestLinuxInitISR(void)
     
    353363
    354364    init_waitqueue_head(&g_PollEventQueue);
     365    INIT_WORK(&g_MouseEventWQ, vboxguestReportMousePosition
     366#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
     367              , NULL
     368#endif
     369              );
    355370    rc = request_irq(g_pPciDev->irq,
    356371                     vboxguestLinuxISR,
     
    933948
    934949
    935 void VBoxGuestNativeISRMousePollEvent(PVBOXGUESTDEVEXT pDevExt)
     950void vboxguestReportMousePosition(WQ_PARAM unused)
    936951{
    937952    VMMDevReqMouseStatus *pReq;
    938953    int rc;
     954
     955    NOREF(unused);
     956    /* Report events to the kernel input device */
     957    rc = VbglGRAlloc((VMMDevRequestHeader **)&pReq, sizeof(*pReq), VMMDevReq_GetMouseStatus);
     958    if (RT_SUCCESS(rc))
     959    {
     960        pReq->mouseFeatures = 0;
     961        pReq->pointerXPos = 0;
     962        pReq->pointerYPos = 0;
     963        rc = VbglGRPerform(&pReq->header);
     964        input_report_abs(g_pInputDevice, ABS_X, pReq->pointerXPos);
     965        input_report_abs(g_pInputDevice, ABS_Y, pReq->pointerYPos);
     966#ifdef EV_SYN
     967        input_sync(g_pInputDevice);
     968#endif
     969        VbglGRFree(&pReq->header);
     970    }
     971}
     972
     973
     974void VBoxGuestNativeISRMousePollEvent(PVBOXGUESTDEVEXT pDevExt)
     975{
    939976    NOREF(pDevExt);
    940977
     
    947984    Log(("VBoxGuestNativeISRMousePollEvent: kill_fasync\n"));
    948985    kill_fasync(&g_pFAsyncQueue, SIGIO, POLL_IN);
    949     /* Report events to the kernel input device */
    950     rc = VbglGRAlloc((VMMDevRequestHeader **)&pReq, sizeof(*pReq), VMMDevReq_GetMouseStatus);
    951     if (RT_SUCCESS(rc))
    952     {
    953         pReq->mouseFeatures = 0;
    954         pReq->pointerXPos = 0;
    955         pReq->pointerYPos = 0;
    956         rc = VbglGRPerform(&pReq->header);
    957         input_report_abs(g_pInputDevice, ABS_X, pReq->pointerXPos);
    958         input_report_abs(g_pInputDevice, ABS_Y, pReq->pointerYPos);
    959 #ifdef EV_SYN
    960         input_sync(g_pInputDevice);
    961 #endif
    962         VbglGRFree(&pReq->header);
    963     }
    964986    Log(("VBoxGuestNativeISRMousePollEvent: done\n"));
     987    schedule_work(&g_MouseEventWQ);
    965988}
    966989
Note: See TracChangeset for help on using the changeset viewer.

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