mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	backend/drm: reset gamma table on VT switch
This commit is contained in:
		
							parent
							
								
									2beb68007e
								
							
						
					
					
						commit
						e88db9a3fb
					
				
					 3 changed files with 26 additions and 3 deletions
				
			
		| 
						 | 
					@ -101,6 +101,16 @@ static void session_signal(struct wl_listener *listener, void *data) {
 | 
				
			||||||
				(plane && plane->cursor_enabled) ? plane->cursor_bo : NULL);
 | 
									(plane && plane->cursor_enabled) ? plane->cursor_bo : NULL);
 | 
				
			||||||
			drm->iface->crtc_move_cursor(drm, conn->crtc, conn->cursor_x,
 | 
								drm->iface->crtc_move_cursor(drm, conn->crtc, conn->cursor_x,
 | 
				
			||||||
				conn->cursor_y);
 | 
									conn->cursor_y);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (conn->crtc->gamma_table != NULL) {
 | 
				
			||||||
 | 
									size_t size = conn->crtc->gamma_table_size;
 | 
				
			||||||
 | 
									uint16_t *r = conn->crtc->gamma_table;
 | 
				
			||||||
 | 
									uint16_t *g = conn->crtc->gamma_table + size;
 | 
				
			||||||
 | 
									uint16_t *b = conn->crtc->gamma_table + 2 * size;
 | 
				
			||||||
 | 
									drm->iface->crtc_set_gamma(drm, conn->crtc, size, r, g, b);
 | 
				
			||||||
 | 
								} else {
 | 
				
			||||||
 | 
									set_drm_connector_gamma(&conn->output, 0, NULL, NULL, NULL);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		wlr_log(WLR_INFO, "DRM fd paused");
 | 
							wlr_log(WLR_INFO, "DRM fd paused");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -193,6 +193,7 @@ void finish_drm_resources(struct wlr_drm_backend *drm) {
 | 
				
			||||||
		if (crtc->gamma_lut) {
 | 
							if (crtc->gamma_lut) {
 | 
				
			||||||
			drmModeDestroyPropertyBlob(drm->fd, crtc->gamma_lut);
 | 
								drmModeDestroyPropertyBlob(drm->fd, crtc->gamma_lut);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							free(crtc->gamma_table);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for (size_t i = 0; i < drm->num_planes; ++i) {
 | 
						for (size_t i = 0; i < drm->num_planes; ++i) {
 | 
				
			||||||
		struct wlr_drm_plane *plane = &drm->planes[i];
 | 
							struct wlr_drm_plane *plane = &drm->planes[i];
 | 
				
			||||||
| 
						 | 
					@ -270,7 +271,7 @@ static size_t drm_connector_get_gamma_size(struct wlr_output *output) {
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static bool drm_connector_set_gamma(struct wlr_output *output, size_t size,
 | 
					bool set_drm_connector_gamma(struct wlr_output *output, size_t size,
 | 
				
			||||||
		const uint16_t *r, const uint16_t *g, const uint16_t *b) {
 | 
							const uint16_t *r, const uint16_t *g, const uint16_t *b) {
 | 
				
			||||||
	struct wlr_drm_connector *conn = get_drm_connector_from_output(output);
 | 
						struct wlr_drm_connector *conn = get_drm_connector_from_output(output);
 | 
				
			||||||
	struct wlr_drm_backend *drm = get_drm_backend_from_backend(output->backend);
 | 
						struct wlr_drm_backend *drm = get_drm_backend_from_backend(output->backend);
 | 
				
			||||||
| 
						 | 
					@ -308,8 +309,13 @@ static bool drm_connector_set_gamma(struct wlr_output *output, size_t size,
 | 
				
			||||||
	bool ok = drm->iface->crtc_set_gamma(drm, conn->crtc, size, _r, _g, _b);
 | 
						bool ok = drm->iface->crtc_set_gamma(drm, conn->crtc, size, _r, _g, _b);
 | 
				
			||||||
	if (ok) {
 | 
						if (ok) {
 | 
				
			||||||
		wlr_output_update_needs_swap(output);
 | 
							wlr_output_update_needs_swap(output);
 | 
				
			||||||
	}
 | 
					
 | 
				
			||||||
 | 
							free(conn->crtc->gamma_table);
 | 
				
			||||||
 | 
							conn->crtc->gamma_table = gamma_table;
 | 
				
			||||||
 | 
							conn->crtc->gamma_table_size = size;
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
		free(gamma_table);
 | 
							free(gamma_table);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	return ok;
 | 
						return ok;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -736,7 +742,7 @@ static const struct wlr_output_impl output_impl = {
 | 
				
			||||||
	.destroy = drm_connector_destroy,
 | 
						.destroy = drm_connector_destroy,
 | 
				
			||||||
	.make_current = drm_connector_make_current,
 | 
						.make_current = drm_connector_make_current,
 | 
				
			||||||
	.swap_buffers = drm_connector_swap_buffers,
 | 
						.swap_buffers = drm_connector_swap_buffers,
 | 
				
			||||||
	.set_gamma = drm_connector_set_gamma,
 | 
						.set_gamma = set_drm_connector_gamma,
 | 
				
			||||||
	.get_gamma_size = drm_connector_get_gamma_size,
 | 
						.get_gamma_size = drm_connector_get_gamma_size,
 | 
				
			||||||
	.export_dmabuf = drm_connector_export_dmabuf,
 | 
						.export_dmabuf = drm_connector_export_dmabuf,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -771,6 +777,8 @@ static void dealloc_crtc(struct wlr_drm_connector *conn) {
 | 
				
			||||||
	wlr_log(WLR_DEBUG, "De-allocating CRTC %zu for output '%s'",
 | 
						wlr_log(WLR_DEBUG, "De-allocating CRTC %zu for output '%s'",
 | 
				
			||||||
		conn->crtc - drm->crtcs, conn->output.name);
 | 
							conn->crtc - drm->crtcs, conn->output.name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						set_drm_connector_gamma(&conn->output, 0, NULL, NULL, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (size_t type = 0; type < 3; ++type) {
 | 
						for (size_t type = 0; type < 3; ++type) {
 | 
				
			||||||
		struct wlr_drm_plane *plane = conn->crtc->planes[type];
 | 
							struct wlr_drm_plane *plane = conn->crtc->planes[type];
 | 
				
			||||||
		if (plane == NULL) {
 | 
							if (plane == NULL) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -57,6 +57,9 @@ struct wlr_drm_crtc {
 | 
				
			||||||
	union wlr_drm_crtc_props props;
 | 
						union wlr_drm_crtc_props props;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wl_list connectors;
 | 
						struct wl_list connectors;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						uint16_t *gamma_table;
 | 
				
			||||||
 | 
						size_t gamma_table_size;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct wlr_drm_backend {
 | 
					struct wlr_drm_backend {
 | 
				
			||||||
| 
						 | 
					@ -151,5 +154,7 @@ void restore_drm_outputs(struct wlr_drm_backend *drm);
 | 
				
			||||||
void scan_drm_connectors(struct wlr_drm_backend *state);
 | 
					void scan_drm_connectors(struct wlr_drm_backend *state);
 | 
				
			||||||
int handle_drm_event(int fd, uint32_t mask, void *data);
 | 
					int handle_drm_event(int fd, uint32_t mask, void *data);
 | 
				
			||||||
bool enable_drm_connector(struct wlr_output *output, bool enable);
 | 
					bool enable_drm_connector(struct wlr_output *output, bool enable);
 | 
				
			||||||
 | 
					bool set_drm_connector_gamma(struct wlr_output *output, size_t size,
 | 
				
			||||||
 | 
						const uint16_t *r, const uint16_t *g, const uint16_t *b);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue