drm/nouveau/kms/nv50-: convert core head_dither() to new push macros
[linux-2.6-microblaze.git] / drivers / gpu / drm / nouveau / dispnv50 / head917d.c
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 "head.h"
23 #include "core.h"
24
25 #include <nvif/push507c.h>
26
27 static int
28 head917d_dither(struct nv50_head *head, struct nv50_head_atom *asyh)
29 {
30         struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
31         const int i = head->base.index;
32         int ret;
33
34         if ((ret = PUSH_WAIT(push, 2)))
35                 return ret;
36
37         PUSH_NVSQ(push, NV917D, 0x04a0 + (i * 0x300), asyh->dither.mode << 3 |
38                                                       asyh->dither.bits << 1 |
39                                                       asyh->dither.enable);
40         return 0;
41 }
42
43 static int
44 head917d_base(struct nv50_head *head, struct nv50_head_atom *asyh)
45 {
46         struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
47         const int i = head->base.index;
48         u32 bounds = 0;
49         int ret;
50
51         if (asyh->base.cpp) {
52                 switch (asyh->base.cpp) {
53                 case 8: bounds |= 0x00000500; break;
54                 case 4: bounds |= 0x00000300; break;
55                 case 2: bounds |= 0x00000100; break;
56                 case 1: bounds |= 0x00000000; break;
57                 default:
58                         WARN_ON(1);
59                         break;
60                 }
61                 bounds |= 0x00020001;
62         }
63
64         if ((ret = PUSH_WAIT(push, 2)))
65                 return ret;
66
67         PUSH_NVSQ(push, NV917D, 0x04d0 + (i * 0x300), bounds);
68         return 0;
69 }
70
71 int
72 head917d_curs_layout(struct nv50_head *head, struct nv50_wndw_atom *asyw,
73                      struct nv50_head_atom *asyh)
74 {
75         switch (asyw->state.fb->width) {
76         case  32: asyh->curs.layout = 0; break;
77         case  64: asyh->curs.layout = 1; break;
78         case 128: asyh->curs.layout = 2; break;
79         case 256: asyh->curs.layout = 3; break;
80         default:
81                 return -EINVAL;
82         }
83         return 0;
84 }
85
86 const struct nv50_head_func
87 head917d = {
88         .view = head907d_view,
89         .mode = head907d_mode,
90         .olut = head907d_olut,
91         .olut_size = 1024,
92         .olut_set = head907d_olut_set,
93         .olut_clr = head907d_olut_clr,
94         .core_calc = head507d_core_calc,
95         .core_set = head907d_core_set,
96         .core_clr = head907d_core_clr,
97         .curs_layout = head917d_curs_layout,
98         .curs_format = head507d_curs_format,
99         .curs_set = head907d_curs_set,
100         .curs_clr = head907d_curs_clr,
101         .base = head917d_base,
102         .ovly = head907d_ovly,
103         .dither = head917d_dither,
104         .procamp = head907d_procamp,
105         .or = head907d_or,
106 };