dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] drm: cec: call cec_s_conn_info()
@ 2019-08-23 11:24 Hans Verkuil
  2019-08-23 11:24 ` [PATCH 1/3] drm/vc4/vc4_hdmi: fill in connector info Hans Verkuil
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Hans Verkuil @ 2019-08-23 11:24 UTC (permalink / raw)
  To: linux-media
  Cc: Archit Taneja, Maxime Ripard, Maling list - DRI developers,
	Laurent Pinchart, Dariusz Marcinkiewicz

Three drivers were not updated in Dariusz' series:

https://patchwork.linuxtv.org/project/linux-media/list/?series=573

This series adds connector info support for those three.

Note that the sun4i patch has this patch as a prerequisite:

https://patchwork.linuxtv.org/project/linux-media/list/?series=573

This will be merged for v5.3, so this should be in before the
sun4i patch is merged.

Regards,

	Hans

Dariusz Marcinkiewicz (1):
  drm/vc4/vc4_hdmi: fill in connector info

Hans Verkuil (2):
  drm/sun4i/sun4i_hdmi_enc: call cec_s_conn_info()
  drm/bridge/adv7511: enable CEC connector info

 drivers/gpu/drm/bridge/adv7511/adv7511_cec.c |  7 ++++++-
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 22 ++++++++++----------
 drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c       |  6 ++++--
 drivers/gpu/drm/vc4/vc4_hdmi.c               | 13 ++++++++----
 4 files changed, 30 insertions(+), 18 deletions(-)

-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/3] drm/vc4/vc4_hdmi: fill in connector info
  2019-08-23 11:24 [PATCH 0/3] drm: cec: call cec_s_conn_info() Hans Verkuil
@ 2019-08-23 11:24 ` Hans Verkuil
  2019-08-23 18:48   ` Eric Anholt
  2019-08-23 11:24 ` [PATCH 2/3] drm/sun4i/sun4i_hdmi_enc: call cec_s_conn_info() Hans Verkuil
  2019-08-23 11:24 ` [PATCH 3/3] drm/bridge/adv7511: enable CEC connector info Hans Verkuil
  2 siblings, 1 reply; 11+ messages in thread
From: Hans Verkuil @ 2019-08-23 11:24 UTC (permalink / raw)
  To: linux-media
  Cc: Archit Taneja, Maxime Ripard, Maling list - DRI developers,
	Laurent Pinchart, Hans Verkuil, Dariusz Marcinkiewicz

From: Dariusz Marcinkiewicz <darekm@google.com>

Fill in the connector info, allowing userspace to associate
the CEC device with the drm connector.

Tested on a Raspberry Pi 3B.

Signed-off-by: Dariusz Marcinkiewicz <darekm@google.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Tested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 drivers/gpu/drm/vc4/vc4_hdmi.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index ee7d4e7b0ee3..0853b980bcb3 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -1285,6 +1285,9 @@ static const struct cec_adap_ops vc4_hdmi_cec_adap_ops = {
 
 static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
 {
+#ifdef CONFIG_DRM_VC4_HDMI_CEC
+	struct cec_connector_info conn_info;
+#endif
 	struct platform_device *pdev = to_platform_device(dev);
 	struct drm_device *drm = dev_get_drvdata(master);
 	struct vc4_dev *vc4 = drm->dev_private;
@@ -1403,13 +1406,15 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
 #ifdef CONFIG_DRM_VC4_HDMI_CEC
 	hdmi->cec_adap = cec_allocate_adapter(&vc4_hdmi_cec_adap_ops,
 					      vc4, "vc4",
-					      CEC_CAP_TRANSMIT |
-					      CEC_CAP_LOG_ADDRS |
-					      CEC_CAP_PASSTHROUGH |
-					      CEC_CAP_RC, 1);
+					      CEC_CAP_DEFAULTS |
+					      CEC_CAP_CONNECTOR_INFO, 1);
 	ret = PTR_ERR_OR_ZERO(hdmi->cec_adap);
 	if (ret < 0)
 		goto err_destroy_conn;
+
+	cec_fill_conn_info_from_drm(&conn_info, hdmi->connector);
+	cec_s_conn_info(hdmi->cec_adap, &conn_info);
+
 	HDMI_WRITE(VC4_HDMI_CPU_MASK_SET, 0xffffffff);
 	value = HDMI_READ(VC4_HDMI_CEC_CNTRL_1);
 	value &= ~VC4_HDMI_CEC_DIV_CLK_CNT_MASK;
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/3] drm/sun4i/sun4i_hdmi_enc: call cec_s_conn_info()
  2019-08-23 11:24 [PATCH 0/3] drm: cec: call cec_s_conn_info() Hans Verkuil
  2019-08-23 11:24 ` [PATCH 1/3] drm/vc4/vc4_hdmi: fill in connector info Hans Verkuil
