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 "ovly.h"
238c2ecf20Sopenharmony_ci#include "atom.h"
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#include <nvif/push507c.h>
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#include <nvhw/class/cl907e.h>
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_cistatic int
308c2ecf20Sopenharmony_ciovly907e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
318c2ecf20Sopenharmony_ci{
328c2ecf20Sopenharmony_ci	struct nvif_push *push = wndw->wndw.push;
338c2ecf20Sopenharmony_ci	int ret;
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci	if ((ret = PUSH_WAIT(push, 12)))
368c2ecf20Sopenharmony_ci		return ret;
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV907E, SET_PRESENT_CONTROL,
398c2ecf20Sopenharmony_ci		  NVDEF(NV907E, SET_PRESENT_CONTROL, BEGIN_MODE, ASAP) |
408c2ecf20Sopenharmony_ci		  NVVAL(NV907E, SET_PRESENT_CONTROL, MIN_PRESENT_INTERVAL, asyw->image.interval));
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV907E, SET_CONTEXT_DMA_ISO, asyw->image.handle[0]);
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV907E, SET_COMPOSITION_CONTROL,
458c2ecf20Sopenharmony_ci		  NVDEF(NV907E, SET_COMPOSITION_CONTROL, MODE, OPAQUE));
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV907E, SURFACE_SET_OFFSET, asyw->image.offset[0] >> 8);
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci	PUSH_MTHD(push, NV907E, SURFACE_SET_SIZE,
508c2ecf20Sopenharmony_ci		  NVVAL(NV907E, SURFACE_SET_SIZE, WIDTH, asyw->image.w) |
518c2ecf20Sopenharmony_ci		  NVVAL(NV907E, SURFACE_SET_SIZE, HEIGHT, asyw->image.h),
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci				SURFACE_SET_STORAGE,
548c2ecf20Sopenharmony_ci		  NVVAL(NV907E, SURFACE_SET_STORAGE, BLOCK_HEIGHT, asyw->image.blockh) |
558c2ecf20Sopenharmony_ci		  NVVAL(NV907E, SURFACE_SET_STORAGE, PITCH, (asyw->image.pitch[0] >> 8)) |
568c2ecf20Sopenharmony_ci		  NVVAL(NV907E, SURFACE_SET_STORAGE, PITCH, asyw->image.blocks[0]) |
578c2ecf20Sopenharmony_ci		  NVVAL(NV907E, SURFACE_SET_STORAGE, MEMORY_LAYOUT, asyw->image.layout),
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci				SURFACE_SET_PARAMS,
608c2ecf20Sopenharmony_ci		  NVVAL(NV907E, SURFACE_SET_PARAMS, FORMAT, asyw->image.format) |
618c2ecf20Sopenharmony_ci		  NVVAL(NV907E, SURFACE_SET_PARAMS, COLOR_SPACE, asyw->image.colorspace));
628c2ecf20Sopenharmony_ci	return 0;
638c2ecf20Sopenharmony_ci}
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ciconst struct nv50_wndw_func
668c2ecf20Sopenharmony_ciovly907e = {
678c2ecf20Sopenharmony_ci	.acquire = ovly507e_acquire,
688c2ecf20Sopenharmony_ci	.release = ovly507e_release,
698c2ecf20Sopenharmony_ci	.ntfy_set = base507c_ntfy_set,
708c2ecf20Sopenharmony_ci	.ntfy_clr = base507c_ntfy_clr,
718c2ecf20Sopenharmony_ci	.ntfy_reset = ovly827e_ntfy_reset,
728c2ecf20Sopenharmony_ci	.ntfy_wait_begun = ovly827e_ntfy_wait_begun,
738c2ecf20Sopenharmony_ci	.image_set = ovly907e_image_set,
748c2ecf20Sopenharmony_ci	.image_clr = base507c_image_clr,
758c2ecf20Sopenharmony_ci	.scale_set = ovly507e_scale_set,
768c2ecf20Sopenharmony_ci	.update = base507c_update,
778c2ecf20Sopenharmony_ci};
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_cistatic const u32
808c2ecf20Sopenharmony_ciovly907e_format[] = {
818c2ecf20Sopenharmony_ci	DRM_FORMAT_YUYV,
828c2ecf20Sopenharmony_ci	DRM_FORMAT_UYVY,
838c2ecf20Sopenharmony_ci	DRM_FORMAT_XRGB8888,
848c2ecf20Sopenharmony_ci	DRM_FORMAT_XRGB1555,
858c2ecf20Sopenharmony_ci	DRM_FORMAT_XBGR2101010,
868c2ecf20Sopenharmony_ci	DRM_FORMAT_XBGR16161616F,
878c2ecf20Sopenharmony_ci	0
888c2ecf20Sopenharmony_ci};
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ciint
918c2ecf20Sopenharmony_ciovly907e_new(struct nouveau_drm *drm, int head, s32 oclass,
928c2ecf20Sopenharmony_ci	     struct nv50_wndw **pwndw)
938c2ecf20Sopenharmony_ci{
948c2ecf20Sopenharmony_ci	return ovly507e_new_(&ovly907e, ovly907e_format, drm, head, oclass,
958c2ecf20Sopenharmony_ci			     0x00000004 << (head * 4), pwndw);
968c2ecf20Sopenharmony_ci}
97