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.
24 #include <nvif/push507c.h>
26 #include <nvhw/class/cl907c.h>
29 base907c_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
31 struct nvif_push *push = wndw->wndw.push;
34 if ((ret = PUSH_WAIT(push, 10)))
37 PUSH_NVSQ(push, NV907C, 0x0084, asyw->image.mode << 8 |
38 asyw->image.interval << 4);
39 PUSH_NVSQ(push, NV907C, 0x00c0, asyw->image.handle[0]);
40 PUSH_NVSQ(push, NV907C, 0x0400, asyw->image.offset[0] >> 8,
42 0x0408, asyw->image.h << 16 | asyw->image.w,
43 0x040c, asyw->image.layout << 24 |
44 (asyw->image.pitch[0] >> 8) << 8 |
45 asyw->image.blocks[0] << 8 |
47 0x0410, asyw->image.format << 8);
52 base907c_xlut_clr(struct nv50_wndw *wndw)
54 struct nvif_push *push = wndw->wndw.push;
57 if ((ret = PUSH_WAIT(push, 6)))
60 PUSH_NVSQ(push, NV907C, 0x00e0, 0x00000000);
61 PUSH_NVSQ(push, NV907C, 0x00e8, 0x00000000);
62 PUSH_NVSQ(push, NV907C, 0x00fc, 0x00000000);
67 base907c_xlut_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
69 struct nvif_push *push = wndw->wndw.push;
72 if ((ret = PUSH_WAIT(push, 6)))
75 PUSH_NVSQ(push, NV907C, 0x00e0, asyw->xlut.i.enable << 30 |
76 asyw->xlut.i.mode << 24,
77 0x00e4, asyw->xlut.i.offset >> 8,
79 PUSH_NVSQ(push, NV907C, 0x00fc, asyw->xlut.handle);
84 base907c_ilut(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw, int size)
86 if (size != 256 && size != 1024)
89 asyw->xlut.i.mode = size == 1024 ? 4 : 7;
90 asyw->xlut.i.enable = 2;
91 asyw->xlut.i.load = head907d_olut_load;
96 csc_drm_to_base(u64 in)
98 /* base takes a 19-bit 2's complement value in S3.16 format */
99 bool sign = in & BIT_ULL(63);
100 u32 integer = (in >> 32) & 0x7fffffff;
101 u32 fraction = in & 0xffffffff;
104 return (1 << 18) - (sign ? 0 : 1);
106 u32 ret = (integer << 16) | (fraction >> 16);
109 return ret & GENMASK(18, 0);
114 base907c_csc(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
115 const struct drm_color_ctm *ctm)
119 for (j = 0; j < 3; j++) {
120 for (i = 0; i < 4; i++) {
121 u32 *val = &asyw->csc.matrix[j * 4 + i];
122 /* DRM does not support constant offset, while
123 * HW CSC does. Skip it. */
127 *val = csc_drm_to_base(ctm->matrix[j * 3 + i]);
134 base907c_csc_clr(struct nv50_wndw *wndw)
136 struct nvif_push *push = wndw->wndw.push;
139 if ((ret = PUSH_WAIT(push, 2)))
142 PUSH_NVSQ(push, NV907C, 0x0140, 0x00000000);
147 base907c_csc_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
149 struct nvif_push *push = wndw->wndw.push;
152 if ((ret = PUSH_WAIT(push, 13)))
155 PUSH_MTHD(push, NV907C, SET_CSC_RED2RED,
156 NVDEF(NV907C, SET_CSC_RED2RED, OWNER, BASE) |
157 NVVAL(NV907C, SET_CSC_RED2RED, COEFF, asyw->csc.matrix[0]),
159 SET_CSC_GRN2RED, &asyw->csc.matrix[1], 11);
163 const struct nv50_wndw_func
165 .acquire = base507c_acquire,
166 .release = base507c_release,
167 .sema_set = base507c_sema_set,
168 .sema_clr = base507c_sema_clr,
169 .ntfy_reset = base507c_ntfy_reset,
170 .ntfy_set = base507c_ntfy_set,
171 .ntfy_clr = base507c_ntfy_clr,
172 .ntfy_wait_begun = base507c_ntfy_wait_begun,
173 .ilut = base907c_ilut,
175 .csc_set = base907c_csc_set,
176 .csc_clr = base907c_csc_clr,
179 .xlut_set = base907c_xlut_set,
180 .xlut_clr = base907c_xlut_clr,
181 .image_set = base907c_image_set,
182 .image_clr = base507c_image_clr,
183 .update = base507c_update,
187 base907c_new(struct nouveau_drm *drm, int head, s32 oclass,
188 struct nv50_wndw **pwndw)
190 return base507c_new_(&base907c, base507c_format, drm, head, oclass,
191 0x00000002 << (head * 4), pwndw);