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 "head.h"
238c2ecf20Sopenharmony_ci#include "core.h"
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#include <nvif/push507c.h>
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#include <nvhw/class/cl827d.h>
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_cistatic int
308c2ecf20Sopenharmony_cihead827d_curs_clr(struct nv50_head *head)
318c2ecf20Sopenharmony_ci{
328c2ecf20Sopenharmony_ci	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
338c2ecf20Sopenharmony_ci	const int i = head->base.index;
348c2ecf20Sopenharmony_ci	int ret;
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 4)))
378c2ecf20Sopenharmony_ci		return ret;
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV827D, HEAD_SET_CONTROL_CURSOR(i),
408c2ecf20Sopenharmony_ci		  NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, ENABLE, DISABLE) |
418c2ecf20Sopenharmony_ci		  NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, FORMAT, A8R8G8B8) |
428c2ecf20Sopenharmony_ci		  NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, SIZE, W64_H64));
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV827D, HEAD_SET_CONTEXT_DMA_CURSOR(i), 0x00000000);
458c2ecf20Sopenharmony_ci	return 0;
468c2ecf20Sopenharmony_ci}
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_cistatic int
498c2ecf20Sopenharmony_cihead827d_curs_set(struct nv50_head *head, struct nv50_head_atom *asyh)
508c2ecf20Sopenharmony_ci{
518c2ecf20Sopenharmony_ci	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
528c2ecf20Sopenharmony_ci	const int i = head->base.index;
538c2ecf20Sopenharmony_ci	int ret;
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 5)))
568c2ecf20Sopenharmony_ci		return ret;
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV827D, HEAD_SET_CONTROL_CURSOR(i),
598c2ecf20Sopenharmony_ci		  NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, ENABLE, ENABLE) |
608c2ecf20Sopenharmony_ci		  NVVAL(NV827D, HEAD_SET_CONTROL_CURSOR, FORMAT, asyh->curs.format) |
618c2ecf20Sopenharmony_ci		  NVVAL(NV827D, HEAD_SET_CONTROL_CURSOR, SIZE, asyh->curs.layout) |
628c2ecf20Sopenharmony_ci		  NVVAL(NV827D, HEAD_SET_CONTROL_CURSOR, HOT_SPOT_X, 0) |
638c2ecf20Sopenharmony_ci		  NVVAL(NV827D, HEAD_SET_CONTROL_CURSOR, HOT_SPOT_Y, 0) |
648c2ecf20Sopenharmony_ci		  NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, COMPOSITION, ALPHA_BLEND) |
658c2ecf20Sopenharmony_ci		  NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, SUB_OWNER, NONE),
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci				HEAD_SET_OFFSET_CURSOR(i), asyh->curs.offset >> 8);
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV827D, HEAD_SET_CONTEXT_DMA_CURSOR(i), asyh->curs.handle);
708c2ecf20Sopenharmony_ci	return 0;
718c2ecf20Sopenharmony_ci}
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_cistatic int
748c2ecf20Sopenharmony_cihead827d_core_set(struct nv50_head *head, struct nv50_head_atom *asyh)
758c2ecf20Sopenharmony_ci{
768c2ecf20Sopenharmony_ci	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
778c2ecf20Sopenharmony_ci	const int i = head->base.index;
788c2ecf20Sopenharmony_ci	int ret;
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 9)))
818c2ecf20Sopenharmony_ci		return ret;
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV827D, HEAD_SET_OFFSET(i, 0),
848c2ecf20Sopenharmony_ci		  NVVAL(NV827D, HEAD_SET_OFFSET, ORIGIN, asyh->core.offset >> 8));
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV827D, HEAD_SET_SIZE(i),
878c2ecf20Sopenharmony_ci		  NVVAL(NV827D, HEAD_SET_SIZE, WIDTH, asyh->core.w) |
888c2ecf20Sopenharmony_ci		  NVVAL(NV827D, HEAD_SET_SIZE, HEIGHT, asyh->core.h),
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci				HEAD_SET_STORAGE(i),
918c2ecf20Sopenharmony_ci		  NVVAL(NV827D, HEAD_SET_STORAGE, BLOCK_HEIGHT, asyh->core.blockh) |
928c2ecf20Sopenharmony_ci		  NVVAL(NV827D, HEAD_SET_STORAGE, PITCH, asyh->core.pitch >> 8) |
938c2ecf20Sopenharmony_ci		  NVVAL(NV827D, HEAD_SET_STORAGE, PITCH, asyh->core.blocks) |
948c2ecf20Sopenharmony_ci		  NVVAL(NV827D, HEAD_SET_STORAGE, MEMORY_LAYOUT, asyh->core.layout),
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci				HEAD_SET_PARAMS(i),
978c2ecf20Sopenharmony_ci		  NVVAL(NV827D, HEAD_SET_PARAMS, FORMAT, asyh->core.format) |
988c2ecf20Sopenharmony_ci		  NVDEF(NV827D, HEAD_SET_PARAMS, SUPER_SAMPLE, X1_AA) |
998c2ecf20Sopenharmony_ci		  NVDEF(NV827D, HEAD_SET_PARAMS, GAMMA, LINEAR),
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci				HEAD_SET_CONTEXT_DMAS_ISO(i, 0),
1028c2ecf20Sopenharmony_ci		  NVVAL(NV827D, HEAD_SET_CONTEXT_DMAS_ISO, HANDLE, asyh->core.handle));
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV827D, HEAD_SET_VIEWPORT_POINT_IN(i, 0),
1058c2ecf20Sopenharmony_ci		  NVVAL(NV827D, HEAD_SET_VIEWPORT_POINT_IN, X, asyh->core.x) |
1068c2ecf20Sopenharmony_ci		  NVVAL(NV827D, HEAD_SET_VIEWPORT_POINT_IN, Y, asyh->core.y));
1078c2ecf20Sopenharmony_ci	return 0;
1088c2ecf20Sopenharmony_ci}
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_cistatic int
1118c2ecf20Sopenharmony_cihead827d_olut_clr(struct nv50_head *head)
1128c2ecf20Sopenharmony_ci{
1138c2ecf20Sopenharmony_ci	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
1148c2ecf20Sopenharmony_ci	const int i = head->base.index;
1158c2ecf20Sopenharmony_ci	int ret;
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 4)))
1188c2ecf20Sopenharmony_ci		return ret;
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV827D, HEAD_SET_BASE_LUT_LO(i),
1218c2ecf20Sopenharmony_ci		  NVDEF(NV827D, HEAD_SET_BASE_LUT_LO, ENABLE, DISABLE));
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV827D, HEAD_SET_CONTEXT_DMA_LUT(i), 0x00000000);
1248c2ecf20Sopenharmony_ci	return 0;
1258c2ecf20Sopenharmony_ci}
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_cistatic int
1288c2ecf20Sopenharmony_cihead827d_olut_set(struct nv50_head *head, struct nv50_head_atom *asyh)
1298c2ecf20Sopenharmony_ci{
1308c2ecf20Sopenharmony_ci	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
1318c2ecf20Sopenharmony_ci	const int i = head->base.index;
1328c2ecf20Sopenharmony_ci	int ret;
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 5)))
1358c2ecf20Sopenharmony_ci		return ret;
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV827D, HEAD_SET_BASE_LUT_LO(i),
1388c2ecf20Sopenharmony_ci		  NVDEF(NV827D, HEAD_SET_BASE_LUT_LO, ENABLE, ENABLE) |
1398c2ecf20Sopenharmony_ci		  NVVAL(NV827D, HEAD_SET_BASE_LUT_LO, MODE, asyh->olut.mode) |
1408c2ecf20Sopenharmony_ci		  NVVAL(NV827D, HEAD_SET_BASE_LUT_LO, ORIGIN, 0),
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci				HEAD_SET_BASE_LUT_HI(i),
1438c2ecf20Sopenharmony_ci		  NVVAL(NV827D, HEAD_SET_BASE_LUT_HI, ORIGIN, asyh->olut.offset >> 8));
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV827D, HEAD_SET_CONTEXT_DMA_LUT(i), asyh->olut.handle);
1468c2ecf20Sopenharmony_ci	return 0;
1478c2ecf20Sopenharmony_ci}
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_ciconst struct nv50_head_func
1508c2ecf20Sopenharmony_cihead827d = {
1518c2ecf20Sopenharmony_ci	.view = head507d_view,
1528c2ecf20Sopenharmony_ci	.mode = head507d_mode,
1538c2ecf20Sopenharmony_ci	.olut = head507d_olut,
1548c2ecf20Sopenharmony_ci	.olut_size = 256,
1558c2ecf20Sopenharmony_ci	.olut_set = head827d_olut_set,
1568c2ecf20Sopenharmony_ci	.olut_clr = head827d_olut_clr,
1578c2ecf20Sopenharmony_ci	.core_calc = head507d_core_calc,
1588c2ecf20Sopenharmony_ci	.core_set = head827d_core_set,
1598c2ecf20Sopenharmony_ci	.core_clr = head507d_core_clr,
1608c2ecf20Sopenharmony_ci	.curs_layout = head507d_curs_layout,
1618c2ecf20Sopenharmony_ci	.curs_format = head507d_curs_format,
1628c2ecf20Sopenharmony_ci	.curs_set = head827d_curs_set,
1638c2ecf20Sopenharmony_ci	.curs_clr = head827d_curs_clr,
1648c2ecf20Sopenharmony_ci	.base = head507d_base,
1658c2ecf20Sopenharmony_ci	.ovly = head507d_ovly,
1668c2ecf20Sopenharmony_ci	.dither = head507d_dither,
1678c2ecf20Sopenharmony_ci	.procamp = head507d_procamp,
1688c2ecf20Sopenharmony_ci};
169