From patchwork Thu Oct 17 07:28:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 11199391 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E6030112C for ; Fri, 18 Oct 2019 18:38:00 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CE26821835 for ; Fri, 18 Oct 2019 18:38:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE26821835 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xs4all.nl Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5CC716EB8B; Fri, 18 Oct 2019 18:37:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lb2-smtp-cloud8.xs4all.net (lb2-smtp-cloud8.xs4all.net [194.109.24.25]) by gabe.freedesktop.org (Postfix) with ESMTPS id C91536E9FA for ; Thu, 17 Oct 2019 07:28:48 +0000 (UTC) Received: from tschai.fritz.box ([46.9.232.237]) by smtp-cloud8.xs4all.net with ESMTPA id L0DCiNIhkPduvL0DHitUWA; Thu, 17 Oct 2019 09:28:47 +0200 From: Hans Verkuil To: linux-media@vger.kernel.org Subject: [PATCHv9 2/2] drm: tda998x: set the connector info Date: Thu, 17 Oct 2019 09:28:42 +0200 Message-Id: <20191017072842.16793-3-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191017072842.16793-1-hverkuil-cisco@xs4all.nl> References: <20191017072842.16793-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfMjm2H/NJK8bIu3deYv4BfEyuT2RBShEcA4goJ14CgKowZA7idHLU2gZ9TjmNh7D+VtZHaudgIfx+Pfc6D/EwnOHqwpuaFXaR9raXVLhDqHGw5oBrO0u uAkCvNVq4B8+pGdWrdTbHgYrWLaeyk3v5jm98mFX9ecNHemKl8oGMp1ZohGRkrCHjj4zln/o00Qyi0ycNDOXkWWOfCVs8TgxHPWwpTlNhYFN2AGYI1G6MkmF M4nsXOY1plXJ2PKhomsWIRSSLMmoeWFtHTcqNy9EqRMeNEtkxe2ZluuNO6qICuBhPQczNWDCGW5li819D+AEQa5bTmpXSybdWBNP9CdzcJAswO6hhfVMqWH9 9x85uXtPTTQhtAICc55ednqcF7WyKWARFJPzKDEfVkI7BimHPIU= X-Mailman-Approved-At: Fri, 18 Oct 2019 18:37:47 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Russell King , dri-devel@lists.freedesktop.org, Laurent Pinchart , Hans Verkuil , Dariusz Marcinkiewicz Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dariusz Marcinkiewicz Fill in the cec_connector_info when calling cec_notifier_conn_register(). Signed-off-by: Dariusz Marcinkiewicz Tested-by: Hans Verkuil Signed-off-by: Hans Verkuil --- drivers/gpu/drm/i2c/tda998x_drv.c | 33 +++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c index dde8decb52a6..b0620842fa3a 100644 --- a/drivers/gpu/drm/i2c/tda998x_drv.c +++ b/drivers/gpu/drm/i2c/tda998x_drv.c @@ -82,6 +82,9 @@ struct tda998x_priv { u8 audio_port_enable[AUDIO_ROUTE_NUM]; struct tda9950_glue cec_glue; struct gpio_desc *calib; + + /* protect cec_notify */ + struct mutex cec_notify_mutex; struct cec_notifier *cec_notify; }; @@ -805,8 +808,11 @@ static irqreturn_t tda998x_irq_thread(int irq, void *data) tda998x_edid_delay_start(priv); } else { schedule_work(&priv->detect_work); + + mutex_lock(&priv->cec_notify_mutex); cec_notifier_phys_addr_invalidate( priv->cec_notify); + mutex_unlock(&priv->cec_notify_mutex); } handled = true; @@ -1331,6 +1337,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 +1355,17 @@ 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); + if (!notifier) + return -ENOMEM; + + mutex_lock(&priv->cec_notify_mutex); + priv->cec_notify = notifier; + mutex_unlock(&priv->cec_notify_mutex); + drm_connector_attach_encoder(&priv->connector, priv->bridge.encoder); @@ -1366,6 +1385,11 @@ static void tda998x_bridge_detach(struct drm_bridge *bridge) { struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge); + mutex_lock(&priv->cec_notify_mutex); + cec_notifier_conn_unregister(priv->cec_notify); + priv->cec_notify = NULL; + mutex_unlock(&priv->cec_notify_mutex); + drm_connector_cleanup(&priv->connector); } @@ -1789,8 +1813,6 @@ static void tda998x_destroy(struct device *dev) cancel_work_sync(&priv->detect_work); i2c_unregister_device(priv->cec); - - cec_notifier_conn_unregister(priv->cec_notify); } static int tda998x_create(struct device *dev) @@ -1811,6 +1833,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_notify_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); @@ -1915,12 +1938,6 @@ static int tda998x_create(struct device *dev) cec_write(priv, REG_CEC_RXSHPDINTENA, CEC_RXSHPDLEV_HPD); } - priv->cec_notify = cec_notifier_conn_register(dev, NULL, NULL); - 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;