From patchwork Thu Dec 7 15:49:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 17698 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4873977vqy; Thu, 7 Dec 2023 07:49:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IE2s8vCONVHCmqYa+u2+J/u0zfhsDFEkAK+/v2Ji3ccO1CoPPuWYK9EQniKTXZtdfm9fBuL X-Received: by 2002:a05:6a20:6a25:b0:18f:f57a:e761 with SMTP id p37-20020a056a206a2500b0018ff57ae761mr1820563pzk.63.1701964179226; Thu, 07 Dec 2023 07:49:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701964179; cv=none; d=google.com; s=arc-20160816; b=BpsZLrdDT/HhW+y5k6CWDV8wxTTZF8H7VLSafRW8S3oN5HjCzs1M+i5cAzk8XeFQnO D17dzbZHRAzbV24+YJxbyocQAUIrcPURRsGHTLH2vLHVEx5LgePbxsDMsjNSmMi4gmqR Vl1PY6WOlWIiX5hbYGChG3MiZ6IsNg0Pp4vCcCZEMevjjRyVIqwJwYkuf8twUitbgoDv WPFT3mOT2AMW2UBH2twl90G4Qbs+kRfYBcQdnrjteR0pHP/c7/DDhaHqgPtKo/+mw9l8 /d3jgX1TlcUZ41F7J9ypIKIS1QyMVtRZW/DANtBaAv7EzSZ3S9b3begk9h+DgX19cTm+ DR5Q== 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=me1WHZomWfYFLABHouSvH3VlUtQL1YE22w3bitgQAec=; fh=Xa1ItbD8vaWzycaFWdXzDVTJ4xRcndfILeO0pjByz2U=; b=HzyzCMBHjeUiI5kgQx/2LTrbwoY9RO7zw3bSxY2/g5eiW4bUiHxo4Eb+Sk+DcPiGpL acSbXPPb4OxZZHVQ/gCqO3G2pzF63jS/r2UxeyDwkcLLSRUYOR2Zl1VQ3vu8B/OHvlvQ HheqrPvRFPNp/pp9EOqQVaVymsciX60w1d0TyMBv5JxBh3ynwrPWp/ADAp4f9b9yjRAj 9ECfakbBq47umgdqo/nOa/41S3dsXY1+MYW6415ukvIADeMK63+qcbTRStOj5UXYyxiA Ks36090+BV9kax3bfy03StkD86o1PxH2mBgXRRZ7AI+veOe2qJ4/8gQraA6KKLR43mb/ z+gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Stkh7Ehp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id f18-20020a631012000000b005c6666dcce1si1355604pgl.583.2023.12.07.07.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 07:49:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Stkh7Ehp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 6941080BEF25; Thu, 7 Dec 2023 07:49:34 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443551AbjLGPtZ (ORCPT + 99 others); Thu, 7 Dec 2023 10:49:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443511AbjLGPtY (ORCPT ); Thu, 7 Dec 2023 10:49:24 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73D93B9 for ; Thu, 7 Dec 2023 07:49:30 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9776AC433C7; Thu, 7 Dec 2023 15:49:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701964170; bh=/u5kEPo+v6kSj/0L0lrQuH79nm8Vys8QGHNxQV73pAk=; h=From:Subject:Date:To:Cc:From; b=Stkh7EhprDaD81vZluQUhrvMjIoSZjLcEtWo58nj1SXn42I1TIrLavuL9gJl05z3H IIk7vVvhvzp96SgdMk1eN/iDUggeXM9ev4gOdaZohOSnwdcgEBXnusNhKgg9unHTbT D1o+cY1WLFOF/81dNokOcGwBnZLO35RU17wqsysoJNrAkcihfqEDsmsmOxUMrtp5TN MGorkNmTAZMtNfP7pLDaMs7ndEEHpo3mILCk+KPJjCwzyoulJTLQJB5A8uICaXNidv HZPjJfzlEjYFd/P6gSGbSNPsuMRBPTHM71DUBvORUJpMJAMYAlxrkJK5KXzhqUA/mc upKLU/GeBmiZw== From: Maxime Ripard Subject: [PATCH v5 00/44] drm/connector: Create HDMI Connector infrastructure Date: Thu, 07 Dec 2023 16:49:23 +0100 Message-Id: <20231207-kms-hdmi-connector-state-v5-0-6538e19d634d@kernel.org> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAIPpcWUC/43MwWrDMBAE0F8JOldhdyVLck/9j5KDam1ikUYGy RhK8L9n6SEhBExOwzDMu6rGNXNTn7urqrzklqcipfvYqWGM5cQ6J+mKgAwEtPp8aXpMl6yHqRQ e5qnqNseZtUPng2fne/JK7mNuMv79ywtKfL+BLKhBgw3Q2XQ0rrNfZ66Ff/dTPamDqAs9pJ5gQ yKR0PeGUkwp+fQimbuEYHBDMiIZCj9wjGxN9C+SfUhIYUOyIg3eAWEXDDh+ktZ1vQE0dbE3jwE AAA== 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 , Johan Jonker , Sui Jingfeng X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=8681; i=mripard@kernel.org; h=from:subject:message-id; bh=/u5kEPo+v6kSj/0L0lrQuH79nm8Vys8QGHNxQV73pAk=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDKmFL1u413FHb/h/7nzaF4e9D1RrJx23Yjrlfcr9xx+b2 EObH5d86ChlYRDjYpAVU2SJETZfEndq1utONr55MHNYmUCGMHBxCsBEPnsx/C/Ur3Es1UmTzVKO yHj8wthj2q2kJH2TIFM9Je1pj/beC2dk2DP7/NNlC9ed/JGet0nFd43m93gXi1u/G/t1Jqxg+n2 SmQ8A X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-Spam-Status: No, score=-1.2 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 agentk.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 (agentk.vger.email [0.0.0.0]); Thu, 07 Dec 2023 07:49:34 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784638791147286942 X-GMAIL-MSGID: 1784638791147286942 Hi, Here's a series that creates some extra infrastructure 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 a tool to decode (and eventually check) infoframes. His current work on edid-decode to enable that based on that series can be found here: https://git.linuxtv.org/hverkuil/edid-decode.git/log/?h=hverkuil And some more context here: https://lore.kernel.org/dri-devel/50db7366-cd3d-4675-aaad-b857202234de@xs4all.nl/ This series thus leverages the infoframe generation code to expose it through debugfs. I also used the occasion to unit-test everything but the infoframe generation, which can come later once I get a proper understanding of what the infoframe are supposed to look like. This required to add some extra kunit helpers and infrastructure to have multiple EDIDs and allow each test to run with a particular set of capabilities. This entire series has been tested on a Pi4, passes all its unittests (125 new tests), and has only been build-tested for sunxi and rockchip. Let me know what you think, Maxime Signed-off-by: Maxime Ripard --- Changes in v5: - Dropped the connector init arg checking patch, and the related kunit tests - Dropped HDMI Vendor infoframes in rockchip inno_hdmi - Fixed the build warnings - Link to v4: https://lore.kernel.org/r/20231128-kms-hdmi-connector-state-v4-0-c7602158306e@kernel.org Changes in v4: - Create unit tests for everything but infoframes - Fix a number of bugs identified by the unit tests - Rename DRM (Dynamic Range and Mastering) infoframe file to HDR_DRM - Drop RFC status - Link to v3: https://lore.kernel.org/r/20231031-kms-hdmi-connector-state-v3-0-328b0fae43a7@kernel.org 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 (44): drm/tests: helpers: Include missing drm_drv header drm/tests: helpers: Add atomic helpers drm/tests: Add helper to create mock plane drm/tests: Add helper to create mock crtc drm/tests: connector: Add tests for drmm_connector_init drm/connector: Introduce an HDMI connector initialization function drm/connector: hdmi: Create an HDMI sub-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/vc4: tests: Remove vc4_dummy_plane structure drm/vc4: tests: Convert to plane creation helper 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: Drop HDMI Vendor Infoframe support drm/rockchip: inno_hdmi: Move infoframe disable to separate function 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 | 659 ++++++++ drivers/gpu/drm/drm_atomic_uapi.c | 4 + drivers/gpu/drm/drm_connector.c | 243 +++ drivers/gpu/drm/drm_debugfs.c | 110 ++ drivers/gpu/drm/rockchip/inno_hdmi.c | 346 +--- drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 203 ++- drivers/gpu/drm/tests/Makefile | 1 + .../gpu/drm/tests/drm_atomic_state_helper_test.c | 1728 ++++++++++++++++++++ drivers/gpu/drm/tests/drm_connector_test.c | 1227 +++++++++++++- drivers/gpu/drm/tests/drm_kunit_edid.h | 482 ++++++ drivers/gpu/drm/tests/drm_kunit_helpers.c | 150 ++ drivers/gpu/drm/vc4/tests/vc4_mock.c | 6 +- drivers/gpu/drm/vc4/tests/vc4_mock.h | 9 +- drivers/gpu/drm/vc4/tests/vc4_mock_plane.c | 44 +- drivers/gpu/drm/vc4/vc4_hdmi.c | 626 +------ 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 | 257 +++ include/drm/drm_kunit_helpers.h | 23 + 23 files changed, 5202 insertions(+), 991 deletions(-) --- base-commit: 90d50b8d85834e73536fdccd5aa913b30494fef0 change-id: 20230814-kms-hdmi-connector-state-616787e67927 Best regards,