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.
25 #include <drm/drm_atomic_helper.h>
26 #include <drm/drm_plane_helper.h>
28 #include <nvif/cl507e.h>
29 #include <nvif/event.h>
32 ovly507e_update(struct nv50_wndw
*wndw
, u32
*interlock
)
35 if ((push
= evo_wait(&wndw
->wndw
, 2))) {
36 evo_mthd(push
, 0x0080, 1);
37 evo_data(push
, interlock
[NV50_DISP_INTERLOCK_CORE
]);
38 evo_kick(push
, &wndw
->wndw
);
43 ovly507e_scale_set(struct nv50_wndw
*wndw
, struct nv50_wndw_atom
*asyw
)
46 if ((push
= evo_wait(&wndw
->wndw
, 4))) {
47 evo_mthd(push
, 0x00e0, 3);
48 evo_data(push
, asyw
->scale
.sy
<< 16 | asyw
->scale
.sx
);
49 evo_data(push
, asyw
->scale
.sh
<< 16 | asyw
->scale
.sw
);
50 evo_data(push
, asyw
->scale
.dw
);
51 evo_kick(push
, &wndw
->wndw
);
56 ovly507e_image_clr(struct nv50_wndw
*wndw
)
59 if ((push
= evo_wait(&wndw
->wndw
, 4))) {
60 evo_mthd(push
, 0x0084, 1);
61 evo_data(push
, 0x00000000);
62 evo_mthd(push
, 0x00c0, 1);
63 evo_data(push
, 0x00000000);
64 evo_kick(push
, &wndw
->wndw
);
69 ovly507e_image_set(struct nv50_wndw
*wndw
, struct nv50_wndw_atom
*asyw
)
72 if ((push
= evo_wait(&wndw
->wndw
, 12))) {
73 evo_mthd(push
, 0x0084, 1);
74 evo_data(push
, asyw
->image
.interval
<< 4);
75 evo_mthd(push
, 0x00c0, 1);
76 evo_data(push
, asyw
->image
.handle
[0]);
77 evo_mthd(push
, 0x0100, 1);
78 evo_data(push
, 0x00000002);
79 evo_mthd(push
, 0x0800, 1);
80 evo_data(push
, asyw
->image
.offset
[0] >> 8);
81 evo_mthd(push
, 0x0808, 3);
82 evo_data(push
, asyw
->image
.h
<< 16 | asyw
->image
.w
);
83 evo_data(push
, asyw
->image
.layout
<< 20 |
84 (asyw
->image
.pitch
[0] >> 8) << 8 |
85 asyw
->image
.blocks
[0] << 8 |
87 evo_data(push
, asyw
->image
.kind
<< 16 |
88 asyw
->image
.format
<< 8 |
89 asyw
->image
.colorspace
);
90 evo_kick(push
, &wndw
->wndw
);
95 ovly507e_ntfy_clr(struct nv50_wndw
*wndw
)
98 if ((push
= evo_wait(&wndw
->wndw
, 2))) {
99 evo_mthd(push
, 0x00a4, 1);
100 evo_data(push
, 0x00000000);
101 evo_kick(push
, &wndw
->wndw
);
106 ovly507e_ntfy_set(struct nv50_wndw
*wndw
, struct nv50_wndw_atom
*asyw
)
109 if ((push
= evo_wait(&wndw
->wndw
, 3))) {
110 evo_mthd(push
, 0x00a0, 2);
111 evo_data(push
, asyw
->ntfy
.awaken
<< 30 | asyw
->ntfy
.offset
);
112 evo_data(push
, asyw
->ntfy
.handle
);
113 evo_kick(push
, &wndw
->wndw
);
118 ovly507e_release(struct nv50_wndw
*wndw
, struct nv50_wndw_atom
*asyw
,
119 struct nv50_head_atom
*asyh
)
125 ovly507e_acquire(struct nv50_wndw
*wndw
, struct nv50_wndw_atom
*asyw
,
126 struct nv50_head_atom
*asyh
)
128 const struct drm_framebuffer
*fb
= asyw
->state
.fb
;
131 ret
= drm_atomic_helper_check_plane_state(&asyw
->state
, &asyh
->state
,
132 DRM_PLANE_HELPER_NO_SCALING
,
133 DRM_PLANE_HELPER_NO_SCALING
,
138 asyh
->ovly
.cpp
= fb
->format
->cpp
[0];
142 #include "nouveau_bo.h"
144 static const struct nv50_wndw_func
146 .acquire
= ovly507e_acquire
,
147 .release
= ovly507e_release
,
148 .ntfy_set
= ovly507e_ntfy_set
,
149 .ntfy_clr
= ovly507e_ntfy_clr
,
150 .ntfy_reset
= base507c_ntfy_reset
,
151 .ntfy_wait_begun
= base507c_ntfy_wait_begun
,
152 .image_set
= ovly507e_image_set
,
153 .image_clr
= ovly507e_image_clr
,
154 .scale_set
= ovly507e_scale_set
,
155 .update
= ovly507e_update
,
159 ovly507e_format
[] = {
170 ovly507e_new_(const struct nv50_wndw_func
*func
, const u32
*format
,
171 struct nouveau_drm
*drm
, int head
, s32 oclass
, u32 interlock_data
,
172 struct nv50_wndw
**pwndw
)
174 struct nv50_disp_overlay_channel_dma_v0 args
= {
177 struct nv50_disp
*disp
= nv50_disp(drm
->dev
);
178 struct nv50_wndw
*wndw
;
181 ret
= nv50_wndw_new_(func
, drm
->dev
, DRM_PLANE_TYPE_OVERLAY
,
182 "ovly", head
, format
, BIT(head
),
183 NV50_DISP_INTERLOCK_OVLY
, interlock_data
,
185 if (*pwndw
= wndw
, ret
)
188 ret
= nv50_dmac_create(&drm
->client
.device
, &disp
->disp
->object
,
189 &oclass
, 0, &args
, sizeof(args
),
190 disp
->sync
->bo
.offset
, &wndw
->wndw
);
192 NV_ERROR(drm
, "ovly%04x allocation failed: %d\n", oclass
, ret
);
196 ret
= nvif_notify_init(&wndw
->wndw
.base
.user
, wndw
->notify
.func
, false,
197 NV50_DISP_OVERLAY_CHANNEL_DMA_V0_NTFY_UEVENT
,
198 &(struct nvif_notify_uevent_req
) {},
199 sizeof(struct nvif_notify_uevent_req
),
200 sizeof(struct nvif_notify_uevent_rep
),
205 wndw
->ntfy
= NV50_DISP_OVLY_NTFY(wndw
->id
);
206 wndw
->sema
= NV50_DISP_OVLY_SEM0(wndw
->id
);
207 wndw
->data
= 0x00000000;
212 ovly507e_new(struct nouveau_drm
*drm
, int head
, s32 oclass
,
213 struct nv50_wndw
**pwndw
)
215 return ovly507e_new_(&ovly507e
, ovly507e_format
, drm
, head
, oclass
,
216 0x00000004 << (head
* 8), pwndw
);