1 /*
2 * Copyright © 2022 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 #undef NDEBUG
25
26 #include <assert.h>
27 #include <stdlib.h>
28 #include <sys/types.h>
29 #include <sys/stat.h>
30 #include <fcntl.h>
31 #include <unistd.h>
32
33 #include <xf86drm.h>
34
35 #include "intel_device_info.h"
36 #include "intel_device_info_test.h"
37
38 int
main(int argc,char * argv[])39 main(int argc, char *argv[])
40 {
41 drmDevicePtr devices[8];
42 int max_devices;
43
44 if (argc != 2) {
45 fprintf(stderr, "format: %s verx10_number\n", argv[0]);
46 return -1;
47 }
48
49 int verx10 = atoi(argv[1]);
50
51 max_devices = drmGetDevices2(0, devices, ARRAY_SIZE(devices));
52 if (max_devices < 1) {
53 fprintf(stderr, "Device not found\n");
54 return -1;
55 }
56
57 for (int i = 0; i < max_devices; i++) {
58 struct intel_device_info devinfo;
59 const char *path = devices[i]->nodes[DRM_NODE_RENDER];
60 int fd = open(path, O_RDWR | O_CLOEXEC);
61
62 if (fd < 0)
63 continue;
64
65 bool success = intel_get_device_info_from_fd(fd, &devinfo);
66 close(fd);
67
68 if (!success)
69 continue;
70
71 fprintf(stderr, "%u\n", devinfo.verx10);
72 assert(devinfo.verx10 == verx10);
73 verify_device_info(&devinfo);
74 }
75
76 return 0;
77 }
78