From patchwork Thu Dec 7 15:49:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 751916 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1541F46B8C; Thu, 7 Dec 2023 15:51:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kMkWra5L" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 884EDC43140; Thu, 7 Dec 2023 15:51:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701964262; bh=Km69nVpnUP64b8Kzk0NTIbgVieEwtlfBTD9lTbvMXp0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kMkWra5LfMebFjlim7OiMi9DpfITxL7WUX3rB+xw5xNhiGNE5gdieGC8N3DOGiPlS 5hFm5y/xKDSkJWTb+z+8SbmC+y1qBobBLX6n1VR12m3VwiPYz3D/qYWn8V1Liq4VOr D/0EZnAfkEsbtIijpnWMSs4OM2vxizDPnI2siT+lW/JyxDdnMpJognErL2z6loLgTn nvSLQuFoWiB7M6bFI5Rln0daFzKaDtkUutze9NPi9dxI+SW+t8ezDJ96QextGrrdx7 h9dMFFnMXEXajuR0z9pV50HKRk6hKWutTEqocf68KGusofCvS9VrO0j9SYtNvRD8Ah pOUPek4CX669w== From: Maxime Ripard Date: Thu, 07 Dec 2023 16:49:55 +0100 Subject: [PATCH v5 32/44] drm/rockchip: inno_hdmi: Remove tmds rate from structure Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231207-kms-hdmi-connector-state-v5-32-6538e19d634d@kernel.org> References: <20231207-kms-hdmi-connector-state-v5-0-6538e19d634d@kernel.org> In-Reply-To: <20231207-kms-hdmi-connector-state-v5-0-6538e19d634d@kernel.org> To: Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Emma Anholt , Jonathan Corbet , Sandy Huang , =?utf-8?q?Heiko_St=C3=BCbner?= , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: Hans Verkuil , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-sunxi@lists.linux.dev, Maxime Ripard X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2323; i=mripard@kernel.org; h=from:subject:message-id; bh=Km69nVpnUP64b8Kzk0NTIbgVieEwtlfBTD9lTbvMXp0=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDKmFL9vmSnYUT/JkiauJfT/nQAKPxkrRjRcmBfO6X7wq/ EkzImBdRykLgxgXg6yYIkuMsPmSuFOzXney8c2DmcPKBDKEgYtTACbidIfhnwbzjnWWL1NvXzEK 6lEUvrHhSNe50Jfhrz4t2Kr419mhdQ0jQ+95QfOY2MK4iI6a+88femUlTl748S1/2vtdaVdX8dd 0sQEA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D The tmds_rate field in the inno_hdmi structure is used mostly to configure the internal i2c controller divider through a call to the inno_hdmi_i2c_init() function. We can simply make that rate an argument to that function, which also removes a workaround to initialize the divider at probe time when we don't have a mode yet. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/rockchip/inno_hdmi.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c index f05417c6b637..35f44e556fcf 100644 --- a/drivers/gpu/drm/rockchip/inno_hdmi.c +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c @@ -50,8 +50,6 @@ struct inno_hdmi { struct inno_hdmi_i2c *i2c; struct i2c_adapter *ddc; - - unsigned int tmds_rate; }; static struct inno_hdmi *encoder_to_inno_hdmi(struct drm_encoder *encoder) @@ -155,11 +153,11 @@ static inline void hdmi_modb(struct inno_hdmi *hdmi, u16 offset, hdmi_writeb(hdmi, offset, temp); } -static void inno_hdmi_i2c_init(struct inno_hdmi *hdmi) +static void inno_hdmi_i2c_init(struct inno_hdmi *hdmi, unsigned long long rate) { - int ddc_bus_freq; + unsigned long long ddc_bus_freq = rate >> 2; - ddc_bus_freq = (hdmi->tmds_rate >> 2) / HDMI_SCL_RATE; + do_div(ddc_bus_freq, HDMI_SCL_RATE); hdmi_writeb(hdmi, DDC_BUS_FREQ_L, ddc_bus_freq & 0xFF); hdmi_writeb(hdmi, DDC_BUS_FREQ_H, (ddc_bus_freq >> 8) & 0xFF); @@ -389,8 +387,7 @@ static int inno_hdmi_setup(struct inno_hdmi *hdmi, * DCLK_LCDC, so we need to init the TMDS rate to mode pixel * clock rate, and reconfigure the DDC clock. */ - hdmi->tmds_rate = mode->clock * 1000; - inno_hdmi_i2c_init(hdmi); + inno_hdmi_i2c_init(hdmi, mode->clock * 1000); /* Unmute video and audio output */ hdmi_modb(hdmi, HDMI_AV_MUTE, m_AUDIO_MUTE | m_VIDEO_BLACK, @@ -768,8 +765,7 @@ static int inno_hdmi_bind(struct device *dev, struct device *master, * PCLK_HDMI, so we need to init the TMDS rate to PCLK rate, * and reconfigure the DDC clock. */ - hdmi->tmds_rate = clk_get_rate(hdmi->pclk); - inno_hdmi_i2c_init(hdmi); + inno_hdmi_i2c_init(hdmi, clk_get_rate(hdmi->pclk)); ret = inno_hdmi_register(drm, hdmi); if (ret)