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/push507c.h>
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#include <nvhw/class/cl827c.h>
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_cistatic int
298c2ecf20Sopenharmony_cibase827c_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
308c2ecf20Sopenharmony_ci{
318c2ecf20Sopenharmony_ci	struct nvif_push *push = wndw->wndw.push;
328c2ecf20Sopenharmony_ci	int ret;
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 13)))
358c2ecf20Sopenharmony_ci		return ret;
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV827C, SET_PRESENT_CONTROL,
388c2ecf20Sopenharmony_ci		  NVVAL(NV827C, SET_PRESENT_CONTROL, BEGIN_MODE, asyw->image.mode) |
398c2ecf20Sopenharmony_ci		  NVVAL(NV827C, SET_PRESENT_CONTROL, MIN_PRESENT_INTERVAL, asyw->image.interval));
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV827C, SET_CONTEXT_DMAS_ISO(0), asyw->image.handle, 1);
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci	if (asyw->image.format == NV827C_SURFACE_SET_PARAMS_FORMAT_RF16_GF16_BF16_AF16) {
448c2ecf20Sopenharmony_ci		PUSH_MTHD(push, NV827C, SET_PROCESSING,
458c2ecf20Sopenharmony_ci			  NVDEF(NV827C, SET_PROCESSING, USE_GAIN_OFS, ENABLE),
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci					SET_CONVERSION,
488c2ecf20Sopenharmony_ci			  NVVAL(NV827C, SET_CONVERSION, GAIN, 0) |
498c2ecf20Sopenharmony_ci			  NVVAL(NV827C, SET_CONVERSION, OFS, 0x64));
508c2ecf20Sopenharmony_ci	} else {
518c2ecf20Sopenharmony_ci		PUSH_MTHD(push, NV827C, SET_PROCESSING,
528c2ecf20Sopenharmony_ci			  NVDEF(NV827C, SET_PROCESSING, USE_GAIN_OFS, DISABLE),
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci					SET_CONVERSION,
558c2ecf20Sopenharmony_ci			  NVVAL(NV827C, SET_CONVERSION, GAIN, 0) |
568c2ecf20Sopenharmony_ci			  NVVAL(NV827C, SET_CONVERSION, OFS, 0));
578c2ecf20Sopenharmony_ci	}
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV827C, SURFACE_SET_OFFSET(0, 0), asyw->image.offset[0] >> 8,
608c2ecf20Sopenharmony_ci				SURFACE_SET_OFFSET(0, 1), 0x00000000,
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci				SURFACE_SET_SIZE(0),
638c2ecf20Sopenharmony_ci		  NVVAL(NV827C, SURFACE_SET_SIZE, WIDTH, asyw->image.w) |
648c2ecf20Sopenharmony_ci		  NVVAL(NV827C, SURFACE_SET_SIZE, HEIGHT, asyw->image.h),
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci				SURFACE_SET_STORAGE(0),
678c2ecf20Sopenharmony_ci		  NVVAL(NV827C, SURFACE_SET_STORAGE, BLOCK_HEIGHT, asyw->image.blockh) |
688c2ecf20Sopenharmony_ci		  NVVAL(NV827C, SURFACE_SET_STORAGE, PITCH, asyw->image.pitch[0] >> 8) |
698c2ecf20Sopenharmony_ci		  NVVAL(NV827C, SURFACE_SET_STORAGE, PITCH, asyw->image.blocks[0]) |
708c2ecf20Sopenharmony_ci		  NVVAL(NV827C, SURFACE_SET_STORAGE, MEMORY_LAYOUT, asyw->image.layout),
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci				SURFACE_SET_PARAMS(0),
738c2ecf20Sopenharmony_ci		  NVVAL(NV827C, SURFACE_SET_PARAMS, FORMAT, asyw->image.format) |
748c2ecf20Sopenharmony_ci		  NVDEF(NV827C, SURFACE_SET_PARAMS, SUPER_SAMPLE, X1_AA) |
758c2ecf20Sopenharmony_ci		  NVDEF(NV827C, SURFACE_SET_PARAMS, GAMMA, LINEAR) |
768c2ecf20Sopenharmony_ci		  NVDEF(NV827C, SURFACE_SET_PARAMS, LAYOUT, FRM));
778c2ecf20Sopenharmony_ci	return 0;
788c2ecf20Sopenharmony_ci}
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_cistatic const struct nv50_wndw_func
818c2ecf20Sopenharmony_cibase827c = {
828c2ecf20Sopenharmony_ci	.acquire = base507c_acquire,
838c2ecf20Sopenharmony_ci	.release = base507c_release,
848c2ecf20Sopenharmony_ci	.sema_set = base507c_sema_set,
858c2ecf20Sopenharmony_ci	.sema_clr = base507c_sema_clr,
868c2ecf20Sopenharmony_ci	.ntfy_reset = base507c_ntfy_reset,
878c2ecf20Sopenharmony_ci	.ntfy_set = base507c_ntfy_set,
888c2ecf20Sopenharmony_ci	.ntfy_clr = base507c_ntfy_clr,
898c2ecf20Sopenharmony_ci	.ntfy_wait_begun = base507c_ntfy_wait_begun,
908c2ecf20Sopenharmony_ci	.olut_core = 1,
918c2ecf20Sopenharmony_ci	.xlut_set = base507c_xlut_set,
928c2ecf20Sopenharmony_ci	.xlut_clr = base507c_xlut_clr,
938c2ecf20Sopenharmony_ci	.image_set = base827c_image_set,
948c2ecf20Sopenharmony_ci	.image_clr = base507c_image_clr,
958c2ecf20Sopenharmony_ci	.update = base507c_update,
968c2ecf20Sopenharmony_ci};
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ciint
998c2ecf20Sopenharmony_cibase827c_new(struct nouveau_drm *drm, int head, s32 oclass,
1008c2ecf20Sopenharmony_ci	     struct nv50_wndw **pwndw)
1018c2ecf20Sopenharmony_ci{
1028c2ecf20Sopenharmony_ci	return base507c_new_(&base827c, base507c_format, drm, head, oclass,
1038c2ecf20Sopenharmony_ci			     0x00000002 << (head * 8), pwndw);
1048c2ecf20Sopenharmony_ci}
105