diff --git a/src/backends/native/meta-kms-impl-simple.c b/src/backends/native/meta-kms-impl-simple.c index 7bcdb489f..43283716d 100644 --- a/src/backends/native/meta-kms-impl-simple.c +++ b/src/backends/native/meta-kms-impl-simple.c @@ -31,7 +31,7 @@ #include "backends/native/meta-kms-device-private.h" #include "backends/native/meta-kms-mode.h" #include "backends/native/meta-kms-page-flip-private.h" -#include "backends/native/meta-kms-plane.h" +#include "backends/native/meta-kms-plane-private.h" #include "backends/native/meta-kms-private.h" #include "backends/native/meta-kms-update-private.h" #include "backends/native/meta-kms-utils.h" @@ -106,37 +106,6 @@ process_connector_property (MetaKmsImpl *impl, return TRUE; } -static gboolean -process_plane_property (MetaKmsImpl *impl, - MetaKmsPlane *plane, - MetaKmsProperty *prop, - GError **error) -{ - MetaKmsDevice *device = meta_kms_plane_get_device (plane); - MetaKmsImplDevice *impl_device = meta_kms_device_get_impl_device (device); - int fd; - int ret; - - fd = meta_kms_impl_device_get_fd (impl_device); - - ret = drmModeObjectSetProperty (fd, - meta_kms_plane_get_id (plane), - DRM_MODE_OBJECT_PLANE, - prop->prop_id, - prop->value); - if (ret != 0) - { - g_set_error (error, G_IO_ERROR, g_io_error_from_errno (-ret), - "Failed to set plane %u property %u: %s", - meta_kms_plane_get_id (plane), - prop->prop_id, - g_strerror (-ret)); - return FALSE; - } - - return TRUE; -} - static CachedModeSet * cached_mode_set_new (GList *connectors, const drmModeModeInfo *drm_mode) @@ -179,6 +148,42 @@ fill_connector_ids_array (GList *connectors, } } +static gboolean +set_plane_rotation (MetaKmsImpl *impl, + MetaKmsPlane *plane, + uint64_t rotation, + GError **error) +{ + MetaKmsDevice *device = meta_kms_plane_get_device (plane); + MetaKmsImplDevice *impl_device = meta_kms_device_get_impl_device (device); + int fd; + uint32_t rotation_prop_id; + int ret; + + fd = meta_kms_impl_device_get_fd (impl_device); + + rotation_prop_id = meta_kms_plane_get_prop_id (plane, + META_KMS_PLANE_PROP_ROTATION); + ret = drmModeObjectSetProperty (fd, + meta_kms_plane_get_id (plane), + DRM_MODE_OBJECT_PLANE, + rotation_prop_id, + rotation); + if (ret != 0) + { + g_set_error (error, G_IO_ERROR, g_io_error_from_errno (-ret), + "Failed to rotation property (%u) to %" G_GUINT64_FORMAT + " on plane %u: %s", + rotation_prop_id, + rotation, + meta_kms_plane_get_id (plane), + g_strerror (-ret)); + return FALSE; + } + + return TRUE; +} + static gboolean process_mode_set (MetaKmsImpl *impl, MetaKmsUpdate *update, @@ -203,8 +208,6 @@ process_mode_set (MetaKmsImpl *impl, if (mode_set->mode) { - GList *l; - drm_mode = g_alloca (sizeof *drm_mode); *drm_mode = *meta_kms_mode_get_drm_mode (mode_set->mode); @@ -225,12 +228,12 @@ process_mode_set (MetaKmsImpl *impl, x = meta_fixed_16_to_int (plane_assignment->src_rect.x); y = meta_fixed_16_to_int (plane_assignment->src_rect.y); - for (l = plane_assignment->plane_properties; l; l = l->next) + if (plane_assignment->rotation) { - MetaKmsProperty *prop = l->data; - - if (!process_plane_property (impl, plane_assignment->plane, - prop, error)) + if (!set_plane_rotation (impl, + plane_assignment->plane, + plane_assignment->rotation, + error)) return FALSE; } diff --git a/src/backends/native/meta-kms-plane-private.h b/src/backends/native/meta-kms-plane-private.h index b899c65c1..ca200c753 100644 --- a/src/backends/native/meta-kms-plane-private.h +++ b/src/backends/native/meta-kms-plane-private.h @@ -29,6 +29,7 @@ typedef enum _MetaKmsPlaneProp { META_KMS_PLANE_PROP_TYPE = 0, + META_KMS_PLANE_PROP_ROTATION, META_KMS_PLANE_PROP_IN_FORMATS, META_KMS_PLANE_PROP_SRC_X, META_KMS_PLANE_PROP_SRC_Y, diff --git a/src/backends/native/meta-kms-plane.c b/src/backends/native/meta-kms-plane.c index 9ed0cbe3d..6e4add910 100644 --- a/src/backends/native/meta-kms-plane.c +++ b/src/backends/native/meta-kms-plane.c @@ -46,7 +46,6 @@ struct _MetaKmsPlane uint32_t possible_crtcs; - uint32_t rotation_prop_id; uint32_t rotation_map[META_MONITOR_N_TRANSFORMS]; uint32_t all_hw_transforms; @@ -105,9 +104,8 @@ meta_kms_plane_update_set_rotation (MetaKmsPlane *plane, { g_return_if_fail (meta_kms_plane_is_transform_handled (plane, transform)); - meta_kms_plane_assignment_set_plane_property (plane_assignment, - plane->rotation_prop_id, - plane->rotation_map[transform]); + meta_kms_plane_assignment_set_rotation (plane_assignment, + plane->rotation_map[transform]); } gboolean @@ -184,51 +182,36 @@ meta_kms_plane_is_usable_with (MetaKmsPlane *plane, } static void -parse_rotations (MetaKmsPlane *plane, - MetaKmsImplDevice *impl_device, - drmModePropertyPtr prop) +parse_rotations (MetaKmsImplDevice *impl_device, + MetaKmsProp *prop, + drmModePropertyPtr drm_prop, + uint64_t drm_prop_value, + gpointer user_data) { + MetaKmsPlane *plane = user_data; int i; - for (i = 0; i < prop->count_enums; i++) + for (i = 0; i < drm_prop->count_enums; i++) { MetaMonitorTransform transform = -1; - if (strcmp (prop->enums[i].name, "rotate-0") == 0) + if (strcmp (drm_prop->enums[i].name, "rotate-0") == 0) transform = META_MONITOR_TRANSFORM_NORMAL; - else if (strcmp (prop->enums[i].name, "rotate-90") == 0) + else if (strcmp (drm_prop->enums[i].name, "rotate-90") == 0) transform = META_MONITOR_TRANSFORM_90; - else if (strcmp (prop->enums[i].name, "rotate-180") == 0) + else if (strcmp (drm_prop->enums[i].name, "rotate-180") == 0) transform = META_MONITOR_TRANSFORM_180; - else if (strcmp (prop->enums[i].name, "rotate-270") == 0) + else if (strcmp (drm_prop->enums[i].name, "rotate-270") == 0) transform = META_MONITOR_TRANSFORM_270; if (transform != -1) { plane->all_hw_transforms |= 1 << transform; - plane->rotation_map[transform] = 1 << prop->enums[i].value; + plane->rotation_map[transform] = 1 << drm_prop->enums[i].value; } } } -static void -init_rotations (MetaKmsPlane *plane, - MetaKmsImplDevice *impl_device, - drmModeObjectProperties *drm_plane_props) -{ - drmModePropertyPtr prop; - int idx; - - prop = meta_kms_impl_device_find_property (impl_device, drm_plane_props, - "rotation", &idx); - if (prop) - { - plane->rotation_prop_id = drm_plane_props->props[idx]; - parse_rotations (plane, impl_device, prop); - drmModeFreeProperty (prop); - } -} - static inline uint32_t * drm_formats_ptr (struct drm_format_modifier_blob *blob) { @@ -390,6 +373,12 @@ init_properties (MetaKmsPlane *plane, .name = "type", .type = DRM_MODE_PROP_ENUM, }, + [META_KMS_PLANE_PROP_ROTATION] = + { + .name = "rotation", + .type = DRM_MODE_PROP_BITMASK, + .parse = parse_rotations, + }, [META_KMS_PLANE_PROP_IN_FORMATS] = { .name = "IN_FORMATS", @@ -472,8 +461,6 @@ meta_kms_plane_new (MetaKmsPlaneType type, plane->possible_crtcs = drm_plane->possible_crtcs; plane->device = meta_kms_impl_device_get_device (impl_device); - init_rotations (plane, impl_device, drm_plane_props); - init_properties (plane, impl_device, drm_plane, drm_plane_props); init_legacy_formats (plane, impl_device, drm_plane, drm_plane_props); diff --git a/src/backends/native/meta-kms-update-private.h b/src/backends/native/meta-kms-update-private.h index f3d3419d2..d33d92327 100644 --- a/src/backends/native/meta-kms-update-private.h +++ b/src/backends/native/meta-kms-update-private.h @@ -34,12 +34,6 @@ typedef struct _MetaKmsFeedback GError *error; } MetaKmsFeedback; -typedef struct _MetaKmsProperty -{ - uint32_t prop_id; - uint64_t value; -} MetaKmsProperty; - typedef struct _MetaKmsPlaneAssignment { MetaKmsUpdate *update; @@ -50,7 +44,7 @@ typedef struct _MetaKmsPlaneAssignment MetaFixed16Rectangle dst_rect; MetaKmsAssignPlaneFlag flags; - GList *plane_properties; + uint64_t rotation; struct { gboolean is_valid; @@ -120,9 +114,8 @@ void meta_kms_update_set_crtc_gamma (MetaKmsUpdate *update, const uint16_t *green, const uint16_t *blue); -void meta_kms_plane_assignment_set_plane_property (MetaKmsPlaneAssignment *plane_assignment, - uint32_t prop_id, - uint64_t value); +void meta_kms_plane_assignment_set_rotation (MetaKmsPlaneAssignment *plane_assignment, + uint64_t rotation); MetaKmsPlaneAssignment * meta_kms_update_get_primary_plane_assignment (MetaKmsUpdate *update, MetaKmsCrtc *crtc); diff --git a/src/backends/native/meta-kms-update.c b/src/backends/native/meta-kms-update.c index 1cdbef1b7..ed1ddd0a7 100644 --- a/src/backends/native/meta-kms-update.c +++ b/src/backends/native/meta-kms-update.c @@ -118,32 +118,9 @@ meta_kms_feedback_get_error (MetaKmsFeedback *feedback) return feedback->error; } -static MetaKmsProperty * -meta_kms_property_new (uint32_t prop_id, - uint64_t value) -{ - MetaKmsProperty *prop; - - prop = g_new0 (MetaKmsProperty, 1); - *prop = (MetaKmsProperty) { - .prop_id = prop_id, - .value = value, - }; - - return prop; -} - -static void -meta_kms_property_free (MetaKmsProperty *prop) -{ - g_free (prop); -} - static void meta_kms_plane_assignment_free (MetaKmsPlaneAssignment *plane_assignment) { - g_list_free_full (plane_assignment->plane_properties, - (GDestroyNotify) meta_kms_property_free); g_free (plane_assignment); } @@ -328,18 +305,13 @@ meta_kms_update_custom_page_flip (MetaKmsUpdate *update, } void -meta_kms_plane_assignment_set_plane_property (MetaKmsPlaneAssignment *plane_assignment, - uint32_t prop_id, - uint64_t value) +meta_kms_plane_assignment_set_rotation (MetaKmsPlaneAssignment *plane_assignment, + uint64_t rotation) { - MetaKmsProperty *plane_prop; - g_assert (!meta_kms_update_is_sealed (plane_assignment->update)); + g_warn_if_fail (rotation); - plane_prop = meta_kms_property_new (prop_id, value); - - plane_assignment->plane_properties = - g_list_prepend (plane_assignment->plane_properties, plane_prop); + plane_assignment->rotation = rotation; } void