1ccd27db8SBen Skeggs /*
2ccd27db8SBen Skeggs * Copyright 2018 Red Hat Inc.
3ccd27db8SBen Skeggs *
4ccd27db8SBen Skeggs * Permission is hereby granted, free of charge, to any person obtaining a
5ccd27db8SBen Skeggs * copy of this software and associated documentation files (the "Software"),
6ccd27db8SBen Skeggs * to deal in the Software without restriction, including without limitation
7ccd27db8SBen Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8ccd27db8SBen Skeggs * and/or sell copies of the Software, and to permit persons to whom the
9ccd27db8SBen Skeggs * Software is furnished to do so, subject to the following conditions:
10ccd27db8SBen Skeggs *
11ccd27db8SBen Skeggs * The above copyright notice and this permission notice shall be included in
12ccd27db8SBen Skeggs * all copies or substantial portions of the Software.
13ccd27db8SBen Skeggs *
14ccd27db8SBen Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15ccd27db8SBen Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16ccd27db8SBen Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17ccd27db8SBen Skeggs * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18ccd27db8SBen Skeggs * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19ccd27db8SBen Skeggs * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20ccd27db8SBen Skeggs * OTHER DEALINGS IN THE SOFTWARE.
21ccd27db8SBen Skeggs */
22ccd27db8SBen Skeggs #include "base.h"
23ccd27db8SBen Skeggs
246d6e11e2SBen Skeggs #include <nvif/push507c.h>
256d6e11e2SBen Skeggs
26f844eb48SBen Skeggs #include <nvhw/class/cl827c.h>
27f844eb48SBen Skeggs
286d6e11e2SBen Skeggs static int
base827c_image_set(struct nv50_wndw * wndw,struct nv50_wndw_atom * asyw)29ccd27db8SBen Skeggs base827c_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
30ccd27db8SBen Skeggs {
316d6e11e2SBen Skeggs struct nvif_push *push = wndw->wndw.push;
326d6e11e2SBen Skeggs int ret;
336d6e11e2SBen Skeggs
346d6e11e2SBen Skeggs if ((ret = PUSH_WAIT(push, 13)))
356d6e11e2SBen Skeggs return ret;
366d6e11e2SBen Skeggs
37f844eb48SBen Skeggs PUSH_MTHD(push, NV827C, SET_PRESENT_CONTROL,
38f844eb48SBen Skeggs NVVAL(NV827C, SET_PRESENT_CONTROL, BEGIN_MODE, asyw->image.mode) |
39f844eb48SBen Skeggs NVVAL(NV827C, SET_PRESENT_CONTROL, MIN_PRESENT_INTERVAL, asyw->image.interval));
40f844eb48SBen Skeggs
41f844eb48SBen Skeggs PUSH_MTHD(push, NV827C, SET_CONTEXT_DMAS_ISO(0), asyw->image.handle, 1);
42f844eb48SBen Skeggs
43f844eb48SBen Skeggs if (asyw->image.format == NV827C_SURFACE_SET_PARAMS_FORMAT_RF16_GF16_BF16_AF16) {
44f844eb48SBen Skeggs PUSH_MTHD(push, NV827C, SET_PROCESSING,
45f844eb48SBen Skeggs NVDEF(NV827C, SET_PROCESSING, USE_GAIN_OFS, ENABLE),
46f844eb48SBen Skeggs
47f844eb48SBen Skeggs SET_CONVERSION,
48f844eb48SBen Skeggs NVVAL(NV827C, SET_CONVERSION, GAIN, 0) |
49f844eb48SBen Skeggs NVVAL(NV827C, SET_CONVERSION, OFS, 0x64));
5038a72243SIlia Mirkin } else {
51f844eb48SBen Skeggs PUSH_MTHD(push, NV827C, SET_PROCESSING,
52*fd55b61eSBastian Beranek NVDEF(NV827C, SET_PROCESSING, USE_GAIN_OFS, DISABLE),
53*fd55b61eSBastian Beranek
54*fd55b61eSBastian Beranek SET_CONVERSION,
55*fd55b61eSBastian Beranek NVVAL(NV827C, SET_CONVERSION, GAIN, 0) |
56*fd55b61eSBastian Beranek NVVAL(NV827C, SET_CONVERSION, OFS, 0));
5738a72243SIlia Mirkin }
58f844eb48SBen Skeggs
59f844eb48SBen Skeggs PUSH_MTHD(push, NV827C, SURFACE_SET_OFFSET(0, 0), asyw->image.offset[0] >> 8,
60f844eb48SBen Skeggs SURFACE_SET_OFFSET(0, 1), 0x00000000,
61f844eb48SBen Skeggs
62f844eb48SBen Skeggs SURFACE_SET_SIZE(0),
63f844eb48SBen Skeggs NVVAL(NV827C, SURFACE_SET_SIZE, WIDTH, asyw->image.w) |
64f844eb48SBen Skeggs NVVAL(NV827C, SURFACE_SET_SIZE, HEIGHT, asyw->image.h),
65f844eb48SBen Skeggs
66f844eb48SBen Skeggs SURFACE_SET_STORAGE(0),
67f844eb48SBen Skeggs NVVAL(NV827C, SURFACE_SET_STORAGE, BLOCK_HEIGHT, asyw->image.blockh) |
68f844eb48SBen Skeggs NVVAL(NV827C, SURFACE_SET_STORAGE, PITCH, asyw->image.pitch[0] >> 8) |
69f844eb48SBen Skeggs NVVAL(NV827C, SURFACE_SET_STORAGE, PITCH, asyw->image.blocks[0]) |
70f844eb48SBen Skeggs NVVAL(NV827C, SURFACE_SET_STORAGE, MEMORY_LAYOUT, asyw->image.layout),
71f844eb48SBen Skeggs
72f844eb48SBen Skeggs SURFACE_SET_PARAMS(0),
73f844eb48SBen Skeggs NVVAL(NV827C, SURFACE_SET_PARAMS, FORMAT, asyw->image.format) |
74f844eb48SBen Skeggs NVDEF(NV827C, SURFACE_SET_PARAMS, SUPER_SAMPLE, X1_AA) |
75f844eb48SBen Skeggs NVDEF(NV827C, SURFACE_SET_PARAMS, GAMMA, LINEAR) |
76f844eb48SBen Skeggs NVDEF(NV827C, SURFACE_SET_PARAMS, LAYOUT, FRM));
776d6e11e2SBen Skeggs return 0;
78ccd27db8SBen Skeggs }
79ccd27db8SBen Skeggs
80ccd27db8SBen Skeggs static const struct nv50_wndw_func
81ccd27db8SBen Skeggs base827c = {
82ccd27db8SBen Skeggs .acquire = base507c_acquire,
83ccd27db8SBen Skeggs .release = base507c_release,
84ccd27db8SBen Skeggs .sema_set = base507c_sema_set,
85ccd27db8SBen Skeggs .sema_clr = base507c_sema_clr,
86ccd27db8SBen Skeggs .ntfy_reset = base507c_ntfy_reset,
87ccd27db8SBen Skeggs .ntfy_set = base507c_ntfy_set,
88ccd27db8SBen Skeggs .ntfy_clr = base507c_ntfy_clr,
89ccd27db8SBen Skeggs .ntfy_wait_begun = base507c_ntfy_wait_begun,
90119608a7SBen Skeggs .olut_core = 1,
91119608a7SBen Skeggs .xlut_set = base507c_xlut_set,
92119608a7SBen Skeggs .xlut_clr = base507c_xlut_clr,
93ccd27db8SBen Skeggs .image_set = base827c_image_set,
94ccd27db8SBen Skeggs .image_clr = base507c_image_clr,
95ccd27db8SBen Skeggs .update = base507c_update,
96ccd27db8SBen Skeggs };
97ccd27db8SBen Skeggs
98ccd27db8SBen Skeggs int
base827c_new(struct nouveau_drm * drm,int head,s32 oclass,struct nv50_wndw ** pwndw)99ccd27db8SBen Skeggs base827c_new(struct nouveau_drm *drm, int head, s32 oclass,
100ccd27db8SBen Skeggs struct nv50_wndw **pwndw)
101ccd27db8SBen Skeggs {
10253e0a3e7SBen Skeggs return base507c_new_(&base827c, base507c_format, drm, head, oclass,
10353e0a3e7SBen Skeggs 0x00000002 << (head * 8), pwndw);
104ccd27db8SBen Skeggs }
105