mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-21 22:52:20 +00:00
backend/drm: store drm prop lists as structs
This makes modifying the property lists slightly easier.
This commit is contained in:
parent
47c578945c
commit
5201836868
@ -320,7 +320,7 @@ void drm_atomic_connector_rollback_commit(struct wlr_drm_connector_state *state)
|
|||||||
|
|
||||||
static void plane_disable(struct atomic *atom, struct wlr_drm_plane *plane) {
|
static void plane_disable(struct atomic *atom, struct wlr_drm_plane *plane) {
|
||||||
uint32_t id = plane->id;
|
uint32_t id = plane->id;
|
||||||
const union wlr_drm_plane_props *props = &plane->props;
|
const struct wlr_drm_plane_props *props = &plane->props;
|
||||||
atomic_add(atom, id, props->fb_id, 0);
|
atomic_add(atom, id, props->fb_id, 0);
|
||||||
atomic_add(atom, id, props->crtc_id, 0);
|
atomic_add(atom, id, props->crtc_id, 0);
|
||||||
}
|
}
|
||||||
@ -329,7 +329,7 @@ static void set_plane_props(struct atomic *atom, struct wlr_drm_backend *drm,
|
|||||||
struct wlr_drm_plane *plane, struct wlr_drm_fb *fb, uint32_t crtc_id,
|
struct wlr_drm_plane *plane, struct wlr_drm_fb *fb, uint32_t crtc_id,
|
||||||
int32_t x, int32_t y) {
|
int32_t x, int32_t y) {
|
||||||
uint32_t id = plane->id;
|
uint32_t id = plane->id;
|
||||||
const union wlr_drm_plane_props *props = &plane->props;
|
const struct wlr_drm_plane_props *props = &plane->props;
|
||||||
|
|
||||||
if (fb == NULL) {
|
if (fb == NULL) {
|
||||||
wlr_log(WLR_ERROR, "Failed to acquire FB for plane %"PRIu32, plane->id);
|
wlr_log(WLR_ERROR, "Failed to acquire FB for plane %"PRIu32, plane->id);
|
||||||
|
@ -139,7 +139,7 @@ static bool init_plane(struct wlr_drm_backend *drm,
|
|||||||
struct wlr_drm_plane *p, const drmModePlane *drm_plane) {
|
struct wlr_drm_plane *p, const drmModePlane *drm_plane) {
|
||||||
uint32_t id = drm_plane->plane_id;
|
uint32_t id = drm_plane->plane_id;
|
||||||
|
|
||||||
union wlr_drm_plane_props props = {0};
|
struct wlr_drm_plane_props props = {0};
|
||||||
if (!get_drm_plane_props(drm->fd, id, &props)) {
|
if (!get_drm_plane_props(drm->fd, id, &props)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ struct prop_info {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const struct prop_info connector_info[] = {
|
static const struct prop_info connector_info[] = {
|
||||||
#define INDEX(name) (offsetof(union wlr_drm_connector_props, name) / sizeof(uint32_t))
|
#define INDEX(name) (offsetof(struct wlr_drm_connector_props, name) / sizeof(uint32_t))
|
||||||
{ "CRTC_ID", INDEX(crtc_id) },
|
{ "CRTC_ID", INDEX(crtc_id) },
|
||||||
{ "DPMS", INDEX(dpms) },
|
{ "DPMS", INDEX(dpms) },
|
||||||
{ "EDID", INDEX(edid) },
|
{ "EDID", INDEX(edid) },
|
||||||
@ -35,7 +35,7 @@ static const struct prop_info connector_info[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const struct prop_info crtc_info[] = {
|
static const struct prop_info crtc_info[] = {
|
||||||
#define INDEX(name) (offsetof(union wlr_drm_crtc_props, name) / sizeof(uint32_t))
|
#define INDEX(name) (offsetof(struct wlr_drm_crtc_props, name) / sizeof(uint32_t))
|
||||||
{ "ACTIVE", INDEX(active) },
|
{ "ACTIVE", INDEX(active) },
|
||||||
{ "GAMMA_LUT", INDEX(gamma_lut) },
|
{ "GAMMA_LUT", INDEX(gamma_lut) },
|
||||||
{ "GAMMA_LUT_SIZE", INDEX(gamma_lut_size) },
|
{ "GAMMA_LUT_SIZE", INDEX(gamma_lut_size) },
|
||||||
@ -45,7 +45,7 @@ static const struct prop_info crtc_info[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const struct prop_info plane_info[] = {
|
static const struct prop_info plane_info[] = {
|
||||||
#define INDEX(name) (offsetof(union wlr_drm_plane_props, name) / sizeof(uint32_t))
|
#define INDEX(name) (offsetof(struct wlr_drm_plane_props, name) / sizeof(uint32_t))
|
||||||
{ "CRTC_H", INDEX(crtc_h) },
|
{ "CRTC_H", INDEX(crtc_h) },
|
||||||
{ "CRTC_ID", INDEX(crtc_id) },
|
{ "CRTC_ID", INDEX(crtc_id) },
|
||||||
{ "CRTC_W", INDEX(crtc_w) },
|
{ "CRTC_W", INDEX(crtc_w) },
|
||||||
@ -100,19 +100,18 @@ static bool scan_properties(int fd, uint32_t id, uint32_t type, uint32_t *result
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get_drm_connector_props(int fd, uint32_t id,
|
bool get_drm_connector_props(int fd, uint32_t id, struct wlr_drm_connector_props *out) {
|
||||||
union wlr_drm_connector_props *out) {
|
return scan_properties(fd, id, DRM_MODE_OBJECT_CONNECTOR, (uint32_t *)out,
|
||||||
return scan_properties(fd, id, DRM_MODE_OBJECT_CONNECTOR, out->props,
|
|
||||||
connector_info, sizeof(connector_info) / sizeof(connector_info[0]));
|
connector_info, sizeof(connector_info) / sizeof(connector_info[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get_drm_crtc_props(int fd, uint32_t id, union wlr_drm_crtc_props *out) {
|
bool get_drm_crtc_props(int fd, uint32_t id, struct wlr_drm_crtc_props *out) {
|
||||||
return scan_properties(fd, id, DRM_MODE_OBJECT_CRTC, out->props,
|
return scan_properties(fd, id, DRM_MODE_OBJECT_CRTC, (uint32_t *)out,
|
||||||
crtc_info, sizeof(crtc_info) / sizeof(crtc_info[0]));
|
crtc_info, sizeof(crtc_info) / sizeof(crtc_info[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get_drm_plane_props(int fd, uint32_t id, union wlr_drm_plane_props *out) {
|
bool get_drm_plane_props(int fd, uint32_t id, struct wlr_drm_plane_props *out) {
|
||||||
return scan_properties(fd, id, DRM_MODE_OBJECT_PLANE, out->props,
|
return scan_properties(fd, id, DRM_MODE_OBJECT_PLANE, (uint32_t *)out,
|
||||||
plane_info, sizeof(plane_info) / sizeof(plane_info[0]));
|
plane_info, sizeof(plane_info) / sizeof(plane_info[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ struct wlr_drm_plane {
|
|||||||
|
|
||||||
struct wlr_drm_format_set formats;
|
struct wlr_drm_format_set formats;
|
||||||
|
|
||||||
union wlr_drm_plane_props props;
|
struct wlr_drm_plane_props props;
|
||||||
|
|
||||||
uint32_t initial_crtc_id;
|
uint32_t initial_crtc_id;
|
||||||
struct liftoff_plane *liftoff;
|
struct liftoff_plane *liftoff;
|
||||||
@ -71,7 +71,7 @@ struct wlr_drm_crtc {
|
|||||||
struct wlr_drm_plane *primary;
|
struct wlr_drm_plane *primary;
|
||||||
struct wlr_drm_plane *cursor;
|
struct wlr_drm_plane *cursor;
|
||||||
|
|
||||||
union wlr_drm_crtc_props props;
|
struct wlr_drm_crtc_props props;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_drm_backend {
|
struct wlr_drm_backend {
|
||||||
@ -181,7 +181,7 @@ struct wlr_drm_connector {
|
|||||||
struct wlr_drm_crtc *crtc;
|
struct wlr_drm_crtc *crtc;
|
||||||
uint32_t possible_crtcs;
|
uint32_t possible_crtcs;
|
||||||
|
|
||||||
union wlr_drm_connector_props props;
|
struct wlr_drm_connector_props props;
|
||||||
|
|
||||||
bool cursor_enabled;
|
bool cursor_enabled;
|
||||||
int cursor_x, cursor_y;
|
int cursor_x, cursor_y;
|
||||||
|
@ -11,70 +11,61 @@
|
|||||||
* https://dri.freedesktop.org/docs/drm/gpu/drm-kms.html#kms-properties
|
* https://dri.freedesktop.org/docs/drm/gpu/drm-kms.html#kms-properties
|
||||||
*/
|
*/
|
||||||
|
|
||||||
union wlr_drm_connector_props {
|
struct wlr_drm_connector_props {
|
||||||
struct {
|
uint32_t edid;
|
||||||
uint32_t edid;
|
uint32_t dpms;
|
||||||
uint32_t dpms;
|
uint32_t link_status; // not guaranteed to exist
|
||||||
uint32_t link_status; // not guaranteed to exist
|
uint32_t path;
|
||||||
uint32_t path;
|
uint32_t vrr_capable; // not guaranteed to exist
|
||||||
uint32_t vrr_capable; // not guaranteed to exist
|
uint32_t subconnector; // not guaranteed to exist
|
||||||
uint32_t subconnector; // not guaranteed to exist
|
uint32_t non_desktop;
|
||||||
uint32_t non_desktop;
|
uint32_t panel_orientation; // not guaranteed to exist
|
||||||
uint32_t panel_orientation; // not guaranteed to exist
|
uint32_t content_type; // not guaranteed to exist
|
||||||
uint32_t content_type; // not guaranteed to exist
|
uint32_t max_bpc; // not guaranteed to exist
|
||||||
uint32_t max_bpc; // not guaranteed to exist
|
|
||||||
|
|
||||||
// atomic-modesetting only
|
// atomic-modesetting only
|
||||||
|
|
||||||
uint32_t crtc_id;
|
uint32_t crtc_id;
|
||||||
};
|
|
||||||
uint32_t props[4];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
union wlr_drm_crtc_props {
|
struct wlr_drm_crtc_props {
|
||||||
struct {
|
// Neither of these are guaranteed to exist
|
||||||
// Neither of these are guaranteed to exist
|
uint32_t vrr_enabled;
|
||||||
uint32_t vrr_enabled;
|
uint32_t gamma_lut;
|
||||||
uint32_t gamma_lut;
|
uint32_t gamma_lut_size;
|
||||||
uint32_t gamma_lut_size;
|
|
||||||
|
|
||||||
// atomic-modesetting only
|
// atomic-modesetting only
|
||||||
|
|
||||||
uint32_t active;
|
uint32_t active;
|
||||||
uint32_t mode_id;
|
uint32_t mode_id;
|
||||||
};
|
|
||||||
uint32_t props[6];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
union wlr_drm_plane_props {
|
struct wlr_drm_plane_props {
|
||||||
struct {
|
uint32_t type;
|
||||||
uint32_t type;
|
uint32_t rotation; // Not guaranteed to exist
|
||||||
uint32_t rotation; // Not guaranteed to exist
|
uint32_t in_formats; // Not guaranteed to exist
|
||||||
uint32_t in_formats; // Not guaranteed to exist
|
|
||||||
|
|
||||||
// atomic-modesetting only
|
// atomic-modesetting only
|
||||||
|
|
||||||
uint32_t src_x;
|
uint32_t src_x;
|
||||||
uint32_t src_y;
|
uint32_t src_y;
|
||||||
uint32_t src_w;
|
uint32_t src_w;
|
||||||
uint32_t src_h;
|
uint32_t src_h;
|
||||||
uint32_t crtc_x;
|
uint32_t crtc_x;
|
||||||
uint32_t crtc_y;
|
uint32_t crtc_y;
|
||||||
uint32_t crtc_w;
|
uint32_t crtc_w;
|
||||||
uint32_t crtc_h;
|
uint32_t crtc_h;
|
||||||
uint32_t fb_id;
|
uint32_t fb_id;
|
||||||
uint32_t crtc_id;
|
uint32_t crtc_id;
|
||||||
uint32_t fb_damage_clips;
|
uint32_t fb_damage_clips;
|
||||||
uint32_t hotspot_x;
|
uint32_t hotspot_x;
|
||||||
uint32_t hotspot_y;
|
uint32_t hotspot_y;
|
||||||
};
|
|
||||||
uint32_t props[16];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool get_drm_connector_props(int fd, uint32_t id,
|
bool get_drm_connector_props(int fd, uint32_t id,
|
||||||
union wlr_drm_connector_props *out);
|
struct wlr_drm_connector_props *out);
|
||||||
bool get_drm_crtc_props(int fd, uint32_t id, union wlr_drm_crtc_props *out);
|
bool get_drm_crtc_props(int fd, uint32_t id, struct wlr_drm_crtc_props *out);
|
||||||
bool get_drm_plane_props(int fd, uint32_t id, union wlr_drm_plane_props *out);
|
bool get_drm_plane_props(int fd, uint32_t id, struct wlr_drm_plane_props *out);
|
||||||
|
|
||||||
bool get_drm_prop(int fd, uint32_t obj, uint32_t prop, uint64_t *ret);
|
bool get_drm_prop(int fd, uint32_t obj, uint32_t prop, uint64_t *ret);
|
||||||
void *get_drm_prop_blob(int fd, uint32_t obj, uint32_t prop, size_t *ret_len);
|
void *get_drm_prop_blob(int fd, uint32_t obj, uint32_t prop, size_t *ret_len);
|
||||||
|
Loading…
Reference in New Issue
Block a user