2 * Copyright 2018 Red Hat Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
26 head507d_procamp(struct nv50_head
*head
, struct nv50_head_atom
*asyh
)
28 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
30 if ((push
= evo_wait(core
, 2))) {
31 evo_mthd(push
, 0x08a8 + (head
->base
.index
* 0x400), 1);
32 evo_data(push
, asyh
->procamp
.sat
.sin
<< 20 |
33 asyh
->procamp
.sat
.cos
<< 8);
39 head507d_dither(struct nv50_head
*head
, struct nv50_head_atom
*asyh
)
41 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
43 if ((push
= evo_wait(core
, 2))) {
44 evo_mthd(push
, 0x08a0 + (head
->base
.index
* 0x0400), 1);
45 evo_data(push
, asyh
->dither
.mode
<< 3 |
46 asyh
->dither
.bits
<< 1 |
53 head507d_ovly(struct nv50_head
*head
, struct nv50_head_atom
*asyh
)
55 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
60 switch (asyh
->ovly
.cpp
) {
61 case 4: bounds
|= 0x00000300; break;
62 case 2: bounds
|= 0x00000100; break;
72 if ((push
= evo_wait(core
, 2))) {
73 evo_mthd(push
, 0x0904 + head
->base
.index
* 0x400, 1);
74 evo_data(push
, bounds
);
80 head507d_base(struct nv50_head
*head
, struct nv50_head_atom
*asyh
)
82 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
87 switch (asyh
->base
.cpp
) {
88 case 8: bounds
|= 0x00000500; break;
89 case 4: bounds
|= 0x00000300; break;
90 case 2: bounds
|= 0x00000100; break;
91 case 1: bounds
|= 0x00000000; break;
99 if ((push
= evo_wait(core
, 2))) {
100 evo_mthd(push
, 0x0900 + head
->base
.index
* 0x400, 1);
101 evo_data(push
, bounds
);
102 evo_kick(push
, core
);
107 head507d_curs_clr(struct nv50_head
*head
)
109 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
111 if ((push
= evo_wait(core
, 2))) {
112 evo_mthd(push
, 0x0880 + head
->base
.index
* 0x400, 1);
113 evo_data(push
, 0x05000000);
114 evo_kick(push
, core
);
119 head507d_curs_set(struct nv50_head
*head
, struct nv50_head_atom
*asyh
)
121 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
123 if ((push
= evo_wait(core
, 3))) {
124 evo_mthd(push
, 0x0880 + head
->base
.index
* 0x400, 2);
125 evo_data(push
, 0x80000000 | asyh
->curs
.layout
<< 26 |
126 asyh
->curs
.format
<< 24);
127 evo_data(push
, asyh
->curs
.offset
>> 8);
128 evo_kick(push
, core
);
133 head507d_curs_format(struct nv50_head
*head
, struct nv50_wndw_atom
*asyw
,
134 struct nv50_head_atom
*asyh
)
136 switch (asyw
->image
.format
) {
137 case 0xcf: asyh
->curs
.format
= 1; break;
146 head507d_curs_layout(struct nv50_head
*head
, struct nv50_wndw_atom
*asyw
,
147 struct nv50_head_atom
*asyh
)
149 switch (asyw
->image
.w
) {
150 case 32: asyh
->curs
.layout
= 0; break;
151 case 64: asyh
->curs
.layout
= 1; break;
159 head507d_core_clr(struct nv50_head
*head
)
161 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
163 if ((push
= evo_wait(core
, 2))) {
164 evo_mthd(push
, 0x0874 + head
->base
.index
* 0x400, 1);
165 evo_data(push
, 0x00000000);
166 evo_kick(push
, core
);
171 head507d_core_set(struct nv50_head
*head
, struct nv50_head_atom
*asyh
)
173 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
175 if ((push
= evo_wait(core
, 9))) {
176 evo_mthd(push
, 0x0860 + head
->base
.index
* 0x400, 1);
177 evo_data(push
, asyh
->core
.offset
>> 8);
178 evo_mthd(push
, 0x0868 + head
->base
.index
* 0x400, 4);
179 evo_data(push
, asyh
->core
.h
<< 16 | asyh
->core
.w
);
180 evo_data(push
, asyh
->core
.layout
<< 20 |
181 (asyh
->core
.pitch
>> 8) << 8 |
182 asyh
->core
.blocks
<< 8 |
184 evo_data(push
, asyh
->core
.kind
<< 16 |
185 asyh
->core
.format
<< 8);
186 evo_data(push
, asyh
->core
.handle
);
187 evo_mthd(push
, 0x08c0 + head
->base
.index
* 0x400, 1);
188 evo_data(push
, asyh
->core
.y
<< 16 | asyh
->core
.x
);
189 evo_kick(push
, core
);
191 /* EVO will complain with INVALID_STATE if we have an
192 * active cursor and (re)specify HeadSetContextDmaIso
193 * without also updating HeadSetOffsetCursor.
195 asyh
->set
.curs
= asyh
->curs
.visible
;
196 asyh
->set
.olut
= asyh
->olut
.handle
!= 0;
201 head507d_core_calc(struct nv50_head
*head
, struct nv50_head_atom
*asyh
)
203 struct nv50_disp
*disp
= nv50_disp(head
->base
.base
.dev
);
204 if ((asyh
->core
.visible
= (asyh
->base
.cpp
!= 0))) {
205 asyh
->core
.x
= asyh
->base
.x
;
206 asyh
->core
.y
= asyh
->base
.y
;
207 asyh
->core
.w
= asyh
->base
.w
;
208 asyh
->core
.h
= asyh
->base
.h
;
210 if ((asyh
->core
.visible
= (asyh
->ovly
.cpp
!= 0)) ||
211 (asyh
->core
.visible
= asyh
->curs
.visible
)) {
212 /*XXX: We need to either find some way of having the
213 * primary base layer appear black, while still
214 * being able to display the other layers, or we
215 * need to allocate a dummy black surface here.
219 asyh
->core
.w
= asyh
->state
.mode
.hdisplay
;
220 asyh
->core
.h
= asyh
->state
.mode
.vdisplay
;
222 asyh
->core
.handle
= disp
->core
->chan
.vram
.handle
;
223 asyh
->core
.offset
= 0;
224 asyh
->core
.format
= 0xcf;
226 asyh
->core
.layout
= 1;
227 asyh
->core
.blockh
= 0;
228 asyh
->core
.blocks
= 0;
229 asyh
->core
.pitch
= ALIGN(asyh
->core
.w
, 64) * 4;
233 head507d_olut_clr(struct nv50_head
*head
)
235 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
237 if ((push
= evo_wait(core
, 2))) {
238 evo_mthd(push
, 0x0840 + (head
->base
.index
* 0x400), 1);
239 evo_data(push
, 0x00000000);
240 evo_kick(push
, core
);
245 head507d_olut_set(struct nv50_head
*head
, struct nv50_head_atom
*asyh
)
247 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
249 if ((push
= evo_wait(core
, 3))) {
250 evo_mthd(push
, 0x0840 + (head
->base
.index
* 0x400), 2);
251 evo_data(push
, 0x80000000 | asyh
->olut
.mode
<< 30);
252 evo_data(push
, asyh
->olut
.offset
>> 8);
253 evo_kick(push
, core
);
258 head507d_olut(struct nv50_head
*head
, struct nv50_head_atom
*asyh
)
260 if (asyh
->base
.cpp
== 1)
267 head507d_mode(struct nv50_head
*head
, struct nv50_head_atom
*asyh
)
269 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
270 struct nv50_head_mode
*m
= &asyh
->mode
;
272 if ((push
= evo_wait(core
, 13))) {
273 evo_mthd(push
, 0x0804 + (head
->base
.index
* 0x400), 2);
274 evo_data(push
, 0x00800000 | m
->clock
);
275 evo_data(push
, m
->interlace
? 0x00000002 : 0x00000000);
276 evo_mthd(push
, 0x0810 + (head
->base
.index
* 0x400), 7);
277 evo_data(push
, 0x00000000);
278 evo_data(push
, m
->v
.active
<< 16 | m
->h
.active
);
279 evo_data(push
, m
->v
.synce
<< 16 | m
->h
.synce
);
280 evo_data(push
, m
->v
.blanke
<< 16 | m
->h
.blanke
);
281 evo_data(push
, m
->v
.blanks
<< 16 | m
->h
.blanks
);
282 evo_data(push
, m
->v
.blank2e
<< 16 | m
->v
.blank2s
);
283 evo_data(push
, asyh
->mode
.v
.blankus
);
284 evo_mthd(push
, 0x082c + (head
->base
.index
* 0x400), 1);
285 evo_data(push
, 0x00000000);
286 evo_kick(push
, core
);
291 head507d_view(struct nv50_head
*head
, struct nv50_head_atom
*asyh
)
293 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
295 if ((push
= evo_wait(core
, 7))) {
296 evo_mthd(push
, 0x08a4 + (head
->base
.index
* 0x400), 1);
297 evo_data(push
, 0x00000000);
298 evo_mthd(push
, 0x08c8 + (head
->base
.index
* 0x400), 1);
299 evo_data(push
, asyh
->view
.iH
<< 16 | asyh
->view
.iW
);
300 evo_mthd(push
, 0x08d8 + (head
->base
.index
* 0x400), 2);
301 evo_data(push
, asyh
->view
.oH
<< 16 | asyh
->view
.oW
);
302 evo_data(push
, asyh
->view
.oH
<< 16 | asyh
->view
.oW
);
303 evo_kick(push
, core
);
307 const struct nv50_head_func
309 .view
= head507d_view
,
310 .mode
= head507d_mode
,
311 .olut
= head507d_olut
,
312 .olut_set
= head507d_olut_set
,
313 .olut_clr
= head507d_olut_clr
,
314 .core_calc
= head507d_core_calc
,
315 .core_set
= head507d_core_set
,
316 .core_clr
= head507d_core_clr
,
317 .curs_layout
= head507d_curs_layout
,
318 .curs_format
= head507d_curs_format
,
319 .curs_set
= head507d_curs_set
,
320 .curs_clr
= head507d_curs_clr
,
321 .base
= head507d_base
,
322 .ovly
= head507d_ovly
,
323 .dither
= head507d_dither
,
324 .procamp
= head507d_procamp
,