0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 #include <nvif/client.h>
0026 #include <nvif/driver.h>
0027 #include <nvif/ioctl.h>
0028
0029 #include <nvif/class.h>
0030 #include <nvif/if0000.h>
0031
0032 int
0033 nvif_client_ioctl(struct nvif_client *client, void *data, u32 size)
0034 {
0035 return client->driver->ioctl(client->object.priv, data, size, NULL);
0036 }
0037
0038 int
0039 nvif_client_suspend(struct nvif_client *client)
0040 {
0041 return client->driver->suspend(client->object.priv);
0042 }
0043
0044 int
0045 nvif_client_resume(struct nvif_client *client)
0046 {
0047 return client->driver->resume(client->object.priv);
0048 }
0049
0050 void
0051 nvif_client_dtor(struct nvif_client *client)
0052 {
0053 nvif_object_dtor(&client->object);
0054 if (client->driver) {
0055 if (client->driver->fini)
0056 client->driver->fini(client->object.priv);
0057 client->driver = NULL;
0058 }
0059 }
0060
0061 int
0062 nvif_client_ctor(struct nvif_client *parent, const char *name, u64 device,
0063 struct nvif_client *client)
0064 {
0065 struct nvif_client_v0 args = { .device = device };
0066 struct {
0067 struct nvif_ioctl_v0 ioctl;
0068 struct nvif_ioctl_nop_v0 nop;
0069 } nop = {};
0070 int ret;
0071
0072 strncpy(args.name, name, sizeof(args.name));
0073 ret = nvif_object_ctor(parent != client ? &parent->object : NULL,
0074 name ? name : "nvifClient", 0,
0075 NVIF_CLASS_CLIENT, &args, sizeof(args),
0076 &client->object);
0077 if (ret)
0078 return ret;
0079
0080 client->object.client = client;
0081 client->object.handle = ~0;
0082 client->route = NVIF_IOCTL_V0_ROUTE_NVIF;
0083 client->driver = parent->driver;
0084
0085 if (ret == 0) {
0086 ret = nvif_client_ioctl(client, &nop, sizeof(nop));
0087 client->version = nop.nop.version;
0088 }
0089
0090 if (ret)
0091 nvif_client_dtor(client);
0092 return ret;
0093 }