drm: samsung: panel: use crtc_state mode instead of current

By using crtc_state->mode instead of ctx->current_mode, the mode will
reflect the latest committed atomic state even if it hasn't been applied
yet (i.e. atomic commit tail still in progress).

Bug: 194407556
Change-Id: I26d0c8645e03d14e5443723a4def7459e404d3d2
Signed-off-by: Adrian Salido <salidoa@google.com>
diff --git a/samsung/panel/panel-samsung-drv.c b/samsung/panel/panel-samsung-drv.c
index 85c6aba..fce40e8 100644
--- a/samsung/panel/panel-samsung-drv.c
+++ b/samsung/panel/panel-samsung-drv.c
@@ -50,6 +50,8 @@
 static ssize_t exynos_panel_parse_byte_buf(char *input_str, size_t input_len,
 					   const char **out_buf);
 static int parse_u32_buf(char *src, size_t src_len, u32 *out, size_t out_len);
+static const struct exynos_panel_mode *exynos_panel_get_mode(struct exynos_panel *ctx,
+							     const struct drm_display_mode *mode);
 
 static inline bool is_backlight_off_state(const struct backlight_device *bl)
 {
@@ -1388,11 +1390,18 @@
 				    const struct exynos_drm_connector_state *exynos_state,
 				    uint64_t *val)
 {
+	const struct drm_connector_state *conn_state = &exynos_state->base;
+	const struct drm_crtc_state *crtc_state = conn_state->crtc ? conn_state->crtc->state : NULL;
 	struct exynos_panel *ctx = exynos_connector_to_panel(exynos_conn);
 	struct drm_property_blob *blob = ctx->lp_mode_blob;
-	const struct exynos_panel_mode *cur_mode = READ_ONCE(ctx->current_mode);
+	const struct exynos_panel_mode *cur_mode;
 	struct drm_mode_modeinfo umode;
 
+	if (crtc_state)
+		cur_mode = exynos_panel_get_mode(ctx, &crtc_state->mode);
+	else
+		cur_mode = READ_ONCE(ctx->current_mode);
+
 	if (unlikely(!ctx->desc->lp_mode))
 		return -EINVAL;
 
@@ -1710,10 +1719,6 @@
 {
 	const struct exynos_panel_funcs *funcs;
 
-	/* no need to go through seamless mode set if panel is disabled */
-	if (!is_panel_active(ctx))
-		return false;
-
 	funcs = ctx->desc->exynos_panel_func;
 	if (!funcs || !funcs->is_mode_seamless)
 		return false;