summaryrefslogtreecommitdiff
path: root/bin/nv_init.c
blob: 90c14d5eaf6452cf44e5837d02f27d49789d7c17 (plain)
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
#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>

#include "util.h"

int
main(int argc, char **argv)
{
	struct nvif_client client;
	struct nvif_device device;
	bool suspend = false, wait = false;
	int ret, c;

	while ((c = getopt(argc, argv, "sw"U_GETOPT)) != -1) {
		switch (c) {
		case 's':
			suspend = true;
			break;
		case 'w':
			wait = true;
			break;
		default:
			if (!u_option(c))
				return 1;
			break;
		}
	}

	ret = u_device(NULL, argv[0], "info", true, true, ~0ULL,
		       0x00000000, &client, &device);
	if (ret)
		return ret;

	if (suspend) {
		nvif_client_suspend(&client);
		nvif_client_resume(&client);
	}

	while (wait && (c = getchar()) == EOF) {
		sched_yield();
	}

	printf("shutting down...\n");
	nvif_device_fini(&device);
	nvif_client_fini(&client);
	printf("done!\n");
	return ret;
}