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