From 60cedeb0501e29c49907c78833cabd1cf73704f5 Mon Sep 17 00:00:00 2001
From: Jeongjun Park <aha310510@gmail.com>
Date: Thu, 9 Apr 2026 19:11:29 +0900
Subject: [PATCH] drm/vc4: txp: add implementation of the missing connector
 reset custom function

In the previous commit, we added a rotation parameter to be used in the
connector, but because we are still using the default reset function
without implementing a custom reset function to properly initialize it,
the rotation variable remains NULL until it is initialized directly
in userspace.

To prevent this, we must implement a custom reset function that properly
initializes the rotation parameter.

Fixes: 30c7044e03f4 ("drm: Add a rotation parameter to connectors.")
Signed-off-by: Jeongjun Park <aha310510@gmail.com>
---
 drivers/gpu/drm/vc4/vc4_drv.h |  1 +
 drivers/gpu/drm/vc4/vc4_txp.c | 18 +++++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

--- a/drivers/gpu/drm/vc4/vc4_drv.h
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
@@ -1060,6 +1060,7 @@ extern struct platform_driver vc4_vec_dr
 
 /* vc4_txp.c */
 extern struct platform_driver vc4_txp_driver;
+void vc4_txp_connector_reset(struct drm_connector *connector);
 
 /* vc4_irq.c */
 void vc4_irq_enable(struct drm_device *dev);
--- a/drivers/gpu/drm/vc4/vc4_txp.c
+++ b/drivers/gpu/drm/vc4/vc4_txp.c
@@ -390,11 +390,27 @@ vc4_txp_connector_detect(struct drm_conn
 	return connector_status_connected;
 }
 
+void vc4_txp_connector_reset(struct drm_connector *connector)
+{
+	uint64_t rotation = DRM_MODE_ROTATE_0;
+
+	drm_atomic_helper_connector_reset(connector);
+
+	if (connector->state) {
+		if (connector->rotation_property)
+			drm_object_property_get_default_value(&connector->base,
+							      connector->rotation_property,
+							      &rotation);
+
+		connector->state->rotation = rotation;
+	}
+}
+
 static const struct drm_connector_funcs vc4_txp_connector_funcs = {
 	.detect = vc4_txp_connector_detect,
 	.fill_modes = drm_helper_probe_single_connector_modes,
 	.destroy = drm_connector_cleanup,
-	.reset = drm_atomic_helper_connector_reset,
+	.reset = vc4_txp_connector_reset,
 	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
