mirror of
https://github.com/brl/mutter.git
synced 2024-12-27 05:12:15 +00:00
backends/native: Use MetaKmsPlaneRotation in plane updates
The ImplDeviceAtomic converts the MetaKmsPlaneRotation back to the concrete KMS value. The MetaMonitorTransform is always directly converted to a MetaKmsPlaneRotation. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2379>
This commit is contained in:
parent
981524c268
commit
4e3f3842a1
@ -97,6 +97,10 @@ uint32_t meta_kms_connector_get_prop_id (MetaKmsConnector *connector,
|
||||
const char * meta_kms_connector_get_prop_name (MetaKmsConnector *connector,
|
||||
MetaKmsConnectorProp prop);
|
||||
|
||||
uint64_t meta_kms_connector_get_prop_drm_value (MetaKmsConnector *connector,
|
||||
MetaKmsConnectorProp prop,
|
||||
uint64_t value);
|
||||
|
||||
MetaKmsUpdateChanges meta_kms_connector_update_state (MetaKmsConnector *connector,
|
||||
drmModeRes *drm_resources);
|
||||
|
||||
|
@ -94,6 +94,15 @@ meta_kms_connector_get_prop_name (MetaKmsConnector *connector,
|
||||
return connector->prop_table.props[prop].name;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
meta_kms_connector_get_prop_drm_value (MetaKmsConnector *connector,
|
||||
MetaKmsConnectorProp property,
|
||||
uint64_t value)
|
||||
{
|
||||
MetaKmsProp *prop = &connector->prop_table.props[property];
|
||||
return meta_kms_prop_convert_value (prop, value);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
meta_kms_connector_get_connector_type (MetaKmsConnector *connector)
|
||||
{
|
||||
|
@ -51,4 +51,8 @@ uint32_t meta_kms_crtc_get_prop_id (MetaKmsCrtc *crtc,
|
||||
const char * meta_kms_crtc_get_prop_name (MetaKmsCrtc *crtc,
|
||||
MetaKmsCrtcProp prop);
|
||||
|
||||
uint64_t meta_kms_crtc_get_prop_drm_value (MetaKmsCrtc *crtc,
|
||||
MetaKmsCrtcProp prop,
|
||||
uint64_t value);
|
||||
|
||||
#endif /* META_KMS_CRTC_PRIVATE_H */
|
||||
|
@ -86,6 +86,15 @@ meta_kms_crtc_get_prop_name (MetaKmsCrtc *crtc,
|
||||
return crtc->prop_table.props[prop].name;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
meta_kms_crtc_get_prop_drm_value (MetaKmsCrtc *crtc,
|
||||
MetaKmsCrtcProp property,
|
||||
uint64_t value)
|
||||
{
|
||||
MetaKmsProp *prop = &crtc->prop_table.props[property];
|
||||
return meta_kms_prop_convert_value (prop, value);
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_kms_crtc_is_active (MetaKmsCrtc *crtc)
|
||||
{
|
||||
|
@ -114,6 +114,8 @@ add_connector_property (MetaKmsImplDevice *impl_device,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
value = meta_kms_connector_get_prop_drm_value (connector, prop, value);
|
||||
|
||||
meta_topic (META_DEBUG_KMS,
|
||||
"[atomic] Setting connector %u (%s) property '%s' (%u) to %"
|
||||
G_GUINT64_FORMAT,
|
||||
@ -165,15 +167,17 @@ process_connector_update (MetaKmsImplDevice *impl_device,
|
||||
if (!add_connector_property (impl_device,
|
||||
connector, req,
|
||||
META_KMS_CONNECTOR_PROP_UNDERSCAN,
|
||||
1,
|
||||
META_KMS_CONNECTOR_UNDERSCAN_ON,
|
||||
error))
|
||||
return FALSE;
|
||||
|
||||
if (!add_connector_property (impl_device,
|
||||
connector, req,
|
||||
META_KMS_CONNECTOR_PROP_UNDERSCAN_HBORDER,
|
||||
connector_update->underscanning.hborder,
|
||||
error))
|
||||
return FALSE;
|
||||
|
||||
if (!add_connector_property (impl_device,
|
||||
connector, req,
|
||||
META_KMS_CONNECTOR_PROP_UNDERSCAN_VBORDER,
|
||||
@ -191,7 +195,7 @@ process_connector_update (MetaKmsImplDevice *impl_device,
|
||||
if (!add_connector_property (impl_device,
|
||||
connector, req,
|
||||
META_KMS_CONNECTOR_PROP_UNDERSCAN,
|
||||
0,
|
||||
META_KMS_CONNECTOR_UNDERSCAN_OFF,
|
||||
error))
|
||||
return FALSE;
|
||||
}
|
||||
@ -207,7 +211,9 @@ process_connector_update (MetaKmsImplDevice *impl_device,
|
||||
if (!add_connector_property (impl_device,
|
||||
connector, req,
|
||||
META_KMS_CONNECTOR_PROP_PRIVACY_SCREEN_SW_STATE,
|
||||
connector_update->privacy_screen.is_enabled,
|
||||
connector_update->privacy_screen.is_enabled ?
|
||||
META_KMS_CONNECTOR_PRIVACY_SCREEN_ENABLED :
|
||||
META_KMS_CONNECTOR_PRIVACY_SCREEN_DISABLED,
|
||||
error))
|
||||
return FALSE;
|
||||
}
|
||||
@ -235,6 +241,8 @@ add_crtc_property (MetaKmsImplDevice *impl_device,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
value = meta_kms_crtc_get_prop_drm_value (crtc, prop, value);
|
||||
|
||||
meta_topic (META_DEBUG_KMS,
|
||||
"[atomic] Setting CRTC %u (%s) property '%s' (%u) to %"
|
||||
G_GUINT64_FORMAT,
|
||||
@ -364,6 +372,8 @@ add_plane_property (MetaKmsImplDevice *impl_device,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
value = meta_kms_plane_get_prop_drm_value (plane, prop, value);
|
||||
|
||||
switch (meta_kms_plane_get_prop_internal_type (plane, prop))
|
||||
{
|
||||
case META_KMS_PROP_TYPE_RAW:
|
||||
@ -546,17 +556,14 @@ process_plane_assignment (MetaKmsImplDevice *impl_device,
|
||||
if (plane_assignment->rotation)
|
||||
{
|
||||
meta_topic (META_DEBUG_KMS,
|
||||
"[atomic] Setting plane (%u, %s) rotation to %"
|
||||
G_GUINT64_FORMAT,
|
||||
"[atomic] Setting plane (%u, %s) rotation to %u",
|
||||
meta_kms_plane_get_id (plane),
|
||||
meta_kms_impl_device_get_path (impl_device),
|
||||
plane_assignment->rotation);
|
||||
|
||||
if (!add_plane_property (impl_device,
|
||||
plane, req,
|
||||
if (!add_plane_property (impl_device, plane, req,
|
||||
META_KMS_PLANE_PROP_ROTATION,
|
||||
plane_assignment->rotation,
|
||||
error))
|
||||
plane_assignment->rotation, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -81,6 +81,10 @@ uint32_t meta_kms_plane_get_prop_id (MetaKmsPlane *plane,
|
||||
const char * meta_kms_plane_get_prop_name (MetaKmsPlane *plane,
|
||||
MetaKmsPlaneProp prop);
|
||||
|
||||
uint64_t meta_kms_plane_get_prop_drm_value (MetaKmsPlane *plane,
|
||||
MetaKmsPlaneProp prop,
|
||||
uint64_t value);
|
||||
|
||||
MetaKmsPropType meta_kms_plane_get_prop_internal_type (MetaKmsPlane *plane,
|
||||
MetaKmsPlaneProp prop);
|
||||
|
||||
|
@ -47,8 +47,7 @@ struct _MetaKmsPlane
|
||||
|
||||
uint32_t possible_crtcs;
|
||||
|
||||
uint32_t rotation_map[META_MONITOR_N_TRANSFORMS];
|
||||
uint32_t all_hw_transforms;
|
||||
MetaKmsPlaneRotation rotations;
|
||||
|
||||
/*
|
||||
* primary plane's supported formats and maybe modifiers
|
||||
@ -105,15 +104,59 @@ meta_kms_plane_get_prop_internal_type (MetaKmsPlane *plane,
|
||||
return plane->prop_table.props[prop].internal_type;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
meta_kms_plane_get_prop_drm_value (MetaKmsPlane *plane,
|
||||
MetaKmsPlaneProp property,
|
||||
uint64_t value)
|
||||
{
|
||||
MetaKmsProp *prop = &plane->prop_table.props[property];
|
||||
return meta_kms_prop_convert_value (prop, value);
|
||||
}
|
||||
|
||||
void
|
||||
meta_kms_plane_update_set_rotation (MetaKmsPlane *plane,
|
||||
MetaKmsPlaneAssignment *plane_assignment,
|
||||
MetaMonitorTransform transform)
|
||||
{
|
||||
MetaKmsPlaneRotation kms_rotation = 0;
|
||||
|
||||
g_return_if_fail (meta_kms_plane_is_transform_handled (plane, transform));
|
||||
|
||||
meta_kms_plane_assignment_set_rotation (plane_assignment,
|
||||
plane->rotation_map[transform]);
|
||||
switch (transform)
|
||||
{
|
||||
case META_MONITOR_TRANSFORM_NORMAL:
|
||||
kms_rotation = META_KMS_PLANE_ROTATION_ROTATE_0;
|
||||
break;
|
||||
case META_MONITOR_TRANSFORM_90:
|
||||
kms_rotation = META_KMS_PLANE_ROTATION_ROTATE_90;
|
||||
break;
|
||||
case META_MONITOR_TRANSFORM_180:
|
||||
kms_rotation = META_KMS_PLANE_ROTATION_ROTATE_180;
|
||||
break;
|
||||
case META_MONITOR_TRANSFORM_270:
|
||||
kms_rotation = META_KMS_PLANE_ROTATION_ROTATE_270;
|
||||
break;
|
||||
case META_MONITOR_TRANSFORM_FLIPPED:
|
||||
kms_rotation = META_KMS_PLANE_ROTATION_ROTATE_0 |
|
||||
META_KMS_PLANE_ROTATION_REFLECT_X;
|
||||
break;
|
||||
case META_MONITOR_TRANSFORM_FLIPPED_90:
|
||||
kms_rotation = META_KMS_PLANE_ROTATION_ROTATE_90 |
|
||||
META_KMS_PLANE_ROTATION_REFLECT_X;
|
||||
break;
|
||||
case META_MONITOR_TRANSFORM_FLIPPED_180:
|
||||
kms_rotation = META_KMS_PLANE_ROTATION_ROTATE_180 |
|
||||
META_KMS_PLANE_ROTATION_REFLECT_X;
|
||||
break;
|
||||
case META_MONITOR_TRANSFORM_FLIPPED_270:
|
||||
kms_rotation = META_KMS_PLANE_ROTATION_ROTATE_270 |
|
||||
META_KMS_PLANE_ROTATION_REFLECT_X;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
meta_kms_plane_assignment_set_rotation (plane_assignment, kms_rotation);
|
||||
}
|
||||
|
||||
gboolean
|
||||
@ -123,23 +166,29 @@ meta_kms_plane_is_transform_handled (MetaKmsPlane *plane,
|
||||
switch (transform)
|
||||
{
|
||||
case META_MONITOR_TRANSFORM_NORMAL:
|
||||
return plane->rotations & META_KMS_PLANE_ROTATION_ROTATE_0;
|
||||
case META_MONITOR_TRANSFORM_180:
|
||||
return plane->rotations & META_KMS_PLANE_ROTATION_ROTATE_180;
|
||||
case META_MONITOR_TRANSFORM_FLIPPED:
|
||||
return plane->rotations & (META_KMS_PLANE_ROTATION_ROTATE_0 |
|
||||
META_KMS_PLANE_ROTATION_REFLECT_X);
|
||||
case META_MONITOR_TRANSFORM_FLIPPED_180:
|
||||
break;
|
||||
return plane->rotations & (META_KMS_PLANE_ROTATION_ROTATE_180 |
|
||||
META_KMS_PLANE_ROTATION_REFLECT_X);
|
||||
/*
|
||||
* Deny these transforms as testing shows that they don't work
|
||||
* anyway, e.g. due to the wrong buffer modifiers. They might as well be
|
||||
* less optimal due to the complexity dealing with rotation at scan-out,
|
||||
* potentially resulting in higher power consumption.
|
||||
*/
|
||||
case META_MONITOR_TRANSFORM_90:
|
||||
case META_MONITOR_TRANSFORM_270:
|
||||
case META_MONITOR_TRANSFORM_FLIPPED_90:
|
||||
case META_MONITOR_TRANSFORM_FLIPPED_270:
|
||||
/*
|
||||
* Blacklist these transforms as testing shows that they don't work
|
||||
* anyway, e.g. due to the wrong buffer modifiers. They might as well be
|
||||
* less optimal due to the complexity dealing with rotation at scan-out,
|
||||
* potentially resulting in higher power consumption.
|
||||
*/
|
||||
return FALSE;
|
||||
}
|
||||
return plane->all_hw_transforms & (1 << transform);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GArray *
|
||||
@ -189,44 +238,6 @@ meta_kms_plane_is_usable_with (MetaKmsPlane *plane,
|
||||
return !!(plane->possible_crtcs & (1 << meta_kms_crtc_get_idx (crtc)));
|
||||
}
|
||||
|
||||
static void
|
||||
update_rotations (MetaKmsPlane *plane)
|
||||
{
|
||||
MetaKmsProp *prop;
|
||||
MetaKmsPlaneRotation rotation;
|
||||
|
||||
prop = &plane->prop_table.props[META_KMS_PLANE_PROP_ROTATION];
|
||||
rotation = prop->value;
|
||||
|
||||
if (rotation & META_KMS_PLANE_ROTATION_ROTATE_0)
|
||||
{
|
||||
plane->all_hw_transforms |= 1 << META_MONITOR_TRANSFORM_NORMAL;
|
||||
plane->rotation_map[META_MONITOR_TRANSFORM_NORMAL] =
|
||||
1 << prop->enum_values[META_KMS_PLANE_ROTATION_BIT_ROTATE_0].value;
|
||||
}
|
||||
|
||||
if (rotation & META_KMS_PLANE_ROTATION_ROTATE_90)
|
||||
{
|
||||
plane->all_hw_transforms |= 1 << META_MONITOR_TRANSFORM_90;
|
||||
plane->rotation_map[META_MONITOR_TRANSFORM_90] =
|
||||
1 << prop->enum_values[META_KMS_PLANE_ROTATION_BIT_ROTATE_90].value;
|
||||
}
|
||||
|
||||
if (rotation & META_KMS_PLANE_ROTATION_ROTATE_180)
|
||||
{
|
||||
plane->all_hw_transforms |= 1 << META_MONITOR_TRANSFORM_180;
|
||||
plane->rotation_map[META_MONITOR_TRANSFORM_180] =
|
||||
1 << prop->enum_values[META_KMS_PLANE_ROTATION_BIT_ROTATE_180].value;
|
||||
}
|
||||
|
||||
if (rotation & META_KMS_PLANE_ROTATION_ROTATE_270)
|
||||
{
|
||||
plane->all_hw_transforms |= 1 << META_MONITOR_TRANSFORM_270;
|
||||
plane->rotation_map[META_MONITOR_TRANSFORM_270] =
|
||||
1 << prop->enum_values[META_KMS_PLANE_ROTATION_BIT_ROTATE_270].value;
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint32_t *
|
||||
drm_formats_ptr (struct drm_format_modifier_blob *blob)
|
||||
{
|
||||
@ -369,6 +380,19 @@ update_legacy_formats (MetaKmsPlane *plane,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
update_rotations (MetaKmsPlane *plane)
|
||||
{
|
||||
unsigned int i;
|
||||
MetaKmsProp *rotation = &plane->prop_table.props[META_KMS_PLANE_PROP_ROTATION];
|
||||
|
||||
for (i = 0; i < rotation->num_enum_values; i++)
|
||||
{
|
||||
if (rotation->enum_values[i].valid)
|
||||
plane->rotations |= rotation->enum_values[i].bitmask;
|
||||
}
|
||||
}
|
||||
|
||||
static MetaKmsUpdateChanges
|
||||
meta_kms_plane_read_state (MetaKmsPlane *plane,
|
||||
MetaKmsImplDevice *impl_device,
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <glib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "backends/native/meta-kms-plane-private.h"
|
||||
#include "backends/native/meta-kms-types.h"
|
||||
#include "backends/native/meta-kms-update.h"
|
||||
|
||||
@ -50,8 +51,7 @@ typedef struct _MetaKmsPlaneAssignment
|
||||
MetaRectangle dst_rect;
|
||||
MetaKmsAssignPlaneFlag flags;
|
||||
MetaKmsFbDamage *fb_damage;
|
||||
|
||||
uint64_t rotation;
|
||||
MetaKmsPlaneRotation rotation;
|
||||
|
||||
struct {
|
||||
gboolean is_valid;
|
||||
@ -133,7 +133,7 @@ META_EXPORT_TEST
|
||||
MetaKmsDevice * meta_kms_update_get_device (MetaKmsUpdate *update);
|
||||
|
||||
void meta_kms_plane_assignment_set_rotation (MetaKmsPlaneAssignment *plane_assignment,
|
||||
uint64_t rotation);
|
||||
MetaKmsPlaneRotation rotation);
|
||||
|
||||
META_EXPORT_TEST
|
||||
MetaKmsPlaneAssignment * meta_kms_update_get_primary_plane_assignment (MetaKmsUpdate *update,
|
||||
|
@ -497,7 +497,7 @@ meta_kms_plane_assignment_set_fb_damage (MetaKmsPlaneAssignment *plane_assignmen
|
||||
|
||||
void
|
||||
meta_kms_plane_assignment_set_rotation (MetaKmsPlaneAssignment *plane_assignment,
|
||||
uint64_t rotation)
|
||||
MetaKmsPlaneRotation rotation)
|
||||
{
|
||||
g_assert (!meta_kms_update_is_locked (plane_assignment->update));
|
||||
g_warn_if_fail (rotation);
|
||||
|
Loading…
Reference in New Issue
Block a user