1 /*
2  * Copyright 2018 Red Hat Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  */
22 #include "core.h"
23 #include "head.h"
24 
25 #include <nvif/pushc37b.h>
26 
27 #include <nvhw/class/clc57d.h>
28 
29 static int
30 corec57d_init(struct nv50_core *core)
31 {
32 	struct nvif_push *push = core->chan.push;
33 	const u32 windows = 8; /*XXX*/
34 	int ret, i;
35 
36 	if ((ret = PUSH_WAIT(push, 2 + windows * 5)))
37 		return ret;
38 
39 	PUSH_MTHD(push, NVC57D, SET_CONTEXT_DMA_NOTIFIER, core->chan.sync.handle);
40 
41 	for (i = 0; i < windows; i++) {
42 		PUSH_MTHD(push, NVC57D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS(i),
43 			  NVDEF(NVC57D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS, RGB_PACKED1BPP, TRUE) |
44 			  NVDEF(NVC57D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS, RGB_PACKED2BPP, TRUE) |
45 			  NVDEF(NVC57D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS, RGB_PACKED4BPP, TRUE) |
46 			  NVDEF(NVC57D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS, RGB_PACKED8BPP, TRUE),
47 
48 					WINDOW_SET_WINDOW_ROTATED_FORMAT_USAGE_BOUNDS(i), 0x00000000);
49 
50 		PUSH_MTHD(push, NVC57D, WINDOW_SET_WINDOW_USAGE_BOUNDS(i),
51 			  NVVAL(NVC57D, WINDOW_SET_WINDOW_USAGE_BOUNDS, MAX_PIXELS_FETCHED_PER_LINE, 0x7fff) |
52 			  NVDEF(NVC57D, WINDOW_SET_WINDOW_USAGE_BOUNDS, ILUT_ALLOWED, TRUE) |
53 			  NVDEF(NVC57D, WINDOW_SET_WINDOW_USAGE_BOUNDS, INPUT_SCALER_TAPS, TAPS_2) |
54 			  NVDEF(NVC57D, WINDOW_SET_WINDOW_USAGE_BOUNDS, UPSCALING_ALLOWED, FALSE));
55 	}
56 
57 	core->assign_windows = true;
58 	return PUSH_KICK(push);
59 }
60 
61 static const struct nv50_core_func
62 corec57d = {
63 	.init = corec57d_init,
64 	.ntfy_init = corec37d_ntfy_init,
65 	.caps_init = corec37d_caps_init,
66 	.ntfy_wait_done = corec37d_ntfy_wait_done,
67 	.update = corec37d_update,
68 	.wndw.owner = corec37d_wndw_owner,
69 	.head = &headc57d,
70 	.sor = &sorc37d,
71 #if IS_ENABLED(CONFIG_DEBUG_FS)
72 	.crc = &crcc57d,
73 #endif
74 };
75 
76 int
77 corec57d_new(struct nouveau_drm *drm, s32 oclass, struct nv50_core **pcore)
78 {
79 	return core507d_new_(&corec57d, drm, oclass, pcore);
80 }
81