Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1619541rdb; Wed, 20 Sep 2023 14:41:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEAIEFMsZ5tJT/FCFABX+wZPHsRxCOAO3ejLqtbQSmqNZVGYdJ0/8MZGT2KQYT0BdPzrkCY X-Received: by 2002:a17:903:52:b0:1c5:8401:355b with SMTP id l18-20020a170903005200b001c58401355bmr6505466pla.29.1695246085431; Wed, 20 Sep 2023 14:41:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695246085; cv=none; d=google.com; s=arc-20160816; b=wxHP8RyWNVEBFlEISr8q91Qp3k22JtKscKgdpWr/j1v5DcZ2rT/TcFjekTFJDifRit Xv06xAB4JybnjTuUgwazkjL6E/7GyjDejo/K4NC06Bo4GqysG9ybRwZyTsHctSKXDfxC wpGVoer5MCQyQUnwOwnXddBhalzhmvmR1WDwwvd14SQ3xU3AbvIiFrRp3/pxQnbIB/Ou jwRWp6ezB0I5vIHlzK3EXcUTTDiI8jOL7+k/iLu6+wKFGyVu/PoNjqszMqCZxnUUbyB6 N9cCfXZ+3Dt5fjCi9S8TpRB9pdLpaRu5vQ5sYd9UQzf56pYwUpRVjpd09R1sciClcZTj iXZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7BA/1TKZ7fFQpqXSbCVNQn/zfVi+d+HyfuxOxnEyY4I=; fh=tuT/jZDmSxN2Z54ILSGez5pC6uRvX4K6I8J2vdCO0YM=; b=UVE5GID4G45f8Fr3SvE1CtL2apTpMaFFDTKvPjVPet+37stYNwaO2aOXm/L4L+rY/1 kMpaCUyaQ3meJQGXiD6Q5aRCi3/YCdZD+wtgBVcLVCVUaMRGezMOoYuYehOI8B05KJcx XI2gz/4IpnjKLqe1TaU+ZJysf4LO4j3ID+ovprjjRE8EKl5rQpNJJ4UvxAInDw/OxGc/ xLL58bb7WL2N5uw1Wl6IRMgUk81YNMBXQLzE2lc+/xpFpPD3gn9u3n11ngVX6sNmwKbA E4dK2w5XqcgY+zF0j3C1xj/a7VQi1WMbdYwIJ2Wpws8CUvatKHPUuVkzZPbYZiLy+y7k Bi5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DHjVpv+1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id w13-20020a170902e88d00b001bdf67d6a8fsi12810657plg.40.2023.09.20.14.41.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 14:41:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DHjVpv+1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id C715B81BFA86; Wed, 20 Sep 2023 10:15:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234609AbjITRPt (ORCPT + 99 others); Wed, 20 Sep 2023 13:15:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234174AbjITRPs (ORCPT ); Wed, 20 Sep 2023 13:15:48 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17A93A3; Wed, 20 Sep 2023 10:15:41 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-530fa34ab80so2594958a12.0; Wed, 20 Sep 2023 10:15:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695230139; x=1695834939; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7BA/1TKZ7fFQpqXSbCVNQn/zfVi+d+HyfuxOxnEyY4I=; b=DHjVpv+1ChsbOTMGB5Dpmk1oEXNskx0m3PcnR6OoHgandUGBYN7ZHi0TmbctauPWHB xFVmItXu0HbroXn9j7pjRvlHZ+8agcIzy5opp8BjoVxeDs9fqrVvUAKzfXlvvV1423CZ OL4NZe6Ct83k/CCPiKtK0AO4i+cNXqCdBv9kqZ/v7HKxnG90TTYam6HPz6xLo06x23RU iZyw/7jlfesMjvUWgFbba4V2qv9Cwz2NctA0eq4t0x+2XsLN1560rjdxokwUP7EoZB3j WtX5EXwKSG3wN30XUGVOFFP/S19GwhGYDSLba+8HTxe0t7MKoA3ihF422ouLgHov0sGn Mnnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695230139; x=1695834939; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7BA/1TKZ7fFQpqXSbCVNQn/zfVi+d+HyfuxOxnEyY4I=; b=utlnOUQ1LGIwFIq9x0XX7Xig4HLuo2AOaSmfKiSWXxNHScCLUSu78UtcsHkBLanv3X m2KGQVCSln8wkNFj+sk7aUskrm6j0eDk9Ku4NC1DI775vH2iZ8Pc7ny+38xUnAWrOidj 2ehyqg4MDTchwIrqPkLIor28uHvtsGuNtYZqLkVX/iUvhhVwxZanPVKcpHJ5Hi/NgWLR doQ5ph+x/MJvVmWHpVW3HAGkWRzyPuHXudZYbNYy+0qQfhFtTz8GlZr0xI1KtKnckTh6 dg2ElDOcn7/9AWOgHPrazCLPlMgYj8xjTkOxWyXcBXdzrVAB6UgW0sn/DjpKrktUfuiC kIOg== X-Gm-Message-State: AOJu0YzW9Os3fAO64JplOm6mdIPftC3kJc7up0/3lvkvtkgN0teojZdR RomGy0zcVrcYoOjNl+fUUAg= X-Received: by 2002:a17:906:3147:b0:993:eee4:e704 with SMTP id e7-20020a170906314700b00993eee4e704mr4288238eje.38.1695230139300; Wed, 20 Sep 2023 10:15:39 -0700 (PDT) Received: from jernej-laptop.localnet (82-149-12-148.dynamic.telemach.net. [82.149.12.148]) by smtp.gmail.com with ESMTPSA id lx12-20020a170906af0c00b00988f168811bsm9649634ejb.135.2023.09.20.10.15.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 10:15:38 -0700 (PDT) From: Jernej =?utf-8?B?xaBrcmFiZWM=?= To: Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Emma Anholt , Jonathan Corbet , Sandy Huang , Heiko =?ISO-8859-1?Q?St=FCbner?= , Chen-Yu Tsai , Samuel Holland , Maxime Ripard 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 Subject: Re: [PATCH RFC v2 07/37] drm/connector: hdmi: Add HDMI compute clock helper Date: Wed, 20 Sep 2023 19:15:37 +0200 Message-ID: <1967070.usQuhbGJ8B@jernej-laptop> In-Reply-To: <20230920-kms-hdmi-connector-state-v2-7-17932daddd7d@kernel.org> References: <20230920-kms-hdmi-connector-state-v2-0-17932daddd7d@kernel.org> <20230920-kms-hdmi-connector-state-v2-7-17932daddd7d@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Wed, 20 Sep 2023 10:15:59 -0700 (PDT) Hi Maxime! Dne sreda, 20. september 2023 ob 16:35:22 CEST je Maxime Ripard napisal(a): > A lot of HDMI drivers have some variation of the formula to calculate > the TMDS character rate from a mode, but few of them actually take all > parameters into account. > > Let's create a helper to provide that rate taking all parameters into > account. > > Signed-off-by: Maxime Ripard > --- > drivers/gpu/drm/drm_connector.c | 31 +++++++++++++++++++++++++++++++ > include/drm/drm_connector.h | 5 +++++ > 2 files changed, 36 insertions(+) > > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c > index b01cb4783ea6..4c1af97971bb 100644 > --- a/drivers/gpu/drm/drm_connector.c > +++ b/drivers/gpu/drm/drm_connector.c > @@ -2944,6 +2944,37 @@ void drm_connector_update_privacy_screen(const struct drm_connector_state *conne > } > EXPORT_SYMBOL(drm_connector_update_privacy_screen); > > +/** > + * drm_connector_hdmi_compute_mode_clock() - Computes the TMDS Character Rate > + * @mode: Display mode to compute the clock for > + * @bpc: Bits per character > + * @fmt: Output Pixel Format used > + * > + * Returns the TMDS Character Rate for a given mode, bpc count and output format. > + * > + * RETURNS: > + * The TMDS Character Rate, in Hertz > + */ > +unsigned long long > +drm_connector_hdmi_compute_mode_clock(const struct drm_display_mode *mode, > + unsigned int bpc, > + enum hdmi_colorspace fmt) > +{ > + unsigned long long clock = mode->clock * 1000ULL; > + > + if (mode->flags & DRM_MODE_FLAG_DBLCLK) > + clock = clock * 2; > + > + if (fmt == HDMI_COLORSPACE_YUV422) > + bpc = 8; I think you're missing YUV420 handling, which needs half of clock speed. But this is a thing of HDMI2. Best regards, Jernej > + > + clock = clock * bpc; > + do_div(clock, 8); > + > + return clock; > +} > +EXPORT_SYMBOL(drm_connector_hdmi_compute_mode_clock); > + > int drm_connector_set_obj_prop(struct drm_mode_object *obj, > struct drm_property *property, > uint64_t value) > diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h > index a66cb4e35d7b..d74e9c64ee88 100644 > --- a/include/drm/drm_connector.h > +++ b/include/drm/drm_connector.h > @@ -38,6 +38,7 @@ struct drm_connector_helper_funcs; > struct drm_modeset_acquire_ctx; > struct drm_device; > struct drm_crtc; > +struct drm_display_mode; > struct drm_encoder; > struct drm_panel; > struct drm_property; > @@ -2115,6 +2116,10 @@ void drm_connector_attach_privacy_screen_properties(struct drm_connector *conn); > void drm_connector_attach_privacy_screen_provider( > struct drm_connector *connector, struct drm_privacy_screen *priv); > void drm_connector_update_privacy_screen(const struct drm_connector_state *connector_state); > +unsigned long long > +drm_connector_hdmi_compute_mode_clock(const struct drm_display_mode *mode, > + unsigned int bpc, > + enum hdmi_colorspace fmt); > > /** > * struct drm_tile_group - Tile group metadata > >