In order to unify the handling of the panel and bridge, apply
panel_bridge helpers for Analogix DP driver. With this patch, the
bridge support will also become available.

The following changes have ben made:
- Apply plane_bridge helper to wrap the panel as the bridge.
- Remove the explicit panel APIs calls, which can be replaced with
  the automic bridge APIs calls wrapped by the panel.
- Unify the API of getting modes to drm_bridge_get_modes().

Signed-off-by: Damon Ding <damon.d...@rock-chips.com>

---

Changes in v4:
- Rename the &analogix_dp_plat_data.bridge to
  &analogix_dp_plat_data.next_bridge.

Changes in v5:
- Move panel_bridge addition a little forward.
- Move next_bridge attachment from Analogix side to Rockchip/Exynos
  side.
---
 .../drm/bridge/analogix/analogix_dp_core.c    | 29 +++++++++----------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c 
b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index 5e9e14b2f29a..e53dc0420490 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -857,11 +857,7 @@ static int analogix_dp_bridge_get_modes(struct drm_bridge 
*bridge, struct drm_co
        struct analogix_dp_device *dp = to_dp(bridge);
        int num_modes = 0;
 
-       if (dp->plat_data->panel)
-               num_modes += drm_panel_get_modes(dp->plat_data->panel, 
connector);
-
-       if (dp->plat_data->next_bridge)
-               num_modes += drm_bridge_get_modes(dp->plat_data->next_bridge, 
connector);
+       num_modes += drm_bridge_get_modes(dp->plat_data->next_bridge, 
connector);
 
        return num_modes;
 }
@@ -909,7 +905,7 @@ analogix_dp_bridge_detect(struct drm_bridge *bridge, struct 
drm_connector *conne
        struct analogix_dp_device *dp = to_dp(bridge);
        enum drm_connector_status status = connector_status_disconnected;
 
-       if (dp->plat_data->panel)
+       if (drm_bridge_is_panel(dp->plat_data->next_bridge))
                return connector_status_connected;
 
        if (!analogix_dp_detect_hpd(dp))
@@ -994,8 +990,6 @@ static void analogix_dp_bridge_atomic_pre_enable(struct 
drm_bridge *bridge,
        /* Don't touch the panel if we're coming back from PSR */
        if (old_crtc_state && old_crtc_state->self_refresh_active)
                return;
-
-       drm_panel_prepare(dp->plat_data->panel);
 }
 
 static int analogix_dp_set_bridge(struct analogix_dp_device *dp)
@@ -1150,7 +1144,6 @@ static void analogix_dp_bridge_atomic_enable(struct 
drm_bridge *bridge,
        while (timeout_loop < MAX_PLL_LOCK_LOOP) {
                if (analogix_dp_set_bridge(dp) == 0) {
                        dp->dpms_mode = DRM_MODE_DPMS_ON;
-                       drm_panel_enable(dp->plat_data->panel);
                        return;
                }
                dev_err(dp->dev, "failed to set bridge, retry: %d\n",
@@ -1168,16 +1161,12 @@ static void analogix_dp_bridge_disable(struct 
drm_bridge *bridge)
        if (dp->dpms_mode != DRM_MODE_DPMS_ON)
                return;
 
-       drm_panel_disable(dp->plat_data->panel);
-
        disable_irq(dp->irq);
 
        analogix_dp_set_analog_power_down(dp, POWER_ALL, 1);
 
        pm_runtime_put_sync(dp->dev);
 
-       drm_panel_unprepare(dp->plat_data->panel);
-
        dp->fast_train_enable = false;
        dp->psr_supported = false;
        dp->dpms_mode = DRM_MODE_DPMS_OFF;
@@ -1498,15 +1487,23 @@ int analogix_dp_bind(struct analogix_dp_device *dp, 
struct drm_device *drm_dev)
                return ret;
        }
 
-       if (dp->plat_data->panel)
+       if (dp->plat_data->panel) {
                /* If the next is a panel, the EDID parsing is checked by the 
panel driver */
                bridge->ops = DRM_BRIDGE_OP_MODES | DRM_BRIDGE_OP_DETECT;
-       else if (dp->plat_data->next_bridge)
+
+               dp->plat_data->next_bridge = devm_drm_panel_bridge_add(dp->dev,
+                                                                      
dp->plat_data->panel);
+               if (IS_ERR(dp->plat_data->next_bridge)) {
+                       ret = PTR_ERR(bridge);
+                       goto err_unregister_aux;
+               }
+       } else if (dp->plat_data->next_bridge) {
                /* If the next is a bridge, the supported operations depend on 
the next bridge */
                bridge->ops = 0;
-       else
+       } else {
                /* In DP mode, the EDID parsing and HPD detection should be 
supported */
                bridge->ops = DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_DETECT;
+       }
 
        bridge->of_node = dp->dev->of_node;
        bridge->type = DRM_MODE_CONNECTOR_eDP;
-- 
2.34.1

Reply via email to