drm/edid: don't modify EDID while parsing
authorJani Nikula <jani.nikula@intel.com>
Mon, 28 Mar 2022 14:34:22 +0000 (17:34 +0300)
committerJani Nikula <jani.nikula@intel.com>
Tue, 29 Mar 2022 11:51:29 +0000 (14:51 +0300)
We'll want to keep the EDID immutable while parsing. Stop modifying the
EDID because of the quirks.

In theory, this does have userspace implications, but the userspace is
supposed to use the modes exposed via KMS API, not by parsing the EDID
directly.

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/45d5cf067eaad49b321ac82836090d9de524374e.1648477901.git.jani.nikula@intel.com
drivers/gpu/drm/drm_edid.c

index a7663f9a11d2c95bdd3962484c9ba83712a09d6f..0e434ab7908c65a6b1eafae83df8777046306ed1 100644 (file)
@@ -2740,9 +2740,9 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
                return NULL;
 
        if (quirks & EDID_QUIRK_135_CLOCK_TOO_HIGH)
-               timing->pixel_clock = cpu_to_le16(1088);
-
-       mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
+               mode->clock = 1088 * 10;
+       else
+               mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
 
        mode->hdisplay = hactive;
        mode->hsync_start = mode->hdisplay + hsync_offset;
@@ -2763,14 +2763,14 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
        drm_mode_do_interlace_quirk(mode, pt);
 
        if (quirks & EDID_QUIRK_DETAILED_SYNC_PP) {
-               pt->misc |= DRM_EDID_PT_HSYNC_POSITIVE | DRM_EDID_PT_VSYNC_POSITIVE;
+               mode->flags |= DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC;
+       } else {
+               mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ?
+                       DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
+               mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
+                       DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
        }
 
-       mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ?
-               DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
-       mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
-               DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
-
 set_size:
        mode->width_mm = pt->width_mm_lo | (pt->width_height_mm_hi & 0xf0) << 4;
        mode->height_mm = pt->height_mm_lo | (pt->width_height_mm_hi & 0xf) << 8;