2 * Copyright 2018 Red Hat Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
25 #include <nvif/class.h>
26 #include <nvif/pushc37b.h>
27 #include <nvif/timer.h>
29 #include <nvhw/class/clc37d.h>
31 #include <nouveau_bo.h>
34 corec37d_wndw_owner(struct nv50_core
*core
)
36 struct nvif_push
*push
= core
->chan
.push
;
37 const u32 windows
= 8; /*XXX*/
40 if ((ret
= PUSH_WAIT(push
, windows
* 2)))
43 for (i
= 0; i
< windows
; i
++) {
44 PUSH_MTHD(push
, NVC37D
, WINDOW_SET_CONTROL(i
),
45 NVDEF(NVC37D
, WINDOW_SET_CONTROL
, OWNER
, HEAD(i
>> 1)));
52 corec37d_update(struct nv50_core
*core
, u32
*interlock
, bool ntfy
)
54 struct nvif_push
*push
= core
->chan
.push
;
57 if ((ret
= PUSH_WAIT(push
, 9)))
61 PUSH_MTHD(push
, NVC37D
, SET_NOTIFIER_CONTROL
,
62 NVDEF(NVC37D
, SET_NOTIFIER_CONTROL
, MODE
, WRITE
) |
63 NVVAL(NVC37D
, SET_NOTIFIER_CONTROL
, OFFSET
, NV50_DISP_CORE_NTFY
>> 4) |
64 NVDEF(NVC37D
, SET_NOTIFIER_CONTROL
, NOTIFY
, ENABLE
));
67 PUSH_MTHD(push
, NVC37D
, SET_INTERLOCK_FLAGS
, interlock
[NV50_DISP_INTERLOCK_CURS
],
68 SET_WINDOW_INTERLOCK_FLAGS
, interlock
[NV50_DISP_INTERLOCK_WNDW
]);
69 PUSH_MTHD(push
, NVC37D
, UPDATE
, 0x00000001 |
70 NVDEF(NVC37D
, UPDATE
, SPECIAL_HANDLING
, NONE
) |
71 NVDEF(NVC37D
, UPDATE
, INHIBIT_INTERRUPTS
, FALSE
));
74 PUSH_MTHD(push
, NVC37D
, SET_NOTIFIER_CONTROL
,
75 NVDEF(NVC37D
, SET_NOTIFIER_CONTROL
, NOTIFY
, DISABLE
));
78 return PUSH_KICK(push
);
82 corec37d_ntfy_wait_done(struct nouveau_bo
*bo
, u32 offset
,
83 struct nvif_device
*device
)
85 s64 time
= nvif_msec(device
, 2000ULL,
86 if (NVBO_TD32(bo
, offset
, NV_DISP_NOTIFIER
, _0
, STATUS
, ==, FINISHED
))
90 return time
< 0 ? time
: 0;
94 corec37d_ntfy_init(struct nouveau_bo
*bo
, u32 offset
)
96 NVBO_WR32(bo
, offset
, NV_DISP_NOTIFIER
, _0
,
97 NVDEF(NV_DISP_NOTIFIER
, _0
, STATUS
, NOT_BEGUN
));
98 NVBO_WR32(bo
, offset
, NV_DISP_NOTIFIER
, _1
, 0);
99 NVBO_WR32(bo
, offset
, NV_DISP_NOTIFIER
, _2
, 0);
100 NVBO_WR32(bo
, offset
, NV_DISP_NOTIFIER
, _3
, 0);
103 int corec37d_caps_init(struct nouveau_drm
*drm
, struct nv50_disp
*disp
)
107 ret
= nvif_object_ctor(&disp
->disp
->object
, "dispCaps", 0,
108 GV100_DISP_CAPS
, NULL
, 0, &disp
->caps
);
111 "Failed to init notifier caps region: %d\n",
116 ret
= nvif_object_map(&disp
->caps
, NULL
, 0);
119 "Failed to map notifier caps region: %d\n",
128 corec37d_init(struct nv50_core
*core
)
130 struct nvif_push
*push
= core
->chan
.push
;
131 const u32 windows
= 8; /*XXX*/
134 if ((ret
= PUSH_WAIT(push
, 2 + windows
* 5)))
137 PUSH_MTHD(push
, NVC37D
, SET_CONTEXT_DMA_NOTIFIER
, core
->chan
.sync
.handle
);
139 for (i
= 0; i
< windows
; i
++) {
140 PUSH_MTHD(push
, NVC37D
, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS(i
),
141 NVDEF(NVC37D
, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS
, RGB_PACKED1BPP
, TRUE
) |
142 NVDEF(NVC37D
, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS
, RGB_PACKED2BPP
, TRUE
) |
143 NVDEF(NVC37D
, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS
, RGB_PACKED4BPP
, TRUE
) |
144 NVDEF(NVC37D
, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS
, RGB_PACKED8BPP
, TRUE
) |
145 NVDEF(NVC37D
, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS
, YUV_PACKED422
, TRUE
),
147 WINDOW_SET_WINDOW_ROTATED_FORMAT_USAGE_BOUNDS(i
), 0x00000000);
149 PUSH_MTHD(push
, NVC37D
, WINDOW_SET_WINDOW_USAGE_BOUNDS(i
),
150 NVVAL(NVC37D
, WINDOW_SET_WINDOW_USAGE_BOUNDS
, MAX_PIXELS_FETCHED_PER_LINE
, 0x7fff) |
151 NVDEF(NVC37D
, WINDOW_SET_WINDOW_USAGE_BOUNDS
, INPUT_LUT
, USAGE_1025
) |
152 NVDEF(NVC37D
, WINDOW_SET_WINDOW_USAGE_BOUNDS
, INPUT_SCALER_TAPS
, TAPS_2
) |
153 NVDEF(NVC37D
, WINDOW_SET_WINDOW_USAGE_BOUNDS
, UPSCALING_ALLOWED
, FALSE
));
156 core
->assign_windows
= true;
157 return PUSH_KICK(push
);
160 static const struct nv50_core_func
162 .init
= corec37d_init
,
163 .ntfy_init
= corec37d_ntfy_init
,
164 .caps_init
= corec37d_caps_init
,
165 .ntfy_wait_done
= corec37d_ntfy_wait_done
,
166 .update
= corec37d_update
,
167 .wndw
.owner
= corec37d_wndw_owner
,
170 #if IS_ENABLED(CONFIG_DEBUG_FS)
176 corec37d_new(struct nouveau_drm
*drm
, s32 oclass
, struct nv50_core
**pcore
)
178 return core507d_new_(&corec37d
, drm
, oclass
, pcore
);