diff mbox series

[v2,15/50] drm/bridge: tfp410: Replace manual connector handling with bridge

Message ID 20190820011721.30136-16-laurent.pinchart@ideasonboard.com (mailing list archive)
State New, archived
Headers show
Series drm/omap: Replace custom display drivers with drm_bridge and drm_panel | expand

Commit Message

Laurent Pinchart Aug. 20, 2019, 1:16 a.m. UTC
Now that a driver is available for display connectors, replace the
manual connector handling code with usage of the DRM bridge API. The
tfp410 driver doesn't deal with the display connector directly anymore,
but still delegates drm_connector operations to the next bridge. This
brings us one step closer to having the tfp410 driver handling the
TFP410 only.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/bridge/ti-tfp410.c | 195 ++++++++++-------------------
 1 file changed, 68 insertions(+), 127 deletions(-)

Comments

Boris Brezillon Aug. 22, 2019, 4:36 p.m. UTC | #1
On Tue, 20 Aug 2019 04:16:46 +0300
Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote:

> Now that a driver is available for display connectors, replace the
> manual connector handling code with usage of the DRM bridge API. The
> tfp410 driver doesn't deal with the display connector directly anymore,
> but still delegates drm_connector operations to the next bridge. This
> brings us one step closer to having the tfp410 driver handling the
> TFP410 only.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/gpu/drm/bridge/ti-tfp410.c | 195 ++++++++++-------------------
>  1 file changed, 68 insertions(+), 127 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/ti-tfp410.c b/drivers/gpu/drm/bridge/ti-tfp410.c
> index 4a468f44ef69..65651ae6c553 100644
> --- a/drivers/gpu/drm/bridge/ti-tfp410.c
> +++ b/drivers/gpu/drm/bridge/ti-tfp410.c
> @@ -4,14 +4,12 @@
>   * Author: Jyri Sarha <jsarha@ti.com>
>   */
>  
> -#include <linux/delay.h>
> -#include <linux/fwnode.h>
>  #include <linux/gpio/consumer.h>
>  #include <linux/i2c.h>
> -#include <linux/irq.h>
>  #include <linux/module.h>
>  #include <linux/of_graph.h>
>  #include <linux/platform_device.h>
> +#include <linux/workqueue.h>
>  
>  #include <drm/drm_atomic_helper.h>
>  #include <drm/drm_bridge.h>
> @@ -24,16 +22,13 @@
>  struct tfp410 {
>  	struct drm_bridge	bridge;
>  	struct drm_connector	connector;
> -	unsigned int		connector_type;
>  
>  	u32			bus_format;
> -	struct i2c_adapter	*ddc;
> -	struct gpio_desc	*hpd;
> -	int			hpd_irq;
>  	struct delayed_work	hpd_work;
>  	struct gpio_desc	*powerdown;
>  
>  	struct drm_bridge_timings timings;
> +	struct drm_bridge	*next_bridge;
>  
>  	struct device *dev;
>  };
> @@ -56,10 +51,10 @@ static int tfp410_get_modes(struct drm_connector *connector)
>  	struct edid *edid;
>  	int ret;
>  
> -	if (!dvi->ddc)
> +	if (!(dvi->next_bridge->ops & DRM_BRIDGE_OP_EDID))
>  		goto fallback;
>  
> -	edid = drm_get_edid(connector, dvi->ddc);
> +	edid = dvi->next_bridge->funcs->get_edid(dvi->next_bridge, connector);

Can we create a drm_bridge_get_edid() wrapper for that?
Something like:

int drm_bridge_get_edid(struct drm_bridge *bridge,
			struct drm_connector *conn)
{
	if (!(dvi->next_bridge->ops & DRM_BRIDGE_OP_EDID))
		return -ENOTSUPP;

	return bridge->funcs->get_edid(bridge, connector);
}

