From: Sebastian Reichel Subject: Re: [PATCH 19/48] drm: omapdrm: displays: Get encoder source at connect time Date: Sat, 14 Oct 2017 14:58:45 +0200 Message-ID: <20171014125845.3ayxgrjjtqpluxdr@earth> References: <20171013145944.26557-1-laurent.pinchart@ideasonboard.com> <20171013145944.26557-20-laurent.pinchart@ideasonboard.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1041660914==" Return-path: Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7C8E76E122 for ; Sat, 14 Oct 2017 12:58:49 +0000 (UTC) In-Reply-To: <20171013145944.26557-20-laurent.pinchart@ideasonboard.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Laurent Pinchart Cc: Tomi Valkeinen , dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org --===============1041660914== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="iskiyfspupxa4tol" Content-Disposition: inline --iskiyfspupxa4tol Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Fri, Oct 13, 2017 at 05:59:15PM +0300, Laurent Pinchart wrote: > The encoder drivers need a handle to the source they are connected to in > order to control the source. >=20 > All drivers get that handle at probe time, resulting in probe deferral > when the source hasn't been probed yet. However they don't need the > handle until their connect handler is called. >=20 > Move retrieval of the source handle to the connect handler to avoid > probe deferrals. >=20 > Signed-off-by: Laurent Pinchart > --- Reviewed-by: Sebastian Reichel -- Sebastian > drivers/gpu/drm/omapdrm/displays/encoder-opa362.c | 35 ++++++------ > drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c | 36 ++++++------ > .../gpu/drm/omapdrm/displays/encoder-tpd12s015.c | 66 ++++++++--------= ------ > 3 files changed, 54 insertions(+), 83 deletions(-) >=20 > diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c b/drivers/= gpu/drm/omapdrm/displays/encoder-opa362.c > index b28ec62267b1..b3bb64b477fa 100644 > --- a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c > +++ b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c > @@ -36,7 +36,7 @@ static int opa362_connect(struct omap_dss_device *dssde= v, > struct omap_dss_device *dst) > { > struct panel_drv_data *ddata =3D to_panel_data(dssdev); > - struct omap_dss_device *in =3D ddata->in; > + struct omap_dss_device *in; > int r; > =20 > dev_dbg(dssdev->dev, "connect\n"); > @@ -44,13 +44,22 @@ static int opa362_connect(struct omap_dss_device *dss= dev, > if (omapdss_device_is_connected(dssdev)) > return -EBUSY; > =20 > + in =3D omapdss_of_find_source_for_first_ep(dssdev->dev->of_node); > + if (IS_ERR(in)) { > + dev_err(dssdev->dev, "failed to find video source\n"); > + return PTR_ERR(in); > + } > + > r =3D in->ops.atv->connect(in, dssdev); > - if (r) > + if (r) { > + omap_dss_put_device(in); > return r; > + } > =20 > dst->src =3D dssdev; > dssdev->dst =3D dst; > =20 > + ddata->in =3D in; > return 0; > } > =20 > @@ -74,6 +83,9 @@ static void opa362_disconnect(struct omap_dss_device *d= ssdev, > dssdev->dst =3D NULL; > =20 > in->ops.atv->disconnect(in, &ddata->dssdev); > + > + omap_dss_put_device(in); > + ddata->in =3D NULL; > } > =20 > static int opa362_enable(struct omap_dss_device *dssdev) > @@ -171,9 +183,8 @@ static const struct omapdss_atv_ops opa362_atv_ops = =3D { > =20 > static int opa362_probe(struct platform_device *pdev) > { > - struct device_node *node =3D pdev->dev.of_node; > struct panel_drv_data *ddata; > - struct omap_dss_device *dssdev, *in; > + struct omap_dss_device *dssdev; > struct gpio_desc *gpio; > int r; > =20 > @@ -191,14 +202,6 @@ static int opa362_probe(struct platform_device *pdev) > =20 > ddata->enable_gpio =3D gpio; > =20 > - in =3D omapdss_of_find_source_for_first_ep(node); > - if (IS_ERR(in)) { > - dev_err(&pdev->dev, "failed to find video source\n"); > - return PTR_ERR(in); > - } > - > - ddata->in =3D in; > - > dssdev =3D &ddata->dssdev; > dssdev->ops.atv =3D &opa362_atv_ops; > dssdev->dev =3D &pdev->dev; > @@ -209,20 +212,16 @@ static int opa362_probe(struct platform_device *pde= v) > r =3D omapdss_register_output(dssdev); > if (r) { > dev_err(&pdev->dev, "Failed to register output\n"); > - goto err_reg; > + return r; > } > =20 > return 0; > -err_reg: > - omap_dss_put_device(ddata->in); > - return r; > } > =20 > static int __exit opa362_remove(struct platform_device *pdev) > { > struct panel_drv_data *ddata =3D platform_get_drvdata(pdev); > struct omap_dss_device *dssdev =3D &ddata->dssdev; > - struct omap_dss_device *in =3D ddata->in; > =20 > omapdss_unregister_output(&ddata->dssdev); > =20 > @@ -234,8 +233,6 @@ static int __exit opa362_remove(struct platform_devic= e *pdev) > if (omapdss_device_is_connected(dssdev)) > opa362_disconnect(dssdev, dssdev->dst); > =20 > - omap_dss_put_device(in); > - > return 0; > } > =20 > diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c b/drivers/= gpu/drm/omapdrm/displays/encoder-tfp410.c > index 9e0ab4e77366..0d640f8c0689 100644 > --- a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c > +++ b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c > @@ -32,19 +32,28 @@ static int tfp410_connect(struct omap_dss_device *dss= dev, > struct omap_dss_device *dst) > { > struct panel_drv_data *ddata =3D to_panel_data(dssdev); > - struct omap_dss_device *in =3D ddata->in; > + struct omap_dss_device *in; > int r; > =20 > if (omapdss_device_is_connected(dssdev)) > return -EBUSY; > =20 > + in =3D omapdss_of_find_source_for_first_ep(dssdev->dev->of_node); > + if (IS_ERR(in)) { > + dev_err(dssdev->dev, "failed to find video source\n"); > + return PTR_ERR(in); > + } > + > r =3D in->ops.dpi->connect(in, dssdev); > - if (r) > + if (r) { > + omap_dss_put_device(in); > return r; > + } > =20 > dst->src =3D dssdev; > dssdev->dst =3D dst; > =20 > + ddata->in =3D in; > return 0; > } > =20 > @@ -66,6 +75,9 @@ static void tfp410_disconnect(struct omap_dss_device *d= ssdev, > dssdev->dst =3D NULL; > =20 > in->ops.dpi->disconnect(in, &ddata->dssdev); > + > + omap_dss_put_device(in); > + ddata->in =3D NULL; > } > =20 > static int tfp410_enable(struct omap_dss_device *dssdev) > @@ -165,7 +177,6 @@ static int tfp410_probe_of(struct platform_device *pd= ev) > { > struct panel_drv_data *ddata =3D platform_get_drvdata(pdev); > struct device_node *node =3D pdev->dev.of_node; > - struct omap_dss_device *in; > int gpio; > =20 > gpio =3D of_get_named_gpio(node, "powerdown-gpios", 0); > @@ -178,14 +189,6 @@ static int tfp410_probe_of(struct platform_device *p= dev) > return gpio; > } > =20 > - in =3D omapdss_of_find_source_for_first_ep(node); > - if (IS_ERR(in)) { > - dev_err(&pdev->dev, "failed to find video source\n"); > - return PTR_ERR(in); > - } > - > - ddata->in =3D in; > - > return 0; > } > =20 > @@ -211,7 +214,7 @@ static int tfp410_probe(struct platform_device *pdev) > if (r) { > dev_err(&pdev->dev, "Failed to request PD GPIO %d\n", > ddata->pd_gpio); > - goto err_gpio; > + return r; > } > } > =20 > @@ -226,21 +229,16 @@ static int tfp410_probe(struct platform_device *pde= v) > r =3D omapdss_register_output(dssdev); > if (r) { > dev_err(&pdev->dev, "Failed to register output\n"); > - goto err_reg; > + return r; > } > =20 > return 0; > -err_reg: > -err_gpio: > - omap_dss_put_device(ddata->in); > - return r; > } > =20 > static int __exit tfp410_remove(struct platform_device *pdev) > { > struct panel_drv_data *ddata =3D platform_get_drvdata(pdev); > struct omap_dss_device *dssdev =3D &ddata->dssdev; > - struct omap_dss_device *in =3D ddata->in; > =20 > omapdss_unregister_output(&ddata->dssdev); > =20 > @@ -252,8 +250,6 @@ static int __exit tfp410_remove(struct platform_devic= e *pdev) > if (omapdss_device_is_connected(dssdev)) > tfp410_disconnect(dssdev, dssdev->dst); > =20 > - omap_dss_put_device(in); > - > return 0; > } > =20 > diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c b/drive= rs/gpu/drm/omapdrm/displays/encoder-tpd12s015.c > index 6c478140a52e..226fad5cdab1 100644 > --- a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c > +++ b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c > @@ -40,12 +40,20 @@ static int tpd_connect(struct omap_dss_device *dssdev, > struct omap_dss_device *dst) > { > struct panel_drv_data *ddata =3D to_panel_data(dssdev); > - struct omap_dss_device *in =3D ddata->in; > + struct omap_dss_device *in; > int r; > =20 > + in =3D omapdss_of_find_source_for_first_ep(dssdev->dev->of_node); > + if (IS_ERR(in)) { > + dev_err(dssdev->dev, "failed to find video source\n"); > + return PTR_ERR(in); > + } > + > r =3D in->ops.hdmi->connect(in, dssdev); > - if (r) > + if (r) { > + omap_dss_put_device(in); > return r; > + } > =20 > dst->src =3D dssdev; > dssdev->dst =3D dst; > @@ -56,6 +64,7 @@ static int tpd_connect(struct omap_dss_device *dssdev, > /* DC-DC converter needs at max 300us to get to 90% of 5V */ > udelay(300); > =20 > + ddata->in =3D in; > return 0; > } > =20 > @@ -77,6 +86,9 @@ static void tpd_disconnect(struct omap_dss_device *dssd= ev, > dssdev->dst =3D NULL; > =20 > in->ops.hdmi->disconnect(in, &ddata->dssdev); > + > + omap_dss_put_device(in); > + ddata->in =3D NULL; > } > =20 > static int tpd_enable(struct omap_dss_device *dssdev) > @@ -269,23 +281,6 @@ static irqreturn_t tpd_hpd_isr(int irq, void *data) > return IRQ_HANDLED; > } > =20 > -static int tpd_probe_of(struct platform_device *pdev) > -{ > - struct panel_drv_data *ddata =3D platform_get_drvdata(pdev); > - struct device_node *node =3D pdev->dev.of_node; > - struct omap_dss_device *in; > - > - in =3D omapdss_of_find_source_for_first_ep(node); > - if (IS_ERR(in)) { > - dev_err(&pdev->dev, "failed to find video source\n"); > - return PTR_ERR(in); > - } > - > - ddata->in =3D in; > - > - return 0; > -} > - > static int tpd_probe(struct platform_device *pdev) > { > struct omap_dss_device *in, *dssdev; > @@ -299,34 +294,24 @@ static int tpd_probe(struct platform_device *pdev) > =20 > platform_set_drvdata(pdev, ddata); > =20 > - r =3D tpd_probe_of(pdev); > - if (r) > - return r; > - > gpio =3D devm_gpiod_get_index_optional(&pdev->dev, NULL, 0, > GPIOD_OUT_LOW); > - if (IS_ERR(gpio)) { > - r =3D PTR_ERR(gpio); > - goto err_gpio; > - } > + if (IS_ERR(gpio)) > + return PTR_ERR(gpio); > =20 > ddata->ct_cp_hpd_gpio =3D gpio; > =20 > gpio =3D devm_gpiod_get_index_optional(&pdev->dev, NULL, 1, > GPIOD_OUT_LOW); > - if (IS_ERR(gpio)) { > - r =3D PTR_ERR(gpio); > - goto err_gpio; > - } > + if (IS_ERR(gpio)) > + return PTR_ERR(gpio); > =20 > ddata->ls_oe_gpio =3D gpio; > =20 > gpio =3D devm_gpiod_get_index(&pdev->dev, NULL, 2, > GPIOD_IN); > - if (IS_ERR(gpio)) { > - r =3D PTR_ERR(gpio); > - goto err_gpio; > - } > + if (IS_ERR(gpio)) > + return PTR_ERR(gpio); > =20 > ddata->hpd_gpio =3D gpio; > =20 > @@ -337,7 +322,7 @@ static int tpd_probe(struct platform_device *pdev) > IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, > "tpd12s015 hpd", ddata); > if (r) > - goto err_gpio; > + return r; > =20 > dssdev =3D &ddata->dssdev; > dssdev->ops.hdmi =3D &tpd_hdmi_ops; > @@ -352,21 +337,16 @@ static int tpd_probe(struct platform_device *pdev) > r =3D omapdss_register_output(dssdev); > if (r) { > dev_err(&pdev->dev, "Failed to register output\n"); > - goto err_reg; > + return r; > } > =20 > return 0; > -err_reg: > -err_gpio: > - omap_dss_put_device(ddata->in); > - return r; > } > =20 > static int __exit tpd_remove(struct platform_device *pdev) > { > struct panel_drv_data *ddata =3D platform_get_drvdata(pdev); > struct omap_dss_device *dssdev =3D &ddata->dssdev; > - struct omap_dss_device *in =3D ddata->in; > =20 > omapdss_unregister_output(&ddata->dssdev); > =20 > @@ -378,8 +358,6 @@ static int __exit tpd_remove(struct platform_device *= pdev) > if (omapdss_device_is_connected(dssdev)) > tpd_disconnect(dssdev, dssdev->dst); > =20 > - omap_dss_put_device(in); > - > return 0; > } > =20 > --=20 > Regards, >=20 > Laurent Pinchart >=20 > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel --iskiyfspupxa4tol Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlniCgUACgkQ2O7X88g7 +pqHKQ/9HjnJ5syYQGS6H3SwdANHew97D+sggHE/4Rafv3JSL5y4NmADHgrzohk/ 29N5IiFOMQpUd6PqVxC+xNcrpkTz6ge4rsfQrJqz4QXIm9QS/38KXQ6vzsEJlwNa lNy0J2zd78CL7jTtEOfl/FxkmkOKou3LaU+qibW/IDBfKiKOyszjfxsgeVlaWbyX 2vHSN3Pxatmz+ZIY0SAcwbV3jRtP2u0W26p1WTgqBEI14Fw6gwgWMmlnIbDDzp/L rRfT/4rHKGLFqMuaC7PaWHHE+UYvHPx5W6BQgo9RvcvmNjp9R+t5eCjhht+ptQmb 66pE7dKRHpifMJ9HyPIYvMi4EaKpjweY9jWclJYeBaI5CSZ1xNQUngD6SXOs4+zi wl7hlXXss8PYE0gKk9zEhqoZ+3djF1Dsih6crwzPdEfJESxkbrbn2AhyEdQAYq05 Xboeh4pnkcV33A6dJF+cXxUkt0Tzu0xuAXMnAWzwIG2UcqIxWybraYFAQuKRh5Zg oN6ieqw2H9tBrHX1TzLqpar0GBeqJfoSgKc3qOmUnydQSV1fDh5Za2sqQ24cF3mF xYDPxX9L1fukPzfX0NglpetRqdQgReMrPRLgXWwJuJ4LRhSYrvAenzn5op6XeF5i EHIgTDuQZJLG4ldZfKhHa30MTfnyCPGBhXWjcQ5uA+WJ5aNJpHI= =OZpR -----END PGP SIGNATURE----- --iskiyfspupxa4tol-- --===============1041660914== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============1041660914==--