xref: /netbsd-src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/disp/nouveau_nvkm_engine_disp_basenv50.c (revision 41ec02673d281bbb3d38e6c78504ce6e30c228c1)
1 /*	$NetBSD: nouveau_nvkm_engine_disp_basenv50.c,v 1.3 2021/12/18 23:45:35 riastradh Exp $	*/
2 
3 /*
4  * Copyright 2012 Red Hat Inc.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22  * OTHER DEALINGS IN THE SOFTWARE.
23  *
24  * Authors: Ben Skeggs
25  */
26 #include <sys/cdefs.h>
27 __KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_disp_basenv50.c,v 1.3 2021/12/18 23:45:35 riastradh Exp $");
28 
29 #include "channv50.h"
30 #include "head.h"
31 
32 #include <core/client.h>
33 
34 #include <nvif/cl507c.h>
35 #include <nvif/unpack.h>
36 
37 int
nv50_disp_base_new_(const struct nv50_disp_chan_func * func,const struct nv50_disp_chan_mthd * mthd,struct nv50_disp * disp,int chid,const struct nvkm_oclass * oclass,void * argv,u32 argc,struct nvkm_object ** pobject)38 nv50_disp_base_new_(const struct nv50_disp_chan_func *func,
39 		    const struct nv50_disp_chan_mthd *mthd,
40 		    struct nv50_disp *disp, int chid,
41 		    const struct nvkm_oclass *oclass, void *argv, u32 argc,
42 		    struct nvkm_object **pobject)
43 {
44 	union {
45 		struct nv50_disp_base_channel_dma_v0 v0;
46 	} *args = argv;
47 	struct nvkm_object *parent = oclass->parent;
48 	int head, ret = -ENOSYS;
49 	u64 push;
50 
51 	nvif_ioctl(parent, "create disp base channel dma size %d\n", argc);
52 	if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false))) {
53 		nvif_ioctl(parent, "create disp base channel dma vers %d "
54 				   "pushbuf %016"PRIx64" head %d\n",
55 			   args->v0.version, args->v0.pushbuf, args->v0.head);
56 		if (!nvkm_head_find(&disp->base, args->v0.head))
57 			return -EINVAL;
58 		push = args->v0.pushbuf;
59 		head = args->v0.head;
60 	} else
61 		return ret;
62 
63 	return nv50_disp_dmac_new_(func, mthd, disp, chid + head,
64 				   head, push, oclass, pobject);
65 }
66 
67 static const struct nv50_disp_mthd_list
68 nv50_disp_base_mthd_base = {
69 	.mthd = 0x0000,
70 	.addr = 0x000000,
71 	.data = {
72 		{ 0x0080, 0x000000 },
73 		{ 0x0084, 0x0008c4 },
74 		{ 0x0088, 0x0008d0 },
75 		{ 0x008c, 0x0008dc },
76 		{ 0x0090, 0x0008e4 },
77 		{ 0x0094, 0x610884 },
78 		{ 0x00a0, 0x6108a0 },
79 		{ 0x00a4, 0x610878 },
80 		{ 0x00c0, 0x61086c },
81 		{ 0x00e0, 0x610858 },
82 		{ 0x00e4, 0x610860 },
83 		{ 0x00e8, 0x6108ac },
84 		{ 0x00ec, 0x6108b4 },
85 		{ 0x0100, 0x610894 },
86 		{ 0x0110, 0x6108bc },
87 		{ 0x0114, 0x61088c },
88 		{}
89 	}
90 };
91 
92 const struct nv50_disp_mthd_list
93 nv50_disp_base_mthd_image = {
94 	.mthd = 0x0400,
95 	.addr = 0x000000,
96 	.data = {
97 		{ 0x0800, 0x6108f0 },
98 		{ 0x0804, 0x6108fc },
99 		{ 0x0808, 0x61090c },
100 		{ 0x080c, 0x610914 },
101 		{ 0x0810, 0x610904 },
102 		{}
103 	}
104 };
105 
106 static const struct nv50_disp_chan_mthd
107 nv50_disp_base_mthd = {
108 	.name = "Base",
109 	.addr = 0x000540,
110 	.prev = 0x000004,
111 	.data = {
112 		{ "Global", 1, &nv50_disp_base_mthd_base },
113 		{  "Image", 2, &nv50_disp_base_mthd_image },
114 		{}
115 	}
116 };
117 
118 int
nv50_disp_base_new(const struct nvkm_oclass * oclass,void * argv,u32 argc,struct nv50_disp * disp,struct nvkm_object ** pobject)119 nv50_disp_base_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
120 		   struct nv50_disp *disp, struct nvkm_object **pobject)
121 {
122 	return nv50_disp_base_new_(&nv50_disp_dmac_func, &nv50_disp_base_mthd,
123 				   disp, 1, oclass, argv, argc, pobject);
124 }
125