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 "atom.h"
248c2ecf20Sopenharmony_ci#include "core.h"
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#include <nvif/pushc37b.h>
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#include <nvhw/class/clc37d.h>
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_cistatic int
318c2ecf20Sopenharmony_ciheadc37d_or(struct nv50_head *head, struct nv50_head_atom *asyh)
328c2ecf20Sopenharmony_ci{
338c2ecf20Sopenharmony_ci	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
348c2ecf20Sopenharmony_ci	const int i = head->base.index;
358c2ecf20Sopenharmony_ci	u8 depth;
368c2ecf20Sopenharmony_ci	int ret;
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci	/*XXX: This is a dirty hack until OR depth handling is
398c2ecf20Sopenharmony_ci	 *     improved later for deep colour etc.
408c2ecf20Sopenharmony_ci	 */
418c2ecf20Sopenharmony_ci	switch (asyh->or.depth) {
428c2ecf20Sopenharmony_ci	case 6: depth = 5; break;
438c2ecf20Sopenharmony_ci	case 5: depth = 4; break;
448c2ecf20Sopenharmony_ci	case 2: depth = 1; break;
458c2ecf20Sopenharmony_ci	case 0:	depth = 4; break;
468c2ecf20Sopenharmony_ci	default:
478c2ecf20Sopenharmony_ci		depth = asyh->or.depth;
488c2ecf20Sopenharmony_ci		WARN_ON(1);
498c2ecf20Sopenharmony_ci		break;
508c2ecf20Sopenharmony_ci	}
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 2)))
538c2ecf20Sopenharmony_ci		return ret;
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NVC37D, HEAD_SET_CONTROL_OUTPUT_RESOURCE(i),
568c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_CONTROL_OUTPUT_RESOURCE, CRC_MODE, asyh->or.crc_raster) |
578c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_CONTROL_OUTPUT_RESOURCE, HSYNC_POLARITY, asyh->or.nhsync) |
588c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_CONTROL_OUTPUT_RESOURCE, VSYNC_POLARITY, asyh->or.nvsync) |
598c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_CONTROL_OUTPUT_RESOURCE, PIXEL_DEPTH, depth) |
608c2ecf20Sopenharmony_ci		  NVDEF(NVC37D, HEAD_SET_CONTROL_OUTPUT_RESOURCE, COLOR_SPACE_OVERRIDE, DISABLE));
618c2ecf20Sopenharmony_ci	return 0;
628c2ecf20Sopenharmony_ci}
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_cistatic int
658c2ecf20Sopenharmony_ciheadc37d_procamp(struct nv50_head *head, struct nv50_head_atom *asyh)
668c2ecf20Sopenharmony_ci{
678c2ecf20Sopenharmony_ci	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
688c2ecf20Sopenharmony_ci	const int i = head->base.index;
698c2ecf20Sopenharmony_ci	int ret;
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 2)))
728c2ecf20Sopenharmony_ci		return ret;
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NVC37D, HEAD_SET_PROCAMP(i),
758c2ecf20Sopenharmony_ci		  NVDEF(NVC37D, HEAD_SET_PROCAMP, COLOR_SPACE, RGB) |
768c2ecf20Sopenharmony_ci		  NVDEF(NVC37D, HEAD_SET_PROCAMP, CHROMA_LPF, DISABLE) |
778c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_PROCAMP, SAT_COS, asyh->procamp.sat.cos) |
788c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_PROCAMP, SAT_SINE, asyh->procamp.sat.sin) |
798c2ecf20Sopenharmony_ci		  NVDEF(NVC37D, HEAD_SET_PROCAMP, DYNAMIC_RANGE, VESA) |
808c2ecf20Sopenharmony_ci		  NVDEF(NVC37D, HEAD_SET_PROCAMP, RANGE_COMPRESSION, DISABLE) |
818c2ecf20Sopenharmony_ci		  NVDEF(NVC37D, HEAD_SET_PROCAMP, BLACK_LEVEL, GRAPHICS));
828c2ecf20Sopenharmony_ci	return 0;
838c2ecf20Sopenharmony_ci}
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ciint
868c2ecf20Sopenharmony_ciheadc37d_dither(struct nv50_head *head, struct nv50_head_atom *asyh)
878c2ecf20Sopenharmony_ci{
888c2ecf20Sopenharmony_ci	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
898c2ecf20Sopenharmony_ci	const int i = head->base.index;
908c2ecf20Sopenharmony_ci	int ret;
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 2)))
938c2ecf20Sopenharmony_ci		return ret;
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NVC37D, HEAD_SET_DITHER_CONTROL(i),
968c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_DITHER_CONTROL, ENABLE, asyh->dither.enable) |
978c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_DITHER_CONTROL, BITS, asyh->dither.bits) |
988c2ecf20Sopenharmony_ci		  NVDEF(NVC37D, HEAD_SET_DITHER_CONTROL, OFFSET_ENABLE, DISABLE) |
998c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_DITHER_CONTROL, MODE, asyh->dither.mode) |
1008c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_DITHER_CONTROL, PHASE, 0));
1018c2ecf20Sopenharmony_ci	return 0;
1028c2ecf20Sopenharmony_ci}
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ciint
1058c2ecf20Sopenharmony_ciheadc37d_curs_clr(struct nv50_head *head)
1068c2ecf20Sopenharmony_ci{
1078c2ecf20Sopenharmony_ci	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
1088c2ecf20Sopenharmony_ci	const int i = head->base.index;
1098c2ecf20Sopenharmony_ci	int ret;
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 4)))
1128c2ecf20Sopenharmony_ci		return ret;
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NVC37D, HEAD_SET_CONTROL_CURSOR(i),
1158c2ecf20Sopenharmony_ci		  NVDEF(NVC37D, HEAD_SET_CONTROL_CURSOR, ENABLE, DISABLE) |
1168c2ecf20Sopenharmony_ci		  NVDEF(NVC37D, HEAD_SET_CONTROL_CURSOR, FORMAT, A8R8G8B8));
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NVC37D, HEAD_SET_CONTEXT_DMA_CURSOR(i, 0), 0x00000000);
1198c2ecf20Sopenharmony_ci	return 0;
1208c2ecf20Sopenharmony_ci}
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ciint
1238c2ecf20Sopenharmony_ciheadc37d_curs_set(struct nv50_head *head, struct nv50_head_atom *asyh)
1248c2ecf20Sopenharmony_ci{
1258c2ecf20Sopenharmony_ci	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
1268c2ecf20Sopenharmony_ci	const int i = head->base.index;
1278c2ecf20Sopenharmony_ci	int ret;
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 7)))
1308c2ecf20Sopenharmony_ci		return ret;
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NVC37D, HEAD_SET_CONTROL_CURSOR(i),
1338c2ecf20Sopenharmony_ci		  NVDEF(NVC37D, HEAD_SET_CONTROL_CURSOR, ENABLE, ENABLE) |
1348c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_CONTROL_CURSOR, FORMAT, asyh->curs.format) |
1358c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_CONTROL_CURSOR, SIZE, asyh->curs.layout) |
1368c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_CONTROL_CURSOR, HOT_SPOT_X, 0) |
1378c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_CONTROL_CURSOR, HOT_SPOT_Y, 0) |
1388c2ecf20Sopenharmony_ci		  NVDEF(NVC37D, HEAD_SET_CONTROL_CURSOR, DE_GAMMA, NONE),
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci				HEAD_SET_CONTROL_CURSOR_COMPOSITION(i),
1418c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_CONTROL_CURSOR_COMPOSITION, K1, 0xff) |
1428c2ecf20Sopenharmony_ci		  NVDEF(NVC37D, HEAD_SET_CONTROL_CURSOR_COMPOSITION, CURSOR_COLOR_FACTOR_SELECT,
1438c2ecf20Sopenharmony_ci								     K1) |
1448c2ecf20Sopenharmony_ci		  NVDEF(NVC37D, HEAD_SET_CONTROL_CURSOR_COMPOSITION, VIEWPORT_COLOR_FACTOR_SELECT,
1458c2ecf20Sopenharmony_ci								     NEG_K1_TIMES_SRC) |
1468c2ecf20Sopenharmony_ci		  NVDEF(NVC37D, HEAD_SET_CONTROL_CURSOR_COMPOSITION, MODE, BLEND));
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NVC37D, HEAD_SET_CONTEXT_DMA_CURSOR(i, 0), asyh->curs.handle);
1498c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NVC37D, HEAD_SET_OFFSET_CURSOR(i, 0), asyh->curs.offset >> 8);
1508c2ecf20Sopenharmony_ci	return 0;
1518c2ecf20Sopenharmony_ci}
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ciint
1548c2ecf20Sopenharmony_ciheadc37d_curs_format(struct nv50_head *head, struct nv50_wndw_atom *asyw,
1558c2ecf20Sopenharmony_ci		     struct nv50_head_atom *asyh)
1568c2ecf20Sopenharmony_ci{
1578c2ecf20Sopenharmony_ci	asyh->curs.format = asyw->image.format;
1588c2ecf20Sopenharmony_ci	return 0;
1598c2ecf20Sopenharmony_ci}
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_cistatic int
1628c2ecf20Sopenharmony_ciheadc37d_olut_clr(struct nv50_head *head)
1638c2ecf20Sopenharmony_ci{
1648c2ecf20Sopenharmony_ci	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
1658c2ecf20Sopenharmony_ci	const int i = head->base.index;
1668c2ecf20Sopenharmony_ci	int ret;
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 2)))
1698c2ecf20Sopenharmony_ci		return ret;
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NVC37D, HEAD_SET_CONTEXT_DMA_OUTPUT_LUT(i), 0x00000000);
1728c2ecf20Sopenharmony_ci	return 0;
1738c2ecf20Sopenharmony_ci}
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_cistatic int
1768c2ecf20Sopenharmony_ciheadc37d_olut_set(struct nv50_head *head, struct nv50_head_atom *asyh)
1778c2ecf20Sopenharmony_ci{
1788c2ecf20Sopenharmony_ci	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
1798c2ecf20Sopenharmony_ci	const int i = head->base.index;
1808c2ecf20Sopenharmony_ci	int ret;
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 4)))
1838c2ecf20Sopenharmony_ci		return ret;
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NVC37D, HEAD_SET_CONTROL_OUTPUT_LUT(i),
1868c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_CONTROL_OUTPUT_LUT, SIZE, asyh->olut.size) |
1878c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_CONTROL_OUTPUT_LUT, RANGE, asyh->olut.range) |
1888c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_CONTROL_OUTPUT_LUT, OUTPUT_MODE, asyh->olut.output_mode),
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_ci				HEAD_SET_OFFSET_OUTPUT_LUT(i), asyh->olut.offset >> 8,
1918c2ecf20Sopenharmony_ci				HEAD_SET_CONTEXT_DMA_OUTPUT_LUT(i), asyh->olut.handle);
1928c2ecf20Sopenharmony_ci	return 0;
1938c2ecf20Sopenharmony_ci}
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_cistatic bool
1968c2ecf20Sopenharmony_ciheadc37d_olut(struct nv50_head *head, struct nv50_head_atom *asyh, int size)
1978c2ecf20Sopenharmony_ci{
1988c2ecf20Sopenharmony_ci	if (size != 256 && size != 1024)
1998c2ecf20Sopenharmony_ci		return false;
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci	asyh->olut.size = size == 1024 ? NVC37D_HEAD_SET_CONTROL_OUTPUT_LUT_SIZE_SIZE_1025 :
2028c2ecf20Sopenharmony_ci					 NVC37D_HEAD_SET_CONTROL_OUTPUT_LUT_SIZE_SIZE_257;
2038c2ecf20Sopenharmony_ci	asyh->olut.range = NVC37D_HEAD_SET_CONTROL_OUTPUT_LUT_RANGE_UNITY;
2048c2ecf20Sopenharmony_ci	asyh->olut.output_mode = NVC37D_HEAD_SET_CONTROL_OUTPUT_LUT_OUTPUT_MODE_INTERPOLATE;
2058c2ecf20Sopenharmony_ci	asyh->olut.load = head907d_olut_load;
2068c2ecf20Sopenharmony_ci	return true;
2078c2ecf20Sopenharmony_ci}
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_cistatic int
2108c2ecf20Sopenharmony_ciheadc37d_mode(struct nv50_head *head, struct nv50_head_atom *asyh)
2118c2ecf20Sopenharmony_ci{
2128c2ecf20Sopenharmony_ci	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
2138c2ecf20Sopenharmony_ci	struct nv50_head_mode *m = &asyh->mode;
2148c2ecf20Sopenharmony_ci	const int i = head->base.index;
2158c2ecf20Sopenharmony_ci	int ret;
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 15)))
2188c2ecf20Sopenharmony_ci		return ret;
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NVC37D, HEAD_SET_RASTER_SIZE(i),
2218c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_RASTER_SIZE, WIDTH, m->h.active) |
2228c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_RASTER_SIZE, HEIGHT, m->v.active),
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci				HEAD_SET_RASTER_SYNC_END(i),
2258c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_RASTER_SYNC_END, X, m->h.synce) |
2268c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_RASTER_SYNC_END, Y, m->v.synce),
2278c2ecf20Sopenharmony_ci
2288c2ecf20Sopenharmony_ci				HEAD_SET_RASTER_BLANK_END(i),
2298c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_RASTER_BLANK_END, X, m->h.blanke) |
2308c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_RASTER_BLANK_END, Y, m->v.blanke),
2318c2ecf20Sopenharmony_ci
2328c2ecf20Sopenharmony_ci				HEAD_SET_RASTER_BLANK_START(i),
2338c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_RASTER_BLANK_START, X, m->h.blanks) |
2348c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_RASTER_BLANK_START, Y, m->v.blanks));
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_ci	//XXX:
2378c2ecf20Sopenharmony_ci	PUSH_NVSQ(push, NVC37D, 0x2074 + (i * 0x400), m->v.blank2e << 16 | m->v.blank2s);
2388c2ecf20Sopenharmony_ci	PUSH_NVSQ(push, NVC37D, 0x2008 + (i * 0x400), m->interlace);
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NVC37D, HEAD_SET_PIXEL_CLOCK_FREQUENCY(i),
2418c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_PIXEL_CLOCK_FREQUENCY, HERTZ, m->clock * 1000));
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NVC37D, HEAD_SET_PIXEL_CLOCK_FREQUENCY_MAX(i),
2448c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_PIXEL_CLOCK_FREQUENCY_MAX, HERTZ, m->clock * 1000));
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_ci	/*XXX: HEAD_USAGE_BOUNDS, doesn't belong here. */
2478c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NVC37D, HEAD_SET_HEAD_USAGE_BOUNDS(i),
2488c2ecf20Sopenharmony_ci		  NVDEF(NVC37D, HEAD_SET_HEAD_USAGE_BOUNDS, CURSOR, USAGE_W256_H256) |
2498c2ecf20Sopenharmony_ci		  NVDEF(NVC37D, HEAD_SET_HEAD_USAGE_BOUNDS, OUTPUT_LUT, USAGE_1025) |
2508c2ecf20Sopenharmony_ci		  NVDEF(NVC37D, HEAD_SET_HEAD_USAGE_BOUNDS, UPSCALING_ALLOWED, TRUE));
2518c2ecf20Sopenharmony_ci	return 0;
2528c2ecf20Sopenharmony_ci}
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ciint
2558c2ecf20Sopenharmony_ciheadc37d_view(struct nv50_head *head, struct nv50_head_atom *asyh)
2568c2ecf20Sopenharmony_ci{
2578c2ecf20Sopenharmony_ci	struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
2588c2ecf20Sopenharmony_ci	const int i = head->base.index;
2598c2ecf20Sopenharmony_ci	int ret;
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 4)))
2628c2ecf20Sopenharmony_ci		return ret;
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NVC37D, HEAD_SET_VIEWPORT_SIZE_IN(i),
2658c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_VIEWPORT_SIZE_IN, WIDTH, asyh->view.iW) |
2668c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_VIEWPORT_SIZE_IN, HEIGHT, asyh->view.iH));
2678c2ecf20Sopenharmony_ci
2688c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NVC37D, HEAD_SET_VIEWPORT_SIZE_OUT(i),
2698c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_VIEWPORT_SIZE_OUT, WIDTH, asyh->view.oW) |
2708c2ecf20Sopenharmony_ci		  NVVAL(NVC37D, HEAD_SET_VIEWPORT_SIZE_OUT, HEIGHT, asyh->view.oH));
2718c2ecf20Sopenharmony_ci	return 0;
2728c2ecf20Sopenharmony_ci}
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_civoid
2758c2ecf20Sopenharmony_ciheadc37d_static_wndw_map(struct nv50_head *head, struct nv50_head_atom *asyh)
2768c2ecf20Sopenharmony_ci{
2778c2ecf20Sopenharmony_ci	int i, end;
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_ci	for (i = head->base.index * 2, end = i + 2; i < end; i++)
2808c2ecf20Sopenharmony_ci		asyh->wndw.owned |= BIT(i);
2818c2ecf20Sopenharmony_ci}
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_ciconst struct nv50_head_func
2848c2ecf20Sopenharmony_ciheadc37d = {
2858c2ecf20Sopenharmony_ci	.view = headc37d_view,
2868c2ecf20Sopenharmony_ci	.mode = headc37d_mode,
2878c2ecf20Sopenharmony_ci	.olut = headc37d_olut,
2888c2ecf20Sopenharmony_ci	.olut_size = 1024,
2898c2ecf20Sopenharmony_ci	.olut_set = headc37d_olut_set,
2908c2ecf20Sopenharmony_ci	.olut_clr = headc37d_olut_clr,
2918c2ecf20Sopenharmony_ci	.curs_layout = head917d_curs_layout,
2928c2ecf20Sopenharmony_ci	.curs_format = headc37d_curs_format,
2938c2ecf20Sopenharmony_ci	.curs_set = headc37d_curs_set,
2948c2ecf20Sopenharmony_ci	.curs_clr = headc37d_curs_clr,
2958c2ecf20Sopenharmony_ci	.dither = headc37d_dither,
2968c2ecf20Sopenharmony_ci	.procamp = headc37d_procamp,
2978c2ecf20Sopenharmony_ci	.or = headc37d_or,
2988c2ecf20Sopenharmony_ci	.static_wndw_map = headc37d_static_wndw_map,
2998c2ecf20Sopenharmony_ci};
300