[PATCH 17/48] drm: omapdrm: displays: Get connector source at connect time

Sebastian Reichel sebastian.reichel at collabora.co.uk
Sat Oct 14 12:51:59 UTC 2017


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.
> 
> 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.
> 
> Move retrieval of the source handle to the connect handler to avoid
> probe deferrals.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel at collabora.co.uk>

-- 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(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c b/drivers/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 = {
>  static int tvc_connect(struct omap_dss_device *dssdev)
>  {
>  	struct panel_drv_data *ddata = to_panel_data(dssdev);
> -	struct omap_dss_device *in = ddata->in;
> +	struct omap_dss_device *in;
>  	int r;
>  
>  	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;
>  
> +	in = 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 = in->ops.atv->connect(in, dssdev);
> -	if (r)
> +	if (r) {
> +		omap_dss_put_device(in);
>  		return r;
> +	}
>  
> +	ddata->in = in;
>  	return 0;
>  }
>  
> @@ -71,6 +80,9 @@ static void tvc_disconnect(struct omap_dss_device *dssdev)
>  		return;
>  
>  	in->ops.atv->disconnect(in, dssdev);
> +
> +	omap_dss_put_device(in);
> +	ddata->in = NULL;
>  }
>  
>  static int tvc_enable(struct omap_dss_device *dssdev)
> @@ -173,23 +185,6 @@ static struct omap_dss_driver tvc_driver = {
>  	.set_wss		= tvc_set_wss,
>  };
>  
> -static int tvc_probe_of(struct platform_device *pdev)
> -{
> -	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
> -	struct device_node *node = pdev->dev.of_node;
> -	struct omap_dss_device *in;
> -
> -	in = 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 = 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 = &pdev->dev;
>  
> -	r = tvc_probe_of(pdev);
> -	if (r)
> -		return r;
> -
>  	ddata->vm = tvc_pal_vm;
>  
>  	dssdev = &ddata->dssdev;
> @@ -219,28 +210,22 @@ static int tvc_probe(struct platform_device *pdev)
>  	r = omapdss_register_display(dssdev);
>  	if (r) {
>  		dev_err(&pdev->dev, "Failed to register panel\n");
> -		goto err_reg;
> +		return r;
>  	}
>  
>  	return 0;
> -err_reg:
> -	omap_dss_put_device(ddata->in);
> -	return r;
>  }
>  
>  static int __exit tvc_remove(struct platform_device *pdev)
>  {
>  	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
>  	struct omap_dss_device *dssdev = &ddata->dssdev;
> -	struct omap_dss_device *in = ddata->in;
>  
>  	omapdss_unregister_display(&ddata->dssdev);
>  
>  	tvc_disable(dssdev);
>  	tvc_disconnect(dssdev);
>  
> -	omap_dss_put_device(in);
> -
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c b/drivers/gpu/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 = to_panel_data(dssdev);
> -	struct omap_dss_device *in = ddata->in;
> +	struct omap_dss_device *in;
>  	int r;
>  
>  	if (omapdss_device_is_connected(dssdev))
>  		return 0;
>  
> +	in = 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 = in->ops.dvi->connect(in, dssdev);
> -	if (r)
> +	if (r) {
> +		omap_dss_put_device(in);
>  		return r;
> +	}
>  
> +	ddata->in = in;
>  	return 0;
>  }
>  
> @@ -73,6 +82,9 @@ static void dvic_disconnect(struct omap_dss_device *dssdev)
>  		return;
>  
>  	in->ops.dvi->disconnect(in, dssdev);
> +
> +	omap_dss_put_device(in);
> +	ddata->in = NULL;
>  }
>  
>  static int dvic_enable(struct omap_dss_device *dssdev)
> @@ -235,25 +247,15 @@ static int dvic_probe_of(struct platform_device *pdev)
>  {
>  	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
>  	struct device_node *node = pdev->dev.of_node;
> -	struct omap_dss_device *in;
>  	struct device_node *adapter_node;
>  	struct i2c_adapter *adapter;
>  
> -	in = 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 = in;
> -
>  	adapter_node = of_parse_phandle(node, "ddc-i2c-bus", 0);
>  	if (adapter_node) {
>  		adapter = of_get_i2c_adapter_by_node(adapter_node);
>  		of_node_put(adapter_node);
>  		if (adapter == NULL) {
>  			dev_err(&pdev->dev, "failed to parse ddc-i2c-bus\n");
> -			omap_dss_put_device(ddata->in);
>  			return -EPROBE_DEFER;
>  		}
>  
> @@ -297,8 +299,6 @@ static int dvic_probe(struct platform_device *pdev)
>  	return 0;
>  
>  err_reg:
> -	omap_dss_put_device(ddata->in);
> -
>  	i2c_put_adapter(ddata->i2c_adapter);
>  
>  	return r;
> @@ -308,15 +308,12 @@ static int __exit dvic_remove(struct platform_device *pdev)
>  {
>  	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
>  	struct omap_dss_device *dssdev = &ddata->dssdev;
> -	struct omap_dss_device *in = ddata->in;
>  
>  	omapdss_unregister_display(&ddata->dssdev);
>  
>  	dvic_disable(dssdev);
>  	dvic_disconnect(dssdev);
>  
> -	omap_dss_put_device(in);
> -
>  	i2c_put_adapter(ddata->i2c_adapter);
>  
>  	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 = to_panel_data(dssdev);
> -	struct omap_dss_device *in = ddata->in;
> +	struct omap_dss_device *in;
>  	int r;
>  
>  	dev_dbg(ddata->dev, "connect\n");
> @@ -63,10 +63,19 @@ static int hdmic_connect(struct omap_dss_device *dssdev)
>  	if (omapdss_device_is_connected(dssdev))
>  		return 0;
>  
> +	in = 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 = in->ops.hdmi->connect(in, dssdev);
> -	if (r)
> +	if (r) {
> +		omap_dss_put_device(in);
>  		return r;
> +	}
>  
> +	ddata->in = in;
>  	return 0;
>  }
>  
> @@ -81,6 +90,9 @@ static void hdmic_disconnect(struct omap_dss_device *dssdev)
>  		return;
>  
>  	in->ops.hdmi->disconnect(in, dssdev);
> +
> +	omap_dss_put_device(in);
> +	ddata->in = NULL;
>  }
>  
>  static int hdmic_enable(struct omap_dss_device *dssdev)
> @@ -302,7 +314,6 @@ static int hdmic_probe_of(struct platform_device *pdev)
>  {
>  	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
>  	struct device_node *node = pdev->dev.of_node;
> -	struct omap_dss_device *in;
>  	int gpio;
>  
>  	/* HPD GPIO */
> @@ -312,14 +323,6 @@ static int hdmic_probe_of(struct platform_device *pdev)
>  	else
>  		ddata->hpd_gpio = -ENODEV;
>  
> -	in = 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 = in;
> -
>  	return 0;
>  }
>  
> @@ -346,7 +349,7 @@ static int hdmic_probe(struct platform_device *pdev)
>  		r = devm_gpio_request_one(&pdev->dev, ddata->hpd_gpio,
>  				GPIOF_DIR_IN, "hdmi_hpd");
>  		if (r)
> -			goto err_reg;
> +			return r;
>  
>  		r = 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;
>  	}
>  
>  	ddata->vm = hdmic_default_vm;
> @@ -370,28 +373,22 @@ static int hdmic_probe(struct platform_device *pdev)
>  	r = omapdss_register_display(dssdev);
>  	if (r) {
>  		dev_err(&pdev->dev, "Failed to register panel\n");
> -		goto err_reg;
> +		return r;
>  	}
>  
>  	return 0;
> -err_reg:
> -	omap_dss_put_device(ddata->in);
> -	return r;
>  }
>  
>  static int __exit hdmic_remove(struct platform_device *pdev)
>  {
>  	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
>  	struct omap_dss_device *dssdev = &ddata->dssdev;
> -	struct omap_dss_device *in = ddata->in;
>  
>  	omapdss_unregister_display(&ddata->dssdev);
>  
>  	hdmic_disable(dssdev);
>  	hdmic_disconnect(dssdev);
>  
> -	omap_dss_put_device(in);
> -
>  	return 0;
>  }
>  
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20171014/b3903571/attachment.sig>


More information about the dri-devel mailing list