[PATCH 2/2] modesetting: add output master support

Dave Airlie airlied at gmail.com
Thu Jun 11 16:48:50 PDT 2015


This allows a glamor enabled master device to have
slave USB devices attached.

Tested with modesetting on SNB + USB.

It relies on the previous patch to export linear
buffers from glamor.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 hw/xfree86/drivers/modesetting/driver.c | 58 +++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index e90e4b8..092cc53 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -532,6 +532,38 @@ dispatch_slave_dirty(ScreenPtr pScreen)
 }
 
 static void
+redisplay_dirty(ScreenPtr screen, PixmapDirtyUpdatePtr dirty)
+{
+
+        RegionRec pixregion;
+
+        PixmapRegionInit(&pixregion, dirty->slave_dst);
+        DamageRegionAppend(&dirty->slave_dst->drawable, &pixregion);
+        PixmapSyncDirtyHelper(dirty, &pixregion);
+
+        DamageRegionProcessPending(&dirty->slave_dst->drawable);
+        RegionUninit(&pixregion);
+}
+
+static void
+ms_dirty_update(ScreenPtr screen)
+{
+        RegionPtr region;
+        PixmapDirtyUpdatePtr ent;
+
+        if (xorg_list_is_empty(&screen->pixmap_dirty_list))
+                return;
+
+        xorg_list_for_each_entry(ent, &screen->pixmap_dirty_list, ent) {
+                region = DamageRegion(ent->damage);
+                if (RegionNotEmpty(region)) {
+                        redisplay_dirty(screen, ent);
+                        DamageEmpty(ent->damage);
+                }
+        }
+}
+
+static void
 msBlockHandler(ScreenPtr pScreen, void *pTimeout, void *pReadmask)
 {
     modesettingPtr ms = modesettingPTR(xf86ScreenToScrn(pScreen));
@@ -544,6 +576,8 @@ msBlockHandler(ScreenPtr pScreen, void *pTimeout, void *pReadmask)
         dispatch_slave_dirty(pScreen);
     else if (ms->dirty_enabled)
         dispatch_dirty(pScreen);
+
+    ms_dirty_update(pScreen);
 }
 
 static void
@@ -727,6 +761,10 @@ PreInit(ScrnInfoPtr pScrn, int flags)
     if (ret == 0) {
         if (value & DRM_PRIME_CAP_IMPORT)
             pScrn->capabilities |= RR_Capability_SinkOutput;
+#if GLAMOR_HAS_GBM_LINEAR
+        if (value & DRM_PRIME_CAP_EXPORT)
+            pScrn->capabilities |= RR_Capability_SourceOutput;
+#endif
     }
 #endif
     drmmode_get_default_bpp(pScrn, &ms->drmmode, &defaultdepth, &defaultbpp);
@@ -938,6 +976,23 @@ msShadowInit(ScreenPtr pScreen)
 }
 
 static Bool
+msSharePixmapBacking(PixmapPtr ppix, ScreenPtr screen, void **handle)
+{
+#ifdef GLAMOR_HAS_GBM
+    int ret;
+    CARD16 stride;
+    CARD32 size;
+    ret = glamor_fd_from_pixmap(ppix->drawable.pScreen, ppix, &stride, &size);
+    if (ret == -1)
+        return FALSE;
+
+    *handle = (void *)(long)(ret);
+    return TRUE;
+#endif
+    return FALSE;
+}
+
+static Bool
 msSetSharedPixmapBacking(PixmapPtr ppix, void *fd_handle)
 {
     ScreenPtr screen = ppix->drawable.pScreen;
@@ -1089,7 +1144,10 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
     ms->BlockHandler = pScreen->BlockHandler;
     pScreen->BlockHandler = msBlockHandler;
 
+    pScreen->SharePixmapBacking = msSharePixmapBacking;
     pScreen->SetSharedPixmapBacking = msSetSharedPixmapBacking;
+    pScreen->StartPixmapTracking = PixmapStartDirtyTracking;
+    pScreen->StopPixmapTracking = PixmapStopDirtyTracking;
 
     if (!xf86CrtcScreenInit(pScreen))
         return FALSE;
-- 
2.4.2



More information about the xorg-devel mailing list