From patchwork Thu Jan 2 21:27:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King X-Patchwork-Id: 3431591 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 74E399F2E9 for ; Fri, 3 Jan 2014 15:22:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A140F20134 for ; Fri, 3 Jan 2014 15:22:30 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 718D820127 for ; Fri, 3 Jan 2014 15:22:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 53B73FAA9F; Fri, 3 Jan 2014 07:22:05 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from pandora.arm.linux.org.uk (gw-1.arm.linux.org.uk [78.32.30.217]) by gabe.freedesktop.org (Postfix) with ESMTP id A0FC3F9F97 for ; Thu, 2 Jan 2014 13:32:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=pandora; h=Date:Sender:Message-Id:Subject:Cc:To:From:References:In-Reply-To; bh=cVZvAEUG3yFAIOKWDLklSfzXBVRGlbi8wV3AYfHgUn8=; b=oHBMaIE5VGUpMsMSJHeDcxOR9mtZXmNfFB69iRD14s15t1xSvpg9T0/mSO/KTdBqYzdiYQ+I9Oqo3RKor+TDVVoyrViBu3vWDFHxP/oB3SmDbsP6MhNoqTvHMULDPVSpYf9r4i7l7W62qlxhYVVgzIUei+gIazZ+dTShGLfolJU=; Received: from [fd8f:7570:feb6:1:222:68ff:fe15:37dd] (port=50845 helo=rmk-PC.arm.linux.org.uk) by pandora.arm.linux.org.uk with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1Vypnc-0004AJ-DK; Thu, 02 Jan 2014 21:27:28 +0000 Received: from rmk by rmk-PC.arm.linux.org.uk with local (Exim 4.76) (envelope-from ) id 1Vypnc-0007Eq-0J; Thu, 02 Jan 2014 21:27:28 +0000 In-Reply-To: <20140102212528.GD7383@n2100.arm.linux.org.uk> References: <20140102212528.GD7383@n2100.arm.linux.org.uk> From: Russell King To: David Airlie , Greg Kroah-Hartman , Sascha Hauer , Shawn Guo Subject: [PATCH RFC 20/46] imx-drm: imx-hdmi: fix CTS/N setup at init time Message-Id: Date: Thu, 02 Jan 2014 21:27:28 +0000 X-Mailman-Approved-At: Fri, 03 Jan 2014 07:21:55 -0800 Cc: devel@driverdev.osuosl.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 Many of the variables for the audio clock regenerator (CTS/N) were not initialised in any way. The pixel rate which was being used also wasn't being adjusted at all when the display mode is modified. Get rid of the seaprate 'pixel_clk_rate', and use the stored pixel clock rate instead. Pass this desired pixel clock rate into hdmi_set_clk_regenerator(). Collapse down hdmi_init_clk_regenerator() since it is a copy of hdmi_set_clk_regenerator(), and pass a default pixel clock rate. Signed-off-by: Russell King --- drivers/staging/imx-drm/imx-hdmi.c | 48 +++++++---------------------------- 1 files changed, 10 insertions(+), 38 deletions(-) diff --git a/drivers/staging/imx-drm/imx-hdmi.c b/drivers/staging/imx-drm/imx-hdmi.c index 075dd1f0c8a7..2eb51e7ea9bb 100644 --- a/drivers/staging/imx-drm/imx-hdmi.c +++ b/drivers/staging/imx-drm/imx-hdmi.c @@ -138,7 +138,6 @@ struct imx_hdmi { struct i2c_adapter *ddc; void __iomem *regs; - unsigned long pixel_clk_rate; unsigned int sample_rate; int ratio; }; @@ -332,34 +331,25 @@ static unsigned int hdmi_compute_cts(unsigned int freq, unsigned long pixel_clk, return (cts * ratio) / 100; } -static void hdmi_get_pixel_clk(struct imx_hdmi *hdmi) -{ - unsigned long rate; - - rate = 65000000; /* FIXME */ - - if (rate) - hdmi->pixel_clk_rate = rate; -} - -static void hdmi_set_clk_regenerator(struct imx_hdmi *hdmi) +static void hdmi_set_clk_regenerator(struct imx_hdmi *hdmi, + unsigned long pixel_clk) { unsigned int clk_n, clk_cts; - clk_n = hdmi_compute_n(hdmi->sample_rate, hdmi->pixel_clk_rate, + clk_n = hdmi_compute_n(hdmi->sample_rate, pixel_clk, hdmi->ratio); - clk_cts = hdmi_compute_cts(hdmi->sample_rate, hdmi->pixel_clk_rate, + clk_cts = hdmi_compute_cts(hdmi->sample_rate, pixel_clk, hdmi->ratio); if (!clk_cts) { dev_dbg(hdmi->dev, "%s: pixel clock not supported: %lu\n", - __func__, hdmi->pixel_clk_rate); + __func__, pixel_clk); return; } dev_dbg(hdmi->dev, "%s: samplerate=%d ratio=%d pixelclk=%lu N=%d cts=%d\n", __func__, hdmi->sample_rate, hdmi->ratio, - hdmi->pixel_clk_rate, clk_n, clk_cts); + pixel_clk, clk_n, clk_cts); hdmi_set_clock_regenerator_n(hdmi, clk_n); hdmi_regenerate_cts(hdmi, clk_cts); @@ -367,32 +357,12 @@ static void hdmi_set_clk_regenerator(struct imx_hdmi *hdmi) static void hdmi_init_clk_regenerator(struct imx_hdmi *hdmi) { - unsigned int clk_n, clk_cts; - - clk_n = hdmi_compute_n(hdmi->sample_rate, hdmi->pixel_clk_rate, - hdmi->ratio); - clk_cts = hdmi_compute_cts(hdmi->sample_rate, hdmi->pixel_clk_rate, - hdmi->ratio); - - if (!clk_cts) { - dev_dbg(hdmi->dev, "%s: pixel clock not supported: %lu\n", - __func__, hdmi->pixel_clk_rate); - return; - } - - dev_dbg(hdmi->dev, "%s: samplerate=%d ratio=%d pixelclk=%lu N=%d cts=%d\n", - __func__, hdmi->sample_rate, hdmi->ratio, - hdmi->pixel_clk_rate, clk_n, clk_cts); - - hdmi_set_clock_regenerator_n(hdmi, clk_n); - hdmi_regenerate_cts(hdmi, clk_cts); + hdmi_set_clk_regenerator(hdmi, 74250000); } static void hdmi_clk_regenerator_update_pixel_clock(struct imx_hdmi *hdmi) { - /* Get pixel clock from ipu */ - hdmi_get_pixel_clk(hdmi); - hdmi_set_clk_regenerator(hdmi); + hdmi_set_clk_regenerator(hdmi, hdmi->hdmi_data.video_mode.mpixelclock); } /* @@ -1640,6 +1610,8 @@ static int imx_hdmi_platform_probe(struct platform_device *pdev) return -ENOMEM; hdmi->dev = &pdev->dev; + hdmi->sample_rate = 48000; + hdmi->ratio = 100; if (of_id) { const struct platform_device_id *device_id = of_id->data;