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 <drm/drm_atomic_helper.h>
26 #include <drm/drm_plane_helper.h>
27 #include <nouveau_bo.h>
29 #include <nvif/clc37e.h>
32 wndwc37e_ilut_clr(struct nv50_wndw *wndw)
35 if ((push = evo_wait(&wndw->wndw, 2))) {
36 evo_mthd(push, 0x02b8, 1);
37 evo_data(push, 0x00000000);
38 evo_kick(push, &wndw->wndw);
43 wndwc37e_ilut_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
46 if ((push = evo_wait(&wndw->wndw, 4))) {
47 evo_mthd(push, 0x02b0, 3);
48 evo_data(push, asyw->xlut.i.output_mode << 8 |
49 asyw->xlut.i.range << 4 |
51 evo_data(push, asyw->xlut.i.offset >> 8);
52 evo_data(push, asyw->xlut.handle);
53 evo_kick(push, &wndw->wndw);
58 wndwc37e_ilut(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
60 asyw->xlut.i.mode = 2;
61 asyw->xlut.i.size = 0;
62 asyw->xlut.i.range = 0;
63 asyw->xlut.i.output_mode = 1;
64 asyw->xlut.i.load = head907d_olut_load;
68 wndwc37e_image_clr(struct nv50_wndw *wndw)
71 if ((push = evo_wait(&wndw->wndw, 4))) {
72 evo_mthd(push, 0x0308, 1);
73 evo_data(push, 0x00000000);
74 evo_mthd(push, 0x0240, 1);
75 evo_data(push, 0x00000000);
76 evo_kick(push, &wndw->wndw);
81 wndwc37e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
85 if (!(push = evo_wait(&wndw->wndw, 25)))
88 evo_mthd(push, 0x0308, 1);
89 evo_data(push, asyw->image.mode << 4 | asyw->image.interval);
90 evo_mthd(push, 0x0224, 4);
91 evo_data(push, asyw->image.h << 16 | asyw->image.w);
92 evo_data(push, asyw->image.layout << 4 | asyw->image.blockh);
93 evo_data(push, asyw->image.colorspace << 8 | asyw->image.format);
94 evo_data(push, asyw->image.blocks[0] | (asyw->image.pitch[0] >> 6));
95 evo_mthd(push, 0x0240, 1);
96 evo_data(push, asyw->image.handle[0]);
97 evo_mthd(push, 0x0260, 1);
98 evo_data(push, asyw->image.offset[0] >> 8);
99 evo_mthd(push, 0x0290, 1);
100 evo_data(push, (asyw->state.src_y >> 16) << 16 |
101 (asyw->state.src_x >> 16));
102 evo_mthd(push, 0x0298, 1);
103 evo_data(push, (asyw->state.src_h >> 16) << 16 |
104 (asyw->state.src_w >> 16));
105 evo_mthd(push, 0x02a4, 1);
106 evo_data(push, asyw->state.crtc_h << 16 |
109 /*XXX: Composition-related stuff. Need to implement properly. */
110 evo_mthd(push, 0x02ec, 7);
111 evo_data(push, (2 - (wndw->id & 1)) << 4);
112 evo_data(push, 0x000000ff);
113 evo_data(push, 0x00007722);
114 evo_data(push, 0xffff0000);
115 evo_data(push, 0xffff0000);
116 evo_data(push, 0xffff0000);
117 evo_data(push, 0xffff0000);
118 evo_kick(push, &wndw->wndw);
122 wndwc37e_ntfy_clr(struct nv50_wndw *wndw)
125 if ((push = evo_wait(&wndw->wndw, 2))) {
126 evo_mthd(push, 0x021c, 1);
127 evo_data(push, 0x00000000);
128 evo_kick(push, &wndw->wndw);
133 wndwc37e_ntfy_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
136 if ((push = evo_wait(&wndw->wndw, 3))) {
137 evo_mthd(push, 0x021c, 2);
138 evo_data(push, asyw->ntfy.handle);
139 evo_data(push, asyw->ntfy.offset | asyw->ntfy.awaken);
140 evo_kick(push, &wndw->wndw);
145 wndwc37e_sema_clr(struct nv50_wndw *wndw)
148 if ((push = evo_wait(&wndw->wndw, 2))) {
149 evo_mthd(push, 0x0218, 1);
150 evo_data(push, 0x00000000);
151 evo_kick(push, &wndw->wndw);
156 wndwc37e_sema_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
159 if ((push = evo_wait(&wndw->wndw, 5))) {
160 evo_mthd(push, 0x020c, 4);
161 evo_data(push, asyw->sema.offset);
162 evo_data(push, asyw->sema.acquire);
163 evo_data(push, asyw->sema.release);
164 evo_data(push, asyw->sema.handle);
165 evo_kick(push, &wndw->wndw);
170 wndwc37e_update(struct nv50_wndw *wndw, u32 *interlock)
173 if ((push = evo_wait(&wndw->wndw, 5))) {
174 evo_mthd(push, 0x0370, 2);
175 evo_data(push, interlock[NV50_DISP_INTERLOCK_CURS] << 1 |
176 interlock[NV50_DISP_INTERLOCK_CORE]);
177 evo_data(push, interlock[NV50_DISP_INTERLOCK_WNDW]);
178 evo_mthd(push, 0x0200, 1);
179 if (interlock[NV50_DISP_INTERLOCK_WIMM] & wndw->interlock.data)
180 evo_data(push, 0x00001001);
182 evo_data(push, 0x00000001);
183 evo_kick(push, &wndw->wndw);
188 wndwc37e_release(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
189 struct nv50_head_atom *asyh)
194 wndwc37e_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
195 struct nv50_head_atom *asyh)
197 return drm_atomic_helper_check_plane_state(&asyw->state, &asyh->state,
198 DRM_PLANE_HELPER_NO_SCALING,
199 DRM_PLANE_HELPER_NO_SCALING,
204 wndwc37e_format[] = {
213 DRM_FORMAT_XBGR2101010,
214 DRM_FORMAT_ABGR2101010,
217 DRM_FORMAT_XRGB2101010,
218 DRM_FORMAT_ARGB2101010,
219 DRM_FORMAT_XBGR16161616F,
220 DRM_FORMAT_ABGR16161616F,
224 static const struct nv50_wndw_func
226 .acquire = wndwc37e_acquire,
227 .release = wndwc37e_release,
228 .sema_set = wndwc37e_sema_set,
229 .sema_clr = wndwc37e_sema_clr,
230 .ntfy_set = wndwc37e_ntfy_set,
231 .ntfy_clr = wndwc37e_ntfy_clr,
232 .ntfy_reset = corec37d_ntfy_init,
233 .ntfy_wait_begun = base507c_ntfy_wait_begun,
234 .ilut = wndwc37e_ilut,
235 .xlut_set = wndwc37e_ilut_set,
236 .xlut_clr = wndwc37e_ilut_clr,
237 .image_set = wndwc37e_image_set,
238 .image_clr = wndwc37e_image_clr,
239 .update = wndwc37e_update,
243 wndwc37e_new_(const struct nv50_wndw_func *func, struct nouveau_drm *drm,
244 enum drm_plane_type type, int index, s32 oclass, u32 heads,
245 struct nv50_wndw **pwndw)
247 struct nvc37e_window_channel_dma_v0 args = {
248 .pushbuf = 0xb0007e00 | index,
251 struct nv50_disp *disp = nv50_disp(drm->dev);
252 struct nv50_wndw *wndw;
255 ret = nv50_wndw_new_(func, drm->dev, type, "wndw", index,
256 wndwc37e_format, heads, NV50_DISP_INTERLOCK_WNDW,
258 if (*pwndw = wndw, ret)
261 ret = nv50_dmac_create(&drm->client.device, &disp->disp->object,
262 &oclass, 0, &args, sizeof(args),
263 disp->sync->bo.offset, &wndw->wndw);
265 NV_ERROR(drm, "qndw%04x allocation failed: %d\n", oclass, ret);
269 wndw->ntfy = NV50_DISP_WNDW_NTFY(wndw->id);
270 wndw->sema = NV50_DISP_WNDW_SEM0(wndw->id);
271 wndw->data = 0x00000000;
276 wndwc37e_new(struct nouveau_drm *drm, enum drm_plane_type type, int index,
277 s32 oclass, struct nv50_wndw **pwndw)
279 return wndwc37e_new_(&wndwc37e, drm, type, index, oclass,
280 BIT(index >> 1), pwndw);