backends/native: Update PropTable on hotplug and remove parse callback
Updating the PropTable has the side effect that the parse callback now also gets called on hotplug but it is used to initialize data. The parse callbacks are moved to the read_state functions which are aware if this is an initializing call or just an update. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2379>
This commit is contained in:
parent
1e06b346cb
commit
981524c268
@ -675,6 +675,13 @@ meta_kms_connector_read_state (MetaKmsConnector *connector,
|
||||
current_state = g_steal_pointer (&connector->current_state);
|
||||
changes = META_KMS_UPDATE_CHANGE_NONE;
|
||||
|
||||
meta_kms_impl_device_update_prop_table (impl_device,
|
||||
drm_connector->props,
|
||||
drm_connector->prop_values,
|
||||
drm_connector->count_props,
|
||||
connector->prop_table.props,
|
||||
META_KMS_CONNECTOR_N_PROPS);
|
||||
|
||||
if (!drm_connector)
|
||||
{
|
||||
if (current_state)
|
||||
@ -1048,14 +1055,6 @@ init_properties (MetaKmsConnector *connector,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
meta_kms_impl_device_init_prop_table (impl_device,
|
||||
drm_connector->props,
|
||||
drm_connector->prop_values,
|
||||
drm_connector->count_props,
|
||||
connector->prop_table.props,
|
||||
META_KMS_CONNECTOR_N_PROPS,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static char *
|
||||
|
@ -156,24 +156,6 @@ meta_kms_crtc_state_changes (MetaKmsCrtcState *state,
|
||||
return META_KMS_UPDATE_CHANGE_NONE;
|
||||
}
|
||||
|
||||
static int
|
||||
find_prop_idx (MetaKmsProp *prop,
|
||||
uint32_t *drm_props,
|
||||
int n_drm_props)
|
||||
{
|
||||
int i;
|
||||
|
||||
g_return_val_if_fail (prop->prop_id > 0, -1);
|
||||
|
||||
for (i = 0; i < n_drm_props; i++)
|
||||
{
|
||||
if (drm_props[i] == prop->prop_id)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
clear_gamma_state (MetaKmsCrtcState *crtc_state)
|
||||
{
|
||||
@ -192,7 +174,13 @@ meta_kms_crtc_read_state (MetaKmsCrtc *crtc,
|
||||
MetaKmsCrtcState crtc_state = {0};
|
||||
MetaKmsUpdateChanges changes = META_KMS_UPDATE_CHANGE_NONE;
|
||||
MetaKmsProp *active_prop;
|
||||
int active_idx;
|
||||
|
||||
meta_kms_impl_device_update_prop_table (impl_device,
|
||||
drm_props->props,
|
||||
drm_props->prop_values,
|
||||
drm_props->count_props,
|
||||
crtc->prop_table.props,
|
||||
META_KMS_CRTC_N_PROPS);
|
||||
|
||||
crtc_state.rect = (MetaRectangle) {
|
||||
.x = drm_crtc->x,
|
||||
@ -205,17 +193,11 @@ meta_kms_crtc_read_state (MetaKmsCrtc *crtc,
|
||||
crtc_state.drm_mode = drm_crtc->mode;
|
||||
|
||||
active_prop = &crtc->prop_table.props[META_KMS_CRTC_PROP_ACTIVE];
|
||||
|
||||
if (active_prop->prop_id)
|
||||
{
|
||||
active_idx = find_prop_idx (active_prop,
|
||||
drm_props->props,
|
||||
drm_props->count_props);
|
||||
crtc_state.is_active = !!drm_props->prop_values[active_idx];
|
||||
}
|
||||
crtc_state.is_active = !!active_prop->value;
|
||||
else
|
||||
{
|
||||
crtc_state.is_active = drm_crtc->mode_valid;
|
||||
}
|
||||
crtc_state.is_active = drm_crtc->mode_valid;
|
||||
|
||||
read_gamma_state (crtc, &crtc_state, impl_device, drm_crtc);
|
||||
|
||||
@ -350,27 +332,12 @@ meta_kms_crtc_predict_state (MetaKmsCrtc *crtc,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
parse_active (MetaKmsImplDevice *impl_device,
|
||||
MetaKmsProp *prop,
|
||||
drmModePropertyPtr drm_prop,
|
||||
uint64_t drm_prop_value,
|
||||
gpointer user_data)
|
||||
{
|
||||
MetaKmsCrtc *crtc = user_data;
|
||||
|
||||
crtc->current_state.is_active = !!drm_prop_value;
|
||||
}
|
||||
|
||||
static void
|
||||
init_properties (MetaKmsCrtc *crtc,
|
||||
MetaKmsImplDevice *impl_device,
|
||||
drmModeCrtc *drm_crtc)
|
||||
{
|
||||
MetaKmsCrtcPropTable *prop_table = &crtc->prop_table;
|
||||
int fd;
|
||||
drmModeObjectProperties *drm_props;
|
||||
int i;
|
||||
|
||||
*prop_table = (MetaKmsCrtcPropTable) {
|
||||
.props = {
|
||||
@ -383,7 +350,6 @@ init_properties (MetaKmsCrtc *crtc,
|
||||
{
|
||||
.name = "ACTIVE",
|
||||
.type = DRM_MODE_PROP_RANGE,
|
||||
.parse = parse_active,
|
||||
},
|
||||
[META_KMS_CRTC_PROP_GAMMA_LUT] =
|
||||
{
|
||||
@ -392,32 +358,6 @@ init_properties (MetaKmsCrtc *crtc,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
fd = meta_kms_impl_device_get_fd (impl_device);
|
||||
drm_props = drmModeObjectGetProperties (fd,
|
||||
drm_crtc->crtc_id,
|
||||
DRM_MODE_OBJECT_CRTC);
|
||||
|
||||
meta_kms_impl_device_init_prop_table (impl_device,
|
||||
drm_props->props,
|
||||
drm_props->prop_values,
|
||||
drm_props->count_props,
|
||||
crtc->prop_table.props,
|
||||
META_KMS_CRTC_N_PROPS,
|
||||
crtc);
|
||||
|
||||
drmModeFreeObjectProperties (drm_props);
|
||||
|
||||
for (i = 0; i < META_KMS_CRTC_N_PROPS; i++)
|
||||
{
|
||||
meta_topic (META_DEBUG_KMS,
|
||||
"%s (%s) CRTC %u property '%s' is %s",
|
||||
meta_kms_impl_device_get_path (impl_device),
|
||||
meta_kms_impl_device_get_driver_name (impl_device),
|
||||
drm_crtc->crtc_id,
|
||||
prop_table->props[i].name,
|
||||
prop_table->props[i].prop_id ? "supported" : "unsupported");
|
||||
}
|
||||
}
|
||||
|
||||
MetaKmsCrtc *
|
||||
|
@ -623,13 +623,12 @@ find_prop (MetaKmsProp *props,
|
||||
}
|
||||
|
||||
void
|
||||
meta_kms_impl_device_init_prop_table (MetaKmsImplDevice *impl_device,
|
||||
uint32_t *drm_props,
|
||||
uint64_t *drm_prop_values,
|
||||
int n_drm_props,
|
||||
MetaKmsProp *props,
|
||||
int n_props,
|
||||
gpointer user_data)
|
||||
meta_kms_impl_device_update_prop_table (MetaKmsImplDevice *impl_device,
|
||||
uint32_t *drm_props,
|
||||
uint64_t *drm_prop_values,
|
||||
int n_drm_props,
|
||||
MetaKmsProp *props,
|
||||
int n_props)
|
||||
{
|
||||
int fd;
|
||||
uint32_t i, j;
|
||||
@ -691,13 +690,6 @@ meta_kms_impl_device_init_prop_table (MetaKmsImplDevice *impl_device,
|
||||
|
||||
update_prop_value (prop, prop_value);
|
||||
|
||||
if (prop->parse)
|
||||
{
|
||||
prop->parse (impl_device, prop,
|
||||
drm_prop, prop_value,
|
||||
user_data);
|
||||
}
|
||||
|
||||
drmModeFreeProperty (drm_prop);
|
||||
}
|
||||
}
|
||||
|
@ -66,12 +66,6 @@ struct _MetaKmsProp
|
||||
|
||||
uint32_t prop_id;
|
||||
uint64_t value;
|
||||
|
||||
void (* parse) (MetaKmsImplDevice *impl_device,
|
||||
MetaKmsProp *prop,
|
||||
drmModePropertyPtr drm_prop,
|
||||
uint64_t value,
|
||||
gpointer user_data);
|
||||
};
|
||||
|
||||
#define META_TYPE_KMS_IMPL_DEVICE (meta_kms_impl_device_get_type ())
|
||||
@ -164,13 +158,12 @@ MetaKmsPlane * meta_kms_impl_device_add_fake_plane (MetaKmsImplDevice *impl_devi
|
||||
MetaKmsPlaneType plane_type,
|
||||
MetaKmsCrtc *crtc);
|
||||
|
||||
void meta_kms_impl_device_init_prop_table (MetaKmsImplDevice *impl_device,
|
||||
uint32_t *drm_props,
|
||||
uint64_t *drm_props_values,
|
||||
int n_drm_props,
|
||||
MetaKmsProp *props,
|
||||
int n_props,
|
||||
gpointer user_data);
|
||||
void meta_kms_impl_device_update_prop_table (MetaKmsImplDevice *impl_device,
|
||||
uint32_t *drm_props,
|
||||
uint64_t *drm_props_values,
|
||||
int n_drm_props,
|
||||
MetaKmsProp *props,
|
||||
int n_props);
|
||||
|
||||
void meta_kms_impl_device_reload_prop_values (MetaKmsImplDevice *impl_device,
|
||||
uint32_t *drm_props,
|
||||
|
@ -190,33 +190,40 @@ meta_kms_plane_is_usable_with (MetaKmsPlane *plane,
|
||||
}
|
||||
|
||||
static void
|
||||
parse_rotations (MetaKmsImplDevice *impl_device,
|
||||
MetaKmsProp *prop,
|
||||
drmModePropertyPtr drm_prop,
|
||||
uint64_t drm_prop_value,
|
||||
gpointer user_data)
|
||||
update_rotations (MetaKmsPlane *plane)
|
||||
{
|
||||
MetaKmsPlane *plane = user_data;
|
||||
int i;
|
||||
MetaKmsProp *prop;
|
||||
MetaKmsPlaneRotation rotation;
|
||||
|
||||
for (i = 0; i < drm_prop->count_enums; i++)
|
||||
prop = &plane->prop_table.props[META_KMS_PLANE_PROP_ROTATION];
|
||||
rotation = prop->value;
|
||||
|
||||
if (rotation & META_KMS_PLANE_ROTATION_ROTATE_0)
|
||||
{
|
||||
MetaMonitorTransform transform = -1;
|
||||
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 (strcmp (drm_prop->enums[i].name, "rotate-0") == 0)
|
||||
transform = META_MONITOR_TRANSFORM_NORMAL;
|
||||
else if (strcmp (drm_prop->enums[i].name, "rotate-90") == 0)
|
||||
transform = META_MONITOR_TRANSFORM_90;
|
||||
else if (strcmp (drm_prop->enums[i].name, "rotate-180") == 0)
|
||||
transform = META_MONITOR_TRANSFORM_180;
|
||||
else if (strcmp (drm_prop->enums[i].name, "rotate-270") == 0)
|
||||
transform = META_MONITOR_TRANSFORM_270;
|
||||
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 (transform != -1)
|
||||
{
|
||||
plane->all_hw_transforms |= 1 << transform;
|
||||
plane->rotation_map[transform] = 1 << drm_prop->enums[i].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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,13 +250,9 @@ free_modifier_array (GArray *array)
|
||||
}
|
||||
|
||||
static void
|
||||
parse_formats (MetaKmsImplDevice *impl_device,
|
||||
MetaKmsProp *prop,
|
||||
drmModePropertyPtr drm_prop,
|
||||
uint64_t drm_prop_value,
|
||||
gpointer user_data)
|
||||
update_formats (MetaKmsPlane *plane,
|
||||
MetaKmsImplDevice *impl_device)
|
||||
{
|
||||
MetaKmsPlane *plane = user_data;
|
||||
uint64_t blob_id;
|
||||
int fd;
|
||||
drmModePropertyBlobPtr blob;
|
||||
@ -257,10 +260,12 @@ parse_formats (MetaKmsImplDevice *impl_device,
|
||||
uint32_t *formats;
|
||||
struct drm_format_modifier *drm_modifiers;
|
||||
unsigned int fmt_i, mod_i;
|
||||
MetaKmsProp *in_formats;
|
||||
|
||||
g_return_if_fail (g_hash_table_size (plane->formats_modifiers) == 0);
|
||||
|
||||
blob_id = drm_prop_value;
|
||||
in_formats = &plane->prop_table.props[META_KMS_PLANE_PROP_IN_FORMATS];
|
||||
blob_id = in_formats->value;
|
||||
if (blob_id == 0)
|
||||
return;
|
||||
|
||||
@ -345,10 +350,8 @@ static const uint32_t drm_default_formats[] =
|
||||
};
|
||||
|
||||
static void
|
||||
init_legacy_formats (MetaKmsPlane *plane,
|
||||
MetaKmsImplDevice *impl_device,
|
||||
drmModePlane *drm_plane,
|
||||
drmModeObjectProperties *drm_plane_props)
|
||||
update_legacy_formats (MetaKmsPlane *plane,
|
||||
drmModePlane *drm_plane)
|
||||
{
|
||||
if (g_hash_table_size (plane->formats_modifiers) == 0)
|
||||
{
|
||||
@ -366,6 +369,28 @@ init_legacy_formats (MetaKmsPlane *plane,
|
||||
}
|
||||
}
|
||||
|
||||
static MetaKmsUpdateChanges
|
||||
meta_kms_plane_read_state (MetaKmsPlane *plane,
|
||||
MetaKmsImplDevice *impl_device,
|
||||
drmModePlane *drm_plane,
|
||||
drmModeObjectProperties *drm_plane_props)
|
||||
{
|
||||
MetaKmsUpdateChanges changes = META_KMS_UPDATE_CHANGE_NONE;
|
||||
|
||||
meta_kms_impl_device_update_prop_table (impl_device,
|
||||
drm_plane_props->props,
|
||||
drm_plane_props->prop_values,
|
||||
drm_plane_props->count_props,
|
||||
plane->prop_table.props,
|
||||
META_KMS_PLANE_N_PROPS);
|
||||
|
||||
update_formats (plane, impl_device);
|
||||
update_rotations (plane);
|
||||
update_legacy_formats (plane, drm_plane);
|
||||
|
||||
return changes;
|
||||
}
|
||||
|
||||
static void
|
||||
init_properties (MetaKmsPlane *plane,
|
||||
MetaKmsImplDevice *impl_device,
|
||||
@ -388,13 +413,11 @@ init_properties (MetaKmsPlane *plane,
|
||||
.enum_values = prop_table->rotation_bitmask,
|
||||
.num_enum_values = META_KMS_PLANE_ROTATION_BIT_N_PROPS,
|
||||
.default_value = META_KMS_PLANE_ROTATION_UNKNOWN,
|
||||
.parse = parse_rotations,
|
||||
},
|
||||
[META_KMS_PLANE_PROP_IN_FORMATS] =
|
||||
{
|
||||
.name = "IN_FORMATS",
|
||||
.type = DRM_MODE_PROP_BLOB,
|
||||
.parse = parse_formats,
|
||||
},
|
||||
[META_KMS_PLANE_PROP_SRC_X] =
|
||||
{
|
||||
@ -489,14 +512,6 @@ init_properties (MetaKmsPlane *plane,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
meta_kms_impl_device_init_prop_table (impl_device,
|
||||
drm_plane_props->props,
|
||||
drm_plane_props->prop_values,
|
||||
drm_plane_props->count_props,
|
||||
plane->prop_table.props,
|
||||
META_KMS_PLANE_N_PROPS,
|
||||
plane);
|
||||
}
|
||||
|
||||
MetaKmsPlane *
|
||||
@ -514,7 +529,8 @@ meta_kms_plane_new (MetaKmsPlaneType type,
|
||||
plane->device = meta_kms_impl_device_get_device (impl_device);
|
||||
|
||||
init_properties (plane, impl_device, drm_plane, drm_plane_props);
|
||||
init_legacy_formats (plane, impl_device, drm_plane, drm_plane_props);
|
||||
|
||||
meta_kms_plane_read_state (plane, impl_device, drm_plane, drm_plane_props);
|
||||
|
||||
return plane;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user