@ 2019-08-23 11:24 ` Hans Verkuil
  2019-08-28  8:17   ` Maxime Ripard
  2019-08-23 11:24 ` [PATCH 3/3] drm/bridge/adv7511: enable CEC connector info Hans Verkuil
  2 siblings, 1 reply; 11+ messages in thread
From: Hans Verkuil @ 2019-08-23 11:24 UTC (permalink / raw)
  To: linux-media
  Cc: Archit Taneja, Maxime Ripard, Maling list - DRI developers,
	Laurent Pinchart, Hans Verkuil, Dariusz Marcinkiewicz

Set the connector info for the CEC adapter. This helps
userspace to associate the CEC device with the HDMI connector.

Tested on a Cubieboard.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Tested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
index 9c3f99339b82..22f082c32e1f 100644
--- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
+++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
@@ -489,6 +489,7 @@ static int sun4i_hdmi_bind(struct device *dev, struct device *master,
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	struct drm_device *drm = data;
+	struct cec_connector_info conn_info;
 	struct sun4i_drv *drv = drm->dev_private;
 	struct sun4i_hdmi *hdmi;
 	struct resource *res;
@@ -628,8 +629,7 @@ static int sun4i_hdmi_bind(struct device *dev, struct device *master,
 
 #ifdef CONFIG_DRM_SUN4I_HDMI_CEC
 	hdmi->cec_adap = cec_pin_allocate_adapter(&sun4i_hdmi_cec_pin_ops,
-		hdmi, "sun4i", CEC_CAP_TRANSMIT | CEC_CAP_LOG_ADDRS |
-		CEC_CAP_PASSTHROUGH | CEC_CAP_RC);
+		hdmi, "sun4i", CEC_CAP_DEFAULTS | CEC_CAP_CONNECTOR_INFO);
 	ret = PTR_ERR_OR_ZERO(hdmi->cec_adap);
 	if (ret < 0)
 		goto err_cleanup_connector;
@@ -647,6 +647,8 @@ static int sun4i_hdmi_bind(struct device *dev, struct device *master,
 			"Couldn't initialise the HDMI connector\n");
 		goto err_cleanup_connector;
 	}
+	cec_fill_conn_info_from_drm(&conn_info, &hdmi->connector);
+	cec_s_conn_info(hdmi->cec_adap, &conn_info);
 
 	/* There is no HPD interrupt, so we need to poll the controller */
 	hdmi->connector.polled = DRM_CONNECTOR_POLL_CONNECT |
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/3] drm/bridge/adv7511: enable CEC connector info
  2019-08-23 11:24 [PATCH 0/3] drm: cec: call cec_s_conn_info() Hans Verkuil
  2019-08-23 11:24 ` [PATCH 1/3] drm/vc4/vc4_hdmi: fill in connector info Hans Verkuil
  2019-08-23 11:24 ` [PATCH 2/3] drm/sun4i/sun4i_hdmi_enc: call cec_s_conn_info() Hans Verkuil
@ 2019-08-23 11:24 ` Hans Verkuil
  2019-08-23 18:58   ` Laurent Pinchart
  2 siblings, 1 reply; 11+ messages in thread
From: Hans Verkuil @ 2019-08-23 11:24 UTC (permalink / raw)
  To: linux-media
  Cc: Archit Taneja, Maxime Ripard, Maling list - DRI developers,
	Laurent Pinchart, Hans Verkuil, Dariusz Marcinkiewicz

Set the connector info to help userspace associate the CEC adapter
with the HDMI connector.

This required that the cec initialization and unregistering the
CEC adapter takes place in the bridge attach and detach ops.

Tested on an R-Car Koelsch board.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Tested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 drivers/gpu/drm/bridge/adv7511/adv7511_cec.c |  7 ++++++-
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 22 ++++++++++----------
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c b/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
index a20a45c0b353..accf5e232396 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
@@ -302,6 +302,7 @@ static int adv7511_cec_parse_dt(struct device *dev, struct adv7511 *adv7511)
 
 int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511)
 {
+	struct cec_connector_info conn_info;
 	unsigned int offset = adv7511->type == ADV7533 ?
 						ADV7533_REG_CEC_OFFSET : 0;
 	int ret = adv7511_cec_parse_dt(dev, adv7511);
@@ -310,7 +311,8 @@ int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511)
 		goto err_cec_parse_dt;
 
 	adv7511->cec_adap = cec_allocate_adapter(&adv7511_cec_adap_ops,
-		adv7511, dev_name(dev), CEC_CAP_DEFAULTS, ADV7511_MAX_ADDRS);
+		adv7511, dev_name(dev),
+		CEC_CAP_DEFAULTS | CEC_CAP_CONNECTOR_INFO, ADV7511_MAX_ADDRS);
 	if (IS_ERR(adv7511->cec_adap)) {
 		ret = PTR_ERR(adv7511->cec_adap);
 		goto err_cec_alloc;
@@ -331,6 +333,9 @@ int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511)
 		     ADV7511_REG_CEC_CLK_DIV + offset,
 		     ((adv7511->cec_clk_freq / 750000) - 1) << 2);
 
+	cec_fill_conn_info_from_drm(&conn_info, &adv7511->connector);
+	cec_s_conn_info(adv7511->cec_adap, &conn_info);
+
 	ret = cec_register_adapter(adv7511->cec_adap, dev);
 	if (ret)
 		goto err_cec_register;
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
index f6d2681f6927..bbcb996c4d4f 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
@@ -881,14 +881,24 @@ static int adv7511_bridge_attach(struct drm_bridge *bridge)
 		regmap_write(adv->regmap, ADV7511_REG_INT_ENABLE(0),
 			     ADV7511_INT0_HPD);
 
+	if (!ret)
+		ret = adv7511_cec_init(&adv->i2c_main->dev, adv);
 	return ret;
 }
 
+static void adv7511_bridge_detach(struct drm_bridge *bridge)
+{
+	struct adv7511 *adv = bridge_to_adv7511(bridge);
+
+	cec_unregister_adapter(adv->cec_adap);
+}
+
 static const struct drm_bridge_funcs adv7511_bridge_funcs = {
 	.enable = adv7511_bridge_enable,
 	.disable = adv7511_bridge_disable,
 	.mode_set = adv7511_bridge_mode_set,
 	.attach = adv7511_bridge_attach,
+	.detach = adv7511_bridge_detach,
 };
 
 /* -----------------------------------------------------------------------------
@@ -1202,7 +1212,7 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
 						IRQF_ONESHOT, dev_name(dev),
 						adv7511);
 		if (ret)
-			goto err_unregister_cec;
+			goto err_i2c_unregister_packet;
 	}
 
 	adv7511_power_off(adv7511);
@@ -1212,10 +1222,6 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
 	if (adv7511->type == ADV7511)
 		adv7511_set_link_config(adv7511, &link_config);
 
-	ret = adv7511_cec_init(dev, adv7511);
-	if (ret)
-		goto err_unregister_cec;
-
 	adv7511->bridge.funcs = &adv7511_bridge_funcs;
 	adv7511->bridge.of_node = dev->of_node;
 
@@ -1224,10 +1230,6 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
 	adv7511_audio_init(dev, adv7511);
 	return 0;
 
-err_unregister_cec:
-	i2c_unregister_device(adv7511->i2c_cec);
-	if (adv7511->cec_clk)
-		clk_disable_unprepare(adv7511->cec_clk);
 err_i2c_unregister_packet:
 	i2c_unregister_device(adv7511->i2c_packet);
 err_i2c_unregister_edid:
@@ -1254,8 +1256,6 @@ static int adv7511_remove(struct i2c_client *i2c)
 
 	adv7511_audio_exit(adv7511);
 
-	cec_unregister_adapter(adv7511->cec_adap);
-
 	i2c_unregister_device(adv7511->i2c_packet);
 	i2c_unregister_device(adv7511->i2c_edid);
 
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] drm/vc4/vc4_hdmi: fill in connector info
  2019-08-23 11:24 ` [PATCH 1/3] drm/vc4/vc4_hdmi: fill in connector info Hans Verkuil
@ 2019-08-23 18:48   ` Eric Anholt
  0 siblings, 0 replies; 11+ messages in thread
From: Eric Anholt @ 2019-08-23 18:48 UTC (permalink / raw)
  To: linux-media
  Cc: Archit Taneja, Maxime Ripard, Maling list - DRI developers,
	Laurent Pinchart, Hans Verkuil, Dariusz Marcinkiewicz


[-- Attachment #1.1: Type: text/plain, Size: 245 bytes --]

Hans Verkuil <hverkuil-cisco@xs4all.nl> writes:

> From: Dariusz Marcinkiewicz <darekm@google.com>
>
> Fill in the connector info, allowing userspace to associate
> the CEC device with the drm connector.

Acked-by: Eric Anholt <eric@anholt.net>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/3] drm/bridge/adv7511: enable CEC connector info
  2019-08-23 11:24 ` [PATCH 3/3] drm/bridge/adv7511: enable CEC connector info Hans Verkuil
@ 2019-08-23 18:58   ` Laurent Pinchart
  2019-08-23 19:01     ` Laurent Pinchart
  0 siblings, 1 reply; 11+ messages in thread
From: Laurent Pinchart @ 2019-08-23 18:58 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: Archit Taneja, Maxime Ripard, Maling list - DRI developers,
	Dariusz Marcinkiewicz, linux-media

Hi Hans,

Thank you for the patch.

