From 77c14764ae164b7969e65437a87aca25b30d8b80 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Fri, 14 Apr 2023 11:14:22 +0200 Subject: [PATCH] drm/vc4: tests: Add tests for BCM2712 PixelValve Muxing The BCM2712 has a simpler pipeline than the BCM2711, and thus the muxing requirements are different. Create some tests to make sure we get proper muxing decisions. Signed-off-by: Maxime Ripard --- .../gpu/drm/vc4/tests/vc4_test_pv_muxing.c | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) --- a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c +++ b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c @@ -105,6 +105,13 @@ static const struct encoder_constraint v ENCODER_CONSTRAINT(VC4_ENCODER_TYPE_HDMI1, 0, 1, 2), }; +static const struct encoder_constraint vc6_encoder_constraints[] = { + ENCODER_CONSTRAINT(VC4_ENCODER_TYPE_HDMI0, 0), + ENCODER_CONSTRAINT(VC4_ENCODER_TYPE_HDMI1, 1), + ENCODER_CONSTRAINT(VC4_ENCODER_TYPE_TXP1, 1), + ENCODER_CONSTRAINT(VC4_ENCODER_TYPE_TXP0, 2), +}; + static bool check_vc4_encoder_constraints(enum vc4_encoder_type type, unsigned int channel) { return __check_encoder_constraints(vc4_encoder_constraints, @@ -119,6 +126,13 @@ static bool check_vc5_encoder_constraint type, channel); } +static bool check_vc6_encoder_constraints(enum vc4_encoder_type type, unsigned int channel) +{ + return __check_encoder_constraints(vc6_encoder_constraints, + ARRAY_SIZE(vc6_encoder_constraints), + type, channel); +} + static struct vc4_crtc_state * get_vc4_crtc_state_for_encoder(struct kunit *test, const struct drm_atomic_state *state, @@ -196,6 +210,9 @@ static void vc4_test_pv_muxing_desc(cons #define VC5_PV_MUXING_TEST(_name, ...) \ PV_MUXING_TEST(_name, vc5_mock_device, check_vc5_encoder_constraints, __VA_ARGS__) +#define VC6_PV_MUXING_TEST(_name, ...) \ + PV_MUXING_TEST(_name, vc6_mock_device, check_vc6_encoder_constraints, __VA_ARGS__) + static const struct pv_muxing_param vc4_test_pv_muxing_params[] = { VC4_PV_MUXING_TEST("1 output: DSI0", VC4_ENCODER_TYPE_DSI0), @@ -674,6 +691,54 @@ KUNIT_ARRAY_PARAM(vc5_test_pv_muxing_inv vc5_test_pv_muxing_invalid_params, vc4_test_pv_muxing_desc); +static const struct pv_muxing_param vc6_test_pv_muxing_params[] = { + VC6_PV_MUXING_TEST("1 output: HDMI0", + VC4_ENCODER_TYPE_HDMI0), + VC6_PV_MUXING_TEST("1 output: HDMI1", + VC4_ENCODER_TYPE_HDMI1), + VC6_PV_MUXING_TEST("1 output: MOPLET", + VC4_ENCODER_TYPE_TXP1), + VC6_PV_MUXING_TEST("1 output: MOP", + VC4_ENCODER_TYPE_TXP0), + VC6_PV_MUXING_TEST("2 outputs: HDMI0, HDMI1", + VC4_ENCODER_TYPE_HDMI0, + VC4_ENCODER_TYPE_HDMI1), + VC6_PV_MUXING_TEST("2 outputs: HDMI0, MOPLET", + VC4_ENCODER_TYPE_HDMI0, + VC4_ENCODER_TYPE_TXP1), + VC6_PV_MUXING_TEST("2 outputs: HDMI0, MOP", + VC4_ENCODER_TYPE_HDMI0, + VC4_ENCODER_TYPE_TXP0), + VC6_PV_MUXING_TEST("2 outputs: HDMI1, MOP", + VC4_ENCODER_TYPE_HDMI1, + VC4_ENCODER_TYPE_TXP0), + VC6_PV_MUXING_TEST("2 outputs: MOPLET, MOP", + VC4_ENCODER_TYPE_TXP1, + VC4_ENCODER_TYPE_TXP0), + VC6_PV_MUXING_TEST("3 outputs: HDMI0, HDMI1, MOP", + VC4_ENCODER_TYPE_HDMI0, + VC4_ENCODER_TYPE_HDMI1, + VC4_ENCODER_TYPE_TXP0), + VC6_PV_MUXING_TEST("3 outputs: HDMI0, MOPLET, MOP", + VC4_ENCODER_TYPE_HDMI0, + VC4_ENCODER_TYPE_TXP1, + VC4_ENCODER_TYPE_TXP0), +}; + +KUNIT_ARRAY_PARAM(vc6_test_pv_muxing, + vc6_test_pv_muxing_params, + vc4_test_pv_muxing_desc); + +static const struct pv_muxing_param vc6_test_pv_muxing_invalid_params[] = { + VC6_PV_MUXING_TEST("HDMI1/MOPLET Conflict", + VC4_ENCODER_TYPE_HDMI1, + VC4_ENCODER_TYPE_TXP1), +}; + +KUNIT_ARRAY_PARAM(vc6_test_pv_muxing_invalid, + vc6_test_pv_muxing_invalid_params, + vc4_test_pv_muxing_desc); + static void drm_vc4_test_pv_muxing(struct kunit *test) { const struct pv_muxing_param *params = test->param_value; @@ -797,6 +862,21 @@ static struct kunit_suite vc5_pv_muxing_ .test_cases = vc5_pv_muxing_tests, }; +static struct kunit_case vc6_pv_muxing_tests[] = { + KUNIT_CASE_PARAM(drm_vc4_test_pv_muxing, + vc6_test_pv_muxing_gen_params), + KUNIT_CASE_PARAM(drm_vc4_test_pv_muxing_invalid, + vc6_test_pv_muxing_invalid_gen_params), + {} +}; + +static struct kunit_suite vc6_pv_muxing_test_suite = { + .name = "vc6-pv-muxing-combinations", + .init = vc4_pv_muxing_test_init, + .exit = vc4_pv_muxing_test_exit, + .test_cases = vc6_pv_muxing_tests, +}; + /* See * https://lore.kernel.org/all/3e113525-aa89-b1e2-56b7-ca55bd41d057@samsung.com/ * and @@ -1040,5 +1120,6 @@ static struct kunit_suite vc5_pv_muxing_ kunit_test_suites( &vc4_pv_muxing_test_suite, &vc5_pv_muxing_test_suite, + &vc6_pv_muxing_test_suite, &vc5_pv_muxing_bugs_test_suite );