mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 08:30:42 -05:00
backends/native: Use the PropTable to look up KMS values
We already look up all the metadata and values in the MetaKmsConnectorPropTable so we can just use them instead of looking it all up again. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2379>
This commit is contained in:
parent
4e3f3842a1
commit
a49c4e188a
@ -213,42 +213,41 @@ sync_fd_held (MetaKmsConnector *connector,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
set_panel_orientation (MetaKmsConnectorState *state,
|
set_panel_orientation (MetaKmsConnectorState *state,
|
||||||
drmModePropertyPtr prop,
|
MetaKmsProp *panel_orientation)
|
||||||
uint64_t orientation)
|
|
||||||
{
|
{
|
||||||
const char *name;
|
MetaMonitorTransform transform;
|
||||||
|
MetaKmsConnectorPanelOrientation orientation = panel_orientation->value;
|
||||||
|
|
||||||
name = prop->enums[orientation].name;
|
switch (orientation)
|
||||||
if (strcmp (name, "Upside Down") == 0)
|
|
||||||
{
|
{
|
||||||
state->panel_orientation_transform = META_MONITOR_TRANSFORM_180;
|
case META_KMS_CONNECTOR_PANEL_ORIENTATION_UPSIDE_DOWN:
|
||||||
}
|
transform = META_MONITOR_TRANSFORM_180;
|
||||||
else if (strcmp (name, "Left Side Up") == 0)
|
break;
|
||||||
{
|
case META_KMS_CONNECTOR_PANEL_ORIENTATION_LEFT_SIDE_UP:
|
||||||
/* Left side up, rotate 90 degrees counter clockwise to correct */
|
transform = META_MONITOR_TRANSFORM_90;
|
||||||
state->panel_orientation_transform = META_MONITOR_TRANSFORM_90;
|
break;
|
||||||
}
|
case META_KMS_CONNECTOR_PANEL_ORIENTATION_RIGHT_SIDE_UP:
|
||||||
else if (strcmp (name, "Right Side Up") == 0)
|
transform = META_MONITOR_TRANSFORM_270;
|
||||||
{
|
break;
|
||||||
/* Right side up, rotate 270 degrees counter clockwise to correct */
|
default:
|
||||||
state->panel_orientation_transform = META_MONITOR_TRANSFORM_270;
|
transform = META_MONITOR_TRANSFORM_NORMAL;
|
||||||
}
|
break;
|
||||||
else
|
|
||||||
{
|
|
||||||
state->panel_orientation_transform = META_MONITOR_TRANSFORM_NORMAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state->panel_orientation_transform = transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_privacy_screen (MetaKmsConnectorState *state,
|
set_privacy_screen (MetaKmsConnectorState *state,
|
||||||
MetaKmsConnector *connector,
|
MetaKmsConnector *connector,
|
||||||
drmModePropertyPtr prop,
|
MetaKmsProp *hw_state)
|
||||||
uint64_t value)
|
|
||||||
{
|
{
|
||||||
|
MetaKmsConnectorPrivacyScreen privacy_screen = hw_state->value;
|
||||||
|
|
||||||
if (!meta_kms_connector_is_privacy_screen_supported (connector))
|
if (!meta_kms_connector_is_privacy_screen_supported (connector))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (value)
|
switch (privacy_screen)
|
||||||
{
|
{
|
||||||
case META_KMS_PRIVACY_SCREEN_HW_STATE_DISABLED:
|
case META_KMS_PRIVACY_SCREEN_HW_STATE_DISABLED:
|
||||||
state->privacy_screen_state = META_PRIVACY_SCREEN_DISABLED;
|
state->privacy_screen_state = META_PRIVACY_SCREEN_DISABLED;
|
||||||
@ -266,7 +265,7 @@ set_privacy_screen (MetaKmsConnectorState *state,
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
state->privacy_screen_state = META_PRIVACY_SCREEN_DISABLED;
|
state->privacy_screen_state = META_PRIVACY_SCREEN_DISABLED;
|
||||||
g_warning ("Unknown privacy screen state: %" G_GUINT64_FORMAT, value);
|
g_warning ("Unknown privacy screen state: %u", privacy_screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!has_privacy_screen_software_toggle (connector))
|
if (!has_privacy_screen_software_toggle (connector))
|
||||||
@ -279,43 +278,36 @@ state_set_properties (MetaKmsConnectorState *state,
|
|||||||
MetaKmsConnector *connector,
|
MetaKmsConnector *connector,
|
||||||
drmModeConnector *drm_connector)
|
drmModeConnector *drm_connector)
|
||||||
{
|
{
|
||||||
int fd;
|
MetaKmsProp *props = connector->prop_table.props;
|
||||||
int i;
|
MetaKmsProp *prop;
|
||||||
|
|
||||||
fd = meta_kms_impl_device_get_fd (impl_device);
|
prop = &props[META_KMS_CONNECTOR_PROP_SUGGESTED_X];
|
||||||
|
if (prop->prop_id)
|
||||||
|
state->suggested_x = prop->value;
|
||||||
|
|
||||||
for (i = 0; i < drm_connector->count_props; i++)
|
prop = &props[META_KMS_CONNECTOR_PROP_SUGGESTED_Y];
|
||||||
{
|
if (prop->prop_id)
|
||||||
drmModePropertyPtr prop;
|
state->suggested_y = prop->value;
|
||||||
|
|
||||||
prop = drmModeGetProperty (fd, drm_connector->props[i]);
|
prop = &props[META_KMS_CONNECTOR_PROP_HOTPLUG_MODE_UPDATE];
|
||||||
if (!prop)
|
if (prop->prop_id)
|
||||||
continue;
|
state->hotplug_mode_update = prop->value;
|
||||||
|
|
||||||
if ((prop->flags & DRM_MODE_PROP_RANGE) &&
|
prop = &props[META_KMS_CONNECTOR_PROP_SCALING_MODE];
|
||||||
strcmp (prop->name, "suggested X") == 0)
|
if (prop->prop_id)
|
||||||
state->suggested_x = drm_connector->prop_values[i];
|
|
||||||
else if ((prop->flags & DRM_MODE_PROP_RANGE) &&
|
|
||||||
strcmp (prop->name, "suggested Y") == 0)
|
|
||||||
state->suggested_y = drm_connector->prop_values[i];
|
|
||||||
else if ((prop->flags & DRM_MODE_PROP_RANGE) &&
|
|
||||||
strcmp (prop->name, "hotplug_mode_update") == 0)
|
|
||||||
state->hotplug_mode_update = drm_connector->prop_values[i];
|
|
||||||
else if (strcmp (prop->name, "scaling mode") == 0)
|
|
||||||
state->has_scaling = TRUE;
|
state->has_scaling = TRUE;
|
||||||
else if ((prop->flags & DRM_MODE_PROP_ENUM) &&
|
|
||||||
strcmp (prop->name, "panel orientation") == 0)
|
|
||||||
set_panel_orientation (state, prop, drm_connector->prop_values[i]);
|
|
||||||
else if ((prop->flags & DRM_MODE_PROP_RANGE) &&
|
|
||||||
strcmp (prop->name, "non-desktop") == 0)
|
|
||||||
state->non_desktop = drm_connector->prop_values[i];
|
|
||||||
else if (prop->prop_id == meta_kms_connector_get_prop_id (connector,
|
|
||||||
META_KMS_CONNECTOR_PROP_PRIVACY_SCREEN_HW_STATE))
|
|
||||||
set_privacy_screen (state, connector, prop,
|
|
||||||
drm_connector->prop_values[i]);
|
|
||||||
|
|
||||||
drmModeFreeProperty (prop);
|
prop = &props[META_KMS_CONNECTOR_PROP_PANEL_ORIENTATION];
|
||||||
}
|
if (prop->prop_id)
|
||||||
|
set_panel_orientation (state, prop);
|
||||||
|
|
||||||
|
prop = &props[META_KMS_CONNECTOR_PROP_NON_DESKTOP];
|
||||||
|
if (prop->prop_id)
|
||||||
|
state->non_desktop = prop->value;
|
||||||
|
|
||||||
|
prop = &props[META_KMS_CONNECTOR_PROP_PRIVACY_SCREEN_HW_STATE];
|
||||||
|
if (prop->prop_id)
|
||||||
|
set_privacy_screen (state, connector, prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
static CoglSubpixelOrder
|
static CoglSubpixelOrder
|
||||||
@ -416,36 +408,15 @@ state_set_blobs (MetaKmsConnectorState *state,
|
|||||||
MetaKmsImplDevice *impl_device,
|
MetaKmsImplDevice *impl_device,
|
||||||
drmModeConnector *drm_connector)
|
drmModeConnector *drm_connector)
|
||||||
{
|
{
|
||||||
int fd;
|
MetaKmsProp *prop;
|
||||||
int i;
|
|
||||||
|
|
||||||
fd = meta_kms_impl_device_get_fd (impl_device);
|
prop = &connector->prop_table.props[META_KMS_CONNECTOR_PROP_EDID];
|
||||||
|
if (prop->prop_id && prop->value)
|
||||||
|
state_set_edid (state, connector, impl_device, prop->value);
|
||||||
|
|
||||||
for (i = 0; i < drm_connector->count_props; i++)
|
prop = &connector->prop_table.props[META_KMS_CONNECTOR_PROP_TILE];
|
||||||
{
|
if (prop->prop_id && prop->value)
|
||||||
drmModePropertyPtr prop;
|
state_set_tile_info (state, connector, impl_device, prop->value);
|
||||||
|
|
||||||
prop = drmModeGetProperty (fd, drm_connector->props[i]);
|
|
||||||
if (!prop)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (prop->flags & DRM_MODE_PROP_BLOB)
|
|
||||||
{
|
|
||||||
uint32_t blob_id;
|
|
||||||
|
|
||||||
blob_id = drm_connector->prop_values[i];
|
|
||||||
|
|
||||||
if (blob_id)
|
|
||||||
{
|
|
||||||
if (strcmp (prop->name, "EDID") == 0)
|
|
||||||
state_set_edid (state, connector, impl_device, blob_id);
|
|
||||||
else if (strcmp (prop->name, "TILE") == 0)
|
|
||||||
state_set_tile_info (state, connector, impl_device, blob_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
drmModeFreeProperty (prop);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user