From patchwork Fri Jun 19 16:21:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yakir Yang X-Patchwork-Id: 6646061 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 19E20C0433 for ; Fri, 19 Jun 2015 16:24:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 30BD420941 for ; Fri, 19 Jun 2015 16:24:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 417EA20960 for ; Fri, 19 Jun 2015 16:24:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z5z5t-0002mo-Q7; Fri, 19 Jun 2015 16:24:41 +0000 Received: from regular1.263xmail.com ([211.150.99.139]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z5z5a-0002Zm-Qr; Fri, 19 Jun 2015 16:24:24 +0000 Received: from ykk?rock-chips.com (unknown [192.168.167.87]) by regular1.263xmail.com (Postfix) with SMTP id 21D78450E; Sat, 20 Jun 2015 00:23:56 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-ADDR-CHECKED: 0 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 0EB664434; Sat, 20 Jun 2015 00:23:57 +0800 (CST) X-RL-SENDER: ykk@rock-chips.com X-FST-TO: linux-rockchip@lists.infradead.org X-SENDER-IP: 112.111.49.167 X-LOGIN-NAME: ykk@rock-chips.com X-UNIQUE-TAG: <825b6184535bf366d4c911ff96597a35> X-ATTACHMENT-NUM: 0 X-SENDER: ykk@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [112.111.49.167]) by smtp.263.net (Postfix) whith ESMTP id 27362IAGTQG; Sat, 20 Jun 2015 00:23:59 +0800 (CST) From: Yakir Yang To: linux-rockchip@lists.infradead.org, dri-devel , linux-kernel@vger.kernel.org, linux-arm-kernel Subject: [PATCH v5 2/6] drm: bridge/dw_hdmi: enable audio when sink device is HDMI and has audio Date: Sat, 20 Jun 2015 00:21:42 +0800 Message-Id: <1434730902-10875-1-git-send-email-ykk@rock-chips.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1434730417-10629-1-git-send-email-ykk@rock-chips.com> References: <1434730417-10629-1-git-send-email-ykk@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150619_092423_280330_74736BDA X-CRM114-Status: GOOD ( 11.83 ) X-Spam-Score: -0.0 (/) Cc: Fabio Estevam , David Airlie , Doug Anderson , Daniel Kurtz , Philipp Zabel , Yakir Yang , Russell King , Andy Yan X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.5 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 The original code only provide audio func when video code is a CEA mode, but I found that No-CEA mode could also play sound when sink is HDMI mode and has audio. So I think if sink device has the ability to play audio, then source should enable audio support that set fc_invidconf to HDMI mode and config n/cts rightly. And actually we could know those information through parsing sink edid. drm_detect_hdmi_monitor() could report whether sink is a HDMI monitor, drm_detect_monitor_audio() could return whether sink has audio. Signed-off-by: Yakir Yang --- Changes in v5: - Take Russell suggest that create "sink_has_audio" and "sink_is_hdmi" in struct hdmi, and keep vmode's mdvi changeless. - Config fc_invidconf to HDMI mode when sink device is HDMI monitor. Changes in v4: - Take Dainel suggest that introduce drm_detect_monitor_audio() to judge whether source should config audio. Changes in v3: None Changes in v2: None drivers/gpu/drm/bridge/dw_hdmi.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c index f717a2a..417cc82 100644 --- a/drivers/gpu/drm/bridge/dw_hdmi.c +++ b/drivers/gpu/drm/bridge/dw_hdmi.c @@ -119,6 +119,8 @@ struct dw_hdmi { u8 edid[HDMI_EDID_LEN]; bool cable_plugin; + bool sink_is_hdmi; + bool sink_has_audio; bool phy_enabled; struct drm_display_mode previous_mode; @@ -1152,7 +1154,11 @@ static void hdmi_av_composer(struct dw_hdmi *hdmi, HDMI_FC_INVIDCONF_IN_I_P_INTERLACED : HDMI_FC_INVIDCONF_IN_I_P_PROGRESSIVE; - inv_val |= (vmode->mdvi ? + /* + * when sink device is hdmi monitor, then we can config + * this to hdmi_mode even if the video mode is No-CEA mode. + */ + inv_val |= (hdmi->sink_is_hdmi ? HDMI_FC_INVIDCONF_DVI_MODEZ_DVI_MODE : HDMI_FC_INVIDCONF_DVI_MODEZ_HDMI_MODE); @@ -1330,11 +1336,10 @@ static int dw_hdmi_setup(struct dw_hdmi *hdmi, struct drm_display_mode *mode) /* HDMI Initialization Step B.3 */ dw_hdmi_enable_video_path(hdmi); - /* not for DVI mode */ - if (hdmi->hdmi_data.video_mode.mdvi) { - dev_dbg(hdmi->dev, "%s DVI mode\n", __func__); + if (!hdmi->sink_has_audio) { + dev_info(hdmi->dev, "sink device does not support audio\n"); } else { - dev_dbg(hdmi->dev, "%s CEA mode\n", __func__); + dev_dbg(hdmi->dev, "sink device support audio\n"); /* HDMI Initialization Step E - Configure audio */ hdmi_clk_regenerator_update_pixel_clock(hdmi); @@ -1500,6 +1505,9 @@ 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 */