10d4a2c57SBen Skeggs /* 20d4a2c57SBen Skeggs * Copyright 2018 Red Hat Inc. 30d4a2c57SBen Skeggs * 40d4a2c57SBen Skeggs * Permission is hereby granted, free of charge, to any person obtaining a 50d4a2c57SBen Skeggs * copy of this software and associated documentation files (the "Software"), 60d4a2c57SBen Skeggs * to deal in the Software without restriction, including without limitation 70d4a2c57SBen Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense, 80d4a2c57SBen Skeggs * and/or sell copies of the Software, and to permit persons to whom the 90d4a2c57SBen Skeggs * Software is furnished to do so, subject to the following conditions: 100d4a2c57SBen Skeggs * 110d4a2c57SBen Skeggs * The above copyright notice and this permission notice shall be included in 120d4a2c57SBen Skeggs * all copies or substantial portions of the Software. 130d4a2c57SBen Skeggs * 140d4a2c57SBen Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 150d4a2c57SBen Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 160d4a2c57SBen Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 170d4a2c57SBen Skeggs * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 180d4a2c57SBen Skeggs * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 190d4a2c57SBen Skeggs * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 200d4a2c57SBen Skeggs * OTHER DEALINGS IN THE SOFTWARE. 210d4a2c57SBen Skeggs */ 220d4a2c57SBen Skeggs #include <nvif/disp.h> 230d4a2c57SBen Skeggs #include <nvif/device.h> 24*168c0299SBen Skeggs #include <nvif/printf.h> 250d4a2c57SBen Skeggs 260d4a2c57SBen Skeggs #include <nvif/class.h> 27*168c0299SBen Skeggs #include <nvif/if0010.h> 280d4a2c57SBen Skeggs 290d4a2c57SBen Skeggs void 300d4a2c57SBen Skeggs nvif_disp_dtor(struct nvif_disp *disp) 310d4a2c57SBen Skeggs { 329ac596a4SBen Skeggs nvif_object_dtor(&disp->object); 330d4a2c57SBen Skeggs } 340d4a2c57SBen Skeggs 350d4a2c57SBen Skeggs int 36*168c0299SBen Skeggs nvif_disp_ctor(struct nvif_device *device, const char *name, s32 oclass, struct nvif_disp *disp) 370d4a2c57SBen Skeggs { 380d4a2c57SBen Skeggs static const struct nvif_mclass disps[] = { 39*168c0299SBen Skeggs { GA102_DISP, 0 }, 40*168c0299SBen Skeggs { TU102_DISP, 0 }, 41*168c0299SBen Skeggs { GV100_DISP, 0 }, 42*168c0299SBen Skeggs { GP102_DISP, 0 }, 43*168c0299SBen Skeggs { GP100_DISP, 0 }, 44*168c0299SBen Skeggs { GM200_DISP, 0 }, 45*168c0299SBen Skeggs { GM107_DISP, 0 }, 46*168c0299SBen Skeggs { GK110_DISP, 0 }, 47*168c0299SBen Skeggs { GK104_DISP, 0 }, 48*168c0299SBen Skeggs { GF110_DISP, 0 }, 49*168c0299SBen Skeggs { GT214_DISP, 0 }, 50*168c0299SBen Skeggs { GT206_DISP, 0 }, 51*168c0299SBen Skeggs { GT200_DISP, 0 }, 52*168c0299SBen Skeggs { G82_DISP, 0 }, 53*168c0299SBen Skeggs { NV50_DISP, 0 }, 54*168c0299SBen Skeggs { NV04_DISP, 0 }, 550d4a2c57SBen Skeggs {} 560d4a2c57SBen Skeggs }; 57*168c0299SBen Skeggs struct nvif_disp_v0 args; 58*168c0299SBen Skeggs int cid, ret; 590d4a2c57SBen Skeggs 60*168c0299SBen Skeggs cid = nvif_sclass(&device->object, disps, oclass); 61*168c0299SBen Skeggs disp->object.client = NULL; 62*168c0299SBen Skeggs if (cid < 0) { 63*168c0299SBen Skeggs NVIF_ERRON(cid, &device->object, "[NEW disp%04x] not supported", oclass); 64*168c0299SBen Skeggs return cid; 65*168c0299SBen Skeggs } 66*168c0299SBen Skeggs 67*168c0299SBen Skeggs args.version = 0; 68*168c0299SBen Skeggs 69*168c0299SBen Skeggs ret = nvif_object_ctor(&device->object, name ?: "nvifDisp", 0, 70*168c0299SBen Skeggs disps[cid].oclass, &args, sizeof(args), &disp->object); 71*168c0299SBen Skeggs NVIF_ERRON(ret, &device->object, "[NEW disp%04x]", disps[cid].oclass); 72*168c0299SBen Skeggs return ret; 730d4a2c57SBen Skeggs } 74