From: "Leo (Sunpeng) Li" <sunpeng...@amd.com>

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...@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

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to