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/cl0002.h>
28 #include <drm/drm_atomic_helper.h>
29 #include <drm/drm_fourcc.h>
31 #include "nouveau_bo.h"
32 #include "nouveau_gem.h"
35 nv50_wndw_ctxdma_del(struct nv50_wndw_ctxdma *ctxdma)
37 nvif_object_fini(&ctxdma->object);
38 list_del(&ctxdma->head);
42 static struct nv50_wndw_ctxdma *
43 nv50_wndw_ctxdma_new(struct nv50_wndw *wndw, struct drm_framebuffer *fb)
45 struct nouveau_drm *drm = nouveau_drm(fb->dev);
46 struct nv50_wndw_ctxdma *ctxdma;
51 struct nv_dma_v0 base;
53 struct nv50_dma_v0 nv50;
54 struct gf100_dma_v0 gf100;
55 struct gf119_dma_v0 gf119;
58 u32 argc = sizeof(args.base);
61 nouveau_framebuffer_get_layout(fb, &unused, &kind);
62 handle = 0xfb000000 | kind;
64 list_for_each_entry(ctxdma, &wndw->ctxdma.list, head) {
65 if (ctxdma->object.handle == handle)
69 if (!(ctxdma = kzalloc(sizeof(*ctxdma), GFP_KERNEL)))
70 return ERR_PTR(-ENOMEM);
71 list_add(&ctxdma->head, &wndw->ctxdma.list);
73 args.base.target = NV_DMA_V0_TARGET_VRAM;
74 args.base.access = NV_DMA_V0_ACCESS_RDWR;
76 args.base.limit = drm->client.device.info.ram_user - 1;
78 if (drm->client.device.info.chipset < 0x80) {
79 args.nv50.part = NV50_DMA_V0_PART_256;
80 argc += sizeof(args.nv50);
82 if (drm->client.device.info.chipset < 0xc0) {
83 args.nv50.part = NV50_DMA_V0_PART_256;
84 args.nv50.kind = kind;
85 argc += sizeof(args.nv50);
87 if (drm->client.device.info.chipset < 0xd0) {
88 args.gf100.kind = kind;
89 argc += sizeof(args.gf100);
91 args.gf119.page = GF119_DMA_V0_PAGE_LP;
92 args.gf119.kind = kind;
93 argc += sizeof(args.gf119);
96 ret = nvif_object_init(wndw->ctxdma.parent, handle, NV_DMA_IN_MEMORY,
97 &args, argc, &ctxdma->object);
99 nv50_wndw_ctxdma_del(ctxdma);
107 nv50_wndw_wait_armed(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
109 struct nv50_disp *disp = nv50_disp(wndw->plane.dev);
110 if (asyw->set.ntfy) {
111 return wndw->func->ntfy_wait_begun(disp->sync,
113 wndw->wndw.base.device);
119 nv50_wndw_flush_clr(struct nv50_wndw *wndw, u32 *interlock, bool flush,
120 struct nv50_wndw_atom *asyw)
122 union nv50_wndw_atom_mask clr = {
123 .mask = asyw->clr.mask & ~(flush ? 0 : asyw->set.mask),
125 if (clr.sema ) wndw->func-> sema_clr(wndw);
126 if (clr.ntfy ) wndw->func-> ntfy_clr(wndw);
127 if (clr.xlut ) wndw->func-> xlut_clr(wndw);
128 if (clr.csc ) wndw->func-> csc_clr(wndw);
129 if (clr.image) wndw->func->image_clr(wndw);
131 interlock[wndw->interlock.type] |= wndw->interlock.data;
135 nv50_wndw_flush_set(struct nv50_wndw *wndw, u32 *interlock,
136 struct nv50_wndw_atom *asyw)
138 if (interlock[NV50_DISP_INTERLOCK_CORE]) {
139 asyw->image.mode = 0;
140 asyw->image.interval = 1;
143 if (asyw->set.sema ) wndw->func->sema_set (wndw, asyw);
144 if (asyw->set.ntfy ) wndw->func->ntfy_set (wndw, asyw);
145 if (asyw->set.image) wndw->func->image_set(wndw, asyw);
147 if (asyw->set.xlut ) {
149 asyw->xlut.i.offset =
150 nv50_lut_load(&wndw->ilut, asyw->xlut.i.buffer,
151 asyw->ilut, asyw->xlut.i.load);
153 wndw->func->xlut_set(wndw, asyw);
156 if (asyw->set.csc ) wndw->func->csc_set (wndw, asyw);
157 if (asyw->set.scale) wndw->func->scale_set(wndw, asyw);
158 if (asyw->set.blend) wndw->func->blend_set(wndw, asyw);
159 if (asyw->set.point) {
160 if (asyw->set.point = false, asyw->set.mask)
161 interlock[wndw->interlock.type] |= wndw->interlock.data;
162 interlock[NV50_DISP_INTERLOCK_WIMM] |= wndw->interlock.wimm;
164 wndw->immd->point(wndw, asyw);
165 wndw->immd->update(wndw, interlock);
167 interlock[wndw->interlock.type] |= wndw->interlock.data;
172 nv50_wndw_ntfy_enable(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
174 struct nv50_disp *disp = nv50_disp(wndw->plane.dev);
176 asyw->ntfy.handle = wndw->wndw.sync.handle;
177 asyw->ntfy.offset = wndw->ntfy;
178 asyw->ntfy.awaken = false;
179 asyw->set.ntfy = true;
181 wndw->func->ntfy_reset(disp->sync, wndw->ntfy);
186 nv50_wndw_atomic_check_release(struct nv50_wndw *wndw,
187 struct nv50_wndw_atom *asyw,
188 struct nv50_head_atom *asyh)
190 struct nouveau_drm *drm = nouveau_drm(wndw->plane.dev);
191 NV_ATOMIC(drm, "%s release\n", wndw->plane.name);
192 wndw->func->release(wndw, asyw, asyh);
193 asyw->ntfy.handle = 0;
194 asyw->sema.handle = 0;
195 asyw->xlut.handle = 0;
196 memset(asyw->image.handle, 0x00, sizeof(asyw->image.handle));
200 nv50_wndw_atomic_check_acquire_yuv(struct nv50_wndw_atom *asyw)
202 switch (asyw->state.fb->format->format) {
203 case DRM_FORMAT_YUYV: asyw->image.format = 0x28; break;
204 case DRM_FORMAT_UYVY: asyw->image.format = 0x29; break;
209 asyw->image.colorspace = 1;
214 nv50_wndw_atomic_check_acquire_rgb(struct nv50_wndw_atom *asyw)
216 switch (asyw->state.fb->format->format) {
217 case DRM_FORMAT_C8 : asyw->image.format = 0x1e; break;
218 case DRM_FORMAT_XRGB8888 :
219 case DRM_FORMAT_ARGB8888 : asyw->image.format = 0xcf; break;
220 case DRM_FORMAT_RGB565 : asyw->image.format = 0xe8; break;
221 case DRM_FORMAT_XRGB1555 :
222 case DRM_FORMAT_ARGB1555 : asyw->image.format = 0xe9; break;
223 case DRM_FORMAT_XBGR2101010 :
224 case DRM_FORMAT_ABGR2101010 : asyw->image.format = 0xd1; break;
225 case DRM_FORMAT_XBGR8888 :
226 case DRM_FORMAT_ABGR8888 : asyw->image.format = 0xd5; break;
227 case DRM_FORMAT_XRGB2101010 :
228 case DRM_FORMAT_ARGB2101010 : asyw->image.format = 0xdf; break;
229 case DRM_FORMAT_XBGR16161616F:
230 case DRM_FORMAT_ABGR16161616F: asyw->image.format = 0xca; break;
234 asyw->image.colorspace = 0;
239 nv50_wndw_atomic_check_acquire(struct nv50_wndw *wndw, bool modeset,
240 struct nv50_wndw_atom *armw,
241 struct nv50_wndw_atom *asyw,
242 struct nv50_head_atom *asyh)
244 struct drm_framebuffer *fb = asyw->state.fb;
245 struct nouveau_drm *drm = nouveau_drm(wndw->plane.dev);
250 NV_ATOMIC(drm, "%s acquire\n", wndw->plane.name);
252 if (fb != armw->state.fb || !armw->visible || modeset) {
253 nouveau_framebuffer_get_layout(fb, &tile_mode, &kind);
255 asyw->image.w = fb->width;
256 asyw->image.h = fb->height;
257 asyw->image.kind = kind;
259 ret = nv50_wndw_atomic_check_acquire_rgb(asyw);
261 ret = nv50_wndw_atomic_check_acquire_yuv(asyw);
266 if (asyw->image.kind) {
267 asyw->image.layout = 0;
268 if (drm->client.device.info.chipset >= 0xc0)
269 asyw->image.blockh = tile_mode >> 4;
271 asyw->image.blockh = tile_mode;
272 asyw->image.blocks[0] = fb->pitches[0] / 64;
273 asyw->image.pitch[0] = 0;
275 asyw->image.layout = 1;
276 asyw->image.blockh = 0;
277 asyw->image.blocks[0] = 0;
278 asyw->image.pitch[0] = fb->pitches[0];
281 if (!asyh->state.async_flip)
282 asyw->image.interval = 1;
284 asyw->image.interval = 0;
285 asyw->image.mode = asyw->image.interval ? 0 : 1;
286 asyw->set.image = wndw->func->image_set != NULL;
289 if (wndw->func->scale_set) {
290 asyw->scale.sx = asyw->state.src_x >> 16;
291 asyw->scale.sy = asyw->state.src_y >> 16;
292 asyw->scale.sw = asyw->state.src_w >> 16;
293 asyw->scale.sh = asyw->state.src_h >> 16;
294 asyw->scale.dw = asyw->state.crtc_w;
295 asyw->scale.dh = asyw->state.crtc_h;
296 if (memcmp(&armw->scale, &asyw->scale, sizeof(asyw->scale)))
297 asyw->set.scale = true;
300 if (wndw->func->blend_set) {
301 asyw->blend.depth = 255 - asyw->state.normalized_zpos;
302 asyw->blend.k1 = asyw->state.alpha >> 8;
303 switch (asyw->state.pixel_blend_mode) {
304 case DRM_MODE_BLEND_PREMULTI:
305 asyw->blend.src_color = 2; /* K1 */
306 asyw->blend.dst_color = 7; /* NEG_K1_TIMES_SRC */
308 case DRM_MODE_BLEND_COVERAGE:
309 asyw->blend.src_color = 5; /* K1_TIMES_SRC */
310 asyw->blend.dst_color = 7; /* NEG_K1_TIMES_SRC */
312 case DRM_MODE_BLEND_PIXEL_NONE:
314 asyw->blend.src_color = 2; /* K1 */
315 asyw->blend.dst_color = 4; /* NEG_K1 */
318 if (memcmp(&armw->blend, &asyw->blend, sizeof(asyw->blend)))
319 asyw->set.blend = true;
323 asyw->point.x = asyw->state.crtc_x;
324 asyw->point.y = asyw->state.crtc_y;
325 if (memcmp(&armw->point, &asyw->point, sizeof(asyw->point)))
326 asyw->set.point = true;
329 return wndw->func->acquire(wndw, asyw, asyh);
333 nv50_wndw_atomic_check_lut(struct nv50_wndw *wndw,
334 struct nv50_wndw_atom *armw,
335 struct nv50_wndw_atom *asyw,
336 struct nv50_head_atom *asyh)
338 struct drm_property_blob *ilut = asyh->state.degamma_lut;
340 /* I8 format without an input LUT makes no sense, and the
341 * HW error-checks for this.
343 * In order to handle legacy gamma, when there's no input
344 * LUT we need to steal the output LUT and use it instead.
346 if (!ilut && asyw->state.fb->format->format == DRM_FORMAT_C8) {
347 /* This should be an error, but there's legacy clients
348 * that do a modeset before providing a gamma table.
350 * We keep the window disabled to avoid angering HW.
352 if (!(ilut = asyh->state.gamma_lut)) {
353 asyw->visible = false;
357 if (wndw->func->ilut)
358 asyh->wndw.olut |= BIT(wndw->id);
360 asyh->wndw.olut &= ~BIT(wndw->id);
363 if (!ilut && wndw->func->ilut_identity &&
364 asyw->state.fb->format->format != DRM_FORMAT_XBGR16161616F &&
365 asyw->state.fb->format->format != DRM_FORMAT_ABGR16161616F) {
366 static struct drm_property_blob dummy = {};
370 /* Recalculate LUT state. */
371 memset(&asyw->xlut, 0x00, sizeof(asyw->xlut));
372 if ((asyw->ilut = wndw->func->ilut ? ilut : NULL)) {
373 if (!wndw->func->ilut(wndw, asyw, drm_color_lut_size(ilut))) {
374 DRM_DEBUG_KMS("Invalid ilut\n");
377 asyw->xlut.handle = wndw->wndw.vram.handle;
378 asyw->xlut.i.buffer = !asyw->xlut.i.buffer;
379 asyw->set.xlut = true;
381 asyw->clr.xlut = armw->xlut.handle != 0;
384 /* Handle setting base SET_OUTPUT_LUT_LO_ENABLE_USE_CORE_LUT. */
385 if (wndw->func->olut_core &&
386 (!armw->visible || (armw->xlut.handle && !asyw->xlut.handle)))
387 asyw->set.xlut = true;
389 if (wndw->func->csc && asyh->state.ctm) {
390 const struct drm_color_ctm *ctm = asyh->state.ctm->data;
391 wndw->func->csc(wndw, asyw, ctm);
392 asyw->csc.valid = true;
393 asyw->set.csc = true;
395 asyw->csc.valid = false;
396 asyw->clr.csc = armw->csc.valid;
399 /* Can't do an immediate flip while changing the LUT. */
400 asyh->state.async_flip = false;
405 nv50_wndw_atomic_check(struct drm_plane *plane, struct drm_plane_state *state)
407 struct nouveau_drm *drm = nouveau_drm(plane->dev);
408 struct nv50_wndw *wndw = nv50_wndw(plane);
409 struct nv50_wndw_atom *armw = nv50_wndw_atom(wndw->plane.state);
410 struct nv50_wndw_atom *asyw = nv50_wndw_atom(state);
411 struct nv50_head_atom *harm = NULL, *asyh = NULL;
412 bool modeset = false;
415 NV_ATOMIC(drm, "%s atomic_check\n", plane->name);
417 /* Fetch the assembly state for the head the window will belong to,
418 * and determine whether the window will be visible.
420 if (asyw->state.crtc) {
421 asyh = nv50_head_atom_get(asyw->state.state, asyw->state.crtc);
423 return PTR_ERR(asyh);
424 modeset = drm_atomic_crtc_needs_modeset(&asyh->state);
425 asyw->visible = asyh->state.active;
427 asyw->visible = false;
430 /* Fetch assembly state for the head the window used to belong to. */
431 if (armw->state.crtc) {
432 harm = nv50_head_atom_get(asyw->state.state, armw->state.crtc);
434 return PTR_ERR(harm);
437 /* LUT configuration can potentially cause the window to be disabled. */
438 if (asyw->visible && wndw->func->xlut_set &&
440 asyh->state.color_mgmt_changed ||
441 asyw->state.fb->format->format !=
442 armw->state.fb->format->format)) {
443 ret = nv50_wndw_atomic_check_lut(wndw, armw, asyw, asyh);
448 /* Calculate new window state. */
450 ret = nv50_wndw_atomic_check_acquire(wndw, modeset,
455 asyh->wndw.mask |= BIT(wndw->id);
458 nv50_wndw_atomic_check_release(wndw, asyw, harm);
459 harm->wndw.mask &= ~BIT(wndw->id);
464 /* Aside from the obvious case where the window is actively being
465 * disabled, we might also need to temporarily disable the window
466 * when performing certain modeset operations.
468 if (!asyw->visible || modeset) {
469 asyw->clr.ntfy = armw->ntfy.handle != 0;
470 asyw->clr.sema = armw->sema.handle != 0;
471 asyw->clr.xlut = armw->xlut.handle != 0;
472 if (asyw->clr.xlut && asyw->visible)
473 asyw->set.xlut = asyw->xlut.handle != 0;
474 asyw->clr.csc = armw->csc.valid;
475 if (wndw->func->image_clr)
476 asyw->clr.image = armw->image.handle[0] != 0;
483 nv50_wndw_cleanup_fb(struct drm_plane *plane, struct drm_plane_state *old_state)
485 struct nouveau_drm *drm = nouveau_drm(plane->dev);
486 struct nouveau_bo *nvbo;
488 NV_ATOMIC(drm, "%s cleanup: %p\n", plane->name, old_state->fb);
492 nvbo = nouveau_gem_object(old_state->fb->obj[0]);
493 nouveau_bo_unpin(nvbo);
497 nv50_wndw_prepare_fb(struct drm_plane *plane, struct drm_plane_state *state)
499 struct drm_framebuffer *fb = state->fb;
500 struct nouveau_drm *drm = nouveau_drm(plane->dev);
501 struct nv50_wndw *wndw = nv50_wndw(plane);
502 struct nv50_wndw_atom *asyw = nv50_wndw_atom(state);
503 struct nouveau_bo *nvbo;
504 struct nv50_head_atom *asyh;
505 struct nv50_wndw_ctxdma *ctxdma;
508 NV_ATOMIC(drm, "%s prepare: %p\n", plane->name, fb);
512 nvbo = nouveau_gem_object(fb->obj[0]);
513 ret = nouveau_bo_pin(nvbo, TTM_PL_FLAG_VRAM, true);
517 if (wndw->ctxdma.parent) {
518 ctxdma = nv50_wndw_ctxdma_new(wndw, fb);
519 if (IS_ERR(ctxdma)) {
520 nouveau_bo_unpin(nvbo);
521 return PTR_ERR(ctxdma);
525 asyw->image.handle[0] = ctxdma->object.handle;
528 asyw->state.fence = dma_resv_get_excl_rcu(nvbo->bo.base.resv);
529 asyw->image.offset[0] = nvbo->offset;
531 if (wndw->func->prepare) {
532 asyh = nv50_head_atom_get(asyw->state.state, asyw->state.crtc);
534 return PTR_ERR(asyh);
536 wndw->func->prepare(wndw, asyh, asyw);
542 static const struct drm_plane_helper_funcs
544 .prepare_fb = nv50_wndw_prepare_fb,
545 .cleanup_fb = nv50_wndw_cleanup_fb,
546 .atomic_check = nv50_wndw_atomic_check,
550 nv50_wndw_atomic_destroy_state(struct drm_plane *plane,
551 struct drm_plane_state *state)
553 struct nv50_wndw_atom *asyw = nv50_wndw_atom(state);
554 __drm_atomic_helper_plane_destroy_state(&asyw->state);
558 static struct drm_plane_state *
559 nv50_wndw_atomic_duplicate_state(struct drm_plane *plane)
561 struct nv50_wndw_atom *armw = nv50_wndw_atom(plane->state);
562 struct nv50_wndw_atom *asyw;
563 if (!(asyw = kmalloc(sizeof(*asyw), GFP_KERNEL)))
565 __drm_atomic_helper_plane_duplicate_state(plane, &asyw->state);
566 asyw->sema = armw->sema;
567 asyw->ntfy = armw->ntfy;
569 asyw->xlut = armw->xlut;
570 asyw->csc = armw->csc;
571 asyw->image = armw->image;
572 asyw->point = armw->point;
579 nv50_wndw_zpos_default(struct drm_plane *plane)
581 return (plane->type == DRM_PLANE_TYPE_PRIMARY) ? 0 :
582 (plane->type == DRM_PLANE_TYPE_OVERLAY) ? 1 : 255;
586 nv50_wndw_reset(struct drm_plane *plane)
588 struct nv50_wndw_atom *asyw;
590 if (WARN_ON(!(asyw = kzalloc(sizeof(*asyw), GFP_KERNEL))))
594 plane->funcs->atomic_destroy_state(plane, plane->state);
596 __drm_atomic_helper_plane_reset(plane, &asyw->state);
597 plane->state->zpos = nv50_wndw_zpos_default(plane);
598 plane->state->normalized_zpos = nv50_wndw_zpos_default(plane);
602 nv50_wndw_destroy(struct drm_plane *plane)
604 struct nv50_wndw *wndw = nv50_wndw(plane);
605 struct nv50_wndw_ctxdma *ctxdma, *ctxtmp;
607 list_for_each_entry_safe(ctxdma, ctxtmp, &wndw->ctxdma.list, head) {
608 nv50_wndw_ctxdma_del(ctxdma);
611 nvif_notify_fini(&wndw->notify);
612 nv50_dmac_destroy(&wndw->wimm);
613 nv50_dmac_destroy(&wndw->wndw);
615 nv50_lut_fini(&wndw->ilut);
617 drm_plane_cleanup(&wndw->plane);
621 /* This function assumes the format has already been validated against the plane
622 * and the modifier was validated against the device-wides modifier list at FB
625 static bool nv50_plane_format_mod_supported(struct drm_plane *plane,
626 u32 format, u64 modifier)
628 struct nouveau_drm *drm = nouveau_drm(plane->dev);
631 if (drm->client.device.info.chipset < 0xc0) {
632 const struct drm_format_info *info = drm_format_info(format);
633 const uint8_t kind = (modifier >> 12) & 0xff;
635 if (!format) return false;
637 for (i = 0; i < info->num_planes; i++)
638 if ((info->cpp[i] != 4) && kind != 0x70) return false;
644 const struct drm_plane_funcs
646 .update_plane = drm_atomic_helper_update_plane,
647 .disable_plane = drm_atomic_helper_disable_plane,
648 .destroy = nv50_wndw_destroy,
649 .reset = nv50_wndw_reset,
650 .atomic_duplicate_state = nv50_wndw_atomic_duplicate_state,
651 .atomic_destroy_state = nv50_wndw_atomic_destroy_state,
652 .format_mod_supported = nv50_plane_format_mod_supported,
656 nv50_wndw_notify(struct nvif_notify *notify)
658 return NVIF_NOTIFY_KEEP;
662 nv50_wndw_fini(struct nv50_wndw *wndw)
664 nvif_notify_put(&wndw->notify);
668 nv50_wndw_init(struct nv50_wndw *wndw)
670 nvif_notify_get(&wndw->notify);
674 nv50_wndw_new_(const struct nv50_wndw_func *func, struct drm_device *dev,
675 enum drm_plane_type type, const char *name, int index,
676 const u32 *format, u32 heads,
677 enum nv50_disp_interlock_type interlock_type, u32 interlock_data,
678 struct nv50_wndw **pwndw)
680 struct nouveau_drm *drm = nouveau_drm(dev);
681 struct nvif_mmu *mmu = &drm->client.mmu;
682 struct nv50_disp *disp = nv50_disp(dev);
683 struct nv50_wndw *wndw;
687 if (!(wndw = *pwndw = kzalloc(sizeof(*wndw), GFP_KERNEL)))
691 wndw->interlock.type = interlock_type;
692 wndw->interlock.data = interlock_data;
694 wndw->ctxdma.parent = &wndw->wndw.base.user;
695 INIT_LIST_HEAD(&wndw->ctxdma.list);
697 for (nformat = 0; format[nformat]; nformat++);
699 ret = drm_universal_plane_init(dev, &wndw->plane, heads, &nv50_wndw,
701 nouveau_display(dev)->format_modifiers,
702 type, "%s-%d", name, index);
709 drm_plane_helper_add(&wndw->plane, &nv50_wndw_helper);
711 if (wndw->func->ilut) {
712 ret = nv50_lut_init(disp, mmu, &wndw->ilut);
717 wndw->notify.func = nv50_wndw_notify;
719 if (wndw->func->blend_set) {
720 ret = drm_plane_create_zpos_property(&wndw->plane,
721 nv50_wndw_zpos_default(&wndw->plane), 0, 254);
725 ret = drm_plane_create_alpha_property(&wndw->plane);
729 ret = drm_plane_create_blend_mode_property(&wndw->plane,
730 BIT(DRM_MODE_BLEND_PIXEL_NONE) |
731 BIT(DRM_MODE_BLEND_PREMULTI) |
732 BIT(DRM_MODE_BLEND_COVERAGE));
736 ret = drm_plane_create_zpos_immutable_property(&wndw->plane,
737 nv50_wndw_zpos_default(&wndw->plane));
746 nv50_wndw_new(struct nouveau_drm *drm, enum drm_plane_type type, int index,
747 struct nv50_wndw **pwndw)
752 int (*new)(struct nouveau_drm *, enum drm_plane_type,
753 int, s32, struct nv50_wndw **);
755 { TU102_DISP_WINDOW_CHANNEL_DMA, 0, wndwc57e_new },
756 { GV100_DISP_WINDOW_CHANNEL_DMA, 0, wndwc37e_new },
759 struct nv50_disp *disp = nv50_disp(drm->dev);
762 cid = nvif_mclass(&disp->disp->object, wndws);
764 NV_ERROR(drm, "No supported window class\n");
768 ret = wndws[cid].new(drm, type, index, wndws[cid].oclass, pwndw);
772 return nv50_wimm_init(drm, *pwndw);