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: 6646041 Return-Path: X-Original-To: patchwork-dri-devel@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 972539F326 for ; Fri, 19 Jun 2015 16:24:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BB67D20920 for ; Fri, 19 Jun 2015 16:24:08 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C88F52077A for ; Fri, 19 Jun 2015 16:24:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EB4D46EF0F; Fri, 19 Jun 2015 09:24:06 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from regular1.263xmail.com (regular1.263xmail.com [211.150.99.139]) by gabe.freedesktop.org (Postfix) with ESMTP id 3F0C06EF0F for ; Fri, 19 Jun 2015 09:24:05 -0700 (PDT) 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> Cc: Fabio Estevam , Doug Anderson , Yakir Yang , Russell King , Andy Yan 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-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 */