Commit 3bb80f24 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Archit Taneja

drm: bridge: Link encoder and bridge in core code

Instead of linking encoders and bridges in every driver (and getting it
wrong half of the time, as many drivers forget to set the drm_bridge
encoder pointer), do so in core code. The drm_bridge_attach() function
needs the encoder and optional previous bridge to perform that task,
update all the callers.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Stefan Agner <stefan@agner.ch> # For DCU
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com> # For atmel-hlcdc
Acked-by: Vincent Abriou <vincent.abriou@st.com> # For STI
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com> # For sun4i
Acked-by: Xinliang Liu <z.liuxinliang@hisilicon.com> # For hisilicon
Acked-by: Jyri Sarha <jsarha@ti.com> # For tilcdc
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarArchit Taneja <architt@codeaurora.org>
Link: http://patchwork.freedesktop.org/patch/msgid/1481709550-29226-4-git-send-email-laurent.pinchart+renesas@ideasonboard.com
parent 2407d1dc
...@@ -47,10 +47,7 @@ int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np) ...@@ -47,10 +47,7 @@ int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
return ret; return ret;
/* Link drm_bridge to encoder */ /* Link drm_bridge to encoder */
bridge->encoder = encoder; ret = drm_bridge_attach(encoder, bridge, NULL);
encoder->bridge = bridge;
ret = drm_bridge_attach(drm, bridge);
if (ret) if (ret)
drm_encoder_cleanup(encoder); drm_encoder_cleanup(encoder);
......
...@@ -230,9 +230,7 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, ...@@ -230,9 +230,7 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev,
of_node_put(np); of_node_put(np);
if (bridge) { if (bridge) {
output->encoder.bridge = bridge; ret = drm_bridge_attach(&output->encoder, bridge, NULL);
bridge->encoder = &output->encoder;
ret = drm_bridge_attach(dev, bridge);
if (!ret) if (!ret)
return 0; return 0;
} }
......
...@@ -1232,12 +1232,10 @@ static int analogix_dp_create_bridge(struct drm_device *drm_dev, ...@@ -1232,12 +1232,10 @@ static int analogix_dp_create_bridge(struct drm_device *drm_dev,
dp->bridge = bridge; dp->bridge = bridge;
dp->encoder->bridge = bridge;
bridge->driver_private = dp; bridge->driver_private = dp;
bridge->encoder = dp->encoder;
bridge->funcs = &analogix_dp_bridge_funcs; bridge->funcs = &analogix_dp_bridge_funcs;
ret = drm_bridge_attach(drm_dev, bridge); ret = drm_bridge_attach(dp->encoder, bridge, NULL);
if (ret) { if (ret) {
DRM_ERROR("failed to attach drm bridge\n"); DRM_ERROR("failed to attach drm bridge\n");
return -EINVAL; return -EINVAL;
......
...@@ -1841,13 +1841,12 @@ static int dw_hdmi_register(struct drm_device *drm, struct dw_hdmi *hdmi) ...@@ -1841,13 +1841,12 @@ static int dw_hdmi_register(struct drm_device *drm, struct dw_hdmi *hdmi)
hdmi->bridge = bridge; hdmi->bridge = bridge;
bridge->driver_private = hdmi; bridge->driver_private = hdmi;
bridge->funcs = &dw_hdmi_bridge_funcs; bridge->funcs = &dw_hdmi_bridge_funcs;
ret = drm_bridge_attach(drm, bridge); ret = drm_bridge_attach(encoder, bridge, NULL);
if (ret) { if (ret) {
DRM_ERROR("Failed to initialize bridge with drm\n"); DRM_ERROR("Failed to initialize bridge with drm\n");
return -EINVAL; return -EINVAL;
} }
encoder->bridge = bridge;
hdmi->connector.polled = DRM_CONNECTOR_POLL_HPD; hdmi->connector.polled = DRM_CONNECTOR_POLL_HPD;
drm_connector_helper_add(&hdmi->connector, drm_connector_helper_add(&hdmi->connector,
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/mutex.h> #include <linux/mutex.h>
#include <drm/drm_bridge.h> #include <drm/drm_bridge.h>
#include <drm/drm_encoder.h>
/** /**
* DOC: overview * DOC: overview
...@@ -92,32 +93,53 @@ void drm_bridge_remove(struct drm_bridge *bridge) ...@@ -92,32 +93,53 @@ void drm_bridge_remove(struct drm_bridge *bridge)
EXPORT_SYMBOL(drm_bridge_remove); EXPORT_SYMBOL(drm_bridge_remove);
/** /**
* drm_bridge_attach - associate given bridge to our DRM device * drm_bridge_attach - attach the bridge to an encoder's chain
* *
* @dev: DRM device * @encoder: DRM encoder
* @bridge: bridge control structure * @bridge: bridge to attach
* @previous: previous bridge in the chain (optional)
* *
* Called by a kms driver to link one of our encoder/bridge to the given * Called by a kms driver to link the bridge to an encoder's chain. The previous
* bridge. * argument specifies the previous bridge in the chain. If NULL, the bridge is
* linked directly at the encoder's output. Otherwise it is linked at the
* previous bridge's output.
* *
* Note that setting up links between the bridge and our encoder/bridge * If non-NULL the previous bridge must be already attached by a call to this
* objects needs to be handled by the kms driver itself. * function.
* *
* RETURNS: * RETURNS:
* Zero on success, error code on failure * Zero on success, error code on failure
*/ */
int drm_bridge_attach(struct drm_device *dev, struct drm_bridge *bridge) int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
struct drm_bridge *previous)
{ {
if (!dev || !bridge) int ret;
if (!encoder || !bridge)
return -EINVAL;
if (previous && (!previous->dev || previous->encoder != encoder))
return -EINVAL; return -EINVAL;
if (bridge->dev) if (bridge->dev)
return -EBUSY; return -EBUSY;
bridge->dev = dev; bridge->dev = encoder->dev;
bridge->encoder = encoder;
if (bridge->funcs->attach) {
ret = bridge->funcs->attach(bridge);
if (ret < 0) {
bridge->dev = NULL;
bridge->encoder = NULL;
return ret;
}
}
if (bridge->funcs->attach) if (previous)
return bridge->funcs->attach(bridge); previous->next = bridge;
else
encoder->bridge = bridge;
return 0; return 0;
} }
......
...@@ -182,9 +182,7 @@ static const struct drm_plane_funcs drm_simple_kms_plane_funcs = { ...@@ -182,9 +182,7 @@ static const struct drm_plane_funcs drm_simple_kms_plane_funcs = {
int drm_simple_display_pipe_attach_bridge(struct drm_simple_display_pipe *pipe, int drm_simple_display_pipe_attach_bridge(struct drm_simple_display_pipe *pipe,
struct drm_bridge *bridge) struct drm_bridge *bridge)
{ {
bridge->encoder = &pipe->encoder; return drm_bridge_attach(&pipe->encoder, bridge, NULL);
pipe->encoder.bridge = bridge;
return drm_bridge_attach(pipe->encoder.dev, bridge);
} }
EXPORT_SYMBOL(drm_simple_display_pipe_attach_bridge); EXPORT_SYMBOL(drm_simple_display_pipe_attach_bridge);
......
...@@ -99,7 +99,6 @@ static int exynos_dp_bridge_attach(struct analogix_dp_plat_data *plat_data, ...@@ -99,7 +99,6 @@ static int exynos_dp_bridge_attach(struct analogix_dp_plat_data *plat_data,
struct drm_connector *connector) struct drm_connector *connector)
{ {
struct exynos_dp_device *dp = to_dp(plat_data); struct exynos_dp_device *dp = to_dp(plat_data);
struct drm_encoder *encoder = &dp->encoder;
int ret; int ret;
drm_connector_register(connector); drm_connector_register(connector);
...@@ -107,9 +106,7 @@ static int exynos_dp_bridge_attach(struct analogix_dp_plat_data *plat_data, ...@@ -107,9 +106,7 @@ static int exynos_dp_bridge_attach(struct analogix_dp_plat_data *plat_data,
/* Pre-empt DP connector creation if there's a bridge */ /* Pre-empt DP connector creation if there's a bridge */
if (dp->ptn_bridge) { if (dp->ptn_bridge) {
bridge->next = dp->ptn_bridge; ret = drm_bridge_attach(&dp->encoder, dp->ptn_bridge, bridge);
dp->ptn_bridge->encoder = encoder;
ret = drm_bridge_attach(encoder->dev, dp->ptn_bridge);
if (ret) { if (ret) {
DRM_ERROR("Failed to attach bridge to drm\n"); DRM_ERROR("Failed to attach bridge to drm\n");
bridge->next = NULL; bridge->next = NULL;
......
...@@ -1718,10 +1718,8 @@ static int exynos_dsi_bind(struct device *dev, struct device *master, ...@@ -1718,10 +1718,8 @@ static int exynos_dsi_bind(struct device *dev, struct device *master,
} }
bridge = of_drm_find_bridge(dsi->bridge_node); bridge = of_drm_find_bridge(dsi->bridge_node);
if (bridge) { if (bridge)
encoder->bridge = bridge; drm_bridge_attach(encoder, bridge, NULL);
drm_bridge_attach(drm_dev, bridge);
}
return mipi_dsi_host_register(&dsi->dsi_host); return mipi_dsi_host_register(&dsi->dsi_host);
} }
......
...@@ -160,10 +160,7 @@ static int fsl_dcu_attach_endpoint(struct fsl_dcu_drm_device *fsl_dev, ...@@ -160,10 +160,7 @@ static int fsl_dcu_attach_endpoint(struct fsl_dcu_drm_device *fsl_dev,
if (!bridge) if (!bridge)
return -ENODEV; return -ENODEV;
fsl_dev->encoder.bridge = bridge; return drm_bridge_attach(&fsl_dev->encoder, bridge, NULL);
bridge->encoder = &fsl_dev->encoder;
return drm_bridge_attach(fsl_dev->drm, bridge);
} }
int fsl_dcu_create_outputs(struct fsl_dcu_drm_device *fsl_dev) int fsl_dcu_create_outputs(struct fsl_dcu_drm_device *fsl_dev)
......
...@@ -709,10 +709,7 @@ static int dsi_bridge_init(struct drm_device *dev, struct dw_dsi *dsi) ...@@ -709,10 +709,7 @@ static int dsi_bridge_init(struct drm_device *dev, struct dw_dsi *dsi)
int ret; int ret;
/* associate the bridge to dsi encoder */ /* associate the bridge to dsi encoder */
encoder->bridge = bridge; ret = drm_bridge_attach(encoder, bridge, NULL);
bridge->encoder = encoder;
ret = drm_bridge_attach(dev, bridge);
if (ret) { if (ret) {
DRM_ERROR("failed to attach external bridge\n"); DRM_ERROR("failed to attach external bridge\n");
return ret; return ret;
......
...@@ -454,10 +454,8 @@ static int imx_ldb_register(struct drm_device *drm, ...@@ -454,10 +454,8 @@ static int imx_ldb_register(struct drm_device *drm,
DRM_MODE_ENCODER_LVDS, NULL); DRM_MODE_ENCODER_LVDS, NULL);
if (imx_ldb_ch->bridge) { if (imx_ldb_ch->bridge) {
imx_ldb_ch->bridge->encoder = encoder; ret = drm_bridge_attach(&imx_ldb_ch->encoder,
imx_ldb_ch->bridge, NULL);
imx_ldb_ch->encoder.bridge = imx_ldb_ch->bridge;
ret = drm_bridge_attach(drm, imx_ldb_ch->bridge);
if (ret) { if (ret) {
DRM_ERROR("Failed to initialize bridge with drm\n"); DRM_ERROR("Failed to initialize bridge with drm\n");
return ret; return ret;
......
...@@ -191,9 +191,7 @@ static int imx_pd_register(struct drm_device *drm, ...@@ -191,9 +191,7 @@ static int imx_pd_register(struct drm_device *drm,
drm_panel_attach(imxpd->panel, &imxpd->connector); drm_panel_attach(imxpd->panel, &imxpd->connector);
if (imxpd->bridge) { if (imxpd->bridge) {
imxpd->bridge->encoder = encoder; ret = drm_bridge_attach(encoder, imxpd->bridge, NULL);
encoder->bridge = imxpd->bridge;
ret = drm_bridge_attach(drm, imxpd->bridge);
if (ret < 0) { if (ret < 0) {
dev_err(imxpd->dev, "failed to attach bridge: %d\n", dev_err(imxpd->dev, "failed to attach bridge: %d\n",
ret); ret);
......
...@@ -63,6 +63,7 @@ enum mtk_dpi_out_color_format { ...@@ -63,6 +63,7 @@ enum mtk_dpi_out_color_format {
struct mtk_dpi { struct mtk_dpi {
struct mtk_ddp_comp ddp_comp; struct mtk_ddp_comp ddp_comp;
struct drm_encoder encoder; struct drm_encoder encoder;
struct drm_bridge *bridge;
void __iomem *regs; void __iomem *regs;
struct device *dev; struct device *dev;
struct clk *engine_clk; struct clk *engine_clk;
...@@ -620,8 +621,7 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data) ...@@ -620,8 +621,7 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data)
/* Currently DPI0 is fixed to be driven by OVL1 */ /* Currently DPI0 is fixed to be driven by OVL1 */
dpi->encoder.possible_crtcs = BIT(1); dpi->encoder.possible_crtcs = BIT(1);
dpi->encoder.bridge->encoder = &dpi->encoder; ret = drm_bridge_attach(&dpi->encoder, dpi->bridge, NULL);
ret = drm_bridge_attach(dpi->encoder.dev, dpi->encoder.bridge);
if (ret) { if (ret) {
dev_err(dev, "Failed to attach bridge: %d\n", ret); dev_err(dev, "Failed to attach bridge: %d\n", ret);
goto err_cleanup; goto err_cleanup;
...@@ -718,9 +718,9 @@ static int mtk_dpi_probe(struct platform_device *pdev) ...@@ -718,9 +718,9 @@ static int mtk_dpi_probe(struct platform_device *pdev)
dev_info(dev, "Found bridge node: %s\n", bridge_node->full_name); dev_info(dev, "Found bridge node: %s\n", bridge_node->full_name);
dpi->encoder.bridge = of_drm_find_bridge(bridge_node); dpi->bridge = of_drm_find_bridge(bridge_node);
of_node_put(bridge_node); of_node_put(bridge_node);
if (!dpi->encoder.bridge) if (!dpi->bridge)
return -EPROBE_DEFER; return -EPROBE_DEFER;
comp_id = mtk_ddp_comp_get_id(dev->of_node, MTK_DPI); comp_id = mtk_ddp_comp_get_id(dev->of_node, MTK_DPI);
......
...@@ -622,26 +622,6 @@ static const struct drm_connector_helper_funcs ...@@ -622,26 +622,6 @@ static const struct drm_connector_helper_funcs
.get_modes = mtk_dsi_connector_get_modes, .get_modes = mtk_dsi_connector_get_modes,
}; };
static int mtk_drm_attach_bridge(struct drm_bridge *bridge,
struct drm_encoder *encoder)
{
int ret;
if (!bridge)
return -ENOENT;
encoder->bridge = bridge;
bridge->encoder = encoder;
ret = drm_bridge_attach(encoder->dev, bridge);
if (ret) {
DRM_ERROR("Failed to attach bridge to drm\n");
encoder->bridge = NULL;
bridge->encoder = NULL;
}
return ret;
}
static int mtk_dsi_create_connector(struct drm_device *drm, struct mtk_dsi *dsi) static int mtk_dsi_create_connector(struct drm_device *drm, struct mtk_dsi *dsi)
{ {
int ret; int ret;
...@@ -692,8 +672,10 @@ static int mtk_dsi_create_conn_enc(struct drm_device *drm, struct mtk_dsi *dsi) ...@@ -692,8 +672,10 @@ static int mtk_dsi_create_conn_enc(struct drm_device *drm, struct mtk_dsi *dsi)
dsi->encoder.possible_crtcs = 1; dsi->encoder.possible_crtcs = 1;
/* If there's a bridge, attach to it and let it create the connector */ /* If there's a bridge, attach to it and let it create the connector */
ret = mtk_drm_attach_bridge(dsi->bridge, &dsi->encoder); ret = drm_bridge_attach(&dsi->encoder, dsi->bridge, NULL);
if (ret) { if (ret) {
DRM_ERROR("Failed to attach bridge to drm\n");
/* Otherwise create our own connector and attach to a panel */ /* Otherwise create our own connector and attach to a panel */
ret = mtk_dsi_create_connector(drm, dsi); ret = mtk_dsi_create_connector(drm, dsi);
if (ret) if (ret)
......
...@@ -149,6 +149,7 @@ struct hdmi_audio_param { ...@@ -149,6 +149,7 @@ struct hdmi_audio_param {
struct mtk_hdmi { struct mtk_hdmi {
struct drm_bridge bridge; struct drm_bridge bridge;
struct drm_bridge *next_bridge;
struct drm_connector conn; struct drm_connector conn;
struct device *dev; struct device *dev;
struct phy *phy; struct phy *phy;
...@@ -1314,9 +1315,9 @@ static int mtk_hdmi_bridge_attach(struct drm_bridge *bridge) ...@@ -1314,9 +1315,9 @@ static int mtk_hdmi_bridge_attach(struct drm_bridge *bridge)
return ret; return ret;
} }
if (bridge->next) { if (hdmi->next_bridge) {
bridge->next->encoder = bridge->encoder; ret = drm_bridge_attach(bridge->encoder, hdmi->next_bridge,
ret = drm_bridge_attach(bridge->encoder->dev, bridge->next); bridge);
if (ret) { if (ret) {
dev_err(hdmi->dev, dev_err(hdmi->dev,
"Failed to attach external bridge: %d\n", ret); "Failed to attach external bridge: %d\n", ret);
...@@ -1510,8 +1511,8 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, ...@@ -1510,8 +1511,8 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
of_node_put(ep); of_node_put(ep);
if (!of_device_is_compatible(remote, "hdmi-connector")) { if (!of_device_is_compatible(remote, "hdmi-connector")) {
hdmi->bridge.next = of_drm_find_bridge(remote); hdmi->next_bridge = of_drm_find_bridge(remote);
if (!hdmi->bridge.next) { if (!hdmi->next_bridge) {
dev_err(dev, "Waiting for external bridge\n"); dev_err(dev, "Waiting for external bridge\n");
of_node_put(remote); of_node_put(remote);
return -EPROBE_DEFER; return -EPROBE_DEFER;
......
...@@ -579,6 +579,7 @@ struct drm_bridge *msm_dsi_manager_bridge_init(u8 id) ...@@ -579,6 +579,7 @@ struct drm_bridge *msm_dsi_manager_bridge_init(u8 id)
struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
struct drm_bridge *bridge = NULL; struct drm_bridge *bridge = NULL;
struct dsi_bridge *dsi_bridge; struct dsi_bridge *dsi_bridge;
struct drm_encoder *encoder;
int ret; int ret;
dsi_bridge = devm_kzalloc(msm_dsi->dev->dev, dsi_bridge = devm_kzalloc(msm_dsi->dev->dev,
...@@ -590,10 +591,18 @@ struct drm_bridge *msm_dsi_manager_bridge_init(u8 id) ...@@ -590,10 +591,18 @@ struct drm_bridge *msm_dsi_manager_bridge_init(u8 id)
dsi_bridge->id = id; dsi_bridge->id = id;
/*
* HACK: we may not know the external DSI bridge device's mode
* flags here. We'll get to know them only when the device
* attaches to the dsi host. For now, assume the bridge supports
* DSI video mode
*/
encoder = msm_dsi->encoders[MSM_DSI_VIDEO_ENCODER_ID];
bridge = &dsi_bridge->base; bridge = &dsi_bridge->base;
bridge->funcs = &dsi_mgr_bridge_funcs; bridge->funcs = &dsi_mgr_bridge_funcs;
ret = drm_bridge_attach(msm_dsi->dev, bridge); ret = drm_bridge_attach(encoder, bridge, NULL);
if (ret) if (ret)
goto fail; goto fail;
...@@ -628,11 +637,7 @@ struct drm_connector *msm_dsi_manager_ext_bridge_init(u8 id) ...@@ -628,11 +637,7 @@ struct drm_connector *msm_dsi_manager_ext_bridge_init(u8 id)
encoder = msm_dsi->encoders[MSM_DSI_VIDEO_ENCODER_ID]; encoder = msm_dsi->encoders[MSM_DSI_VIDEO_ENCODER_ID];
/* link the internal dsi bridge to the external bridge */ /* link the internal dsi bridge to the external bridge */
int_bridge->next = ext_bridge; drm_bridge_attach(encoder, ext_bridge, int_bridge);
/* set the external bridge's encoder as dsi's encoder */
ext_bridge->encoder = encoder;
drm_bridge_attach(dev, ext_bridge);
/* /*
* we need the drm_connector created by the external bridge * we need the drm_connector created by the external bridge
......
...@@ -106,7 +106,7 @@ struct drm_bridge *msm_edp_bridge_init(struct msm_edp *edp) ...@@ -106,7 +106,7 @@ struct drm_bridge *msm_edp_bridge_init(struct msm_edp *edp)
bridge = &edp_bridge->base; bridge = &edp_bridge->base;
bridge->funcs = &edp_bridge_funcs; bridge->funcs = &edp_bridge_funcs;
ret = drm_bridge_attach(edp->dev, bridge); ret = drm_bridge_attach(edp->encoder, bridge, NULL);
if (ret) if (ret)
goto fail; goto fail;
......
...@@ -227,7 +227,7 @@ struct drm_bridge *msm_hdmi_bridge_init(struct hdmi *hdmi) ...@@ -227,7 +227,7 @@ struct drm_bridge *msm_hdmi_bridge_init(struct hdmi *hdmi)
bridge = &hdmi_bridge->base; bridge = &hdmi_bridge->base;
bridge->funcs = &msm_hdmi_bridge_funcs; bridge->funcs = &msm_hdmi_bridge_funcs;
ret = drm_bridge_attach(hdmi->dev, bridge); ret = drm_bridge_attach(hdmi->encoder, bridge, NULL);
if (ret) if (ret)
goto fail; goto fail;
......
...@@ -124,10 +124,7 @@ int rcar_du_hdmienc_init(struct rcar_du_device *rcdu, ...@@ -124,10 +124,7 @@ int rcar_du_hdmienc_init(struct rcar_du_device *rcdu,
hdmienc->renc = renc; hdmienc->renc = renc;
/* Link the bridge to the encoder. */ /* Link the bridge to the encoder. */
bridge->encoder = encoder; ret = drm_bridge_attach(encoder, bridge, NULL);
encoder->bridge = bridge;
ret = drm_bridge_attach(rcdu->ddev, bridge);
if (ret) { if (ret) {
drm_encoder_cleanup(encoder); drm_encoder_cleanup(encoder);
return ret; return ret;
......
...@@ -478,14 +478,13 @@ static int sti_dvo_bind(struct device *dev, struct device *master, void *data) ...@@ -478,14 +478,13 @@ static int sti_dvo_bind(struct device *dev, struct device *master, void *data)
return err; return err;
} }
err = drm_bridge_attach(drm_dev, bridge); err = drm_bridge_attach(encoder, bridge, NULL);
if (err) { if (err) {
DRM_ERROR("Failed to attach bridge\n"); DRM_ERROR("Failed to attach bridge\n");
return err; return err;
} }
dvo->bridge = bridge; dvo->bridge = bridge;
encoder->bridge = bridge;
connector->encoder = encoder; connector->encoder = encoder;
dvo->encoder = encoder; dvo->encoder = encoder;
......
...@@ -707,9 +707,8 @@ static int sti_hda_bind(struct device *dev, struct device *master, void *data) ...@@ -707,9 +707,8 @@ static int sti_hda_bind(struct device *dev, struct device *master, void *data)
bridge->driver_private = hda; bridge->driver_private = hda;
bridge->funcs = &sti_hda_bridge_funcs; bridge->funcs = &sti_hda_bridge_funcs;
drm_bridge_attach(drm_dev, bridge); drm_bridge_attach(encoder, bridge, NULL);
encoder->bridge = bridge;
connector->encoder = encoder; connector->encoder = encoder;
drm_connector = (struct drm_connector *)connector; drm_connector = (struct drm_connector *)connector;
......
...@@ -1308,9 +1308,8 @@ static int sti_hdmi_bind(struct device *dev, struct device *master, void *data) ...@@ -1308,9 +1308,8 @@ static int sti_hdmi_bind(struct device *dev, struct device *master, void *data)
bridge->driver_private = hdmi; bridge->driver_private = hdmi;
bridge->funcs = &sti_hdmi_bridge_funcs; bridge->funcs = &sti_hdmi_bridge_funcs;
drm_bridge_attach(drm_dev, bridge); drm_bridge_attach(encoder, bridge, NULL);
encoder->bridge = bridge;
connector->encoder = encoder; connector->encoder = encoder;
drm_connector = (struct drm_connector *)connector; drm_connector = (struct drm_connector *)connector;
......
...@@ -208,6 +208,7 @@ int sun4i_rgb_init(struct drm_device *drm) ...@@ -208,6 +208,7 @@ int sun4i_rgb_init(struct drm_device *drm)
struct sun4i_drv *drv = drm->dev_private; struct sun4i_drv *drv = drm->dev_private;
struct sun4i_tcon *tcon = drv->tcon; struct sun4i_tcon *tcon = drv->tcon;
struct drm_encoder *encoder; struct drm_encoder *encoder;
struct drm_bridge *bridge;
struct sun4i_rgb *rgb; struct sun4i_rgb *rgb;
int ret; int ret;
...@@ -218,8 +219,8 @@ int sun4i_rgb_init(struct drm_device *drm) ...@@ -218,8 +219,8 @@ int sun4i_rgb_init(struct drm_device *drm)
encoder = &rgb->encoder; encoder = &rgb->encoder;
tcon->panel = sun4i_tcon_find_panel(tcon->dev->of_node); tcon->panel = sun4i_tcon_find_panel(tcon->dev->of_node);
encoder->bridge = sun4i_tcon_find_bridge(tcon->dev->of_node); bridge = sun4i_tcon_find_bridge(tcon->dev->of_node);
if (IS_ERR(tcon->panel) && IS_ERR(encoder->bridge)) { if (IS_ERR(tcon->panel) && IS_ERR(bridge)) {
dev_info(drm->dev, "No panel or bridge found... RGB output disabled\n"); dev_info(drm->dev, "No panel or bridge found... RGB output disabled\n");
return 0; return 0;
} }
...@@ -260,16 +261,12 @@ int sun4i_rgb_init(struct drm_device *drm) ...@@ -260,16 +261,12 @@ int sun4i_rgb_init(struct drm_device *drm)
} }
} }
if (!IS_ERR(encoder->bridge)) { if (!IS_ERR(bridge)) {
encoder->bridge->encoder = &rgb->encoder; ret = drm_bridge_attach(encoder, bridge, NULL);
ret = drm_bridge_attach(drm, encoder->bridge);
if (ret) { if (ret) {
dev_err(drm->dev, "Couldn't attach our bridge\n"); dev_err(drm->dev, "Couldn't attach our bridge\n");
goto err_cleanup_connector; goto err_cleanup_connector;
} }
} else {
encoder->bridge = NULL;
} }
return 0; return 0;
......
...@@ -167,10 +167,8 @@ int tilcdc_attach_bridge(struct drm_device *ddev, struct drm_bridge *bridge) ...@@ -167,10 +167,8 @@ int tilcdc_attach_bridge(struct drm_device *ddev, struct drm_bridge *bridge)
int ret; int ret;
priv->external_encoder->possible_crtcs = BIT(0); priv->external_encoder->possible_crtcs = BIT(0);
priv->external_encoder->bridge = bridge;
bridge->encoder = priv->external_encoder;
ret = drm_bridge_attach(ddev, bridge); ret = drm_bridge_attach(priv->external_encoder, bridge, NULL);
if (ret) { if (ret) {
dev_err(ddev->dev, "drm_bridge_attach() failed %d\n", ret); dev_err(ddev->dev, "drm_bridge_attach() failed %d\n", ret);
return ret; return ret;
......
...@@ -201,7 +201,8 @@ struct drm_bridge { ...@@ -201,7 +201,8 @@ struct drm_bridge {
int drm_bridge_add(struct drm_bridge *bridge); int drm_bridge_add(struct drm_bridge *bridge);
void drm_bridge_remove(struct drm_bridge *bridge); void drm_bridge_remove(struct drm_bridge *bridge);
struct drm_bridge *of_drm_find_bridge(struct device_node *np); struct drm_bridge *of_drm_find_bridge(struct device_node *np);
int drm_bridge_attach(struct drm_device *dev, struct drm_bridge *bridge); int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
struct drm_bridge *previous);
void drm_bridge_detach(struct drm_bridge *bridge); void drm_bridge_detach(struct drm_bridge *bridge);
bool drm_bridge_mode_fixup(struct drm_bridge *bridge, bool drm_bridge_mode_fixup(struct drm_bridge *bridge,
......
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