vc4 VEC (analogue video) updates - margins and monochrome
Subsystems (3)
Dave Stevenson
maintainerv2 cover vc4 VEC (analogue video) updates - margins and monochrome
Changes since v1:
- (Patch adding DRM_MODE_TV_MODE_MONOCHROME has already been merged)
- Added kunit tests as requested by Maxime
- Fixed error in vc4_vec_connector_get_property which was returning the value rather than setting *val.
- The legacy driver property has to be updated with the new value as returning an error from get_property will crash modetest (or similar) when it queries the value.
- Added Maxime's R-b on patch 3.
Hi All
A couple of patches to vc4, including adding a new "TV mode" enum for monochrome output (yes we have some users who wish for monochrome).
Adding mono has raised a query here as to whether the the TV_MODE is meant to describe the timing, or just the colour encoding.
The description for NTSC references "CCIR System M (aka 525-lines)", and PAL references "CCIR System B" which is the 625 line standard.
PAL-60 is absent from the enum, but support has been added to vc4 by selecting DRM_MODE_TV_MODE_PAL but with the NTSC (CCIR System M) timings. Is that the correct implementation? In which case the description for PAL should drop the CCIR System B reference as selecting the "TV mode" doesn't dictate the timing.
Monochrome is in the same boat as it can adopt either 525 or 625 line timing, or indeed anything else. Pi5 can support System A 405-line and the French 819-line mono modes as well.
If "TV mode" does dictate the timing as well as the colour encoding, then we need to add PAL-60, and 2 modes for mono (extending to 4 for 405 and 819 line modes later). If not, we ought to update the description.
Thoughts?
Thanks
Dave
Dave Stevenson (3):
drm/tests: Add tests for the new Monochrome value of tv_mode drm/vc4: Add monochrome mode to the VEC.
drm/vc4: vec: Add the margin properties to the connector
.../gpu/drm/tests/drm_cmdline_parser_test.c | 20 ++++++------ drivers/gpu/drm/tests/drm_connector_test.c | 1 + drivers/gpu/drm/tests/drm_modes_test.c | 31 +++++++++++++++++++ drivers/gpu/drm/vc4/vc4_vec.c | 31 ++++++++++++++++++- 4 files changed, 73 insertions(+), 10 deletions(-)
Signature · 1 line
2.34.1
Dave Stevenson
maintainerPATCH v2 1/3 drm/tests: Add tests for the new Monochrome value of tv_mode
Adds test for the cmdline parser, connector property, and drm_analog_tv_mode to ensure the behaviour of the new value is correct.
--- .../gpu/drm/tests/drm_cmdline_parser_test.c | 20 ++++++------ drivers/gpu/drm/tests/drm_connector_test.c | 1 + drivers/gpu/drm/tests/drm_modes_test.c | 31 +++++++++++++++++++ 3 files changed, 43 insertions(+), 9 deletions(-)
drivers/gpu/drm/tests/drm_cmdline_parser_test.c +11 -9
@@ -976,22 +976,24 @@ static void drm_test_cmdline_tv_options(struct kunit *test)KUNIT_EXPECT_EQ (test, mode.force,DRM_FORCE_UNSPECIFIED ); } -#define TV_OPT_TEST (_opt, _cmdline, _mode_fn) \ +#define TV_OPT_TEST (_opt, _cmdline, _mode_fn, _tvmode) \ { \ .name = #_opt, \ .cmdline = _cmdline, \ .mode_fn = _mode_fn, \ - .tv_mode = DRM_MODE_TV_MODE_ ## _opt, \ + .tv_mode = DRM_MODE_TV_MODE_ ## _tvmode, \ }static const struct drm_cmdline_tv_option_test drm_cmdline_tv_option_tests[] = { -TV_OPT_TEST (NTSC ,"720x480i,tv_mode=NTSC" , drm_mode_analog_ntsc_480i), -TV_OPT_TEST (NTSC_443 ,"720x480i,tv_mode=NTSC-443" , drm_mode_analog_ntsc_480i), -TV_OPT_TEST (NTSC_J ,"720x480i,tv_mode=NTSC-J" , drm_mode_analog_ntsc_480i), -TV_OPT_TEST (PAL ,"720x576i,tv_mode=PAL" , drm_mode_analog_pal_576i), -TV_OPT_TEST (PAL_M ,"720x480i,tv_mode=PAL-M" , drm_mode_analog_ntsc_480i), -TV_OPT_TEST (PAL_N ,"720x576i,tv_mode=PAL-N" , drm_mode_analog_pal_576i), -TV_OPT_TEST (SECAM ,"720x576i,tv_mode=SECAM" , drm_mode_analog_pal_576i), +TV_OPT_TEST (NTSC ,"720x480i,tv_mode=NTSC" , drm_mode_analog_ntsc_480i,NTSC ), +TV_OPT_TEST (NTSC_443 ,"720x480i,tv_mode=NTSC-443" , drm_mode_analog_ntsc_480i,NTSC_443 ), +TV_OPT_TEST (NTSC_J ,"720x480i,tv_mode=NTSC-J" , drm_mode_analog_ntsc_480i,NTSC_J ), +TV_OPT_TEST (PAL ,"720x576i,tv_mode=PAL" , drm_mode_analog_pal_576i,PAL ), +TV_OPT_TEST (PAL_M ,"720x480i,tv_mode=PAL-M" , drm_mode_analog_ntsc_480i,PAL_M ), +TV_OPT_TEST (PAL_N ,"720x576i,tv_mode=PAL-N" , drm_mode_analog_pal_576i,PAL_N ), +TV_OPT_TEST (SECAM ,"720x576i,tv_mode=SECAM" , drm_mode_analog_pal_576i,SECAM ), +TV_OPT_TEST (MONO_525 ,"720x480i,tv_mode=Mono" , drm_mode_analog_ntsc_480i,MONOCHROME ), +TV_OPT_TEST (MONO_625 ,"720x576i,tv_mode=Mono" , drm_mode_analog_pal_576i,MONOCHROME ), }; static void drm_cmdline_tv_option_desc(const struct drm_cmdline_tv_option_test *t,
drivers/gpu/drm/tests/drm_connector_test.c +1 -0
@@ -777,6 +777,7 @@ struct drm_get_tv_mode_from_name_test drm_get_tv_mode_from_name_valid_tests[] =TV_MODE_NAME ("PAL-M" ,DRM_MODE_TV_MODE_PAL_M ),TV_MODE_NAME ("PAL-N" ,DRM_MODE_TV_MODE_PAL_N ),TV_MODE_NAME ("SECAM" ,DRM_MODE_TV_MODE_SECAM ), + TV_MODE_NAME("Mono", DRM_MODE_TV_MODE_MONOCHROME), }; static void
drivers/gpu/drm/tests/drm_modes_test.c +31 -0
@@ -130,11 +130,42 @@ static void drm_test_modes_analog_tv_pal_576i_inlined(struct kunit *test)KUNIT_EXPECT_TRUE (test,drm_mode_equal (expected, mode)); } +static void drm_test_modes_analog_tv_mono_576i (struct kunit *test) +{ +struct drm_test_modes_priv *priv = test->priv; +struct drm_display_mode *mode; + + mode =drm_analog_tv_mode (priv->drm, +DRM_MODE_TV_MODE_MONOCHROME , +13500 *HZ_PER_KHZ ,720 ,576 , + true); +KUNIT_ASSERT_NOT_NULL (test, mode); + +KUNIT_EXPECT_EQ (test,drm_mode_vrefresh (mode),50 ); +KUNIT_EXPECT_EQ (test, mode->hdisplay,720 ); + +/* BT.601 defines hsync_start at 732 for 576i */ +KUNIT_EXPECT_EQ (test, mode->hsync_start,732 ); + +/* +* The PAL standard expects a line to take 64us. With a pixel +* clock of 13.5 MHz, a pixel takes around 74ns, so we need to +* have 64000ns / 74ns = 864. +* +* This is also mandated by BT.601. +*/ +KUNIT_EXPECT_EQ (test, mode->htotal,864 ); + +KUNIT_EXPECT_EQ (test, mode->vdisplay,576 ); +KUNIT_EXPECT_EQ (test, mode->vtotal,625 ); +} +static struct kunit_case drm_modes_analog_tv_tests[] = {KUNIT_CASE (drm_test_modes_analog_tv_ntsc_480i),KUNIT_CASE (drm_test_modes_analog_tv_ntsc_480i_inlined),KUNIT_CASE (drm_test_modes_analog_tv_pal_576i),KUNIT_CASE (drm_test_modes_analog_tv_pal_576i_inlined), +KUNIT_CASE (drm_test_modes_analog_tv_mono_576i), { } };
Signature · 1 line
2.34.1
Maxime Ripard
maintainerRe: [PATCH v2 1/3] drm/tests: Add tests for the new Monochrome value of tv_mode
Hi,
Thanks for working on the tests
Quoted 37 lines · Dave Stevenson
Adds test for the cmdline parser, connector property, and
drm_analog_tv_modeto ensure the behaviour of the new value is correct.Signed-off-by Dave Stevenson <[email protected]>--- .../gpu/drm/tests/drm_cmdline_parser_test.c | 20 ++++++------ drivers/gpu/drm/tests/drm_connector_test.c | 1 + drivers/gpu/drm/tests/drm_modes_test.c | 31 +++++++++++++++++++ 3 files changed, 43 insertions(+), 9 deletions(-)drivers/gpu/drm/tests/drm_cmdline_parser_test.c +2
-9@@ -976,22 +976,24 @@ static void drm_test_cmdline_tv_options(struct kunit *test)KUNIT_EXPECT_EQ (test, mode.force,DRM_FORCE_UNSPECIFIED ); } -#define TV_OPT_TEST (_opt, _cmdline, _mode_fn) \ +#define TV_OPT_TEST (_opt, _cmdline, _mode_fn, _tvmode) \ { \ .name = #_opt, \ .cmdline = _cmdline, \ .mode_fn = _mode_fn, \ - .tv_mode = DRM_MODE_TV_MODE_ ## _opt, \ + .tv_mode = DRM_MODE_TV_MODE_ ## _tvmode, \ }static const struct drm_cmdline_tv_option_test drm_cmdline_tv_option_tests[] = { -TV_OPT_TEST (NTSC ,"720x480i,tv_mode=NTSC" , drm_mode_analog_ntsc_480i), -TV_OPT_TEST (NTSC_443 ,"720x480i,tv_mode=NTSC-443" , drm_mode_analog_ntsc_480i), -TV_OPT_TEST (NTSC_J ,"720x480i,tv_mode=NTSC-J" , drm_mode_analog_ntsc_480i), -TV_OPT_TEST (PAL ,"720x576i,tv_mode=PAL" , drm_mode_analog_pal_576i), -TV_OPT_TEST (PAL_M ,"720x480i,tv_mode=PAL-M" , drm_mode_analog_ntsc_480i), -TV_OPT_TEST (PAL_N ,"720x576i,tv_mode=PAL-N" , drm_mode_analog_pal_576i), -TV_OPT_TEST (SECAM ,"720x576i,tv_mode=SECAM" , drm_mode_analog_pal_576i),
drivers/gpu/drm/tests/drm_cmdline_parser_test.c static void drm_test_cmdline_tv_options(struct kunit *test) · line 997
Quoted 10 lines
drivers/gpu/drm/tests/drm_cmdline_parser_test.c +9
-0+TV_OPT_TEST (NTSC ,"720x480i,tv_mode=NTSC" , drm_mode_analog_ntsc_480i,NTSC ), +TV_OPT_TEST (NTSC_443 ,"720x480i,tv_mode=NTSC-443" , drm_mode_analog_ntsc_480i,NTSC_443 ), +TV_OPT_TEST (NTSC_J ,"720x480i,tv_mode=NTSC-J" , drm_mode_analog_ntsc_480i,NTSC_J ), +TV_OPT_TEST (PAL ,"720x576i,tv_mode=PAL" , drm_mode_analog_pal_576i,PAL ), +TV_OPT_TEST (PAL_M ,"720x480i,tv_mode=PAL-M" , drm_mode_analog_ntsc_480i,PAL_M ), +TV_OPT_TEST (PAL_N ,"720x576i,tv_mode=PAL-N" , drm_mode_analog_pal_576i,PAL_N ), +TV_OPT_TEST (SECAM ,"720x576i,tv_mode=SECAM" , drm_mode_analog_pal_576i,SECAM ), +TV_OPT_TEST (MONO_525 ,"720x480i,tv_mode=Mono" , drm_mode_analog_ntsc_480i,MONOCHROME ), + TV_OPT_TEST(MONO_625, "720x576i,tv_mode=Mono", drm_mode_analog_pal_576i, MONOCHROME), };
I assume you did that because, otherwise, the name for both mono variants would have been the same and the test generation wouldn't work anymore?
If so, I think I'd prefer to not use the macro in this case but define the struct by hand. It keeps the general case clean, while allowing to deal with our odd case still.
Maxime
Maxime Ripard
maintainerRe: [PATCH v2 1/3] drm/tests: Add tests for the new Monochrome value of tv_mode
In reply to Dave Stevensondrivers/gpu/drm/tests/drm_modes_test.c static void drm_test_modes_analog_tv_pal_576i_inlined(struct kunit *test) · line 169
Quoted 7 lines · Dave Stevenson
static struct
kunit_casedrm_modes_analog_tv_tests[] = {drivers/gpu/drm/tests/drm_modes_test.c +1
-0KUNIT_CASE (drm_test_modes_analog_tv_ntsc_480i),KUNIT_CASE (drm_test_modes_analog_tv_ntsc_480i_inlined),KUNIT_CASE (drm_test_modes_analog_tv_pal_576i),KUNIT_CASE (drm_test_modes_analog_tv_pal_576i_inlined), + KUNIT_CASE(drm_test_modes_analog_tv_mono_576i), { }
Also, the tests should be sorted by alphabetical order
Maxime
Dave Stevenson
maintainerPATCH v2 2/3 drm/vc4: Add monochrome mode to the VEC.
In reply to Dave StevensonThe VEC supports not producing colour bursts for monochrome output. It also has an option for disabling the chroma input to remove chroma from the signal.
Now that there is a DRM_MODE_TV_MODE_MONOCHROME defined, plumb this in.
--- drivers/gpu/drm/vc4/vc4_vec.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_vec.c +28 -1
@@ -234,6 +234,7 @@ enum vc4_vec_tv_mode_id {VC4_VEC_TV_MODE_PAL_60 ,VC4_VEC_TV_MODE_PAL_N ,VC4_VEC_TV_MODE_SECAM , + VC4_VEC_TV_MODE_MONOCHROME, }; struct vc4_vec_tv_mode {
@@ -324,6 +325,22 @@ static const struct vc4_vec_tv_mode vc4_vec_tv_modes[] = { .config1 = VEC_CONFIG1_C_CVBS_CVBS, .custom_freq = 0x29c71c72, }, + { +/* 50Hz mono */ + .mode = DRM_MODE_TV_MODE_MONOCHROME, + .expected_htotal = 864, + .config0 = VEC_CONFIG0_PAL_BDGHI_STD | VEC_CONFIG0_BURDIS | + VEC_CONFIG0_CHRDIS, + .config1 = VEC_CONFIG1_C_CVBS_CVBS, + }, + { +/* 60Hz mono */ + .mode = DRM_MODE_TV_MODE_MONOCHROME, + .expected_htotal = 858, + .config0 = VEC_CONFIG0_PAL_M_STD | VEC_CONFIG0_BURDIS | + VEC_CONFIG0_CHRDIS, + .config1 = VEC_CONFIG1_C_CVBS_CVBS, + }, }; static inline const struct vc4_vec_tv_mode *
@@ -351,6 +368,7 @@ static const struct drm_prop_enum_list legacy_tv_mode_names[] = { { VC4_VEC_TV_MODE_PAL_M, "PAL-M", }, { VC4_VEC_TV_MODE_PAL_N, "PAL-N", }, { VC4_VEC_TV_MODE_SECAM, "SECAM", }, + { VC4_VEC_TV_MODE_MONOCHROME, "Mono", }, }; static enum drm_connector_status
@@ -406,6 +424,10 @@ vc4_vec_connector_set_property(struct drm_connector *connector, state->tv.mode =DRM_MODE_TV_MODE_SECAM ;break ; +case VC4_VEC_TV_MODE_MONOCHROME : + state->tv.mode =DRM_MODE_TV_MODE_MONOCHROME ; +break ; +default :return -EINVAL ; }
@@ -453,6 +475,10 @@ vc4_vec_connector_get_property(struct drm_connector *connector, *val =VC4_VEC_TV_MODE_SECAM ;break ; +case DRM_MODE_TV_MODE_MONOCHROME : + *val =VC4_VEC_TV_MODE_MONOCHROME ; +break ; +default :return -EINVAL ; }
@@ -754,7 +780,8 @@ static int vc4_vec_bind(struct device *dev, struct device *master, void *data)BIT (DRM_MODE_TV_MODE_PAL ) |BIT (DRM_MODE_TV_MODE_PAL_M ) |BIT (DRM_MODE_TV_MODE_PAL_N ) | - BIT(DRM_MODE_TV_MODE_SECAM)); +BIT (DRM_MODE_TV_MODE_SECAM ) | + BIT(DRM_MODE_TV_MODE_MONOCHROME));if (ret)return ret;
Signature · 1 line
2.34.1
Re: (subset) [PATCH v2 2/3] drm/vc4: Add monochrome mode to the VEC.
Quoted 8 lines · Dave Stevenson
The VEC supports not producing colour bursts for monochrome output. It also has an option for disabling the chroma input to remove chroma from the signal.
Now that there is a
DRM_MODE_TV_MODE_MONOCHROMEdefined, plumb this in.[...]
Applied to misc/kernel.git (drm-misc-next).
Thanks!
Maxime
Dave Stevenson
maintainerPATCH v2 3/3 drm/vc4: vec: Add the margin properties to the connector
In reply to Dave StevensonAll the handling for the properties was present, but they were never attached to the connector to allow userspace to change them.
Add them to the connector.
--- drivers/gpu/drm/vc4/vc4_vec.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/vc4/vc4_vec.c +2 -0
@@ -529,6 +529,8 @@ static int vc4_vec_connector_init(struct drm_device *dev, struct vc4_vec *vec)drm_object_attach_property (&connector->base, prop,VC4_VEC_TV_MODE_NTSC ); +drm_connector_attach_tv_margin_properties (connector); +drm_connector_attach_encoder (connector, &vec->encoder.base);return 0 ;
Signature · 1 line
2.34.1
Re: (subset) [PATCH v2 3/3] drm/vc4: vec: Add the margin properties to the connector
Quoted 8 lines · Dave Stevenson
All the handling for the properties was present, but they were never attached to the connector to allow userspace to change them.
Add them to the connector.
[...]
Applied to misc/kernel.git (drm-misc-next).
Thanks!
Maxime