[PATCH] xf86Crtc: add tile prop setting

Dave Airlie airlied at gmail.com
Mon Mar 30 19:27:36 PDT 2015


From: Dave Airlie <airlied at redhat.com>

Add support for drivers to set the tiling
property. This is used by clients to
work out the monitor tiles for DisplayID
monitors.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 hw/xfree86/modes/xf86Crtc.c | 53 +++++++++++++++++++++++++++++++++++++++++++++
 hw/xfree86/modes/xf86Crtc.h | 26 ++++++++++++++++++++--
 2 files changed, 77 insertions(+), 2 deletions(-)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 9d592a7..a194724 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -3026,6 +3026,27 @@ xf86OutputSetEDIDProperty(xf86OutputPtr output, void *data, int data_len)
     }
 }
 
+#define TILE_ATOM_NAME		"TILE"
+/* changing this in the future could be tricky as people may hardcode 8 */
+#define TILE_PROP_NUM_ITEMS		8
+static void
+xf86OutputSetTileProperty(xf86OutputPtr output)
+{
+    Atom tile_atom = MakeAtom(TILE_ATOM_NAME, sizeof(TILE_ATOM_NAME) - 1, TRUE);
+
+    /* This may get called before the RandR resources have been created */
+    if (output->randr_output == NULL)
+        return;
+
+    if (output->tile_info.group_id != 0) {
+        RRChangeOutputProperty(output->randr_output, tile_atom, XA_INTEGER, 32,
+                               PropModeReplace, TILE_PROP_NUM_ITEMS, (uint32_t *)&output->tile_info, FALSE, TRUE);
+    }
+    else {
+        RRDeleteOutputProperty(output->randr_output, tile_atom);
+    }
+}
+
 #endif
 
 /* Pull out a phyiscal size from a detailed timing if available. */
@@ -3071,6 +3092,38 @@ handle_detailed_physical_size(struct detailed_monitor_section
     }
 }
 
+Bool
+xf86OutputParseKMSTile(const char *tile_data, int tile_length,
+                       struct xf86CrtcTileInfo *tile_info)
+{
+    int ret;
+
+    ret = sscanf(tile_data, "%d:%d:%d:%d:%d:%d:%d:%d",
+                 &tile_info->group_id,
+                 &tile_info->flags,
+                 &tile_info->num_h_tile,
+                 &tile_info->num_v_tile,
+                 &tile_info->tile_h_loc,
+                 &tile_info->tile_v_loc,
+                 &tile_info->tile_h_size,
+                 &tile_info->tile_v_size);
+    if (ret != 8)
+        return FALSE;
+    return TRUE;
+}
+
+void
+xf86OutputSetTile(xf86OutputPtr output, struct xf86CrtcTileInfo *tile_info)
+{
+    if (tile_info)
+        output->tile_info = *tile_info;
+    else
+        memset(&output->tile_info, 0, sizeof(output->tile_info));
+#ifdef RANDR_12_INTERFACE
+    xf86OutputSetTileProperty(output);
+#endif
+}
+
 /**
  * Set the EDID information for the specified output
  */
diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index 692bf40..3c5bbcf 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -70,6 +70,17 @@ typedef enum _xf86OutputStatus {
     XF86OutputStatusUnknown
 } xf86OutputStatus;
 
+struct xf86CrtcTileInfo {
+    uint32_t group_id;
+    uint32_t flags;
+    uint32_t num_h_tile;
+    uint32_t num_v_tile;
+    uint32_t tile_h_loc;
+    uint32_t tile_v_loc;
+    uint32_t tile_h_size;
+    uint32_t tile_v_size;
+};
+
 typedef struct _xf86CrtcFuncs {
    /**
     * Turns the crtc on/off, or sets intermediate power levels if available.
@@ -226,7 +237,7 @@ typedef struct _xf86CrtcFuncs {
 
 } xf86CrtcFuncsRec, *xf86CrtcFuncsPtr;
 
-#define XF86_CRTC_VERSION 5
+#define XF86_CRTC_VERSION 6
 
 struct _xf86Crtc {
     /**
@@ -500,7 +511,7 @@ typedef struct _xf86OutputFuncs {
      (*destroy) (xf86OutputPtr output);
 } xf86OutputFuncsRec, *xf86OutputFuncsPtr;
 
-#define XF86_OUTPUT_VERSION 2
+#define XF86_OUTPUT_VERSION 3
 
 struct _xf86Output {
     /**
@@ -615,6 +626,8 @@ struct _xf86Output {
     BoxRec initialTotalArea;
     BoxRec initialTrackingArea;
     INT16 initialBorder[4];
+
+    struct xf86CrtcTileInfo tile_info;
 };
 
 typedef struct _xf86ProviderFuncs {
@@ -881,6 +894,15 @@ extern _X_EXPORT void
  xf86OutputSetEDID(xf86OutputPtr output, xf86MonPtr edid_mon);
 
 /**
+ * Set the TILE information for the specified output
+ */
+extern _X_EXPORT void
+xf86OutputSetTile(xf86OutputPtr output, struct xf86CrtcTileInfo *tile_info);
+
+extern _X_EXPORT Bool
+xf86OutputParseKMSTile(const char *tile_data, int tile_length, struct xf86CrtcTileInfo *tile_info);
+
+/**
  * Return the list of modes supported by the EDID information
  * stored in 'output'
  */
-- 
2.3.3



More information about the xorg-devel mailing list