1 // SPDX-License-Identifier: GPL-2.0
2 
3 #include <drm/drm_atomic_state_helper.h>
4 #include <drm/drm_modeset_helper_vtables.h>
5 
6 #include <kunit/test.h>
7 
8 #include "vc4_mock.h"
9 
10 static const struct drm_crtc_helper_funcs vc4_dummy_crtc_helper_funcs = {
11 	.atomic_check	= vc4_crtc_atomic_check,
12 };
13 
14 static const struct drm_crtc_funcs vc4_dummy_crtc_funcs = {
15 	.atomic_destroy_state	= vc4_crtc_destroy_state,
16 	.atomic_duplicate_state	= vc4_crtc_duplicate_state,
17 	.reset			= vc4_crtc_reset,
18 };
19 
vc4_mock_pv(struct kunit * test,struct drm_device * drm,struct drm_plane * plane,const struct vc4_crtc_data * data)20 struct vc4_dummy_crtc *vc4_mock_pv(struct kunit *test,
21 				   struct drm_device *drm,
22 				   struct drm_plane *plane,
23 				   const struct vc4_crtc_data *data)
24 {
25 	struct vc4_dummy_crtc *dummy_crtc;
26 	struct vc4_crtc *vc4_crtc;
27 	int ret;
28 
29 	dummy_crtc = drmm_kzalloc(drm, sizeof(*dummy_crtc), GFP_KERNEL);
30 	KUNIT_ASSERT_NOT_NULL(test, dummy_crtc);
31 
32 	vc4_crtc = &dummy_crtc->crtc;
33 	ret = __vc4_crtc_init(drm, NULL,
34 			      vc4_crtc, data, plane,
35 			      &vc4_dummy_crtc_funcs,
36 			      &vc4_dummy_crtc_helper_funcs,
37 			      false);
38 	KUNIT_ASSERT_EQ(test, ret, 0);
39 
40 	return dummy_crtc;
41 }
42