Skip to content
Snippets Groups Projects
Commit 75cb9178 authored by Pekka Paalanen's avatar Pekka Paalanen
Browse files

compositor-drm: set output make/model/serial once


This fixes a regression where monitor make and model would always be
advertised as "unknown" to Wayland clients. The EDID strings were parsed
at create_output_for_connector() time, but the fallback "unknown" values
were set in weston_drm_output_api::set_mode vfunc later. This made the
correct monitor info be shown in the log, but not sent to clients.

The purpose of the "unknown" assignments is to give fallback values in
case EDID is not providing them.

Fix all that by moving all setting of the make, model and serial into
create_output_for_connector(). These values cannot change afterwards
anyway. While at it, document find_and_parse_output_edid().

The ugly casts in create_output_for_connector() are required to silence
compositor warnings from ignoring const attribute. This is temporary,
and a future refactoring will get rid of the casts.

Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
parent 17ba3a11
No related branches found
No related tags found
No related merge requests found
...@@ -2841,9 +2841,26 @@ edid_parse(struct drm_edid *edid, const uint8_t *data, size_t length) ...@@ -2841,9 +2841,26 @@ edid_parse(struct drm_edid *edid, const uint8_t *data, size_t length)
return 0; return 0;
} }
/** Parse monitor make, model and serial from EDID
*
* \param b The backend instance.
* \param output The output whose \c drm_edid to fill in.
* \param props The DRM connector properties to get the EDID from.
* \param make[out] The monitor make (PNP ID).
* \param model[out] The monitor model (name).
* \param serial_number[out] The monitor serial number.
*
* Each of \c *make, \c *model and \c *serial_number are set only if the
* information is found in the EDID. The pointers they are set to must not
* be free()'d explicitly, instead they get implicitly freed when the
* \c drm_output is destroyed.
*/
static void static void
find_and_parse_output_edid(struct drm_backend *b, struct drm_output *output, find_and_parse_output_edid(struct drm_backend *b, struct drm_output *output,
drmModeObjectPropertiesPtr props) drmModeObjectPropertiesPtr props,
const char **make,
const char **model,
const char **serial_number)
{ {
drmModePropertyBlobPtr edid_blob = NULL; drmModePropertyBlobPtr edid_blob = NULL;
uint32_t blob_id; uint32_t blob_id;
...@@ -2868,17 +2885,15 @@ find_and_parse_output_edid(struct drm_backend *b, struct drm_output *output, ...@@ -2868,17 +2885,15 @@ find_and_parse_output_edid(struct drm_backend *b, struct drm_output *output,
output->edid.monitor_name, output->edid.monitor_name,
output->edid.serial_number); output->edid.serial_number);
if (output->edid.pnp_id[0] != '\0') if (output->edid.pnp_id[0] != '\0')
output->base.make = output->edid.pnp_id; *make = output->edid.pnp_id;
if (output->edid.monitor_name[0] != '\0') if (output->edid.monitor_name[0] != '\0')
output->base.model = output->edid.monitor_name; *model = output->edid.monitor_name;
if (output->edid.serial_number[0] != '\0') if (output->edid.serial_number[0] != '\0')
output->base.serial_number = output->edid.serial_number; *serial_number = output->edid.serial_number;
} }
drmModeFreePropertyBlob(edid_blob); drmModeFreePropertyBlob(edid_blob);
} }
static int static int
parse_modeline(const char *s, drmModeModeInfo *mode) parse_modeline(const char *s, drmModeModeInfo *mode)
{ {
...@@ -3093,10 +3108,6 @@ drm_output_set_mode(struct weston_output *base, ...@@ -3093,10 +3108,6 @@ drm_output_set_mode(struct weston_output *base,
struct drm_mode *current; struct drm_mode *current;
drmModeModeInfo crtc_mode; drmModeModeInfo crtc_mode;
output->base.make = "unknown";
output->base.model = "unknown";
output->base.serial_number = "unknown";
if (connector_get_current_mode(output->connector, b->drm.fd, &crtc_mode) < 0) if (connector_get_current_mode(output->connector, b->drm.fd, &crtc_mode) < 0)
return -1; return -1;
...@@ -3328,6 +3339,9 @@ create_output_for_connector(struct drm_backend *b, ...@@ -3328,6 +3339,9 @@ create_output_for_connector(struct drm_backend *b,
drmModeObjectPropertiesPtr props; drmModeObjectPropertiesPtr props;
struct drm_mode *drm_mode; struct drm_mode *drm_mode;
char *name; char *name;
const char *make = "unknown";
const char *model = "unknown";
const char *serial_number = "unknown";
int i; int i;
static const struct drm_property_info connector_props[] = { static const struct drm_property_info connector_props[] = {
...@@ -3374,7 +3388,11 @@ create_output_for_connector(struct drm_backend *b, ...@@ -3374,7 +3388,11 @@ create_output_for_connector(struct drm_backend *b,
} }
drm_property_info_populate(b, connector_props, output->props_conn, drm_property_info_populate(b, connector_props, output->props_conn,
WDRM_CONNECTOR__COUNT, props); WDRM_CONNECTOR__COUNT, props);
find_and_parse_output_edid(b, output, props); find_and_parse_output_edid(b, output, props,
&make, &model, &serial_number);
output->base.make = (char *)make;
output->base.model = (char *)model;
output->base.serial_number = (char *)serial_number;
drmModeFreeObjectProperties(props); drmModeFreeObjectProperties(props);
for (i = 0; i < output->connector->count_modes; i++) { for (i = 0; i < output->connector->count_modes; i++) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment