1 /*
2 * Copyright 2018 Red Hat Inc.
3 *
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:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
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.
21 */
22 #include "ovly.h"
23 #include "atom.h"
24
25 #include <nvif/push507c.h>
26
27 #include <nvhw/class/cl907e.h>
28
29 static int
ovly907e_image_set(struct nv50_wndw * wndw,struct nv50_wndw_atom * asyw)30 ovly907e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
31 {
32 struct nvif_push *push = &wndw->wndw.push;
33 int ret;
34
35 if ((ret = PUSH_WAIT(push, 12)))
36 return ret;
37
38 PUSH_MTHD(push, NV907E, SET_PRESENT_CONTROL,
39 NVDEF(NV907E, SET_PRESENT_CONTROL, BEGIN_MODE, ASAP) |
40 NVVAL(NV907E, SET_PRESENT_CONTROL, MIN_PRESENT_INTERVAL, asyw->image.interval));
41
42 PUSH_MTHD(push, NV907E, SET_CONTEXT_DMA_ISO, asyw->image.handle[0]);
43
44 PUSH_MTHD(push, NV907E, SET_COMPOSITION_CONTROL,
45 NVDEF(NV907E, SET_COMPOSITION_CONTROL, MODE, OPAQUE));
46
47 PUSH_MTHD(push, NV907E, SURFACE_SET_OFFSET, asyw->image.offset[0] >> 8);
48
49 PUSH_MTHD(push, NV907E, SURFACE_SET_SIZE,
50 NVVAL(NV907E, SURFACE_SET_SIZE, WIDTH, asyw->image.w) |
51 NVVAL(NV907E, SURFACE_SET_SIZE, HEIGHT, asyw->image.h),
52
53 SURFACE_SET_STORAGE,
54 NVVAL(NV907E, SURFACE_SET_STORAGE, BLOCK_HEIGHT, asyw->image.blockh) |
55 NVVAL(NV907E, SURFACE_SET_STORAGE, PITCH, (asyw->image.pitch[0] >> 8)) |
56 NVVAL(NV907E, SURFACE_SET_STORAGE, PITCH, asyw->image.blocks[0]) |
57 NVVAL(NV907E, SURFACE_SET_STORAGE, MEMORY_LAYOUT, asyw->image.layout),
58
59 SURFACE_SET_PARAMS,
60 NVVAL(NV907E, SURFACE_SET_PARAMS, FORMAT, asyw->image.format) |
61 NVVAL(NV907E, SURFACE_SET_PARAMS, COLOR_SPACE, asyw->image.colorspace));
62 return 0;
63 }
64
65 const struct nv50_wndw_func
66 ovly907e = {
67 .acquire = ovly507e_acquire,
68 .release = ovly507e_release,
69 .ntfy_set = base507c_ntfy_set,
70 .ntfy_clr = base507c_ntfy_clr,
71 .ntfy_reset = ovly827e_ntfy_reset,
72 .ntfy_wait_begun = ovly827e_ntfy_wait_begun,
73 .image_set = ovly907e_image_set,
74 .image_clr = base507c_image_clr,
75 .scale_set = ovly507e_scale_set,
76 .update = base507c_update,
77 };
78
79 static const u32
80 ovly907e_format[] = {
81 DRM_FORMAT_YUYV,
82 DRM_FORMAT_UYVY,
83 DRM_FORMAT_XRGB8888,
84 DRM_FORMAT_XRGB1555,
85 DRM_FORMAT_XBGR2101010,
86 DRM_FORMAT_XBGR16161616F,
87 0
88 };
89
90 int
ovly907e_new(struct nouveau_drm * drm,int head,s32 oclass,struct nv50_wndw ** pwndw)91 ovly907e_new(struct nouveau_drm *drm, int head, s32 oclass,
92 struct nv50_wndw **pwndw)
93 {
94 return ovly507e_new_(&ovly907e, ovly907e_format, drm, head, oclass,
95 0x00000004 << (head * 4), pwndw);
96 }
97