[PATCH xf86-video-amdgpu 4/5] Enable configure & change helper to handle enums
sunpeng.li at amd.com
sunpeng.li at amd.com
Mon Mar 26 20:00:17 UTC 2018
From: "Leo (Sunpeng) Li" <sunpeng.li at amd.com>
Copy code from output_create_resources, insert into configure &
change helper, and rename variables. Some formatting changes as well.
Modify doc-string to reflect change.
Signed-off-by: Leo (Sunpeng) Li <sunpeng.li at amd.com>
---
src/drmmode_display.c | 42 ++++++++++++++++++++++++++++++++++++++++--
1 file changed, 40 insertions(+), 2 deletions(-)
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 45457c4..9c95abc 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1656,8 +1656,7 @@ static Bool drmmode_property_ignore(drmModePropertyPtr prop)
}
/**
-* Configure and change the given output property through randr. Currently
-* ignores DRM_MODE_PROP_ENU property types. Used as part of create_resources.
+* Configure and change the given output/CRTC property through randr.
*
* @output: The output to configure and change the property on.
* @pmode_prop: The driver-private property object.
@@ -1733,6 +1732,45 @@ static int __rr_configure_and_change_property(xf86OutputPtr output,
if (err)
goto rrchange_error;
}
+ else if (mode_prop->flags & DRM_MODE_PROP_ENUM) {
+ int j;
+
+ pmode_prop->num_atoms = mode_prop->count_enums + 1;
+ pmode_prop->atoms = calloc(pmode_prop->num_atoms, sizeof(Atom));
+ if (!pmode_prop->atoms)
+ return 0;
+
+ pmode_prop->atoms[0] = MakeAtom(mode_prop->name,
+ strlen(mode_prop->name), TRUE);
+
+ for (j = 1; j <= mode_prop->count_enums; j++) {
+ struct drm_mode_property_enum *e =
+ &mode_prop->enums[j - 1];
+ pmode_prop->atoms[j] = MakeAtom(e->name,
+ strlen(e->name),
+ TRUE);
+ }
+ err = RRConfigureOutputProperty(output->randr_output,
+ pmode_prop->atoms[0],
+ FALSE, FALSE,
+ is_immutable,
+ pmode_prop->num_atoms - 1,
+ (INT32 *) &pmode_prop->atoms[1]);
+ if (err != 0)
+ goto rrconfig_error;
+
+ for (j = 0; j < mode_prop->count_enums; j++)
+ if (mode_prop->enums[j].value == pmode_prop->value)
+ break;
+ /* there's always a matching value */
+ err = RRChangeOutputProperty(output->randr_output,
+ pmode_prop->atoms[0], XA_ATOM, 32,
+ PropModeReplace, 1,
+ &pmode_prop->atoms[j + 1], FALSE,
+ pending);
+ if (err != 0)
+ goto rrchange_error;
+ }
return 0;
--
2.7.4
More information about the amd-gfx
mailing list