1facaed62SBen Skeggs /*
2facaed62SBen Skeggs  * Copyright 2018 Red Hat Inc.
3facaed62SBen Skeggs  *
4facaed62SBen Skeggs  * Permission is hereby granted, free of charge, to any person obtaining a
5facaed62SBen Skeggs  * copy of this software and associated documentation files (the "Software"),
6facaed62SBen Skeggs  * to deal in the Software without restriction, including without limitation
7facaed62SBen Skeggs  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8facaed62SBen Skeggs  * and/or sell copies of the Software, and to permit persons to whom the
9facaed62SBen Skeggs  * Software is furnished to do so, subject to the following conditions:
10facaed62SBen Skeggs  *
11facaed62SBen Skeggs  * The above copyright notice and this permission notice shall be included in
12facaed62SBen Skeggs  * all copies or substantial portions of the Software.
13facaed62SBen Skeggs  *
14facaed62SBen Skeggs  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15facaed62SBen Skeggs  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16facaed62SBen Skeggs  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17facaed62SBen Skeggs  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18facaed62SBen Skeggs  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19facaed62SBen Skeggs  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20facaed62SBen Skeggs  * OTHER DEALINGS IN THE SOFTWARE.
21facaed62SBen Skeggs  */
22facaed62SBen Skeggs #include "wimm.h"
23facaed62SBen Skeggs 
24facaed62SBen Skeggs #include <nvif/class.h>
25facaed62SBen Skeggs 
26facaed62SBen Skeggs int
nv50_wimm_init(struct nouveau_drm * drm,struct nv50_wndw * wndw)27facaed62SBen Skeggs nv50_wimm_init(struct nouveau_drm *drm, struct nv50_wndw *wndw)
28facaed62SBen Skeggs {
29facaed62SBen Skeggs 	struct {
30facaed62SBen Skeggs 		s32 oclass;
31facaed62SBen Skeggs 		int version;
32facaed62SBen Skeggs 		int (*init)(struct nouveau_drm *, s32, struct nv50_wndw *);
33facaed62SBen Skeggs 	} wimms[] = {
34*8ef23b6fSBen Skeggs 		{ GA102_DISP_WINDOW_IMM_CHANNEL_DMA, 0, wimmc37b_init },
3586037742SBen Skeggs 		{ TU102_DISP_WINDOW_IMM_CHANNEL_DMA, 0, wimmc37b_init },
36facaed62SBen Skeggs 		{ GV100_DISP_WINDOW_IMM_CHANNEL_DMA, 0, wimmc37b_init },
37facaed62SBen Skeggs 		{}
38facaed62SBen Skeggs 	};
39facaed62SBen Skeggs 	struct nv50_disp *disp = nv50_disp(drm->dev);
40facaed62SBen Skeggs 	int cid;
41facaed62SBen Skeggs 
42facaed62SBen Skeggs 	cid = nvif_mclass(&disp->disp->object, wimms);
43facaed62SBen Skeggs 	if (cid < 0) {
44facaed62SBen Skeggs 		NV_ERROR(drm, "No supported window immediate class\n");
45facaed62SBen Skeggs 		return cid;
46facaed62SBen Skeggs 	}
47facaed62SBen Skeggs 
48facaed62SBen Skeggs 	return wimms[cid].init(drm, wimms[cid].oclass, wndw);
49facaed62SBen Skeggs }
50