From: Pekka Paalanen <pekka.paala...@collabora.co.uk> 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 <pekka.paala...@collabora.co.uk> --- libweston/compositor-drm.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c index 36e2015e..ee3e76dd 100644 --- a/libweston/compositor-drm.c +++ b/libweston/compositor-drm.c @@ -2841,9 +2841,26 @@ edid_parse(struct drm_edid *edid, const uint8_t *data, size_t length) 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 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; uint32_t blob_id; @@ -2868,17 +2885,15 @@ find_and_parse_output_edid(struct drm_backend *b, struct drm_output *output, output->edid.monitor_name, output->edid.serial_number); 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') - output->base.model = output->edid.monitor_name; + *model = output->edid.monitor_name; if (output->edid.serial_number[0] != '\0') - output->base.serial_number = output->edid.serial_number; + *serial_number = output->edid.serial_number; } drmModeFreePropertyBlob(edid_blob); } - - static int parse_modeline(const char *s, drmModeModeInfo *mode) { @@ -3093,10 +3108,6 @@ drm_output_set_mode(struct weston_output *base, struct drm_mode *current; 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) return -1; @@ -3328,6 +3339,9 @@ create_output_for_connector(struct drm_backend *b, drmModeObjectPropertiesPtr props; struct drm_mode *drm_mode; char *name; + const char *make = "unknown"; + const char *model = "unknown"; + const char *serial_number = "unknown"; int i; static const struct drm_property_info connector_props[] = { @@ -3374,7 +3388,11 @@ create_output_for_connector(struct drm_backend *b, } drm_property_info_populate(b, connector_props, output->props_conn, 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); for (i = 0; i < output->connector->count_modes; i++) { -- 2.13.5 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel