From patchwork Sat Jul 15 11:00:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Zhong X-Patchwork-Id: 9842315 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 B6C8060392 for ; Sat, 15 Jul 2017 11:00:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A67D12872B for ; Sat, 15 Jul 2017 11:00:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B09F2872E; Sat, 15 Jul 2017 11:00:59 +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=-1.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4BAAA2872A for ; Sat, 15 Jul 2017 11:00:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=ZU+CSizptM5CovhsLUGfWmaT3wWBrSwy/N319sVpKJc=; b=RrU bi2ZT3/mZkcTC1wFgMLEibkm4Oq19HJfhxlKfR+vavokcKAsVUCKIjfr+ZtO0u57kP69DGBrXNrk/ xYwRrI3y3dbAscQD5+VRP43VpgEc1oSG3xz1a254JQnKgu7oj0yPUer9NW5JB9lnIvfp0iQiGVgDC nmS5AjNVlNv7E+h4gnviG3R7GmNgtEMKesmm9BfhOqFFHdFy7JCcVH1KGe4KpoXY5UUUNwsWSKmRs 9lgjDDjrBBkSSZoNHfHmPX4Zwnd1/1Rp7I+rqfYUF0+pD/Zc/JCwOBc13XiU/YW3O74lNsfukLlJ/ eSOiGA7OO5iKUKRYOLasV2/OmglUNDQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dWKoi-0003E6-EF; Sat, 15 Jul 2017 11:00:56 +0000 Received: from mail-pf0-f196.google.com ([209.85.192.196]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dWKod-0003Ag-Vz; Sat, 15 Jul 2017 11:00:53 +0000 Received: by mail-pf0-f196.google.com with SMTP id c24so13897576pfe.1; Sat, 15 Jul 2017 04:00:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=FImrjlD6hnudT5oeqEuwNNHnwHxj4OvUI9GllKmbY/Q=; b=IJlEuiZOLvbeMZoGqNtS05u6gL4SFQrPMYlwOIKQy+tldnJLETWToVwKq0Sp5P2lrr uimoQ+5OrO90WGovrW1gcJAnEIhTbgrfaWCInvLHl7T43Hw8qLUwbZ9pci4vz/umQsZg iZfFg6IxsmF4q+8j0h3psU4uEm72bEl43xZ/rbVCxZ8R5C/a2dRgqwt4TNsO2YfMZKxo mghEt8HJAoiiW/zA64wHzuJKaVCqzgIyo7gVzKl89R3iLa4dRdi/tUGYsiU5nFkH1r0c nB+X5GbBM0h0piyk59qSTGM+Iv3Tzq7vMCfoqjnkXaMO2xT1c2uwM3ldcwAQUWKiUR43 3Cag== X-Gm-Message-State: AIVw113R3U89wy7GFvJosLk6VkuJBdwfhkAsUqZ2SELKkb72RgP4B3V0 /eJoqHeRGAX28YQj X-Received: by 10.99.99.193 with SMTP id x184mr19465633pgb.13.1500116435460; Sat, 15 Jul 2017 04:00:35 -0700 (PDT) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id 79sm21374275pgg.46.2017.07.15.04.00.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 15 Jul 2017 04:00:34 -0700 (PDT) From: Chris Zhong To: linux-rockchip@lists.infradead.org, seanpaul@chromium.org, dianders@chromium.org, briannorris@chromium.org Subject: [PATCH] drm/rockchip: cdn-dp: send audio infoframe to sink Date: Sat, 15 Jul 2017 19:00:18 +0800 Message-Id: <1500116418-4178-1-git-send-email-zyw@rock-chips.com> X-Mailer: git-send-email 2.6.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170715_040052_090344_F893F292 X-CRM114-Status: GOOD ( 11.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , David Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Chris Zhong , linux-arm-kernel@lists.infradead.org, Mark Yao MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Some DP/HDMI sink need to receive the audio infoframe to play sound, especially some multi-channel AV receiver, they need the channel_allocation from infoframe to config the speakers. Send the audio infoframe via SDP will make them work properly. Signed-off-by: Chris Zhong --- drivers/gpu/drm/rockchip/cdn-dp-core.c | 20 ++++++++++++++++++++ drivers/gpu/drm/rockchip/cdn-dp-reg.c | 19 +++++++++++++++++++ drivers/gpu/drm/rockchip/cdn-dp-reg.h | 6 ++++++ 3 files changed, 45 insertions(+) diff --git a/drivers/gpu/drm/rockchip/cdn-dp-core.c b/drivers/gpu/drm/rockchip/cdn-dp-core.c index 9b0b058..e59ca47 100644 --- a/drivers/gpu/drm/rockchip/cdn-dp-core.c +++ b/drivers/gpu/drm/rockchip/cdn-dp-core.c @@ -802,6 +802,7 @@ static int cdn_dp_audio_hw_params(struct device *dev, void *data, .sample_rate = params->sample_rate, .channels = params->channels, }; + u8 buffer[14]; int ret; mutex_lock(&dp->lock); @@ -823,6 +824,25 @@ static int cdn_dp_audio_hw_params(struct device *dev, void *data, goto out; } + memset(buffer, 0, sizeof(buffer)); + + ret = hdmi_audio_infoframe_pack(¶ms->cea, buffer, sizeof(buffer)); + if (ret < 0) { + DRM_DEV_ERROR(dev, "Failed to pack audio infoframe: %d\n", ret); + goto out; + } + + /* + * Change the infoframe header to SDP header per DP 1.3 spec, Table + * 2-98. + */ + buffer[0] = 0; + buffer[1] = HDMI_INFOFRAME_TYPE_AUDIO; + buffer[2] = 0x1b; + buffer[3] = 0x48; + + cdn_dp_sdp_write(dp, 0, buffer, sizeof(buffer)); + ret = cdn_dp_audio_config(dp, &audio); if (!ret) dp->audio_info = audio; diff --git a/drivers/gpu/drm/rockchip/cdn-dp-reg.c b/drivers/gpu/drm/rockchip/cdn-dp-reg.c index b14d211..8907db0 100644 --- a/drivers/gpu/drm/rockchip/cdn-dp-reg.c +++ b/drivers/gpu/drm/rockchip/cdn-dp-reg.c @@ -951,6 +951,25 @@ static void cdn_dp_audio_config_spdif(struct cdn_dp_device *dp) clk_set_rate(dp->spdif_clk, CDN_DP_SPDIF_CLK); } +void cdn_dp_sdp_write(struct cdn_dp_device *dp, int entry_id, u8 *buf, u32 len) +{ + int idx; + u32 *packet = (u32 *)buf; + u32 length = len / 4; + u8 type = buf[1]; + + for (idx = 0; idx < length; idx++) + writel(cpu_to_le32(*packet++), dp->regs + SOURCE_PIF_DATA_WR); + + writel(entry_id, dp->regs + SOURCE_PIF_WR_ADDR); + + writel(F_HOST_WR, dp->regs + SOURCE_PIF_WR_REQ); + + writel(PIF_PKT_TYPE_VALID | F_PACKET_TYPE(type) | entry_id, + dp->regs + SOURCE_PIF_PKT_ALLOC_REG); + writel(PIF_PKT_ALLOC_WR_EN, dp->regs + SOURCE_PIF_PKT_ALLOC_WR_EN); +} + int cdn_dp_audio_config(struct cdn_dp_device *dp, struct audio_info *audio) { int ret; diff --git a/drivers/gpu/drm/rockchip/cdn-dp-reg.h b/drivers/gpu/drm/rockchip/cdn-dp-reg.h index c4bbb4a83..6ec0e81 100644 --- a/drivers/gpu/drm/rockchip/cdn-dp-reg.h +++ b/drivers/gpu/drm/rockchip/cdn-dp-reg.h @@ -424,6 +424,11 @@ /* Reference cycles when using lane clock as reference */ #define LANE_REF_CYC 0x8000 +#define F_HOST_WR BIT(0) +#define PIF_PKT_ALLOC_WR_EN BIT(0) +#define PIF_PKT_TYPE_VALID (3 << 16) +#define F_PACKET_TYPE(x) (((x) & 0xff) << 8) + enum voltage_swing_level { VOLTAGE_LEVEL_0, VOLTAGE_LEVEL_1, @@ -478,5 +483,6 @@ int cdn_dp_set_video_status(struct cdn_dp_device *dp, int active); int cdn_dp_config_video(struct cdn_dp_device *dp); int cdn_dp_audio_stop(struct cdn_dp_device *dp, struct audio_info *audio); int cdn_dp_audio_mute(struct cdn_dp_device *dp, bool enable); +void cdn_dp_sdp_write(struct cdn_dp_device *dp, int entry_id, u8 *buf, u32 len); int cdn_dp_audio_config(struct cdn_dp_device *dp, struct audio_info *audio); #endif /* _CDN_DP_REG_H */