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 static void
26 ovly907e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
27 {
28 	u32 *push;
29 	if ((push = evo_wait(&wndw->wndw, 12))) {
30 		evo_mthd(push, 0x0084, 1);
31 		evo_data(push, asyw->image.interval << 4);
32 		evo_mthd(push, 0x00c0, 1);
33 		evo_data(push, asyw->image.handle[0]);
34 		evo_mthd(push, 0x0100, 1);
35 		evo_data(push, 0x00000002);
36 		evo_mthd(push, 0x0400, 1);
37 		evo_data(push, asyw->image.offset[0] >> 8);
38 		evo_mthd(push, 0x0408, 3);
39 		evo_data(push, asyw->image.h << 16 | asyw->image.w);
40 		evo_data(push, asyw->image.layout << 24 |
41 			       (asyw->image.pitch[0] >> 8) << 8 |
42 			       asyw->image.blocks[0] << 8 |
43 			       asyw->image.blockh);
44 		evo_data(push, asyw->image.format << 8 |
45 			       asyw->image.colorspace);
46 		evo_kick(push, &wndw->wndw);
47 	}
48 }
49 
50 const struct nv50_wndw_func
51 ovly907e = {
52 	.acquire = ovly507e_acquire,
53 	.release = ovly507e_release,
54 	.ntfy_set = ovly507e_ntfy_set,
55 	.ntfy_clr = ovly507e_ntfy_clr,
56 	.ntfy_reset = ovly827e_ntfy_reset,
57 	.ntfy_wait_begun = ovly827e_ntfy_wait_begun,
58 	.image_set = ovly907e_image_set,
59 	.image_clr = ovly507e_image_clr,
60 	.scale_set = ovly507e_scale_set,
61 	.update = ovly507e_update,
62 };
63 
64 int
65 ovly907e_new(struct nouveau_drm *drm, int head, s32 oclass,
66 	     struct nv50_wndw **pwndw)
67 {
68 	return ovly507e_new_(&ovly907e, ovly827e_format, drm, head, oclass,
69 			     0x00000004 << (head * 4), pwndw);
70 }
71