diff options
author | Thierry Reding | 2014-02-19 07:48:31 -0600 |
---|---|---|
committer | Thierry Reding | 2014-11-27 10:20:27 -0600 |
commit | 93035cfbebf1344a041b70fbf9f3b89f6542805f (patch) | |
tree | 1b5daee7de436e3569d494c6ab9adfdfcad2fd23 /tests/tegra/openclose.c | |
parent | d6a4c2cbd11e357a9123f6d41f6d40d38e82e7f2 (diff) | |
download | external-libgbm-93035cfbebf1344a041b70fbf9f3b89f6542805f.tar.gz external-libgbm-93035cfbebf1344a041b70fbf9f3b89f6542805f.tar.xz external-libgbm-93035cfbebf1344a041b70fbf9f3b89f6542805f.zip |
tegra: Add simple test for drm_tegra_open()
This test opens a device, dumps the version information and checks that
a Tegra DRM context can be opened on it.
Signed-off-by: Thierry Reding <treding@nvidia.com>
Diffstat (limited to 'tests/tegra/openclose.c')
-rw-r--r-- | tests/tegra/openclose.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/tegra/openclose.c b/tests/tegra/openclose.c new file mode 100644 index 00000000..881d8aa4 --- /dev/null +++ b/tests/tegra/openclose.c | |||
@@ -0,0 +1,71 @@ | |||
1 | /* | ||
2 | * Copyright © 2014 NVIDIA 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 shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #ifdef HAVE_CONFIG_H | ||
24 | # include "config.h" | ||
25 | #endif | ||
26 | |||
27 | #include <fcntl.h> | ||
28 | #include <stdio.h> | ||
29 | #include <unistd.h> | ||
30 | |||
31 | #include "xf86drm.h" | ||
32 | #include "tegra.h" | ||
33 | |||
34 | static const char default_device[] = "/dev/dri/card0"; | ||
35 | |||
36 | int main(int argc, char *argv[]) | ||
37 | { | ||
38 | struct drm_tegra *tegra; | ||
39 | drmVersionPtr version; | ||
40 | const char *device; | ||
41 | int err, fd; | ||
42 | |||
43 | if (argc < 2) | ||
44 | device = default_device; | ||
45 | else | ||
46 | device = argv[1]; | ||
47 | |||
48 | fd = open(device, O_RDWR); | ||
49 | if (fd < 0) | ||
50 | return 1; | ||
51 | |||
52 | version = drmGetVersion(fd); | ||
53 | if (version) { | ||
54 | printf("Version: %d.%d.%d\n", version->version_major, | ||
55 | version->version_minor, version->version_patchlevel); | ||
56 | printf(" Name: %s\n", version->name); | ||
57 | printf(" Date: %s\n", version->date); | ||
58 | printf(" Description: %s\n", version->desc); | ||
59 | |||
60 | drmFreeVersion(version); | ||
61 | } | ||
62 | |||
63 | err = drm_tegra_new(&tegra, fd); | ||
64 | if (err < 0) | ||
65 | return 1; | ||
66 | |||
67 | drm_tegra_close(tegra); | ||
68 | close(fd); | ||
69 | |||
70 | return 0; | ||
71 | } | ||