mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 01:50:42 -05:00
kms/connector: Make property ID fetching more declarative
Instead of relatively verbosely going through the DRM properties finding the properties we care about and saving their ID's, add a more declarative way to fetch property metadata. This'll allow for fetching more property IDs with relatively less code, which will be useful for the atomic backend. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
This commit is contained in:
parent
309651df6b
commit
df89e8ce4b
@ -30,6 +30,20 @@
|
|||||||
#include "backends/native/meta-kms-mode-private.h"
|
#include "backends/native/meta-kms-mode-private.h"
|
||||||
#include "backends/native/meta-kms-update-private.h"
|
#include "backends/native/meta-kms-update-private.h"
|
||||||
|
|
||||||
|
typedef enum _MetaKmsConnectorProp
|
||||||
|
{
|
||||||
|
META_KMS_CONNECTOR_PROP_DPMS = 0,
|
||||||
|
META_KMS_CONNECTOR_PROP_UNDERSCAN,
|
||||||
|
META_KMS_CONNECTOR_PROP_UNDERSCAN_HBORDER,
|
||||||
|
META_KMS_CONNECTOR_PROP_UNDERSCAN_VBORDER,
|
||||||
|
META_KMS_CONNECTOR_N_PROPS
|
||||||
|
} MetaKmsConnectorProp;
|
||||||
|
|
||||||
|
typedef struct _MetaKmsConnectorPropTable
|
||||||
|
{
|
||||||
|
MetaKmsProp props[META_KMS_CONNECTOR_N_PROPS];
|
||||||
|
} MetaKmsConnectorPropTable;
|
||||||
|
|
||||||
struct _MetaKmsConnector
|
struct _MetaKmsConnector
|
||||||
{
|
{
|
||||||
GObject parent;
|
GObject parent;
|
||||||
@ -43,10 +57,8 @@ struct _MetaKmsConnector
|
|||||||
|
|
||||||
MetaKmsConnectorState *current_state;
|
MetaKmsConnectorState *current_state;
|
||||||
|
|
||||||
uint32_t dpms_prop_id;
|
MetaKmsConnectorPropTable prop_table;
|
||||||
uint32_t underscan_prop_id;
|
|
||||||
uint32_t underscan_hborder_prop_id;
|
|
||||||
uint32_t underscan_vborder_prop_id;
|
|
||||||
uint32_t edid_blob_id;
|
uint32_t edid_blob_id;
|
||||||
uint32_t tile_blob_id;
|
uint32_t tile_blob_id;
|
||||||
};
|
};
|
||||||
@ -64,9 +76,12 @@ meta_kms_connector_update_set_dpms_state (MetaKmsConnector *connector,
|
|||||||
MetaKmsUpdate *update,
|
MetaKmsUpdate *update,
|
||||||
uint64_t state)
|
uint64_t state)
|
||||||
{
|
{
|
||||||
|
uint32_t prop_id;
|
||||||
|
|
||||||
|
prop_id = connector->prop_table.props[META_KMS_CONNECTOR_PROP_DPMS].prop_id;
|
||||||
meta_kms_update_set_connector_property (update,
|
meta_kms_update_set_connector_property (update,
|
||||||
connector,
|
connector,
|
||||||
connector->dpms_prop_id,
|
prop_id,
|
||||||
state);
|
state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,17 +91,29 @@ meta_kms_connector_set_underscanning (MetaKmsConnector *connector,
|
|||||||
uint64_t hborder,
|
uint64_t hborder,
|
||||||
uint64_t vborder)
|
uint64_t vborder)
|
||||||
{
|
{
|
||||||
|
MetaKmsProp *props = connector->prop_table.props;
|
||||||
|
uint32_t underscan_prop_id;
|
||||||
|
uint32_t underscan_hborder_prop_id;
|
||||||
|
uint32_t underscan_vborder_prop_id;
|
||||||
|
|
||||||
|
underscan_prop_id =
|
||||||
|
props[META_KMS_CONNECTOR_PROP_UNDERSCAN].prop_id;
|
||||||
|
underscan_hborder_prop_id =
|
||||||
|
props[META_KMS_CONNECTOR_PROP_UNDERSCAN_HBORDER].prop_id;
|
||||||
|
underscan_vborder_prop_id =
|
||||||
|
props[META_KMS_CONNECTOR_PROP_UNDERSCAN_VBORDER].prop_id;
|
||||||
|
|
||||||
meta_kms_update_set_connector_property (update,
|
meta_kms_update_set_connector_property (update,
|
||||||
connector,
|
connector,
|
||||||
connector->underscan_prop_id,
|
underscan_prop_id,
|
||||||
1);
|
1);
|
||||||
meta_kms_update_set_connector_property (update,
|
meta_kms_update_set_connector_property (update,
|
||||||
connector,
|
connector,
|
||||||
connector->underscan_hborder_prop_id,
|
underscan_hborder_prop_id,
|
||||||
hborder);
|
hborder);
|
||||||
meta_kms_update_set_connector_property (update,
|
meta_kms_update_set_connector_property (update,
|
||||||
connector,
|
connector,
|
||||||
connector->underscan_vborder_prop_id,
|
underscan_vborder_prop_id,
|
||||||
vborder);
|
vborder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,9 +121,13 @@ void
|
|||||||
meta_kms_connector_unset_underscanning (MetaKmsConnector *connector,
|
meta_kms_connector_unset_underscanning (MetaKmsConnector *connector,
|
||||||
MetaKmsUpdate *update)
|
MetaKmsUpdate *update)
|
||||||
{
|
{
|
||||||
|
MetaKmsProp *props = connector->prop_table.props;
|
||||||
|
uint32_t underscan_prop_id;
|
||||||
|
|
||||||
|
underscan_prop_id = props[META_KMS_CONNECTOR_PROP_UNDERSCAN].prop_id;
|
||||||
meta_kms_update_set_connector_property (update,
|
meta_kms_update_set_connector_property (update,
|
||||||
connector,
|
connector,
|
||||||
connector->underscan_prop_id,
|
underscan_prop_id,
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +175,12 @@ meta_kms_connector_get_current_state (MetaKmsConnector *connector)
|
|||||||
gboolean
|
gboolean
|
||||||
meta_kms_connector_is_underscanning_supported (MetaKmsConnector *connector)
|
meta_kms_connector_is_underscanning_supported (MetaKmsConnector *connector)
|
||||||
{
|
{
|
||||||
return connector->underscan_prop_id != 0;
|
uint32_t underscan_prop_id;
|
||||||
|
|
||||||
|
underscan_prop_id =
|
||||||
|
connector->prop_table.props[META_KMS_CONNECTOR_PROP_UNDERSCAN].prop_id;
|
||||||
|
|
||||||
|
return underscan_prop_id != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -543,38 +579,42 @@ meta_kms_connector_predict_state (MetaKmsConnector *connector,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
find_property_ids (MetaKmsConnector *connector,
|
init_properties (MetaKmsConnector *connector,
|
||||||
MetaKmsImplDevice *impl_device,
|
MetaKmsImplDevice *impl_device,
|
||||||
drmModeConnector *drm_connector)
|
drmModeConnector *drm_connector)
|
||||||
{
|
{
|
||||||
int fd;
|
MetaKmsConnectorPropTable *prop_table = &connector->prop_table;
|
||||||
int i;
|
|
||||||
|
|
||||||
fd = meta_kms_impl_device_get_fd (impl_device);
|
*prop_table = (MetaKmsConnectorPropTable) {
|
||||||
|
.props = {
|
||||||
for (i = 0; i < drm_connector->count_props; i++)
|
[META_KMS_CONNECTOR_PROP_DPMS] =
|
||||||
{
|
{
|
||||||
drmModePropertyPtr prop;
|
.name = "DPMS",
|
||||||
|
.type = DRM_MODE_PROP_ENUM,
|
||||||
prop = drmModeGetProperty (fd, drm_connector->props[i]);
|
},
|
||||||
if (!prop)
|
[META_KMS_CONNECTOR_PROP_UNDERSCAN] =
|
||||||
continue;
|
{
|
||||||
|
.name = "underscan",
|
||||||
if ((prop->flags & DRM_MODE_PROP_ENUM) &&
|
.type = DRM_MODE_PROP_ENUM,
|
||||||
strcmp (prop->name, "DPMS") == 0)
|
},
|
||||||
connector->dpms_prop_id = prop->prop_id;
|
[META_KMS_CONNECTOR_PROP_UNDERSCAN_HBORDER] =
|
||||||
else if ((prop->flags & DRM_MODE_PROP_ENUM) &&
|
{
|
||||||
strcmp (prop->name, "underscan") == 0)
|
.name = "underscan hborder",
|
||||||
connector->underscan_prop_id = prop->prop_id;
|
.type = DRM_MODE_PROP_RANGE,
|
||||||
else if ((prop->flags & DRM_MODE_PROP_RANGE) &&
|
},
|
||||||
strcmp (prop->name, "underscan hborder") == 0)
|
[META_KMS_CONNECTOR_PROP_UNDERSCAN_VBORDER] =
|
||||||
connector->underscan_hborder_prop_id = prop->prop_id;
|
{
|
||||||
else if ((prop->flags & DRM_MODE_PROP_RANGE) &&
|
.name = "underscan vborder",
|
||||||
strcmp (prop->name, "underscan vborder") == 0)
|
.type = DRM_MODE_PROP_RANGE,
|
||||||
connector->underscan_vborder_prop_id = prop->prop_id;
|
},
|
||||||
|
|
||||||
drmModeFreeProperty (prop);
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
meta_kms_impl_device_init_prop_table (impl_device,
|
||||||
|
drm_connector->props,
|
||||||
|
drm_connector->count_props,
|
||||||
|
connector->prop_table.props,
|
||||||
|
META_KMS_CONNECTOR_N_PROPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
@ -633,7 +673,7 @@ meta_kms_connector_new (MetaKmsImplDevice *impl_device,
|
|||||||
connector->type_id = drm_connector->connector_type_id;
|
connector->type_id = drm_connector->connector_type_id;
|
||||||
connector->name = make_connector_name (drm_connector);
|
connector->name = make_connector_name (drm_connector);
|
||||||
|
|
||||||
find_property_ids (connector, impl_device, drm_connector);
|
init_properties (connector, impl_device, drm_connector);
|
||||||
|
|
||||||
meta_kms_connector_read_state (connector, impl_device,
|
meta_kms_connector_read_state (connector, impl_device,
|
||||||
drm_connector,
|
drm_connector,
|
||||||
|
@ -337,6 +337,69 @@ meta_kms_impl_device_add_fake_plane (MetaKmsImplDevice *impl_device,
|
|||||||
return plane;
|
return plane;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static MetaKmsProp *
|
||||||
|
find_prop (MetaKmsProp *props,
|
||||||
|
int n_props,
|
||||||
|
const char *name)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < n_props; i++)
|
||||||
|
{
|
||||||
|
MetaKmsProp *prop = &props[i];
|
||||||
|
|
||||||
|
g_warn_if_fail (prop->name);
|
||||||
|
|
||||||
|
if (g_strcmp0 (prop->name, name) == 0)
|
||||||
|
return prop;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_kms_impl_device_init_prop_table (MetaKmsImplDevice *impl_device,
|
||||||
|
uint32_t *drm_props,
|
||||||
|
int n_drm_props,
|
||||||
|
MetaKmsProp *props,
|
||||||
|
int n_props)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
|
fd = meta_kms_impl_device_get_fd (impl_device);
|
||||||
|
|
||||||
|
for (i = 0; i < n_drm_props; i++)
|
||||||
|
{
|
||||||
|
drmModePropertyRes *drm_prop;
|
||||||
|
MetaKmsProp *prop;
|
||||||
|
|
||||||
|
drm_prop = drmModeGetProperty (fd, drm_props[i]);
|
||||||
|
if (!drm_prop)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
prop = find_prop (props, n_props, drm_prop->name);
|
||||||
|
if (!prop)
|
||||||
|
{
|
||||||
|
drmModeFreeProperty (drm_prop);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(drm_prop->flags & prop->type))
|
||||||
|
{
|
||||||
|
g_warning ("DRM property '%s' (%u) had unexpected flags (0x%x), "
|
||||||
|
"ignoring",
|
||||||
|
drm_prop->name, drm_props[i], drm_prop->flags);
|
||||||
|
drmModeFreeProperty (drm_prop);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
prop->prop_id = drm_props[i];
|
||||||
|
|
||||||
|
drmModeFreeProperty (drm_prop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
init_planes (MetaKmsImplDevice *impl_device)
|
init_planes (MetaKmsImplDevice *impl_device)
|
||||||
{
|
{
|
||||||
|
@ -35,6 +35,14 @@ typedef struct _MetaKmsDeviceCaps
|
|||||||
uint64_t cursor_height;
|
uint64_t cursor_height;
|
||||||
} MetaKmsDeviceCaps;
|
} MetaKmsDeviceCaps;
|
||||||
|
|
||||||
|
typedef struct _MetaKmsProp
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
uint32_t type;
|
||||||
|
|
||||||
|
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,
|
||||||
META, KMS_IMPL_DEVICE,
|
META, KMS_IMPL_DEVICE,
|
||||||
@ -77,6 +85,12 @@ MetaKmsPlane * meta_kms_impl_device_add_fake_plane (MetaKmsImplDevice *impl_devi
|
|||||||
MetaKmsPlaneType plane_type,
|
MetaKmsPlaneType plane_type,
|
||||||
MetaKmsCrtc *crtc);
|
MetaKmsCrtc *crtc);
|
||||||
|
|
||||||
|
void meta_kms_impl_device_init_prop_table (MetaKmsImplDevice *impl_device,
|
||||||
|
uint32_t *drm_props,
|
||||||
|
int n_drm_props,
|
||||||
|
MetaKmsProp *props,
|
||||||
|
int n_props);
|
||||||
|
|
||||||
int meta_kms_impl_device_close (MetaKmsImplDevice *impl_device);
|
int meta_kms_impl_device_close (MetaKmsImplDevice *impl_device);
|
||||||
|
|
||||||
MetaKmsImplDevice * meta_kms_impl_device_new (MetaKmsDevice *device,
|
MetaKmsImplDevice * meta_kms_impl_device_new (MetaKmsDevice *device,
|
||||||
|
Loading…
Reference in New Issue
Block a user