VirtualBox

Ignore:
Timestamp:
Feb 3, 2016 9:33:34 AM (9 years ago)
Author:
vboxsync
Message:

bugref:8087: Additions/x11: support non-root X server: further refactor the KMS driver to bring the code closer to the original AST code and (again) to the kernel coding style instead of the VirtualBox style.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/linux/drm/vbox_mode.c

    r59526 r59568  
    7272    struct vbox_private *vbox;
    7373    int width, height, cBPP, pitch;
    74     unsigned iCrtc;
     74    unsigned crtc_id;
    7575    uint16_t fFlags;
    7676
     
    8080    width = mode->hdisplay ? mode->hdisplay : 640;
    8181    height = mode->vdisplay ? mode->vdisplay : 480;
    82     iCrtc = vbox_crtc->crtc_id;
     82    crtc_id = vbox_crtc->crtc_id;
    8383    cBPP = crtc->enabled ? CRTC_FB(crtc)->bits_per_pixel : 32;
    8484#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
     
    9393    fFlags = VBVA_SCREEN_F_ACTIVE;
    9494    fFlags |= (crtc->enabled ? 0 : VBVA_SCREEN_F_DISABLED);
    95     VBoxHGSMIProcessDisplayInfo(&vbox->Ctx, vbox_crtc->crtc_id,
     95    VBoxHGSMIProcessDisplayInfo(&vbox->submit_info, vbox_crtc->crtc_id,
    9696                                crtc->x, crtc->y,
    9797                                crtc->x * cBPP / 8 + crtc->y * pitch,
    9898                                pitch, width, height,
    99                                 vbox_crtc->fBlanked ? 0 : cBPP, fFlags);
    100     VBoxHGSMIReportFlagsLocation(&vbox->Ctx, vbox->offHostFlags);
    101     VBoxHGSMISendCapsInfo(&vbox->Ctx, VBVACAPS_VIDEO_MODE_HINTS | VBVACAPS_DISABLE_CURSOR_INTEGRATION);
     99                                vbox_crtc->blanked ? 0 : cBPP, fFlags);
     100    VBoxHGSMIReportFlagsLocation(&vbox->submit_info, vbox->host_flags_offset);
     101    VBoxHGSMISendCapsInfo(&vbox->submit_info, VBVACAPS_VIDEO_MODE_HINTS | VBVACAPS_DISABLE_CURSOR_INTEGRATION);
    102102    LogFunc(("vboxvideo: %d\n", __LINE__));
    103103}
     
    118118     * the first view be the managed memory plus the first command buffer, the
    119119     * second the same plus the second buffer and so on. */
    120     p = VBoxHGSMIBufferAlloc(&vbox->Ctx, sizeof(VBVAINFOVIEW), HGSMI_CH_VBVA,
     120    p = VBoxHGSMIBufferAlloc(&vbox->submit_info, sizeof(VBVAINFOVIEW), HGSMI_CH_VBVA,
    121121                             VBVA_INFO_VIEW);
    122122    if (p)
     
    124124        VBVAINFOVIEW *pInfo = (VBVAINFOVIEW *)p;
    125125        pInfo->u32ViewIndex = vbox_crtc->crtc_id;
    126         pInfo->u32ViewOffset = vbox_crtc->offFB;
    127         pInfo->u32ViewSize =   vbox->vram_size - vbox_crtc->offFB
     126        pInfo->u32ViewOffset = vbox_crtc->fb_offset;
     127        pInfo->u32ViewSize =   vbox->vram_size - vbox_crtc->fb_offset
    128128                             + vbox_crtc->crtc_id * VBVA_MIN_BUFFER_SIZE;
    129         pInfo->u32MaxScreenSize = vbox->vram_size - vbox_crtc->offFB;
    130         VBoxHGSMIBufferSubmit(&vbox->Ctx, p);
    131         VBoxHGSMIBufferFree(&vbox->Ctx, p);
     129        pInfo->u32MaxScreenSize = vbox->vram_size - vbox_crtc->fb_offset;
     130        VBoxHGSMIBufferSubmit(&vbox->submit_info, p);
     131        VBoxHGSMIBufferFree(&vbox->submit_info, p);
    132132    }
    133133    else
     
    152152    switch (mode) {
    153153    case DRM_MODE_DPMS_ON:
    154         vbox_crtc->fBlanked = false;
     154        vbox_crtc->blanked = false;
    155155        break;
    156156    case DRM_MODE_DPMS_STANDBY:
    157157    case DRM_MODE_DPMS_SUSPEND:
    158158    case DRM_MODE_DPMS_OFF:
    159         vbox_crtc->fBlanked = true;
     159        vbox_crtc->blanked = true;
    160160        break;
    161161    }
     
    222222
    223223    /* vbox_set_start_address_crt1(crtc, (u32)gpu_addr); */
    224     vbox_crtc->offFB = gpu_addr;
     224    vbox_crtc->fb_offset = gpu_addr;
    225225
    226226    LogFunc(("vboxvideo: %d: vbox_fb=%p, obj=%p, bo=%p, gpu_addr=%u\n",
     
    413413    LogFunc(("vboxvideo: %d: vbox_connector=%p\n", __LINE__, vbox_connector));
    414414    pVBox = vbox_connector->base.dev->dev_private;
    415     rc = VBoxHGSMIGetModeHints(&pVBox->Ctx, pVBox->cCrtcs, pVBox->paVBVAModeHints);
     415    rc = VBoxHGSMIGetModeHints(&pVBox->submit_info, pVBox->num_crtcs, pVBox->last_mode_hints);
    416416    AssertMsgRCReturnVoid(rc, ("VBoxHGSMIGetModeHints failed, rc=%Rrc.\n", rc));
    417     if (pVBox->paVBVAModeHints[vbox_connector->iCrtc].magic == VBVAMODEHINT_MAGIC)
     417    if (pVBox->last_mode_hints[vbox_connector->crtc_id].magic == VBVAMODEHINT_MAGIC)
    418418    {
    419         vbox_connector->modeHint.cX = pVBox->paVBVAModeHints[vbox_connector->iCrtc].cx & 0x8fff;
    420         vbox_connector->modeHint.cY = pVBox->paVBVAModeHints[vbox_connector->iCrtc].cy & 0x8fff;
    421         vbox_connector->modeHint.fDisconnected = !(pVBox->paVBVAModeHints[vbox_connector->iCrtc].fEnabled);
    422         LogFunc(("vboxvideo: %d: cX=%u, cY=%u, fDisconnected=%RTbool\n", __LINE__,
    423                  (unsigned)vbox_connector->modeHint.cX, (unsigned)vbox_connector->modeHint.cY,
    424                  vbox_connector->modeHint.fDisconnected));
     419        vbox_connector->mode_hint.width = pVBox->last_mode_hints[vbox_connector->crtc_id].cx & 0x8fff;
     420        vbox_connector->mode_hint.height = pVBox->last_mode_hints[vbox_connector->crtc_id].cy & 0x8fff;
     421        vbox_connector->mode_hint.disconnected = !(pVBox->last_mode_hints[vbox_connector->crtc_id].fEnabled);
     422        LogFunc(("vboxvideo: %d: width=%u, height=%u, disconnected=%RTbool\n", __LINE__,
     423                 (unsigned)vbox_connector->mode_hint.width, (unsigned)vbox_connector->mode_hint.height,
     424                 vbox_connector->mode_hint.disconnected));
    425425    }
    426426}
     
    431431    struct drm_display_mode *pMode = NULL;
    432432    unsigned cModes = 0;
    433     int cxPreferred, cyPreferred;
     433    int widthPreferred, heightPreferred;
    434434
    435435    LogFunc(("vboxvideo: %d: connector=%p\n", __LINE__, connector));
     
    437437    vboxUpdateHints(vbox_connector);
    438438    cModes = drm_add_modes_noedid(connector, 2560, 1600);
    439     cxPreferred = vbox_connector->modeHint.cX ? vbox_connector->modeHint.cX : 1024;
    440     cyPreferred = vbox_connector->modeHint.cY ? vbox_connector->modeHint.cY : 768;
    441     pMode = drm_cvt_mode(connector->dev, cxPreferred, cyPreferred, 60, false,
     439    widthPreferred = vbox_connector->mode_hint.width ? vbox_connector->mode_hint.width : 1024;
     440    heightPreferred = vbox_connector->mode_hint.height ? vbox_connector->mode_hint.height : 768;
     441    pMode = drm_cvt_mode(connector->dev, widthPreferred, heightPreferred, 60, false,
    442442                         false, false);
    443443    if (pMode)
     
    462462    LogFunc(("vboxvideo: %d: connector=%p\n", __LINE__, connector));
    463463    vbox_connector = to_vbox_connector(connector);
    464     device_remove_file(connector->dev->dev, &vbox_connector->deviceAttribute);
     464    device_remove_file(connector->dev->dev, &vbox_connector->sysfs_node);
    465465#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
    466466    drm_sysfs_connector_remove(connector);
     
    481481    vbox_connector = to_vbox_connector(connector);
    482482    vboxUpdateHints(vbox_connector);
    483     return !vbox_connector->modeHint.fDisconnected;
     483    return !vbox_connector->mode_hint.disconnected;
    484484}
    485485
     
    525525             dev, pAttr, psz, (unsigned long long)cch));
    526526    vbox_connector = container_of(pAttr, struct vbox_connector,
    527                                   deviceAttribute);
     527                                  sysfs_node);
    528528    pVBox = vbox_connector->base.dev->dev_private;
    529529    drm_kms_helper_hotplug_event(vbox_connector->base.dev);
     
    547547
    548548    connector = &vbox_connector->base;
    549     vbox_connector->iCrtc = cScreen;
     549    vbox_connector->crtc_id = cScreen;
    550550
    551551    /*
     
    553553     * space.
    554554     */
    555     snprintf(vbox_connector->szName, sizeof(vbox_connector->szName),
     555    snprintf(vbox_connector->name, sizeof(vbox_connector->name),
    556556             "vbox_screen_%u", cScreen);
    557     vbox_connector->deviceAttribute.attr.name = vbox_connector->szName;
    558     vbox_connector->deviceAttribute.attr.mode = S_IWUSR;
    559     vbox_connector->deviceAttribute.show      = NULL;
    560     vbox_connector->deviceAttribute.store     = vbox_connector_write_sysfs;
    561     rc = device_create_file(dev->dev, &vbox_connector->deviceAttribute);
     557    vbox_connector->sysfs_node.attr.name = vbox_connector->name;
     558    vbox_connector->sysfs_node.attr.mode = S_IWUSR;
     559    vbox_connector->sysfs_node.show      = NULL;
     560    vbox_connector->sysfs_node.store     = vbox_connector_write_sysfs;
     561    rc = device_create_file(dev->dev, &vbox_connector->sysfs_node);
    562562    if (rc < 0)
    563563    {
     
    638638    /* vbox_cursor_init(dev); */
    639639    LogFunc(("vboxvideo: %d: dev=%p\n", __LINE__, dev));
    640     for (i = 0; i < pVBox->cCrtcs; ++i)
     640    for (i = 0; i < pVBox->num_crtcs; ++i)
    641641    {
    642642        vbox_crtc_init(dev, i);
     
    654654
    655655
    656 void VBoxRefreshModes(struct drm_device *dev)
     656void vbox_refresh_modes(struct drm_device *dev)
    657657{
    658658    struct vbox_private *vbox = dev->dev_private;
     
    702702    if (!handle) {
    703703        /* Hide cursor. */
    704         VBoxHGSMIUpdatePointerShape(&vbox->Ctx, 0, 0, 0, 0, 0, NULL, 0);
     704        VBoxHGSMIUpdatePointerShape(&vbox->submit_info, 0, 0, 0, 0, 0, NULL, 0);
    705705        return 0;
    706706    }
     
    733733                                          | VBOX_MOUSE_POINTER_ALPHA;
    734734                        copy_cursor_image(src, dst, width, height, cbMask);
    735                         rc = VBoxHGSMIUpdatePointerShape(&vbox->Ctx, fFlags,
     735                        rc = VBoxHGSMIUpdatePointerShape(&vbox->submit_info, fFlags,
    736736                                                         hot_x, hot_y, width,
    737737                                                         height, dst, cbData);
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