mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-01-23 19:49:45 +07:00
a25b988ff8
Most bridge drivers create a DRM connector to model the connector at the output of the bridge. This model is historical and has worked pretty well so far, but causes several issues: - It prevents supporting more complex display pipelines where DRM connector operations are split over multiple components. For instance a pipeline with a bridge connected to the DDC signals to read EDID data, and another one connected to the HPD signal to detect connection and disconnection, will not be possible to support through this model. - It requires every bridge driver to implement similar connector handling code, resulting in code duplication. - It assumes that a bridge will either be wired to a connector or to another bridge, but doesn't support bridges that can be used in both positions very well (although there is some ad-hoc support for this in the analogix_dp bridge driver). In order to solve these issues, ownership of the connector should be moved to the display controller driver (where it can be implemented using helpers provided by the core). Extend the bridge API to allow disabling connector creation in bridge drivers as a first step towards the new model. The new flags argument to the bridge .attach() operation allows instructing the bridge driver to skip creating a connector. Unconditionally set the new flags argument to 0 for now to keep the existing behaviour, and modify all existing bridge drivers to return an error when connector creation is not requested as they don't support this feature yet. The change is based on the following semantic patch, with manual review and edits. @ rule1 @ identifier funcs; identifier fn; @@ struct drm_bridge_funcs funcs = { ..., .attach = fn }; @ depends on rule1 @ identifier rule1.fn; identifier bridge; statement S, S1; @@ int fn( struct drm_bridge *bridge + , enum drm_bridge_attach_flags flags ) { ... when != S + if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) { + DRM_ERROR("Fix bridge driver to make connector optional!"); + return -EINVAL; + } + S1 ... } @ depends on rule1 @ identifier rule1.fn; identifier bridge, flags; expression E1, E2, E3; @@ int fn( struct drm_bridge *bridge, enum drm_bridge_attach_flags flags ) { <... drm_bridge_attach(E1, E2, E3 + , flags ) ...> } @@ expression E1, E2, E3; @@ drm_bridge_attach(E1, E2, E3 + , 0 ) Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Acked-by: Sam Ravnborg <sam@ravnborg.org> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Tested-by: Sebastian Reichel <sebastian.reichel@collabora.com> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200226112514.12455-10-laurent.pinchart@ideasonboard.com
203 lines
4.0 KiB
C
203 lines
4.0 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
|
|
*/
|
|
|
|
#include <linux/of_irq.h>
|
|
#include "edp.h"
|
|
|
|
static irqreturn_t edp_irq(int irq, void *dev_id)
|
|
{
|
|
struct msm_edp *edp = dev_id;
|
|
|
|
/* Process eDP irq */
|
|
return msm_edp_ctrl_irq(edp->ctrl);
|
|
}
|
|
|
|
static void edp_destroy(struct platform_device *pdev)
|
|
{
|
|
struct msm_edp *edp = platform_get_drvdata(pdev);
|
|
|
|
if (!edp)
|
|
return;
|
|
|
|
if (edp->ctrl) {
|
|
msm_edp_ctrl_destroy(edp->ctrl);
|
|
edp->ctrl = NULL;
|
|
}
|
|
|
|
platform_set_drvdata(pdev, NULL);
|
|
}
|
|
|
|
/* construct eDP at bind/probe time, grab all the resources. */
|
|
static struct msm_edp *edp_init(struct platform_device *pdev)
|
|
{
|
|
struct msm_edp *edp = NULL;
|
|
int ret;
|
|
|
|
if (!pdev) {
|
|
pr_err("no eDP device\n");
|
|
ret = -ENXIO;
|
|
goto fail;
|
|
}
|
|
|
|
edp = devm_kzalloc(&pdev->dev, sizeof(*edp), GFP_KERNEL);
|
|
if (!edp) {
|
|
ret = -ENOMEM;
|
|
goto fail;
|
|
}
|
|
DBG("eDP probed=%p", edp);
|
|
|
|
edp->pdev = pdev;
|
|
platform_set_drvdata(pdev, edp);
|
|
|
|
ret = msm_edp_ctrl_init(edp);
|
|
if (ret)
|
|
goto fail;
|
|
|
|
return edp;
|
|
|
|
fail:
|
|
if (edp)
|
|
edp_destroy(pdev);
|
|
|
|
return ERR_PTR(ret);
|
|
}
|
|
|
|
static int edp_bind(struct device *dev, struct device *master, void *data)
|
|
{
|
|
struct drm_device *drm = dev_get_drvdata(master);
|
|
struct msm_drm_private *priv = drm->dev_private;
|
|
struct msm_edp *edp;
|
|
|
|
DBG("");
|
|
edp = edp_init(to_platform_device(dev));
|
|
if (IS_ERR(edp))
|
|
return PTR_ERR(edp);
|
|
priv->edp = edp;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void edp_unbind(struct device *dev, struct device *master, void *data)
|
|
{
|
|
struct drm_device *drm = dev_get_drvdata(master);
|
|
struct msm_drm_private *priv = drm->dev_private;
|
|
|
|
DBG("");
|
|
if (priv->edp) {
|
|
edp_destroy(to_platform_device(dev));
|
|
priv->edp = NULL;
|
|
}
|
|
}
|
|
|
|
static const struct component_ops edp_ops = {
|
|
.bind = edp_bind,
|
|
.unbind = edp_unbind,
|
|
};
|
|
|
|
static int edp_dev_probe(struct platform_device *pdev)
|
|
{
|
|
DBG("");
|
|
return component_add(&pdev->dev, &edp_ops);
|
|
}
|
|
|
|
static int edp_dev_remove(struct platform_device *pdev)
|
|
{
|
|
DBG("");
|
|
component_del(&pdev->dev, &edp_ops);
|
|
return 0;
|
|
}
|
|
|
|
static const struct of_device_id dt_match[] = {
|
|
{ .compatible = "qcom,mdss-edp" },
|
|
{}
|
|
};
|
|
|
|
static struct platform_driver edp_driver = {
|
|
.probe = edp_dev_probe,
|
|
.remove = edp_dev_remove,
|
|
.driver = {
|
|
.name = "msm_edp",
|
|
.of_match_table = dt_match,
|
|
},
|
|
};
|
|
|
|
void __init msm_edp_register(void)
|
|
{
|
|
DBG("");
|
|
platform_driver_register(&edp_driver);
|
|
}
|
|
|
|
void __exit msm_edp_unregister(void)
|
|
{
|
|
DBG("");
|
|
platform_driver_unregister(&edp_driver);
|
|
}
|
|
|
|
/* Second part of initialization, the drm/kms level modeset_init */
|
|
int msm_edp_modeset_init(struct msm_edp *edp, struct drm_device *dev,
|
|
struct drm_encoder *encoder)
|
|
{
|
|
struct platform_device *pdev = edp->pdev;
|
|
struct msm_drm_private *priv = dev->dev_private;
|
|
int ret;
|
|
|
|
edp->encoder = encoder;
|
|
edp->dev = dev;
|
|
|
|
edp->bridge = msm_edp_bridge_init(edp);
|
|
if (IS_ERR(edp->bridge)) {
|
|
ret = PTR_ERR(edp->bridge);
|
|
DRM_DEV_ERROR(dev->dev, "failed to create eDP bridge: %d\n", ret);
|
|
edp->bridge = NULL;
|
|
goto fail;
|
|
}
|
|
|
|
edp->connector = msm_edp_connector_init(edp);
|
|
if (IS_ERR(edp->connector)) {
|
|
ret = PTR_ERR(edp->connector);
|
|
DRM_DEV_ERROR(dev->dev, "failed to create eDP connector: %d\n", ret);
|
|
edp->connector = NULL;
|
|
goto fail;
|
|
}
|
|
|
|
edp->irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
|
|
if (edp->irq < 0) {
|
|
ret = edp->irq;
|
|
DRM_DEV_ERROR(dev->dev, "failed to get IRQ: %d\n", ret);
|
|
goto fail;
|
|
}
|
|
|
|
ret = devm_request_irq(&pdev->dev, edp->irq,
|
|
edp_irq, IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
|
|
"edp_isr", edp);
|
|
if (ret < 0) {
|
|
DRM_DEV_ERROR(dev->dev, "failed to request IRQ%u: %d\n",
|
|
edp->irq, ret);
|
|
goto fail;
|
|
}
|
|
|
|
ret = drm_bridge_attach(encoder, edp->bridge, NULL, 0);
|
|
if (ret)
|
|
goto fail;
|
|
|
|
priv->bridges[priv->num_bridges++] = edp->bridge;
|
|
priv->connectors[priv->num_connectors++] = edp->connector;
|
|
|
|
return 0;
|
|
|
|
fail:
|
|
/* bridge/connector are normally destroyed by drm */
|
|
if (edp->bridge) {
|
|
edp_bridge_destroy(edp->bridge);
|
|
edp->bridge = NULL;
|
|
}
|
|
if (edp->connector) {
|
|
edp->connector->funcs->destroy(edp->connector);
|
|
edp->connector = NULL;
|
|
}
|
|
|
|
return ret;
|
|
}
|