2017-09-23 10:26:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#ifndef BACKEND_DRM_UTIL_H
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#define BACKEND_DRM_UTIL_H
							 | 
						
					
						
							
								
									
										
										
										
											2017-08-05 17:56:22 +12:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <stdint.h>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <xf86drm.h>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <xf86drmMode.h>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-06 11:58:17 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								struct wlr_drm_connector;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-08-05 17:56:22 +12:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// Calculates a more accurate refresh rate (mHz) than what mode itself provides
							 | 
						
					
						
							
								
									
										
										
										
											2018-12-16 11:06:46 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								int32_t calculate_refresh_rate(const drmModeModeInfo *mode);
							 | 
						
					
						
							
								
									
										
										
										
											2022-09-05 16:56:47 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								enum wlr_output_mode_aspect_ratio get_picture_aspect_ratio(const drmModeModeInfo *mode);
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-27 00:11:47 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								// Returns manufacturer based on pnp id
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-02 12:14:11 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								const char *get_pnp_manufacturer(const char code[static 3]);
							 | 
						
					
						
							
								
									
										
										
										
											2017-08-05 17:56:22 +12:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// Populates the make/model/phys_{width,height} of output from the edid data
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-06 11:58:17 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void parse_edid(struct wlr_drm_connector *conn, size_t len, const uint8_t *data);
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-06 18:31:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								const char *drm_connector_status_str(drmModeConnection status);
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-02 13:41:40 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void generate_cvt_mode(drmModeModeInfo *mode, int hdisplay, int vdisplay,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									float vrefresh);
							 | 
						
					
						
							
								
									
										
										
										
											2017-08-05 17:56:22 +12:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-21 21:56:39 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								// Part of match_connectors_with_crtcs
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-21 22:18:23 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#define UNMATCHED ((uint32_t)-1)
							 | 
						
					
						
							
								
									
										
										
										
											2017-08-05 17:56:22 +12:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-21 21:56:39 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * Tries to match DRM connectors with DRM CRTCs.
							 | 
						
					
						
							
								
									
										
										
										
											2017-08-05 17:56:22 +12:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-21 21:56:39 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * conns contains an array of bitmasks describing compatible CRTCs. For
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * instance bit 0 set in an connector element means that it's compatible with
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * CRTC 0.
							 | 
						
					
						
							
								
									
										
										
										
											2017-08-05 17:56:22 +12:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-21 21:56:39 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * prev_crtcs contains connector indices each CRTC was previously matched with,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * or UNMATCHED.
							 | 
						
					
						
							
								
									
										
										
										
											2017-08-05 17:56:22 +12:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-21 21:56:39 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * new_crtcs is populated with the new connector indices.
							 | 
						
					
						
							
								
									
										
										
										
											2017-08-05 17:56:22 +12:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-21 22:02:51 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void match_connectors_with_crtcs(size_t num_conns,
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-21 21:56:39 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									const uint32_t conns[static restrict num_conns],
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									size_t num_crtcs, const uint32_t prev_crtcs[static restrict num_crtcs],
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									uint32_t new_crtcs[static restrict num_crtcs]);
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-25 23:24:58 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-08-05 17:56:22 +12:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 |