mirror of
https://gitlab.freedesktop.org/emersion/libliftoff.git
synced 2024-12-25 21:59:11 +01:00
plane: store drmModePropertyRes
This retains all of the info we need: ID, name, type, possible enum values. We'll need the possible enum values in the next commit.
This commit is contained in:
parent
8ec1203e64
commit
9568888b99
2 changed files with 20 additions and 24 deletions
|
@ -72,18 +72,13 @@ struct liftoff_plane {
|
||||||
/* TODO: formats */
|
/* TODO: formats */
|
||||||
struct liftoff_list link; /* liftoff_device.planes */
|
struct liftoff_list link; /* liftoff_device.planes */
|
||||||
|
|
||||||
struct liftoff_plane_property *props;
|
drmModePropertyRes **props;
|
||||||
size_t props_len;
|
size_t props_len;
|
||||||
drmModePropertyBlobRes *in_formats_blob;
|
drmModePropertyBlobRes *in_formats_blob;
|
||||||
|
|
||||||
struct liftoff_layer *layer;
|
struct liftoff_layer *layer;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct liftoff_plane_property {
|
|
||||||
char name[DRM_PROP_NAME_LEN];
|
|
||||||
uint32_t id;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct liftoff_rect {
|
struct liftoff_rect {
|
||||||
int x, y;
|
int x, y;
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
37
plane.c
37
plane.c
|
@ -40,8 +40,7 @@ liftoff_plane_create(struct liftoff_device *device, uint32_t id)
|
||||||
drmModePlane *drm_plane;
|
drmModePlane *drm_plane;
|
||||||
drmModeObjectProperties *drm_props;
|
drmModeObjectProperties *drm_props;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
drmModePropertyRes *drm_prop;
|
drmModePropertyRes *prop;
|
||||||
struct liftoff_plane_property *prop;
|
|
||||||
uint64_t value;
|
uint64_t value;
|
||||||
bool has_type = false, has_zpos = false;
|
bool has_type = false, has_zpos = false;
|
||||||
|
|
||||||
|
@ -75,25 +74,20 @@ liftoff_plane_create(struct liftoff_device *device, uint32_t id)
|
||||||
liftoff_log_errno(LIFTOFF_ERROR, "drmModeObjectGetProperties");
|
liftoff_log_errno(LIFTOFF_ERROR, "drmModeObjectGetProperties");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
plane->props = calloc(drm_props->count_props,
|
plane->props = calloc(drm_props->count_props, sizeof(plane->props[0]));
|
||||||
sizeof(struct liftoff_plane_property));
|
|
||||||
if (plane->props == NULL) {
|
if (plane->props == NULL) {
|
||||||
liftoff_log_errno(LIFTOFF_ERROR, "calloc");
|
liftoff_log_errno(LIFTOFF_ERROR, "calloc");
|
||||||
drmModeFreeObjectProperties(drm_props);
|
drmModeFreeObjectProperties(drm_props);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
for (i = 0; i < drm_props->count_props; i++) {
|
for (i = 0; i < drm_props->count_props; i++) {
|
||||||
drm_prop = drmModeGetProperty(device->drm_fd,
|
prop = drmModeGetProperty(device->drm_fd, drm_props->props[i]);
|
||||||
drm_props->props[i]);
|
if (prop == NULL) {
|
||||||
if (drm_prop == NULL) {
|
|
||||||
liftoff_log_errno(LIFTOFF_ERROR, "drmModeGetProperty");
|
liftoff_log_errno(LIFTOFF_ERROR, "drmModeGetProperty");
|
||||||
drmModeFreeObjectProperties(drm_props);
|
drmModeFreeObjectProperties(drm_props);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
prop = &plane->props[i];
|
plane->props[i] = prop;
|
||||||
memcpy(prop->name, drm_prop->name, sizeof(prop->name));
|
|
||||||
prop->id = drm_prop->prop_id;
|
|
||||||
drmModeFreeProperty(drm_prop);
|
|
||||||
plane->props_len++;
|
plane->props_len++;
|
||||||
|
|
||||||
value = drm_props->prop_values[i];
|
value = drm_props->prop_values[i];
|
||||||
|
@ -152,9 +146,16 @@ liftoff_plane_create(struct liftoff_device *device, uint32_t id)
|
||||||
void
|
void
|
||||||
liftoff_plane_destroy(struct liftoff_plane *plane)
|
liftoff_plane_destroy(struct liftoff_plane *plane)
|
||||||
{
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
if (plane->layer != NULL) {
|
if (plane->layer != NULL) {
|
||||||
plane->layer->plane = NULL;
|
plane->layer->plane = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < plane->props_len; i++) {
|
||||||
|
drmModeFreeProperty(plane->props[i]);
|
||||||
|
}
|
||||||
|
|
||||||
liftoff_list_remove(&plane->link);
|
liftoff_list_remove(&plane->link);
|
||||||
free(plane->props);
|
free(plane->props);
|
||||||
drmModeFreePropertyBlob(plane->in_formats_blob);
|
drmModeFreePropertyBlob(plane->in_formats_blob);
|
||||||
|
@ -167,14 +168,14 @@ liftoff_plane_get_id(struct liftoff_plane *plane)
|
||||||
return plane->id;
|
return plane->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct liftoff_plane_property *
|
static const drmModePropertyRes *
|
||||||
plane_get_property(struct liftoff_plane *plane, const char *name)
|
plane_get_property(struct liftoff_plane *plane, const char *name)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < plane->props_len; i++) {
|
for (i = 0; i < plane->props_len; i++) {
|
||||||
if (strcmp(plane->props[i].name, name) == 0) {
|
if (strcmp(plane->props[i]->name, name) == 0) {
|
||||||
return &plane->props[i];
|
return plane->props[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -182,11 +183,11 @@ plane_get_property(struct liftoff_plane *plane, const char *name)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
plane_set_prop(struct liftoff_plane *plane, drmModeAtomicReq *req,
|
plane_set_prop(struct liftoff_plane *plane, drmModeAtomicReq *req,
|
||||||
struct liftoff_plane_property *prop, uint64_t value)
|
const drmModePropertyRes *prop, uint64_t value)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = drmModeAtomicAddProperty(req, plane->id, prop->id, value);
|
ret = drmModeAtomicAddProperty(req, plane->id, prop->prop_id, value);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
liftoff_log(LIFTOFF_ERROR, "drmModeAtomicAddProperty: %s",
|
liftoff_log(LIFTOFF_ERROR, "drmModeAtomicAddProperty: %s",
|
||||||
strerror(-ret));
|
strerror(-ret));
|
||||||
|
@ -200,7 +201,7 @@ static int
|
||||||
set_plane_prop_str(struct liftoff_plane *plane, drmModeAtomicReq *req,
|
set_plane_prop_str(struct liftoff_plane *plane, drmModeAtomicReq *req,
|
||||||
const char *name, uint64_t value)
|
const char *name, uint64_t value)
|
||||||
{
|
{
|
||||||
struct liftoff_plane_property *prop;
|
const drmModePropertyRes *prop;
|
||||||
|
|
||||||
prop = plane_get_property(plane, name);
|
prop = plane_get_property(plane, name);
|
||||||
if (prop == NULL) {
|
if (prop == NULL) {
|
||||||
|
@ -271,7 +272,7 @@ plane_apply(struct liftoff_plane *plane, struct liftoff_layer *layer,
|
||||||
int cursor, ret;
|
int cursor, ret;
|
||||||
size_t i;
|
size_t i;
|
||||||
struct liftoff_layer_property *layer_prop;
|
struct liftoff_layer_property *layer_prop;
|
||||||
struct liftoff_plane_property *plane_prop;
|
const drmModePropertyRes *plane_prop;
|
||||||
|
|
||||||
cursor = drmModeAtomicGetCursor(req);
|
cursor = drmModeAtomicGetCursor(req);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue