Add atomic gamma lut size fetching
Legacy gamma lut size now uses the new legacy_crtc member of wlr_drm_crtc. This was Previously doen using old_crtc in wlr_drm_connector, but since this refers to the crtc that was connected to the ouput, this could give the wrong result.
This commit is contained in:
parent
cc1229e75e
commit
ab011406ad
|
@ -226,10 +226,24 @@ static bool atomic_crtc_set_gamma(struct wlr_drm_backend *drm,
|
||||||
return atomic_end(drm->fd, &atom);
|
return atomic_end(drm->fd, &atom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint32_t atomic_crtc_get_gamma_size(struct wlr_drm_backend *drm,
|
||||||
|
struct wlr_drm_crtc *crtc) {
|
||||||
|
uint64_t gamma_lut_size;
|
||||||
|
|
||||||
|
if (!wlr_drm_get_prop(drm->fd, crtc->id, crtc->props.gamma_lut_size,
|
||||||
|
&gamma_lut_size)) {
|
||||||
|
wlr_log(L_ERROR, "Unable to get gamma lut size");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (uint32_t) gamma_lut_size;
|
||||||
|
}
|
||||||
|
|
||||||
const struct wlr_drm_interface atomic_iface = {
|
const struct wlr_drm_interface atomic_iface = {
|
||||||
.conn_enable = atomic_conn_enable,
|
.conn_enable = atomic_conn_enable,
|
||||||
.crtc_pageflip = atomic_crtc_pageflip,
|
.crtc_pageflip = atomic_crtc_pageflip,
|
||||||
.crtc_set_cursor = atomic_crtc_set_cursor,
|
.crtc_set_cursor = atomic_crtc_set_cursor,
|
||||||
.crtc_move_cursor = atomic_crtc_move_cursor,
|
.crtc_move_cursor = atomic_crtc_move_cursor,
|
||||||
.crtc_set_gamma = atomic_crtc_set_gamma,
|
.crtc_set_gamma = atomic_crtc_set_gamma,
|
||||||
|
.crtc_get_gamma_size = atomic_crtc_get_gamma_size,
|
||||||
};
|
};
|
||||||
|
|
|
@ -140,6 +140,7 @@ bool wlr_drm_resources_init(struct wlr_drm_backend *drm) {
|
||||||
for (size_t i = 0; i < drm->num_crtcs; ++i) {
|
for (size_t i = 0; i < drm->num_crtcs; ++i) {
|
||||||
struct wlr_drm_crtc *crtc = &drm->crtcs[i];
|
struct wlr_drm_crtc *crtc = &drm->crtcs[i];
|
||||||
crtc->id = res->crtcs[i];
|
crtc->id = res->crtcs[i];
|
||||||
|
crtc->legacy_crtc = drmModeGetCrtc(drm->fd, crtc->id);
|
||||||
wlr_drm_get_crtc_props(drm->fd, crtc->id, &crtc->props);
|
wlr_drm_get_crtc_props(drm->fd, crtc->id, &crtc->props);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,6 +167,7 @@ void wlr_drm_resources_free(struct wlr_drm_backend *drm) {
|
||||||
for (size_t i = 0; i < drm->num_crtcs; ++i) {
|
for (size_t i = 0; i < drm->num_crtcs; ++i) {
|
||||||
struct wlr_drm_crtc *crtc = &drm->crtcs[i];
|
struct wlr_drm_crtc *crtc = &drm->crtcs[i];
|
||||||
drmModeAtomicFree(crtc->atomic);
|
drmModeAtomicFree(crtc->atomic);
|
||||||
|
drmModeFreeCrtc(crtc->legacy_crtc);
|
||||||
if (crtc->mode_id) {
|
if (crtc->mode_id) {
|
||||||
drmModeDestroyPropertyBlob(drm->fd, crtc->mode_id);
|
drmModeDestroyPropertyBlob(drm->fd, crtc->mode_id);
|
||||||
}
|
}
|
||||||
|
@ -235,8 +237,8 @@ static void wlr_drm_connector_set_gamma(struct wlr_output *output,
|
||||||
|
|
||||||
static uint32_t wlr_drm_connector_get_gamma_size(struct wlr_output *output) {
|
static uint32_t wlr_drm_connector_get_gamma_size(struct wlr_output *output) {
|
||||||
struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output;
|
struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output;
|
||||||
drmModeCrtc *crtc = conn->old_crtc;
|
struct wlr_drm_backend *drm = (struct wlr_drm_backend *)output->backend;
|
||||||
return crtc ? crtc->gamma_size : 0;
|
return drm->iface->crtc_get_gamma_size(drm, conn->crtc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_drm_connector_start_renderer(struct wlr_drm_connector *conn) {
|
void wlr_drm_connector_start_renderer(struct wlr_drm_connector *conn) {
|
||||||
|
|
|
@ -65,6 +65,10 @@ bool legacy_crtc_set_gamma(struct wlr_drm_backend *drm,
|
||||||
return !drmModeCrtcSetGamma(drm->fd, crtc->id, size, r, g, b);
|
return !drmModeCrtcSetGamma(drm->fd, crtc->id, size, r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t legacy_crtc_get_gamma_size(struct wlr_drm_backend *drm,
|
||||||
|
struct wlr_drm_crtc *crtc) {
|
||||||
|
return crtc->legacy_crtc->gamma_size;
|
||||||
|
}
|
||||||
|
|
||||||
const struct wlr_drm_interface legacy_iface = {
|
const struct wlr_drm_interface legacy_iface = {
|
||||||
.conn_enable = legacy_conn_enable,
|
.conn_enable = legacy_conn_enable,
|
||||||
|
@ -72,4 +76,5 @@ const struct wlr_drm_interface legacy_iface = {
|
||||||
.crtc_set_cursor = legacy_crtc_set_cursor,
|
.crtc_set_cursor = legacy_crtc_set_cursor,
|
||||||
.crtc_move_cursor = legacy_crtc_move_cursor,
|
.crtc_move_cursor = legacy_crtc_move_cursor,
|
||||||
.crtc_set_gamma = legacy_crtc_set_gamma,
|
.crtc_set_gamma = legacy_crtc_set_gamma,
|
||||||
|
.crtc_get_gamma_size = legacy_crtc_get_gamma_size,
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,11 +27,12 @@ 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(union wlr_drm_crtc_props, name) / sizeof(uint32_t))
|
||||||
{ "ACTIVE", INDEX(active) },
|
{ "ACTIVE", INDEX(active) },
|
||||||
{ "GAMMA_LUT", INDEX(gamma_lut) },
|
{ "GAMMA_LUT", INDEX(gamma_lut) },
|
||||||
{ "MODE_ID", INDEX(mode_id) },
|
{ "GAMMA_LUT_SIZE", INDEX(gamma_lut_size) },
|
||||||
{ "rotation", INDEX(rotation) },
|
{ "MODE_ID", INDEX(mode_id) },
|
||||||
{ "scaling mode", INDEX(scaling_mode) },
|
{ "rotation", INDEX(rotation) },
|
||||||
|
{ "scaling mode", INDEX(scaling_mode) },
|
||||||
#undef INDEX
|
#undef INDEX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,9 @@ struct wlr_drm_crtc {
|
||||||
uint32_t gamma_lut;
|
uint32_t gamma_lut;
|
||||||
drmModeAtomicReq *atomic;
|
drmModeAtomicReq *atomic;
|
||||||
|
|
||||||
|
// Legacy only
|
||||||
|
drmModeCrtc *legacy_crtc;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
struct wlr_drm_plane *overlay;
|
struct wlr_drm_plane *overlay;
|
||||||
|
|
|
@ -31,6 +31,9 @@ struct wlr_drm_interface {
|
||||||
bool (*crtc_set_gamma)(struct wlr_drm_backend *drm,
|
bool (*crtc_set_gamma)(struct wlr_drm_backend *drm,
|
||||||
struct wlr_drm_crtc *crtc, uint16_t *r, uint16_t *g, uint16_t *b,
|
struct wlr_drm_crtc *crtc, uint16_t *r, uint16_t *g, uint16_t *b,
|
||||||
uint32_t size);
|
uint32_t size);
|
||||||
|
// Get the gamma lut size of a crtc
|
||||||
|
uint32_t (*crtc_get_gamma_size)(struct wlr_drm_backend *drm,
|
||||||
|
struct wlr_drm_crtc *crtc);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const struct wlr_drm_interface atomic_iface;
|
extern const struct wlr_drm_interface atomic_iface;
|
||||||
|
|
|
@ -33,8 +33,9 @@ union wlr_drm_crtc_props {
|
||||||
uint32_t active;
|
uint32_t active;
|
||||||
uint32_t mode_id;
|
uint32_t mode_id;
|
||||||
uint32_t gamma_lut;
|
uint32_t gamma_lut;
|
||||||
|
uint32_t gamma_lut_size;
|
||||||
};
|
};
|
||||||
uint32_t props[5];
|
uint32_t props[6];
|
||||||
};
|
};
|
||||||
|
|
||||||
union wlr_drm_plane_props {
|
union wlr_drm_plane_props {
|
||||||
|
|
Loading…
Reference in New Issue