From: Sebastian Reichel Subject: Re: [PATCH 17/48] drm: omapdrm: displays: Get connector source at connect time Date: Sat, 14 Oct 2017 14:51:59 +0200 Message-ID: <20171014125159.aagamn2bf6eztbfw@earth> References: <20171013145944.26557-1-laurent.pinchart@ideasonboard.com> <20171013145944.26557-18-laurent.pinchart@ideasonboard.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1910914672==" Return-path: Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0C8626E0CA for ; Sat, 14 Oct 2017 12:52:04 +0000 (UTC) In-Reply-To: <20171013145944.26557-18-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 --===============1910914672== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="c6aimvowqads2id2" Content-Disposition: inline --c6aimvowqads2id2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Fri, Oct 13, 2017 at 05:59:13PM +0300, Laurent Pinchart wrote: > The connector 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 > .../gpu/drm/omapdrm/displays/connector-analog-tv.c | 45 ++++++++--------= ------ > drivers/gpu/drm/omapdrm/displays/connector-dvi.c | 31 +++++++-------- > drivers/gpu/drm/omapdrm/displays/connector-hdmi.c | 37 ++++++++--------= -- > 3 files changed, 46 insertions(+), 67 deletions(-) >=20 > diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c b/dri= vers/gpu/drm/omapdrm/displays/connector-analog-tv.c > index 44c7d9238b54..f07546b8e8dd 100644 > --- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c > +++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c > @@ -45,7 +45,7 @@ static const struct videomode tvc_pal_vm =3D { > static int tvc_connect(struct omap_dss_device *dssdev) > { > 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(ddata->dev, "connect\n"); > @@ -53,10 +53,19 @@ static int tvc_connect(struct omap_dss_device *dssdev) > if (omapdss_device_is_connected(dssdev)) > return 0; > =20 > + in =3D omapdss_of_find_source_for_first_ep(ddata->dev->of_node); > + if (IS_ERR(in)) { > + dev_err(ddata->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 > + ddata->in =3D in; > return 0; > } > =20 > @@ -71,6 +80,9 @@ static void tvc_disconnect(struct omap_dss_device *dssd= ev) > return; > =20 > in->ops.atv->disconnect(in, dssdev); > + > + omap_dss_put_device(in); > + ddata->in =3D NULL; > } > =20 > static int tvc_enable(struct omap_dss_device *dssdev) > @@ -173,23 +185,6 @@ static struct omap_dss_driver tvc_driver =3D { > .set_wss =3D tvc_set_wss, > }; > =20 > -static int tvc_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 tvc_probe(struct platform_device *pdev) > { > struct panel_drv_data *ddata; > @@ -203,10 +198,6 @@ static int tvc_probe(struct platform_device *pdev) > platform_set_drvdata(pdev, ddata); > ddata->dev =3D &pdev->dev; > =20 > - r =3D tvc_probe_of(pdev); > - if (r) > - return r; > - > ddata->vm =3D tvc_pal_vm; > =20 > dssdev =3D &ddata->dssdev; > @@ -219,28 +210,22 @@ static int tvc_probe(struct platform_device *pdev) > r =3D omapdss_register_display(dssdev); > if (r) { > dev_err(&pdev->dev, "Failed to register panel\n"); > - goto err_reg; > + return r; > } > =20 > return 0; > -err_reg: > - omap_dss_put_device(ddata->in); > - return r; > } > =20 > static int __exit tvc_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_display(&ddata->dssdev); > =20 > tvc_disable(dssdev); > tvc_disconnect(dssdev); > =20 > - omap_dss_put_device(in); > - > return 0; > } > =20 > diff --git a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c b/drivers/g= pu/drm/omapdrm/displays/connector-dvi.c > index 7728b5425d19..ad915860b7fd 100644 > --- a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c > +++ b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c > @@ -51,16 +51,25 @@ struct panel_drv_data { > static int dvic_connect(struct omap_dss_device *dssdev) > { > 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 0; > =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.dvi->connect(in, dssdev); > - if (r) > + if (r) { > + omap_dss_put_device(in); > return r; > + } > =20 > + ddata->in =3D in; > return 0; > } > =20 > @@ -73,6 +82,9 @@ static void dvic_disconnect(struct omap_dss_device *dss= dev) > return; > =20 > in->ops.dvi->disconnect(in, dssdev); > + > + omap_dss_put_device(in); > + ddata->in =3D NULL; > } > =20 > static int dvic_enable(struct omap_dss_device *dssdev) > @@ -235,25 +247,15 @@ static int dvic_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; > struct device_node *adapter_node; > struct i2c_adapter *adapter; > =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; > - > adapter_node =3D of_parse_phandle(node, "ddc-i2c-bus", 0); > if (adapter_node) { > adapter =3D of_get_i2c_adapter_by_node(adapter_node); > of_node_put(adapter_node); > if (adapter =3D=3D NULL) { > dev_err(&pdev->dev, "failed to parse ddc-i2c-bus\n"); > - omap_dss_put_device(ddata->in); > return -EPROBE_DEFER; > } > =20 > @@ -297,8 +299,6 @@ static int dvic_probe(struct platform_device *pdev) > return 0; > =20 > err_reg: > - omap_dss_put_device(ddata->in); > - > i2c_put_adapter(ddata->i2c_adapter); > =20 > return r; > @@ -308,15 +308,12 @@ static int __exit dvic_remove(struct platform_devic= e *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_display(&ddata->dssdev); > =20 > dvic_disable(dssdev); > dvic_disconnect(dssdev); > =20 > - omap_dss_put_device(in); > - > i2c_put_adapter(ddata->i2c_adapter); > =20 > return 0; > diff --git a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c b/drivers/= gpu/drm/omapdrm/displays/connector-hdmi.c > index b8d74fba4f45..dedf60b32dab 100644 > --- a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c > +++ b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c > @@ -55,7 +55,7 @@ struct panel_drv_data { > static int hdmic_connect(struct omap_dss_device *dssdev) > { > 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(ddata->dev, "connect\n"); > @@ -63,10 +63,19 @@ static int hdmic_connect(struct omap_dss_device *dssd= ev) > if (omapdss_device_is_connected(dssdev)) > return 0; > =20 > + in =3D omapdss_of_find_source_for_first_ep(ddata->dev->of_node); > + if (IS_ERR(in)) { > + dev_err(ddata->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 > + ddata->in =3D in; > return 0; > } > =20 > @@ -81,6 +90,9 @@ static void hdmic_disconnect(struct omap_dss_device *ds= sdev) > return; > =20 > in->ops.hdmi->disconnect(in, dssdev); > + > + omap_dss_put_device(in); > + ddata->in =3D NULL; > } > =20 > static int hdmic_enable(struct omap_dss_device *dssdev) > @@ -302,7 +314,6 @@ static int hdmic_probe_of(struct platform_device *pde= v) > { > 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 > /* HPD GPIO */ > @@ -312,14 +323,6 @@ static int hdmic_probe_of(struct platform_device *pd= ev) > else > ddata->hpd_gpio =3D -ENODEV; > =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 > @@ -346,7 +349,7 @@ static int hdmic_probe(struct platform_device *pdev) > r =3D devm_gpio_request_one(&pdev->dev, ddata->hpd_gpio, > GPIOF_DIR_IN, "hdmi_hpd"); > if (r) > - goto err_reg; > + return r; > =20 > r =3D devm_request_threaded_irq(&pdev->dev, > gpio_to_irq(ddata->hpd_gpio), > @@ -355,7 +358,7 @@ static int hdmic_probe(struct platform_device *pdev) > IRQF_ONESHOT, > "hdmic hpd", ddata); > if (r) > - goto err_reg; > + return r; > } > =20 > ddata->vm =3D hdmic_default_vm; > @@ -370,28 +373,22 @@ static int hdmic_probe(struct platform_device *pdev) > r =3D omapdss_register_display(dssdev); > if (r) { > dev_err(&pdev->dev, "Failed to register panel\n"); > - goto err_reg; > + return r; > } > =20 > return 0; > -err_reg: > - omap_dss_put_device(ddata->in); > - return r; > } > =20 > static int __exit hdmic_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_display(&ddata->dssdev); > =20 > hdmic_disable(dssdev); > hdmic_disconnect(dssdev); > =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 --c6aimvowqads2id2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlniCG8ACgkQ2O7X88g7 +pqhRw/5ARhJwBS/5QIT74yF6w4nwe9xnsJuebl0VZ0THi8ma2gP8vYMcDpvO1+k I4MrL7E/AWJL83NRiTlHhfJ6B8CgyY9UzqTrxcbYIpSg71T/EC39vcdVdVG/zbOb Ntmf5M2nTYv380sh4J4MYDXyQ7DXKhDcoTz5D78hhVEKGU+Zge8z0g+Gk3iEsboo J1SfgxVxpmypFK1XnWlWddvbVYh/0lj1/AFHoHJOX6sYAbHyWvmkwcFoHQ0hP9CD dHfXuXjkQr1q1K8rjqV4x5ReKgbxrLx+7xThVL4sHD5PBBeszpmFH3WqW/SgIbmo zMFtvEHUawnBDwuNoG06bxam4L3YZHmXLbwZ43k9LWYkrHgYtxXRkRXRS5RczAAE H3wreQmmkW7ZUf31HbOQaMbE8/BSX3t2wdt35IYCRySfe1K2VsmuJua2X+fwVK/m jIoJoF3b37AL4ji2x2cnOFnrc/E5L3TeBYXRR3wnIS7sqhNJFxzuO9lis2Hpg/pQ oumUvNYavpNIFQpEqdNjovaoC9YeUmj6vjTVqNkpz404HA8/JtnqJvRGCHR39qOE jKdL9jXvUSjmPMvghNSVHTxqkILlEQeV0zoK3BiLgY+77XoyKBE/BIkfwJV0XPag AGvQ8O/dqSql1ssfoHUsBF+rB3wd0Pax6oyM0+uX2wYNdvVcYcM= =bGMV -----END PGP SIGNATURE----- --c6aimvowqads2id2-- --===============1910914672== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============1910914672==--