6c0db592c936c04e398f26524c99122a989a43c9
[openwrt/staging/ansuel.git] /
1 From 77c14764ae164b7969e65437a87aca25b30d8b80 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Fri, 14 Apr 2023 11:14:22 +0200
4 Subject: [PATCH] drm/vc4: tests: Add tests for BCM2712 PixelValve Muxing
5
6 The BCM2712 has a simpler pipeline than the BCM2711, and thus the muxing
7 requirements are different. Create some tests to make sure we get proper
8 muxing decisions.
9
10 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
11 ---
12 .../gpu/drm/vc4/tests/vc4_test_pv_muxing.c | 81 +++++++++++++++++++
13 1 file changed, 81 insertions(+)
14
15 --- a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
16 +++ b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
17 @@ -105,6 +105,13 @@ static const struct encoder_constraint v
18 ENCODER_CONSTRAINT(VC4_ENCODER_TYPE_HDMI1, 0, 1, 2),
19 };
20
21 +static const struct encoder_constraint vc6_encoder_constraints[] = {
22 + ENCODER_CONSTRAINT(VC4_ENCODER_TYPE_HDMI0, 0),
23 + ENCODER_CONSTRAINT(VC4_ENCODER_TYPE_HDMI1, 1),
24 + ENCODER_CONSTRAINT(VC4_ENCODER_TYPE_TXP1, 1),
25 + ENCODER_CONSTRAINT(VC4_ENCODER_TYPE_TXP0, 2),
26 +};
27 +
28 static bool check_vc4_encoder_constraints(enum vc4_encoder_type type, unsigned int channel)
29 {
30 return __check_encoder_constraints(vc4_encoder_constraints,
31 @@ -119,6 +126,13 @@ static bool check_vc5_encoder_constraint
32 type, channel);
33 }
34
35 +static bool check_vc6_encoder_constraints(enum vc4_encoder_type type, unsigned int channel)
36 +{
37 + return __check_encoder_constraints(vc6_encoder_constraints,
38 + ARRAY_SIZE(vc6_encoder_constraints),
39 + type, channel);
40 +}
41 +
42 static struct vc4_crtc_state *
43 get_vc4_crtc_state_for_encoder(struct kunit *test,
44 const struct drm_atomic_state *state,
45 @@ -196,6 +210,9 @@ static void vc4_test_pv_muxing_desc(cons
46 #define VC5_PV_MUXING_TEST(_name, ...) \
47 PV_MUXING_TEST(_name, vc5_mock_device, check_vc5_encoder_constraints, __VA_ARGS__)
48
49 +#define VC6_PV_MUXING_TEST(_name, ...) \
50 + PV_MUXING_TEST(_name, vc6_mock_device, check_vc6_encoder_constraints, __VA_ARGS__)
51 +
52 static const struct pv_muxing_param vc4_test_pv_muxing_params[] = {
53 VC4_PV_MUXING_TEST("1 output: DSI0",
54 VC4_ENCODER_TYPE_DSI0),
55 @@ -674,6 +691,54 @@ KUNIT_ARRAY_PARAM(vc5_test_pv_muxing_inv
56 vc5_test_pv_muxing_invalid_params,
57 vc4_test_pv_muxing_desc);
58
59 +static const struct pv_muxing_param vc6_test_pv_muxing_params[] = {
60 + VC6_PV_MUXING_TEST("1 output: HDMI0",
61 + VC4_ENCODER_TYPE_HDMI0),
62 + VC6_PV_MUXING_TEST("1 output: HDMI1",
63 + VC4_ENCODER_TYPE_HDMI1),
64 + VC6_PV_MUXING_TEST("1 output: MOPLET",
65 + VC4_ENCODER_TYPE_TXP1),
66 + VC6_PV_MUXING_TEST("1 output: MOP",
67 + VC4_ENCODER_TYPE_TXP0),
68 + VC6_PV_MUXING_TEST("2 outputs: HDMI0, HDMI1",
69 + VC4_ENCODER_TYPE_HDMI0,
70 + VC4_ENCODER_TYPE_HDMI1),
71 + VC6_PV_MUXING_TEST("2 outputs: HDMI0, MOPLET",
72 + VC4_ENCODER_TYPE_HDMI0,
73 + VC4_ENCODER_TYPE_TXP1),
74 + VC6_PV_MUXING_TEST("2 outputs: HDMI0, MOP",
75 + VC4_ENCODER_TYPE_HDMI0,
76 + VC4_ENCODER_TYPE_TXP0),
77 + VC6_PV_MUXING_TEST("2 outputs: HDMI1, MOP",
78 + VC4_ENCODER_TYPE_HDMI1,
79 + VC4_ENCODER_TYPE_TXP0),
80 + VC6_PV_MUXING_TEST("2 outputs: MOPLET, MOP",
81 + VC4_ENCODER_TYPE_TXP1,
82 + VC4_ENCODER_TYPE_TXP0),
83 + VC6_PV_MUXING_TEST("3 outputs: HDMI0, HDMI1, MOP",
84 + VC4_ENCODER_TYPE_HDMI0,
85 + VC4_ENCODER_TYPE_HDMI1,
86 + VC4_ENCODER_TYPE_TXP0),
87 + VC6_PV_MUXING_TEST("3 outputs: HDMI0, MOPLET, MOP",
88 + VC4_ENCODER_TYPE_HDMI0,
89 + VC4_ENCODER_TYPE_TXP1,
90 + VC4_ENCODER_TYPE_TXP0),
91 +};
92 +
93 +KUNIT_ARRAY_PARAM(vc6_test_pv_muxing,
94 + vc6_test_pv_muxing_params,
95 + vc4_test_pv_muxing_desc);
96 +
97 +static const struct pv_muxing_param vc6_test_pv_muxing_invalid_params[] = {
98 + VC6_PV_MUXING_TEST("HDMI1/MOPLET Conflict",
99 + VC4_ENCODER_TYPE_HDMI1,
100 + VC4_ENCODER_TYPE_TXP1),
101 +};
102 +
103 +KUNIT_ARRAY_PARAM(vc6_test_pv_muxing_invalid,
104 + vc6_test_pv_muxing_invalid_params,
105 + vc4_test_pv_muxing_desc);
106 +
107 static void drm_vc4_test_pv_muxing(struct kunit *test)
108 {
109 const struct pv_muxing_param *params = test->param_value;
110 @@ -797,6 +862,21 @@ static struct kunit_suite vc5_pv_muxing_
111 .test_cases = vc5_pv_muxing_tests,
112 };
113
114 +static struct kunit_case vc6_pv_muxing_tests[] = {
115 + KUNIT_CASE_PARAM(drm_vc4_test_pv_muxing,
116 + vc6_test_pv_muxing_gen_params),
117 + KUNIT_CASE_PARAM(drm_vc4_test_pv_muxing_invalid,
118 + vc6_test_pv_muxing_invalid_gen_params),
119 + {}
120 +};
121 +
122 +static struct kunit_suite vc6_pv_muxing_test_suite = {
123 + .name = "vc6-pv-muxing-combinations",
124 + .init = vc4_pv_muxing_test_init,
125 + .exit = vc4_pv_muxing_test_exit,
126 + .test_cases = vc6_pv_muxing_tests,
127 +};
128 +
129 /* See
130 * https://lore.kernel.org/all/3e113525-aa89-b1e2-56b7-ca55bd41d057@samsung.com/
131 * and
132 @@ -1040,5 +1120,6 @@ static struct kunit_suite vc5_pv_muxing_
133 kunit_test_suites(
134 &vc4_pv_muxing_test_suite,
135 &vc5_pv_muxing_test_suite,
136 + &vc6_pv_muxing_test_suite,
137 &vc5_pv_muxing_bugs_test_suite
138 );