[PATCH xf86-video-amdgpu 04/13] Use CRTC's color properties if output has a CRTC attached

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Leo (Sunpeng) Li" <sunpeng.li@xxxxxxx>

Previously, all outputs will have disabled color properties initialized.
However, an output with a CRTC attached should use the properties on the
attached CRTC.

To do so, an color properties "update" function is added. It takes
staged properties within the driver-private CRTC, and executes a
non-pending RandR configure + change on all outputs it's attached on.
This effectively updates the output properties listed by RandR, without
unnecessarily pushing changes to kernel DRM.

Signed-off-by: Leo (Sunpeng) Li <sunpeng.li at amd.com>
---
 src/drmmode_display.c | 41 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index c28796c..ac50e19 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -987,6 +987,42 @@ static int rr_configure_and_change_cm_property(xf86OutputPtr output,
 }
 
 /**
+ * Take the staged color properties on the CRTC, and updated the values within
+ * RandR. All outputs using the given CRTC will have their color properties
+ * updated in user-land only. i.e. changes will not be pushed to DRM.
+ *
+ * @crtc: The CRTC containing staged properties.
+ */
+static void drmmode_crtc_update_cm_props(xf86CrtcPtr crtc)
+{
+	xf86CrtcConfigPtr xf86_crtc_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
+	int i, j, ret;
+
+	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+	for (i = 0; i < xf86_crtc_config->num_output; i++) {
+		xf86OutputPtr output = xf86_crtc_config->output[i];
+		if (output->crtc != crtc)
+			continue;
+
+		for (j = 0; j < CM_NUM_PROPS; j++) {
+			/* Non-pending configure and change: Just updating
+			 * values on user-side */
+			ret = rr_configure_and_change_cm_property(output,
+								  drmmode_crtc,
+								  j, FALSE);
+			if (ret) {
+				xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
+					   "Error updating color properties: %d\n",
+					   ret);
+				break;
+			}
+		}
+	}
+
+}
+
+/**
  * Push staged color management properties on the CRTC to DRM.
  *
  * @crtc: The CRTC containing staged properties
@@ -2131,7 +2167,10 @@ static void drmmode_output_create_resources(xf86OutputPtr output)
 		}
 	}
 
-	drmmode_disabled_crtc_create_resources(output);
+	if (output->crtc)
+		drmmode_crtc_update_cm_props(output->crtc);
+	else
+		drmmode_disabled_crtc_create_resources(output);
 }
 
 static void
-- 
2.7.4



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux