[PATCH RFC 17/19] drm/bridge: lvds-encoder: Implement bus format negotiation for sn75lvds83

Boris Brezillon boris.brezillon at collabora.com
Thu Aug 8 15:11:48 UTC 2019


The SN75LVDS83 bridge support several input formats except the input
format is directly related to the expected output format. Let's express
that constraint by setting the bridge_state->output_bus_cfg.fmt field
to the appropriate value.

The previous element in the chain might be able to use this information
to pick the appropriate output bus format.

Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>
---
 drivers/gpu/drm/bridge/lvds-encoder.c | 48 +++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/drivers/gpu/drm/bridge/lvds-encoder.c b/drivers/gpu/drm/bridge/lvds-encoder.c
index da7013c5faf1..8d399d1828b0 100644
--- a/drivers/gpu/drm/bridge/lvds-encoder.c
+++ b/drivers/gpu/drm/bridge/lvds-encoder.c
@@ -159,9 +159,57 @@ static int lvds_encoder_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static int sn75lvds83_atomic_check(struct drm_bridge *bridge,
+				   struct drm_bridge_state *bridge_state,
+				   struct drm_crtc_state *crtc_state,
+				   struct drm_connector_state *conn_state)
+{
+	int ret;
+
+	ret = drm_atomic_bridge_choose_output_bus_cfg(bridge_state, crtc_state,
+						      conn_state);
+	if (ret)
+		return ret;
+
+	/*
+	 * The output bus format has a direct impact on the expected input bus
+	 * format.
+	 */
+	switch (bridge_state->output_bus_cfg.fmt) {
+	case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA:
+	case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG:
+		/*
+		 * JEIDA and SPWG variants theoretically require different pin
+		 * mapping, but MEDIA_BUS_FMT_ definitions do not allow
+		 * fined-grained pin placement definition, and this is
+		 * something we expect to be taken care of at board design
+		 * time, so let's ignore this for now.
+		 * If it becomes a problem, we can always add a way to override
+		 * the bus format with a FW property.
+		 */
+		bridge_state->input_bus_cfg.fmt = MEDIA_BUS_FMT_RGB888_1X24;
+		break;
+	case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG:
+		bridge_state->input_bus_cfg.fmt = MEDIA_BUS_FMT_RGB666_1X18;
+		break;
+	default:
+		bridge_state->input_bus_cfg.fmt = 0;
+		break;
+	}
+
+	/* Propagate the bus_flags. */
+	bridge_state->input_bus_cfg.flags = bridge_state->output_bus_cfg.flags;
+	return 0;
+}
+
+static const struct lvds_encoder_ops sn75lvds83_ops = {
+	.atomic_check = sn75lvds83_atomic_check,
+};
+
 static const struct of_device_id lvds_encoder_match[] = {
 	{ .compatible = "lvds-encoder" },
 	{ .compatible = "thine,thc63lvdm83d" },
+	{ .compatible = "ti,sn75lvds83", .data = &sn75lvds83_ops },
 	{},
 };
 MODULE_DEVICE_TABLE(of, lvds_encoder_match);
-- 
2.21.0



More information about the dri-devel mailing list