Hi, On Wed, Mar 26, 2025 at 12:20:04PM +0200, Cristian Ciocaltea wrote: > Provide test to verify a forced fallback to YUV420 output cannot succeed > when driver doesn't advertise YUV420 support. > > Signed-off-by: Cristian Ciocaltea <[email protected]> > --- > drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c | 46 > ++++++++++++++++++++++ > 1 file changed, 46 insertions(+) > > diff --git a/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c > b/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c > index > 99bedb2d6f555b3b140256000dfa7491d2a8f515..c2976b42aa2aacd2a68a871bffe97e795ca713d4 > 100644 > --- a/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c > +++ b/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c > @@ -1493,6 +1493,51 @@ static void > drm_test_check_max_tmds_rate_format_fallback_yuv420(struct kunit *te > drm_modeset_acquire_fini(&ctx); > } > > +/* > + * Test that if a driver supports only RGB, but the chosen mode can be > + * supported by the screen only in YUV420 output format, we end up with > + * an unsuccessful forced fallback attempt.
What do you mean by "forced"?
> + */
> +static void drm_test_check_driver_unsupported_fallback_yuv420(struct kunit
> *test)
> +{
> + struct drm_atomic_helper_connector_hdmi_priv *priv;
> + struct drm_modeset_acquire_ctx ctx;
> + struct drm_display_info *info;
> + struct drm_display_mode *yuv420_only_mode;
> + struct drm_connector *conn;
> + struct drm_device *drm;
> + struct drm_crtc *crtc;
> + int ret;
> +
> + priv = drm_kunit_helper_connector_hdmi_init_with_edid(test,
> + BIT(HDMI_COLORSPACE_RGB),
> + 12,
> +
> test_edid_hdmi_1080p_rgb_yuv_4k_yuv420_dc_max_200mhz);
> + KUNIT_ASSERT_NOT_NULL(test, priv);
> +
> + drm = &priv->drm;
> + crtc = priv->crtc;
> + conn = &priv->connector;
> + info = &conn->display_info;
> + KUNIT_ASSERT_TRUE(test, info->is_hdmi);
> + KUNIT_ASSERT_FALSE(test, conn->ycbcr_420_allowed);
> +
> + yuv420_only_mode = drm_kunit_display_mode_from_cea_vic(test, drm, 95);
> + KUNIT_ASSERT_NOT_NULL(test, yuv420_only_mode);
> + KUNIT_ASSERT_TRUE(test, drm_mode_is_420_only(info, yuv420_only_mode));
> +
> + drm_modeset_acquire_init(&ctx, 0);
> +
> + ret = drm_kunit_helper_enable_crtc_connector(test, drm,
> + crtc, conn,
> + yuv420_only_mode,
> + &ctx);
> + KUNIT_EXPECT_LT(test, ret, 0);
I think that's where your current approach falls a bit short. You should
really craft the state yourself and check the returned value of
drm_atomic_check_only(), not rely on
drm_kunit_helper_enable_crtc_connector() doing the right thing, when it
doesn't really tell you :)
> + drm_modeset_drop_locks(&ctx);
> + drm_modeset_acquire_fini(&ctx);
> +}
> +
We still need to do the same with a driver that supports both, but the
monitor doesn't.
Maxime
signature.asc
Description: PGP signature
