<div dir="ltr">One can switch from NTSC to PAL now using (on vc4)<br><br>modetest -M vc4 -s 53:720x480i -w 53:'TV mode':1 # NTSC<br>modetest -M vc4 -s 53:720x576i -w 53:'TV mode':4 # PAL<br><div><br></div><div><br></div><div>NTSC should be 640x480i, not 720. It will probably work on most TV's, but NTSC by the spec is 640x480i.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 7, 2022 at 3:16 PM Maxime Ripard <maxime@cerno.tech> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
Here's a series aiming at improving the command line named modes support,<br>
and more importantly how we deal with all the analog TV variants.<br>
<br>
The named modes support were initially introduced to allow to specify the<br>
analog TV mode to be used.<br>
<br>
However, this was causing multiple issues:<br>
<br>
* The mode name parsed on the command line was passed directly to the<br>
driver, which had to figure out which mode it was suppose to match;<br>
<br>
* Figuring that out wasn't really easy, since the video= argument or what<br>
the userspace might not even have a name in the first place, but<br>
instead could have passed a mode with the same timings;<br>
<br>
* The fallback to matching on the timings was mostly working as long as<br>
we were supporting one 525 lines (most likely NSTC) and one 625 lines<br>
(PAL), but couldn't differentiate between two modes with the same<br>
timings (NTSC vs PAL-M vs NSTC-J for example);<br>
<br>
* There was also some overlap with the tv mode property registered by<br>
drm_mode_create_tv_properties(), but named modes weren't interacting<br>
with that property at all.<br>
<br>
* Even though that property was generic, its possible values were<br>
specific to each drivers, which made some generic support difficult.<br>
<br>
Thus, I chose to tackle in multiple steps:<br>
<br>
* A new TV mode property was introduced, with generic values, each driver<br>
reporting through a bitmask what standard it supports to the userspace;<br>
<br>
* This option was added to the command line parsing code to be able to<br>
specify it on the kernel command line, and new atomic_check and reset<br>
helpers were created to integrate properly into atomic KMS;<br>
<br>
* The named mode parsing code is now creating a proper display mode for<br>
the given named mode, and the TV standard will thus be part of the<br>
connector state;<br>
<br>
* Two drivers were converted and tested for now (vc4 and sun4i), with<br>
some backward compatibility code to translate the old TV mode to the<br>
new TV mode;<br>
<br>
Unit tests were created along the way.<br>
<br>
One can switch from NTSC to PAL now using (on vc4)<br>
<br>
modetest -M vc4 -s 53:720x480i -w 53:'TV mode':1 # NTSC<br>
modetest -M vc4 -s 53:720x576i -w 53:'TV mode':4 # PAL<br>
<br>
Let me know what you think,<br>
Maxime<br>
<br>
To: David Airlie <<a href="mailto:airlied@linux.ie" target="_blank">airlied@linux.ie</a>><br>
To: Daniel Vetter <<a href="mailto:daniel@ffwll.ch" target="_blank">daniel@ffwll.ch</a>><br>
To: Maarten Lankhorst <<a href="mailto:maarten.lankhorst@linux.intel.com" target="_blank">maarten.lankhorst@linux.intel.com</a>><br>
To: Maxime Ripard <<a href="mailto:mripard@kernel.org" target="_blank">mripard@kernel.org</a>><br>
To: Thomas Zimmermann <<a href="mailto:tzimmermann@suse.de" target="_blank">tzimmermann@suse.de</a>><br>
To: Emma Anholt <<a href="mailto:emma@anholt.net" target="_blank">emma@anholt.net</a>><br>
To: Jani Nikula <<a href="mailto:jani.nikula@linux.intel.com" target="_blank">jani.nikula@linux.intel.com</a>><br>
To: Joonas Lahtinen <<a href="mailto:joonas.lahtinen@linux.intel.com" target="_blank">joonas.lahtinen@linux.intel.com</a>><br>
To: Rodrigo Vivi <<a href="mailto:rodrigo.vivi@intel.com" target="_blank">rodrigo.vivi@intel.com</a>><br>
To: Tvrtko Ursulin <<a href="mailto:tvrtko.ursulin@linux.intel.com" target="_blank">tvrtko.ursulin@linux.intel.com</a>><br>
To: Ben Skeggs <<a href="mailto:bskeggs@redhat.com" target="_blank">bskeggs@redhat.com</a>><br>
To: Karol Herbst <<a href="mailto:kherbst@redhat.com" target="_blank">kherbst@redhat.com</a>><br>
To: Lyude Paul <<a href="mailto:lyude@redhat.com" target="_blank">lyude@redhat.com</a>><br>
To: Chen-Yu Tsai <<a href="mailto:wens@csie.org" target="_blank">wens@csie.org</a>><br>
To: Jernej Skrabec <<a href="mailto:jernej.skrabec@gmail.com" target="_blank">jernej.skrabec@gmail.com</a>><br>
To: Samuel Holland <<a href="mailto:samuel@sholland.org" target="_blank">samuel@sholland.org</a>><br>
Cc: Geert Uytterhoeven <<a href="mailto:geert@linux-m68k.org" target="_blank">geert@linux-m68k.org</a>><br>
Cc: Mateusz Kwiatkowski <<a href="mailto:kfyatek%2Bpublicgit@gmail.com" target="_blank">kfyatek+publicgit@gmail.com</a>><br>
Cc: "Noralf Trønnes" <<a href="mailto:noralf@tronnes.org" target="_blank">noralf@tronnes.org</a>><br>
Cc: Dave Stevenson <<a href="mailto:dave.stevenson@raspberrypi.com" target="_blank">dave.stevenson@raspberrypi.com</a>><br>
Cc: Dom Cobley <<a href="mailto:dom@raspberrypi.com" target="_blank">dom@raspberrypi.com</a>><br>
Cc: Phil Elwell <<a href="mailto:phil@raspberrypi.com" target="_blank">phil@raspberrypi.com</a>><br>
Cc: <<a href="mailto:dri-devel@lists.freedesktop.org" target="_blank">dri-devel@lists.freedesktop.org</a>><br>
Cc: <a href="mailto:linux-kernel@vger.kernel.org" target="_blank">linux-kernel@vger.kernel.org</a><br>
Cc: <a href="mailto:intel-gfx@lists.freedesktop.org" target="_blank">intel-gfx@lists.freedesktop.org</a><br>
Cc: <a href="mailto:nouveau@lists.freedesktop.org" target="_blank">nouveau@lists.freedesktop.org</a><br>
Cc: <a href="mailto:linux-arm-kernel@lists.infradead.org" target="_blank">linux-arm-kernel@lists.infradead.org</a><br>
Cc: <a href="mailto:linux-sunxi@lists.linux.dev" target="_blank">linux-sunxi@lists.linux.dev</a><br>
Cc: Hans de Goede <<a href="mailto:hdegoede@redhat.com" target="_blank">hdegoede@redhat.com</a>><br>
Signed-off-by: Maxime Ripard <maxime@cerno.tech><br>
<br>
---<br>
Changes in v7:<br>
- Switch to another implementation of get_modes from Noralf<br>
- Made more checks in VEC's atomic_check<br>
- Fixed typo in a commit log<br>
- Checked for tv_mode_specified in drm_mode_parse_command_line_for_connector<br>
- Rebased on drm-misc-next-2022-11-03<br>
- Link to v6: <a href="https://lore.kernel.org/r/20220728-rpi-analog-tv-properties-v6-0-e7792734108f@cerno.tech" rel="noreferrer" target="_blank">https://lore.kernel.org/r/20220728-rpi-analog-tv-properties-v6-0-e7792734108f@cerno.tech</a><br>
<br>
Changes in v6:<br>
- Add and convert to a new get_modes helper to create the PAL and NTSC modes in<br>
the proper order, with the right preferred mode flag, depending on the driver<br>
capabilities and defaults.<br>
- Support PAL60<br>
- Renamed tests to be consistent with DRM tests naming convention<br>
- Simplified a bit the named mode parsing code<br>
- Add a tv_mode_specified field<br>
- Return 0 in get_modes implementations instead of error codes<br>
- Link to v5: <a href="https://lore.kernel.org/r/20220728-rpi-analog-tv-properties-v5-0-d841cc64fe4b@cerno.tech" rel="noreferrer" target="_blank">https://lore.kernel.org/r/20220728-rpi-analog-tv-properties-v5-0-d841cc64fe4b@cerno.tech</a><br>
<br>
Changes in v5:<br>
- Dropped TV Standard documentation removal<br>
- Switched the TV Mode documentation from CSV to actual documentation<br>
- Switched to kunit assertions where possible<br>
- Switched to KUNIT_ASSERT_NOT_NULL instead of KUNIT_ASSERT_PTR_NE(..., NULL)<br>
- Shuffled a bit the introduction of drm_client_modeset_connector_get_modes between patches<br>
- Renamed tv_mode_names to legacy_tv_mode_names<br>
- Removed the count variable in sun4i_tv_comp_get_modes<br>
- Rebased on top of current drm-misc-next<br>
- Link to v4: <a href="https://lore.kernel.org/r/20220728-rpi-analog-tv-properties-v4-0-60d38873f782@cerno.tech" rel="noreferrer" target="_blank">https://lore.kernel.org/r/20220728-rpi-analog-tv-properties-v4-0-60d38873f782@cerno.tech</a><br>
<br>
Changes in v4:<br>
- Removed the unused TV Standard property documentation<br>
- Added the TV Mode property documentation to kms-properties.csv<br>
- Fixed the documentation of drm_mode_create_tv_properties()<br>
- Removed DRM_MODE_TV_MODE_NONE<br>
- Reworded the line length check comment in drm_mode_analog_tv tests<br>
- Switched to HZ_PER_KHZ in drm_mode_analog_tv tests<br>
- Reworked drm_mode_analog_tv to fill our mode using the previously computed<br>
timings<br>
- Added the command-line option documentation to modedb.rst<br>
- Improved the Kunit helpers cleanup<br>
- Moved the subconnector documentation renaming to the proper patch<br>
- Added the various review tags<br>
- Removed the count variable in vc4_vec_connector_get_modes<br>
- Rebased on drm-misc-next-2022-09-23 and fixed a merge conflict<br>
- Folded all the named mode parsing improvements in a single patch<br>
- Link to v3: <a href="https://lore.kernel.org/r/20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech" rel="noreferrer" target="_blank">https://lore.kernel.org/r/20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech</a><br>
<br>
Changes in v3:<br>
- Applied some of the fixes to vc4 and sun4i<br>
- Renamed the old TV mode property to legacy_mode<br>
- Fixed a bunch of bisection errors<br>
- Removed most of the redundant TV modes<br>
- Added a new None TV mode to not fall back on NTSC by mistake<br>
- Fixed the mode generation function to match better what is expected<br>
- Added some logging to the mode generation function<br>
- Split the improvements to the named mode parsing logic into separate patches<br>
- Added more checks to the TV atomic_check helper<br>
- Link to v2: <a href="https://lore.kernel.org/dri-devel/20220728-rpi-analog-tv-properties-v2-0-459522d653a7@cerno.tech/" rel="noreferrer" target="_blank">https://lore.kernel.org/dri-devel/20220728-rpi-analog-tv-properties-v2-0-459522d653a7@cerno.tech/</a><br>
<br>
Changes in v2:<br>
- Kept the older TV mode property as legacy so we can keep the old drivers functional<br>
- Renamed the tv_norm property to tv_mode<br>
- Added a function to create PAL and NTSC compatible display modes<br>
- Added some helpers to instantiate a mock DRM device in Kunit<br>
- More Kunit tests<br>
- Removed the HD analog TV modes<br>
- Renamed some of the tests<br>
- Renamed some of the named modes<br>
- Fixed typos in commit logs<br>
- Added the various tags<br>
- Link to v1: <a href="https://lore.kernel.org/dri-devel/20220728-rpi-analog-tv-properties-v1-0-3d53ae722097@cerno.tech/" rel="noreferrer" target="_blank">https://lore.kernel.org/dri-devel/20220728-rpi-analog-tv-properties-v1-0-3d53ae722097@cerno.tech/</a><br>
<br>
---<br>
Mateusz Kwiatkowski (2):<br>
drm/vc4: vec: Check for VEC output constraints<br>
drm/vc4: vec: Add support for more analog TV standards<br>
<br>
Maxime Ripard (20):<br>
drm/tests: Add Kunit Helpers<br>
drm/connector: Rename legacy TV property<br>
drm/connector: Only register TV mode property if present<br>
drm/connector: Rename drm_mode_create_tv_properties<br>
drm/connector: Add TV standard property<br>
drm/modes: Add a function to generate analog display modes<br>
drm/client: Add some tests for drm_connector_pick_cmdline_mode()<br>
drm/modes: Move named modes parsing to a separate function<br>
drm/modes: Switch to named mode descriptors<br>
drm/modes: Fill drm_cmdline mode from named modes<br>
drm/connector: Add pixel clock to cmdline mode<br>
drm/connector: Add a function to lookup a TV mode by its name<br>
drm/modes: Introduce the tv_mode property as a command-line option<br>
drm/modes: Properly generate a drm_display_mode from a named mode<br>
drm/modes: Introduce more named modes<br>
drm/atomic-helper: Add a TV properties reset helper<br>
drm/atomic-helper: Add an analog TV atomic_check implementation<br>
drm/vc4: vec: Use TV Reset implementation<br>
drm/vc4: vec: Convert to the new TV mode property<br>
drm/sun4i: tv: Convert to the new TV mode property<br>
<br>
Noralf Trønnes (1):<br>
drm/probe-helper: Provide a TV get_modes helper<br>
<br>
Documentation/fb/modedb.rst | 2 +<br>
Documentation/gpu/drm-kms.rst | 6 +<br>
drivers/gpu/drm/drm_atomic_state_helper.c | 124 +++++<br>
drivers/gpu/drm/drm_atomic_uapi.c | 4 +<br>
drivers/gpu/drm/drm_client_modeset.c | 4 +<br>
drivers/gpu/drm/drm_connector.c | 173 ++++++-<br>
drivers/gpu/drm/drm_modes.c | 639 +++++++++++++++++++++++-<br>
drivers/gpu/drm/drm_probe_helper.c | 97 ++++<br>
drivers/gpu/drm/gud/gud_connector.c | 10 +-<br>
drivers/gpu/drm/i2c/ch7006_drv.c | 6 +-<br>
drivers/gpu/drm/i915/display/intel_tv.c | 5 +-<br>
drivers/gpu/drm/nouveau/dispnv04/tvnv17.c | 6 +-<br>
drivers/gpu/drm/sun4i/sun4i_tv.c | 141 ++----<br>
drivers/gpu/drm/tests/Makefile | 3 +<br>
drivers/gpu/drm/tests/drm_client_modeset_test.c | 229 +++++++++<br>
drivers/gpu/drm/tests/drm_cmdline_parser_test.c | 67 +++<br>
drivers/gpu/drm/tests/drm_connector_test.c | 90 ++++<br>
drivers/gpu/drm/tests/drm_kunit_helpers.c | 61 +++<br>
drivers/gpu/drm/tests/drm_kunit_helpers.h | 9 +<br>
drivers/gpu/drm/tests/drm_modes_test.c | 144 ++++++<br>
drivers/gpu/drm/vc4/vc4_vec.c | 342 +++++++++++--<br>
include/drm/drm_atomic_state_helper.h | 4 +<br>
include/drm/drm_connector.h | 89 +++-<br>
include/drm/drm_mode_config.h | 12 +-<br>
include/drm/drm_modes.h | 17 +<br>
include/drm/drm_probe_helper.h | 1 +<br>
26 files changed, 2081 insertions(+), 204 deletions(-)<br>
---<br>
base-commit: 3b536e43463ed91b7bf9acec1eb4da0bc677dc43<br>
change-id: 20220728-rpi-analog-tv-properties-0914dfcee460<br>
<br>
Best regards,<br>
-- <br>
Maxime Ripard <maxime@cerno.tech><br>
</blockquote></div>