kms/impl-device: Make property ID lookup also handle parsing

Values may need to be processed and parsed in custom ways; make this
possible via the property table infrastructure using a callback.
Will be used for e.g. parsing rotation and formats.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
This commit is contained in:
Jonas Ådahl 2020-07-14 14:58:47 +02:00 committed by Marge Bot
parent a9ae202327
commit 1b3e8b4a27
5 changed files with 31 additions and 7 deletions

View File

@ -612,9 +612,11 @@ init_properties (MetaKmsConnector *connector,
meta_kms_impl_device_init_prop_table (impl_device, meta_kms_impl_device_init_prop_table (impl_device,
drm_connector->props, drm_connector->props,
drm_connector->prop_values,
drm_connector->count_props, drm_connector->count_props,
connector->prop_table.props, connector->prop_table.props,
META_KMS_CONNECTOR_N_PROPS); META_KMS_CONNECTOR_N_PROPS,
NULL);
} }
static char * static char *

View File

@ -266,9 +266,11 @@ init_proporties (MetaKmsCrtc *crtc,
meta_kms_impl_device_init_prop_table (impl_device, meta_kms_impl_device_init_prop_table (impl_device,
drm_props->props, drm_props->props,
drm_props->prop_values,
drm_props->count_props, drm_props->count_props,
crtc->prop_table.props, crtc->prop_table.props,
META_KMS_CRTC_N_PROPS); META_KMS_CRTC_N_PROPS,
NULL);
drmModeFreeObjectProperties (drm_props); drmModeFreeObjectProperties (drm_props);
} }

View File

@ -360,9 +360,11 @@ find_prop (MetaKmsProp *props,
void void
meta_kms_impl_device_init_prop_table (MetaKmsImplDevice *impl_device, meta_kms_impl_device_init_prop_table (MetaKmsImplDevice *impl_device,
uint32_t *drm_props, uint32_t *drm_props,
uint64_t *drm_prop_values,
int n_drm_props, int n_drm_props,
MetaKmsProp *props, MetaKmsProp *props,
int n_props) int n_props,
gpointer user_data)
{ {
int fd; int fd;
uint32_t i; uint32_t i;
@ -396,6 +398,13 @@ meta_kms_impl_device_init_prop_table (MetaKmsImplDevice *impl_device,
prop->prop_id = drm_props[i]; prop->prop_id = drm_props[i];
if (prop->parse)
{
prop->parse (impl_device, prop,
drm_prop, drm_prop_values[i],
user_data);
}
drmModeFreeProperty (drm_prop); drmModeFreeProperty (drm_prop);
} }
} }

View File

@ -35,13 +35,20 @@ typedef struct _MetaKmsDeviceCaps
uint64_t cursor_height; uint64_t cursor_height;
} MetaKmsDeviceCaps; } MetaKmsDeviceCaps;
typedef struct _MetaKmsProp typedef struct _MetaKmsProp MetaKmsProp;
struct _MetaKmsProp
{ {
const char *name; const char *name;
uint32_t type; uint32_t type;
void (* parse) (MetaKmsImplDevice *impl_device,
MetaKmsProp *prop,
drmModePropertyPtr drm_prop,
uint64_t value,
gpointer user_data);
uint32_t prop_id; uint32_t prop_id;
} MetaKmsProp; };
#define META_TYPE_KMS_IMPL_DEVICE (meta_kms_impl_device_get_type ()) #define META_TYPE_KMS_IMPL_DEVICE (meta_kms_impl_device_get_type ())
G_DECLARE_FINAL_TYPE (MetaKmsImplDevice, meta_kms_impl_device, G_DECLARE_FINAL_TYPE (MetaKmsImplDevice, meta_kms_impl_device,
@ -87,9 +94,11 @@ MetaKmsPlane * meta_kms_impl_device_add_fake_plane (MetaKmsImplDevice *impl_devi
void meta_kms_impl_device_init_prop_table (MetaKmsImplDevice *impl_device, void meta_kms_impl_device_init_prop_table (MetaKmsImplDevice *impl_device,
uint32_t *drm_props, uint32_t *drm_props,
uint64_t *drm_props_values,
int n_drm_props, int n_drm_props,
MetaKmsProp *props, MetaKmsProp *props,
int n_props); int n_props,
gpointer user_data);
int meta_kms_impl_device_close (MetaKmsImplDevice *impl_device); int meta_kms_impl_device_close (MetaKmsImplDevice *impl_device);

View File

@ -454,9 +454,11 @@ init_properties (MetaKmsPlane *plane,
meta_kms_impl_device_init_prop_table (impl_device, meta_kms_impl_device_init_prop_table (impl_device,
drm_plane_props->props, drm_plane_props->props,
drm_plane_props->prop_values,
drm_plane_props->count_props, drm_plane_props->count_props,
plane->prop_table.props, plane->prop_table.props,
META_KMS_PLANE_N_PROPS); META_KMS_PLANE_N_PROPS,
NULL);
} }
MetaKmsPlane * MetaKmsPlane *