Message ID | 20240527-kms-hdmi-connector-state-v15-0-c5af16c3aae2@kernel.org |
---|---|
Headers | show |
Series | drm/connector: Create HDMI Connector infrastructure | expand |
On Mon, May 27, 2024 at 03:58:06PM +0200, Maxime Ripard wrote: > The Broadcast RGB property has been documented as three separate entries > so far, each with a different set of values. > > The first one is pretty much the generic one: it's used by i915 and vc4, > and is the one used by all the compositors. > > The second one is used by the gma500 driver, and is a subset of the > first one: it can have the values "Full" or "Limited 16:235", but lack > the "Automatic" value. > > The third one however isn't used by any driver and documents the values > "off", "auto" and "on". > > It's unclear where the last one comes from. It was first documented in > commit 6c6a3996f2c5 ("Documentation: drm: describing drm properties > exposed by various drivers") which adds a number of properties used by > drivers, but without mentioning which driver was using what property. > > Grepping at the 6c6a3996f2c5 commit however, it looks like no driver is > actually using it, and a quick look at the entire kernel history doesn't > show any match either. > > At the time though, gma500 had an "audio" property used right next to > Broadcast RGB that did have the "off", "auto" and "on" values in the > same order. > > As such, it was probably a copy/paste or scripting error back then, and > there's never been such property used in the kernel. > > Either way, it certainly hasn't been used in a decade or two so we can > just get rid of it. > > Suggested-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > Signed-off-by: Maxime Ripard <mripard@kernel.org> > --- > Documentation/gpu/kms-properties.csv | 1 - > 1 file changed, 1 deletion(-) > Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
On Mon, 27 May 2024 15:57:49 +0200, Maxime Ripard wrote: > 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. > > [...] Applied to misc/kernel.git (drm-misc-next). Thanks! Maxime
On Mon, 27 May 2024, Maxime Ripard <mripard@kernel.org> wrote:
> Let me know what you think,
Sorry to report that this series generates a bunch of kernel-doc
warnings in include/drm/drm_connector.h. Documenting nested struct
members doesn't work as smoothly as you'd expect:
../include/drm/drm_connector.h:1138: warning: Excess struct member 'broadcast_rgb' description in 'drm_connector_state'
../include/drm/drm_connector.h:1138: warning: Excess struct member 'infoframes' description in 'drm_connector_state'
../include/drm/drm_connector.h:1138: warning: Excess struct member 'avi' description in 'drm_connector_state'
../include/drm/drm_connector.h:1138: warning: Excess struct member 'hdr_drm' description in 'drm_connector_state'
../include/drm/drm_connector.h:1138: warning: Excess struct member 'spd' description in 'drm_connector_state'
../include/drm/drm_connector.h:1138: warning: Excess struct member 'vendor' description in 'drm_connector_state'
../include/drm/drm_connector.h:1138: warning: Excess struct member 'is_limited_range' description in 'drm_connector_state'
../include/drm/drm_connector.h:1138: warning: Excess struct member 'output_bpc' description in 'drm_connector_state'
../include/drm/drm_connector.h:1138: warning: Excess struct member 'output_format' description in 'drm_connector_state'
../include/drm/drm_connector.h:1138: warning: Excess struct member 'tmds_char_rate' description in 'drm_connector_state'
../include/drm/drm_connector.h:2112: warning: Excess struct member 'vendor' description in 'drm_connector'
../include/drm/drm_connector.h:2112: warning: Excess struct member 'product' description in 'drm_connector'
../include/drm/drm_connector.h:2112: warning: Excess struct member 'supported_formats' description in 'drm_connector'
../include/drm/drm_connector.h:2112: warning: Excess struct member 'infoframes' description in 'drm_connector'
../include/drm/drm_connector.h:2112: warning: Excess struct member 'lock' description in 'drm_connector'
../include/drm/drm_connector.h:2112: warning: Excess struct member 'audio' description in 'drm_connector'
Noticed this when I was rebasing [1]. Having that merged would find
issues in headers at build time instead of 'make htmldocs'.
In the mean time, this is the quick reproducer:
$ scripts/kernel-doc -none include/drm/drm_connector.h
BR,
Jani.
[1] https://lore.kernel.org/r/20240402140136.1722533-1-jani.nikula@intel.com
Hi Hans, On Wed, Jul 31, 2024 at 04:56:16PM GMT, Hans Verkuil wrote: > Hi Maxime, > > On 27/05/2024 15:57, Maxime Ripard wrote: > <snip> > > > 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 > > Since this patch series is now merged in mainline I also pushed support > for parsing InfoFrames to the edid-decode git repo. > > I believe the parsing part of the InfoFrames is complete, but the conformity > checks for the AVI and HDMI InfoFrames are still work-in-progress. But it > should be easier to develop this now that is merged. > > The git repo for edid-decode is here: https://git.linuxtv.org/edid-decode.git/ > > I added test files to the test/if directory, and if you run: > > edid-decode -I audio.test -I avi.test -I vendor.test -I spd.test edid.test -c > > you'll get the output below. That's awesome to hear, I'll send a patch for the KMS documentation to mention it Thanks! Maxime
Hi Am 27.05.24 um 15:57 schrieb Maxime Ripard: > A lot of the various HDMI drivers duplicate some logic that depends on > the HDMI spec itself and not really a particular hardware > implementation. > > Output BPC or format selection, infoframe generation are good examples > of such areas. > > This creates a lot of boilerplate, with a lot of variations, which makes > it hard for userspace to rely on, and makes it difficult to get it right > for drivers. > > In the next patches, we'll add a lot of infrastructure around the > drm_connector and drm_connector_state structures, which will allow to > abstract away the duplicated logic. This infrastructure comes with a few > requirements though, and thus we need a new initialization function. > > Hopefully, this will make drivers simpler to handle, and their behaviour > more consistent. > > Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com> > Reviewed-by: Sui Jingfeng <sui.jingfeng@linux.dev> > Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > Signed-off-by: Maxime Ripard <mripard@kernel.org> > --- > drivers/gpu/drm/drm_connector.c | 39 +++++++++++++++++++++++++++++++++++++++ > include/drm/drm_connector.h | 5 +++++ > 2 files changed, 44 insertions(+) > > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c > index b0516505f7ae..d9961cce8245 100644 > --- a/drivers/gpu/drm/drm_connector.c > +++ b/drivers/gpu/drm/drm_connector.c > @@ -450,10 +450,49 @@ int drmm_connector_init(struct drm_device *dev, > > return 0; > } > EXPORT_SYMBOL(drmm_connector_init); > > +/** > + * drmm_connector_hdmi_init - Init a preallocated HDMI connector > + * @dev: DRM device > + * @connector: A pointer to the HDMI connector to init > + * @funcs: callbacks for this connector > + * @connector_type: user visible type of the connector > + * @ddc: optional pointer to the associated ddc adapter > + * > + * Initialises a preallocated HDMI connector. Connectors can be > + * subclassed as part of driver connector objects. > + * > + * Cleanup is automatically handled with a call to > + * drm_connector_cleanup() in a DRM-managed action. > + * > + * The connector structure should be allocated with drmm_kzalloc(). > + * > + * Returns: > + * Zero on success, error code on failure. > + */ > +int drmm_connector_hdmi_init(struct drm_device *dev, > + struct drm_connector *connector, > + const struct drm_connector_funcs *funcs, > + int connector_type, > + struct i2c_adapter *ddc) I know I'm late to the review. Wouldn't it be better to make a separate HDMI-setup helper instead of yet another init function? The type of init function to use is mostly about memory management within the driver, while the new HDMI state is about features. Maybe rather add something like drm_connector_init_hdmi_state(), which takes an initialized connector and sets all the values coming the other patches. Drivers would not have to subscribe to a certain way of memory management. AFAICT this would also allow to protect the helper and the new drm_connector.hdmi field behind DRM_DISPLAY_HDMI_STATE_HELPER. Best regards Thomas > +{ > + int ret; > + > + if (!(connector_type == DRM_MODE_CONNECTOR_HDMIA || > + connector_type == DRM_MODE_CONNECTOR_HDMIB)) > + return -EINVAL; > + > + ret = drmm_connector_init(dev, connector, funcs, connector_type, ddc); > + if (ret) > + return ret; > + > + return 0; > +} > +EXPORT_SYMBOL(drmm_connector_hdmi_init); > + > /** > * drm_connector_attach_edid_property - attach edid property. > * @connector: the connector > * > * Some connector types like DRM_MODE_CONNECTOR_VIRTUAL do not get a > diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h > index fe88d7fc6b8f..4491c4c2fb6e 100644 > --- a/include/drm/drm_connector.h > +++ b/include/drm/drm_connector.h > @@ -1902,10 +1902,15 @@ int drm_connector_init_with_ddc(struct drm_device *dev, > int drmm_connector_init(struct drm_device *dev, > struct drm_connector *connector, > const struct drm_connector_funcs *funcs, > int connector_type, > struct i2c_adapter *ddc); > +int drmm_connector_hdmi_init(struct drm_device *dev, > + struct drm_connector *connector, > + const struct drm_connector_funcs *funcs, > + int connector_type, > + struct i2c_adapter *ddc); > void drm_connector_attach_edid_property(struct drm_connector *connector); > int drm_connector_register(struct drm_connector *connector); > void drm_connector_unregister(struct drm_connector *connector); > int drm_connector_attach_encoder(struct drm_connector *connector, > struct drm_encoder *encoder); >
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 <mripard@kernel.org> --- Changes in v15: - Fix YUV422 bpc check - Mention explicitly (and in the logs) that YUV420 isn't supported for now - Fix warning when running the bpc test - Change the order of the drm_mode_obj_find_prop_id export patch - Fix some sun4i changes having made their way into the rockchip patch - Drop spurious Broadcast RGB documentation - Link to v14: https://lore.kernel.org/r/20240521-kms-hdmi-connector-state-v14-0-51950db4fedb@kernel.org Changes in v14: - Warn instead of rejecting the configuration if RGB is missing due to some bad or faulty EDID - Link to v13: https://lore.kernel.org/r/20240507-kms-hdmi-connector-state-v13-0-8fafc5efe8be@kernel.org Changes in v13: - Adapt to latest Kconfig helper changes - Fixes for sun4i and rockchip - Rebase on current drm-misc-next - Link to v12: https://lore.kernel.org/r/20240423-kms-hdmi-connector-state-v12-0-3338e4c0b189@kernel.org Changes in v12: - Rebase on current drm-misc-next - Remove VIC check in clock rate computation function - Invert RGB range logic to signal limited range instead of full like before - Link to v11: https://lore.kernel.org/r/20240326-kms-hdmi-connector-state-v11-0-c5680ffcf261@kernel.org Changes in v11: - Turn the HDMI state helpers into a separate C file under drivers/gpu/drm/display - Rework the Kconfig options too to prevent configuration breakages. - Link to v10: https://lore.kernel.org/r/20240321-kms-hdmi-connector-state-v10-0-e6c178361898@kernel.org Changes in v10: - Drop the YUV422 fallback, and adjust the tests accordingly - Fix HDMI infoframe handling - Remove the infoframe copy in drm_connector - Add a TODO that drm_hdmi_avi_infoframe_quant_range() only works for RGB - Add a TODO for the YUV420 selection - Fix a few bugs in vc4 - Change the logging from driver to KMS for the helpers - Drop UPDATE_INFOFRAME macro - Add infoframe code logging - Document the selection of 8bpc for VIC1 - Rename state to conn_state where relevant - Link to v9: https://lore.kernel.org/r/20240311-kms-hdmi-connector-state-v9-0-d45890323344@kernel.org Changes in v9: - Generate every infoframe but the HDMI vendor one if has_hdmi_infoframe isn't set - Fix typos in the doc - Removed undef for inexisting macro - Improve the Broadcast RGB sanitation test - Make EDID bytes array const - Link to v8: https://lore.kernel.org/r/20240307-kms-hdmi-connector-state-v8-0-ef6a6f31964b@kernel.org Changes in v8: - Drop applied patches - Drop the YUV limited range mention in the Broadcast RGB documentation - Rephrase the vc4_dummy_plane removal commit log - Move infroframe mutex initialisation to the main drm_connector_init function to make sure it's always initialised - Link to v7: https://lore.kernel.org/r/20240222-kms-hdmi-connector-state-v7-0-8f4af575fce2@kernel.org Changes in v7: - Rebased on top of current next - Only consider the Broadcast RGB property if the output format is RGB, and use a limited range otherwise - Document the fact that Broadcast RGB only applies if the output format is RGB - Add some test to make sure we always get a limited range if we have a YCbCr output format. - Link to v6: https://lore.kernel.org/r/20240212-kms-hdmi-connector-state-v6-0-f4bcdc979e6f@kernel.org Changes in v6: - Rebased on top of current next - Split the tests into separate patches - Improve the Broadcast RGB documentation - Link to v5: https://lore.kernel.org/r/20231207-kms-hdmi-connector-state-v5-0-6538e19d634d@kernel.org 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 (29): drm/connector: Introduce an HDMI connector initialization function drm/tests: connector: Add tests for drmm_connector_hdmi_init drm/connector: hdmi: Create an HDMI sub-state drm/connector: hdmi: Add output BPC to the connector state drm/mode_object: Export drm_mode_obj_find_prop_id for tests drm/tests: Add output bpc tests drm/connector: hdmi: Add support for output format drm/tests: Add output formats tests drm/display: hdmi: Add HDMI compute clock helper drm/tests: Add HDMI TDMS character rate tests drm/connector: hdmi: Calculate TMDS character rate drm/tests: Add TDMS character rate connector state tests drm/connector: hdmi: Add custom hook to filter TMDS character rate drm/tests: Add HDMI connector rate filter hook tests drm/connector: hdmi: Compute bpc and format automatically drm/tests: Add HDMI connector bpc and format tests drm/doc: Remove unused Broadcast RGB Property drm/connector: hdmi: Add Broadcast RGB property drm/tests: Add tests for Broadcast RGB property drm/connector: hdmi: Add RGB Quantization Range to the connector state drm/tests: Add RGB Quantization tests drm/connector: hdmi: Add Infoframes generation drm/tests: Add infoframes test drm/connector: hdmi: Create Infoframe DebugFS entries 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: Switch to HDMI connector drm/sun4i: hdmi: Switch to HDMI connector Documentation/gpu/kms-properties.csv | 2 - drivers/gpu/drm/Kconfig | 1 + drivers/gpu/drm/display/Kconfig | 7 + drivers/gpu/drm/display/Makefile | 2 + drivers/gpu/drm/display/drm_hdmi_helper.c | 61 + drivers/gpu/drm/display/drm_hdmi_state_helper.c | 716 ++++++++ drivers/gpu/drm/drm_atomic.c | 11 + drivers/gpu/drm/drm_atomic_uapi.c | 4 + drivers/gpu/drm/drm_connector.c | 194 +++ drivers/gpu/drm/drm_debugfs.c | 152 ++ drivers/gpu/drm/drm_mode_object.c | 1 + drivers/gpu/drm/rockchip/Kconfig | 3 + drivers/gpu/drm/rockchip/inno_hdmi.c | 172 +- drivers/gpu/drm/sun4i/Kconfig | 3 + drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 84 +- drivers/gpu/drm/tests/Makefile | 1 + drivers/gpu/drm/tests/drm_connector_test.c | 1051 +++++++++++- drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c | 1743 ++++++++++++++++++++ drivers/gpu/drm/tests/drm_kunit_edid.h | 482 ++++++ drivers/gpu/drm/vc4/Kconfig | 1 + 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 | 644 +------- drivers/gpu/drm/vc4/vc4_hdmi.h | 44 +- drivers/gpu/drm/vc4/vc4_hdmi_phy.c | 6 +- include/drm/display/drm_hdmi_helper.h | 4 + include/drm/display/drm_hdmi_state_helper.h | 23 + include/drm/drm_connector.h | 229 +++ 29 files changed, 4911 insertions(+), 789 deletions(-) --- base-commit: 533db32499de1618443b2249bc20011cd5abc9d9 change-id: 20230814-kms-hdmi-connector-state-616787e67927 Best regards,