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 #include <nvif/pushc37b.h>
29 headc37d_or(struct nv50_head *head, struct nv50_head_atom *asyh)
31 struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
32 const int i = head->base.index;
36 /*XXX: This is a dirty hack until OR depth handling is
37 * improved later for deep colour etc.
39 switch (asyh->or.depth) {
40 case 6: depth = 5; break;
41 case 5: depth = 4; break;
42 case 2: depth = 1; break;
43 case 0: depth = 4; break;
45 depth = asyh->or.depth;
50 if ((ret = PUSH_WAIT(push, 2)))
53 PUSH_NVSQ(push, NVC37D, 0x2004 + (i * 0x400), depth << 4 |
54 asyh->or.nvsync << 3 |
55 asyh->or.nhsync << 2 |
61 headc37d_procamp(struct nv50_head *head, struct nv50_head_atom *asyh)
63 struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
64 const int i = head->base.index;
67 if ((ret = PUSH_WAIT(push, 2)))
70 PUSH_NVSQ(push, NVC37D, 0x2000 + (i * 0x400), 0x80000000 |
71 asyh->procamp.sat.sin << 16 |
72 asyh->procamp.sat.cos << 4);
77 headc37d_dither(struct nv50_head *head, struct nv50_head_atom *asyh)
79 struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
80 const int i = head->base.index;
83 if ((ret = PUSH_WAIT(push, 2)))
86 PUSH_NVSQ(push, NV907D, 0x2018 + (i * 0x400), asyh->dither.mode << 8 |
87 asyh->dither.bits << 4 |
93 headc37d_curs_clr(struct nv50_head *head)
95 struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
96 const int i = head->base.index;
99 if ((ret = PUSH_WAIT(push, 4)))
102 PUSH_NVSQ(push, NVC37D, 0x209c + (i * 0x400), 0x000000cf);
103 PUSH_NVSQ(push, NVC37D, 0x2088 + (i * 0x400), 0x00000000);
108 headc37d_curs_set(struct nv50_head *head, struct nv50_head_atom *asyh)
110 struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
111 const int i = head->base.index;
114 if ((ret = PUSH_WAIT(push, 7)))
117 PUSH_NVSQ(push, NVC37D, 0x209c + (i * 0x400), 0x80000000 |
118 asyh->curs.layout << 8 |
119 asyh->curs.format << 0,
120 0x20a0 + (i * 0x400), 0x000072ff);
121 PUSH_NVSQ(push, NVC37D, 0x2088 + (i * 0x400), asyh->curs.handle);
122 PUSH_NVSQ(push, NVC37D, 0x2090 + (i * 0x400), asyh->curs.offset >> 8);
127 headc37d_curs_format(struct nv50_head *head, struct nv50_wndw_atom *asyw,
128 struct nv50_head_atom *asyh)
130 asyh->curs.format = asyw->image.format;
135 headc37d_olut_clr(struct nv50_head *head)
137 struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
138 const int i = head->base.index;
141 if ((ret = PUSH_WAIT(push, 2)))
144 PUSH_NVSQ(push, NVC37D, 0x20ac + (i * 0x400), 0x00000000);
149 headc37d_olut_set(struct nv50_head *head, struct nv50_head_atom *asyh)
151 struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
152 const int i = head->base.index;
155 if ((ret = PUSH_WAIT(push, 4)))
158 PUSH_NVSQ(push, NVC37D, 0x20a4 + (i * 0x400), asyh->olut.output_mode << 8 |
159 asyh->olut.range << 4 |
161 0x20a8 + (i * 0x400), asyh->olut.offset >> 8,
162 0x20ac + (i * 0x400), asyh->olut.handle);
167 headc37d_olut(struct nv50_head *head, struct nv50_head_atom *asyh, int size)
169 if (size != 256 && size != 1024)
173 asyh->olut.size = size == 1024 ? 2 : 0;
174 asyh->olut.range = 0;
175 asyh->olut.output_mode = 1;
176 asyh->olut.load = head907d_olut_load;
181 headc37d_mode(struct nv50_head *head, struct nv50_head_atom *asyh)
183 struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
184 struct nv50_head_mode *m = &asyh->mode;
185 const int i = head->base.index;
188 if ((ret = PUSH_WAIT(push, 13)))
191 PUSH_NVSQ(push, NVC37D, 0x2064 + (i * 0x400), m->v.active << 16 | m->h.active,
192 0x2068 + (i * 0x400), m->v.synce << 16 | m->h.synce,
193 0x206c + (i * 0x400), m->v.blanke << 16 | m->h.blanke,
194 0x2070 + (i * 0x400), m->v.blanks << 16 | m->h.blanks,
195 0x2074 + (i * 0x400), m->v.blank2e << 16 | m->v.blank2s);
196 PUSH_NVSQ(push, NVC37D, 0x2008 + (i * 0x400), m->interlace,
197 0x200c + (i * 0x400), m->clock * 1000);
198 PUSH_NVSQ(push, NVC37D, 0x2028 + (i * 0x400), m->clock * 1000);
200 /*XXX: HEAD_USAGE_BOUNDS, doesn't belong here. */
201 PUSH_NVSQ(push, NVC37D, 0x2030 + (i * 0x400), 0x00000124);
206 headc37d_view(struct nv50_head *head, struct nv50_head_atom *asyh)
208 struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
209 const int i = head->base.index;
212 if ((ret = PUSH_WAIT(push, 4)))
215 PUSH_NVSQ(push, NVC37D, 0x204c + (i * 0x400), asyh->view.iH << 16 | asyh->view.iW);
216 PUSH_NVSQ(push, NVC37D, 0x2058 + (i * 0x400), asyh->view.oH << 16 | asyh->view.oW);
221 headc37d_static_wndw_map(struct nv50_head *head, struct nv50_head_atom *asyh)
225 for (i = head->base.index * 2, end = i + 2; i < end; i++)
226 asyh->wndw.owned |= BIT(i);
229 const struct nv50_head_func
231 .view = headc37d_view,
232 .mode = headc37d_mode,
233 .olut = headc37d_olut,
235 .olut_set = headc37d_olut_set,
236 .olut_clr = headc37d_olut_clr,
237 .curs_layout = head917d_curs_layout,
238 .curs_format = headc37d_curs_format,
239 .curs_set = headc37d_curs_set,
240 .curs_clr = headc37d_curs_clr,
241 .dither = headc37d_dither,
242 .procamp = headc37d_procamp,
244 .static_wndw_map = headc37d_static_wndw_map,