7d230294fc42bc86c668d23809c675360166d37c
[openwrt/staging/xback.git] /
1 From a2f912c44b98acb6c10c977db105e199011c09b5 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Fri, 14 Apr 2023 12:57:53 +0200
4 Subject: [PATCH] drm/vc4: tests: Add helper to add a new plane to a state
5
6 We'll start to add some tests for the plane state logic, so let's create
7 a helper to add a plane to an existing atomic state.
8
9 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
10 ---
11 drivers/gpu/drm/vc4/tests/vc4_mock.h | 4 ++++
12 drivers/gpu/drm/vc4/tests/vc4_mock_plane.c | 22 ++++++++++++++++++++++
13 2 files changed, 26 insertions(+)
14
15 --- a/drivers/gpu/drm/vc4/tests/vc4_mock.h
16 +++ b/drivers/gpu/drm/vc4/tests/vc4_mock.h
17 @@ -42,6 +42,10 @@ struct vc4_dummy_plane {
18 struct vc4_dummy_plane *vc4_dummy_plane(struct kunit *test,
19 struct drm_device *drm,
20 enum drm_plane_type type);
21 +struct drm_plane *
22 +vc4_mock_atomic_add_plane(struct kunit *test,
23 + struct drm_atomic_state *state,
24 + struct drm_crtc *crtc);
25
26 struct vc4_dummy_crtc {
27 struct vc4_crtc crtc;
28 --- a/drivers/gpu/drm/vc4/tests/vc4_mock_plane.c
29 +++ b/drivers/gpu/drm/vc4/tests/vc4_mock_plane.c
30 @@ -1,6 +1,7 @@
31 // SPDX-License-Identifier: GPL-2.0
32
33 #include <drm/drm_atomic_state_helper.h>
34 +#include <drm/drm_atomic_uapi.h>
35 #include <drm/drm_fourcc.h>
36 #include <drm/drm_modeset_helper_vtables.h>
37 #include <drm/drm_plane.h>
38 @@ -46,3 +47,24 @@ struct vc4_dummy_plane *vc4_dummy_plane(
39
40 return dummy_plane;
41 }
42 +
43 +struct drm_plane *
44 +vc4_mock_atomic_add_plane(struct kunit *test,
45 + struct drm_atomic_state *state,
46 + struct drm_crtc *crtc)
47 +{
48 + struct drm_plane_state *plane_state;
49 + struct drm_plane *plane;
50 + int ret;
51 +
52 + plane = vc4_mock_find_plane_for_crtc(test, crtc);
53 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, plane);
54 +
55 + plane_state = drm_atomic_get_plane_state(state, plane);
56 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, plane_state);
57 +
58 + ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
59 + KUNIT_EXPECT_EQ(test, ret, 0);
60 +
61 + return plane;
62 +}