Skip to contentSkip to conversation

drm/stm: Fix bus_flags handling

PATCH Superseded Marek Vasut 1 participant 1 message Jan 16, 2021

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 drm/stm: Fix bus_flags handling

The drm_display_mode_to_videomode() does not populate DISPLAY_FLAGS_DE_LOW or DISPLAY_FLAGS_PIXDATA_NEGEDGE flags in struct videomode. Therefore, no matter what polarity the next bridge or display might require, these flags are never set, and thus the LTDC GCR_DEPOL and GCR_PCPOL bits are never set, and the LTDC behaves as if both DISPLAY_FLAGS_PIXDATA_POSEDGE and DISPLAY_FLAGS_DE_HIGH were always set.

The fix for this problem is taken almost verbatim from MXSFB driver. In case there is a bridge attached to the LTDC, the bridge might have extra polarity requirements, so extract bus_flags from the bridge and use them for LTDC configuration. Otherwise, extract bus_flags from the connector, which is the display.

Fixes b759012c5fa7 ("drm/stm: Add STM32 LTDC driver")
Cc Alexandre Torgue <[email protected]>
Cc Antonio Borneo <[email protected]>
Cc Benjamin Gaignard <[email protected]>
Cc Maxime Coquelin <[email protected]>
Cc Philippe Cornu <[email protected]>
Cc Sam Ravnborg <[email protected]>
Cc Vincent Abriou <[email protected]>
Cc Yannick Fertre <[email protected]>

To: [email protected]
---
V2: Check if ldev->bridge->timings is non-NULL before accessing it
V3: get bus_flags from connector (from Yannick)
- Display controller could support several connectors (not connected at the same time). ie: stm32mp15c-DK2 board have 2 connectors (HDMI + DSI). Driver check which connector is connected to get the bus flag.

---
 drivers/gpu/drm/stm/ltdc.c | 28 ++++++++++++++++++++++++++--
 drivers/gpu/drm/stm/ltdc.h |  2 ++
 2 files changed, 28 insertions(+), 2 deletions(-)
drivers/gpu/drm/stm/ltdc.c +26 -2
index 7812094f93d6..b9cd2dc114cd 100644
@@ -525,13 +525,25 @@ static void ltdc_crtc_mode_set_nofb(struct drm_crtc *crtc)
 {
 	struct ltdc_device *ldev = crtc_to_ltdc(crtc);
 	struct drm_device *ddev = crtc->dev;
+	struct drm_connector_list_iter iter;
+	struct drm_connector *connector;
 	struct drm_display_mode *mode = &crtc->state->adjusted_mode;
 	struct videomode vm;
+	u32 bus_flags = 0;
 	u32 hsync, vsync, accum_hbp, accum_vbp, accum_act_w, accum_act_h;
 	u32 total_width, total_height;
 	u32 val;
 	int ret;
 
+	/* Get the connector which is connected */
+	drm_connector_list_iter_begin(ddev, &iter);
+	drm_for_each_connector_iter(connector, &iter)
+		if(connector->status == connector_status_connected)
+			break;
+	drm_connector_list_iter_end(&iter);
+
+	bus_flags = connector->display_info.bus_flags;
+
 	if (!pm_runtime_active(ddev->dev)) {
 		ret = pm_runtime_get_sync(ddev->dev);
 		if (ret) {
@@ -567,10 +579,10 @@ static void ltdc_crtc_mode_set_nofb(struct drm_crtc *crtc)
 	if (vm.flags & DISPLAY_FLAGS_VSYNC_HIGH)
 		val |= GCR_VSPOL;
 
-	if (vm.flags & DISPLAY_FLAGS_DE_LOW)
+	if (bus_flags & DRM_BUS_FLAG_DE_LOW)
 		val |= GCR_DEPOL;
 
-	if (vm.flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE)
+	if (bus_flags & DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE)
 		val |= GCR_PCPOL;
 
 	reg_update_bits(ldev->regs, LTDC_GCR,
@@ -1078,6 +1090,8 @@ static const struct drm_encoder_helper_funcs ltdc_encoder_helper_funcs = {
 
 static int ltdc_encoder_init(struct drm_device *ddev, struct drm_bridge *bridge)
 {
+	struct ltdc_device *ldev = ddev->dev_private;
+	struct drm_connector_list_iter iter;
 	struct drm_encoder *encoder;
 	int ret;
 
@@ -1099,6 +1113,16 @@ static int ltdc_encoder_init(struct drm_device *ddev, struct drm_bridge *bridge)
 		return -EINVAL;
 	}
 
+	ldev->bridge = bridge;
+
+	/*
+	 * Get hold of the connector. This is a bit of a hack, until the bridge
+	 * API gives us bus flags and formats.
+	 */
+	drm_connector_list_iter_begin(ddev, &iter);
+	ldev->connector = drm_connector_list_iter_next(&iter);
+	drm_connector_list_iter_end(&iter);
+
 	DRM_DEBUG_DRIVER("Bridge encoder:%d created\n", encoder->base.id);
 
 	return 0;
drivers/gpu/drm/stm/ltdc.h +2 -0
index f153b908c70e..d0d2c81de29a 100644
@@ -38,6 +38,8 @@ struct ltdc_device {
 	u32 irq_status;
 	struct fps_info plane_fpsi[LTDC_MAX_LAYER];
 	struct drm_atomic_state *suspend_state;
+	struct drm_bridge *bridge;
+	struct drm_connector *connector;
 };
 
 int ltdc_load(struct drm_device *ddev);
Signature · 7 lines
2.29.2


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel