1 /* SPDX-License-Identifier: GPL-2.0 AND MIT */
2 /*
3  * Copyright © 2023 Intel Corporation
4  */
5 #ifndef TTM_KUNIT_HELPERS_H
6 #define TTM_KUNIT_HELPERS_H
7 
8 #include <drm/drm_drv.h>
9 #include <drm/ttm/ttm_device.h>
10 #include <drm/ttm/ttm_bo.h>
11 
12 #include <drm/drm_kunit_helpers.h>
13 #include <kunit/test.h>
14 
15 extern struct ttm_device_funcs ttm_dev_funcs;
16 
17 struct ttm_test_devices {
18 	struct drm_device *drm;
19 	struct device *dev;
20 	struct ttm_device *ttm_dev;
21 };
22 
23 /* Building blocks for test-specific init functions */
24 int ttm_device_kunit_init(struct ttm_test_devices *priv,
25 			  struct ttm_device *ttm,
26 			  bool use_dma_alloc,
27 			  bool use_dma32);
28 struct ttm_buffer_object *ttm_bo_kunit_init(struct kunit *test,
29 					    struct ttm_test_devices *devs,
30 					    size_t size);
31 
32 struct ttm_test_devices *ttm_test_devices_basic(struct kunit *test);
33 struct ttm_test_devices *ttm_test_devices_all(struct kunit *test);
34 
35 void ttm_test_devices_put(struct kunit *test, struct ttm_test_devices *devs);
36 
37 /* Generic init/fini for tests that only need DRM/TTM devices */
38 int ttm_test_devices_init(struct kunit *test);
39 void ttm_test_devices_fini(struct kunit *test);
40 
41 #endif // TTM_KUNIT_HELPERS_H
42