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: 5331891 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7C1DEC11AC for ; Tue, 18 Nov 2014 17:42:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B8A03201BC for ; Tue, 18 Nov 2014 17:42:13 +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 DA70A20125 for ; Tue, 18 Nov 2014 17:42:12 +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 1Xqml9-00014h-7x; Tue, 18 Nov 2014 17:40:11 +0000 Received: from fw-tnat.cambridge.arm.com ([217.140.96.21] helo=cam-smtp0.cambridge.arm.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xqml5-0008KP-1b for linux-arm-kernel@lists.infradead.org; Tue, 18 Nov 2014 17:40:08 +0000 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141118_094007_501233_2E589C5D X-CRM114-Status: GOOD ( 13.82 ) X-Spam-Score: -2.3 (--) Cc: Liviu Dudau , "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, 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;