drm/tests: hdmi: Add test for unsuccessful fallback to YUV420
Provide test to verify a mandatory fallback to YUV420 output cannot succeed when driver doesn't advertise YUV420 support. Acked-by: Maxime Ripard <mripard@kernel.org> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> Link: https://lore.kernel.org/r/20250527-hdmi-conn-yuv-v5-19-74c9c4a8ac0c@collabora.com Signed-off-by: Maxime Ripard <mripard@kernel.org>
This commit is contained in:
committed by
Maxime Ripard
parent
e271ecaaa5
commit
e42a3c203c
@@ -1534,6 +1534,92 @@ retry_conn_enable:
|
||||
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
|
||||
* unsuccessful fallback attempts.
|
||||
*/
|
||||
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_connector_state *conn_state;
|
||||
struct drm_crtc_state *crtc_state;
|
||||
struct drm_atomic_state *state;
|
||||
struct drm_display_info *info;
|
||||
struct drm_display_mode *preferred, *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_funcs(test,
|
||||
BIT(HDMI_COLORSPACE_RGB),
|
||||
12,
|
||||
&dummy_connector_hdmi_funcs,
|
||||
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);
|
||||
|
||||
preferred = find_preferred_mode(conn);
|
||||
KUNIT_ASSERT_NOT_NULL(test, preferred);
|
||||
KUNIT_ASSERT_FALSE(test, drm_mode_is_420_also(info, preferred));
|
||||
|
||||
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);
|
||||
|
||||
retry_conn_enable:
|
||||
ret = drm_kunit_helper_enable_crtc_connector(test, drm, crtc, conn,
|
||||
preferred, &ctx);
|
||||
if (ret == -EDEADLK) {
|
||||
ret = drm_modeset_backoff(&ctx);
|
||||
if (!ret)
|
||||
goto retry_conn_enable;
|
||||
}
|
||||
KUNIT_EXPECT_EQ(test, ret, 0);
|
||||
|
||||
conn_state = conn->state;
|
||||
KUNIT_ASSERT_NOT_NULL(test, conn_state);
|
||||
KUNIT_EXPECT_EQ(test, conn_state->hdmi.output_format, HDMI_COLORSPACE_RGB);
|
||||
|
||||
state = drm_kunit_helper_atomic_state_alloc(test, drm, &ctx);
|
||||
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
|
||||
|
||||
retry_crtc_state:
|
||||
crtc_state = drm_atomic_get_crtc_state(state, crtc);
|
||||
if (PTR_ERR(crtc_state) == -EDEADLK) {
|
||||
drm_atomic_state_clear(state);
|
||||
ret = drm_modeset_backoff(&ctx);
|
||||
if (!ret)
|
||||
goto retry_crtc_state;
|
||||
}
|
||||
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, crtc_state);
|
||||
|
||||
ret = drm_atomic_set_mode_for_crtc(crtc_state, yuv420_only_mode);
|
||||
KUNIT_EXPECT_EQ(test, ret, 0);
|
||||
|
||||
ret = drm_atomic_check_only(state);
|
||||
if (ret == -EDEADLK) {
|
||||
drm_atomic_state_clear(state);
|
||||
ret = drm_modeset_backoff(&ctx);
|
||||
if (!ret)
|
||||
goto retry_crtc_state;
|
||||
}
|
||||
KUNIT_ASSERT_LT(test, ret, 0);
|
||||
|
||||
drm_modeset_drop_locks(&ctx);
|
||||
drm_modeset_acquire_fini(&ctx);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test that if a driver and screen supports RGB and YUV formats, and we
|
||||
* try to set the VIC 1 mode, we end up with 8bpc RGB even if we could
|
||||
@@ -1930,6 +2016,7 @@ static struct kunit_case drm_atomic_helper_connector_hdmi_check_tests[] = {
|
||||
KUNIT_CASE(drm_test_check_max_tmds_rate_bpc_fallback_yuv420),
|
||||
KUNIT_CASE(drm_test_check_max_tmds_rate_bpc_fallback_ignore_yuv422),
|
||||
KUNIT_CASE(drm_test_check_max_tmds_rate_bpc_fallback_ignore_yuv420),
|
||||
KUNIT_CASE(drm_test_check_driver_unsupported_fallback_yuv420),
|
||||
KUNIT_CASE(drm_test_check_output_bpc_crtc_mode_changed),
|
||||
KUNIT_CASE(drm_test_check_output_bpc_crtc_mode_not_changed),
|
||||
KUNIT_CASE(drm_test_check_output_bpc_dvi),
|
||||
|
||||
Reference in New Issue
Block a user