xref: /linux/drivers/gpu/drm/nouveau/dispnv50/corec57d.c (revision fb7399cf2d0b33825b8039f95c45395c7deba25c)
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/class.h>
26 #include <nvif/pushc37b.h>
27 
28 #include <nvhw/class/clc57d.h>
29 
30 static int
31 corec57d_init(struct nv50_core *core)
32 {
33 	struct nvif_push *push = &core->chan.push;
34 	const u32 windows = 8; /*XXX*/
35 	int ret, i;
36 
37 	if ((ret = PUSH_WAIT(push, 2 + windows * 5)))
38 		return ret;
39 
40 	PUSH_MTHD(push, NVC57D, SET_CONTEXT_DMA_NOTIFIER, core->chan.sync.handle);
41 
42 	for (i = 0; i < windows; i++) {
43 		PUSH_MTHD(push, NVC57D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS(i),
44 			  NVDEF(NVC57D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS, RGB_PACKED1BPP, TRUE) |
45 			  NVDEF(NVC57D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS, RGB_PACKED2BPP, TRUE) |
46 			  NVDEF(NVC57D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS, RGB_PACKED4BPP, TRUE) |
47 			  NVDEF(NVC57D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS, RGB_PACKED8BPP, TRUE),
48 
49 					WINDOW_SET_WINDOW_ROTATED_FORMAT_USAGE_BOUNDS(i), 0x00000000);
50 
51 		PUSH_MTHD(push, NVC57D, WINDOW_SET_WINDOW_USAGE_BOUNDS(i),
52 			  NVVAL(NVC57D, WINDOW_SET_WINDOW_USAGE_BOUNDS, MAX_PIXELS_FETCHED_PER_LINE, 0x7fff) |
53 			  NVDEF(NVC57D, WINDOW_SET_WINDOW_USAGE_BOUNDS, ILUT_ALLOWED, TRUE) |
54 			  NVDEF(NVC57D, WINDOW_SET_WINDOW_USAGE_BOUNDS, INPUT_SCALER_TAPS, TAPS_2) |
55 			  NVDEF(NVC57D, WINDOW_SET_WINDOW_USAGE_BOUNDS, UPSCALING_ALLOWED, FALSE));
56 	}
57 
58 	core->assign_windows = true;
59 	return PUSH_KICK(push);
60 }
61 
62 static const struct nv50_core_func
63 corec57d = {
64 	.init = corec57d_init,
65 	.ntfy_init = corec37d_ntfy_init,
66 	.caps_init = corec37d_caps_init,
67 	.caps_class = GV100_DISP_CAPS,
68 	.ntfy_wait_done = corec37d_ntfy_wait_done,
69 	.update = corec37d_update,
70 	.wndw.owner = corec37d_wndw_owner,
71 	.head = &headc57d,
72 	.sor = &sorc37d,
73 #if IS_ENABLED(CONFIG_DEBUG_FS)
74 	.crc = &crcc57d,
75 #endif
76 };
77 
78 int
79 corec57d_new(struct nouveau_drm *drm, s32 oclass, struct nv50_core **pcore)
80 {
81 	return core507d_new_(&corec57d, drm, oclass, pcore);
82 }
83