xref: /linux/drivers/gpu/drm/nouveau/dispnv50/base907c.c (revision b05d873808c77fedd25130b0355acc0da1c11e19)
1ccd27db8SBen Skeggs /*
2ccd27db8SBen Skeggs  * Copyright 2018 Red Hat Inc.
3ccd27db8SBen Skeggs  *
4ccd27db8SBen Skeggs  * Permission is hereby granted, free of charge, to any person obtaining a
5ccd27db8SBen Skeggs  * copy of this software and associated documentation files (the "Software"),
6ccd27db8SBen Skeggs  * to deal in the Software without restriction, including without limitation
7ccd27db8SBen Skeggs  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8ccd27db8SBen Skeggs  * and/or sell copies of the Software, and to permit persons to whom the
9ccd27db8SBen Skeggs  * Software is furnished to do so, subject to the following conditions:
10ccd27db8SBen Skeggs  *
11ccd27db8SBen Skeggs  * The above copyright notice and this permission notice shall be included in
12ccd27db8SBen Skeggs  * all copies or substantial portions of the Software.
13ccd27db8SBen Skeggs  *
14ccd27db8SBen Skeggs  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15ccd27db8SBen Skeggs  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16ccd27db8SBen Skeggs  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17ccd27db8SBen Skeggs  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18ccd27db8SBen Skeggs  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19ccd27db8SBen Skeggs  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20ccd27db8SBen Skeggs  * OTHER DEALINGS IN THE SOFTWARE.
21ccd27db8SBen Skeggs  */
22ccd27db8SBen Skeggs #include "base.h"
23ccd27db8SBen Skeggs 
24ccd27db8SBen Skeggs static void
25ccd27db8SBen Skeggs base907c_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
26ccd27db8SBen Skeggs {
27ccd27db8SBen Skeggs 	u32 *push;
28ccd27db8SBen Skeggs 	if ((push = evo_wait(&wndw->wndw, 10))) {
29ccd27db8SBen Skeggs 		evo_mthd(push, 0x0084, 1);
30ccd27db8SBen Skeggs 		evo_data(push, asyw->image.mode << 8 |
31ccd27db8SBen Skeggs 			       asyw->image.interval << 4);
32ccd27db8SBen Skeggs 		evo_mthd(push, 0x00c0, 1);
33261fcfa9SBen Skeggs 		evo_data(push, asyw->image.handle[0]);
34ccd27db8SBen Skeggs 		evo_mthd(push, 0x0400, 5);
35261fcfa9SBen Skeggs 		evo_data(push, asyw->image.offset[0] >> 8);
36ccd27db8SBen Skeggs 		evo_data(push, 0x00000000);
37ccd27db8SBen Skeggs 		evo_data(push, asyw->image.h << 16 | asyw->image.w);
38ccd27db8SBen Skeggs 		evo_data(push, asyw->image.layout << 24 |
39*b05d8738SBen Skeggs 			       (asyw->image.pitch[0] >> 8) << 8 |
40*b05d8738SBen Skeggs 			       asyw->image.blocks[0] << 8 |
41*b05d8738SBen Skeggs 			       asyw->image.blockh);
42ccd27db8SBen Skeggs 		evo_data(push, asyw->image.format << 8);
43ccd27db8SBen Skeggs 		evo_kick(push, &wndw->wndw);
44ccd27db8SBen Skeggs 	}
45ccd27db8SBen Skeggs }
46ccd27db8SBen Skeggs 
47119608a7SBen Skeggs static void
48119608a7SBen Skeggs base907c_xlut_clr(struct nv50_wndw *wndw)
49119608a7SBen Skeggs {
50119608a7SBen Skeggs 	u32 *push;
51119608a7SBen Skeggs 	if ((push = evo_wait(&wndw->wndw, 6))) {
52119608a7SBen Skeggs 		evo_mthd(push, 0x00e0, 1);
53119608a7SBen Skeggs 		evo_data(push, 0x00000000);
54119608a7SBen Skeggs 		evo_mthd(push, 0x00e8, 1);
55119608a7SBen Skeggs 		evo_data(push, 0x00000000);
56119608a7SBen Skeggs 		evo_mthd(push, 0x00fc, 1);
57119608a7SBen Skeggs 		evo_data(push, 0x00000000);
58119608a7SBen Skeggs 		evo_kick(push, &wndw->wndw);
59119608a7SBen Skeggs 	}
60119608a7SBen Skeggs }
61119608a7SBen Skeggs 
62119608a7SBen Skeggs static void
63119608a7SBen Skeggs base907c_xlut_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
64119608a7SBen Skeggs {
65119608a7SBen Skeggs 	u32 *push;
66119608a7SBen Skeggs 	if ((push = evo_wait(&wndw->wndw, 6))) {
67119608a7SBen Skeggs 		evo_mthd(push, 0x00e0, 3);
68119608a7SBen Skeggs 		evo_data(push, asyw->xlut.i.enable << 30 |
69119608a7SBen Skeggs 			       asyw->xlut.i.mode << 24);
70119608a7SBen Skeggs 		evo_data(push, asyw->xlut.i.offset >> 8);
71119608a7SBen Skeggs 		evo_data(push, 0x40000000);
72119608a7SBen Skeggs 		evo_mthd(push, 0x00fc, 1);
73119608a7SBen Skeggs 		evo_data(push, asyw->xlut.handle);
74119608a7SBen Skeggs 		evo_kick(push, &wndw->wndw);
75119608a7SBen Skeggs 	}
76119608a7SBen Skeggs }
77119608a7SBen Skeggs 
78119608a7SBen Skeggs static void
79119608a7SBen Skeggs base907c_ilut(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
80119608a7SBen Skeggs {
81119608a7SBen Skeggs 	asyw->xlut.i.mode = 7;
82119608a7SBen Skeggs 	asyw->xlut.i.enable = 2;
83119608a7SBen Skeggs }
84119608a7SBen Skeggs 
85ccd27db8SBen Skeggs static const struct nv50_wndw_func
86ccd27db8SBen Skeggs base907c = {
87ccd27db8SBen Skeggs 	.acquire = base507c_acquire,
88ccd27db8SBen Skeggs 	.release = base507c_release,
89ccd27db8SBen Skeggs 	.sema_set = base507c_sema_set,
90ccd27db8SBen Skeggs 	.sema_clr = base507c_sema_clr,
91ccd27db8SBen Skeggs 	.ntfy_reset = base507c_ntfy_reset,
92ccd27db8SBen Skeggs 	.ntfy_set = base507c_ntfy_set,
93ccd27db8SBen Skeggs 	.ntfy_clr = base507c_ntfy_clr,
94ccd27db8SBen Skeggs 	.ntfy_wait_begun = base507c_ntfy_wait_begun,
95119608a7SBen Skeggs 	.ilut = base907c_ilut,
96119608a7SBen Skeggs 	.olut_core = true,
97119608a7SBen Skeggs 	.xlut_set = base907c_xlut_set,
98119608a7SBen Skeggs 	.xlut_clr = base907c_xlut_clr,
99ccd27db8SBen Skeggs 	.image_set = base907c_image_set,
100ccd27db8SBen Skeggs 	.image_clr = base507c_image_clr,
10153e0a3e7SBen Skeggs 	.update = base507c_update,
102ccd27db8SBen Skeggs };
103ccd27db8SBen Skeggs 
104ccd27db8SBen Skeggs int
105ccd27db8SBen Skeggs base907c_new(struct nouveau_drm *drm, int head, s32 oclass,
106ccd27db8SBen Skeggs 	     struct nv50_wndw **pwndw)
107ccd27db8SBen Skeggs {
10853e0a3e7SBen Skeggs 	return base507c_new_(&base907c, base507c_format, drm, head, oclass,
10953e0a3e7SBen Skeggs 			     0x00000002 << (head * 4), pwndw);
110ccd27db8SBen Skeggs }
111