Hi,
On Wed, Jun 06, 2018 at 12:36:43PM +0300, Laurent Pinchart wrote:
> Instead of calling the hot-plug detection callback registration
> operations (.register_hpd_cb() and .unregister_hpd_cb()) recursively
> from the display device back to the first device that provides hot plug
> detection support, iterate over the devices manually in the DRM
> connector code. This moves the complexity to a single central location
> and simplifies the logic in omap_dss_device drivers.
>
> Signed-off-by: Laurent Pinchart
> ---
Reviewed-by: Sebastian Reichel
-- Sebastian
> drivers/gpu/drm/omapdrm/displays/connector-dvi.c | 8 ++-
> drivers/gpu/drm/omapdrm/displays/connector-hdmi.c | 67 --
> .../gpu/drm/omapdrm/displays/encoder-tpd12s015.c | 3 +-
> drivers/gpu/drm/omapdrm/omap_connector.c | 79
> ++
> 4 files changed, 88 insertions(+), 69 deletions(-)
>
> diff --git a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
> b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
> index f1674b3eee50..e9353e4cd297 100644
> --- a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
> +++ b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
> @@ -372,8 +372,12 @@ static int dvic_probe(struct platform_device *pdev)
> dssdev->type = OMAP_DISPLAY_TYPE_DVI;
> dssdev->owner = THIS_MODULE;
> dssdev->of_ports = BIT(0);
> - dssdev->ops_flags = ddata->hpd_gpio || ddata->i2c_adapter
> - ? OMAP_DSS_DEVICE_OP_DETECT : 0;
> +
> + if (ddata->hpd_gpio)
> + dssdev->ops_flags = OMAP_DSS_DEVICE_OP_DETECT
> + | OMAP_DSS_DEVICE_OP_HPD;
> + else if (ddata->i2c_adapter)
> + dssdev->ops_flags = OMAP_DSS_DEVICE_OP_DETECT;
>
> omapdss_display_init(dssdev);
> omapdss_device_register(dssdev);
> diff --git a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
> b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
> index 0d22d7004c98..8eae973474dd 100644
> --- a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
> +++ b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
> @@ -153,62 +153,53 @@ static int hdmic_register_hpd_cb(struct omap_dss_device
> *dssdev,
>void *cb_data)
> {
> struct panel_drv_data *ddata = to_panel_data(dssdev);
> - struct omap_dss_device *src = dssdev->src;
>
> - if (ddata->hpd_gpio) {
> - mutex_lock(>hpd_lock);
> - ddata->hpd_cb = cb;
> - ddata->hpd_cb_data = cb_data;
> - mutex_unlock(>hpd_lock);
> - return 0;
> - } else if (src->ops->register_hpd_cb) {
> - return src->ops->register_hpd_cb(src, cb, cb_data);
> - }
> + if (!ddata->hpd_gpio)
> + return -ENOTSUPP;
>
> - return -ENOTSUPP;
> + mutex_lock(>hpd_lock);
> + ddata->hpd_cb = cb;
> + ddata->hpd_cb_data = cb_data;
> + mutex_unlock(>hpd_lock);
> +
> + return 0;
> }
>
> static void hdmic_unregister_hpd_cb(struct omap_dss_device *dssdev)
> {
> struct panel_drv_data *ddata = to_panel_data(dssdev);
> - struct omap_dss_device *src = dssdev->src;
>
> - if (ddata->hpd_gpio) {
> - mutex_lock(>hpd_lock);
> - ddata->hpd_cb = NULL;
> - ddata->hpd_cb_data = NULL;
> - mutex_unlock(>hpd_lock);
> - } else if (src->ops->unregister_hpd_cb) {
> - src->ops->unregister_hpd_cb(src);
> - }
> + if (!ddata->hpd_gpio)
> + return;
> +
> + mutex_lock(>hpd_lock);
> + ddata->hpd_cb = NULL;
> + ddata->hpd_cb_data = NULL;
> + mutex_unlock(>hpd_lock);
> }
>
> static void hdmic_enable_hpd(struct omap_dss_device *dssdev)
> {
> struct panel_drv_data *ddata = to_panel_data(dssdev);
> - struct omap_dss_device *src = dssdev->src;
>
> - if (ddata->hpd_gpio) {
> - mutex_lock(>hpd_lock);
> - ddata->hpd_enabled = true;
> - mutex_unlock(>hpd_lock);
> - } else if (src->ops->enable_hpd) {
> - src->ops->enable_hpd(src);
> - }
> + if (!ddata->hpd_gpio)
> + return;
> +
> + mutex_lock(>hpd_lock);
> + ddata->hpd_enabled = true;
> + mutex_unlock(>hpd_lock);
> }
>
> static void hdmic_disable_hpd(struct omap_dss_device *dssdev)
> {
> struct panel_drv_data *ddata = to_panel_data(dssdev);
> - struct omap_dss_device *src = dssdev->src;
>
> - if (ddata->hpd_gpio) {
> - mutex_lock(>hpd_lock);
> - ddata->hpd_enabled = false;
> - mutex_unlock(>hpd_lock);
> - } else if (src->ops->disable_hpd) {
> - src->ops->disable_hpd(src);
> - }
> + if (!ddata->hpd_gpio)
> + return;
> +
> + mutex_lock(>hpd_lock);
> + ddata->hpd_enabled = false;
> + mutex_unlock(>hpd_lock);
> }
>
> static int hdmic_set_hdmi_mode(struct omap_dss_device *dssdev, bool
> hdmi_mode)
> @@ -314,7 +305,9 @@ static