On Fri, Aug 23, 2019 at 01:24:27PM +0200, Hans Verkuil wrote:
> Set the connector info to help userspace associate the CEC adapter
> with the HDMI connector.
> 
> This required that the cec initialization and unregistering the
> CEC adapter takes place in the bridge attach and detach ops.
> 
> Tested on an R-Car Koelsch board.
> 
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> Tested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> ---
>  drivers/gpu/drm/bridge/adv7511/adv7511_cec.c |  7 ++++++-
>  drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 22 ++++++++++----------
>  2 files changed, 17 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c b/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
> index a20a45c0b353..accf5e232396 100644
> --- a/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
> +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
> @@ -302,6 +302,7 @@ static int adv7511_cec_parse_dt(struct device *dev, struct adv7511 *adv7511)
>  
>  int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511)
>  {
> +	struct cec_connector_info conn_info;
>  	unsigned int offset = adv7511->type == ADV7533 ?
>  						ADV7533_REG_CEC_OFFSET : 0;
>  	int ret = adv7511_cec_parse_dt(dev, adv7511);
> @@ -310,7 +311,8 @@ int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511)
>  		goto err_cec_parse_dt;
>  
>  	adv7511->cec_adap = cec_allocate_adapter(&adv7511_cec_adap_ops,
> -		adv7511, dev_name(dev), CEC_CAP_DEFAULTS, ADV7511_MAX_ADDRS);
> +		adv7511, dev_name(dev),
> +		CEC_CAP_DEFAULTS | CEC_CAP_CONNECTOR_INFO, ADV7511_MAX_ADDRS);
>  	if (IS_ERR(adv7511->cec_adap)) {
>  		ret = PTR_ERR(adv7511->cec_adap);
>  		goto err_cec_alloc;
> @@ -331,6 +333,9 @@ int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511)
>  		     ADV7511_REG_CEC_CLK_DIV + offset,
>  		     ((adv7511->cec_clk_freq / 750000) - 1) << 2);
>  
> +	cec_fill_conn_info_from_drm(&conn_info, &adv7511->connector);
> +	cec_s_conn_info(adv7511->cec_adap, &conn_info);

I'm painfully trying to decouple bridges and connectors, if we keep
merging patches that go in the opposite direction, I'll never manage to
complete this :-(

Bridges are moving to a model where they won't create connectors
themselves, so any new access to drm_connector contained in a bridge
structure is a no-go I'm afraid (I'm replying to this patch as I know
this driver best, but this comment applies to the other two patches in
the series as well).

Here's what I wrote in a private e-mail, regarding similar changes for
the omapdrm driver.

--------
Please have a look at "[PATCH 00/60] drm/omap: Replace custom display
drivers with drm_bridge and drm_panel", available in a new version at

	git://linuxtv.org/pinchartl/media.git omapdrm/bridge/devel

(I will post v2 soon)

The patches show the direction the omapdrm driver is taking. The goal is
to decouple connectors from bridges, which I'm afraid will have an
impact on associating drm_connector with a CEC adapter. This should be
implemented through new drm_bridge operations, as bridges, when created,
will not create drm_connector anymore.

I've solved a similar problem related to associating DRM connectors with
an I2C adapter for DDC. Please see the drm_bridge_connector_init()
function and how the DDC adapter is handled. Something similar could be
done for CEC.
--------

Since then v2 has been posted ("[PATCH v2 00/50] drm/omap: Replace
custom display drivers with drm_bridge and drm_panel") and v3 is in
preparation.

So, please, let's both go in the right direction and solve the problem
properly for CEC.

> +
>  	ret = cec_register_adapter(adv7511->cec_adap, dev);
>  	if (ret)
>  		goto err_cec_register;
> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> index f6d2681f6927..bbcb996c4d4f 100644
> --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> @@ -881,14 +881,24 @@ static int adv7511_bridge_attach(struct drm_bridge *bridge)
>  		regmap_write(adv->regmap, ADV7511_REG_INT_ENABLE(0),
>  			     ADV7511_INT0_HPD);
>  
> +	if (!ret)
> +		ret = adv7511_cec_init(&adv->i2c_main->dev, adv);
>  	return ret;
>  }
>  
> +static void adv7511_bridge_detach(struct drm_bridge *bridge)
> +{
> +	struct adv7511 *adv = bridge_to_adv7511(bridge);
> +
> +	cec_unregister_adapter(adv->cec_adap);
> +}
> +
>  static const struct drm_bridge_funcs adv7511_bridge_funcs = {
>  	.enable = adv7511_bridge_enable,
>  	.disable = adv7511_bridge_disable,
>  	.mode_set = adv7511_bridge_mode_set,
>  	.attach = adv7511_bridge_attach,
> +	.detach = adv7511_bridge_detach,
>  };
>  
>  /* -----------------------------------------------------------------------------
> @@ -1202,7 +1212,7 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
>  						IRQF_ONESHOT, dev_name(dev),
>  						adv7511);
>  		if (ret)
> -			goto err_unregister_cec;
> +			goto err_i2c_unregister_packet;
>  	}
>  
>  	adv7511_power_off(adv7511);
> @@ -1212,10 +1222,6 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
>  	if (adv7511->type == ADV7511)
>  		adv7511_set_link_config(adv7511, &link_config);
>  
> -	ret = adv7511_cec_init(dev, adv7511);
> -	if (ret)
> -		goto err_unregister_cec;
> -
>  	adv7511->bridge.funcs = &adv7511_bridge_funcs;
>  	adv7511->bridge.of_node = dev->of_node;
>  
> @@ -1224,10 +1230,6 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
>  	adv7511_audio_init(dev, adv7511);
>  	return 0;
>  
> -err_unregister_cec:
> -	i2c_unregister_device(adv7511->i2c_cec);
> -	if (adv7511->cec_clk)
> -		clk_disable_unprepare(adv7511->cec_clk);
>  err_i2c_unregister_packet:
>  	i2c_unregister_device(adv7511->i2c_packet);
>  err_i2c_unregister_edid:
> @@ -1254,8 +1256,6 @@ static int adv7511_remove(struct i2c_client *i2c)
>  
>  	adv7511_audio_exit(adv7511);
>  
> -	cec_unregister_adapter(adv7511->cec_adap);
> -
>  	i2c_unregister_device(adv7511->i2c_packet);
>  	i2c_unregister_device(adv7511->i2c_edid);
>  

-- 
Regards,

Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/3] drm/bridge/adv7511: enable CEC connector info
  2019-08-23 18:58   ` Laurent Pinchart
@ 2019-08-23 19:01     ` Laurent Pinchart
  2019-08-26  9:01       ` Hans Verkuil
  0 siblings, 1 reply; 11+ messages in thread
From: Laurent Pinchart @ 2019-08-23 19:01 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: Archit Taneja, Maxime Ripard, Neil Armstrong, Boris Brezillon,
	Maling list - DRI developers, Dariusz Marcinkiewicz, linux-media

(And CC'ing Andrzej Hajda and Neil Armstrong as the new DRM bridge
maintainers, as well as Boris Brezillon, to make sure they're aware of
the problem)

I would really appreciate if we could delay merging this series and
other similar changes until we find a proper solution.

On Fri, Aug 23, 2019 at 09:58:47PM +0300, Laurent Pinchart wrote:
> Hi Hans,
> 
> Thank you for the patch.
> 
> On Fri, Aug 23, 2019 at 01:24:27PM +0200, Hans Verkuil wrote:
> > Set the connector info to help userspace associate the CEC adapter
> > with the HDMI connector.
> > 
> > This required that the cec initialization and unregistering the
> > CEC adapter takes place in the bridge attach and detach ops.
> > 
> > Tested on an R-Car Koelsch board.
> > 
> > Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> > Tested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> > ---
> >  drivers/gpu/drm/bridge/adv7511/adv7511_cec.c |  7 ++++++-
> >  drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 22 ++++++++++----------
> >  2 files changed, 17 insertions(+), 12 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c b/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
> > index a20a45c0b353..accf5e232396 100644
> > --- a/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
> > +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
> > @@ -302,6 +302,7 @@ static int adv7511_cec_parse_dt(struct device *dev, struct adv7511 *adv7511)
> >  
> >  int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511)
> >  {
> > +	struct cec_connector_info conn_info;
> >  	unsigned int offset = adv7511->type == ADV7533 ?
> >  						ADV7533_REG_CEC_OFFSET : 0;
> >  	int ret = adv7511_cec_parse_dt(dev, adv7511);
> > @@ -310,7 +311,8 @@ int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511)
> >  		goto err_cec_parse_dt;
> >  
> >  	adv7511->cec_adap = cec_allocate_adapter(&adv7511_cec_adap_ops,
> > -		adv7511, dev_name(dev), CEC_CAP_DEFAULTS, ADV7511_MAX_ADDRS);
> > +		adv7511, dev_name(dev),
> > +		CEC_CAP_DEFAULTS | CEC_CAP_CONNECTOR_INFO, ADV7511_MAX_ADDRS);
> >  	if (IS_ERR(adv7511->cec_adap)) {
> >  		ret = PTR_ERR(adv7511->cec_adap);
> >  		goto err_cec_alloc;
> > @@ -331,6 +333,9 @@ int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511)
> >  		     ADV7511_REG_CEC_CLK_DIV + offset,
> >  		     ((adv7511->cec_clk_freq / 750000) - 1) << 2);
> >  
> > +	cec_fill_conn_info_from_drm(&conn_info, &adv7511->connector);
> > +	cec_s_conn_info(adv7511->cec_adap, &conn_info);
> 
> I'm painfully trying to decouple bridges and connectors, if we keep
> merging patches that go in the opposite direction, I'll never manage to
> complete this :-(
> 
> Bridges are moving to a model where they won't create connectors
> themselves, so any new access to drm_connector contained in a bridge
> structure is a no-go I'm afraid (I'm replying to this patch as I know
> this driver best, but this comment applies to the other two patches in
> the series as well).
> 
> Here's what I wrote in a private e-mail, regarding similar changes for
> the omapdrm driver.
> 
> --------
> Please have a look at "[PATCH 00/60] drm/omap: Replace custom display
> drivers with drm_bridge and drm_panel", available in a new version at
> 
> 	git://linuxtv.org/pinchartl/media.git omapdrm/bridge/devel
> 
> (I will post v2 soon)
> 
> The patches show the direction the omapdrm driver is taking. The goal is
> to decouple connectors from bridges, which I'm afraid will have an
> impact on associating drm_connector with a CEC adapter. This should be
> implemented through new drm_bridge operations, as bridges, when created,
> will not create drm_connector anymore.
> 
> I've solved a similar problem related to associating DRM connectors with
> an I2C adapter for DDC. Please see the drm_bridge_connector_init()
> function and how the DDC adapter is handled. Something similar could be
> done for CEC.
> --------
> 
> Since then v2 has been posted ("[PATCH v2 00/50] drm/omap: Replace
> custom display drivers with drm_bridge and drm_panel") and v3 is in
> preparation.
> 
> So, please, let's both go in the right direction and solve the problem
> properly for CEC.
> 
> > +
> >  	ret = cec_register_adapter(adv7511->cec_adap, dev);
> >  	if (ret)
> >  		goto err_cec_register;
> > diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> > index f6d2681f6927..bbcb996c4d4f 100644
> > --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> > +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> > @@ -881,14 +881,24 @@ static int adv7511_bridge_attach(struct drm_bridge *bridge)
> >  		regmap_write(adv->regmap, ADV7511_REG_INT_ENABLE(0),
> >  			     ADV7511_INT0_HPD);
> >  
> > +	if (!ret)
> > +		ret = adv7511_cec_init(&adv->i2c_main->dev, adv);
> >  	return ret;
> >  }
> >  
> > +static void adv7511_bridge_detach(struct drm_bridge *bridge)
> > +{
> > +	struct adv7511 *adv = bridge_to_adv7511(bridge);
> > +
> > +	cec_unregister_adapter(adv->cec_adap);
> > +}
> > +
> >  static const struct drm_bridge_funcs adv7511_bridge_funcs = {
> >  	.enable = adv7511_bridge_enable,
> >  	.disable = adv7511_bridge_disable,
> >  	.mode_set = adv7511_bridge_mode_set,
> >  	.attach = adv7511_bridge_attach,
> > +	.detach = adv7511_bridge_detach,
> >  };
> >  
> >  /* -----------------------------------------------------------------------------
> > @@ -1202,7 +1212,7 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
> >  						IRQF_ONESHOT, dev_name(dev),
> >  						adv7511);
> >  		if (ret)
> > -			goto err_unregister_cec;
> > +			goto err_i2c_unregister_packet;
> >  	}
> >  
> >  	adv7511_power_off(adv7511);
> > @@ -1212,10 +1222,6 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
> >  	if (adv7511->type == ADV7511)
> >  		adv7511_set_link_config(adv7511, &link_config);
> >  
> > -	ret = adv7511_cec_init(dev, adv7511);
> > -	if (ret)
> > -		goto err_unregister_cec;
> > -
> >  	adv7511->bridge.funcs = &adv7511_bridge_funcs;
> >  	adv7511->bridge.of_node = dev->of_node;
> >  
> > @@ -1224,10 +1230,6 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
> >  	adv7511_audio_init(dev, adv7511);
> >  	return 0;
> >  
> > -err_unregister_cec:
> > -	i2c_unregister_device(adv7511->i2c_cec);
> > -	if (adv7511->cec_clk)
> > -		clk_disable_unprepare(adv7511->cec_clk);
> >  err_i2c_unregister_packet:
> >  	i2c_unregister_device(adv7511->i2c_packet);
> >  err_i2c_unregister_edid:
> > @@ -1254,8 +1256,6 @@ static int adv7511_remove(struct i2c_client *i2c)
> >  
> >  	adv7511_audio_exit(adv7511);
> >  
> > -	cec_unregister_adapter(adv7511->cec_adap);
> > -
> >  	i2c_unregister_device(adv7511->i2c_packet);
> >  	i2c_unregister_device(adv7511->i2c_edid);
> >  
> 
> -- 
> Regards,
> 
> Laurent Pinchart

-- 
Regards,

Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/3] drm/bridge/adv7511: enable CEC connector info
  2019-08-23 19:01     ` Laurent Pinchart
@ 2019-08-26  9:01       ` Hans Verkuil
  2019-08-26 10:13         ` Laurent Pinchart
  0 siblings, 1 reply; 11+ messages in thread
From: Hans Verkuil @ 2019-08-26  9:01 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Archit Taneja, Maxime Ripard, Neil Armstrong, Boris Brezillon,
	Maling list - DRI developers, Dariusz Marcinkiewicz, linux-media

On 8/23/19 9:01 PM, Laurent Pinchart wrote:
> (And CC'ing Andrzej Hajda and Neil Armstrong as the new DRM bridge
> maintainers, as well as Boris Brezillon, to make sure they're aware of
> the problem)
> 
> I would really appreciate if we could delay merging this series and
> other similar changes until we find a proper solution.
> 
> On Fri, Aug 23, 2019 at 09:58:47PM +0300, Laurent Pinchart wrote:
>> Hi Hans,
>>
>> Thank you for the patch.
>>
>> On Fri, Aug 23, 2019 at 01:24:27PM +0200, Hans Verkuil wrote:
>>> Set the connector info to help userspace associate the CEC adapter
>>> with the HDMI connector.
>>>
>>> This required that the cec initialization and unregistering the
>>> CEC adapter takes place in the bridge attach and detach ops.
>>>
>>> Tested on an R-Car Koelsch board.
>>>
>>> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
>>> Tested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
>>> ---
>>>  drivers/gpu/drm/bridge/adv7511/adv7511_cec.c |  7 ++++++-
>>>  drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 22 ++++++++++----------
>>>  2 files changed, 17 insertions(+), 12 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c b/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
>>> index a20a45c0b353..accf5e232396 100644
>>> --- a/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
>>> +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
>>> @@ -302,6 +302,7 @@ static int adv7511_cec_parse_dt(struct device *dev, struct adv7511 *adv7511)
>>>  
>>>  int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511)
>>>  {
>>> +	struct cec_connector_info conn_info;
>>>  	unsigned int offset = adv7511->type == ADV7533 ?
>>>  						ADV7533_REG_CEC_OFFSET : 0;
>>>  	int ret = adv7511_cec_parse_dt(dev, adv7511);
>>> @@ -310,7 +311,8 @@ int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511)
>>>  		goto err_cec_parse_dt;
>>>  
>>>  	adv7511->cec_adap = cec_allocate_adapter(&adv7511_cec_adap_ops,
>>> -		adv7511, dev_name(dev), CEC_CAP_DEFAULTS, ADV7511_MAX_ADDRS);
>>> +		adv7511, dev_name(dev),
>>> +		CEC_CAP_DEFAULTS | CEC_CAP_CONNECTOR_INFO, ADV7511_MAX_ADDRS);
>>>  	if (IS_ERR(adv7511->cec_adap)) {
>>>  		ret = PTR_ERR(adv7511->cec_adap);
>>>  		goto err_cec_alloc;
>>> @@ -331,6 +333,9 @@ int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511)
>>>  		     ADV7511_REG_CEC_CLK_DIV + offset,
>>>  		     ((adv7511->cec_clk_freq / 750000) - 1) << 2);
>>>  
>>> +	cec_fill_conn_info_from_drm(&conn_info, &adv7511->connector);
>>> +	cec_s_conn_info(adv7511->cec_adap, &conn_info);
>>
>> I'm painfully trying to decouple bridges and connectors, if we keep
>> merging patches that go in the opposite direction, I'll never manage to
>> complete this :-(
>>
>> Bridges are moving to a model where they won't create connectors
>> themselves, so any new access to drm_connector contained in a bridge
>> structure is a no-go I'm afraid (I'm replying to this patch as I know
>> this driver best, but this comment applies to the other two patches in
>> the series as well).
>>
>> Here's what I wrote in a private e-mail, regarding similar changes for
>> the omapdrm driver.
>>
>> --------
>> Please have a look at "[PATCH 00/60] drm/omap: Replace custom display
>> drivers with drm_bridge and drm_panel", available in a new version at
>>
>> 	git://linuxtv.org/pinchartl/media.git omapdrm/bridge/devel
>>
>> (I will post v2 soon)
>>
>> The patches show the direction the omapdrm driver is taking. The goal is
>> to decouple connectors from bridges, which I'm afraid will have an
>> impact on associating drm_connector with a CEC adapter. This should be
>> implemented through new drm_bridge operations, as bridges, when created,
>> will not create drm_connector anymore.
>>
>> I've solved a similar problem related to associating DRM connectors with
>> an I2C adapter for DDC. Please see the drm_bridge_connector_init()
>> function and how the DDC adapter is handled. Something similar could be
>> done for CEC.
>> --------
>>
>> Since then v2 has been posted ("[PATCH v2 00/50] drm/omap: Replace
>> custom display drivers with drm_bridge and drm_panel") and v3 is in
>> preparation.
>>
>> So, please, let's both go in the right direction and solve the problem
>> properly for CEC.

I don't mind waiting one kernel cycle, but not longer. This CEC feature is
ready to be rolled out, so I am not willing to wait a long time for all
of this to land. I can help test CEC once you are going to roll this out
for all drm drivers (except for the sti SoC, since I don't have any HW).

So do you think this will land for 5.5? If yes, then I'll wait.

Regards,

	Hans

>>
>>> +
>>>  	ret = cec_register_adapter(adv7511->cec_adap, dev);
>>>  	if (ret)
>>>  		goto err_cec_register;
>>> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
>>> index f6d2681f6927..bbcb996c4d4f 100644
>>> --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
>>> +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
>>> @@ -881,14 +881,24 @@ static int adv7511_bridge_attach(struct drm_bridge *bridge)
>>>  		regmap_write(adv->regmap, ADV7511_REG_INT_ENABLE(0),
>>>  			     ADV7511_INT0_HPD);
>>>  
>>> +	if (!ret)
>>> +		ret = adv7511_cec_init(&adv->i2c_main->dev, adv);
>>>  	return ret;
>>>  }
>>>  
>>> +static void adv7511_bridge_detach(struct drm_bridge *bridge)
>>> +{
>>> +	struct adv7511 *adv = bridge_to_adv7511(bridge);
>>> +
>>> +	cec_unregister_adapter(adv->cec_adap);
>>> +}
>>> +
>>>  static const struct drm_bridge_funcs adv7511_bridge_funcs = {
>>>  	.enable = adv7511_bridge_enable,
>>>  	.disable = adv7511_bridge_disable,
>>>  	.mode_set = adv7511_bridge_mode_set,
>>>  	.attach = adv7511_bridge_attach,
>>> +	.detach = adv7511_bridge_detach,
>>>  };
>>>  
>>>  /* -----------------------------------------------------------------------------
>>> @@ -1202,7 +1212,7 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
>>>  						IRQF_ONESHOT, dev_name(dev),
>>>  						adv7511);
>>>  		if (ret)
>>> -			goto err_unregister_cec;
>>> +			goto err_i2c_unregister_packet;
>>>  	}
>>>  
>>>  	adv7511_power_off(adv7511);
>>> @@ -1212,10 +1222,6 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
>>>  	if (adv7511->type == ADV7511)
>>>  		adv7511_set_link_config(adv7511, &link_config);
>>>  
>>> -	ret = adv7511_cec_init(dev, adv7511);
>>> -	if (ret)
>>> -		goto err_unregister_cec;
>>> -
>>>  	adv7511->bridge.funcs = &adv7511_bridge_funcs;
>>>  	adv7511->bridge.of_node = dev->of_node;
>>>  
>>> @@ -1224,10 +1230,6 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
>>>  	adv7511_audio_init(dev, adv7511);
>>>  	return 0;
>>>  
>>> -err_unregister_cec:
>>> -	i2c_unregister_device(adv7511->i2c_cec);
>>> -	if (adv7511->cec_clk)
>>> -		clk_disable_unprepare(adv7511->cec_clk);
>>>  err_i2c_unregister_packet:
>>>  	i2c_unregister_device(adv7511->i2c_packet);
>>>  err_i2c_unregister_edid:
>>> @@ -1254,8 +1256,6 @@ static int adv7511_remove(struct i2c_client *i2c)
>>>  
>>>  	adv7511_audio_exit(adv7511);
>>>  
>>> -	cec_unregister_adapter(adv7511->cec_adap);
>>> -
>>>  	i2c_unregister_device(adv7511->i2c_packet);
>>>  	i2c_unregister_device(adv7511->i2c_edid);
>>>  
>>
>> -- 
>> Regards,
>>
>> Laurent Pinchart
> 

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/3] drm/bridge/adv7511: enable CEC connector info
  2019-08-26  9:01       ` Hans Verkuil
@ 2019-08-26 10:13         ` Laurent Pinchart
  2019-08-26 10:16           ` Hans Verkuil
  0 siblings, 1 reply; 11+ messages in thread
From: Laurent Pinchart @ 2019-08-26 10:13 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: Archit Taneja, Maxime Ripard, Neil Armstrong, Boris Brezillon,
	Maling list - DRI developers, Dariusz Marcinkiewicz, linux-media

Hi Hans,

On Mon, Aug 26, 2019 at 11:01:40AM +0200, Hans Verkuil wrote:
> On 8/23/19 9:01 PM, Laurent Pinchart wrote:
> > (And CC'ing Andrzej Hajda and Neil Armstrong as the new DRM bridge
> > maintainers, as well as Boris Brezillon, to make sure they're aware of
> > the problem)
> > 
> > I would really appreciate if we could delay merging this series and
> > other similar changes until we find a proper solution.
> > 
> > On Fri, Aug 23, 2019 at 09:58:47PM +0300, Laurent Pinchart wrote:
> >> On Fri, Aug 23, 2019 at 01:24:27PM +0200, Hans Verkuil wrote:
> >>> Set the connector info to help userspace associate the CEC adapter
> >>> with the HDMI connector.
> >>>
> >>> This required that the cec initialization and unregistering the
> >>> CEC adapter takes place in the bridge attach and detach ops.
> >>>
> >>> Tested on an R-Car Koelsch board.
> >>>
> >>> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> >>> Tested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> >>> ---
> >>>  drivers/gpu/drm/bridge/adv7511/adv7511_cec.c |  7 ++++++-
> >>>  drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 22 ++++++++++----------
> >>>  2 files changed, 17 insertions(+), 12 deletions(-)
> >>>
> >>> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c b/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
> >>> index a20a45c0b353..accf5e232396 100644
> >>> --- a/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
> >>> +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
> >>> @@ -302,6 +302,7 @@ static int adv7511_cec_parse_dt(struct device *dev, struct adv7511 *adv7511)
> >>>  
> >>>  int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511)
> >>>  {
> >>> +	struct cec_connector_info conn_info;
> >>>  	unsigned int offset = adv7511->type == ADV7533 ?
> >>>  						ADV7533_REG_CEC_OFFSET : 0;
> >>>  	int ret = adv7511_cec_parse_dt(dev, adv7511);
> >>> @@ -310,7 +311,8 @@ int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511)
> >>>  		goto err_cec_parse_dt;
> >>>  
> >>>  	adv7511->cec_adap = cec_allocate_adapter(&adv7511_cec_adap_ops,
> >>> -		adv7511, dev_name(dev), CEC_CAP_DEFAULTS, ADV7511_MAX_ADDRS);
> >>> +		adv7511, dev_name(dev),
> >>> +		CEC_CAP_DEFAULTS | CEC_CAP_CONNECTOR_INFO, ADV7511_MAX_ADDRS);
> >>>  	if (IS_ERR(adv7511->cec_adap)) {
> >>>  		ret = PTR_ERR(adv7511->cec_adap);
> >>>  		goto err_cec_alloc;
> >>> @@ -331,6 +333,9 @@ int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511)
> >>>  		     ADV7511_REG_CEC_CLK_DIV + offset,
> >>>  		     ((adv7511->cec_clk_freq / 750000) - 1) << 2);
> >>>  
> >>> +	cec_fill_conn_info_from_drm(&conn_info, &adv7511->connector);
> >>> +	cec_s_conn_info(adv7511->cec_adap, &conn_info);
> >>
> >> I'm painfully trying to decouple bridges and connectors, if we keep
> >> merging patches that go in the opposite direction, I'll never manage to
> >> complete this :-(
> >>
> >> Bridges are moving to a model where they won't create connectors
> >> themselves, so any new access to drm_connector contained in a bridge
> >> structure is a no-go I'm afraid (I'm replying to this patch as I know
> >> this driver best, but this comment applies to the other two patches in
> >> the series as well).
> >>
> >> Here's what I wrote in a private e-mail, regarding similar changes for
> >> the omapdrm driver.
> >>
> >> --------
> >> Please have a look at "[PATCH 00/60] drm/omap: Replace custom display
> >> drivers with drm_bridge and drm_panel", available in a new version at
> >>
> >> 	git://linuxtv.org/pinchartl/media.git omapdrm/bridge/devel
> >>
> >> (I will post v2 soon)
> >>
> >> The patches show the direction the omapdrm driver is taking. The goal is
> >> to decouple connectors from bridges, which I'm afraid will have an
> >> impact on associating drm_connector with a CEC adapter. This should be
> >> implemented through new drm_bridge operations, as bridges, when created,
> >> will not create drm_connector anymore.
> >>
> >> I've solved a similar problem related to associating DRM connectors with
> >> an I2C adapter for DDC. Please see the drm_bridge_connector_init()
> >> function and how the DDC adapter is handled. Something similar could be
> >> done for CEC.
> >> --------
> >>
> >> Since then v2 has been posted ("[PATCH v2 00/50] drm/omap: Replace
> >> custom display drivers with drm_bridge and drm_panel") and v3 is in
> >> preparation.
> >>
> >> So, please, let's both go in the right direction and solve the problem
> >> properly for CEC.
> 
> I don't mind waiting one kernel cycle, but not longer. This CEC feature is
> ready to be rolled out, so I am not willing to wait a long time for all
> of this to land. I can help test CEC once you are going to roll this out
> for all drm drivers (except for the sti SoC, since I don't have any HW).
> 
> So do you think this will land for 5.5? If yes, then I'll wait.

I really hope so !

Would you be able to try to implement this feature for the OMAP4 based
on my omapdrm/bridge/devel branch ? The other drivers should follow the
same path, so that would be a good exercise.

> >>> +
> >>>  	ret = cec_register_adapter(adv7511->cec_adap, dev);
> >>>  	if (ret)
> >>>  		goto err_cec_register;
> >>> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> >>> index f6d2681f6927..bbcb996c4d4f 100644
> >>> --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> >>> +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> >>> @@ -881,14 +881,24 @@ static int adv7511_bridge_attach(struct drm_bridge *bridge)
> >>>  		regmap_write(adv->regmap, ADV7511_REG_INT_ENABLE(0),
> >>>  			     ADV7511_INT0_HPD);
> >>>  
> >>> +	if (!ret)
> >>> +		ret = adv7511_cec_init(&adv->i2c_main->dev, adv);
> >>>  	return ret;
> >>>  }
> >>>  
> >>> +static void adv7511_bridge_detach(struct drm_bridge *bridge)
> >>> +{
> >>> +	struct adv7511 *adv = bridge_to_adv7511(bridge);
> >>> +
> >>> +	cec_unregister_adapter(adv->cec_adap);
> >>> +}
> >>> +
> >>>  static const struct drm_bridge_funcs adv7511_bridge_funcs = {
> >>>  	.enable = adv7511_bridge_enable,
> >>>  	.disable = adv7511_bridge_disable,
> >>>  	.mode_set = adv7511_bridge_mode_set,
> >>>  	.attach = adv7511_bridge_attach,
> >>> +	.detach = adv7511_bridge_detach,
> >>>  };
> >>>  
> >>>  /* -----------------------------------------------------------------------------
> >>> @@ -1202,7 +1212,7 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
> >>>  						IRQF_ONESHOT, dev_name(dev),
> >>>  						adv7511);
> >>>  		if (ret)
> >>> -			goto err_unregister_cec;
> >>> +			goto err_i2c_unregister_packet;
> >>>  	}
> >>>  
> >>>  	adv7511_power_off(adv7511);
> >>> @@ -1212,10 +1222,6 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
> >>>  	if (adv7511->type == ADV7511)
> >>>  		adv7511_set_link_config(adv7511, &link_config);
> >>>  
> >>> -	ret = adv7511_cec_init(dev, adv7511);
> >>> -	if (ret)
> >>> -		goto err_unregister_cec;
> >>> -
> >>>  	adv7511->bridge.funcs = &adv7511_bridge_funcs;
> >>>  	adv7511->bridge.of_node = dev->of_node;
> >>>  
> >>> @@ -1224,10 +1230,6 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
> >>>  	adv7511_audio_init(dev, adv7511);
> >>>  	return 0;
> >>>  
> >>> -err_unregister_cec:
> >>> -	i2c_unregister_device(adv7511->i2c_cec);
> >>> -	if (adv7511->cec_clk)
> >>> -		clk_disable_unprepare(adv7511->cec_clk);
> >>>  err_i2c_unregister_packet:
> >>>  	i2c_unregister_device(adv7511->i2c_packet);
> >>>  err_i2c_unregister_edid:
> >>> @@ -1254,8 +1256,6 @@ static int adv7511_remove(struct i2c_client *i2c)
> >>>  
> >>>  	adv7511_audio_exit(adv7511);
> >>>  
> >>> -	cec_unregister_adapter(adv7511->cec_adap);
> >>> -
> >>>  	i2c_unregister_device(adv7511->i2c_packet);
> >>>  	i2c_unregister_device(adv7511->i2c_edid);
> >>>  

-- 
Regards,

Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/3] drm/bridge/adv7511: enable CEC connector info
  2019-08-26 10:13         ` Laurent Pinchart
@ 2019-08-26 10:16           ` Hans Verkuil
  0 siblings, 0 replies; 11+ messages in thread
From: Hans Verkuil @ 2019-08-26 10:16 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Archit Taneja, Maxime Ripard, Neil Armstrong, Boris Brezillon,
	Maling list - DRI developers, Dariusz Marcinkiewicz, linux-media

On 8/26/19 12:13 PM, Laurent Pinchart wrote:
> Hi Hans,
> 
> On Mon, Aug 26, 2019 at 11:01:40AM +0200, Hans Verkuil wrote:
>> On 8/23/19 9:01 PM, Laurent Pinchart wrote:
>>> (And CC'ing Andrzej Hajda and Neil Armstrong as the new DRM bridge
>>> maintainers, as well as Boris Brezillon, to make sure they're aware of
>>> the problem)
>>>
>>> I would really appreciate if we could delay merging this series and
>>> other similar changes until we find a proper solution.
>>>
>>> On Fri, Aug 23, 2019 at 09:58:47PM +0300, Laurent Pinchart wrote:
>>>> On Fri, Aug 23, 2019 at 01:24:27PM +0200, Hans Verkuil wrote:
>>>>> Set the connector info to help userspace associate the CEC adapter
>>>>> with the HDMI connector.
>>>>>
>>>>> This required that the cec initialization and unregistering the
>>>>> CEC adapter takes place in the bridge attach and detach ops.
>>>>>
>>>>> Tested on an R-Car Koelsch board.
>>>>>
>>>>> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
>>>>> Tested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
>>>>> ---
>>>>>  drivers/gpu/drm/bridge/adv7511/adv7511_cec.c |  7 ++++++-
>>>>>  drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 22 ++++++++++----------
>>>>>  2 files changed, 17 insertions(+), 12 deletions(-)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c b/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
>>>>> index a20a45c0b353..accf5e232396 100644
>>>>> --- a/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
>>>>> +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
>>>>> @@ -302,6 +302,7 @@ static int adv7511_cec_parse_dt(struct device *dev, struct adv7511 *adv7511)
>>>>>  
>>>>>  int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511)
>>>>>  {
>>>>> +	struct cec_connector_info conn_info;
>>>>>  	unsigned int offset = adv7511->type == ADV7533 ?
>>>>>  						ADV7533_REG_CEC_OFFSET : 0;
>>>>>  	int ret = adv7511_cec_parse_dt(dev, adv7511);
>>>>> @@ -310,7 +311,8 @@ int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511)
>>>>>  		goto err_cec_parse_dt;
>>>>>  
>>>>>  	adv7511->cec_adap = cec_allocate_adapter(&adv7511_cec_adap_ops,
>>>>> -		adv7511, dev_name(dev), CEC_CAP_DEFAULTS, ADV7511_MAX_ADDRS);
>>>>> +		adv7511, dev_name(dev),
>>>>> +		CEC_CAP_DEFAULTS | CEC_CAP_CONNECTOR_INFO, ADV7511_MAX_ADDRS);
>>>>>  	if (IS_ERR(adv7511->cec_adap)) {
>>>>>  		ret = PTR_ERR(adv7511->cec_adap);
>>>>>  		goto err_cec_alloc;
>>>>> @@ -331,6 +333,9 @@ int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511)
>>>>>  		     ADV7511_REG_CEC_CLK_DIV + offset,
>>>>>  		     ((adv7511->cec_clk_freq / 750000) - 1) << 2);
>>>>>  
>>>>> +	cec_fill_conn_info_from_drm(&conn_info, &adv7511->connector);
>>>>> +	cec_s_conn_info(adv7511->cec_adap, &conn_info);
>>>>
>>>> I'm painfully trying to decouple bridges and connectors, if we keep
>>>> merging patches that go in the opposite direction, I'll never manage to
>>>> complete this :-(
>>>>
>>>> Bridges are moving to a model where they won't create connectors
>>>> themselves, so any new access to drm_connector contained in a bridge
>>>> structure is a no-go I'm afraid (I'm replying to this patch as I know
>>>> this driver best, but this comment applies to the other two patches in
>>>> the series as well).
>>>>
>>>> Here's what I wrote in a private e-mail, regarding similar changes for
>>>> the omapdrm driver.
>>>>
>>>> --------
>>>> Please have a look at "[PATCH 00/60] drm/omap: Replace custom display
>>>> drivers with drm_bridge and drm_panel", available in a new version at
>>>>
>>>> 	git://linuxtv.org/pinchartl/media.git omapdrm/bridge/devel
>>>>
>>>> (I will post v2 soon)
>>>>
>>>> The patches show the direction the omapdrm driver is taking. The goal is
>>>> to decouple connectors from bridges, which I'm afraid will have an
>>>> impact on associating drm_connector with a CEC adapter. This should be
>>>> implemented through new drm_bridge operations, as bridges, when created,
>>>> will not create drm_connector anymore.
>>>>
>>>> I've solved a similar problem related to associating DRM connectors with
>>>> an I2C adapter for DDC. Please see the drm_bridge_connector_init()
>>>> function and how the DDC adapter is handled. Something similar could be
>>>> done for CEC.
>>>> --------
>>>>
>>>> Since then v2 has been posted ("[PATCH v2 00/50] drm/omap: Replace
>>>> custom display drivers with drm_bridge and drm_panel") and v3 is in
>>>> preparation.
>>>>
>>>> So, please, let's both go in the right direction and solve the problem
>>>> properly for CEC.
>>
>> I don't mind waiting one kernel cycle, but not longer. This CEC feature is
>> ready to be rolled out, so I am not willing to wait a long time for all
>> of this to land. I can help test CEC once you are going to roll this out
>> for all drm drivers (except for the sti SoC, since I don't have any HW).
>>
>> So do you think this will land for 5.5? If yes, then I'll wait.
> 
> I really hope so !
> 
> Would you be able to try to implement this feature for the OMAP4 based
> on my omapdrm/bridge/devel branch ? The other drivers should follow the
> same path, so that would be a good exercise.

I can try that later this week.

Regards,

	Hans

> 
>>>>> +
>>>>>  	ret = cec_register_adapter(adv7511->cec_adap, dev);
>>>>>  	if (ret)
>>>>>  		goto err_cec_register;
>>>>> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
>>>>> index f6d2681f6927..bbcb996c4d4f 100644
>>>>> --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
>>>>> +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
>>>>> @@ -881,14 +881,24 @@ static int adv7511_bridge_attach(struct drm_bridge *bridge)
>>>>>  		regmap_write(adv->regmap, ADV7511_REG_INT_ENABLE(0),
>>>>>  			     ADV7511_INT0_HPD);
>>>>>  
>>>>> +	if (!ret)
>>>>> +		ret = adv7511_cec_init(&adv->i2c_main->dev, adv);
>>>>>  	return ret;
>>>>>  }
>>>>>  
>>>>> +static void adv7511_bridge_detach(struct drm_bridge *bridge)
>>>>> +{
>>>>> +	struct adv7511 *adv = bridge_to_adv7511(bridge);
>>>>> +
>>>>> +	cec_unregister_adapter(adv->cec_adap);
>>>>> +}
>>>>> +
>>>>>  static const struct drm_bridge_funcs adv7511_bridge_funcs = {
>>>>>  	.enable = adv7511_bridge_enable,
>>>>>  	.disable = adv7511_bridge_disable,
>>>>>  	.mode_set = adv7511_bridge_mode_set,
>>>>>  	.attach = adv7511_bridge_attach,
>>>>> +	.detach = adv7511_bridge_detach,
>>>>>  };
>>>>>  
>>>>>  /* -----------------------------------------------------------------------------
>>>>> @@ -1202,7 +1212,7 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
>>>>>  						IRQF_ONESHOT, dev_name(dev),
>>>>>  						adv7511);
>>>>>  		if (ret)
>>>>> -			goto err_unregister_cec;
>>>>> +			goto err_i2c_unregister_packet;
>>>>>  	}
>>>>>  
>>>>>  	adv7511_power_off(adv7511);
>>>>> @@ -1212,10 +1222,6 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
>>>>>  	if (adv7511->type == ADV7511)
>>>>>  		adv7511_set_link_config(adv7511, &link_config);
>>>>>  
>>>>> -	ret = adv7511_cec_init(dev, adv7511);
>>>>> -	if (ret)
>>>>> -		goto err_unregister_cec;
>>>>> -
>>>>>  	adv7511->bridge.funcs = &adv7511_bridge_funcs;
>>>>>  	adv7511->bridge.of_node = dev->of_node;
>>>>>  
>>>>> @@ -1224,10 +1230,6 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
>>>>>  	adv7511_audio_init(dev, adv7511);
>>>>>  	return 0;
>>>>>  
>>>>> -err_unregister_cec:
>>>>> -	i2c_unregister_device(adv7511->i2c_cec);
>>>>> -	if (adv7511->cec_clk)
>>>>> -		clk_disable_unprepare(adv7511->cec_clk);
>>>>>  err_i2c_unregister_packet:
>>>>>  	i2c_unregister_device(adv7511->i2c_packet);
>>>>>  err_i2c_unregister_edid:
>>>>> @@ -1254,8 +1256,6 @@ static int adv7511_remove(struct i2c_client *i2c)
>>>>>  
>>>>>  	adv7511_audio_exit(adv7511);
>>>>>  
>>>>> -	cec_unregister_adapter(adv7511->cec_adap);
>>>>> -
>>>>>  	i2c_unregister_device(adv7511->i2c_packet);
>>>>>  	i2c_unregister_device(adv7511->i2c_edid);
>>>>>  
> 

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/3] drm/sun4i/sun4i_hdmi_enc: call cec_s_conn_info()
  2019-08-23 11:24 ` [PATCH 2/3] drm/sun4i/sun4i_hdmi_enc: call cec_s_conn_info() Hans Verkuil
@ 2019-08-28  8:17   ` Maxime Ripard
  0 siblings, 0 replies; 11+ messages in thread
From: Maxime Ripard @ 2019-08-28  8:17 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: Archit Taneja, Maling list - DRI developers, Laurent Pinchart,
	Dariusz Marcinkiewicz, linux-media


[-- Attachment #1.1: Type: text/plain, Size: 471 bytes --]

On Fri, Aug 23, 2019 at 01:24:26PM +0200, Hans Verkuil wrote:
> Set the connector info for the CEC adapter. This helps
> userspace to associate the CEC device with the HDMI connector.
>
> Tested on a Cubieboard.
>
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> Tested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>

Acked-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-08-28  8:17 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-23 11:24 [PATCH 0/3] drm: cec: call cec_s_conn_info() Hans Verkuil
2019-08-23 11:24 ` [PATCH 1/3] drm/vc4/vc4_hdmi: fill in connector info Hans Verkuil
2019-08-23 18:48   ` Eric Anholt
2019-08-23 11:24 ` [PATCH 2/3] drm/sun4i/sun4i_hdmi_enc: call cec_s_conn_info() Hans Verkuil
2019-08-28  8:17   ` Maxime Ripard
2019-08-23 11:24 ` [PATCH 3/3] drm/bridge/adv7511: enable CEC connector info Hans Verkuil
2019-08-23 18:58   ` Laurent Pinchart
2019-08-23 19:01     ` Laurent Pinchart
2019-08-26  9:01       ` Hans Verkuil
2019-08-26 10:13         ` Laurent Pinchart
2019-08-26 10:16           ` Hans Verkuil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).