From patchwork Sun Oct 30 13:56:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Le Cuirot X-Patchwork-Id: 9404865 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 61DF560588 for ; Mon, 31 Oct 2016 00:49:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EA7C28E38 for ; Mon, 31 Oct 2016 00:49:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43AC428E3C; Mon, 31 Oct 2016 00:49:52 +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 D025828E38 for ; Mon, 31 Oct 2016 00:49:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7B4576E14D; Mon, 31 Oct 2016 00:49:20 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by gabe.freedesktop.org (Postfix) with ESMTPS id 28FCE6E0AA for ; Sun, 30 Oct 2016 13:56:54 +0000 (UTC) Received: from symphony.aura-online.co.uk (154.189.187.81.in-addr.arpa [81.187.189.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: chewi) by smtp.gentoo.org (Postfix) with ESMTPSA id 641C3341024; Sun, 30 Oct 2016 13:56:51 +0000 (UTC) From: James Le Cuirot To: Russell King , David Airlie Subject: [PATCH] drm/bridge: dw-hdmi: Set sink_is_hdmi and sink_has_audio in mode_set Date: Sun, 30 Oct 2016 13:56:25 +0000 Message-Id: <20161030135625.11117-1-chewi@gentoo.org> X-Mailer: git-send-email 2.10.1 X-Mailman-Approved-At: Mon, 31 Oct 2016 00:48:38 +0000 Cc: Daniel Vetter , James Le Cuirot , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org 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 These were previously set in dw_hdmi_connector_get_modes but this isn't called when the EDID is overridden. This can be seen in drm_helper_probe_single_connector_modes. Using the drm_kms_helper.edid_firmware parameter therefore always resulted in silence, even when providing the very same EDID that had previously been read from /sys. I saw that other drivers set similar properties in mode_set rather than get_modes. radeon_audio_hdmi_mode_set is one such example. It calls radeon_connector_edid to retrieve the EDID so I drew inspiration from this for the fix. I have tested this with a Utilite Pro on 4.9-rc3. I tried overriding the EDID with my own, not overriding the EDID, hotplugging the display after booting, and overriding the EDID with 1920x1080.bin. The latter has no audio parameters so no sound was heard as expected. Signed-off-by: James Le Cuirot --- Notes: I do have some questions. I don't know the significance of the mutex lock. I put my code inside it because I am modifying the hdmi properties. Is this necessary? Should it go before or after the lock instead? I'm also wondering whether I should initially set both properties to false in case the EDID is missing but the driver didn't do this previously. Perhaps it should have? I have only contributed one line to the kernel before, many years ago, so please be gentle. :) drivers/gpu/drm/bridge/dw-hdmi.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/bridge/dw-hdmi.c b/drivers/gpu/drm/bridge/dw-hdmi.c index ab7023e..a30b691 100644 --- a/drivers/gpu/drm/bridge/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/dw-hdmi.c @@ -1383,12 +1383,23 @@ static void dw_hdmi_bridge_mode_set(struct drm_bridge *bridge, struct drm_display_mode *mode) { struct dw_hdmi *hdmi = bridge->driver_private; + struct drm_property_blob *edid_blob; + struct edid *edid; mutex_lock(&hdmi->mutex); /* Store the display mode for plugin/DKMS poweron events */ memcpy(&hdmi->previous_mode, mode, sizeof(hdmi->previous_mode)); + edid_blob = hdmi->connector.edid_blob_ptr; + if (edid_blob) { + edid = (struct edid *) edid_blob->data; + if (edid) { + hdmi->sink_is_hdmi = drm_detect_hdmi_monitor(edid); + hdmi->sink_has_audio = drm_detect_monitor_audio(edid); + } + } + mutex_unlock(&hdmi->mutex); } @@ -1445,8 +1456,6 @@ static int dw_hdmi_connector_get_modes(struct drm_connector *connector) dev_dbg(hdmi->dev, "got edid: width[%d] x height[%d]\n", edid->width_cm, edid->height_cm); - hdmi->sink_is_hdmi = drm_detect_hdmi_monitor(edid); - hdmi->sink_has_audio = drm_detect_monitor_audio(edid); drm_mode_connector_update_edid_property(connector, edid); ret = drm_add_edid_modes(connector, edid); /* Store the ELD */