Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/edid: Fix csync detailed mode parsing

Remove the bogus csync check and replace it with something that:
- triggers for all forms of csync, not just the basic analog variant
- actually populates the mode csync flags so that drivers can
decide what to do with the mode

Originally the code tried to outright reject csync, but that
apparently broke some bogus LCD monitor that claimed to have
a detailed mode that uses analog csync, despite also claiming
the monitor only support separate sync:
https://bugzilla.redhat.com/show_bug.cgi?id=540024
Potentially that monitor should just be quirked or something.

Anyways, what we are dealing with now is some kind of funny i915
JSL machine with eDP where the panel claims to support a sensible
60Hz separate sync mode, and a 50Hz mode with bipolar analog
csync. The 50Hz mode does not work so we want to not use it.
Easiest way is to just correctly flag it as csync and the driver
will reject it.

TODO: or should we just reject any form of csync (or at least
the analog variants) for digital display interfaces?

v2: Grab digital csync polarity from hsync polarity bit (Jani)

Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/8146
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230228213610.26283-1-ville.syrjala@linux.intel.com

+30 -11
+21 -8
drivers/gpu/drm/drm_edid.c
··· 3424 3424 connector->base.id, connector->name); 3425 3425 return NULL; 3426 3426 } 3427 - if (!(pt->misc & DRM_EDID_PT_SEPARATE_SYNC)) { 3428 - drm_dbg_kms(dev, "[CONNECTOR:%d:%s] Composite sync not supported\n", 3429 - connector->base.id, connector->name); 3430 - } 3431 3427 3432 3428 /* it is incorrect if hsync/vsync width is zero */ 3433 3429 if (!hsync_pulse_width || !vsync_pulse_width) { ··· 3470 3474 if (info->quirks & EDID_QUIRK_DETAILED_SYNC_PP) { 3471 3475 mode->flags |= DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC; 3472 3476 } else { 3473 - mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ? 3474 - DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC; 3475 - mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ? 3476 - DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC; 3477 + switch (pt->misc & DRM_EDID_PT_SYNC_MASK) { 3478 + case DRM_EDID_PT_ANALOG_CSYNC: 3479 + case DRM_EDID_PT_BIPOLAR_ANALOG_CSYNC: 3480 + drm_dbg_kms(dev, "[CONNECTOR:%d:%s] Analog composite sync!\n", 3481 + connector->base.id, connector->name); 3482 + mode->flags |= DRM_MODE_FLAG_CSYNC | DRM_MODE_FLAG_NCSYNC; 3483 + break; 3484 + case DRM_EDID_PT_DIGITAL_CSYNC: 3485 + drm_dbg_kms(dev, "[CONNECTOR:%d:%s] Digital composite sync!\n", 3486 + connector->base.id, connector->name); 3487 + mode->flags |= DRM_MODE_FLAG_CSYNC; 3488 + mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ? 3489 + DRM_MODE_FLAG_PCSYNC : DRM_MODE_FLAG_NCSYNC; 3490 + break; 3491 + case DRM_EDID_PT_DIGITAL_SEPARATE_SYNC: 3492 + mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ? 3493 + DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC; 3494 + mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ? 3495 + DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC; 3496 + break; 3497 + } 3477 3498 } 3478 3499 3479 3500 set_size:
+9 -3
include/drm/drm_edid.h
··· 61 61 u8 vfreq_aspect; 62 62 } __attribute__((packed)); 63 63 64 - #define DRM_EDID_PT_HSYNC_POSITIVE (1 << 1) 65 - #define DRM_EDID_PT_VSYNC_POSITIVE (1 << 2) 66 - #define DRM_EDID_PT_SEPARATE_SYNC (3 << 3) 64 + #define DRM_EDID_PT_SYNC_MASK (3 << 3) 65 + # define DRM_EDID_PT_ANALOG_CSYNC (0 << 3) 66 + # define DRM_EDID_PT_BIPOLAR_ANALOG_CSYNC (1 << 3) 67 + # define DRM_EDID_PT_DIGITAL_CSYNC (2 << 3) 68 + # define DRM_EDID_PT_CSYNC_ON_RGB (1 << 1) /* analog csync only */ 69 + # define DRM_EDID_PT_CSYNC_SERRATE (1 << 2) 70 + # define DRM_EDID_PT_DIGITAL_SEPARATE_SYNC (3 << 3) 71 + # define DRM_EDID_PT_HSYNC_POSITIVE (1 << 1) /* also digital csync */ 72 + # define DRM_EDID_PT_VSYNC_POSITIVE (1 << 2) 67 73 #define DRM_EDID_PT_STEREO (1 << 5) 68 74 #define DRM_EDID_PT_INTERLACED (1 << 7) 69 75