From patchwork Tue Jul 21 07:57:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Henningsson X-Patchwork-Id: 6832691 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 71F349F38B for ; Tue, 21 Jul 2015 07:57:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8B00B205F9 for ; Tue, 21 Jul 2015 07:57:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B7B84205F0 for ; Tue, 21 Jul 2015 07:57:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E3CEE6E8D1; Tue, 21 Jul 2015 00:57:32 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7559B6E8D2 for ; Tue, 21 Jul 2015 00:57:31 -0700 (PDT) Received: from 1.general.diwic.uk.vpn ([10.172.196.28] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1ZHSQc-0005Kr-6M; Tue, 21 Jul 2015 07:57:30 +0000 From: David Henningsson To: alsa-devel@alsa-project.org, intel-gfx@lists.freedesktop.org, tiwai@suse.de, daniel.vetter@intel.com, jani.nikula@linux.intel.com Date: Tue, 21 Jul 2015 09:57:25 +0200 Message-Id: <1437465447-8974-3-git-send-email-david.henningsson@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1437465447-8974-1-git-send-email-david.henningsson@canonical.com> References: <1437465447-8974-1-git-send-email-david.henningsson@canonical.com> Cc: vinod.koul@intel.com, David Henningsson Subject: [Intel-gfx] [PATCH 2/4] drm/i915: Call audio hotplug notify function X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On HDMI hotplug events, notify the audio driver. This will enable the audio driver to get the information at all times (even when audio is in different powersave states), and also without reading it from the hardware. Signed-off-by: David Henningsson --- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_audio.c | 46 ++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 542fac6..696624c 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1808,6 +1808,7 @@ struct drm_i915_private { struct drm_property *force_audio_property; /* hda/i915 audio component */ + struct i915_audio_component *audio_component; bool audio_component_registered; uint32_t hw_context_size; diff --git a/drivers/gpu/drm/i915/intel_audio.c b/drivers/gpu/drm/i915/intel_audio.c index 3da9b84..eb29e1f 100644 --- a/drivers/gpu/drm/i915/intel_audio.c +++ b/drivers/gpu/drm/i915/intel_audio.c @@ -384,6 +384,44 @@ static void ilk_audio_codec_enable(struct drm_connector *connector, I915_WRITE(aud_config, tmp); } +static void audio_hotplug_notify(struct drm_i915_private *dev_priv, + struct drm_connector *connector, + struct intel_encoder *encoder, + bool plugged_in) +{ + struct i915_audio_component *acomp = dev_priv->audio_component; + struct i915_audio_hotplug_info audio_info; + struct intel_digital_port *intel_dig_port = + enc_to_dig_port(&encoder->base); + enum port port = intel_dig_port->port; + + if (!acomp || !acomp->cb_ops || !acomp->cb_ops->hotplug_notify) + return; + + if (connector) { + audio_info.connector_type = connector->connector_type; + audio_info.connector_type_id = connector->connector_type_id; + } else { + audio_info.connector_type = -1; + audio_info.connector_type_id = -1; + } + + audio_info.port = (int) port; + /* DP Mst is unsupported for now */ + audio_info.port_multi_stream_device = 0; + + audio_info.plugged_in = plugged_in; + if (plugged_in && connector) { + audio_info.eld = connector->eld; + audio_info.eld_size = drm_eld_size(audio_info.eld); + } else { + audio_info.eld = NULL; + audio_info.eld_size = 0; + } + + acomp->cb_ops->hotplug_notify(acomp->hdac_bus, &audio_info); +} + /** * intel_audio_codec_enable - Enable the audio codec for HD audio * @intel_encoder: encoder on which to enable audio @@ -419,6 +457,8 @@ void intel_audio_codec_enable(struct intel_encoder *intel_encoder) if (dev_priv->display.audio_codec_enable) dev_priv->display.audio_codec_enable(connector, intel_encoder, mode); + + audio_hotplug_notify(dev_priv, connector, intel_encoder, true); } /** @@ -435,6 +475,8 @@ void intel_audio_codec_disable(struct intel_encoder *encoder) if (dev_priv->display.audio_codec_disable) dev_priv->display.audio_codec_disable(encoder); + + audio_hotplug_notify(dev_priv, NULL, encoder, false); } /** @@ -525,12 +567,14 @@ static int i915_audio_component_bind(struct device *i915_dev, struct device *hda_dev, void *data) { struct i915_audio_component *acomp = data; + struct drm_i915_private *dev_priv = dev_to_i915(i915_dev); if (WARN_ON(acomp->ops || acomp->dev)) return -EEXIST; acomp->ops = &i915_audio_component_ops; acomp->dev = i915_dev; + dev_priv->audio_component = acomp; return 0; } @@ -539,9 +583,11 @@ static void i915_audio_component_unbind(struct device *i915_dev, struct device *hda_dev, void *data) { struct i915_audio_component *acomp = data; + struct drm_i915_private *dev_priv = dev_to_i915(i915_dev); acomp->ops = NULL; acomp->dev = NULL; + dev_priv->audio_component = NULL; } static const struct component_ops i915_audio_component_bind_ops = {