1*37e1c45aSBen Skeggs /* 2*37e1c45aSBen Skeggs * Copyright 2018 Red Hat Inc. 3*37e1c45aSBen Skeggs * 4*37e1c45aSBen Skeggs * Permission is hereby granted, free of charge, to any person obtaining a 5*37e1c45aSBen Skeggs * copy of this software and associated documentation files (the "Software"), 6*37e1c45aSBen Skeggs * to deal in the Software without restriction, including without limitation 7*37e1c45aSBen Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8*37e1c45aSBen Skeggs * and/or sell copies of the Software, and to permit persons to whom the 9*37e1c45aSBen Skeggs * Software is furnished to do so, subject to the following conditions: 10*37e1c45aSBen Skeggs * 11*37e1c45aSBen Skeggs * The above copyright notice and this permission notice shall be included in 12*37e1c45aSBen Skeggs * all copies or substantial portions of the Software. 13*37e1c45aSBen Skeggs * 14*37e1c45aSBen Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15*37e1c45aSBen Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16*37e1c45aSBen Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17*37e1c45aSBen Skeggs * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18*37e1c45aSBen Skeggs * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19*37e1c45aSBen Skeggs * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20*37e1c45aSBen Skeggs * OTHER DEALINGS IN THE SOFTWARE. 21*37e1c45aSBen Skeggs */ 22*37e1c45aSBen Skeggs #include <nvif/user.h> 23*37e1c45aSBen Skeggs #include <nvif/device.h> 24*37e1c45aSBen Skeggs 25*37e1c45aSBen Skeggs #include <nvif/class.h> 26*37e1c45aSBen Skeggs 27*37e1c45aSBen Skeggs void 28*37e1c45aSBen Skeggs nvif_user_fini(struct nvif_device *device) 29*37e1c45aSBen Skeggs { 30*37e1c45aSBen Skeggs if (device->user.func) { 31*37e1c45aSBen Skeggs nvif_object_fini(&device->user.object); 32*37e1c45aSBen Skeggs device->user.func = NULL; 33*37e1c45aSBen Skeggs } 34*37e1c45aSBen Skeggs } 35*37e1c45aSBen Skeggs 36*37e1c45aSBen Skeggs int 37*37e1c45aSBen Skeggs nvif_user_init(struct nvif_device *device) 38*37e1c45aSBen Skeggs { 39*37e1c45aSBen Skeggs struct { 40*37e1c45aSBen Skeggs s32 oclass; 41*37e1c45aSBen Skeggs int version; 42*37e1c45aSBen Skeggs const struct nvif_user_func *func; 43*37e1c45aSBen Skeggs } users[] = { 44*37e1c45aSBen Skeggs { VOLTA_USERMODE_A, -1, &nvif_userc361 }, 45*37e1c45aSBen Skeggs {} 46*37e1c45aSBen Skeggs }; 47*37e1c45aSBen Skeggs int cid, ret; 48*37e1c45aSBen Skeggs 49*37e1c45aSBen Skeggs if (device->user.func) 50*37e1c45aSBen Skeggs return 0; 51*37e1c45aSBen Skeggs 52*37e1c45aSBen Skeggs cid = nvif_mclass(&device->object, users); 53*37e1c45aSBen Skeggs if (cid < 0) 54*37e1c45aSBen Skeggs return cid; 55*37e1c45aSBen Skeggs 56*37e1c45aSBen Skeggs ret = nvif_object_init(&device->object, 0, users[cid].oclass, NULL, 0, 57*37e1c45aSBen Skeggs &device->user.object); 58*37e1c45aSBen Skeggs if (ret) 59*37e1c45aSBen Skeggs return ret; 60*37e1c45aSBen Skeggs 61*37e1c45aSBen Skeggs nvif_object_map(&device->user.object, NULL, 0); 62*37e1c45aSBen Skeggs device->user.func = users[cid].func; 63*37e1c45aSBen Skeggs return 0; 64*37e1c45aSBen Skeggs } 65