From patchwork Mon Nov 20 11:42:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 10066343 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6BF1A60375 for ; Mon, 20 Nov 2017 11:42:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BDC929228 for ; Mon, 20 Nov 2017 11:42:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50DF82927E; Mon, 20 Nov 2017 11:42:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E6D7A29228 for ; Mon, 20 Nov 2017 11:42:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C26C16E181; Mon, 20 Nov 2017 11:42:24 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lb3-smtp-cloud8.xs4all.net (lb3-smtp-cloud8.xs4all.net [194.109.24.29]) by gabe.freedesktop.org (Postfix) with ESMTPS id 565706E183 for ; Mon, 20 Nov 2017 11:42:23 +0000 (UTC) Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud8.xs4all.net with ESMTPA id GkSretCwNg5cRGkSzeAJZx; Mon, 20 Nov 2017 12:42:21 +0100 From: Hans Verkuil To: linux-media@vger.kernel.org Subject: [PATCHv5 3/3] drm/i915: add DisplayPort CEC-Tunneling-over-AUX support Date: Mon, 20 Nov 2017 12:42:11 +0100 Message-Id: <20171120114211.21825-4-hverkuil@xs4all.nl> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171120114211.21825-1-hverkuil@xs4all.nl> References: <20171120114211.21825-1-hverkuil@xs4all.nl> X-CMAE-Envelope: MS4wfHWcBl22dE67yOnzGIZGE0qW/cdNQu+hOt6+tNGuxXVrC69cFp1ckeJl4ssELNtdqmjccjJZ+rpfdWUwyJveToLqzUMLi04Yv3M9/XEh5jxLlAWIYibE DfhBS12Jt/wmIiMMc0exM6XwSbWSsR3NhkXGF7PJvV6c61dC/qi7NFNjjlCSO8To8i6Q20im6JQbuYviWqzJNe3hCT9o9pGGM0QlSxJx3rHGy61DbCWni7e4 BaIcHgNeU5pG8QWBuyfmlu4h7CE+X5T/rE7s0ptdEL1eWzdB7zBr2xmtxaS1kMpzr0Bt4V2spqPt3eFrcUlfndIJKbRKAkjuHnJFYD+vl2VQghuhC9jhWZ9Y YrBY7+Hq Cc: Daniel Vetter , Hans Verkuil , dri-devel@lists.freedesktop.org, Carlos Santa X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil Implement support for this DisplayPort feature. The cec device is created whenever it detects an adapter that has this feature. It is only removed when a new adapter is connected that does not support this. If a new adapter is connected that has different properties than the previous one, then the old cec device is unregistered and a new one is registered to replace the old one. Signed-off-by: Hans Verkuil --- Changes since v4: Reworked the last patch (adding CEC to i915) based on Ville's comments and my MST testing: - register/unregister CEC in intel_dp_connector_register/unregister - add comment and check if connector is registered in long_pulse - unregister CEC if an MST 'connector' is detected. --- drivers/gpu/drm/i915/intel_dp.c | 47 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 09f274419eea..853346e8c5e9 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -4690,6 +4691,7 @@ intel_dp_set_edid(struct intel_dp *intel_dp) intel_connector->detect_edid = edid; intel_dp->has_audio = drm_detect_monitor_audio(edid); + cec_s_phys_addr_from_edid(intel_dp->aux.cec_adap, edid); } static void @@ -4699,6 +4701,7 @@ intel_dp_unset_edid(struct intel_dp *intel_dp) kfree(intel_connector->detect_edid); intel_connector->detect_edid = NULL; + cec_phys_addr_invalidate(intel_dp->aux.cec_adap); intel_dp->has_audio = false; } @@ -4773,6 +4776,14 @@ intel_dp_long_pulse(struct intel_connector *intel_connector) * with EDID on it */ status = connector_status_disconnected; + if (connector->registered) { + /* + * CEC is not supported for an MST device, unregister + * the existing CEC adapter, if any. + */ + cec_unregister_adapter(intel_dp->aux.cec_adap); + intel_dp->aux.cec_adap = NULL; + } goto out; } else { /* @@ -4822,6 +4833,25 @@ intel_dp_long_pulse(struct intel_connector *intel_connector) if (status != connector_status_connected && !intel_dp->is_mst) intel_dp_unset_edid(intel_dp); + if (status == connector_status_connected && connector->registered) { + /* + * A new DP-to-HDMI adapter could have been plugged in, so + * call drm_dp_cec_configure_adapter to check if a CEC device + * should be unregistered and/or registered, depending on the + * CEC capabilities of the adapter. + * + * The CEC device is associated with the connector, so it + * sticks around when the adapter is unplugged and is only + * unregistered if the connector is unregistered or if another + * adapter is plugged in with no or different CEC capabilities. + * + * This is what CEC applications expect. + */ + drm_dp_cec_configure_adapter(&intel_dp->aux, + connector->name, dev->dev, + intel_connector->detect_edid); + } + intel_display_power_put(to_i915(dev), intel_dp->aux_power_domain); return status; } @@ -4902,6 +4932,7 @@ static int intel_dp_connector_register(struct drm_connector *connector) { struct intel_dp *intel_dp = intel_attached_dp(connector); + struct drm_device *dev = connector->dev; int ret; ret = intel_connector_register(connector); @@ -4913,6 +4944,15 @@ intel_dp_connector_register(struct drm_connector *connector) DRM_DEBUG_KMS("registering %s bus for %s\n", intel_dp->aux.name, connector->kdev->kobj.name); + if (connector->status == connector_status_connected && + !intel_dp->is_mst && !intel_dp->aux.cec_adap) { + struct intel_connector *intel_connector = + intel_dp->attached_connector; + + drm_dp_cec_configure_adapter(&intel_dp->aux, + connector->name, dev->dev, + intel_connector->detect_edid); + } intel_dp->aux.dev = connector->kdev; return drm_dp_aux_register(&intel_dp->aux); } @@ -4920,7 +4960,11 @@ intel_dp_connector_register(struct drm_connector *connector) static void intel_dp_connector_unregister(struct drm_connector *connector) { - drm_dp_aux_unregister(&intel_attached_dp(connector)->aux); + struct intel_dp *intel_dp = intel_attached_dp(connector); + + cec_unregister_adapter(intel_dp->aux.cec_adap); + intel_dp->aux.cec_adap = NULL; + drm_dp_aux_unregister(&intel_dp->aux); intel_connector_unregister(connector); } @@ -5129,6 +5173,7 @@ intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port, bool long_hpd) } if (!intel_dp->is_mst) { + drm_dp_cec_irq(&intel_dp->aux); if (!intel_dp_short_pulse(intel_dp)) { intel_dp->detect_done = false; goto put_power;