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 head907d_or(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
, 3))) {
31 evo_mthd(push
, 0x0404 + (head
->base
.index
* 0x300), 2);
32 evo_data(push
, 0x00000001 | asyh
->or.depth
<< 6 |
33 asyh
->or.nvsync
<< 4 |
34 asyh
->or.nhsync
<< 3);
35 evo_data(push
, 0x31ec6000 | head
->base
.index
<< 25 |
36 asyh
->mode
.interlace
);
42 head907d_procamp(struct nv50_head
*head
, struct nv50_head_atom
*asyh
)
44 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
46 if ((push
= evo_wait(core
, 2))) {
47 evo_mthd(push
, 0x0498 + (head
->base
.index
* 0x300), 1);
48 evo_data(push
, asyh
->procamp
.sat
.sin
<< 20 |
49 asyh
->procamp
.sat
.cos
<< 8);
55 head907d_dither(struct nv50_head
*head
, struct nv50_head_atom
*asyh
)
57 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
59 if ((push
= evo_wait(core
, 2))) {
60 evo_mthd(push
, 0x0490 + (head
->base
.index
* 0x0300), 1);
61 evo_data(push
, asyh
->dither
.mode
<< 3 |
62 asyh
->dither
.bits
<< 1 |
69 head907d_ovly(struct nv50_head
*head
, struct nv50_head_atom
*asyh
)
71 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
76 switch (asyh
->ovly
.cpp
) {
77 case 8: bounds
|= 0x00000500; break;
78 case 4: bounds
|= 0x00000300; break;
79 case 2: bounds
|= 0x00000100; break;
89 if ((push
= evo_wait(core
, 2))) {
90 evo_mthd(push
, 0x04d4 + head
->base
.index
* 0x300, 1);
91 evo_data(push
, bounds
);
97 head907d_base(struct nv50_head
*head
, struct nv50_head_atom
*asyh
)
99 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
103 if (asyh
->base
.cpp
) {
104 switch (asyh
->base
.cpp
) {
105 case 8: bounds
|= 0x00000500; break;
106 case 4: bounds
|= 0x00000300; break;
107 case 2: bounds
|= 0x00000100; break;
108 case 1: bounds
|= 0x00000000; break;
113 bounds
|= 0x00000001;
116 if ((push
= evo_wait(core
, 2))) {
117 evo_mthd(push
, 0x04d0 + head
->base
.index
* 0x300, 1);
118 evo_data(push
, bounds
);
119 evo_kick(push
, core
);
124 head907d_curs_clr(struct nv50_head
*head
)
126 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
128 if ((push
= evo_wait(core
, 4))) {
129 evo_mthd(push
, 0x0480 + head
->base
.index
* 0x300, 1);
130 evo_data(push
, 0x05000000);
131 evo_mthd(push
, 0x048c + head
->base
.index
* 0x300, 1);
132 evo_data(push
, 0x00000000);
133 evo_kick(push
, core
);
138 head907d_curs_set(struct nv50_head
*head
, struct nv50_head_atom
*asyh
)
140 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
142 if ((push
= evo_wait(core
, 5))) {
143 evo_mthd(push
, 0x0480 + head
->base
.index
* 0x300, 2);
144 evo_data(push
, 0x80000000 | asyh
->curs
.layout
<< 26 |
145 asyh
->curs
.format
<< 24);
146 evo_data(push
, asyh
->curs
.offset
>> 8);
147 evo_mthd(push
, 0x048c + head
->base
.index
* 0x300, 1);
148 evo_data(push
, asyh
->curs
.handle
);
149 evo_kick(push
, core
);
154 head907d_core_clr(struct nv50_head
*head
)
156 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
158 if ((push
= evo_wait(core
, 2))) {
159 evo_mthd(push
, 0x0474 + head
->base
.index
* 0x300, 1);
160 evo_data(push
, 0x00000000);
161 evo_kick(push
, core
);
166 head907d_core_set(struct nv50_head
*head
, struct nv50_head_atom
*asyh
)
168 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
170 if ((push
= evo_wait(core
, 9))) {
171 evo_mthd(push
, 0x0460 + head
->base
.index
* 0x300, 1);
172 evo_data(push
, asyh
->core
.offset
>> 8);
173 evo_mthd(push
, 0x0468 + head
->base
.index
* 0x300, 4);
174 evo_data(push
, asyh
->core
.h
<< 16 | asyh
->core
.w
);
175 evo_data(push
, asyh
->core
.layout
<< 24 |
176 (asyh
->core
.pitch
>> 8) << 8 |
177 asyh
->core
.blocks
<< 8 |
179 evo_data(push
, asyh
->core
.format
<< 8);
180 evo_data(push
, asyh
->core
.handle
);
181 evo_mthd(push
, 0x04b0 + head
->base
.index
* 0x300, 1);
182 evo_data(push
, asyh
->core
.y
<< 16 | asyh
->core
.x
);
183 evo_kick(push
, core
);
188 head907d_olut_clr(struct nv50_head
*head
)
190 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
192 if ((push
= evo_wait(core
, 4))) {
193 evo_mthd(push
, 0x0448 + (head
->base
.index
* 0x300), 1);
194 evo_data(push
, 0x00000000);
195 evo_mthd(push
, 0x045c + (head
->base
.index
* 0x300), 1);
196 evo_data(push
, 0x00000000);
197 evo_kick(push
, core
);
202 head907d_olut_set(struct nv50_head
*head
, struct nv50_head_atom
*asyh
)
204 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
206 if ((push
= evo_wait(core
, 5))) {
207 evo_mthd(push
, 0x0448 + (head
->base
.index
* 0x300), 2);
208 evo_data(push
, 0x80000000 | asyh
->olut
.mode
<< 24);
209 evo_data(push
, asyh
->olut
.offset
>> 8);
210 evo_mthd(push
, 0x045c + (head
->base
.index
* 0x300), 1);
211 evo_data(push
, asyh
->olut
.handle
);
212 evo_kick(push
, core
);
217 head907d_olut_load(struct drm_color_lut
*in
, int size
, void __iomem
*mem
)
219 for (; size
--; in
++, mem
+= 8) {
220 writew(drm_color_lut_extract(in
-> red
, 14) + 0x6000, mem
+ 0);
221 writew(drm_color_lut_extract(in
->green
, 14) + 0x6000, mem
+ 2);
222 writew(drm_color_lut_extract(in
-> blue
, 14) + 0x6000, mem
+ 4);
225 /* INTERPOLATE modes require a "next" entry to interpolate with,
226 * so we replicate the last entry to deal with this for now.
228 writew(readw(mem
- 8), mem
+ 0);
229 writew(readw(mem
- 6), mem
+ 2);
230 writew(readw(mem
- 4), mem
+ 4);
234 head907d_olut(struct nv50_head
*head
, struct nv50_head_atom
*asyh
)
237 asyh
->olut
.load
= head907d_olut_load
;
241 head907d_mode(struct nv50_head
*head
, struct nv50_head_atom
*asyh
)
243 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
244 struct nv50_head_mode
*m
= &asyh
->mode
;
246 if ((push
= evo_wait(core
, 14))) {
247 evo_mthd(push
, 0x0410 + (head
->base
.index
* 0x300), 6);
248 evo_data(push
, 0x00000000);
249 evo_data(push
, m
->v
.active
<< 16 | m
->h
.active
);
250 evo_data(push
, m
->v
.synce
<< 16 | m
->h
.synce
);
251 evo_data(push
, m
->v
.blanke
<< 16 | m
->h
.blanke
);
252 evo_data(push
, m
->v
.blanks
<< 16 | m
->h
.blanks
);
253 evo_data(push
, m
->v
.blank2e
<< 16 | m
->v
.blank2s
);
254 evo_mthd(push
, 0x042c + (head
->base
.index
* 0x300), 2);
255 evo_data(push
, 0x00000000); /* ??? */
256 evo_data(push
, 0xffffff00);
257 evo_mthd(push
, 0x0450 + (head
->base
.index
* 0x300), 3);
258 evo_data(push
, m
->clock
* 1000);
259 evo_data(push
, 0x00200000); /* ??? */
260 evo_data(push
, m
->clock
* 1000);
261 evo_kick(push
, core
);
266 head907d_view(struct nv50_head
*head
, struct nv50_head_atom
*asyh
)
268 struct nv50_dmac
*core
= &nv50_disp(head
->base
.base
.dev
)->core
->chan
;
270 if ((push
= evo_wait(core
, 8))) {
271 evo_mthd(push
, 0x0494 + (head
->base
.index
* 0x300), 1);
272 evo_data(push
, 0x00000000);
273 evo_mthd(push
, 0x04b8 + (head
->base
.index
* 0x300), 1);
274 evo_data(push
, asyh
->view
.iH
<< 16 | asyh
->view
.iW
);
275 evo_mthd(push
, 0x04c0 + (head
->base
.index
* 0x300), 3);
276 evo_data(push
, asyh
->view
.oH
<< 16 | asyh
->view
.oW
);
277 evo_data(push
, asyh
->view
.oH
<< 16 | asyh
->view
.oW
);
278 evo_data(push
, asyh
->view
.oH
<< 16 | asyh
->view
.oW
);
279 evo_kick(push
, core
);
283 const struct nv50_head_func
285 .view
= head907d_view
,
286 .mode
= head907d_mode
,
287 .olut
= head907d_olut
,
288 .olut_set
= head907d_olut_set
,
289 .olut_clr
= head907d_olut_clr
,
290 .core_calc
= head507d_core_calc
,
291 .core_set
= head907d_core_set
,
292 .core_clr
= head907d_core_clr
,
293 .curs_layout
= head507d_curs_layout
,
294 .curs_format
= head507d_curs_format
,
295 .curs_set
= head907d_curs_set
,
296 .curs_clr
= head907d_curs_clr
,
297 .base
= head907d_base
,
298 .ovly
= head907d_ovly
,
299 .dither
= head907d_dither
,
300 .procamp
= head907d_procamp
,