1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * Copyright 2018 Red Hat Inc.
3*4882a593Smuzhiyun *
4*4882a593Smuzhiyun * Permission is hereby granted, free of charge, to any person obtaining a
5*4882a593Smuzhiyun * copy of this software and associated documentation files (the "Software"),
6*4882a593Smuzhiyun * to deal in the Software without restriction, including without limitation
7*4882a593Smuzhiyun * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*4882a593Smuzhiyun * and/or sell copies of the Software, and to permit persons to whom the
9*4882a593Smuzhiyun * Software is furnished to do so, subject to the following conditions:
10*4882a593Smuzhiyun *
11*4882a593Smuzhiyun * The above copyright notice and this permission notice shall be included in
12*4882a593Smuzhiyun * all copies or substantial portions of the Software.
13*4882a593Smuzhiyun *
14*4882a593Smuzhiyun * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*4882a593Smuzhiyun * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*4882a593Smuzhiyun * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17*4882a593Smuzhiyun * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18*4882a593Smuzhiyun * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19*4882a593Smuzhiyun * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20*4882a593Smuzhiyun * OTHER DEALINGS IN THE SOFTWARE.
21*4882a593Smuzhiyun */
22*4882a593Smuzhiyun #include "head.h"
23*4882a593Smuzhiyun #include "core.h"
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun #include <nvif/push507c.h>
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun #include <nvhw/class/cl827d.h>
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun static int
head827d_curs_clr(struct nv50_head * head)30*4882a593Smuzhiyun head827d_curs_clr(struct nv50_head *head)
31*4882a593Smuzhiyun {
32*4882a593Smuzhiyun struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
33*4882a593Smuzhiyun const int i = head->base.index;
34*4882a593Smuzhiyun int ret;
35*4882a593Smuzhiyun
36*4882a593Smuzhiyun if ((ret = PUSH_WAIT(push, 4)))
37*4882a593Smuzhiyun return ret;
38*4882a593Smuzhiyun
39*4882a593Smuzhiyun PUSH_MTHD(push, NV827D, HEAD_SET_CONTROL_CURSOR(i),
40*4882a593Smuzhiyun NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, ENABLE, DISABLE) |
41*4882a593Smuzhiyun NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, FORMAT, A8R8G8B8) |
42*4882a593Smuzhiyun NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, SIZE, W64_H64));
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun PUSH_MTHD(push, NV827D, HEAD_SET_CONTEXT_DMA_CURSOR(i), 0x00000000);
45*4882a593Smuzhiyun return 0;
46*4882a593Smuzhiyun }
47*4882a593Smuzhiyun
48*4882a593Smuzhiyun static int
head827d_curs_set(struct nv50_head * head,struct nv50_head_atom * asyh)49*4882a593Smuzhiyun head827d_curs_set(struct nv50_head *head, struct nv50_head_atom *asyh)
50*4882a593Smuzhiyun {
51*4882a593Smuzhiyun struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
52*4882a593Smuzhiyun const int i = head->base.index;
53*4882a593Smuzhiyun int ret;
54*4882a593Smuzhiyun
55*4882a593Smuzhiyun if ((ret = PUSH_WAIT(push, 5)))
56*4882a593Smuzhiyun return ret;
57*4882a593Smuzhiyun
58*4882a593Smuzhiyun PUSH_MTHD(push, NV827D, HEAD_SET_CONTROL_CURSOR(i),
59*4882a593Smuzhiyun NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, ENABLE, ENABLE) |
60*4882a593Smuzhiyun NVVAL(NV827D, HEAD_SET_CONTROL_CURSOR, FORMAT, asyh->curs.format) |
61*4882a593Smuzhiyun NVVAL(NV827D, HEAD_SET_CONTROL_CURSOR, SIZE, asyh->curs.layout) |
62*4882a593Smuzhiyun NVVAL(NV827D, HEAD_SET_CONTROL_CURSOR, HOT_SPOT_X, 0) |
63*4882a593Smuzhiyun NVVAL(NV827D, HEAD_SET_CONTROL_CURSOR, HOT_SPOT_Y, 0) |
64*4882a593Smuzhiyun NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, COMPOSITION, ALPHA_BLEND) |
65*4882a593Smuzhiyun NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, SUB_OWNER, NONE),
66*4882a593Smuzhiyun
67*4882a593Smuzhiyun HEAD_SET_OFFSET_CURSOR(i), asyh->curs.offset >> 8);
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun PUSH_MTHD(push, NV827D, HEAD_SET_CONTEXT_DMA_CURSOR(i), asyh->curs.handle);
70*4882a593Smuzhiyun return 0;
71*4882a593Smuzhiyun }
72*4882a593Smuzhiyun
73*4882a593Smuzhiyun static int
head827d_core_set(struct nv50_head * head,struct nv50_head_atom * asyh)74*4882a593Smuzhiyun head827d_core_set(struct nv50_head *head, struct nv50_head_atom *asyh)
75*4882a593Smuzhiyun {
76*4882a593Smuzhiyun struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
77*4882a593Smuzhiyun const int i = head->base.index;
78*4882a593Smuzhiyun int ret;
79*4882a593Smuzhiyun
80*4882a593Smuzhiyun if ((ret = PUSH_WAIT(push, 9)))
81*4882a593Smuzhiyun return ret;
82*4882a593Smuzhiyun
83*4882a593Smuzhiyun PUSH_MTHD(push, NV827D, HEAD_SET_OFFSET(i, 0),
84*4882a593Smuzhiyun NVVAL(NV827D, HEAD_SET_OFFSET, ORIGIN, asyh->core.offset >> 8));
85*4882a593Smuzhiyun
86*4882a593Smuzhiyun PUSH_MTHD(push, NV827D, HEAD_SET_SIZE(i),
87*4882a593Smuzhiyun NVVAL(NV827D, HEAD_SET_SIZE, WIDTH, asyh->core.w) |
88*4882a593Smuzhiyun NVVAL(NV827D, HEAD_SET_SIZE, HEIGHT, asyh->core.h),
89*4882a593Smuzhiyun
90*4882a593Smuzhiyun HEAD_SET_STORAGE(i),
91*4882a593Smuzhiyun NVVAL(NV827D, HEAD_SET_STORAGE, BLOCK_HEIGHT, asyh->core.blockh) |
92*4882a593Smuzhiyun NVVAL(NV827D, HEAD_SET_STORAGE, PITCH, asyh->core.pitch >> 8) |
93*4882a593Smuzhiyun NVVAL(NV827D, HEAD_SET_STORAGE, PITCH, asyh->core.blocks) |
94*4882a593Smuzhiyun NVVAL(NV827D, HEAD_SET_STORAGE, MEMORY_LAYOUT, asyh->core.layout),
95*4882a593Smuzhiyun
96*4882a593Smuzhiyun HEAD_SET_PARAMS(i),
97*4882a593Smuzhiyun NVVAL(NV827D, HEAD_SET_PARAMS, FORMAT, asyh->core.format) |
98*4882a593Smuzhiyun NVDEF(NV827D, HEAD_SET_PARAMS, SUPER_SAMPLE, X1_AA) |
99*4882a593Smuzhiyun NVDEF(NV827D, HEAD_SET_PARAMS, GAMMA, LINEAR),
100*4882a593Smuzhiyun
101*4882a593Smuzhiyun HEAD_SET_CONTEXT_DMAS_ISO(i, 0),
102*4882a593Smuzhiyun NVVAL(NV827D, HEAD_SET_CONTEXT_DMAS_ISO, HANDLE, asyh->core.handle));
103*4882a593Smuzhiyun
104*4882a593Smuzhiyun PUSH_MTHD(push, NV827D, HEAD_SET_VIEWPORT_POINT_IN(i, 0),
105*4882a593Smuzhiyun NVVAL(NV827D, HEAD_SET_VIEWPORT_POINT_IN, X, asyh->core.x) |
106*4882a593Smuzhiyun NVVAL(NV827D, HEAD_SET_VIEWPORT_POINT_IN, Y, asyh->core.y));
107*4882a593Smuzhiyun return 0;
108*4882a593Smuzhiyun }
109*4882a593Smuzhiyun
110*4882a593Smuzhiyun static int
head827d_olut_clr(struct nv50_head * head)111*4882a593Smuzhiyun head827d_olut_clr(struct nv50_head *head)
112*4882a593Smuzhiyun {
113*4882a593Smuzhiyun struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
114*4882a593Smuzhiyun const int i = head->base.index;
115*4882a593Smuzhiyun int ret;
116*4882a593Smuzhiyun
117*4882a593Smuzhiyun if ((ret = PUSH_WAIT(push, 4)))
118*4882a593Smuzhiyun return ret;
119*4882a593Smuzhiyun
120*4882a593Smuzhiyun PUSH_MTHD(push, NV827D, HEAD_SET_BASE_LUT_LO(i),
121*4882a593Smuzhiyun NVDEF(NV827D, HEAD_SET_BASE_LUT_LO, ENABLE, DISABLE));
122*4882a593Smuzhiyun
123*4882a593Smuzhiyun PUSH_MTHD(push, NV827D, HEAD_SET_CONTEXT_DMA_LUT(i), 0x00000000);
124*4882a593Smuzhiyun return 0;
125*4882a593Smuzhiyun }
126*4882a593Smuzhiyun
127*4882a593Smuzhiyun static int
head827d_olut_set(struct nv50_head * head,struct nv50_head_atom * asyh)128*4882a593Smuzhiyun head827d_olut_set(struct nv50_head *head, struct nv50_head_atom *asyh)
129*4882a593Smuzhiyun {
130*4882a593Smuzhiyun struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
131*4882a593Smuzhiyun const int i = head->base.index;
132*4882a593Smuzhiyun int ret;
133*4882a593Smuzhiyun
134*4882a593Smuzhiyun if ((ret = PUSH_WAIT(push, 5)))
135*4882a593Smuzhiyun return ret;
136*4882a593Smuzhiyun
137*4882a593Smuzhiyun PUSH_MTHD(push, NV827D, HEAD_SET_BASE_LUT_LO(i),
138*4882a593Smuzhiyun NVDEF(NV827D, HEAD_SET_BASE_LUT_LO, ENABLE, ENABLE) |
139*4882a593Smuzhiyun NVVAL(NV827D, HEAD_SET_BASE_LUT_LO, MODE, asyh->olut.mode) |
140*4882a593Smuzhiyun NVVAL(NV827D, HEAD_SET_BASE_LUT_LO, ORIGIN, 0),
141*4882a593Smuzhiyun
142*4882a593Smuzhiyun HEAD_SET_BASE_LUT_HI(i),
143*4882a593Smuzhiyun NVVAL(NV827D, HEAD_SET_BASE_LUT_HI, ORIGIN, asyh->olut.offset >> 8));
144*4882a593Smuzhiyun
145*4882a593Smuzhiyun PUSH_MTHD(push, NV827D, HEAD_SET_CONTEXT_DMA_LUT(i), asyh->olut.handle);
146*4882a593Smuzhiyun return 0;
147*4882a593Smuzhiyun }
148*4882a593Smuzhiyun
149*4882a593Smuzhiyun const struct nv50_head_func
150*4882a593Smuzhiyun head827d = {
151*4882a593Smuzhiyun .view = head507d_view,
152*4882a593Smuzhiyun .mode = head507d_mode,
153*4882a593Smuzhiyun .olut = head507d_olut,
154*4882a593Smuzhiyun .olut_size = 256,
155*4882a593Smuzhiyun .olut_set = head827d_olut_set,
156*4882a593Smuzhiyun .olut_clr = head827d_olut_clr,
157*4882a593Smuzhiyun .core_calc = head507d_core_calc,
158*4882a593Smuzhiyun .core_set = head827d_core_set,
159*4882a593Smuzhiyun .core_clr = head507d_core_clr,
160*4882a593Smuzhiyun .curs_layout = head507d_curs_layout,
161*4882a593Smuzhiyun .curs_format = head507d_curs_format,
162*4882a593Smuzhiyun .curs_set = head827d_curs_set,
163*4882a593Smuzhiyun .curs_clr = head827d_curs_clr,
164*4882a593Smuzhiyun .base = head507d_base,
165*4882a593Smuzhiyun .ovly = head507d_ovly,
166*4882a593Smuzhiyun .dither = head507d_dither,
167*4882a593Smuzhiyun .procamp = head507d_procamp,
168*4882a593Smuzhiyun };
169