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.
- Remove the unnecessary analogix_dp_bridge_get_modes().

Signed-off-by: Damon Ding <[email protected]>
Tested-by: Marek Szyprowski <[email protected]>
Reviewed-by: Dmitry Baryshkov <[email protected]>

---

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.

Changes in v6
- Remove the unnecessary analogix_dp_bridge_get_modes().
- Not to set DRM_BRIDGE_OP_MODES if the next is a panel.
- Squash [PATCH v5 15/17]drm/bridge: analogix_dp: Remove panel
  disabling and enabling in analogix_dp_set_bridge() into this
  commit.
- Fix the &drm_bridge->ops to DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_DETECT.
---
 .../drm/bridge/analogix/analogix_dp_core.c    | 41 +++++--------------
 1 file changed, 11 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c 
b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index 7e3e9d4f4ea2..d2ea93e1c9a3 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -749,9 +749,6 @@ static int analogix_dp_commit(struct analogix_dp_device *dp)
 {
        int ret;
 
-       /* Keep the panel disabled while we configure video */
-       drm_panel_disable(dp->plat_data->panel);
-
        ret = analogix_dp_train_link(dp);
        if (ret) {
                dev_err(dp->dev, "unable to do link train, ret=%d\n", ret);
@@ -771,9 +768,6 @@ static int analogix_dp_commit(struct analogix_dp_device *dp)
                return ret;
        }
 
-       /* Safe to enable the panel now */
-       drm_panel_enable(dp->plat_data->panel);
-
        /* Check whether panel supports fast training */
        ret = analogix_dp_fast_link_train_detection(dp);
        if (ret)
@@ -858,17 +852,6 @@ static int analogix_dp_disable_psr(struct 
analogix_dp_device *dp)
        return analogix_dp_send_psr_spd(dp, &psr_vsc, true);
 }
 
-static int analogix_dp_bridge_get_modes(struct drm_bridge *bridge, struct 
drm_connector *connector)
-{
-       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);
-
-       return num_modes;
-}
-
 static const struct drm_edid *analogix_dp_bridge_edid_read(struct drm_bridge 
*bridge,
                                                           struct drm_connector 
*connector)
 {
@@ -909,7 +892,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 || dp->plat_data->next_bridge)
+       if (dp->plat_data->next_bridge)
                return connector_status_connected;
 
        if (!analogix_dp_detect_hpd(dp))
@@ -995,8 +978,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)
@@ -1168,16 +1149,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;
@@ -1252,7 +1229,6 @@ static const struct drm_bridge_funcs 
analogix_dp_bridge_funcs = {
        .atomic_post_disable = analogix_dp_bridge_atomic_post_disable,
        .atomic_check = analogix_dp_bridge_atomic_check,
        .attach = analogix_dp_bridge_attach,
-       .get_modes = analogix_dp_bridge_get_modes,
        .edid_read = analogix_dp_bridge_edid_read,
        .detect = analogix_dp_bridge_detect,
 };
@@ -1498,17 +1474,22 @@ int analogix_dp_bind(struct analogix_dp_device *dp, 
struct drm_device *drm_dev)
                return ret;
        }
 
-       if (dp->plat_data->panel)
-               bridge->ops = DRM_BRIDGE_OP_MODES | DRM_BRIDGE_OP_DETECT;
-       else
-               bridge->ops = DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_DETECT;
-
+       bridge->ops = DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_DETECT;
        bridge->of_node = dp->dev->of_node;
        bridge->type = DRM_MODE_CONNECTOR_eDP;
        ret = devm_drm_bridge_add(dp->dev, &dp->bridge);
        if (ret)
                goto err_unregister_aux;
 
+       if (dp->plat_data->panel) {
+               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;
+               }
+       }
+
        ret = drm_bridge_attach(dp->encoder, bridge, NULL, 
DRM_BRIDGE_ATTACH_NO_CONNECTOR);
        if (ret) {
                DRM_ERROR("failed to create bridge (%d)\n", ret);
-- 
2.34.1

Reply via email to