Commit 87d322e9 authored by Dmitry Baryshkov's avatar Dmitry Baryshkov

drm/msm/dsi: simplify connector creation

Instead of having two functions, msm_dsi_manager_bridge_init()
and msm_dsi_manager_ext_bridge_init(), merge them into
msm_dsi_manager_connector_init(), moving drm_bridge_attach() to be
called from the bridge's attach callback (as most other bridges do).
Signed-off-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: default avatarAbhinav Kumar <quic_abhinavk@quicinc.com>
Patchwork: https://patchwork.freedesktop.org/patch/582212/
Link: https://lore.kernel.org/r/20240309-fd-dsi-cleanup-bridges-v1-3-962ebdba82ed@linaro.org
parent c73588c0
......@@ -232,7 +232,6 @@ void __exit msm_dsi_unregister(void)
int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,
struct drm_encoder *encoder)
{
struct drm_bridge *bridge;
int ret;
msm_dsi->dev = dev;
......@@ -252,14 +251,7 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,
return 0;
}
bridge = msm_dsi_manager_bridge_init(msm_dsi, encoder);
if (IS_ERR(bridge)) {
ret = PTR_ERR(bridge);
DRM_DEV_ERROR(dev->dev, "failed to create dsi bridge: %d\n", ret);
return ret;
}
ret = msm_dsi_manager_ext_bridge_init(msm_dsi->id, bridge);
ret = msm_dsi_manager_connector_init(msm_dsi, encoder);
if (ret) {
DRM_DEV_ERROR(dev->dev,
"failed to create dsi connector: %d\n", ret);
......
......@@ -47,9 +47,8 @@ struct msm_dsi {
};
/* dsi manager */
struct drm_bridge *msm_dsi_manager_bridge_init(struct msm_dsi *msm_dsi,
struct drm_encoder *encoder);
int msm_dsi_manager_ext_bridge_init(u8 id, struct drm_bridge *int_bridge);
int msm_dsi_manager_connector_init(struct msm_dsi *msm_dsi,
struct drm_encoder *encoder);
int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len);
int msm_dsi_manager_register(struct msm_dsi *msm_dsi);
......
......@@ -423,7 +423,18 @@ static enum drm_mode_status dsi_mgr_bridge_mode_valid(struct drm_bridge *bridge,
return msm_dsi_host_check_dsc(host, mode);
}
static int dsi_mgr_bridge_attach(struct drm_bridge *bridge,
enum drm_bridge_attach_flags flags)
{
int id = dsi_mgr_bridge_get_id(bridge);
struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
return drm_bridge_attach(bridge->encoder, msm_dsi->next_bridge,
bridge, flags);
}
static const struct drm_bridge_funcs dsi_mgr_bridge_funcs = {
.attach = dsi_mgr_bridge_attach,
.pre_enable = dsi_mgr_bridge_pre_enable,
.post_disable = dsi_mgr_bridge_post_disable,
.mode_set = dsi_mgr_bridge_mode_set,
......@@ -431,17 +442,19 @@ static const struct drm_bridge_funcs dsi_mgr_bridge_funcs = {
};
/* initialize bridge */
struct drm_bridge *msm_dsi_manager_bridge_init(struct msm_dsi *msm_dsi,
struct drm_encoder *encoder)
int msm_dsi_manager_connector_init(struct msm_dsi *msm_dsi,
struct drm_encoder *encoder)
{
struct drm_device *dev = msm_dsi->dev;
struct drm_bridge *bridge;
struct dsi_bridge *dsi_bridge;
struct drm_connector *connector;
int ret;
dsi_bridge = devm_kzalloc(msm_dsi->dev->dev,
sizeof(*dsi_bridge), GFP_KERNEL);
if (!dsi_bridge)
return ERR_PTR(-ENOMEM);
return -ENOMEM;
dsi_bridge->id = msm_dsi->id;
......@@ -450,27 +463,9 @@ struct drm_bridge *msm_dsi_manager_bridge_init(struct msm_dsi *msm_dsi,
ret = devm_drm_bridge_add(msm_dsi->dev->dev, bridge);
if (ret)
return ERR_PTR(ret);
ret = drm_bridge_attach(encoder, bridge, NULL, 0);
if (ret)
return ERR_PTR(ret);
return bridge;
}
int msm_dsi_manager_ext_bridge_init(u8 id, struct drm_bridge *int_bridge)
{
struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
struct drm_device *dev = msm_dsi->dev;
struct drm_encoder *encoder;
struct drm_connector *connector;
int ret;
encoder = int_bridge->encoder;
return ret;
ret = drm_bridge_attach(encoder, msm_dsi->next_bridge, int_bridge,
DRM_BRIDGE_ATTACH_NO_CONNECTOR);
ret = drm_bridge_attach(encoder, bridge, NULL, DRM_BRIDGE_ATTACH_NO_CONNECTOR);
if (ret)
return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment