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>
24168c0299SBen Skeggs #include <nvif/printf.h>
250d4a2c57SBen Skeggs
260d4a2c57SBen Skeggs #include <nvif/class.h>
27168c0299SBen Skeggs #include <nvif/if0010.h>
280d4a2c57SBen Skeggs
290d4a2c57SBen Skeggs void
nvif_disp_dtor(struct nvif_disp * disp)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
nvif_disp_ctor(struct nvif_device * device,const char * name,s32 oclass,struct nvif_disp * disp)36168c0299SBen 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[] = {
39168c0299SBen Skeggs { GA102_DISP, 0 },
40168c0299SBen Skeggs { TU102_DISP, 0 },
41168c0299SBen Skeggs { GV100_DISP, 0 },
42168c0299SBen Skeggs { GP102_DISP, 0 },
43168c0299SBen Skeggs { GP100_DISP, 0 },
44168c0299SBen Skeggs { GM200_DISP, 0 },
45168c0299SBen Skeggs { GM107_DISP, 0 },
46168c0299SBen Skeggs { GK110_DISP, 0 },
47168c0299SBen Skeggs { GK104_DISP, 0 },
48168c0299SBen Skeggs { GF110_DISP, 0 },
49168c0299SBen Skeggs { GT214_DISP, 0 },
50168c0299SBen Skeggs { GT206_DISP, 0 },
51168c0299SBen Skeggs { GT200_DISP, 0 },
52168c0299SBen Skeggs { G82_DISP, 0 },
53168c0299SBen Skeggs { NV50_DISP, 0 },
54168c0299SBen Skeggs { NV04_DISP, 0 },
550d4a2c57SBen Skeggs {}
560d4a2c57SBen Skeggs };
57168c0299SBen Skeggs struct nvif_disp_v0 args;
58168c0299SBen Skeggs int cid, ret;
590d4a2c57SBen Skeggs
60168c0299SBen Skeggs cid = nvif_sclass(&device->object, disps, oclass);
61168c0299SBen Skeggs disp->object.client = NULL;
62168c0299SBen Skeggs if (cid < 0) {
63168c0299SBen Skeggs NVIF_ERRON(cid, &device->object, "[NEW disp%04x] not supported", oclass);
64168c0299SBen Skeggs return cid;
65168c0299SBen Skeggs }
66168c0299SBen Skeggs
67168c0299SBen Skeggs args.version = 0;
68168c0299SBen Skeggs
69168c0299SBen Skeggs ret = nvif_object_ctor(&device->object, name ?: "nvifDisp", 0,
70168c0299SBen Skeggs disps[cid].oclass, &args, sizeof(args), &disp->object);
71168c0299SBen Skeggs NVIF_ERRON(ret, &device->object, "[NEW disp%04x]", disps[cid].oclass);
7295983aeaSBen Skeggs if (ret)
73168c0299SBen Skeggs return ret;
7495983aeaSBen Skeggs
75*a2b7eadfSBen Skeggs NVIF_DEBUG(&disp->object, "[NEW] conn_mask:%08x outp_mask:%08x head_mask:%08x",
76*a2b7eadfSBen Skeggs args.conn_mask, args.outp_mask, args.head_mask);
7795983aeaSBen Skeggs disp->conn_mask = args.conn_mask;
781b255f1cSBen Skeggs disp->outp_mask = args.outp_mask;
79*a2b7eadfSBen Skeggs disp->head_mask = args.head_mask;
8095983aeaSBen Skeggs return 0;
810d4a2c57SBen Skeggs }
82