18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright 2018 Red Hat Inc.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation
78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
128c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
158c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
168c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
178c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
188c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
198c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
208c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
218c2ecf20Sopenharmony_ci */
228c2ecf20Sopenharmony_ci#include "base.h"
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#include <nvif/cl507c.h>
258c2ecf20Sopenharmony_ci#include <nvif/event.h>
268c2ecf20Sopenharmony_ci#include <nvif/push507c.h>
278c2ecf20Sopenharmony_ci#include <nvif/timer.h>
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci#include <nvhw/class/cl507c.h>
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#include <drm/drm_atomic_helper.h>
328c2ecf20Sopenharmony_ci#include <drm/drm_fourcc.h>
338c2ecf20Sopenharmony_ci#include <drm/drm_plane_helper.h>
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#include "nouveau_bo.h"
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ciint
388c2ecf20Sopenharmony_cibase507c_update(struct nv50_wndw *wndw, u32 *interlock)
398c2ecf20Sopenharmony_ci{
408c2ecf20Sopenharmony_ci	struct nvif_push *push = wndw->wndw.push;
418c2ecf20Sopenharmony_ci	int ret;
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 2)))
448c2ecf20Sopenharmony_ci		return ret;
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV507C, UPDATE, interlock[NV50_DISP_INTERLOCK_CORE]);
478c2ecf20Sopenharmony_ci	return PUSH_KICK(push);
488c2ecf20Sopenharmony_ci}
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ciint
518c2ecf20Sopenharmony_cibase507c_image_clr(struct nv50_wndw *wndw)
528c2ecf20Sopenharmony_ci{
538c2ecf20Sopenharmony_ci	struct nvif_push *push = wndw->wndw.push;
548c2ecf20Sopenharmony_ci	int ret;
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 4)))
578c2ecf20Sopenharmony_ci		return ret;
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV507C, SET_PRESENT_CONTROL,
608c2ecf20Sopenharmony_ci		  NVDEF(NV507C, SET_PRESENT_CONTROL, BEGIN_MODE, NON_TEARING) |
618c2ecf20Sopenharmony_ci		  NVVAL(NV507C, SET_PRESENT_CONTROL, MIN_PRESENT_INTERVAL, 0));
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV507C, SET_CONTEXT_DMA_ISO, 0x00000000);
648c2ecf20Sopenharmony_ci	return 0;
658c2ecf20Sopenharmony_ci}
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_cistatic int
688c2ecf20Sopenharmony_cibase507c_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
698c2ecf20Sopenharmony_ci{
708c2ecf20Sopenharmony_ci	struct nvif_push *push = wndw->wndw.push;
718c2ecf20Sopenharmony_ci	int ret;
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 13)))
748c2ecf20Sopenharmony_ci		return ret;
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV507C, SET_PRESENT_CONTROL,
778c2ecf20Sopenharmony_ci		  NVVAL(NV507C, SET_PRESENT_CONTROL, BEGIN_MODE, asyw->image.mode) |
788c2ecf20Sopenharmony_ci		  NVVAL(NV507C, SET_PRESENT_CONTROL, MIN_PRESENT_INTERVAL, asyw->image.interval));
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV507C, SET_CONTEXT_DMA_ISO, asyw->image.handle[0]);
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci	if (asyw->image.format == NV507C_SURFACE_SET_PARAMS_FORMAT_RF16_GF16_BF16_AF16) {
838c2ecf20Sopenharmony_ci		PUSH_MTHD(push, NV507C, SET_PROCESSING,
848c2ecf20Sopenharmony_ci			  NVDEF(NV507C, SET_PROCESSING, USE_GAIN_OFS, ENABLE),
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci					SET_CONVERSION,
878c2ecf20Sopenharmony_ci			  NVVAL(NV507C, SET_CONVERSION, GAIN, 0) |
888c2ecf20Sopenharmony_ci			  NVVAL(NV507C, SET_CONVERSION, OFS, 0x64));
898c2ecf20Sopenharmony_ci	} else {
908c2ecf20Sopenharmony_ci		PUSH_MTHD(push, NV507C, SET_PROCESSING,
918c2ecf20Sopenharmony_ci			  NVDEF(NV507C, SET_PROCESSING, USE_GAIN_OFS, DISABLE),
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci					SET_CONVERSION,
948c2ecf20Sopenharmony_ci			  NVVAL(NV507C, SET_CONVERSION, GAIN, 0) |
958c2ecf20Sopenharmony_ci			  NVVAL(NV507C, SET_CONVERSION, OFS, 0));
968c2ecf20Sopenharmony_ci	}
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV507C, SURFACE_SET_OFFSET(0, 0), asyw->image.offset[0] >> 8);
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV507C, SURFACE_SET_SIZE(0),
1018c2ecf20Sopenharmony_ci		  NVVAL(NV507C, SURFACE_SET_SIZE, WIDTH, asyw->image.w) |
1028c2ecf20Sopenharmony_ci		  NVVAL(NV507C, SURFACE_SET_SIZE, HEIGHT, asyw->image.h),
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci				SURFACE_SET_STORAGE(0),
1058c2ecf20Sopenharmony_ci		  NVVAL(NV507C, SURFACE_SET_STORAGE, MEMORY_LAYOUT, asyw->image.layout) |
1068c2ecf20Sopenharmony_ci		  NVVAL(NV507C, SURFACE_SET_STORAGE, PITCH, asyw->image.pitch[0] >> 8) |
1078c2ecf20Sopenharmony_ci		  NVVAL(NV507C, SURFACE_SET_STORAGE, PITCH, asyw->image.blocks[0]) |
1088c2ecf20Sopenharmony_ci		  NVVAL(NV507C, SURFACE_SET_STORAGE, BLOCK_HEIGHT, asyw->image.blockh),
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci				SURFACE_SET_PARAMS(0),
1118c2ecf20Sopenharmony_ci		  NVVAL(NV507C, SURFACE_SET_PARAMS, FORMAT, asyw->image.format) |
1128c2ecf20Sopenharmony_ci		  NVDEF(NV507C, SURFACE_SET_PARAMS, SUPER_SAMPLE, X1_AA) |
1138c2ecf20Sopenharmony_ci		  NVDEF(NV507C, SURFACE_SET_PARAMS, GAMMA, LINEAR) |
1148c2ecf20Sopenharmony_ci		  NVDEF(NV507C, SURFACE_SET_PARAMS, LAYOUT, FRM) |
1158c2ecf20Sopenharmony_ci		  NVVAL(NV507C, SURFACE_SET_PARAMS, KIND, asyw->image.kind) |
1168c2ecf20Sopenharmony_ci		  NVDEF(NV507C, SURFACE_SET_PARAMS, PART_STRIDE, PARTSTRIDE_256));
1178c2ecf20Sopenharmony_ci	return 0;
1188c2ecf20Sopenharmony_ci}
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ciint
1218c2ecf20Sopenharmony_cibase507c_xlut_clr(struct nv50_wndw *wndw)
1228c2ecf20Sopenharmony_ci{
1238c2ecf20Sopenharmony_ci	struct nvif_push *push = wndw->wndw.push;
1248c2ecf20Sopenharmony_ci	int ret;
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 2)))
1278c2ecf20Sopenharmony_ci		return ret;
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV507C, SET_BASE_LUT_LO,
1308c2ecf20Sopenharmony_ci		  NVDEF(NV507C, SET_BASE_LUT_LO, ENABLE, DISABLE));
1318c2ecf20Sopenharmony_ci	return 0;
1328c2ecf20Sopenharmony_ci}
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ciint
1358c2ecf20Sopenharmony_cibase507c_xlut_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
1368c2ecf20Sopenharmony_ci{
1378c2ecf20Sopenharmony_ci	struct nvif_push *push = wndw->wndw.push;
1388c2ecf20Sopenharmony_ci	int ret;
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 2)))
1418c2ecf20Sopenharmony_ci		return ret;
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV507C, SET_BASE_LUT_LO,
1448c2ecf20Sopenharmony_ci		  NVDEF(NV507C, SET_BASE_LUT_LO, ENABLE, USE_CORE_LUT));
1458c2ecf20Sopenharmony_ci	return 0;
1468c2ecf20Sopenharmony_ci}
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ciint
1498c2ecf20Sopenharmony_cibase507c_ntfy_wait_begun(struct nouveau_bo *bo, u32 offset,
1508c2ecf20Sopenharmony_ci			 struct nvif_device *device)
1518c2ecf20Sopenharmony_ci{
1528c2ecf20Sopenharmony_ci	s64 time = nvif_msec(device, 2000ULL,
1538c2ecf20Sopenharmony_ci		if (NVBO_TD32(bo, offset, NV_DISP_BASE_NOTIFIER_1, _0, STATUS, ==, BEGUN))
1548c2ecf20Sopenharmony_ci			break;
1558c2ecf20Sopenharmony_ci		usleep_range(1, 2);
1568c2ecf20Sopenharmony_ci	);
1578c2ecf20Sopenharmony_ci	return time < 0 ? time : 0;
1588c2ecf20Sopenharmony_ci}
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ciint
1618c2ecf20Sopenharmony_cibase507c_ntfy_clr(struct nv50_wndw *wndw)
1628c2ecf20Sopenharmony_ci{
1638c2ecf20Sopenharmony_ci	struct nvif_push *push = wndw->wndw.push;
1648c2ecf20Sopenharmony_ci	int ret;
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 2)))
1678c2ecf20Sopenharmony_ci		return ret;
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV507C, SET_CONTEXT_DMA_NOTIFIER, 0x00000000);
1708c2ecf20Sopenharmony_ci	return 0;
1718c2ecf20Sopenharmony_ci}
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ciint
1748c2ecf20Sopenharmony_cibase507c_ntfy_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
1758c2ecf20Sopenharmony_ci{
1768c2ecf20Sopenharmony_ci	struct nvif_push *push = wndw->wndw.push;
1778c2ecf20Sopenharmony_ci	int ret;
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 3)))
1808c2ecf20Sopenharmony_ci		return ret;
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV507C, SET_NOTIFIER_CONTROL,
1838c2ecf20Sopenharmony_ci		  NVVAL(NV507C, SET_NOTIFIER_CONTROL, MODE, asyw->ntfy.awaken) |
1848c2ecf20Sopenharmony_ci		  NVVAL(NV507C, SET_NOTIFIER_CONTROL, OFFSET, asyw->ntfy.offset >> 2),
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_ci				SET_CONTEXT_DMA_NOTIFIER, asyw->ntfy.handle);
1878c2ecf20Sopenharmony_ci	return 0;
1888c2ecf20Sopenharmony_ci}
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_civoid
1918c2ecf20Sopenharmony_cibase507c_ntfy_reset(struct nouveau_bo *bo, u32 offset)
1928c2ecf20Sopenharmony_ci{
1938c2ecf20Sopenharmony_ci	NVBO_WR32(bo, offset, NV_DISP_BASE_NOTIFIER_1, _0,
1948c2ecf20Sopenharmony_ci			NVDEF(NV_DISP_BASE_NOTIFIER_1, _0, STATUS, NOT_BEGUN));
1958c2ecf20Sopenharmony_ci}
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ciint
1988c2ecf20Sopenharmony_cibase507c_sema_clr(struct nv50_wndw *wndw)
1998c2ecf20Sopenharmony_ci{
2008c2ecf20Sopenharmony_ci	struct nvif_push *push = wndw->wndw.push;
2018c2ecf20Sopenharmony_ci	int ret;
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 2)))
2048c2ecf20Sopenharmony_ci		return ret;
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV507C, SET_CONTEXT_DMA_SEMAPHORE, 0x00000000);
2078c2ecf20Sopenharmony_ci	return 0;
2088c2ecf20Sopenharmony_ci}
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_ciint
2118c2ecf20Sopenharmony_cibase507c_sema_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
2128c2ecf20Sopenharmony_ci{
2138c2ecf20Sopenharmony_ci	struct nvif_push *push = wndw->wndw.push;
2148c2ecf20Sopenharmony_ci	int ret;
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 5)))
2178c2ecf20Sopenharmony_ci		return ret;
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV507C, SET_SEMAPHORE_CONTROL, asyw->sema.offset,
2208c2ecf20Sopenharmony_ci				SET_SEMAPHORE_ACQUIRE, asyw->sema.acquire,
2218c2ecf20Sopenharmony_ci				SET_SEMAPHORE_RELEASE, asyw->sema.release,
2228c2ecf20Sopenharmony_ci				SET_CONTEXT_DMA_SEMAPHORE, asyw->sema.handle);
2238c2ecf20Sopenharmony_ci	return 0;
2248c2ecf20Sopenharmony_ci}
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_civoid
2278c2ecf20Sopenharmony_cibase507c_release(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
2288c2ecf20Sopenharmony_ci		 struct nv50_head_atom *asyh)
2298c2ecf20Sopenharmony_ci{
2308c2ecf20Sopenharmony_ci	asyh->base.cpp = 0;
2318c2ecf20Sopenharmony_ci}
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ciint
2348c2ecf20Sopenharmony_cibase507c_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
2358c2ecf20Sopenharmony_ci		 struct nv50_head_atom *asyh)
2368c2ecf20Sopenharmony_ci{
2378c2ecf20Sopenharmony_ci	const struct drm_framebuffer *fb = asyw->state.fb;
2388c2ecf20Sopenharmony_ci	int ret;
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_ci	ret = drm_atomic_helper_check_plane_state(&asyw->state, &asyh->state,
2418c2ecf20Sopenharmony_ci						  DRM_PLANE_HELPER_NO_SCALING,
2428c2ecf20Sopenharmony_ci						  DRM_PLANE_HELPER_NO_SCALING,
2438c2ecf20Sopenharmony_ci						  false, true);
2448c2ecf20Sopenharmony_ci	if (ret)
2458c2ecf20Sopenharmony_ci		return ret;
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ci	if (!wndw->func->ilut) {
2488c2ecf20Sopenharmony_ci		if ((asyh->base.cpp != 1) ^ (fb->format->cpp[0] != 1))
2498c2ecf20Sopenharmony_ci			asyh->state.color_mgmt_changed = true;
2508c2ecf20Sopenharmony_ci	}
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_ci	asyh->base.depth = fb->format->depth;
2538c2ecf20Sopenharmony_ci	asyh->base.cpp = fb->format->cpp[0];
2548c2ecf20Sopenharmony_ci	asyh->base.x = asyw->state.src.x1 >> 16;
2558c2ecf20Sopenharmony_ci	asyh->base.y = asyw->state.src.y1 >> 16;
2568c2ecf20Sopenharmony_ci	asyh->base.w = asyw->state.fb->width;
2578c2ecf20Sopenharmony_ci	asyh->base.h = asyw->state.fb->height;
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci	/* Some newer formats, esp FP16 ones, don't have a
2608c2ecf20Sopenharmony_ci	 * "depth". There's nothing that really makes sense there
2618c2ecf20Sopenharmony_ci	 * either, so just set it to the implicit bit count.
2628c2ecf20Sopenharmony_ci	 */
2638c2ecf20Sopenharmony_ci	if (!asyh->base.depth)
2648c2ecf20Sopenharmony_ci		asyh->base.depth = asyh->base.cpp * 8;
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci	return 0;
2678c2ecf20Sopenharmony_ci}
2688c2ecf20Sopenharmony_ci
2698c2ecf20Sopenharmony_ciconst u32
2708c2ecf20Sopenharmony_cibase507c_format[] = {
2718c2ecf20Sopenharmony_ci	DRM_FORMAT_C8,
2728c2ecf20Sopenharmony_ci	DRM_FORMAT_RGB565,
2738c2ecf20Sopenharmony_ci	DRM_FORMAT_XRGB1555,
2748c2ecf20Sopenharmony_ci	DRM_FORMAT_ARGB1555,
2758c2ecf20Sopenharmony_ci	DRM_FORMAT_XRGB8888,
2768c2ecf20Sopenharmony_ci	DRM_FORMAT_ARGB8888,
2778c2ecf20Sopenharmony_ci	DRM_FORMAT_XBGR2101010,
2788c2ecf20Sopenharmony_ci	DRM_FORMAT_ABGR2101010,
2798c2ecf20Sopenharmony_ci	DRM_FORMAT_XBGR8888,
2808c2ecf20Sopenharmony_ci	DRM_FORMAT_ABGR8888,
2818c2ecf20Sopenharmony_ci	DRM_FORMAT_XBGR16161616F,
2828c2ecf20Sopenharmony_ci	DRM_FORMAT_ABGR16161616F,
2838c2ecf20Sopenharmony_ci	0
2848c2ecf20Sopenharmony_ci};
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_cistatic const struct nv50_wndw_func
2878c2ecf20Sopenharmony_cibase507c = {
2888c2ecf20Sopenharmony_ci	.acquire = base507c_acquire,
2898c2ecf20Sopenharmony_ci	.release = base507c_release,
2908c2ecf20Sopenharmony_ci	.sema_set = base507c_sema_set,
2918c2ecf20Sopenharmony_ci	.sema_clr = base507c_sema_clr,
2928c2ecf20Sopenharmony_ci	.ntfy_reset = base507c_ntfy_reset,
2938c2ecf20Sopenharmony_ci	.ntfy_set = base507c_ntfy_set,
2948c2ecf20Sopenharmony_ci	.ntfy_clr = base507c_ntfy_clr,
2958c2ecf20Sopenharmony_ci	.ntfy_wait_begun = base507c_ntfy_wait_begun,
2968c2ecf20Sopenharmony_ci	.olut_core = 1,
2978c2ecf20Sopenharmony_ci	.xlut_set = base507c_xlut_set,
2988c2ecf20Sopenharmony_ci	.xlut_clr = base507c_xlut_clr,
2998c2ecf20Sopenharmony_ci	.image_set = base507c_image_set,
3008c2ecf20Sopenharmony_ci	.image_clr = base507c_image_clr,
3018c2ecf20Sopenharmony_ci	.update = base507c_update,
3028c2ecf20Sopenharmony_ci};
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_ciint
3058c2ecf20Sopenharmony_cibase507c_new_(const struct nv50_wndw_func *func, const u32 *format,
3068c2ecf20Sopenharmony_ci	      struct nouveau_drm *drm, int head, s32 oclass, u32 interlock_data,
3078c2ecf20Sopenharmony_ci	      struct nv50_wndw **pwndw)
3088c2ecf20Sopenharmony_ci{
3098c2ecf20Sopenharmony_ci	struct nv50_disp_base_channel_dma_v0 args = {
3108c2ecf20Sopenharmony_ci		.head = head,
3118c2ecf20Sopenharmony_ci	};
3128c2ecf20Sopenharmony_ci	struct nouveau_display *disp = nouveau_display(drm->dev);
3138c2ecf20Sopenharmony_ci	struct nv50_disp *disp50 = nv50_disp(drm->dev);
3148c2ecf20Sopenharmony_ci	struct nv50_wndw *wndw;
3158c2ecf20Sopenharmony_ci	int ret;
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_ci	ret = nv50_wndw_new_(func, drm->dev, DRM_PLANE_TYPE_PRIMARY,
3188c2ecf20Sopenharmony_ci			     "base", head, format, BIT(head),
3198c2ecf20Sopenharmony_ci			     NV50_DISP_INTERLOCK_BASE, interlock_data, &wndw);
3208c2ecf20Sopenharmony_ci	if (*pwndw = wndw, ret)
3218c2ecf20Sopenharmony_ci		return ret;
3228c2ecf20Sopenharmony_ci
3238c2ecf20Sopenharmony_ci	ret = nv50_dmac_create(&drm->client.device, &disp->disp.object,
3248c2ecf20Sopenharmony_ci			       &oclass, head, &args, sizeof(args),
3258c2ecf20Sopenharmony_ci			       disp50->sync->offset, &wndw->wndw);
3268c2ecf20Sopenharmony_ci	if (ret) {
3278c2ecf20Sopenharmony_ci		NV_ERROR(drm, "base%04x allocation failed: %d\n", oclass, ret);
3288c2ecf20Sopenharmony_ci		return ret;
3298c2ecf20Sopenharmony_ci	}
3308c2ecf20Sopenharmony_ci
3318c2ecf20Sopenharmony_ci	ret = nvif_notify_ctor(&wndw->wndw.base.user, "kmsBaseNtfy",
3328c2ecf20Sopenharmony_ci			       wndw->notify.func, false,
3338c2ecf20Sopenharmony_ci			       NV50_DISP_BASE_CHANNEL_DMA_V0_NTFY_UEVENT,
3348c2ecf20Sopenharmony_ci			       &(struct nvif_notify_uevent_req) {},
3358c2ecf20Sopenharmony_ci			       sizeof(struct nvif_notify_uevent_req),
3368c2ecf20Sopenharmony_ci			       sizeof(struct nvif_notify_uevent_rep),
3378c2ecf20Sopenharmony_ci			       &wndw->notify);
3388c2ecf20Sopenharmony_ci	if (ret)
3398c2ecf20Sopenharmony_ci		return ret;
3408c2ecf20Sopenharmony_ci
3418c2ecf20Sopenharmony_ci	wndw->ntfy = NV50_DISP_BASE_NTFY(wndw->id);
3428c2ecf20Sopenharmony_ci	wndw->sema = NV50_DISP_BASE_SEM0(wndw->id);
3438c2ecf20Sopenharmony_ci	wndw->data = 0x00000000;
3448c2ecf20Sopenharmony_ci	return 0;
3458c2ecf20Sopenharmony_ci}
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_ciint
3488c2ecf20Sopenharmony_cibase507c_new(struct nouveau_drm *drm, int head, s32 oclass,
3498c2ecf20Sopenharmony_ci	     struct nv50_wndw **pwndw)
3508c2ecf20Sopenharmony_ci{
3518c2ecf20Sopenharmony_ci	return base507c_new_(&base507c, base507c_format, drm, head, oclass,
3528c2ecf20Sopenharmony_ci			     0x00000002 << (head * 8), pwndw);
3538c2ecf20Sopenharmony_ci}
354