From patchwork Thu May 25 15:06:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 9748487 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 A1C4160246 for ; Thu, 25 May 2017 15:06:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93F55281C3 for ; Thu, 25 May 2017 15:06:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 88DDD28401; Thu, 25 May 2017 15:06:56 +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=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM 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 E5CD8281C3 for ; Thu, 25 May 2017 15:06:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A57656EA14; Thu, 25 May 2017 15:06:51 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lb2-smtp-cloud2.xs4all.net (lb2-smtp-cloud2.xs4all.net [194.109.24.25]) by gabe.freedesktop.org (Postfix) with ESMTPS id B9B046EA12 for ; Thu, 25 May 2017 15:06:48 +0000 (UTC) Received: from tschai.lan ([46.9.235.119]) by smtp-cloud2.xs4all.net with ESMTP id Qf6b1v0042bEJta01f6oBS; Thu, 25 May 2017 17:06:48 +0200 Received: from tschai.fritz.box (localhost [127.0.0.1]) by tschai.lan (Postfix) with ESMTPSA id 9184F180E53; Thu, 25 May 2017 17:06:26 +0200 (CEST) From: Hans Verkuil To: linux-media@vger.kernel.org Subject: [RFC PATCH 7/7] drm/i915: add DisplayPort CEC-Tunneling-over-AUX support Date: Thu, 25 May 2017 17:06:26 +0200 Message-Id: <20170525150626.29748-8-hverkuil@xs4all.nl> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170525150626.29748-1-hverkuil@xs4all.nl> References: <20170525150626.29748-1-hverkuil@xs4all.nl> Cc: Jani Nikula , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Hans Verkuil 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 --- drivers/gpu/drm/i915/Kconfig | 11 ++++++++++ drivers/gpu/drm/i915/intel_dp.c | 46 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/Kconfig b/drivers/gpu/drm/i915/Kconfig index a5cd5dacf055..f317b13a1409 100644 --- a/drivers/gpu/drm/i915/Kconfig +++ b/drivers/gpu/drm/i915/Kconfig @@ -124,6 +124,17 @@ config DRM_I915_GVT_KVMGT Choose this option if you want to enable KVMGT support for Intel GVT-g. +config DRM_I915_DP_CEC + tristate "Enable DisplayPort CEC-Tunneling-over-AUX HDMI support" + depends on DRM_I915 && CEC_CORE + select DRM_DP_CEC + help + Choose this option if you want to enable HDMI CEC support for + DisplayPort/USB-C to HDMI adapters. + + Note: not all adapters support this feature, and even for those + that do support this often do not hook up the CEC pin. + menu "drm/i915 Debugging" depends on DRM_I915 depends on EXPERT diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index ee77b519835c..38e17ee2548d 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 @@ -1405,6 +1406,7 @@ static void intel_aux_reg_init(struct intel_dp *intel_dp) static void intel_dp_aux_fini(struct intel_dp *intel_dp) { + cec_unregister_adapter(intel_dp->aux.cec_adap); kfree(intel_dp->aux.name); } @@ -4179,6 +4181,33 @@ intel_dp_check_mst_status(struct intel_dp *intel_dp) return -EINVAL; } +static bool +intel_dp_check_cec_status(struct intel_dp *intel_dp) +{ + bool handled = false; + + for (;;) { + u8 cec_irq; + int ret; + + ret = drm_dp_dpcd_readb(&intel_dp->aux, + DP_DEVICE_SERVICE_IRQ_VECTOR_ESI1, + &cec_irq); + if (ret < 0 || !(cec_irq & DP_CEC_IRQ)) + return handled; + + cec_irq &= ~DP_CEC_IRQ; + drm_dp_cec_irq(&intel_dp->aux); + handled = true; + + ret = drm_dp_dpcd_writeb(&intel_dp->aux, + DP_DEVICE_SERVICE_IRQ_VECTOR_ESI1, + cec_irq); + if (ret < 0) + return handled; + } +} + static void intel_dp_retrain_link(struct intel_dp *intel_dp) { @@ -4553,6 +4582,7 @@ intel_dp_set_edid(struct intel_dp *intel_dp) intel_dp->has_audio = intel_dp->force_audio == HDMI_AUDIO_ON; else intel_dp->has_audio = drm_detect_monitor_audio(edid); + cec_s_phys_addr_from_edid(intel_dp->aux.cec_adap, edid); } static void @@ -4562,6 +4592,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; } @@ -4582,13 +4613,17 @@ intel_dp_long_pulse(struct intel_connector *intel_connector) intel_display_power_get(to_i915(dev), intel_dp->aux_power_domain); /* Can't disconnect eDP, but you can close the lid... */ - if (is_edp(intel_dp)) + if (is_edp(intel_dp)) { status = edp_detect(intel_dp); - else if (intel_digital_port_connected(to_i915(dev), - dp_to_dig_port(intel_dp))) + } else if (intel_digital_port_connected(to_i915(dev), + dp_to_dig_port(intel_dp))) { status = intel_dp_detect_dpcd(intel_dp); - else + if (status == connector_status_connected) + drm_dp_cec_configure_adapter(&intel_dp->aux, + intel_dp->aux.name, dev->dev); + } else { status = connector_status_disconnected; + } if (status == connector_status_disconnected) { memset(&intel_dp->compliance, 0, sizeof(intel_dp->compliance)); @@ -5080,6 +5115,9 @@ intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port, bool long_hpd) intel_display_power_get(dev_priv, intel_dp->aux_power_domain); + if (intel_dp->aux.cec_adap) + intel_dp_check_cec_status(intel_dp); + if (intel_dp->is_mst) { if (intel_dp_check_mst_status(intel_dp) == -EINVAL) { /*