[PATCH v1 00/35] drm: Analog TV Improvements

From: Maxime Ripard
Date: Fri Jul 29 2022 - 12:41:24 EST


Hi,

Here's a series aiming at improving the command line named modes support,
and more importantly how we deal with all the analog TV variants.

The named modes support were initially introduced to allow to specify the
analog TV mode to be used.

However, this was causing multiple issues:

* The mode name parsed on the command line was passed directly to the
driver, which had to figure out which mode it was suppose to match;

* Figuring that out wasn't really easy, since the video= argument or what
the userspace might not even have a name in the first place, but
instead could have passed a mode with the same timings;

* The fallback to matching on the timings was mostly working as long as
we were supporting one 525 lines (most likely NSTC) and one 625 lines
(PAL), but couldn't differentiate between two modes with the same
timings (NTSC vs PAL-M vs NSTC-J for example);

* There was also some overlap with the tv mode property registered by
drm_mode_create_tv_properties(), but named modes weren't interacting
with that property at all.

* Even though that property was generic, its possible values were
specific to each drivers, which made some generic support difficult.

Thus, I chose to tackle in multiple steps:

* A new TV norm property was introduced, with generic values, each driver
reporting through a bitmask what standard it supports to the userspace;

* This option was added to the command line parsing code to be able to
specify it on the kernel command line, and new atomic_check and reset
helpers were created to integrate properly into atomic KMS;

* The named mode parsing code is now creating a proper display mode for
the given named mode, and the TV standard will thus be part of the
connector state;

* Two drivers were converted and tested for now (vc4 and sun4i), with
some backward compatibility code to translate the old TV mode to the
new TV mode;

Unit tests were created along the way. Nouveau, ch7006 and gud are
currently broken for now since I expect that work to be reworked fairly
significantly. I'm also not entirely sure about how to migrate GUD to the
new property.

Let me know what you think,
Maxime

Cc: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
Cc: "Noralf Trønnes" <noralf@xxxxxxxxxxx>
Cc: Dave Stevenson <dave.stevenson@xxxxxxxxxxxxxxx>
Cc: Dom Cobley <dom@xxxxxxxxxxxxxxx>
Cc: Phil Elwell <phil@xxxxxxxxxxxxxxx>
Cc: Maarten Lankhorst <maarten.lankhorst@xxxxxxxxxxxxxxx>
Cc: Thomas Zimmermann <tzimmermann@xxxxxxx>
Cc: Daniel Vetter <daniel@xxxxxxxx>
Cc: David Airlie <airlied@xxxxxxxx>
Cc: <dri-devel@xxxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Maxime Ripard <maxime@xxxxxxxxxx>

---
Mateusz Kwiatkowski (5):
drm/vc4: vec: Refactor VEC TV mode setting
drm/vc4: vec: Remove redundant atomic_mode_set
drm/vc4: vec: Fix timings for VEC modes
drm/vc4: vec: Fix definition of PAL-M mode
drm/vc4: vec: Add support for more analog TV standards

Maxime Ripard (30):
drm/atomic-helper: Rename drm_atomic_helper_connector_tv_reset to avoid ambiguity
drm/connector: Rename subconnector state variable
drm/atomic: Add TV subconnector property to get/set_property
drm/modes: Introduce 480i and 576i modes
drm/connector: Add TV standard property
drm/connector: Only register TV mode property if present
drm/modes: Only consider bpp and refresh before options
drm/client: Add some tests for drm_connector_pick_cmdline_mode()
drm/modes: Move named modes parsing to a separate function
drm/modes: Switch to named mode descriptors
drm/modes: Fill drm_cmdline mode from named modes
drmi/modes: Properly generate a drm_display_mode from a named mode
drm/atomic-helper: Add a TV properties reset helper
drm/atomic-helper: Add an analog TV atomic_check implementation
drm/vc4: vec: Remove empty mode_fixup
drm/vc4: vec: Convert to atomic helpers
drm/vc4: vec: Switch for common modes
drm/vc4: vec: Use TV Reset implementation
drm/vc4: vec: Convert to the new TV mode property
drm/sun4i: tv: Remove unused mode_valid
drm/sun4i: tv: Convert to atomic hooks
drm/sun4i: tv: Merge mode_set into atomic_enable
drm/sun4i: tv: Remove useless function
drm/sun4i: tv: Remove useless destroy function
drm/sun4i: tv: Rename error label
drm/sun4i: tv: Add missing reset assertion
drm/sun4i: tv: Convert to the new TV mode property
drm/connector: Remove TV modes property
drm/modes: Introduce the tv_mode property as a command-line option
drm/modes: Introduce more named modes

drivers/gpu/drm/drm_atomic_state_helper.c | 166 +++++++++-
drivers/gpu/drm/drm_atomic_uapi.c | 12 +-
drivers/gpu/drm/drm_client_modeset.c | 4 +
drivers/gpu/drm/drm_connector.c | 46 ++-
drivers/gpu/drm/drm_modes.c | 198 +++++++++--
drivers/gpu/drm/gud/gud_connector.c | 2 +-
drivers/gpu/drm/meson/meson_encoder_cvbs.c | 18 +-
drivers/gpu/drm/meson/meson_encoder_cvbs.h | 2 +-
drivers/gpu/drm/sun4i/sun4i_tv.c | 173 +++-------
drivers/gpu/drm/tests/drm_cmdline_parser_test.c | 295 +++++++++++++++++
drivers/gpu/drm/tests/drm_mode_test.c | 255 +++++++++++++++
drivers/gpu/drm/vc4/vc4_hdmi.c | 2 +-
drivers/gpu/drm/vc4/vc4_vec.c | 418 ++++++++++++++++--------
include/drm/drm_atomic_state_helper.h | 4 +
include/drm/drm_connector.h | 40 ++-
include/drm/drm_mode_config.h | 6 +
include/drm/drm_modes.h | 3 +
17 files changed, 1314 insertions(+), 330 deletions(-)
---
base-commit: 37b355fdaf31ee18bda9a93c2a438dc1cbf57ec9
change-id: 20220728-rpi-analog-tv-properties-0914dfcee460

Best regards,
--
Maxime Ripard <maxime@xxxxxxxxxx>