xref: /netbsd-src/sys/external/bsd/drm2/dist/drm/nouveau/dispnv50/nouveau_dispnv50_base827c.c (revision 41ec02673d281bbb3d38e6c78504ce6e30c228c1)
1 /*	$NetBSD: nouveau_dispnv50_base827c.c,v 1.2 2021/12/18 23:45:32 riastradh Exp $	*/
2 
3 /*
4  * Copyright 2018 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 #include <sys/cdefs.h>
25 __KERNEL_RCSID(0, "$NetBSD: nouveau_dispnv50_base827c.c,v 1.2 2021/12/18 23:45:32 riastradh Exp $");
26 
27 #include "base.h"
28 
29 static void
base827c_image_set(struct nv50_wndw * wndw,struct nv50_wndw_atom * asyw)30 base827c_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
31 {
32 	u32 *push;
33 	if ((push = evo_wait(&wndw->wndw, 13))) {
34 		evo_mthd(push, 0x0084, 1);
35 		evo_data(push, asyw->image.mode << 8 |
36 			       asyw->image.interval << 4);
37 		evo_mthd(push, 0x00c0, 1);
38 		evo_data(push, asyw->image.handle[0]);
39 		if (asyw->image.format == 0xca) {
40 			evo_mthd(push, 0x0110, 2);
41 			evo_data(push, 1);
42 			evo_data(push, 0x6400);
43 		} else {
44 			evo_mthd(push, 0x0110, 2);
45 			evo_data(push, 0);
46 			evo_data(push, 0);
47 		}
48 		evo_mthd(push, 0x0800, 5);
49 		evo_data(push, asyw->image.offset[0] >> 8);
50 		evo_data(push, 0x00000000);
51 		evo_data(push, asyw->image.h << 16 | asyw->image.w);
52 		evo_data(push, asyw->image.layout << 20 |
53 			       (asyw->image.pitch[0] >> 8) << 8 |
54 			       asyw->image.blocks[0] << 8 |
55 			       asyw->image.blockh);
56 		evo_data(push, asyw->image.format << 8);
57 		evo_kick(push, &wndw->wndw);
58 	}
59 }
60 
61 static const struct nv50_wndw_func
62 base827c = {
63 	.acquire = base507c_acquire,
64 	.release = base507c_release,
65 	.sema_set = base507c_sema_set,
66 	.sema_clr = base507c_sema_clr,
67 	.ntfy_reset = base507c_ntfy_reset,
68 	.ntfy_set = base507c_ntfy_set,
69 	.ntfy_clr = base507c_ntfy_clr,
70 	.ntfy_wait_begun = base507c_ntfy_wait_begun,
71 	.olut_core = 1,
72 	.xlut_set = base507c_xlut_set,
73 	.xlut_clr = base507c_xlut_clr,
74 	.image_set = base827c_image_set,
75 	.image_clr = base507c_image_clr,
76 	.update = base507c_update,
77 };
78 
79 int
base827c_new(struct nouveau_drm * drm,int head,s32 oclass,struct nv50_wndw ** pwndw)80 base827c_new(struct nouveau_drm *drm, int head, s32 oclass,
81 	     struct nv50_wndw **pwndw)
82 {
83 	return base507c_new_(&base827c, base507c_format, drm, head, oclass,
84 			     0x00000002 << (head * 8), pwndw);
85 }
86