[PATCH xf86-video-amdgpu 13/13] Refactor pushing color management properties into a function
sunpeng.li at amd.com
sunpeng.li at amd.com
Thu May 3 18:31:55 UTC 2018
From: "Leo (Sunpeng) Li" <sunpeng.li at amd.com>
Pushing all color properties to kernel DRM is done in a few places.
Reduce repetition by refactoring into a function.
Signed-off-by: Leo (Sunpeng) Li <sunpeng.li at amd.com>
---
src/drmmode_display.c | 41 ++++++++++++++++++++---------------------
1 file changed, 20 insertions(+), 21 deletions(-)
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index ba8be14..6dc1a93 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1286,6 +1286,21 @@ static int drmmode_crtc_push_cm_prop(xf86CrtcPtr crtc,
return Success;
}
+static int drmmode_crtc_push_cm_all(xf86CrtcPtr crtc) {
+ int i, ret;
+
+ for (i = 0; i < CM_NUM_PROPS; i++) {
+ if (i == CM_GAMMA_LUT_SIZE || i == CM_DEGAMMA_LUT_SIZE)
+ continue;
+
+ ret = drmmode_crtc_push_cm_prop(crtc, i);
+
+ if (ret)
+ return ret;
+ }
+ return Success;
+}
+
static void
drmmode_do_crtc_dpms(xf86CrtcPtr crtc, int mode)
{
@@ -1294,7 +1309,6 @@ drmmode_do_crtc_dpms(xf86CrtcPtr crtc, int mode)
AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn);
CARD64 ust;
int ret;
- int i;
if (drmmode_crtc->dpms_mode == DPMSModeOn && mode != DPMSModeOn) {
uint32_t seq;
@@ -1342,11 +1356,7 @@ drmmode_do_crtc_dpms(xf86CrtcPtr crtc, int mode)
drmmode_crtc->interpolated_vblanks += delta_seq;
}
- for (i = 0; i < CM_NUM_PROPS; i++) {
- if (i == CM_GAMMA_LUT_SIZE || i == CM_DEGAMMA_LUT_SIZE)
- continue;
- drmmode_crtc_push_cm_prop(crtc, i);
- }
+ drmmode_crtc_push_cm_all(crtc);
}
drmmode_crtc->dpms_mode = mode;
}
@@ -2012,7 +2022,6 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res
drmmode_crtc_private_ptr drmmode_crtc;
AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(pScrn);
AMDGPUInfoPtr info = AMDGPUPTR(pScrn);
- int i;
crtc = xf86CrtcCreate(pScrn, &info->drmmode_crtc_funcs);
if (crtc == NULL)
@@ -2039,12 +2048,8 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res
drmmode_crtc->ctm->matrix[8] = (uint64_t)1 << 32;
/* Push properties to initialize them */
- for (i = 0; i < CM_NUM_PROPS; i++) {
- if (i == CM_DEGAMMA_LUT_SIZE || i == CM_GAMMA_LUT_SIZE)
- continue;
- if (drmmode_crtc_push_cm_prop(crtc, i))
- return 0;
- }
+ if (drmmode_crtc_push_cm_all(crtc))
+ return 0;
/* Mark num'th crtc as in use on this device. */
pAMDGPUEnt->assigned_crtcs |= (1 << num);
@@ -2127,7 +2132,6 @@ static xf86OutputStatus drmmode_output_detect(xf86OutputPtr output)
AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(output->scrn);
xf86OutputStatus status;
drmModeFreeConnector(drmmode_output->mode_output);
- int i;
drmmode_output->mode_output =
drmModeGetConnector(pAMDGPUEnt->fd, drmmode_output->output_id);
@@ -2137,13 +2141,8 @@ static xf86OutputStatus drmmode_output_detect(xf86OutputPtr output)
}
drmmode_output_update_properties(output);
- if (output->crtc) {
- for (i = 0; i < CM_NUM_PROPS; i++) {
- if (i == CM_GAMMA_LUT_SIZE || i == CM_DEGAMMA_LUT_SIZE)
- continue;
- drmmode_crtc_push_cm_prop(output->crtc, i);
- }
- }
+ if (output->crtc)
+ drmmode_crtc_push_cm_all(output->crtc);
switch (drmmode_output->mode_output->connection) {
case DRM_MODE_CONNECTED:
--
2.7.4
More information about the amd-gfx
mailing list