From patchwork Tue Nov 18 17:39:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jackson X-Patchwork-Id: 5333971 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F2D129F462 for ; Wed, 19 Nov 2014 01:22:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3ADAA201F2 for ; Wed, 19 Nov 2014 01:22:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0418D2017E for ; Wed, 19 Nov 2014 01:22:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 17AAE6F03C; Tue, 18 Nov 2014 17:22:19 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by gabe.freedesktop.org (Postfix) with ESMTP id 1211F6E53B for ; Tue, 18 Nov 2014 09:39:39 -0800 (PST) Received: from [10.1.193.37] (e106787-lin.cambridge.arm.com [10.1.193.37]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id sAIHdUlb027474; Tue, 18 Nov 2014 17:39:30 GMT Message-ID: <546B8452.6030701@arm.com> Date: Tue, 18 Nov 2014 17:39:30 +0000 From: Andrew Jackson User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: Russell King - ARM Linux , Dave Airlie , "dri-devel@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH] drm/i2c: tda998x: Allow for different audio sample rates X-Mailman-Approved-At: Tue, 18 Nov 2014 17:22:18 -0800 Cc: "linux-arm-kernel@lists.infradead.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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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, the audio data are carried across the HDMI link which is driven by the TDMS clock. The TDMS clock is dependent on the video pixel rate. This patch sets the denominator (Cycle Time Stamp) appropriately allowing the driver to send audio to a wider range of HDMI sinks (i.e. monitors). Signed-off-by: Andrew Jackson --- drivers/gpu/drm/i2c/tda998x_drv.c | 22 ++++++++++++++++++---- 1 files changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c index d476279..da0d504 100644 --- a/drivers/gpu/drm/i2c/tda998x_drv.c +++ b/drivers/gpu/drm/i2c/tda998x_drv.c @@ -640,7 +640,7 @@ tda998x_configure_audio(struct tda998x_priv *priv, struct drm_display_mode *mode, struct tda998x_encoder_params *p) { uint8_t buf[6], clksel_aip, clksel_fs, cts_n, adiv; - uint32_t n; + uint32_t n, cts; /* Enable audio ports */ reg_write(priv, REG_ENA_AP, p->audio_cfg); @@ -696,9 +696,23 @@ tda998x_configure_audio(struct tda998x_priv *priv, n = 128 * p->audio_sample_rate / 1000; /* Write the CTS and N values */ - buf[0] = 0x44; - buf[1] = 0x42; - buf[2] = 0x01; + if ((n > 0) && (mode->clock > 0)) { + /* + * For non-coherent clocks, the average CTS value is + * calculated as: + * fTMDS * n / (128 * fs) + * which simplifies to: + * fTMDS / 1000 + * (See sections 7.2.2 and 7.2.3 of the HDMI specification.) + * NB mode->clock is in kHz. + */ + cts = mode->clock; + } else { + cts = 82500; + } + buf[0] = cts; + buf[1] = cts >> 8; + buf[2] = cts >> 16; buf[3] = n; buf[4] = n >> 8; buf[5] = n >> 16;