From patchwork Tue Oct 31 16:48:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 160262 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b90f:0:b0:403:3b70:6f57 with SMTP id t15csp375043vqg; Tue, 31 Oct 2023 09:53:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHaUuAx2ODkz8XjNZ/4/GOUGAa09LO8MPFnEtHP9fXNiY4JVbEZRjlly4fUgXFHnHr/XTmG X-Received: by 2002:a17:902:d2c7:b0:1cc:4efc:c87d with SMTP id n7-20020a170902d2c700b001cc4efcc87dmr6473178plc.55.1698771211353; Tue, 31 Oct 2023 09:53:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698771211; cv=none; d=google.com; s=arc-20160816; b=KLYhvyn8+Ky2Tfu+kttfCHcj3ycTbqMmcYNIG41L51hOox7grFcf/T9+3paa5kfV8u C8VCtUJ4n8wxwdxL7EV9iuzoSTcnAGaI9lqgqO4d7XbId1zJaNKSs8wWS4MEanwf17MZ S/l9/OejJ38ObUFciriFzXclJbOzogPju/VgXADZadAK4U2OWh3RHFc0ai/RVSkYjGL1 iI6PN84lEy4+lh3M3V3XuzK78xDxCinrjFdquwclG6FfOGqBRBMuHwr00Hr3jm4CBoy/ JJXcUDsRPAVwyKrW5bcu8eFi8cEMIdBHrDshoGk+1sWcD8ITNoXgQlwcR/ljYx+BKH+H ZARA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=p0S+1JCbHRBjf4KEMC1MhYa37tQLdP/h0qOmTVSb2zU=; fh=e6/uyeFf2k7v8JUtB6fPyaAS5iN3eSA1hjtg35V2Rzw=; b=ROZfAYy98F3NXtJECmgMaTVdpE2BccpMhEP6doEgRehG8EyhjSbKQSW7ixfHjWoqsS m8lfaWshAYJLPiKMuG0hO/gzDklbZncSNxgyCG3z4rYbfkNmVy4eKhZ3l/gHw8PgTm9Y E+cCgvR32FYbICcCG8RzVyNQtSezEIKp/lPrPBAYHqv15hR/yU4lIcet+SqJtQd78diw 4Mqv6UFeBX3YyPTO4MuFyJysZhAFIC0q/LTy3h75Ct/B00eIxfJD4TYe/B0vHHutGSpm Wr2fsJAuf8arZ0RQFXzvdmoNW67CyLg1FScF36fUZOSiGyTwdjvKTZfnJhjlee+W/EfC PQAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Fmlxd2j7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id w1-20020a170902d10100b001c589ba4a0bsi1206639plw.195.2023.10.31.09.53.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 09:53:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Fmlxd2j7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 31AB38029B6D; Tue, 31 Oct 2023 09:53:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376257AbjJaQxM (ORCPT + 33 others); Tue, 31 Oct 2023 12:53:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346853AbjJaQwR (ORCPT ); Tue, 31 Oct 2023 12:52:17 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 656D7D47; Tue, 31 Oct 2023 09:49:46 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B02DCC433C9; Tue, 31 Oct 2023 16:49:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698770986; bh=+5JYn8V0UryLv4NGrPj7TOsjDrccf86rOvDhC/BodNA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Fmlxd2j7TarJj7cZgvHurAprHk03ACpUsmgw7Y1DpEBYdVphqtdyFv0o8kKNvTg9g gf9K1g4RF/QncoudobV4IgACWRPL5UMABqKubkM1KBM8E5kOeVBonQ6skXOgYLUlYX TFs62Bcp3B24tySdE6Ko/5JmW54Se+UpYlr4oNdWRj9Eoioj0iYM9OKydVTypqClBV Wz+SLn8+aKBrH3g3tH/2a4Xh++GtZ/S/tLVgHZN5zEMQtTnBCejdaZ/WX6PCHdaORM ACogEo43K54Sp4rG6f4J/t7GFvzTeEc0rDP9GC8a1D0MXJOER21fAbG8WyiGldr+Oz fx5yeUu5qrOmQ== From: Maxime Ripard Date: Tue, 31 Oct 2023 17:48:38 +0100 Subject: [PATCH RFC v3 25/37] drm/rockchip: inno_hdmi: Remove tmds rate from structure MIME-Version: 1.0 Message-Id: <20231031-kms-hdmi-connector-state-v3-25-328b0fae43a7@kernel.org> References: <20231031-kms-hdmi-connector-state-v3-0-328b0fae43a7@kernel.org> In-Reply-To: <20231031-kms-hdmi-connector-state-v3-0-328b0fae43a7@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=+5JYn8V0UryLv4NGrPj7TOsjDrccf86rOvDhC/BodNA=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDKmO+veziy5EW4ZNWVxoKfle55WA6pOWtMY4n91yqydar HgppC/TUcrCIMbFICumyBIjbL4k7tSs151sfPNg5rAygQxh4OIUgImkX2ZkWKE02yToiO2J1IwA xvKNzaZH2ZY6/ZL1e892PSbLX+vrIUaGE75TJmb96vY8WnJGJePfTcaowImfcng6NZtz+46s+q/ BBAA= X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 31 Oct 2023 09:53:26 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781290721660813984 X-GMAIL-MSGID: 1781290721660813984 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)