xref: /openbmc/linux/drivers/gpu/drm/nouveau/nvif/disp.c (revision 0d4a2c57)
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>
240d4a2c57SBen Skeggs 
250d4a2c57SBen Skeggs #include <nvif/class.h>
260d4a2c57SBen Skeggs 
270d4a2c57SBen Skeggs void
280d4a2c57SBen Skeggs nvif_disp_dtor(struct nvif_disp *disp)
290d4a2c57SBen Skeggs {
300d4a2c57SBen Skeggs 	nvif_object_fini(&disp->object);
310d4a2c57SBen Skeggs }
320d4a2c57SBen Skeggs 
330d4a2c57SBen Skeggs int
340d4a2c57SBen Skeggs nvif_disp_ctor(struct nvif_device *device, s32 oclass, struct nvif_disp *disp)
350d4a2c57SBen Skeggs {
360d4a2c57SBen Skeggs 	static const struct nvif_mclass disps[] = {
370d4a2c57SBen Skeggs 		{ GP102_DISP, -1 },
380d4a2c57SBen Skeggs 		{ GP100_DISP, -1 },
390d4a2c57SBen Skeggs 		{ GM200_DISP, -1 },
400d4a2c57SBen Skeggs 		{ GM107_DISP, -1 },
410d4a2c57SBen Skeggs 		{ GK110_DISP, -1 },
420d4a2c57SBen Skeggs 		{ GK104_DISP, -1 },
430d4a2c57SBen Skeggs 		{ GF110_DISP, -1 },
440d4a2c57SBen Skeggs 		{ GT214_DISP, -1 },
450d4a2c57SBen Skeggs 		{ GT206_DISP, -1 },
460d4a2c57SBen Skeggs 		{ GT200_DISP, -1 },
470d4a2c57SBen Skeggs 		{   G82_DISP, -1 },
480d4a2c57SBen Skeggs 		{  NV50_DISP, -1 },
490d4a2c57SBen Skeggs 		{  NV04_DISP, -1 },
500d4a2c57SBen Skeggs 		{}
510d4a2c57SBen Skeggs 	};
520d4a2c57SBen Skeggs 	int cid = nvif_sclass(&device->object, disps, oclass);
530d4a2c57SBen Skeggs 	disp->object.client = NULL;
540d4a2c57SBen Skeggs 	if (cid < 0)
550d4a2c57SBen Skeggs 		return cid;
560d4a2c57SBen Skeggs 
570d4a2c57SBen Skeggs 	return nvif_object_init(&device->object, 0, disps[cid].oclass,
580d4a2c57SBen Skeggs 				NULL, 0, &disp->object);
590d4a2c57SBen Skeggs }
60