kms/update: Make plane assignment take rotation instead of property list
Instead of having MetaKmsPlaneAssignment carry a low level property list, set the actual state change, and then have the implementation translate that into the necessary property changes. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
This commit is contained in:
parent
2b7b4576fb
commit
c1ce36f08e
@ -31,7 +31,7 @@
|
|||||||
#include "backends/native/meta-kms-device-private.h"
|
#include "backends/native/meta-kms-device-private.h"
|
||||||
#include "backends/native/meta-kms-mode.h"
|
#include "backends/native/meta-kms-mode.h"
|
||||||
#include "backends/native/meta-kms-page-flip-private.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-private.h"
|
||||||
#include "backends/native/meta-kms-update-private.h"
|
#include "backends/native/meta-kms-update-private.h"
|
||||||
#include "backends/native/meta-kms-utils.h"
|
#include "backends/native/meta-kms-utils.h"
|
||||||
@ -106,37 +106,6 @@ process_connector_property (MetaKmsImpl *impl,
|
|||||||
return TRUE;
|
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 *
|
static CachedModeSet *
|
||||||
cached_mode_set_new (GList *connectors,
|
cached_mode_set_new (GList *connectors,
|
||||||
const drmModeModeInfo *drm_mode)
|
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
|
static gboolean
|
||||||
process_mode_set (MetaKmsImpl *impl,
|
process_mode_set (MetaKmsImpl *impl,
|
||||||
MetaKmsUpdate *update,
|
MetaKmsUpdate *update,
|
||||||
@ -203,8 +208,6 @@ process_mode_set (MetaKmsImpl *impl,
|
|||||||
|
|
||||||
if (mode_set->mode)
|
if (mode_set->mode)
|
||||||
{
|
{
|
||||||
GList *l;
|
|
||||||
|
|
||||||
drm_mode = g_alloca (sizeof *drm_mode);
|
drm_mode = g_alloca (sizeof *drm_mode);
|
||||||
*drm_mode = *meta_kms_mode_get_drm_mode (mode_set->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);
|
x = meta_fixed_16_to_int (plane_assignment->src_rect.x);
|
||||||
y = meta_fixed_16_to_int (plane_assignment->src_rect.y);
|
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 (!set_plane_rotation (impl,
|
||||||
|
plane_assignment->plane,
|
||||||
if (!process_plane_property (impl, plane_assignment->plane,
|
plane_assignment->rotation,
|
||||||
prop, error))
|
error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
typedef enum _MetaKmsPlaneProp
|
typedef enum _MetaKmsPlaneProp
|
||||||
{
|
{
|
||||||
META_KMS_PLANE_PROP_TYPE = 0,
|
META_KMS_PLANE_PROP_TYPE = 0,
|
||||||
|
META_KMS_PLANE_PROP_ROTATION,
|
||||||
META_KMS_PLANE_PROP_IN_FORMATS,
|
META_KMS_PLANE_PROP_IN_FORMATS,
|
||||||
META_KMS_PLANE_PROP_SRC_X,
|
META_KMS_PLANE_PROP_SRC_X,
|
||||||
META_KMS_PLANE_PROP_SRC_Y,
|
META_KMS_PLANE_PROP_SRC_Y,
|
||||||
|
@ -46,7 +46,6 @@ struct _MetaKmsPlane
|
|||||||
|
|
||||||
uint32_t possible_crtcs;
|
uint32_t possible_crtcs;
|
||||||
|
|
||||||
uint32_t rotation_prop_id;
|
|
||||||
uint32_t rotation_map[META_MONITOR_N_TRANSFORMS];
|
uint32_t rotation_map[META_MONITOR_N_TRANSFORMS];
|
||||||
uint32_t all_hw_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));
|
g_return_if_fail (meta_kms_plane_is_transform_handled (plane, transform));
|
||||||
|
|
||||||
meta_kms_plane_assignment_set_plane_property (plane_assignment,
|
meta_kms_plane_assignment_set_rotation (plane_assignment,
|
||||||
plane->rotation_prop_id,
|
plane->rotation_map[transform]);
|
||||||
plane->rotation_map[transform]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
@ -184,51 +182,36 @@ meta_kms_plane_is_usable_with (MetaKmsPlane *plane,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
parse_rotations (MetaKmsPlane *plane,
|
parse_rotations (MetaKmsImplDevice *impl_device,
|
||||||
MetaKmsImplDevice *impl_device,
|
MetaKmsProp *prop,
|
||||||
drmModePropertyPtr prop)
|
drmModePropertyPtr drm_prop,
|
||||||
|
uint64_t drm_prop_value,
|
||||||
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
MetaKmsPlane *plane = user_data;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < prop->count_enums; i++)
|
for (i = 0; i < drm_prop->count_enums; i++)
|
||||||
{
|
{
|
||||||
MetaMonitorTransform transform = -1;
|
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;
|
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;
|
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;
|
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;
|
transform = META_MONITOR_TRANSFORM_270;
|
||||||
|
|
||||||
if (transform != -1)
|
if (transform != -1)
|
||||||
{
|
{
|
||||||
plane->all_hw_transforms |= 1 << transform;
|
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 *
|
static inline uint32_t *
|
||||||
drm_formats_ptr (struct drm_format_modifier_blob *blob)
|
drm_formats_ptr (struct drm_format_modifier_blob *blob)
|
||||||
{
|
{
|
||||||
@ -390,6 +373,12 @@ init_properties (MetaKmsPlane *plane,
|
|||||||
.name = "type",
|
.name = "type",
|
||||||
.type = DRM_MODE_PROP_ENUM,
|
.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] =
|
[META_KMS_PLANE_PROP_IN_FORMATS] =
|
||||||
{
|
{
|
||||||
.name = "IN_FORMATS",
|
.name = "IN_FORMATS",
|
||||||
@ -472,8 +461,6 @@ meta_kms_plane_new (MetaKmsPlaneType type,
|
|||||||
plane->possible_crtcs = drm_plane->possible_crtcs;
|
plane->possible_crtcs = drm_plane->possible_crtcs;
|
||||||
plane->device = meta_kms_impl_device_get_device (impl_device);
|
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_properties (plane, impl_device, drm_plane, drm_plane_props);
|
||||||
init_legacy_formats (plane, impl_device, drm_plane, drm_plane_props);
|
init_legacy_formats (plane, impl_device, drm_plane, drm_plane_props);
|
||||||
|
|
||||||
|
@ -34,12 +34,6 @@ typedef struct _MetaKmsFeedback
|
|||||||
GError *error;
|
GError *error;
|
||||||
} MetaKmsFeedback;
|
} MetaKmsFeedback;
|
||||||
|
|
||||||
typedef struct _MetaKmsProperty
|
|
||||||
{
|
|
||||||
uint32_t prop_id;
|
|
||||||
uint64_t value;
|
|
||||||
} MetaKmsProperty;
|
|
||||||
|
|
||||||
typedef struct _MetaKmsPlaneAssignment
|
typedef struct _MetaKmsPlaneAssignment
|
||||||
{
|
{
|
||||||
MetaKmsUpdate *update;
|
MetaKmsUpdate *update;
|
||||||
@ -50,7 +44,7 @@ typedef struct _MetaKmsPlaneAssignment
|
|||||||
MetaFixed16Rectangle dst_rect;
|
MetaFixed16Rectangle dst_rect;
|
||||||
MetaKmsAssignPlaneFlag flags;
|
MetaKmsAssignPlaneFlag flags;
|
||||||
|
|
||||||
GList *plane_properties;
|
uint64_t rotation;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
gboolean is_valid;
|
gboolean is_valid;
|
||||||
@ -120,9 +114,8 @@ void meta_kms_update_set_crtc_gamma (MetaKmsUpdate *update,
|
|||||||
const uint16_t *green,
|
const uint16_t *green,
|
||||||
const uint16_t *blue);
|
const uint16_t *blue);
|
||||||
|
|
||||||
void meta_kms_plane_assignment_set_plane_property (MetaKmsPlaneAssignment *plane_assignment,
|
void meta_kms_plane_assignment_set_rotation (MetaKmsPlaneAssignment *plane_assignment,
|
||||||
uint32_t prop_id,
|
uint64_t rotation);
|
||||||
uint64_t value);
|
|
||||||
|
|
||||||
MetaKmsPlaneAssignment * meta_kms_update_get_primary_plane_assignment (MetaKmsUpdate *update,
|
MetaKmsPlaneAssignment * meta_kms_update_get_primary_plane_assignment (MetaKmsUpdate *update,
|
||||||
MetaKmsCrtc *crtc);
|
MetaKmsCrtc *crtc);
|
||||||
|
@ -118,32 +118,9 @@ meta_kms_feedback_get_error (MetaKmsFeedback *feedback)
|
|||||||
return feedback->error;
|
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
|
static void
|
||||||
meta_kms_plane_assignment_free (MetaKmsPlaneAssignment *plane_assignment)
|
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);
|
g_free (plane_assignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,18 +305,13 @@ meta_kms_update_custom_page_flip (MetaKmsUpdate *update,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_kms_plane_assignment_set_plane_property (MetaKmsPlaneAssignment *plane_assignment,
|
meta_kms_plane_assignment_set_rotation (MetaKmsPlaneAssignment *plane_assignment,
|
||||||
uint32_t prop_id,
|
uint64_t rotation)
|
||||||
uint64_t value)
|
|
||||||
{
|
{
|
||||||
MetaKmsProperty *plane_prop;
|
|
||||||
|
|
||||||
g_assert (!meta_kms_update_is_sealed (plane_assignment->update));
|
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->rotation = rotation;
|
||||||
|
|
||||||
plane_assignment->plane_properties =
|
|
||||||
g_list_prepend (plane_assignment->plane_properties, plane_prop);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user