From c7945e66cdcd3e6b888e111745c3025777d01242 Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
Date: Mon, 16 Jun 2025 16:44:08 +0100
Subject: [PATCH] drm/probe-helper: Ensure cmdline mode matches interlace mode

drm_helper_probe_add_cmdline_mode was looking for a match for
the width, height, and refresh rate within the EDID modes, but
didn't check the interlacing flag. That meant that with
video=1920x1080@50i would match any 1920x1080@50 mode that was
found.
The converse would be possible too if an interlaced mode with
matching resolution & refresh rate was found first.

Check the interlacing flag as well.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
 drivers/gpu/drm/drm_probe_helper.c | 4 ++++
 1 file changed, 4 insertions(+)

--- a/drivers/gpu/drm/drm_probe_helper.c
+++ b/drivers/gpu/drm/drm_probe_helper.c
@@ -164,6 +164,10 @@ static int drm_helper_probe_add_cmdline_
 				continue;
 		}
 
+		if (cmdline_mode->interlace !=
+		    !!(mode->flags & DRM_MODE_FLAG_INTERLACE))
+			continue;
+
 		/* Mark the matching mode as being preferred by the user */
 		mode->type |= DRM_MODE_TYPE_USERDEF;
 		return 0;
