From patchwork Tue Oct 31 16:48:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 16110 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b90f:0:b0:403:3b70:6f57 with SMTP id t15csp372743vqg; Tue, 31 Oct 2023 09:49:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFru/j92ymu45nEjNgw/m2ZJpBTpnIvoVYJgg/fLAdIszkI/K7XZQdreQ3gdXdUi8w95+PR X-Received: by 2002:a17:902:ce83:b0:1cc:6ec2:d24e with SMTP id f3-20020a170902ce8300b001cc6ec2d24emr1448524plg.53.1698770956035; Tue, 31 Oct 2023 09:49:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698770956; cv=none; d=google.com; s=arc-20160816; b=bI1BNeX/jfqkdtmpH9nQgJxb0iHz/lPpu6MFCxuVzS35EyTuRDoBYWnteIptiSQ3Vh SWhKdsNAHupVE1JPsZtgojJT5ylcuDqMGz0x1jYWEz9zZwCVmjwTNbhA0ITpL1oBYhjQ DTG4UmHnTjM2uL1+L94GvG3EdCZrvgexn9C7oMqWsulYERQ/XEIIcIY/srkF9NF3lVhX q4nl8q8PbnfhC7zkXCROq9LtrpbdjFj7oYvJBApb3c5zs6hyzpv5V5WL6mf/Qwwvexo3 Dq7vBhgtgBLE5bbg38Phqs++R9VL2HS8zdRFFAZN+grj72GU9HMnhui66e5Qjz3HtfrA 26sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:content-transfer-encoding:mime-version :message-id:date:subject:from:dkim-signature; bh=Ib9fr8OCbgpL1Lj9V+JCC8UmQjwbIU3xStwdQHYbTRI=; fh=e6/uyeFf2k7v8JUtB6fPyaAS5iN3eSA1hjtg35V2Rzw=; b=d0W6W8OtYuTeCxzKOUEa9mpLSYEr3o6AvLqafHZjAQYM3rD4EOqi18bgEZhiwCuxcl bLo2OTbwN+sGreTEpHMBE05FCYe1UN/fHGj2VGbCPjB84hYTiS4vyFlYu29A325NIT6M 6n7PkNB7WozGJkz1hXUPHgEbT9uVXM0swG6nTyhPNPQXnQhN0EUu2HrgJl0mQm6YCBrc +3csyKryozD6xITZdo4tKK28mUdWnomA/0JO/XxPoKrrd29Kmwf2wJAUlB5F2nTZube4 qOyog2i3dRn3oNDZYIbZExkj5Jv0a03JFTxRGluEsbx3+Or2BCIaTE2ckM7uGQZGHd2t IFag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dKz+IPkB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id cb14-20020a056a02070e00b0057745d87b53si1280482pgb.686.2023.10.31.09.49.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 09:49:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dKz+IPkB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id EFDE88045BF4; Tue, 31 Oct 2023 09:49:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346033AbjJaQsj (ORCPT + 33 others); Tue, 31 Oct 2023 12:48:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235751AbjJaQsi (ORCPT ); Tue, 31 Oct 2023 12:48:38 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 321F7DF; Tue, 31 Oct 2023 09:48:35 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6096DC433C8; Tue, 31 Oct 2023 16:48:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698770914; bh=UTXiOQLTvMkvbOw9m5YrJAM7tKQY8I2vb1txsTaB+ww=; h=From:Subject:Date:To:Cc:From; b=dKz+IPkB1YjAQopIg5/wqctpT5XPs9kwBvEabr+vWXBfR1DJQsQFx+pMcgaIEDDr6 zhDX7M43NkPtBzJZzzP/ym0ci/wAtup3XaRXBoX8wD9GYYFclvFj8H1T1/Do5LBYd1 hM7fDUi5YJ/V+u+BmcT3R5sBdG4xQS/6QFfxh4GAMEUNNRdFvH8fI8sEA9SvidqjFy JBTP7EXruC/zsdqsdIXg90Se/zIe2F4067naac1sdD0rwT89gRPsY9HJZerMqa/ChA ht/mLTlsTrttAEiu8flbJVOOqfdZI4dWNDV1Rt23pB+mqFg8RoKVkuCDwyYrM1dpUI Sq42JQDpOSaVQ== From: Maxime Ripard Subject: [PATCH RFC v3 00/37] drm/connector: Create HDMI Connector infrastructure Date: Tue, 31 Oct 2023 17:48:13 +0100 Message-Id: <20231031-kms-hdmi-connector-state-v3-0-328b0fae43a7@kernel.org> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAM4vQWUC/4XNQQrCMBAF0KuUrI0kaZq0rgTBA7gVF6UzbUNtI kkJSundDdmIG13+P/w3KwnoDQZyKFbiMZpgnE2h3BWkG1s7IDWQMhFMlKzmkk5zoCPMhnbOWuw W52lY2gWp4krXGpVuhCZp/vDYm2emr+RyPpFbKkcT0uKV30WeT//lyCmjTNasktCXqpLHCb3F+ 975IatRfKRGsB+SSBLXTSmgBQANX9K2bW9wAKu8EAEAAA== 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=6338; i=mripard@kernel.org; h=from:subject:message-id; bh=UTXiOQLTvMkvbOw9m5YrJAM7tKQY8I2vb1txsTaB+ww=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDKmO+nef/XR+1KS6yUn3KisHU07+rHXlqS5rMrhZ0qxXe EoytAd1lLIwiHExyIopssQImy+JOzXrdScb3zyYOaxMIEMYuDgFYCKieYwMs/ZqGpVUHdwml71F fePTlqXcpWxxrQydIRL+rDG3emZZMjK8euUSeHxTdqmwZdWPqM+5ETF+t+4mc11SnSIyZ5qC7gZ WAA== 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 groat.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 (groat.vger.email [0.0.0.0]); Tue, 31 Oct 2023 09:49:10 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781290454260028849 X-GMAIL-MSGID: 1781290454260028849 Hi, Here's a series that creates a subclass of drm_connector specifically targeted at HDMI controllers. The idea behind this series came from a recent discussion on IRC during which we discussed infoframes generation of i915 vs everything else. Infoframes generation code still requires some decent boilerplate, with each driver doing some variation of it. In parallel, while working on vc4, we ended up converting a lot of i915 logic (mostly around format / bpc selection, and scrambler setup) to apply on top of a driver that relies only on helpers. While currently sitting in the vc4 driver, none of that logic actually relies on any driver or hardware-specific behaviour. The only missing piece to make it shareable are a bunch of extra variables stored in a state (current bpc, format, RGB range selection, etc.). The initial implementation was relying on some generic subclass of drm_connector to address HDMI connectors, with a bunch of helpers that will take care of all the "HDMI Spec" related code. Scrambler setup is missing at the moment but can easily be plugged in. The feedback was that creating a connector subclass like was done for writeback would prevent the adoption of those helpers since it couldn't be used in all situations (like when the connector driver can implement multiple output) and required more churn to cast between the drm_connector and its subclass. The decision was thus to provide a set of helper and to store the required variables in drm_connector and drm_connector_state. This what has been implemented now. Hans Verkuil also expressed interest in implementing a mechanism in v4l2 to retrieve infoframes from HDMI receiver and implementing an infoframe-decode tool. This series thus leverages the infoframe generation code to expose it through debugfs. This entire series has been tested on a Pi4, and has only been build-tested for sunxi and rockchip. Let me know what you think, Maxime Signed-off-by: Maxime Ripard --- Changes in v3: - Made sure the series work on the RaspberryPi4 - Handle YUV420 in the char clock rate computation - Use the maximum bpc value the connector allows at reset - Expose the RGB Limited vs Full Range value in the connector state instead of through a helper - Fix Broadcast RGB documentation - Add more debug logging - Small fixes here and there - Link to v2: https://lore.kernel.org/r/20230920-kms-hdmi-connector-state-v2-0-17932daddd7d@kernel.org Changes in v2: - Change from a subclass to a set of helpers for drm_connector and drm_connector state - Don't assume that all drivers support RGB, YUV420 and YUV422 but make them provide a bitfield instead. - Don't assume that all drivers support the Broadcast RGB property but make them call the registration helper. - Document the Broacast RGB property - Convert the inno_hdmi and sun4i_hdmi driver. - Link to v1: https://lore.kernel.org/r/20230814-kms-hdmi-connector-state-v1-0-048054df3654@kernel.org --- Maxime Ripard (37): drm/connector: Introduce an HDMI connector drm/connector: hdmi: Create a custom state drm/connector: hdmi: Add Broadcast RGB property drm/connector: hdmi: Add RGB Quantization Range to the connector state drm/connector: hdmi: Add output BPC to the connector state drm/connector: hdmi: Add support for output format drm/connector: hdmi: Add HDMI compute clock helper drm/connector: hdmi: Calculate TMDS character rate drm/connector: hdmi: Add custom hook to filter TMDS character rate drm/connector: hdmi: Compute bpc and format automatically drm/connector: hdmi: Add Infoframes generation drm/connector: hdmi: Create Infoframe DebugFS entries drm/vc4: hdmi: Create destroy state implementation drm/vc4: hdmi: Switch to HDMI connector drm/rockchip: inno_hdmi: Remove useless mode_fixup drm/rockchip: inno_hdmi: Remove useless copy of drm_display_mode drm/rockchip: inno_hdmi: Switch encoder hooks to atomic drm/rockchip: inno_hdmi: Get rid of mode_set drm/rockchip: inno_hdmi: no need to store vic drm/rockchip: inno_hdmi: Remove unneeded has audio flag drm/rockchip: inno_hdmi: Remove useless input format drm/rockchip: inno_hdmi: Remove useless output format drm/rockchip: inno_hdmi: Remove useless colorimetry drm/rockchip: inno_hdmi: Remove useless enum drm/rockchip: inno_hdmi: Remove tmds rate from structure drm/rockchip: inno_hdmi: Remove useless coeff_csc matrix drm/rockchip: inno_hdmi: Remove useless mode_valid drm/rockchip: inno_hdmi: Move infoframe disable to separate function drm/rockchip: inno_hdmi: Create mask retrieval functions drm/rockchip: inno_hdmi: Switch to infoframe type drm/rockchip: inno_hdmi: Remove unused drm device pointer drm/rockchip: inno_hdmi: Switch to HDMI connector drm/sun4i: hdmi: Convert encoder to atomic drm/sun4i: hdmi: Move mode_set into enable drm/sun4i: hdmi: Switch to container_of_const drm/sun4i: hdmi: Consolidate atomic_check and mode_valid drm/sun4i: hdmi: Switch to HDMI connector Documentation/gpu/kms-properties.csv | 1 - drivers/gpu/drm/Kconfig | 1 + drivers/gpu/drm/drm_atomic.c | 11 + drivers/gpu/drm/drm_atomic_state_helper.c | 661 ++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_atomic_uapi.c | 4 + drivers/gpu/drm/drm_connector.c | 208 ++++++++++ drivers/gpu/drm/drm_debugfs.c | 110 +++++ drivers/gpu/drm/rockchip/inno_hdmi.c | 409 +++++++----------- drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 203 +++++---- drivers/gpu/drm/vc4/vc4_hdmi.c | 624 ++++------------------------ drivers/gpu/drm/vc4/vc4_hdmi.h | 44 +- drivers/gpu/drm/vc4/vc4_hdmi_phy.c | 6 +- include/drm/drm_atomic_state_helper.h | 12 + include/drm/drm_connector.h | 248 +++++++++++ 14 files changed, 1598 insertions(+), 944 deletions(-) --- base-commit: ffc253263a1375a65fa6c9f62a893e9767fbebfa change-id: 20230814-kms-hdmi-connector-state-616787e67927 Best regards,