1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#include <stdlib.h>
#include <limits.h>
#include <unistd.h>
#include <nvif/client.h>
#include <nvif/driver.h>
#include <nvif/device.h>
#include <nvif/class.h>
int
main(int argc, char **argv)
{
const char *drv = NULL;
const char *cfg = NULL;
const char *dbg = "info";
u64 dev = ~0ULL;
struct nvif_client *client;
struct nvif_device *device;
bool suspend = false, wait = false;
int ret, c;
while ((c = getopt(argc, argv, "-a:b:c:d:sw")) != -1) {
switch (c) {
case 'a': dev = strtoull(optarg, NULL, 0); break;
case 'b': drv = optarg; break;
case 'c': cfg = optarg; break;
case 'd': dbg = optarg; break;
case 's':
suspend = true;
break;
case 'w':
wait = true;
break;
case 1:
return -EINVAL;
}
}
ret = nvif_client_new(drv, argv[0], dev, cfg, dbg, &client);
if (ret)
return ret;
ret = nvif_device_new(nvif_object(client), 0, NV_DEVICE,
&(struct nv_device_v0) {
.device = ~0ULL,
.disable = 0ULL,
.debug0 = 0ULL,
}, sizeof(struct nv_device_v0), &device);
nvif_client_ref(NULL, &client);
if (ret)
return ret;
if (suspend) {
client->driver->suspend(client);
client->driver->resume(client);
}
while (wait && (c = getchar()) == EOF) {
sched_yield();
}
printf("shutting down...\n");
nvif_device_ref(NULL, &device);
printf("done!\n");
return ret;
}
|