mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-09 13:29:46 -05:00
Implement wlr-gamma-control-unstable-v1
This commit is contained in:
parent
5642c5cc8f
commit
a149c2370a
11 changed files with 424 additions and 14 deletions
|
|
@ -199,14 +199,18 @@ static bool atomic_crtc_move_cursor(struct wlr_drm_backend *drm,
|
|||
static bool atomic_crtc_set_gamma(struct wlr_drm_backend *drm,
|
||||
struct wlr_drm_crtc *crtc, uint16_t *r, uint16_t *g, uint16_t *b,
|
||||
uint32_t size) {
|
||||
struct drm_color_lut gamma[size];
|
||||
|
||||
// Fallback to legacy gamma interface when gamma properties are not available
|
||||
// (can happen on older intel gpu's that support gamma but not degamma)
|
||||
if (crtc->props.gamma_lut == 0) {
|
||||
return legacy_iface.crtc_set_gamma(drm, crtc, r, g, b, size);
|
||||
}
|
||||
|
||||
struct drm_color_lut *gamma = malloc(size * sizeof(struct drm_color_lut));
|
||||
if (gamma == NULL) {
|
||||
wlr_log(WLR_ERROR, "Failed to allocate gamma table");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
gamma[i].red = r[i];
|
||||
gamma[i].green = g[i];
|
||||
|
|
@ -218,10 +222,12 @@ static bool atomic_crtc_set_gamma(struct wlr_drm_backend *drm,
|
|||
}
|
||||
|
||||
if (drmModeCreatePropertyBlob(drm->fd, gamma,
|
||||
sizeof(struct drm_color_lut) * size, &crtc->gamma_lut)) {
|
||||
size * sizeof(struct drm_color_lut), &crtc->gamma_lut)) {
|
||||
free(gamma);
|
||||
wlr_log_errno(WLR_ERROR, "Unable to create property blob");
|
||||
return false;
|
||||
}
|
||||
free(gamma);
|
||||
|
||||
struct atomic atom;
|
||||
atomic_begin(crtc, &atom);
|
||||
|
|
|
|||
|
|
@ -228,19 +228,19 @@ static bool drm_connector_swap_buffers(struct wlr_output *output,
|
|||
return true;
|
||||
}
|
||||
|
||||
static void drm_connector_set_gamma(struct wlr_output *output,
|
||||
static bool drm_connector_set_gamma(struct wlr_output *output,
|
||||
uint32_t size, uint16_t *r, uint16_t *g, uint16_t *b) {
|
||||
struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output;
|
||||
struct wlr_drm_backend *drm = (struct wlr_drm_backend *)output->backend;
|
||||
bool ok;
|
||||
|
||||
bool ok = false;
|
||||
if (conn->crtc) {
|
||||
ok = drm->iface->crtc_set_gamma(drm, conn->crtc, r, g, b, size);
|
||||
if (ok) {
|
||||
wlr_output_update_needs_swap(output);
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
static uint32_t drm_connector_get_gamma_size(struct wlr_output *output) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue