linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
To: Dariusz Marcinkiewicz <darekm@google.com>,
	dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org
Cc: David Airlie <airlied@linux.ie>,
	Russell King <linux@armlinux.org.uk>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 5/9] drm: tda998x: use cec_notifier_conn_(un)register
Date: Mon, 19 Aug 2019 11:30:27 +0200	[thread overview]
Message-ID: <7a00ef8f-5b63-bc43-4f76-b0c4773b9117@xs4all.nl> (raw)
In-Reply-To: <20190814104520.6001-6-darekm@google.com>

On 8/14/19 12:45 PM, Dariusz Marcinkiewicz wrote:
> Use the new cec_notifier_conn_(un)register() functions to
> (un)register the notifier for the HDMI connector, and fill
> in the cec_connector_info.
> 
> Changes since v6:
>         - move cec_notifier_conn_unregister to tda998x_bridge_detach,
> 	- add a mutex protecting accesses to a CEC notifier.
> Changes since v2:
> 	- cec_notifier_phys_addr_invalidate where appropriate,
> 	- don't check for NULL notifier before calling
> 	cec_notifier_conn_unregister.
> Changes since v1:
> 	Add memory barrier to make sure that the notifier
> 	becomes visible to the irq thread once it is
> 	fully constructed.
> 
> Signed-off-by: Dariusz Marcinkiewicz <darekm@google.com>
> ---
>  drivers/gpu/drm/i2c/tda998x_drv.c | 36 +++++++++++++++++++++----------
>  1 file changed, 25 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c
> index 61e042918a7fc..643480415473f 100644
> --- a/drivers/gpu/drm/i2c/tda998x_drv.c
> +++ b/drivers/gpu/drm/i2c/tda998x_drv.c
> @@ -82,6 +82,8 @@ struct tda998x_priv {
>  	u8 audio_port_enable[AUDIO_ROUTE_NUM];
>  	struct tda9950_glue cec_glue;
>  	struct gpio_desc *calib;
> +
> +	struct mutex cec_notifiy_mutex;

Typo: notifiy -> notify

Regards,

	Hans

>  	struct cec_notifier *cec_notify;
>  };
>  
> @@ -805,8 +807,11 @@ static irqreturn_t tda998x_irq_thread(int irq, void *data)
>  				tda998x_edid_delay_start(priv);
>  			} else {
>  				schedule_work(&priv->detect_work);
> -				cec_notifier_set_phys_addr(priv->cec_notify,
> -						   CEC_PHYS_ADDR_INVALID);
> +
> +				mutex_lock(&priv->cec_notifiy_mutex);
> +				cec_notifier_phys_addr_invalidate(
> +						priv->cec_notify);
> +				mutex_unlock(&priv->cec_notifiy_mutex);
>  			}
>  
>  			handled = true;
> @@ -1331,6 +1336,8 @@ static int tda998x_connector_init(struct tda998x_priv *priv,
>  				  struct drm_device *drm)
>  {
>  	struct drm_connector *connector = &priv->connector;
> +	struct cec_connector_info conn_info;
> +	struct cec_notifier *notifier;
>  	int ret;
>  
>  	connector->interlace_allowed = 1;
> @@ -1347,6 +1354,16 @@ static int tda998x_connector_init(struct tda998x_priv *priv,
>  	if (ret)
>  		return ret;
>  
> +	cec_fill_conn_info_from_drm(&conn_info, connector);
> +
> +	notifier = cec_notifier_conn_register(priv->cec_glue.parent,
> +					      NULL, &conn_info);
> +		return -ENOMEM;
> +
> +	mutex_lock(&priv->cec_notifiy_mutex);
> +	priv->cec_notify = notifier;
> +	mutex_unlock(&priv->cec_notifiy_mutex);
> +
>  	drm_connector_attach_encoder(&priv->connector,
>  				     priv->bridge.encoder);
>  
> @@ -1366,6 +1383,11 @@ static void tda998x_bridge_detach(struct drm_bridge *bridge)
>  {
>  	struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge);
>  
> +	mutex_lock(&priv->cec_notifiy_mutex);
> +	cec_notifier_conn_unregister(priv->cec_notify);
> +	priv->cec_notify = NULL;
> +	mutex_unlock(&priv->cec_notifiy_mutex);
> +
>  	drm_connector_cleanup(&priv->connector);
>  }
>  
> @@ -1789,9 +1811,6 @@ static void tda998x_destroy(struct device *dev)
>  	cancel_work_sync(&priv->detect_work);
>  
>  	i2c_unregister_device(priv->cec);
> -
> -	if (priv->cec_notify)
> -		cec_notifier_put(priv->cec_notify);
>  }
>  
>  static int tda998x_create(struct device *dev)
> @@ -1812,6 +1831,7 @@ static int tda998x_create(struct device *dev)
>  	mutex_init(&priv->mutex);	/* protect the page access */
>  	mutex_init(&priv->audio_mutex); /* protect access from audio thread */
>  	mutex_init(&priv->edid_mutex);
> +	mutex_init(&priv->cec_notifiy_mutex);
>  	INIT_LIST_HEAD(&priv->bridge.list);
>  	init_waitqueue_head(&priv->edid_delay_waitq);
>  	timer_setup(&priv->edid_delay_timer, tda998x_edid_delay_done, 0);
> @@ -1916,12 +1936,6 @@ static int tda998x_create(struct device *dev)
>  		cec_write(priv, REG_CEC_RXSHPDINTENA, CEC_RXSHPDLEV_HPD);
>  	}
>  
> -	priv->cec_notify = cec_notifier_get(dev);
> -	if (!priv->cec_notify) {
> -		ret = -ENOMEM;
> -		goto fail;
> -	}
> -
>  	priv->cec_glue.parent = dev;
>  	priv->cec_glue.data = priv;
>  	priv->cec_glue.init = tda998x_cec_hook_init;
> 


  reply	other threads:[~2019-08-19  9:30 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-14 10:44 [PATCH v7 0/9] drm: cec: convert DRM drivers to the new notifier API Dariusz Marcinkiewicz
2019-08-14 10:44 ` [PATCH v7 1/9] drm_dp_cec: add connector info support Dariusz Marcinkiewicz
2019-08-15 18:10   ` Lyude Paul
2019-08-26  9:05     ` Ben Skeggs
2019-08-22  8:08   ` Hans Verkuil
2019-08-26  9:00     ` Hans Verkuil
2019-08-28 15:05   ` Ville Syrjälä
2019-08-14 10:45 ` [PATCH v7 2/9] drm/i915/intel_hdmi: use cec_notifier_conn_(un)register Dariusz Marcinkiewicz
2019-08-22  8:03   ` Hans Verkuil
2019-08-26  8:59     ` Hans Verkuil
2019-08-26 12:08   ` Ville Syrjälä
2019-08-14 10:45 ` [PATCH v7 3/9] dw-hdmi-cec: use cec_notifier_cec_adap_(un)register Dariusz Marcinkiewicz
2019-08-19 14:35   ` Neil Armstrong
2019-08-20  7:48     ` Neil Armstrong
2019-08-14 10:45 ` [PATCH v7 4/9] tda9950: " Dariusz Marcinkiewicz
2019-08-14 10:45 ` [PATCH v7 5/9] drm: tda998x: use cec_notifier_conn_(un)register Dariusz Marcinkiewicz
2019-08-19  9:30   ` Hans Verkuil [this message]
2019-08-19 11:22   ` [PATCH v7.1 " Dariusz Marcinkiewicz
2019-08-28  7:15     ` [PATCH v7.2 " Dariusz Marcinkiewicz
2019-08-25 13:12   ` [PATCH v7 " Hans Verkuil
2019-08-28  7:18     ` Dariusz Marcinkiewicz
2019-08-14 10:45 ` [PATCH v7 6/9] drm: sti: " Dariusz Marcinkiewicz
2019-08-19  9:34   ` Hans Verkuil
2019-08-22  8:11   ` Hans Verkuil
2019-09-02 13:11     ` Benjamin Gaignard
2019-08-14 10:45 ` [PATCH v7 7/9] drm: tegra: " Dariusz Marcinkiewicz
2019-08-19  9:33   ` Hans Verkuil
2019-08-28  8:09   ` Hans Verkuil
2019-08-28  9:38     ` Thierry Reding
2019-08-28 10:06       ` Hans Verkuil
2019-08-28 11:54         ` Thierry Reding
2019-10-04  8:48           ` Hans Verkuil
2019-10-14  7:51             ` Hans Verkuil
2019-08-28  9:36   ` Thierry Reding
2019-10-14 12:17   ` Thierry Reding
2019-08-14 10:45 ` [PATCH v7 8/9] drm: dw-hdmi: " Dariusz Marcinkiewicz
2019-08-19  9:32   ` Hans Verkuil
2019-08-19 14:05     ` Hans Verkuil
2019-08-19 14:38       ` Neil Armstrong
2019-08-19 14:41         ` Hans Verkuil
2019-08-19 14:47           ` Neil Armstrong
2019-08-20  7:48             ` Neil Armstrong
2019-08-14 10:45 ` [PATCH v7 9/9] drm: exynos: exynos_hdmi: " Dariusz Marcinkiewicz
2019-08-19  9:32   ` Hans Verkuil
2019-08-28  8:39   ` Sylwester Nawrocki
2019-08-28 12:34     ` [PATCH v7.1 " Dariusz Marcinkiewicz
2019-08-28 12:38     ` [PATCH v7 " Dariusz Marcinkiewicz
2019-08-19  9:38 ` [PATCH v7 0/9] drm: cec: convert DRM drivers to the new notifier API Hans Verkuil
2019-08-19 11:28   ` Dariusz Marcinkiewicz
2019-08-19 12:00     ` Hans Verkuil
2019-08-19 14:48   ` Neil Armstrong
2019-08-19 14:55     ` Hans Verkuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7a00ef8f-5b63-bc43-4f76-b0c4773b9117@xs4all.nl \
    --to=hverkuil-cisco@xs4all.nl \
    --cc=airlied@linux.ie \
    --cc=darekm@google.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).