>  	if (!edid) {
>  		dev_info(dvi->dev,
>  			 "EDID read failed. Fallback to standard modes\n");
> @@ -93,21 +88,10 @@ tfp410_connector_detect(struct drm_connector *connector, bool force)
>  {
>  	struct tfp410 *dvi = drm_connector_to_tfp410(connector);
>  
> -	if (dvi->hpd) {
> -		if (gpiod_get_value_cansleep(dvi->hpd))
> -			return connector_status_connected;
> -		else
> -			return connector_status_disconnected;
> -	}
> +	if (!(dvi->next_bridge->ops & DRM_BRIDGE_OP_DETECT))
> +		return connector_status_unknown;
>  
> -	if (dvi->ddc) {
> -		if (drm_probe_ddc(dvi->ddc))
> -			return connector_status_connected;
> -		else
> -			return connector_status_disconnected;
> -	}
> -
> -	return connector_status_unknown;
> +	return dvi->next_bridge->funcs->detect(dvi->next_bridge);

Same here for the detect hook.
Laurent Pinchart Aug. 22, 2019, 4:54 p.m. UTC | #2
Hi Boris,

On Thu, Aug 22, 2019 at 06:36:45PM +0200, Boris Brezillon wrote:
> On Tue, 20 Aug 2019 04:16:46 +0300 Laurent Pinchart wrote:
> 
> > Now that a driver is available for display connectors, replace the
> > manual connector handling code with usage of the DRM bridge API. The
> > tfp410 driver doesn't deal with the display connector directly anymore,
> > but still delegates drm_connector operations to the next bridge. This
> > brings us one step closer to having the tfp410 driver handling the
> > TFP410 only.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  drivers/gpu/drm/bridge/ti-tfp410.c | 195 ++++++++++-------------------
> >  1 file changed, 68 insertions(+), 127 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/bridge/ti-tfp410.c b/drivers/gpu/drm/bridge/ti-tfp410.c
> > index 4a468f44ef69..65651ae6c553 100644
> > --- a/drivers/gpu/drm/bridge/ti-tfp410.c
> > +++ b/drivers/gpu/drm/bridge/ti-tfp410.c
> > @@ -4,14 +4,12 @@
> >   * Author: Jyri Sarha <jsarha@ti.com>
> >   */
> >  
> > -#include <linux/delay.h>
> > -#include <linux/fwnode.h>
> >  #include <linux/gpio/consumer.h>
> >  #include <linux/i2c.h>
> > -#include <linux/irq.h>
> >  #include <linux/module.h>
> >  #include <linux/of_graph.h>
> >  #include <linux/platform_device.h>
> > +#include <linux/workqueue.h>
> >  
> >  #include <drm/drm_atomic_helper.h>
> >  #include <drm/drm_bridge.h>
> > @@ -24,16 +22,13 @@
> >  struct tfp410 {
> >  	struct drm_bridge	bridge;
> >  	struct drm_connector	connector;
> > -	unsigned int		connector_type;
> >  
> >  	u32			bus_format;
> > -	struct i2c_adapter	*ddc;
> > -	struct gpio_desc	*hpd;
> > -	int			hpd_irq;
> >  	struct delayed_work	hpd_work;
> >  	struct gpio_desc	*powerdown;
> >  
> >  	struct drm_bridge_timings timings;
> > +	struct drm_bridge	*next_bridge;
> >  
> >  	struct device *dev;
> >  };
> > @@ -56,10 +51,10 @@ static int tfp410_get_modes(struct drm_connector *connector)
> >  	struct edid *edid;
> >  	int ret;
> >  
> > -	if (!dvi->ddc)
> > +	if (!(dvi->next_bridge->ops & DRM_BRIDGE_OP_EDID))
> >  		goto fallback;
> >  
> > -	edid = drm_get_edid(connector, dvi->ddc);
> > +	edid = dvi->next_bridge->funcs->get_edid(dvi->next_bridge, connector);
> 
> Can we create a drm_bridge_get_edid() wrapper for that?
> Something like:
> 
> int drm_bridge_get_edid(struct drm_bridge *bridge,
> 			struct drm_connector *conn)
> {
> 	if (!(dvi->next_bridge->ops & DRM_BRIDGE_OP_EDID))
> 		return -ENOTSUPP;

I assume you mean ERR_PTR(-ENOTSUPP) with the return type changed to
struct drm_edid *.

> 
> 	return bridge->funcs->get_edid(bridge, connector);
> }

I've thought about it, but I'm not sure it's worth it. These operations
are not meant to be called manually by bridges like in here. This is an
interim solution until support for drm_connector can be dropped from the
tfp410 driver, once its users will be converted. Do you think I should
still create a wrapper (which I would make static inline then) ?

> >  	if (!edid) {
> >  		dev_info(dvi->dev,
> >  			 "EDID read failed. Fallback to standard modes\n");
> > @@ -93,21 +88,10 @@ tfp410_connector_detect(struct drm_connector *connector, bool force)
> >  {
> >  	struct tfp410 *dvi = drm_connector_to_tfp410(connector);
> >  
> > -	if (dvi->hpd) {
> > -		if (gpiod_get_value_cansleep(dvi->hpd))
> > -			return connector_status_connected;
> > -		else
> > -			return connector_status_disconnected;
> > -	}
> > +	if (!(dvi->next_bridge->ops & DRM_BRIDGE_OP_DETECT))
> > +		return connector_status_unknown;
> >  
> > -	if (dvi->ddc) {
> > -		if (drm_probe_ddc(dvi->ddc))
> > -			return connector_status_connected;
> > -		else
> > -			return connector_status_disconnected;
> > -	}
> > -
> > -	return connector_status_unknown;
> > +	return dvi->next_bridge->funcs->detect(dvi->next_bridge);
> 
> Same here for the detect hook.
>
Boris Brezillon Aug. 22, 2019, 5:15 p.m. UTC | #3
On Thu, 22 Aug 2019 19:54:56 +0300
Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote:

> Hi Boris,
> 
> On Thu, Aug 22, 2019 at 06:36:45PM +0200, Boris Brezillon wrote:
> > On Tue, 20 Aug 2019 04:16:46 +0300 Laurent Pinchart wrote:
> >   
> > > Now that a driver is available for display connectors, replace the
> > > manual connector handling code with usage of the DRM bridge API. The
> > > tfp410 driver doesn't deal with the display connector directly anymore,
> > > but still delegates drm_connector operations to the next bridge. This
> > > brings us one step closer to having the tfp410 driver handling the
> > > TFP410 only.
> > > 
> > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > ---
> > >  drivers/gpu/drm/bridge/ti-tfp410.c | 195 ++++++++++-------------------
> > >  1 file changed, 68 insertions(+), 127 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/bridge/ti-tfp410.c b/drivers/gpu/drm/bridge/ti-tfp410.c
> > > index 4a468f44ef69..65651ae6c553 100644
> > > --- a/drivers/gpu/drm/bridge/ti-tfp410.c
> > > +++ b/drivers/gpu/drm/bridge/ti-tfp410.c
> > > @@ -4,14 +4,12 @@
> > >   * Author: Jyri Sarha <jsarha@ti.com>
> > >   */
> > >  
> > > -#include <linux/delay.h>
> > > -#include <linux/fwnode.h>
> > >  #include <linux/gpio/consumer.h>
> > >  #include <linux/i2c.h>
> > > -#include <linux/irq.h>
> > >  #include <linux/module.h>
> > >  #include <linux/of_graph.h>
> > >  #include <linux/platform_device.h>
> > > +#include <linux/workqueue.h>
> > >  
> > >  #include <drm/drm_atomic_helper.h>
> > >  #include <drm/drm_bridge.h>
> > > @@ -24,16 +22,13 @@
> > >  struct tfp410 {
> > >  	struct drm_bridge	bridge;
> > >  	struct drm_connector	connector;
> > > -	unsigned int		connector_type;
> > >  
> > >  	u32			bus_format;
> > > -	struct i2c_adapter	*ddc;
> > > -	struct gpio_desc	*hpd;
> > > -	int			hpd_irq;
> > >  	struct delayed_work	hpd_work;
> > >  	struct gpio_desc	*powerdown;
> > >  
> > >  	struct drm_bridge_timings timings;
> > > +	struct drm_bridge	*next_bridge;
> > >  
> > >  	struct device *dev;
> > >  };
> > > @@ -56,10 +51,10 @@ static int tfp410_get_modes(struct drm_connector *connector)
> > >  	struct edid *edid;
> > >  	int ret;
> > >  
> > > -	if (!dvi->ddc)
> > > +	if (!(dvi->next_bridge->ops & DRM_BRIDGE_OP_EDID))
> > >  		goto fallback;
> > >  
> > > -	edid = drm_get_edid(connector, dvi->ddc);
> > > +	edid = dvi->next_bridge->funcs->get_edid(dvi->next_bridge, connector);  
> > 
> > Can we create a drm_bridge_get_edid() wrapper for that?
> > Something like:
> > 
> > int drm_bridge_get_edid(struct drm_bridge *bridge,
> > 			struct drm_connector *conn)
> > {
> > 	if (!(dvi->next_bridge->ops & DRM_BRIDGE_OP_EDID))
> > 		return -ENOTSUPP;  
> 
> I assume you mean ERR_PTR(-ENOTSUPP) with the return type changed to
> struct drm_edid *.
> 
> > 
> > 	return bridge->funcs->get_edid(bridge, connector);
> > }  
> 
> I've thought about it, but I'm not sure it's worth it. These operations
> are not meant to be called manually by bridges like in here. This is an
> interim solution until support for drm_connector can be dropped from the
> tfp410 driver, once its users will be converted. Do you think I should
> still create a wrapper (which I would make static inline then) ?

Well, this conversion is likely to take time, not to mention that other
drivers will go through the same process. And every time a bridge
driver is converted, it requires patching all display controller drivers
that are known to be connected to it before you can get rid of this
temporary solution. So yes, I still think it's worth adding those
helpers, maybe with a comment explaining that they should only be used
during the conversion phase (IOW, until the driver starts rejecting
the !DRM_BRIDGE_ATTACH_NO_CONNECTOR case).
Tomi Valkeinen Aug. 27, 2019, 7:43 a.m. UTC | #4
On 20/08/2019 04:16, Laurent Pinchart wrote:
> Now that a driver is available for display connectors, replace the
> manual connector handling code with usage of the DRM bridge API. The
> tfp410 driver doesn't deal with the display connector directly anymore,
> but still delegates drm_connector operations to the next bridge. This
> brings us one step closer to having the tfp410 driver handling the
> TFP410 only.

The next step will drop those hpd related delayed works? They look 
pretty ugly =).

> +	dvi->bridge.type = DRM_MODE_CONNECTOR_DVID;

This is not the connector type seen by userspace, is it? I have never 
seen a board use TFP410 with a DVI connector...

  Tomi
Laurent Pinchart Aug. 27, 2019, 8 a.m. UTC | #5
Hi Tomi,

On Tue, Aug 27, 2019 at 10:43:15AM +0300, Tomi Valkeinen wrote:
> On 20/08/2019 04:16, Laurent Pinchart wrote:
> > Now that a driver is available for display connectors, replace the
> > manual connector handling code with usage of the DRM bridge API. The
> > tfp410 driver doesn't deal with the display connector directly anymore,
> > but still delegates drm_connector operations to the next bridge. This
> > brings us one step closer to having the tfp410 driver handling the
> > TFP410 only.
> 
> The next step will drop those hpd related delayed works? They look 
> pretty ugly =).

Yesn all the connector-related code will disappear once users of the
TFP410 will switch to the new model.

> > +	dvi->bridge.type = DRM_MODE_CONNECTOR_DVID;
> 
> This is not the connector type seen by userspace, is it? I have never 
> seen a board use TFP410 with a DVI connector...

The connector type reported to userspace comes from the HDMI connector
DT node, so dvi->bridge.type isn't very relevant there. I've set it to
DVID to match the hardware.
diff mbox series

Patch

diff --git a/drivers/gpu/drm/bridge/ti-tfp410.c b/drivers/gpu/drm/bridge/ti-tfp410.c
index 4a468f44ef69..65651ae6c553 100644
--- a/drivers/gpu/drm/bridge/ti-tfp410.c
+++ b/drivers/gpu/drm/bridge/ti-tfp410.c
@@ -4,14 +4,12 @@ 
  * Author: Jyri Sarha <jsarha@ti.com>
  */
 
-#include <linux/delay.h>
-#include <linux/fwnode.h>
 #include <linux/gpio/consumer.h>
 #include <linux/i2c.h>
-#include <linux/irq.h>
 #include <linux/module.h>
 #include <linux/of_graph.h>
 #include <linux/platform_device.h>
+#include <linux/workqueue.h>
 
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_bridge.h>
@@ -24,16 +22,13 @@ 
 struct tfp410 {
 	struct drm_bridge	bridge;
 	struct drm_connector	connector;
-	unsigned int		connector_type;
 
 	u32			bus_format;
-	struct i2c_adapter	*ddc;
-	struct gpio_desc	*hpd;
-	int			hpd_irq;
 	struct delayed_work	hpd_work;
 	struct gpio_desc	*powerdown;
 
 	struct drm_bridge_timings timings;
+	struct drm_bridge	*next_bridge;
 
 	struct device *dev;
 };
@@ -56,10 +51,10 @@  static int tfp410_get_modes(struct drm_connector *connector)
 	struct edid *edid;
 	int ret;
 
-	if (!dvi->ddc)
+	if (!(dvi->next_bridge->ops & DRM_BRIDGE_OP_EDID))
 		goto fallback;
 
-	edid = drm_get_edid(connector, dvi->ddc);
+	edid = dvi->next_bridge->funcs->get_edid(dvi->next_bridge, connector);
 	if (!edid) {
 		dev_info(dvi->dev,
 			 "EDID read failed. Fallback to standard modes\n");
@@ -93,21 +88,10 @@  tfp410_connector_detect(struct drm_connector *connector, bool force)
 {
 	struct tfp410 *dvi = drm_connector_to_tfp410(connector);
 
-	if (dvi->hpd) {
-		if (gpiod_get_value_cansleep(dvi->hpd))
-			return connector_status_connected;
-		else
-			return connector_status_disconnected;
-	}
+	if (!(dvi->next_bridge->ops & DRM_BRIDGE_OP_DETECT))
+		return connector_status_unknown;
 
-	if (dvi->ddc) {
-		if (drm_probe_ddc(dvi->ddc))
-			return connector_status_connected;
-		else
-			return connector_status_disconnected;
-	}
-
-	return connector_status_unknown;
+	return dvi->next_bridge->funcs->detect(dvi->next_bridge);
 }
 
 static const struct drm_connector_funcs tfp410_con_funcs = {
@@ -119,12 +103,35 @@  static const struct drm_connector_funcs tfp410_con_funcs = {
 	.atomic_destroy_state	= drm_atomic_helper_connector_destroy_state,
 };
 
+static void tfp410_hpd_work_func(struct work_struct *work)
+{
+	struct tfp410 *dvi;
+
+	dvi = container_of(work, struct tfp410, hpd_work.work);
+
+	if (dvi->bridge.dev)
+		drm_helper_hpd_irq_event(dvi->bridge.dev);
+}
+
+static void tfp410_hpd_callback(void *arg, enum drm_connector_status status)
+{
+	struct tfp410 *dvi = arg;
+
+	mod_delayed_work(system_wq, &dvi->hpd_work,
+			 msecs_to_jiffies(HOTPLUG_DEBOUNCE_MS));
+}
+
 static int tfp410_attach(struct drm_bridge *bridge,
 			 enum drm_bridge_attach_flags flags)
 {
 	struct tfp410 *dvi = drm_bridge_to_tfp410(bridge);
 	int ret;
 
+	ret = drm_bridge_attach(bridge->encoder, dvi->next_bridge, bridge,
+				DRM_BRIDGE_ATTACH_NO_CONNECTOR);
+	if (ret < 0)
+		return ret;
+
 	if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
 		return -EINVAL;
 
@@ -133,17 +140,23 @@  static int tfp410_attach(struct drm_bridge *bridge,
 		return -ENODEV;
 	}
 
-	if (dvi->hpd_irq >= 0)
+	if (dvi->next_bridge->ops & DRM_BRIDGE_OP_DETECT)
 		dvi->connector.polled = DRM_CONNECTOR_POLL_HPD;
 	else
 		dvi->connector.polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT;
 
+	if (dvi->next_bridge->ops & DRM_BRIDGE_OP_HPD) {
+		INIT_DELAYED_WORK(&dvi->hpd_work, tfp410_hpd_work_func);
+		drm_bridge_hpd_enable(dvi->next_bridge, tfp410_hpd_callback,
+				      dvi);
+	}
+
 	drm_connector_helper_add(&dvi->connector,
 				 &tfp410_con_helper_funcs);
 	ret = drm_connector_init_with_ddc(bridge->dev, &dvi->connector,
 					  &tfp410_con_funcs,
-					  dvi->connector_type,
-					  dvi->ddc);
+					  dvi->next_bridge->type,
+					  dvi->next_bridge->ddc);
 	if (ret) {
 		dev_err(dvi->dev, "drm_connector_init() failed: %d\n", ret);
 		return ret;
@@ -152,12 +165,21 @@  static int tfp410_attach(struct drm_bridge *bridge,
 	drm_display_info_set_bus_formats(&dvi->connector.display_info,
 					 &dvi->bus_format, 1);
 
-	drm_connector_attach_encoder(&dvi->connector,
-					  bridge->encoder);
+	drm_connector_attach_encoder(&dvi->connector, bridge->encoder);
 
 	return 0;
 }
 
+static void tfp410_detach(struct drm_bridge *bridge)
+{
+	struct tfp410 *dvi = drm_bridge_to_tfp410(bridge);
+
+	if (dvi->connector.dev && dvi->next_bridge->ops & DRM_BRIDGE_OP_HPD) {
+		drm_bridge_hpd_disable(dvi->next_bridge);
+		cancel_delayed_work_sync(&dvi->hpd_work);
+	}
+}
+
 static void tfp410_enable(struct drm_bridge *bridge)
 {
 	struct tfp410 *dvi = drm_bridge_to_tfp410(bridge);
@@ -174,30 +196,11 @@  static void tfp410_disable(struct drm_bridge *bridge)
 
 static const struct drm_bridge_funcs tfp410_bridge_funcs = {
 	.attach		= tfp410_attach,
+	.detach		= tfp410_detach,
 	.enable		= tfp410_enable,
 	.disable	= tfp410_disable,
 };
 
-static void tfp410_hpd_work_func(struct work_struct *work)
-{
-	struct tfp410 *dvi;
-
-	dvi = container_of(work, struct tfp410, hpd_work.work);
-
-	if (dvi->bridge.dev)
-		drm_helper_hpd_irq_event(dvi->bridge.dev);
-}
-
-static irqreturn_t tfp410_hpd_irq_thread(int irq, void *arg)
-{
-	struct tfp410 *dvi = arg;
-
-	mod_delayed_work(system_wq, &dvi->hpd_work,
-			msecs_to_jiffies(HOTPLUG_DEBOUNCE_MS));
-
-	return IRQ_HANDLED;
-}
-
 static const struct drm_bridge_timings tfp410_default_timings = {
 	.input_bus_flags = DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE
 			 | DRM_BUS_FLAG_DE_HIGH,
@@ -275,51 +278,9 @@  static int tfp410_parse_timings(struct tfp410 *dvi, bool i2c)
 	return 0;
 }
 
-static int tfp410_get_connector_properties(struct tfp410 *dvi)
-{
-	struct device_node *connector_node, *ddc_phandle;
-	int ret = 0;
-
-	/* port@1 is the connector node */
-	connector_node = of_graph_get_remote_node(dvi->dev->of_node, 1, -1);
-	if (!connector_node)
-		return -ENODEV;
-
-	if (of_device_is_compatible(connector_node, "hdmi-connector"))
-		dvi->connector_type = DRM_MODE_CONNECTOR_HDMIA;
-	else
-		dvi->connector_type = DRM_MODE_CONNECTOR_DVID;
-
-	dvi->hpd = fwnode_get_named_gpiod(&connector_node->fwnode,
-					"hpd-gpios", 0, GPIOD_IN, "hpd");
-	if (IS_ERR(dvi->hpd)) {
-		ret = PTR_ERR(dvi->hpd);
-		dvi->hpd = NULL;
-		if (ret == -ENOENT)
-			ret = 0;
-		else
-			goto fail;
-	}
-
-	ddc_phandle = of_parse_phandle(connector_node, "ddc-i2c-bus", 0);
-	if (!ddc_phandle)
-		goto fail;
-
-	dvi->ddc = of_get_i2c_adapter_by_node(ddc_phandle);
-	if (dvi->ddc)
-		dev_info(dvi->dev, "Connector's ddc i2c bus found\n");
-	else
-		ret = -EPROBE_DEFER;
-
-	of_node_put(ddc_phandle);
-
-fail:
-	of_node_put(connector_node);
-	return ret;
-}
-
 static int tfp410_init(struct device *dev, bool i2c)
 {
+	struct device_node *node;
 	struct tfp410 *dvi;
 	int ret;
 
@@ -331,21 +292,31 @@  static int tfp410_init(struct device *dev, bool i2c)
 	dvi = devm_kzalloc(dev, sizeof(*dvi), GFP_KERNEL);
 	if (!dvi)
 		return -ENOMEM;
+
+	dvi->dev = dev;
 	dev_set_drvdata(dev, dvi);
 
 	dvi->bridge.funcs = &tfp410_bridge_funcs;
 	dvi->bridge.of_node = dev->of_node;
 	dvi->bridge.timings = &dvi->timings;
-	dvi->dev = dev;
+	dvi->bridge.type = DRM_MODE_CONNECTOR_DVID;
 
 	ret = tfp410_parse_timings(dvi, i2c);
 	if (ret)
-		goto fail;
+		return ret;
 
-	ret = tfp410_get_connector_properties(dvi);
-	if (ret)
-		goto fail;
+	/* Get the next bridge, connected to port@1. */
+	node = of_graph_get_remote_node(dev->of_node, 1, -1);
+	if (!node)
+		return -ENODEV;
 
+	dvi->next_bridge = of_drm_find_bridge(node);
+	of_node_put(node);
+
+	if (!dvi->next_bridge)
+		return -EPROBE_DEFER;
+
+	/* Get the powerdown GPIO. */
 	dvi->powerdown = devm_gpiod_get_optional(dev, "powerdown",
 						 GPIOD_OUT_HIGH);
 	if (IS_ERR(dvi->powerdown)) {
@@ -353,48 +324,18 @@  static int tfp410_init(struct device *dev, bool i2c)
 		return PTR_ERR(dvi->powerdown);
 	}
 
-	if (dvi->hpd)
-		dvi->hpd_irq = gpiod_to_irq(dvi->hpd);
-	else
-		dvi->hpd_irq = -ENXIO;
-
-	if (dvi->hpd_irq >= 0) {
-		INIT_DELAYED_WORK(&dvi->hpd_work, tfp410_hpd_work_func);
-
-		ret = devm_request_threaded_irq(dev, dvi->hpd_irq,
-			NULL, tfp410_hpd_irq_thread, IRQF_TRIGGER_RISING |
-			IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
-			"hdmi-hpd", dvi);
-		if (ret) {
-			dev_err(dev, "failed to register hpd interrupt\n");
-			goto fail;
-		}
-	}
-
+	/*  Register the DRM bridge. */
 	drm_bridge_add(&dvi->bridge);
 
 	return 0;
-fail:
-	i2c_put_adapter(dvi->ddc);
-	if (dvi->hpd)
-		gpiod_put(dvi->hpd);
-	return ret;
 }
 
 static int tfp410_fini(struct device *dev)
 {
 	struct tfp410 *dvi = dev_get_drvdata(dev);
 
-	if (dvi->hpd_irq >= 0)
-		cancel_delayed_work_sync(&dvi->hpd_work);
-
 	drm_bridge_remove(&dvi->bridge);
 
-	if (dvi->ddc)
-		i2c_put_adapter(dvi->ddc);
-	if (dvi->hpd)
-		gpiod_put(dvi->hpd);
-
 	return 0;
 }