Re: [PATCH v4 05/51] drm/bridge: Extend bridge API to disable connector creation

2020-01-08 Thread Tomi Valkeinen

On 19/12/2019 12:44, Laurent Pinchart wrote:

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 
Reviewed-by: Boris Brezillon 
Acked-by: Sam Ravnborg 


Reviewed-by: Tomi Valkeinen 

 Tomi

--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v4 05/51] drm/bridge: Extend bridge API to disable connector creation

2019-12-19 Thread Laurent Pinchart
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 
Reviewed-by: Boris Brezillon 
Acked-by: Sam Ravnborg 
---
Changes since v3:

- Print error message when DRM_BRIDGE_ATTACH_NO_CONNECTOR can't be
  honoured
- Fix semantic patch to correctly handle drm_bridge_attach() calls from
  within a bridge .attach() handler
- Include drm_print.h in tc358767.c and rcar_lvds.c

Changes since v2:

- Update commit message to the new flags argument
- Replace a leftover 'true' with 0
- Update msm edp and hdmi

Changes since v1:

- Replace the create_connector boolean with a flags bitmask
- Update ingenic driver
- Add semantic patch to commit message
---
 drivers/gpu/drm/arc/arcpgu_hdmi.c |  2 +-
 .../gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c  |  2 +-
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c  |  8 +++-
 .../drm/bridge/analogix/analogix-anx6345.c|  8 +++-
 .../drm/bridge/analogix/analogix-anx78xx.c|  8 +++-
 .../drm/bridge/analogix/analogix_dp_core.c| 10 --
 drivers/gpu/drm/bridge/cdns-dsi.c |  6 --
 drivers/gpu/drm/bridge/dumb-vga-dac.c |  8 +++-
 drivers/gpu/drm/bridge/lvds-encoder.c |  5 +++--
 .../bridge/megachips-stdp-ge-b850v3-fw.c  |  8 +++-
 drivers/gpu/drm/bridge/nxp-ptn3460.c  |  8 +++-
 drivers/gpu/drm/bridge/panel.c|  8 +++-
 drivers/gpu/drm/bridge/parade-ps8622.c|  8 +++-
 drivers/gpu/drm/bridge/sii902x.c  |  8 +++-
 drivers/gpu/drm/bridge/sil-sii8620.c  |  3 ++-
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 10 --
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c |  8 +---
 drivers/gpu/drm/bridge/tc358764.c |  8 +++-
 drivers/gpu/drm/bridge/tc358767.c |  9 -
 drivers/gpu/drm/bridge/thc63lvd1024.c |  5 +++--
 drivers/gpu/drm/bridge/ti-sn65dsi86.c |  8 +++-
 drivers/gpu/drm/bridge/ti-tfp410.c|  8 +++-
 drivers/gpu/drm/drm_bridge.c  |  6 --
 drivers/gpu/drm/drm_simple_kms_helper.c   |  2 +-
 drivers/gpu/drm/exynos/exynos_dp.c|  3 ++-
 drivers/gpu/drm/exynos/exynos_drm_dsi.c   |  4 ++--
 drivers/gpu/drm/exynos/exynos_hdmi.c  |  2 +-
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c |  2 +-
 drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c  |  2 +-
 drivers/gpu/drm/i2c/tda998x_drv.c | 10 --
 drivers/gpu/drm/imx/imx-ldb.c |  2 +-
 drivers/gpu/drm/imx/parallel-display.c|  2 +-
 drivers/gpu/drm/ingenic/ingeni