summaryrefslogtreecommitdiff
path: root/lib/igt_kms.c
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2021-07-16 15:17:28 +0300
committerVille Syrjälä <ville.syrjala@linux.intel.com>2021-09-21 18:29:58 +0300
commitc115930e8aa5be0616628c68205b0b0485cdbfb4 (patch)
treef091616d11629c364ef8ba81dfed7407b5c98f18 /lib/igt_kms.c
parente9ae59cb8b4f1e7bc61a9261f33fc7e52ae06c65 (diff)
lib/kms: Add igt_plane_has_rotation()
Probe the supported rotations for each plane from the kernel This should let us eliminate tons of hand rolled gen checks all over. Reviewed-by: Karthik B S <karthik.b.s@intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Diffstat (limited to 'lib/igt_kms.c')
-rw-r--r--lib/igt_kms.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index cc38f5a2..6b0639f6 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -612,6 +612,41 @@ const char * const igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
[IGT_CONNECTOR_DITHERING_MODE] = "dithering mode",
};
+const char * const igt_rotation_names[] = {
+ [0] = "rotate-0",
+ [1] = "rotate-90",
+ [2] = "rotate-180",
+ [3] = "rotate-270",
+ [4] = "reflect-x",
+ [5] = "reflect-y",
+};
+
+static unsigned int
+igt_plane_rotations(igt_display_t *display, igt_plane_t *plane,
+ drmModePropertyPtr prop)
+{
+ unsigned int rotations = 0;
+
+ igt_assert_eq(prop->flags & DRM_MODE_PROP_LEGACY_TYPE,
+ DRM_MODE_PROP_BITMASK);
+ igt_assert_eq(prop->count_values, prop->count_enums);
+
+ for (int i = 0; i < ARRAY_SIZE(igt_rotation_names); i++) {
+ for (int j = 0; j < prop->count_enums; j++) {
+ if (strcmp(igt_rotation_names[i], prop->enums[j].name))
+ continue;
+
+ /* various places assume the uabi uses specific bit values */
+ igt_assert_eq(prop->values[j], i);
+
+ rotations |= 1 << i;
+ }
+ }
+ igt_assert_neq(rotations, 0);
+
+ return rotations;
+}
+
/*
* Retrieve all the properies specified in props_name and store them into
* plane->props.
@@ -640,9 +675,15 @@ igt_fill_plane_props(igt_display_t *display, igt_plane_t *plane,
break;
}
+ if (strcmp(prop->name, "rotation") == 0)
+ plane->rotations = igt_plane_rotations(display, plane, prop);
+
drmModeFreeProperty(prop);
}
+ if (!plane->rotations)
+ plane->rotations = IGT_ROTATION_0;
+
drmModeFreeObjectProperties(props);
}