diff options
| author | Simon Ser <contact@emersion.fr> | 2022-06-07 11:54:57 +0200 | 
|---|---|---|
| committer | Isaac Freund <mail@isaacfreund.com> | 2022-06-07 13:27:18 +0000 | 
| commit | 1f96f388e9db8ca8b196fc9f72008094fd634177 (patch) | |
| tree | f7d32425720f6136108dedd4011ed4531316a2a2 /backend | |
| parent | 1b27d537d13c25c622bf50b8b1670e5a40b944d1 (diff) | |
| download | wlroots-1f96f388e9db8ca8b196fc9f72008094fd634177.tar.xz | |
backend/drm: make serial optional
The EDID 1.4 spec says that the serial number is optional:
> If this field is not used, then enter “00h, 00h, 00h, 00h”.
Leave the wlr_output.serial field NULL in that case, and hide it
from the output description.
Diffstat (limited to 'backend')
| -rw-r--r-- | backend/drm/drm.c | 10 | ||||
| -rw-r--r-- | backend/drm/util.c | 10 | 
2 files changed, 15 insertions, 5 deletions
| diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 3a4a683f..cca0a8d4 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -1343,9 +1343,13 @@ void scan_drm_connectors(struct wlr_drm_backend *drm,  			struct wlr_output *output = &wlr_conn->output;  			char description[128]; -			snprintf(description, sizeof(description), "%s %s %s (%s%s%s)", -				output->make, output->model, output->serial, output->name, -				subconnector ? " via " : "", subconnector ? subconnector : ""); +			snprintf(description, sizeof(description), "%s %s%s%s (%s%s%s)", +				output->make, output->model, +				output->serial ? " " : "", +				output->serial ? output->serial : "", +				output->name, +				subconnector ? " via " : "", +				subconnector ? subconnector : "");  			wlr_output_set_description(output, description);  			free(subconnector); diff --git a/backend/drm/util.c b/backend/drm/util.c index eb419092..b25d9c8c 100644 --- a/backend/drm/util.c +++ b/backend/drm/util.c @@ -86,7 +86,11 @@ void parse_edid(struct wlr_drm_connector *conn, size_t len, const uint8_t *data)  	uint32_t serial = data[12] | (data[13] << 8) | (data[14] << 8) | (data[15] << 8);  	char serial_str[32]; -	snprintf(serial_str, sizeof(serial_str), "0x%08" PRIX32, serial); +	if (serial != 0) { +		snprintf(serial_str, sizeof(serial_str), "0x%08" PRIX32, serial); +	} else { +		serial_str[0] = '\0'; +	}  	for (size_t i = 72; i <= 108; i += 18) {  		uint16_t flag = (data[i] << 8) | data[i + 1]; @@ -112,7 +116,9 @@ void parse_edid(struct wlr_drm_connector *conn, size_t len, const uint8_t *data)  	}  	output->model = strdup(model_str); -	output->serial = strdup(serial_str); +	if (output->serial[0] != '\0') { +		output->serial = strdup(serial_str); +	}  }  const char *conn_get_name(uint32_t type_id) { | 
