Skip to content

Commit a25b988

Browse files
pinchartltomba
authored andcommitted
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
1 parent 64d05ff commit a25b988

60 files changed

Lines changed: 231 additions & 79 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎drivers/gpu/drm/arc/arcpgu_hdmi.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
4040
return ret;
4141

4242
/* Link drm_bridge to encoder */
43-
ret = drm_bridge_attach(encoder, bridge, NULL);
43+
ret = drm_bridge_attach(encoder, bridge, NULL, 0);
4444
if (ret)
4545
drm_encoder_cleanup(encoder);
4646

‎drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint)
114114
}
115115

116116
if (bridge) {
117-
ret = drm_bridge_attach(&output->encoder, bridge, NULL);
117+
ret = drm_bridge_attach(&output->encoder, bridge, NULL, 0);
118118
if (!ret)
119119
return 0;
120120

‎drivers/gpu/drm/bridge/adv7511/adv7511_drv.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,11 +847,17 @@ static void adv7511_bridge_mode_set(struct drm_bridge *bridge,
847847
adv7511_mode_set(adv, mode, adj_mode);
848848
}
849849

850-
static int adv7511_bridge_attach(struct drm_bridge *bridge)
850+
static int adv7511_bridge_attach(struct drm_bridge *bridge,
851+
enum drm_bridge_attach_flags flags)
851852
{
852853
struct adv7511 *adv = bridge_to_adv7511(bridge);
853854
int ret;
854855

856+
if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
857+
DRM_ERROR("Fix bridge driver to make connector optional!");
858+
return -EINVAL;
859+
}
860+
855861
if (!bridge->encoder) {
856862
DRM_ERROR("Parent encoder object not found");
857863
return -ENODEV;

‎drivers/gpu/drm/bridge/analogix/analogix-anx6345.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,11 +520,17 @@ static const struct drm_connector_funcs anx6345_connector_funcs = {
520520
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
521521
};
522522

523-
static int anx6345_bridge_attach(struct drm_bridge *bridge)
523+
static int anx6345_bridge_attach(struct drm_bridge *bridge,
524+
enum drm_bridge_attach_flags flags)
524525
{
525526
struct anx6345 *anx6345 = bridge_to_anx6345(bridge);
526527
int err;
527528

529+
if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
530+
DRM_ERROR("Fix bridge driver to make connector optional!");
531+
return -EINVAL;
532+
}
533+
528534
if (!bridge->encoder) {
529535
DRM_ERROR("Parent encoder object not found");
530536
return -ENODEV;

‎drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,11 +886,17 @@ static const struct drm_connector_funcs anx78xx_connector_funcs = {
886886
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
887887
};
888888

889-
static int anx78xx_bridge_attach(struct drm_bridge *bridge)
889+
static int anx78xx_bridge_attach(struct drm_bridge *bridge,
890+
enum drm_bridge_attach_flags flags)
890891
{
891892
struct anx78xx *anx78xx = bridge_to_anx78xx(bridge);
892893
int err;
893894

895+
if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
896+
DRM_ERROR("Fix bridge driver to make connector optional!");
897+
return -EINVAL;
898+
}
899+
894900
if (!bridge->encoder) {
895901
DRM_ERROR("Parent encoder object not found");
896902
return -ENODEV;

‎drivers/gpu/drm/bridge/analogix/analogix_dp_core.c‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,13 +1216,19 @@ static const struct drm_connector_funcs analogix_dp_connector_funcs = {
12161216
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
12171217
};
12181218

1219-
static int analogix_dp_bridge_attach(struct drm_bridge *bridge)
1219+
static int analogix_dp_bridge_attach(struct drm_bridge *bridge,
1220+
enum drm_bridge_attach_flags flags)
12201221
{
12211222
struct analogix_dp_device *dp = bridge->driver_private;
12221223
struct drm_encoder *encoder = dp->encoder;
12231224
struct drm_connector *connector = NULL;
12241225
int ret = 0;
12251226

1227+
if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
1228+
DRM_ERROR("Fix bridge driver to make connector optional!");
1229+
return -EINVAL;
1230+
}
1231+
12261232
if (!bridge->encoder) {
12271233
DRM_ERROR("Parent encoder object not found");
12281234
return -ENODEV;
@@ -1598,7 +1604,7 @@ static int analogix_dp_create_bridge(struct drm_device *drm_dev,
15981604
bridge->driver_private = dp;
15991605
bridge->funcs = &analogix_dp_bridge_funcs;
16001606

1601-
ret = drm_bridge_attach(dp->encoder, bridge, NULL);
1607+
ret = drm_bridge_attach(dp->encoder, bridge, NULL, 0);
16021608
if (ret) {
16031609
DRM_ERROR("failed to attach drm bridge\n");
16041610
return -EINVAL;

‎drivers/gpu/drm/bridge/cdns-dsi.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,8 @@ static int cdns_dsi_check_conf(struct cdns_dsi *dsi,
644644
return 0;
645645
}
646646

647-
static int cdns_dsi_bridge_attach(struct drm_bridge *bridge)
647+
static int cdns_dsi_bridge_attach(struct drm_bridge *bridge,
648+
enum drm_bridge_attach_flags flags)
648649
{
649650
struct cdns_dsi_input *input = bridge_to_cdns_dsi_input(bridge);
650651
struct cdns_dsi *dsi = input_to_dsi(input);
@@ -656,7 +657,8 @@ static int cdns_dsi_bridge_attach(struct drm_bridge *bridge)
656657
return -ENOTSUPP;
657658
}
658659

659-
return drm_bridge_attach(bridge->encoder, output->bridge, bridge);
660+
return drm_bridge_attach(bridge->encoder, output->bridge, bridge,
661+
flags);
660662
}
661663

662664
static enum drm_mode_status

‎drivers/gpu/drm/bridge/dumb-vga-dac.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,17 @@ static const struct drm_connector_funcs dumb_vga_con_funcs = {
100100
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
101101
};
102102

103-
static int dumb_vga_attach(struct drm_bridge *bridge)
103+
static int dumb_vga_attach(struct drm_bridge *bridge,
104+
enum drm_bridge_attach_flags flags)
104105
{
105106
struct dumb_vga *vga = drm_bridge_to_dumb_vga(bridge);
106107
int ret;
107108

109+
if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
110+
DRM_ERROR("Fix bridge driver to make connector optional!");
111+
return -EINVAL;
112+
}
113+
108114
if (!bridge->encoder) {
109115
DRM_ERROR("Missing encoder\n");
110116
return -ENODEV;

‎drivers/gpu/drm/bridge/lvds-codec.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ static inline struct lvds_codec *to_lvds_codec(struct drm_bridge *bridge)
2626
return container_of(bridge, struct lvds_codec, bridge);
2727
}
2828

29-
static int lvds_codec_attach(struct drm_bridge *bridge)
29+
static int lvds_codec_attach(struct drm_bridge *bridge,
30+
enum drm_bridge_attach_flags flags)
3031
{
3132
struct lvds_codec *lvds_codec = to_lvds_codec(bridge);
3233

3334
return drm_bridge_attach(bridge->encoder, lvds_codec->panel_bridge,
34-
bridge);
35+
bridge, flags);
3536
}
3637

3738
static void lvds_codec_enable(struct drm_bridge *bridge)

‎drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,19 @@ static irqreturn_t ge_b850v3_lvds_irq_handler(int irq, void *dev_id)
206206
return IRQ_HANDLED;
207207
}
208208

209-
static int ge_b850v3_lvds_attach(struct drm_bridge *bridge)
209+
static int ge_b850v3_lvds_attach(struct drm_bridge *bridge,
210+
enum drm_bridge_attach_flags flags)
210211
{
211212
struct drm_connector *connector = &ge_b850v3_lvds_ptr->connector;
212213
struct i2c_client *stdp4028_i2c
213214
= ge_b850v3_lvds_ptr->stdp4028_i2c;
214215
int ret;
215216

217+
if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
218+
DRM_ERROR("Fix bridge driver to make connector optional!");
219+
return -EINVAL;
220+
}
221+
216222
if (!bridge->encoder) {
217223
DRM_ERROR("Parent encoder object not found");
218224
return -ENODEV;

0 commit comments

Comments
 (0)