xref: /aosp_15_r20/external/igt-gpu-tools/lib/igt_kmod.h (revision d83cc019efdc2edc6c4b16e9034a3ceb8d35d77c)
1 /*
2  * Copyright © 2016 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  */
23 
24 #ifndef IGT_KMOD_H
25 #define IGT_KMOD_H
26 
27 #include <libkmod.h>
28 
29 #include "igt_list.h"
30 
31 bool igt_kmod_is_loaded(const char *mod_name);
32 void igt_kmod_list_loaded(void);
33 
34 int igt_kmod_load(const char *mod_name, const char *opts);
35 int igt_kmod_unload(const char *mod_name, unsigned int flags);
36 
37 int igt_i915_driver_load(const char *opts);
38 int igt_i915_driver_unload(void);
39 
40 void igt_kselftests(const char *module_name,
41 		    const char *module_options,
42 		    const char *result_option,
43 		    const char *filter);
44 
45 struct igt_kselftest {
46 	struct kmod_module *kmod;
47 	char *module_name;
48 	int kmsg;
49 };
50 
51 struct igt_kselftest_list {
52 	struct igt_list link;
53 	unsigned int number;
54 	char *name;
55 	char param[];
56 };
57 
58 int igt_kselftest_init(struct igt_kselftest *tst,
59 		       const char *module_name);
60 int igt_kselftest_begin(struct igt_kselftest *tst);
61 
62 void igt_kselftest_get_tests(struct kmod_module *kmod,
63 			     const char *filter,
64 			     struct igt_list *tests);
65 int igt_kselftest_execute(struct igt_kselftest *tst,
66 			  struct igt_kselftest_list *tl,
67 			  const char *module_options,
68 			  const char *result);
69 
70 void igt_kselftest_end(struct igt_kselftest *tst);
71 void igt_kselftest_fini(struct igt_kselftest *tst);
72 
73 #endif /* IGT_KMOD_H */
74