2019-05-27 06:55:21 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2016-02-19 12:30:26 +00:00
|
|
|
/*
|
|
|
|
* ARC PGU DRM driver.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
|
|
|
|
*/
|
|
|
|
|
2019-08-26 15:26:29 +00:00
|
|
|
#include <drm/drm_bridge.h>
|
2016-10-19 07:46:18 +00:00
|
|
|
#include <drm/drm_crtc.h>
|
2018-01-17 14:17:55 +00:00
|
|
|
#include <drm/drm_encoder.h>
|
|
|
|
#include <drm/drm_device.h>
|
2016-02-19 12:30:26 +00:00
|
|
|
|
|
|
|
#include "arcpgu.h"
|
|
|
|
|
|
|
|
static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
|
|
|
|
.destroy = drm_encoder_cleanup,
|
|
|
|
};
|
|
|
|
|
|
|
|
int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
|
|
|
|
{
|
2016-10-19 07:46:18 +00:00
|
|
|
struct drm_encoder *encoder;
|
|
|
|
struct drm_bridge *bridge;
|
|
|
|
|
|
|
|
int ret = 0;
|
2016-02-19 12:30:26 +00:00
|
|
|
|
|
|
|
encoder = devm_kzalloc(drm->dev, sizeof(*encoder), GFP_KERNEL);
|
|
|
|
if (encoder == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2016-10-19 07:46:18 +00:00
|
|
|
/* Locate drm bridge from the hdmi encoder DT node */
|
|
|
|
bridge = of_drm_find_bridge(np);
|
|
|
|
if (!bridge)
|
2016-02-19 12:30:26 +00:00
|
|
|
return -EPROBE_DEFER;
|
|
|
|
|
2016-10-19 07:46:18 +00:00
|
|
|
encoder->possible_crtcs = 1;
|
|
|
|
encoder->possible_clones = 0;
|
|
|
|
ret = drm_encoder_init(drm, encoder, &arcpgu_drm_encoder_funcs,
|
2016-02-19 12:30:26 +00:00
|
|
|
DRM_MODE_ENCODER_TMDS, NULL);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2016-10-19 07:46:18 +00:00
|
|
|
/* Link drm_bridge to encoder */
|
drm/bridge: Extend bridge API to disable connector creation
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
2020-02-26 11:24:29 +00:00
|
|
|
ret = drm_bridge_attach(encoder, bridge, NULL, 0);
|
2016-10-19 07:46:18 +00:00
|
|
|
if (ret)
|
|
|
|
drm_encoder_cleanup(encoder);
|
2016-02-19 12:30:26 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|