aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/msm/mdp/mdp5
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/msm/mdp/mdp5')
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5.xml.h1036
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c569
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_encoder.c258
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_irq.c111
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c350
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h213
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c389
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_smp.c173
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_smp.h41
9 files changed, 3140 insertions, 0 deletions
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5.xml.h b/drivers/gpu/drm/msm/mdp/mdp5/mdp5.xml.h
new file mode 100644
index 000000000000..0aa51517f826
--- /dev/null
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5.xml.h
@@ -0,0 +1,1036 @@
1#ifndef MDP5_XML
2#define MDP5_XML
3
4/* Autogenerated file, DO NOT EDIT manually!
5
6This file was generated by the rules-ng-ng headergen tool in this git repository:
7http://github.com/freedreno/envytools/
8git clone https://github.com/freedreno/envytools.git
9
10The rules-ng-ng source files this header was generated from are:
11- /home/robclark/src/freedreno/envytools/rnndb/msm.xml ( 647 bytes, from 2013-11-30 14:45:35)
12- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml ( 1453 bytes, from 2013-03-31 16:51:27)
13- /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp4.xml ( 17996 bytes, from 2013-12-01 19:10:31)
14- /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp_common.xml ( 1615 bytes, from 2013-11-30 15:00:52)
15- /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp5.xml ( 22517 bytes, from 2013-12-03 20:59:13)
16- /home/robclark/src/freedreno/envytools/rnndb/dsi/dsi.xml ( 11712 bytes, from 2013-08-17 17:13:43)
17- /home/robclark/src/freedreno/envytools/rnndb/dsi/sfpb.xml ( 344 bytes, from 2013-08-11 19:26:32)
18- /home/robclark/src/freedreno/envytools/rnndb/dsi/mmss_cc.xml ( 1544 bytes, from 2013-08-16 19:17:05)
19- /home/robclark/src/freedreno/envytools/rnndb/hdmi/qfprom.xml ( 600 bytes, from 2013-07-05 19:21:12)
20- /home/robclark/src/freedreno/envytools/rnndb/hdmi/hdmi.xml ( 20932 bytes, from 2013-12-01 15:13:04)
21
22Copyright (C) 2013 by the following authors:
23- Rob Clark <robdclark@gmail.com> (robclark)
24
25Permission is hereby granted, free of charge, to any person obtaining
26a copy of this software and associated documentation files (the
27"Software"), to deal in the Software without restriction, including
28without limitation the rights to use, copy, modify, merge, publish,
29distribute, sublicense, and/or sell copies of the Software, and to
30permit persons to whom the Software is furnished to do so, subject to
31the following conditions:
32
33The above copyright notice and this permission notice (including the
34next paragraph) shall be included in all copies or substantial
35portions of the Software.
36
37THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
38EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
39MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
40IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
41LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
42OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
43WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
44*/
45
46
47enum mdp5_intf {
48 INTF_DSI = 1,
49 INTF_HDMI = 3,
50 INTF_LCDC = 5,
51 INTF_eDP = 9,
52};
53
54enum mdp5_intfnum {
55 NO_INTF = 0,
56 INTF0 = 1,
57 INTF1 = 2,
58 INTF2 = 3,
59 INTF3 = 4,
60};
61
62enum mdp5_pipe {
63 SSPP_VIG0 = 0,
64 SSPP_VIG1 = 1,
65 SSPP_VIG2 = 2,
66 SSPP_RGB0 = 3,
67 SSPP_RGB1 = 4,
68 SSPP_RGB2 = 5,
69 SSPP_DMA0 = 6,
70 SSPP_DMA1 = 7,
71};
72
73enum mdp5_ctl_mode {
74 MODE_NONE = 0,
75 MODE_ROT0 = 1,
76 MODE_ROT1 = 2,
77 MODE_WB0 = 3,
78 MODE_WB1 = 4,
79 MODE_WFD = 5,
80};
81
82enum mdp5_pack_3d {
83 PACK_3D_FRAME_INT = 0,
84 PACK_3D_H_ROW_INT = 1,
85 PACK_3D_V_ROW_INT = 2,
86 PACK_3D_COL_INT = 3,
87};
88
89enum mdp5_chroma_samp_type {
90 CHROMA_RGB = 0,
91 CHROMA_H2V1 = 1,
92 CHROMA_H1V2 = 2,
93 CHROMA_420 = 3,
94};
95
96enum mdp5_scale_filter {
97 SCALE_FILTER_NEAREST = 0,
98 SCALE_FILTER_BIL = 1,
99 SCALE_FILTER_PCMN = 2,
100 SCALE_FILTER_CA = 3,
101};
102
103enum mdp5_pipe_bwc {
104 BWC_LOSSLESS = 0,
105 BWC_Q_HIGH = 1,
106 BWC_Q_MED = 2,
107};
108
109enum mdp5_client_id {
110 CID_UNUSED = 0,
111 CID_VIG0_Y = 1,
112 CID_VIG0_CR = 2,
113 CID_VIG0_CB = 3,
114 CID_VIG1_Y = 4,
115 CID_VIG1_CR = 5,
116 CID_VIG1_CB = 6,
117 CID_VIG2_Y = 7,
118 CID_VIG2_CR = 8,
119 CID_VIG2_CB = 9,
120 CID_DMA0_Y = 10,
121 CID_DMA0_CR = 11,
122 CID_DMA0_CB = 12,
123 CID_DMA1_Y = 13,
124 CID_DMA1_CR = 14,
125 CID_DMA1_CB = 15,
126 CID_RGB0 = 16,
127 CID_RGB1 = 17,
128 CID_RGB2 = 18,
129 CID_MAX = 19,
130};
131
132enum mdp5_igc_type {
133 IGC_VIG = 0,
134 IGC_RGB = 1,
135 IGC_DMA = 2,
136 IGC_DSPP = 3,
137};
138
139#define MDP5_IRQ_INTF0_WB_ROT_COMP 0x00000001
140#define MDP5_IRQ_INTF1_WB_ROT_COMP 0x00000002
141#define MDP5_IRQ_INTF2_WB_ROT_COMP 0x00000004
142#define MDP5_IRQ_INTF3_WB_ROT_COMP 0x00000008
143#define MDP5_IRQ_INTF0_WB_WFD 0x00000010
144#define MDP5_IRQ_INTF1_WB_WFD 0x00000020
145#define MDP5_IRQ_INTF2_WB_WFD 0x00000040
146#define MDP5_IRQ_INTF3_WB_WFD 0x00000080
147#define MDP5_IRQ_INTF0_PING_PONG_COMP 0x00000100
148#define MDP5_IRQ_INTF1_PING_PONG_COMP 0x00000200
149#define MDP5_IRQ_INTF2_PING_PONG_COMP 0x00000400
150#define MDP5_IRQ_INTF3_PING_PONG_COMP 0x00000800
151#define MDP5_IRQ_INTF0_PING_PONG_RD_PTR 0x00001000
152#define MDP5_IRQ_INTF1_PING_PONG_RD_PTR 0x00002000
153#define MDP5_IRQ_INTF2_PING_PONG_RD_PTR 0x00004000
154#define MDP5_IRQ_INTF3_PING_PONG_RD_PTR 0x00008000
155#define MDP5_IRQ_INTF0_PING_PONG_WR_PTR 0x00010000
156#define MDP5_IRQ_INTF1_PING_PONG_WR_PTR 0x00020000
157#define MDP5_IRQ_INTF2_PING_PONG_WR_PTR 0x00040000
158#define MDP5_IRQ_INTF3_PING_PONG_WR_PTR 0x00080000
159#define MDP5_IRQ_INTF0_PING_PONG_AUTO_REF 0x00100000
160#define MDP5_IRQ_INTF1_PING_PONG_AUTO_REF 0x00200000
161#define MDP5_IRQ_INTF2_PING_PONG_AUTO_REF 0x00400000
162#define MDP5_IRQ_INTF3_PING_PONG_AUTO_REF 0x00800000
163#define MDP5_IRQ_INTF0_UNDER_RUN 0x01000000
164#define MDP5_IRQ_INTF0_VSYNC 0x02000000
165#define MDP5_IRQ_INTF1_UNDER_RUN 0x04000000
166#define MDP5_IRQ_INTF1_VSYNC 0x08000000
167#define MDP5_IRQ_INTF2_UNDER_RUN 0x10000000
168#define MDP5_IRQ_INTF2_VSYNC 0x20000000
169#define MDP5_IRQ_INTF3_UNDER_RUN 0x40000000
170#define MDP5_IRQ_INTF3_VSYNC 0x80000000
171#define REG_MDP5_HW_VERSION 0x00000000
172
173#define REG_MDP5_HW_INTR_STATUS 0x00000010
174#define MDP5_HW_INTR_STATUS_INTR_MDP 0x00000001
175#define MDP5_HW_INTR_STATUS_INTR_DSI0 0x00000010
176#define MDP5_HW_INTR_STATUS_INTR_DSI1 0x00000020
177#define MDP5_HW_INTR_STATUS_INTR_HDMI 0x00000100
178#define MDP5_HW_INTR_STATUS_INTR_EDP 0x00001000
179
180#define REG_MDP5_MDP_VERSION 0x00000100
181#define MDP5_MDP_VERSION_MINOR__MASK 0x00ff0000
182#define MDP5_MDP_VERSION_MINOR__SHIFT 16
183static inline uint32_t MDP5_MDP_VERSION_MINOR(uint32_t val)
184{
185 return ((val) << MDP5_MDP_VERSION_MINOR__SHIFT) & MDP5_MDP_VERSION_MINOR__MASK;
186}
187#define MDP5_MDP_VERSION_MAJOR__MASK 0xf0000000
188#define MDP5_MDP_VERSION_MAJOR__SHIFT 28
189static inline uint32_t MDP5_MDP_VERSION_MAJOR(uint32_t val)
190{
191 return ((val) << MDP5_MDP_VERSION_MAJOR__SHIFT) & MDP5_MDP_VERSION_MAJOR__MASK;
192}
193
194#define REG_MDP5_DISP_INTF_SEL 0x00000104
195#define MDP5_DISP_INTF_SEL_INTF0__MASK 0x000000ff
196#define MDP5_DISP_INTF_SEL_INTF0__SHIFT 0
197static inline uint32_t MDP5_DISP_INTF_SEL_INTF0(enum mdp5_intf val)
198{
199 return ((val) << MDP5_DISP_INTF_SEL_INTF0__SHIFT) & MDP5_DISP_INTF_SEL_INTF0__MASK;
200}
201#define MDP5_DISP_INTF_SEL_INTF1__MASK 0x0000ff00
202#define MDP5_DISP_INTF_SEL_INTF1__SHIFT 8
203static inline uint32_t MDP5_DISP_INTF_SEL_INTF1(enum mdp5_intf val)
204{
205 return ((val) << MDP5_DISP_INTF_SEL_INTF1__SHIFT) & MDP5_DISP_INTF_SEL_INTF1__MASK;
206}
207#define MDP5_DISP_INTF_SEL_INTF2__MASK 0x00ff0000
208#define MDP5_DISP_INTF_SEL_INTF2__SHIFT 16
209static inline uint32_t MDP5_DISP_INTF_SEL_INTF2(enum mdp5_intf val)
210{
211 return ((val) << MDP5_DISP_INTF_SEL_INTF2__SHIFT) & MDP5_DISP_INTF_SEL_INTF2__MASK;
212}
213#define MDP5_DISP_INTF_SEL_INTF3__MASK 0xff000000
214#define MDP5_DISP_INTF_SEL_INTF3__SHIFT 24
215static inline uint32_t MDP5_DISP_INTF_SEL_INTF3(enum mdp5_intf val)
216{
217 return ((val) << MDP5_DISP_INTF_SEL_INTF3__SHIFT) & MDP5_DISP_INTF_SEL_INTF3__MASK;
218}
219
220#define REG_MDP5_INTR_EN 0x00000110
221
222#define REG_MDP5_INTR_STATUS 0x00000114
223
224#define REG_MDP5_INTR_CLEAR 0x00000118
225
226#define REG_MDP5_HIST_INTR_EN 0x0000011c
227
228#define REG_MDP5_HIST_INTR_STATUS 0x00000120
229
230#define REG_MDP5_HIST_INTR_CLEAR 0x00000124
231
232static inline uint32_t REG_MDP5_SMP_ALLOC_W(uint32_t i0) { return 0x00000180 + 0x4*i0; }
233
234static inline uint32_t REG_MDP5_SMP_ALLOC_W_REG(uint32_t i0) { return 0x00000180 + 0x4*i0; }
235#define MDP5_SMP_ALLOC_W_REG_CLIENT0__MASK 0x000000ff
236#define MDP5_SMP_ALLOC_W_REG_CLIENT0__SHIFT 0
237static inline uint32_t MDP5_SMP_ALLOC_W_REG_CLIENT0(enum mdp5_client_id val)
238{
239 return ((val) << MDP5_SMP_ALLOC_W_REG_CLIENT0__SHIFT) & MDP5_SMP_ALLOC_W_REG_CLIENT0__MASK;
240}
241#define MDP5_SMP_ALLOC_W_REG_CLIENT1__MASK 0x0000ff00
242#define MDP5_SMP_ALLOC_W_REG_CLIENT1__SHIFT 8
243static inline uint32_t MDP5_SMP_ALLOC_W_REG_CLIENT1(enum mdp5_client_id val)
244{
245 return ((val) << MDP5_SMP_ALLOC_W_REG_CLIENT1__SHIFT) & MDP5_SMP_ALLOC_W_REG_CLIENT1__MASK;
246}
247#define MDP5_SMP_ALLOC_W_REG_CLIENT2__MASK 0x00ff0000
248#define MDP5_SMP_ALLOC_W_REG_CLIENT2__SHIFT 16
249static inline uint32_t MDP5_SMP_ALLOC_W_REG_CLIENT2(enum mdp5_client_id val)
250{
251 return ((val) << MDP5_SMP_ALLOC_W_REG_CLIENT2__SHIFT) & MDP5_SMP_ALLOC_W_REG_CLIENT2__MASK;
252}
253
254static inline uint32_t REG_MDP5_SMP_ALLOC_R(uint32_t i0) { return 0x00000230 + 0x4*i0; }
255
256static inline uint32_t REG_MDP5_SMP_ALLOC_R_REG(uint32_t i0) { return 0x00000230 + 0x4*i0; }
257#define MDP5_SMP_ALLOC_R_REG_CLIENT0__MASK 0x000000ff
258#define MDP5_SMP_ALLOC_R_REG_CLIENT0__SHIFT 0
259static inline uint32_t MDP5_SMP_ALLOC_R_REG_CLIENT0(enum mdp5_client_id val)
260{
261 return ((val) << MDP5_SMP_ALLOC_R_REG_CLIENT0__SHIFT) & MDP5_SMP_ALLOC_R_REG_CLIENT0__MASK;
262}
263#define MDP5_SMP_ALLOC_R_REG_CLIENT1__MASK 0x0000ff00
264#define MDP5_SMP_ALLOC_R_REG_CLIENT1__SHIFT 8
265static inline uint32_t MDP5_SMP_ALLOC_R_REG_CLIENT1(enum mdp5_client_id val)
266{
267 return ((val) << MDP5_SMP_ALLOC_R_REG_CLIENT1__SHIFT) & MDP5_SMP_ALLOC_R_REG_CLIENT1__MASK;
268}
269#define MDP5_SMP_ALLOC_R_REG_CLIENT2__MASK 0x00ff0000
270#define MDP5_SMP_ALLOC_R_REG_CLIENT2__SHIFT 16
271static inline uint32_t MDP5_SMP_ALLOC_R_REG_CLIENT2(enum mdp5_client_id val)
272{
273 return ((val) << MDP5_SMP_ALLOC_R_REG_CLIENT2__SHIFT) & MDP5_SMP_ALLOC_R_REG_CLIENT2__MASK;
274}
275
276static inline uint32_t __offset_IGC(enum mdp5_igc_type idx)
277{
278 switch (idx) {
279 case IGC_VIG: return 0x00000300;
280 case IGC_RGB: return 0x00000310;
281 case IGC_DMA: return 0x00000320;
282 case IGC_DSPP: return 0x00000400;
283 default: return INVALID_IDX(idx);
284 }
285}
286static inline uint32_t REG_MDP5_IGC(enum mdp5_igc_type i0) { return 0x00000000 + __offset_IGC(i0); }
287
288static inline uint32_t REG_MDP5_IGC_LUT(enum mdp5_igc_type i0, uint32_t i1) { return 0x00000000 + __offset_IGC(i0) + 0x4*i1; }
289
290static inline uint32_t REG_MDP5_IGC_LUT_REG(enum mdp5_igc_type i0, uint32_t i1) { return 0x00000000 + __offset_IGC(i0) + 0x4*i1; }
291#define MDP5_IGC_LUT_REG_VAL__MASK 0x00000fff
292#define MDP5_IGC_LUT_REG_VAL__SHIFT 0
293static inline uint32_t MDP5_IGC_LUT_REG_VAL(uint32_t val)
294{
295 return ((val) << MDP5_IGC_LUT_REG_VAL__SHIFT) & MDP5_IGC_LUT_REG_VAL__MASK;
296}
297#define MDP5_IGC_LUT_REG_INDEX_UPDATE 0x02000000
298#define MDP5_IGC_LUT_REG_DISABLE_PIPE_0 0x10000000
299#define MDP5_IGC_LUT_REG_DISABLE_PIPE_1 0x20000000
300#define MDP5_IGC_LUT_REG_DISABLE_PIPE_2 0x40000000
301
302static inline uint32_t REG_MDP5_CTL(uint32_t i0) { return 0x00000600 + 0x100*i0; }
303
304static inline uint32_t REG_MDP5_CTL_LAYER(uint32_t i0, uint32_t i1) { return 0x00000600 + 0x100*i0 + 0x4*i1; }
305
306static inline uint32_t REG_MDP5_CTL_LAYER_REG(uint32_t i0, uint32_t i1) { return 0x00000600 + 0x100*i0 + 0x4*i1; }
307#define MDP5_CTL_LAYER_REG_VIG0__MASK 0x00000007
308#define MDP5_CTL_LAYER_REG_VIG0__SHIFT 0
309static inline uint32_t MDP5_CTL_LAYER_REG_VIG0(enum mdp_mixer_stage_id val)
310{
311 return ((val) << MDP5_CTL_LAYER_REG_VIG0__SHIFT) & MDP5_CTL_LAYER_REG_VIG0__MASK;
312}
313#define MDP5_CTL_LAYER_REG_VIG1__MASK 0x00000038
314#define MDP5_CTL_LAYER_REG_VIG1__SHIFT 3
315static inline uint32_t MDP5_CTL_LAYER_REG_VIG1(enum mdp_mixer_stage_id val)
316{
317 return ((val) << MDP5_CTL_LAYER_REG_VIG1__SHIFT) & MDP5_CTL_LAYER_REG_VIG1__MASK;
318}
319#define MDP5_CTL_LAYER_REG_VIG2__MASK 0x000001c0
320#define MDP5_CTL_LAYER_REG_VIG2__SHIFT 6
321static inline uint32_t MDP5_CTL_LAYER_REG_VIG2(enum mdp_mixer_stage_id val)
322{
323 return ((val) << MDP5_CTL_LAYER_REG_VIG2__SHIFT) & MDP5_CTL_LAYER_REG_VIG2__MASK;
324}
325#define MDP5_CTL_LAYER_REG_RGB0__MASK 0x00000e00
326#define MDP5_CTL_LAYER_REG_RGB0__SHIFT 9
327static inline uint32_t MDP5_CTL_LAYER_REG_RGB0(enum mdp_mixer_stage_id val)
328{
329 return ((val) << MDP5_CTL_LAYER_REG_RGB0__SHIFT) & MDP5_CTL_LAYER_REG_RGB0__MASK;
330}
331#define MDP5_CTL_LAYER_REG_RGB1__MASK 0x00007000
332#define MDP5_CTL_LAYER_REG_RGB1__SHIFT 12
333static inline uint32_t MDP5_CTL_LAYER_REG_RGB1(enum mdp_mixer_stage_id val)
334{
335 return ((val) << MDP5_CTL_LAYER_REG_RGB1__SHIFT) & MDP5_CTL_LAYER_REG_RGB1__MASK;
336}
337#define MDP5_CTL_LAYER_REG_RGB2__MASK 0x00038000
338#define MDP5_CTL_LAYER_REG_RGB2__SHIFT 15
339static inline uint32_t MDP5_CTL_LAYER_REG_RGB2(enum mdp_mixer_stage_id val)
340{
341 return ((val) << MDP5_CTL_LAYER_REG_RGB2__SHIFT) & MDP5_CTL_LAYER_REG_RGB2__MASK;
342}
343#define MDP5_CTL_LAYER_REG_DMA0__MASK 0x001c0000
344#define MDP5_CTL_LAYER_REG_DMA0__SHIFT 18
345static inline uint32_t MDP5_CTL_LAYER_REG_DMA0(enum mdp_mixer_stage_id val)
346{
347 return ((val) << MDP5_CTL_LAYER_REG_DMA0__SHIFT) & MDP5_CTL_LAYER_REG_DMA0__MASK;
348}
349#define MDP5_CTL_LAYER_REG_DMA1__MASK 0x00e00000
350#define MDP5_CTL_LAYER_REG_DMA1__SHIFT 21
351static inline uint32_t MDP5_CTL_LAYER_REG_DMA1(enum mdp_mixer_stage_id val)
352{
353 return ((val) << MDP5_CTL_LAYER_REG_DMA1__SHIFT) & MDP5_CTL_LAYER_REG_DMA1__MASK;
354}
355#define MDP5_CTL_LAYER_REG_BORDER_COLOR 0x01000000
356#define MDP5_CTL_LAYER_REG_CURSOR_OUT 0x02000000
357
358static inline uint32_t REG_MDP5_CTL_OP(uint32_t i0) { return 0x00000614 + 0x100*i0; }
359#define MDP5_CTL_OP_MODE__MASK 0x0000000f
360#define MDP5_CTL_OP_MODE__SHIFT 0
361static inline uint32_t MDP5_CTL_OP_MODE(enum mdp5_ctl_mode val)
362{
363 return ((val) << MDP5_CTL_OP_MODE__SHIFT) & MDP5_CTL_OP_MODE__MASK;
364}
365#define MDP5_CTL_OP_INTF_NUM__MASK 0x00000070
366#define MDP5_CTL_OP_INTF_NUM__SHIFT 4
367static inline uint32_t MDP5_CTL_OP_INTF_NUM(enum mdp5_intfnum val)
368{
369 return ((val) << MDP5_CTL_OP_INTF_NUM__SHIFT) & MDP5_CTL_OP_INTF_NUM__MASK;
370}
371#define MDP5_CTL_OP_CMD_MODE 0x00020000
372#define MDP5_CTL_OP_PACK_3D_ENABLE 0x00080000
373#define MDP5_CTL_OP_PACK_3D__MASK 0x00300000
374#define MDP5_CTL_OP_PACK_3D__SHIFT 20
375static inline uint32_t MDP5_CTL_OP_PACK_3D(enum mdp5_pack_3d val)
376{
377 return ((val) << MDP5_CTL_OP_PACK_3D__SHIFT) & MDP5_CTL_OP_PACK_3D__MASK;
378}
379
380static inline uint32_t REG_MDP5_CTL_FLUSH(uint32_t i0) { return 0x00000618 + 0x100*i0; }
381#define MDP5_CTL_FLUSH_VIG0 0x00000001
382#define MDP5_CTL_FLUSH_VIG1 0x00000002
383#define MDP5_CTL_FLUSH_VIG2 0x00000004
384#define MDP5_CTL_FLUSH_RGB0 0x00000008
385#define MDP5_CTL_FLUSH_RGB1 0x00000010
386#define MDP5_CTL_FLUSH_RGB2 0x00000020
387#define MDP5_CTL_FLUSH_LM0 0x00000040
388#define MDP5_CTL_FLUSH_LM1 0x00000080
389#define MDP5_CTL_FLUSH_LM2 0x00000100
390#define MDP5_CTL_FLUSH_DMA0 0x00000800
391#define MDP5_CTL_FLUSH_DMA1 0x00001000
392#define MDP5_CTL_FLUSH_DSPP0 0x00002000
393#define MDP5_CTL_FLUSH_DSPP1 0x00004000
394#define MDP5_CTL_FLUSH_DSPP2 0x00008000
395#define MDP5_CTL_FLUSH_CTL 0x00020000
396
397static inline uint32_t REG_MDP5_CTL_START(uint32_t i0) { return 0x0000061c + 0x100*i0; }
398
399static inline uint32_t REG_MDP5_CTL_PACK_3D(uint32_t i0) { return 0x00000620 + 0x100*i0; }
400
401static inline uint32_t REG_MDP5_PIPE(enum mdp5_pipe i0) { return 0x00001200 + 0x400*i0; }
402
403static inline uint32_t REG_MDP5_PIPE_HIST_CTL_BASE(enum mdp5_pipe i0) { return 0x000014c4 + 0x400*i0; }
404
405static inline uint32_t REG_MDP5_PIPE_HIST_LUT_BASE(enum mdp5_pipe i0) { return 0x000014f0 + 0x400*i0; }
406
407static inline uint32_t REG_MDP5_PIPE_HIST_LUT_SWAP(enum mdp5_pipe i0) { return 0x00001500 + 0x400*i0; }
408
409static inline uint32_t REG_MDP5_PIPE_SRC_SIZE(enum mdp5_pipe i0) { return 0x00001200 + 0x400*i0; }
410#define MDP5_PIPE_SRC_SIZE_HEIGHT__MASK 0xffff0000
411#define MDP5_PIPE_SRC_SIZE_HEIGHT__SHIFT 16
412static inline uint32_t MDP5_PIPE_SRC_SIZE_HEIGHT(uint32_t val)
413{
414 return ((val) << MDP5_PIPE_SRC_SIZE_HEIGHT__SHIFT) & MDP5_PIPE_SRC_SIZE_HEIGHT__MASK;
415}
416#define MDP5_PIPE_SRC_SIZE_WIDTH__MASK 0x0000ffff
417#define MDP5_PIPE_SRC_SIZE_WIDTH__SHIFT 0
418static inline uint32_t MDP5_PIPE_SRC_SIZE_WIDTH(uint32_t val)
419{
420 return ((val) << MDP5_PIPE_SRC_SIZE_WIDTH__SHIFT) & MDP5_PIPE_SRC_SIZE_WIDTH__MASK;
421}
422
423static inline uint32_t REG_MDP5_PIPE_SRC_IMG_SIZE(enum mdp5_pipe i0) { return 0x00001204 + 0x400*i0; }
424#define MDP5_PIPE_SRC_IMG_SIZE_HEIGHT__MASK 0xffff0000
425#define MDP5_PIPE_SRC_IMG_SIZE_HEIGHT__SHIFT 16
426static inline uint32_t MDP5_PIPE_SRC_IMG_SIZE_HEIGHT(uint32_t val)
427{
428 return ((val) << MDP5_PIPE_SRC_IMG_SIZE_HEIGHT__SHIFT) & MDP5_PIPE_SRC_IMG_SIZE_HEIGHT__MASK;
429}
430#define MDP5_PIPE_SRC_IMG_SIZE_WIDTH__MASK 0x0000ffff
431#define MDP5_PIPE_SRC_IMG_SIZE_WIDTH__SHIFT 0
432static inline uint32_t MDP5_PIPE_SRC_IMG_SIZE_WIDTH(uint32_t val)
433{
434 return ((val) << MDP5_PIPE_SRC_IMG_SIZE_WIDTH__SHIFT) & MDP5_PIPE_SRC_IMG_SIZE_WIDTH__MASK;
435}
436
437static inline uint32_t REG_MDP5_PIPE_SRC_XY(enum mdp5_pipe i0) { return 0x00001208 + 0x400*i0; }
438#define MDP5_PIPE_SRC_XY_Y__MASK 0xffff0000
439#define MDP5_PIPE_SRC_XY_Y__SHIFT 16
440static inline uint32_t MDP5_PIPE_SRC_XY_Y(uint32_t val)
441{
442 return ((val) << MDP5_PIPE_SRC_XY_Y__SHIFT) & MDP5_PIPE_SRC_XY_Y__MASK;
443}
444#define MDP5_PIPE_SRC_XY_X__MASK 0x0000ffff
445#define MDP5_PIPE_SRC_XY_X__SHIFT 0
446static inline uint32_t MDP5_PIPE_SRC_XY_X(uint32_t val)
447{
448 return ((val) << MDP5_PIPE_SRC_XY_X__SHIFT) & MDP5_PIPE_SRC_XY_X__MASK;
449}
450
451static inline uint32_t REG_MDP5_PIPE_OUT_SIZE(enum mdp5_pipe i0) { return 0x0000120c + 0x400*i0; }
452#define MDP5_PIPE_OUT_SIZE_HEIGHT__MASK 0xffff0000
453#define MDP5_PIPE_OUT_SIZE_HEIGHT__SHIFT 16
454static inline uint32_t MDP5_PIPE_OUT_SIZE_HEIGHT(uint32_t val)
455{
456 return ((val) << MDP5_PIPE_OUT_SIZE_HEIGHT__SHIFT) & MDP5_PIPE_OUT_SIZE_HEIGHT__MASK;
457}
458#define MDP5_PIPE_OUT_SIZE_WIDTH__MASK 0x0000ffff
459#define MDP5_PIPE_OUT_SIZE_WIDTH__SHIFT 0
460static inline uint32_t MDP5_PIPE_OUT_SIZE_WIDTH(uint32_t val)
461{
462 return ((val) << MDP5_PIPE_OUT_SIZE_WIDTH__SHIFT) & MDP5_PIPE_OUT_SIZE_WIDTH__MASK;
463}
464
465static inline uint32_t REG_MDP5_PIPE_OUT_XY(enum mdp5_pipe i0) { return 0x00001210 + 0x400*i0; }
466#define MDP5_PIPE_OUT_XY_Y__MASK 0xffff0000
467#define MDP5_PIPE_OUT_XY_Y__SHIFT 16
468static inline uint32_t MDP5_PIPE_OUT_XY_Y(uint32_t val)
469{
470 return ((val) << MDP5_PIPE_OUT_XY_Y__SHIFT) & MDP5_PIPE_OUT_XY_Y__MASK;
471}
472#define MDP5_PIPE_OUT_XY_X__MASK 0x0000ffff
473#define MDP5_PIPE_OUT_XY_X__SHIFT 0
474static inline uint32_t MDP5_PIPE_OUT_XY_X(uint32_t val)
475{
476 return ((val) << MDP5_PIPE_OUT_XY_X__SHIFT) & MDP5_PIPE_OUT_XY_X__MASK;
477}
478
479static inline uint32_t REG_MDP5_PIPE_SRC0_ADDR(enum mdp5_pipe i0) { return 0x00001214 + 0x400*i0; }
480
481static inline uint32_t REG_MDP5_PIPE_SRC1_ADDR(enum mdp5_pipe i0) { return 0x00001218 + 0x400*i0; }
482
483static inline uint32_t REG_MDP5_PIPE_SRC2_ADDR(enum mdp5_pipe i0) { return 0x0000121c + 0x400*i0; }
484
485static inline uint32_t REG_MDP5_PIPE_SRC3_ADDR(enum mdp5_pipe i0) { return 0x00001220 + 0x400*i0; }
486
487static inline uint32_t REG_MDP5_PIPE_SRC_STRIDE_A(enum mdp5_pipe i0) { return 0x00001224 + 0x400*i0; }
488#define MDP5_PIPE_SRC_STRIDE_A_P0__MASK 0x0000ffff
489#define MDP5_PIPE_SRC_STRIDE_A_P0__SHIFT 0
490static inline uint32_t MDP5_PIPE_SRC_STRIDE_A_P0(uint32_t val)
491{
492 return ((val) << MDP5_PIPE_SRC_STRIDE_A_P0__SHIFT) & MDP5_PIPE_SRC_STRIDE_A_P0__MASK;
493}
494#define MDP5_PIPE_SRC_STRIDE_A_P1__MASK 0xffff0000
495#define MDP5_PIPE_SRC_STRIDE_A_P1__SHIFT 16
496static inline uint32_t MDP5_PIPE_SRC_STRIDE_A_P1(uint32_t val)
497{
498 return ((val) << MDP5_PIPE_SRC_STRIDE_A_P1__SHIFT) & MDP5_PIPE_SRC_STRIDE_A_P1__MASK;
499}
500
501static inline uint32_t REG_MDP5_PIPE_SRC_STRIDE_B(enum mdp5_pipe i0) { return 0x00001228 + 0x400*i0; }
502#define MDP5_PIPE_SRC_STRIDE_B_P2__MASK 0x0000ffff
503#define MDP5_PIPE_SRC_STRIDE_B_P2__SHIFT 0
504static inline uint32_t MDP5_PIPE_SRC_STRIDE_B_P2(uint32_t val)
505{
506 return ((val) << MDP5_PIPE_SRC_STRIDE_B_P2__SHIFT) & MDP5_PIPE_SRC_STRIDE_B_P2__MASK;
507}
508#define MDP5_PIPE_SRC_STRIDE_B_P3__MASK 0xffff0000
509#define MDP5_PIPE_SRC_STRIDE_B_P3__SHIFT 16
510static inline uint32_t MDP5_PIPE_SRC_STRIDE_B_P3(uint32_t val)
511{
512 return ((val) << MDP5_PIPE_SRC_STRIDE_B_P3__SHIFT) & MDP5_PIPE_SRC_STRIDE_B_P3__MASK;
513}
514
515static inline uint32_t REG_MDP5_PIPE_STILE_FRAME_SIZE(enum mdp5_pipe i0) { return 0x0000122c + 0x400*i0; }
516
517static inline uint32_t REG_MDP5_PIPE_SRC_FORMAT(enum mdp5_pipe i0) { return 0x00001230 + 0x400*i0; }
518#define MDP5_PIPE_SRC_FORMAT_G_BPC__MASK 0x00000003
519#define MDP5_PIPE_SRC_FORMAT_G_BPC__SHIFT 0
520static inline uint32_t MDP5_PIPE_SRC_FORMAT_G_BPC(enum mdp_bpc val)
521{
522 return ((val) << MDP5_PIPE_SRC_FORMAT_G_BPC__SHIFT) & MDP5_PIPE_SRC_FORMAT_G_BPC__MASK;
523}
524#define MDP5_PIPE_SRC_FORMAT_B_BPC__MASK 0x0000000c
525#define MDP5_PIPE_SRC_FORMAT_B_BPC__SHIFT 2
526static inline uint32_t MDP5_PIPE_SRC_FORMAT_B_BPC(enum mdp_bpc val)
527{
528 return ((val) << MDP5_PIPE_SRC_FORMAT_B_BPC__SHIFT) & MDP5_PIPE_SRC_FORMAT_B_BPC__MASK;
529}
530#define MDP5_PIPE_SRC_FORMAT_R_BPC__MASK 0x00000030
531#define MDP5_PIPE_SRC_FORMAT_R_BPC__SHIFT 4
532static inline uint32_t MDP5_PIPE_SRC_FORMAT_R_BPC(enum mdp_bpc val)
533{
534 return ((val) << MDP5_PIPE_SRC_FORMAT_R_BPC__SHIFT) & MDP5_PIPE_SRC_FORMAT_R_BPC__MASK;
535}
536#define MDP5_PIPE_SRC_FORMAT_A_BPC__MASK 0x000000c0
537#define MDP5_PIPE_SRC_FORMAT_A_BPC__SHIFT 6
538static inline uint32_t MDP5_PIPE_SRC_FORMAT_A_BPC(enum mdp_bpc_alpha val)
539{
540 return ((val) << MDP5_PIPE_SRC_FORMAT_A_BPC__SHIFT) & MDP5_PIPE_SRC_FORMAT_A_BPC__MASK;
541}
542#define MDP5_PIPE_SRC_FORMAT_ALPHA_ENABLE 0x00000100
543#define MDP5_PIPE_SRC_FORMAT_CPP__MASK 0x00000600
544#define MDP5_PIPE_SRC_FORMAT_CPP__SHIFT 9
545static inline uint32_t MDP5_PIPE_SRC_FORMAT_CPP(uint32_t val)
546{
547 return ((val) << MDP5_PIPE_SRC_FORMAT_CPP__SHIFT) & MDP5_PIPE_SRC_FORMAT_CPP__MASK;
548}
549#define MDP5_PIPE_SRC_FORMAT_ROT90 0x00000800
550#define MDP5_PIPE_SRC_FORMAT_UNPACK_COUNT__MASK 0x00003000
551#define MDP5_PIPE_SRC_FORMAT_UNPACK_COUNT__SHIFT 12
552static inline uint32_t MDP5_PIPE_SRC_FORMAT_UNPACK_COUNT(uint32_t val)
553{
554 return ((val) << MDP5_PIPE_SRC_FORMAT_UNPACK_COUNT__SHIFT) & MDP5_PIPE_SRC_FORMAT_UNPACK_COUNT__MASK;
555}
556#define MDP5_PIPE_SRC_FORMAT_UNPACK_TIGHT 0x00020000
557#define MDP5_PIPE_SRC_FORMAT_UNPACK_ALIGN_MSB 0x00040000
558#define MDP5_PIPE_SRC_FORMAT_NUM_PLANES__MASK 0x00780000
559#define MDP5_PIPE_SRC_FORMAT_NUM_PLANES__SHIFT 19
560static inline uint32_t MDP5_PIPE_SRC_FORMAT_NUM_PLANES(uint32_t val)
561{
562 return ((val) << MDP5_PIPE_SRC_FORMAT_NUM_PLANES__SHIFT) & MDP5_PIPE_SRC_FORMAT_NUM_PLANES__MASK;
563}
564#define MDP5_PIPE_SRC_FORMAT_CHROMA_SAMP__MASK 0x01800000
565#define MDP5_PIPE_SRC_FORMAT_CHROMA_SAMP__SHIFT 23
566static inline uint32_t MDP5_PIPE_SRC_FORMAT_CHROMA_SAMP(enum mdp5_chroma_samp_type val)
567{
568 return ((val) << MDP5_PIPE_SRC_FORMAT_CHROMA_SAMP__SHIFT) & MDP5_PIPE_SRC_FORMAT_CHROMA_SAMP__MASK;
569}
570
571static inline uint32_t REG_MDP5_PIPE_SRC_UNPACK(enum mdp5_pipe i0) { return 0x00001234 + 0x400*i0; }
572#define MDP5_PIPE_SRC_UNPACK_ELEM0__MASK 0x000000ff
573#define MDP5_PIPE_SRC_UNPACK_ELEM0__SHIFT 0
574static inline uint32_t MDP5_PIPE_SRC_UNPACK_ELEM0(uint32_t val)
575{
576 return ((val) << MDP5_PIPE_SRC_UNPACK_ELEM0__SHIFT) & MDP5_PIPE_SRC_UNPACK_ELEM0__MASK;
577}
578#define MDP5_PIPE_SRC_UNPACK_ELEM1__MASK 0x0000ff00
579#define MDP5_PIPE_SRC_UNPACK_ELEM1__SHIFT 8
580static inline uint32_t MDP5_PIPE_SRC_UNPACK_ELEM1(uint32_t val)
581{
582 return ((val) << MDP5_PIPE_SRC_UNPACK_ELEM1__SHIFT) & MDP5_PIPE_SRC_UNPACK_ELEM1__MASK;
583}
584#define MDP5_PIPE_SRC_UNPACK_ELEM2__MASK 0x00ff0000
585#define MDP5_PIPE_SRC_UNPACK_ELEM2__SHIFT 16
586static inline uint32_t MDP5_PIPE_SRC_UNPACK_ELEM2(uint32_t val)
587{
588 return ((val) << MDP5_PIPE_SRC_UNPACK_ELEM2__SHIFT) & MDP5_PIPE_SRC_UNPACK_ELEM2__MASK;
589}
590#define MDP5_PIPE_SRC_UNPACK_ELEM3__MASK 0xff000000
591#define MDP5_PIPE_SRC_UNPACK_ELEM3__SHIFT 24
592static inline uint32_t MDP5_PIPE_SRC_UNPACK_ELEM3(uint32_t val)
593{
594 return ((val) << MDP5_PIPE_SRC_UNPACK_ELEM3__SHIFT) & MDP5_PIPE_SRC_UNPACK_ELEM3__MASK;
595}
596
597static inline uint32_t REG_MDP5_PIPE_SRC_OP_MODE(enum mdp5_pipe i0) { return 0x00001238 + 0x400*i0; }
598#define MDP5_PIPE_SRC_OP_MODE_BWC_EN 0x00000001
599#define MDP5_PIPE_SRC_OP_MODE_BWC__MASK 0x00000006
600#define MDP5_PIPE_SRC_OP_MODE_BWC__SHIFT 1
601static inline uint32_t MDP5_PIPE_SRC_OP_MODE_BWC(enum mdp5_pipe_bwc val)
602{
603 return ((val) << MDP5_PIPE_SRC_OP_MODE_BWC__SHIFT) & MDP5_PIPE_SRC_OP_MODE_BWC__MASK;
604}
605#define MDP5_PIPE_SRC_OP_MODE_FLIP_LR 0x00002000
606#define MDP5_PIPE_SRC_OP_MODE_FLIP_UD 0x00004000
607#define MDP5_PIPE_SRC_OP_MODE_IGC_EN 0x00010000
608#define MDP5_PIPE_SRC_OP_MODE_IGC_ROM_0 0x00020000
609#define MDP5_PIPE_SRC_OP_MODE_IGC_ROM_1 0x00040000
610#define MDP5_PIPE_SRC_OP_MODE_DEINTERLACE 0x00400000
611#define MDP5_PIPE_SRC_OP_MODE_DEINTERLACE_ODD 0x00800000
612
613static inline uint32_t REG_MDP5_PIPE_SRC_CONSTANT_COLOR(enum mdp5_pipe i0) { return 0x0000123c + 0x400*i0; }
614
615static inline uint32_t REG_MDP5_PIPE_FETCH_CONFIG(enum mdp5_pipe i0) { return 0x00001248 + 0x400*i0; }
616
617static inline uint32_t REG_MDP5_PIPE_VC1_RANGE(enum mdp5_pipe i0) { return 0x0000124c + 0x400*i0; }
618
619static inline uint32_t REG_MDP5_PIPE_REQPRIO_FIFO_WM_0(enum mdp5_pipe i0) { return 0x00001250 + 0x400*i0; }
620
621static inline uint32_t REG_MDP5_PIPE_REQPRIO_FIFO_WM_1(enum mdp5_pipe i0) { return 0x00001254 + 0x400*i0; }
622
623static inline uint32_t REG_MDP5_PIPE_REQPRIO_FIFO_WM_2(enum mdp5_pipe i0) { return 0x00001258 + 0x400*i0; }
624
625static inline uint32_t REG_MDP5_PIPE_SRC_ADDR_SW_STATUS(enum mdp5_pipe i0) { return 0x00001270 + 0x400*i0; }
626
627static inline uint32_t REG_MDP5_PIPE_CURRENT_SRC0_ADDR(enum mdp5_pipe i0) { return 0x000012a4 + 0x400*i0; }
628
629static inline uint32_t REG_MDP5_PIPE_CURRENT_SRC1_ADDR(enum mdp5_pipe i0) { return 0x000012a8 + 0x400*i0; }
630
631static inline uint32_t REG_MDP5_PIPE_CURRENT_SRC2_ADDR(enum mdp5_pipe i0) { return 0x000012ac + 0x400*i0; }
632
633static inline uint32_t REG_MDP5_PIPE_CURRENT_SRC3_ADDR(enum mdp5_pipe i0) { return 0x000012b0 + 0x400*i0; }
634
635static inline uint32_t REG_MDP5_PIPE_DECIMATION(enum mdp5_pipe i0) { return 0x000012b4 + 0x400*i0; }
636#define MDP5_PIPE_DECIMATION_VERT__MASK 0x000000ff
637#define MDP5_PIPE_DECIMATION_VERT__SHIFT 0
638static inline uint32_t MDP5_PIPE_DECIMATION_VERT(uint32_t val)
639{
640 return ((val) << MDP5_PIPE_DECIMATION_VERT__SHIFT) & MDP5_PIPE_DECIMATION_VERT__MASK;
641}
642#define MDP5_PIPE_DECIMATION_HORZ__MASK 0x0000ff00
643#define MDP5_PIPE_DECIMATION_HORZ__SHIFT 8
644static inline uint32_t MDP5_PIPE_DECIMATION_HORZ(uint32_t val)
645{
646 return ((val) << MDP5_PIPE_DECIMATION_HORZ__SHIFT) & MDP5_PIPE_DECIMATION_HORZ__MASK;
647}
648
649static inline uint32_t REG_MDP5_PIPE_SCALE_CONFIG(enum mdp5_pipe i0) { return 0x00001404 + 0x400*i0; }
650#define MDP5_PIPE_SCALE_CONFIG_SCALEX_EN 0x00000001
651#define MDP5_PIPE_SCALE_CONFIG_SCALEY_EN 0x00000002
652#define MDP5_PIPE_SCALE_CONFIG_SCALEX_MIN_FILTER__MASK 0x00000300
653#define MDP5_PIPE_SCALE_CONFIG_SCALEX_MIN_FILTER__SHIFT 8
654static inline uint32_t MDP5_PIPE_SCALE_CONFIG_SCALEX_MIN_FILTER(enum mdp5_scale_filter val)
655{
656 return ((val) << MDP5_PIPE_SCALE_CONFIG_SCALEX_MIN_FILTER__SHIFT) & MDP5_PIPE_SCALE_CONFIG_SCALEX_MIN_FILTER__MASK;
657}
658#define MDP5_PIPE_SCALE_CONFIG_SCALEY_MIN_FILTER__MASK 0x00000c00
659#define MDP5_PIPE_SCALE_CONFIG_SCALEY_MIN_FILTER__SHIFT 10
660static inline uint32_t MDP5_PIPE_SCALE_CONFIG_SCALEY_MIN_FILTER(enum mdp5_scale_filter val)
661{
662 return ((val) << MDP5_PIPE_SCALE_CONFIG_SCALEY_MIN_FILTER__SHIFT) & MDP5_PIPE_SCALE_CONFIG_SCALEY_MIN_FILTER__MASK;
663}
664#define MDP5_PIPE_SCALE_CONFIG_SCALEX_CR_FILTER__MASK 0x00003000
665#define MDP5_PIPE_SCALE_CONFIG_SCALEX_CR_FILTER__SHIFT 12
666static inline uint32_t MDP5_PIPE_SCALE_CONFIG_SCALEX_CR_FILTER(enum mdp5_scale_filter val)
667{
668 return ((val) << MDP5_PIPE_SCALE_CONFIG_SCALEX_CR_FILTER__SHIFT) & MDP5_PIPE_SCALE_CONFIG_SCALEX_CR_FILTER__MASK;
669}
670#define MDP5_PIPE_SCALE_CONFIG_SCALEY_CR_FILTER__MASK 0x0000c000
671#define MDP5_PIPE_SCALE_CONFIG_SCALEY_CR_FILTER__SHIFT 14
672static inline uint32_t MDP5_PIPE_SCALE_CONFIG_SCALEY_CR_FILTER(enum mdp5_scale_filter val)
673{
674 return ((val) << MDP5_PIPE_SCALE_CONFIG_SCALEY_CR_FILTER__SHIFT) & MDP5_PIPE_SCALE_CONFIG_SCALEY_CR_FILTER__MASK;
675}
676#define MDP5_PIPE_SCALE_CONFIG_SCALEX_MAX_FILTER__MASK 0x00030000
677#define MDP5_PIPE_SCALE_CONFIG_SCALEX_MAX_FILTER__SHIFT 16
678static inline uint32_t MDP5_PIPE_SCALE_CONFIG_SCALEX_MAX_FILTER(enum mdp5_scale_filter val)
679{
680 return ((val) << MDP5_PIPE_SCALE_CONFIG_SCALEX_MAX_FILTER__SHIFT) & MDP5_PIPE_SCALE_CONFIG_SCALEX_MAX_FILTER__MASK;
681}
682#define MDP5_PIPE_SCALE_CONFIG_SCALEY_MAX_FILTER__MASK 0x000c0000
683#define MDP5_PIPE_SCALE_CONFIG_SCALEY_MAX_FILTER__SHIFT 18
684static inline uint32_t MDP5_PIPE_SCALE_CONFIG_SCALEY_MAX_FILTER(enum mdp5_scale_filter val)
685{
686 return ((val) << MDP5_PIPE_SCALE_CONFIG_SCALEY_MAX_FILTER__SHIFT) & MDP5_PIPE_SCALE_CONFIG_SCALEY_MAX_FILTER__MASK;
687}
688
689static inline uint32_t REG_MDP5_PIPE_SCALE_PHASE_STEP_X(enum mdp5_pipe i0) { return 0x00001410 + 0x400*i0; }
690
691static inline uint32_t REG_MDP5_PIPE_SCALE_PHASE_STEP_Y(enum mdp5_pipe i0) { return 0x00001414 + 0x400*i0; }
692
693static inline uint32_t REG_MDP5_PIPE_SCALE_INIT_PHASE_X(enum mdp5_pipe i0) { return 0x00001420 + 0x400*i0; }
694
695static inline uint32_t REG_MDP5_PIPE_SCALE_INIT_PHASE_Y(enum mdp5_pipe i0) { return 0x00001424 + 0x400*i0; }
696
697static inline uint32_t REG_MDP5_LM(uint32_t i0) { return 0x00003200 + 0x400*i0; }
698
699static inline uint32_t REG_MDP5_LM_BLEND_COLOR_OUT(uint32_t i0) { return 0x00003200 + 0x400*i0; }
700#define MDP5_LM_BLEND_COLOR_OUT_STAGE0_FG_ALPHA 0x00000002
701#define MDP5_LM_BLEND_COLOR_OUT_STAGE1_FG_ALPHA 0x00000004
702#define MDP5_LM_BLEND_COLOR_OUT_STAGE2_FG_ALPHA 0x00000008
703#define MDP5_LM_BLEND_COLOR_OUT_STAGE3_FG_ALPHA 0x00000010
704
705static inline uint32_t REG_MDP5_LM_OUT_SIZE(uint32_t i0) { return 0x00003204 + 0x400*i0; }
706#define MDP5_LM_OUT_SIZE_HEIGHT__MASK 0xffff0000
707#define MDP5_LM_OUT_SIZE_HEIGHT__SHIFT 16
708static inline uint32_t MDP5_LM_OUT_SIZE_HEIGHT(uint32_t val)
709{
710 return ((val) << MDP5_LM_OUT_SIZE_HEIGHT__SHIFT) & MDP5_LM_OUT_SIZE_HEIGHT__MASK;
711}
712#define MDP5_LM_OUT_SIZE_WIDTH__MASK 0x0000ffff
713#define MDP5_LM_OUT_SIZE_WIDTH__SHIFT 0
714static inline uint32_t MDP5_LM_OUT_SIZE_WIDTH(uint32_t val)
715{
716 return ((val) << MDP5_LM_OUT_SIZE_WIDTH__SHIFT) & MDP5_LM_OUT_SIZE_WIDTH__MASK;
717}
718
719static inline uint32_t REG_MDP5_LM_BORDER_COLOR_0(uint32_t i0) { return 0x00003208 + 0x400*i0; }
720
721static inline uint32_t REG_MDP5_LM_BORDER_COLOR_1(uint32_t i0) { return 0x00003210 + 0x400*i0; }
722
723static inline uint32_t REG_MDP5_LM_BLEND(uint32_t i0, uint32_t i1) { return 0x00003220 + 0x400*i0 + 0x30*i1; }
724
725static inline uint32_t REG_MDP5_LM_BLEND_OP_MODE(uint32_t i0, uint32_t i1) { return 0x00003220 + 0x400*i0 + 0x30*i1; }
726#define MDP5_LM_BLEND_OP_MODE_FG_ALPHA__MASK 0x00000003
727#define MDP5_LM_BLEND_OP_MODE_FG_ALPHA__SHIFT 0
728static inline uint32_t MDP5_LM_BLEND_OP_MODE_FG_ALPHA(enum mdp_alpha_type val)
729{
730 return ((val) << MDP5_LM_BLEND_OP_MODE_FG_ALPHA__SHIFT) & MDP5_LM_BLEND_OP_MODE_FG_ALPHA__MASK;
731}
732#define MDP5_LM_BLEND_OP_MODE_FG_INV_ALPHA 0x00000004
733#define MDP5_LM_BLEND_OP_MODE_FG_MOD_ALPHA 0x00000008
734#define MDP5_LM_BLEND_OP_MODE_FG_INV_MOD_ALPHA 0x00000010
735#define MDP5_LM_BLEND_OP_MODE_FG_TRANSP_EN 0x00000020
736#define MDP5_LM_BLEND_OP_MODE_BG_ALPHA__MASK 0x00000300
737#define MDP5_LM_BLEND_OP_MODE_BG_ALPHA__SHIFT 8
738static inline uint32_t MDP5_LM_BLEND_OP_MODE_BG_ALPHA(enum mdp_alpha_type val)
739{
740 return ((val) << MDP5_LM_BLEND_OP_MODE_BG_ALPHA__SHIFT) & MDP5_LM_BLEND_OP_MODE_BG_ALPHA__MASK;
741}
742#define MDP5_LM_BLEND_OP_MODE_BG_INV_ALPHA 0x00000400
743#define MDP5_LM_BLEND_OP_MODE_BG_MOD_ALPHA 0x00000800
744#define MDP5_LM_BLEND_OP_MODE_BG_INV_MOD_ALPHA 0x00001000
745#define MDP5_LM_BLEND_OP_MODE_BG_TRANSP_EN 0x00002000
746
747static inline uint32_t REG_MDP5_LM_BLEND_FG_ALPHA(uint32_t i0, uint32_t i1) { return 0x00003224 + 0x400*i0 + 0x30*i1; }
748
749static inline uint32_t REG_MDP5_LM_BLEND_BG_ALPHA(uint32_t i0, uint32_t i1) { return 0x00003228 + 0x400*i0 + 0x30*i1; }
750
751static inline uint32_t REG_MDP5_LM_BLEND_FG_TRANSP_LOW0(uint32_t i0, uint32_t i1) { return 0x0000322c + 0x400*i0 + 0x30*i1; }
752
753static inline uint32_t REG_MDP5_LM_BLEND_FG_TRANSP_LOW1(uint32_t i0, uint32_t i1) { return 0x00003230 + 0x400*i0 + 0x30*i1; }
754
755static inline uint32_t REG_MDP5_LM_BLEND_FG_TRANSP_HIGH0(uint32_t i0, uint32_t i1) { return 0x00003234 + 0x400*i0 + 0x30*i1; }
756
757static inline uint32_t REG_MDP5_LM_BLEND_FG_TRANSP_HIGH1(uint32_t i0, uint32_t i1) { return 0x00003238 + 0x400*i0 + 0x30*i1; }
758
759static inline uint32_t REG_MDP5_LM_BLEND_BG_TRANSP_LOW0(uint32_t i0, uint32_t i1) { return 0x0000323c + 0x400*i0 + 0x30*i1; }
760
761static inline uint32_t REG_MDP5_LM_BLEND_BG_TRANSP_LOW1(uint32_t i0, uint32_t i1) { return 0x00003240 + 0x400*i0 + 0x30*i1; }
762
763static inline uint32_t REG_MDP5_LM_BLEND_BG_TRANSP_HIGH0(uint32_t i0, uint32_t i1) { return 0x00003244 + 0x400*i0 + 0x30*i1; }
764
765static inline uint32_t REG_MDP5_LM_BLEND_BG_TRANSP_HIGH1(uint32_t i0, uint32_t i1) { return 0x00003248 + 0x400*i0 + 0x30*i1; }
766
767static inline uint32_t REG_MDP5_LM_CURSOR_IMG_SIZE(uint32_t i0) { return 0x000032e0 + 0x400*i0; }
768
769static inline uint32_t REG_MDP5_LM_CURSOR_SIZE(uint32_t i0) { return 0x000032e4 + 0x400*i0; }
770
771static inline uint32_t REG_MDP5_LM_CURSOR_XY(uint32_t i0) { return 0x000032e8 + 0x400*i0; }
772
773static inline uint32_t REG_MDP5_LM_CURSOR_STRIDE(uint32_t i0) { return 0x000032dc + 0x400*i0; }
774
775static inline uint32_t REG_MDP5_LM_CURSOR_FORMAT(uint32_t i0) { return 0x000032ec + 0x400*i0; }
776
777static inline uint32_t REG_MDP5_LM_CURSOR_BASE_ADDR(uint32_t i0) { return 0x000032f0 + 0x400*i0; }
778
779static inline uint32_t REG_MDP5_LM_CURSOR_START_XY(uint32_t i0) { return 0x000032f4 + 0x400*i0; }
780
781static inline uint32_t REG_MDP5_LM_CURSOR_BLEND_CONFIG(uint32_t i0) { return 0x000032f8 + 0x400*i0; }
782
783static inline uint32_t REG_MDP5_LM_CURSOR_BLEND_PARAM(uint32_t i0) { return 0x000032fc + 0x400*i0; }
784
785static inline uint32_t REG_MDP5_LM_CURSOR_BLEND_TRANSP_LOW0(uint32_t i0) { return 0x00003300 + 0x400*i0; }
786
787static inline uint32_t REG_MDP5_LM_CURSOR_BLEND_TRANSP_LOW1(uint32_t i0) { return 0x00003304 + 0x400*i0; }
788
789static inline uint32_t REG_MDP5_LM_CURSOR_BLEND_TRANSP_HIGH0(uint32_t i0) { return 0x00003308 + 0x400*i0; }
790
791static inline uint32_t REG_MDP5_LM_CURSOR_BLEND_TRANSP_HIGH1(uint32_t i0) { return 0x0000330c + 0x400*i0; }
792
793static inline uint32_t REG_MDP5_LM_GC_LUT_BASE(uint32_t i0) { return 0x00003310 + 0x400*i0; }
794
795static inline uint32_t REG_MDP5_DSPP(uint32_t i0) { return 0x00004600 + 0x400*i0; }
796
797static inline uint32_t REG_MDP5_DSPP_OP_MODE(uint32_t i0) { return 0x00004600 + 0x400*i0; }
798#define MDP5_DSPP_OP_MODE_IGC_LUT_EN 0x00000001
799#define MDP5_DSPP_OP_MODE_IGC_TBL_IDX__MASK 0x0000000e
800#define MDP5_DSPP_OP_MODE_IGC_TBL_IDX__SHIFT 1
801static inline uint32_t MDP5_DSPP_OP_MODE_IGC_TBL_IDX(uint32_t val)
802{
803 return ((val) << MDP5_DSPP_OP_MODE_IGC_TBL_IDX__SHIFT) & MDP5_DSPP_OP_MODE_IGC_TBL_IDX__MASK;
804}
805#define MDP5_DSPP_OP_MODE_PCC_EN 0x00000010
806#define MDP5_DSPP_OP_MODE_DITHER_EN 0x00000100
807#define MDP5_DSPP_OP_MODE_HIST_EN 0x00010000
808#define MDP5_DSPP_OP_MODE_AUTO_CLEAR 0x00020000
809#define MDP5_DSPP_OP_MODE_HIST_LUT_EN 0x00080000
810#define MDP5_DSPP_OP_MODE_PA_EN 0x00100000
811#define MDP5_DSPP_OP_MODE_GAMUT_EN 0x00800000
812#define MDP5_DSPP_OP_MODE_GAMUT_ORDER 0x01000000
813
814static inline uint32_t REG_MDP5_DSPP_PCC_BASE(uint32_t i0) { return 0x00004630 + 0x400*i0; }
815
816static inline uint32_t REG_MDP5_DSPP_DITHER_DEPTH(uint32_t i0) { return 0x00004750 + 0x400*i0; }
817
818static inline uint32_t REG_MDP5_DSPP_HIST_CTL_BASE(uint32_t i0) { return 0x00004810 + 0x400*i0; }
819
820static inline uint32_t REG_MDP5_DSPP_HIST_LUT_BASE(uint32_t i0) { return 0x00004830 + 0x400*i0; }
821
822static inline uint32_t REG_MDP5_DSPP_HIST_LUT_SWAP(uint32_t i0) { return 0x00004834 + 0x400*i0; }
823
824static inline uint32_t REG_MDP5_DSPP_PA_BASE(uint32_t i0) { return 0x00004838 + 0x400*i0; }
825
826static inline uint32_t REG_MDP5_DSPP_GAMUT_BASE(uint32_t i0) { return 0x000048dc + 0x400*i0; }
827
828static inline uint32_t REG_MDP5_DSPP_GC_BASE(uint32_t i0) { return 0x000048b0 + 0x400*i0; }
829
830static inline uint32_t REG_MDP5_INTF(uint32_t i0) { return 0x00012500 + 0x200*i0; }
831
832static inline uint32_t REG_MDP5_INTF_TIMING_ENGINE_EN(uint32_t i0) { return 0x00012500 + 0x200*i0; }
833
834static inline uint32_t REG_MDP5_INTF_CONFIG(uint32_t i0) { return 0x00012504 + 0x200*i0; }
835
836static inline uint32_t REG_MDP5_INTF_HSYNC_CTL(uint32_t i0) { return 0x00012508 + 0x200*i0; }
837#define MDP5_INTF_HSYNC_CTL_PULSEW__MASK 0x0000ffff
838#define MDP5_INTF_HSYNC_CTL_PULSEW__SHIFT 0
839static inline uint32_t MDP5_INTF_HSYNC_CTL_PULSEW(uint32_t val)
840{
841 return ((val) << MDP5_INTF_HSYNC_CTL_PULSEW__SHIFT) & MDP5_INTF_HSYNC_CTL_PULSEW__MASK;
842}
843#define MDP5_INTF_HSYNC_CTL_PERIOD__MASK 0xffff0000
844#define MDP5_INTF_HSYNC_CTL_PERIOD__SHIFT 16
845static inline uint32_t MDP5_INTF_HSYNC_CTL_PERIOD(uint32_t val)
846{
847 return ((val) << MDP5_INTF_HSYNC_CTL_PERIOD__SHIFT) & MDP5_INTF_HSYNC_CTL_PERIOD__MASK;
848}
849
850static inline uint32_t REG_MDP5_INTF_VSYNC_PERIOD_F0(uint32_t i0) { return 0x0001250c + 0x200*i0; }
851
852static inline uint32_t REG_MDP5_INTF_VSYNC_PERIOD_F1(uint32_t i0) { return 0x00012510 + 0x200*i0; }
853
854static inline uint32_t REG_MDP5_INTF_VSYNC_LEN_F0(uint32_t i0) { return 0x00012514 + 0x200*i0; }
855
856static inline uint32_t REG_MDP5_INTF_VSYNC_LEN_F1(uint32_t i0) { return 0x00012518 + 0x200*i0; }
857
858static inline uint32_t REG_MDP5_INTF_DISPLAY_VSTART_F0(uint32_t i0) { return 0x0001251c + 0x200*i0; }
859
860static inline uint32_t REG_MDP5_INTF_DISPLAY_VSTART_F1(uint32_t i0) { return 0x00012520 + 0x200*i0; }
861
862static inline uint32_t REG_MDP5_INTF_DISPLAY_VEND_F0(uint32_t i0) { return 0x00012524 + 0x200*i0; }
863
864static inline uint32_t REG_MDP5_INTF_DISPLAY_VEND_F1(uint32_t i0) { return 0x00012528 + 0x200*i0; }
865
866static inline uint32_t REG_MDP5_INTF_ACTIVE_VSTART_F0(uint32_t i0) { return 0x0001252c + 0x200*i0; }
867#define MDP5_INTF_ACTIVE_VSTART_F0_VAL__MASK 0x7fffffff
868#define MDP5_INTF_ACTIVE_VSTART_F0_VAL__SHIFT 0
869static inline uint32_t MDP5_INTF_ACTIVE_VSTART_F0_VAL(uint32_t val)
870{
871 return ((val) << MDP5_INTF_ACTIVE_VSTART_F0_VAL__SHIFT) & MDP5_INTF_ACTIVE_VSTART_F0_VAL__MASK;
872}
873#define MDP5_INTF_ACTIVE_VSTART_F0_ACTIVE_V_ENABLE 0x80000000
874
875static inline uint32_t REG_MDP5_INTF_ACTIVE_VSTART_F1(uint32_t i0) { return 0x00012530 + 0x200*i0; }
876#define MDP5_INTF_ACTIVE_VSTART_F1_VAL__MASK 0x7fffffff
877#define MDP5_INTF_ACTIVE_VSTART_F1_VAL__SHIFT 0
878static inline uint32_t MDP5_INTF_ACTIVE_VSTART_F1_VAL(uint32_t val)
879{
880 return ((val) << MDP5_INTF_ACTIVE_VSTART_F1_VAL__SHIFT) & MDP5_INTF_ACTIVE_VSTART_F1_VAL__MASK;
881}
882
883static inline uint32_t REG_MDP5_INTF_ACTIVE_VEND_F0(uint32_t i0) { return 0x00012534 + 0x200*i0; }
884
885static inline uint32_t REG_MDP5_INTF_ACTIVE_VEND_F1(uint32_t i0) { return 0x00012538 + 0x200*i0; }
886
887static inline uint32_t REG_MDP5_INTF_DISPLAY_HCTL(uint32_t i0) { return 0x0001253c + 0x200*i0; }
888#define MDP5_INTF_DISPLAY_HCTL_START__MASK 0x0000ffff
889#define MDP5_INTF_DISPLAY_HCTL_START__SHIFT 0
890static inline uint32_t MDP5_INTF_DISPLAY_HCTL_START(uint32_t val)
891{
892 return ((val) << MDP5_INTF_DISPLAY_HCTL_START__SHIFT) & MDP5_INTF_DISPLAY_HCTL_START__MASK;
893}
894#define MDP5_INTF_DISPLAY_HCTL_END__MASK 0xffff0000
895#define MDP5_INTF_DISPLAY_HCTL_END__SHIFT 16
896static inline uint32_t MDP5_INTF_DISPLAY_HCTL_END(uint32_t val)
897{
898 return ((val) << MDP5_INTF_DISPLAY_HCTL_END__SHIFT) & MDP5_INTF_DISPLAY_HCTL_END__MASK;
899}
900
901static inline uint32_t REG_MDP5_INTF_ACTIVE_HCTL(uint32_t i0) { return 0x00012540 + 0x200*i0; }
902#define MDP5_INTF_ACTIVE_HCTL_START__MASK 0x00007fff
903#define MDP5_INTF_ACTIVE_HCTL_START__SHIFT 0
904static inline uint32_t MDP5_INTF_ACTIVE_HCTL_START(uint32_t val)
905{
906 return ((val) << MDP5_INTF_ACTIVE_HCTL_START__SHIFT) & MDP5_INTF_ACTIVE_HCTL_START__MASK;
907}
908#define MDP5_INTF_ACTIVE_HCTL_END__MASK 0x7fff0000
909#define MDP5_INTF_ACTIVE_HCTL_END__SHIFT 16
910static inline uint32_t MDP5_INTF_ACTIVE_HCTL_END(uint32_t val)
911{
912 return ((val) << MDP5_INTF_ACTIVE_HCTL_END__SHIFT) & MDP5_INTF_ACTIVE_HCTL_END__MASK;
913}
914#define MDP5_INTF_ACTIVE_HCTL_ACTIVE_H_ENABLE 0x80000000
915
916static inline uint32_t REG_MDP5_INTF_BORDER_COLOR(uint32_t i0) { return 0x00012544 + 0x200*i0; }
917
918static inline uint32_t REG_MDP5_INTF_UNDERFLOW_COLOR(uint32_t i0) { return 0x00012548 + 0x200*i0; }
919
920static inline uint32_t REG_MDP5_INTF_HSYNC_SKEW(uint32_t i0) { return 0x0001254c + 0x200*i0; }
921
922static inline uint32_t REG_MDP5_INTF_POLARITY_CTL(uint32_t i0) { return 0x00012550 + 0x200*i0; }
923#define MDP5_INTF_POLARITY_CTL_HSYNC_LOW 0x00000001
924#define MDP5_INTF_POLARITY_CTL_VSYNC_LOW 0x00000002
925#define MDP5_INTF_POLARITY_CTL_DATA_EN_LOW 0x00000004
926
927static inline uint32_t REG_MDP5_INTF_TEST_CTL(uint32_t i0) { return 0x00012554 + 0x200*i0; }
928
929static inline uint32_t REG_MDP5_INTF_TP_COLOR0(uint32_t i0) { return 0x00012558 + 0x200*i0; }
930
931static inline uint32_t REG_MDP5_INTF_TP_COLOR1(uint32_t i0) { return 0x0001255c + 0x200*i0; }
932
933static inline uint32_t REG_MDP5_INTF_DSI_CMD_MODE_TRIGGER_EN(uint32_t i0) { return 0x00012584 + 0x200*i0; }
934
935static inline uint32_t REG_MDP5_INTF_PANEL_FORMAT(uint32_t i0) { return 0x00012590 + 0x200*i0; }
936
937static inline uint32_t REG_MDP5_INTF_FRAME_LINE_COUNT_EN(uint32_t i0) { return 0x000125a8 + 0x200*i0; }
938
939static inline uint32_t REG_MDP5_INTF_FRAME_COUNT(uint32_t i0) { return 0x000125ac + 0x200*i0; }
940
941static inline uint32_t REG_MDP5_INTF_LINE_COUNT(uint32_t i0) { return 0x000125b0 + 0x200*i0; }
942
943static inline uint32_t REG_MDP5_INTF_DEFLICKER_CONFIG(uint32_t i0) { return 0x000125f0 + 0x200*i0; }
944
945static inline uint32_t REG_MDP5_INTF_DEFLICKER_STRNG_COEFF(uint32_t i0) { return 0x000125f4 + 0x200*i0; }
946
947static inline uint32_t REG_MDP5_INTF_DEFLICKER_WEAK_COEFF(uint32_t i0) { return 0x000125f8 + 0x200*i0; }
948
949static inline uint32_t REG_MDP5_INTF_TPG_ENABLE(uint32_t i0) { return 0x00012600 + 0x200*i0; }
950
951static inline uint32_t REG_MDP5_INTF_TPG_MAIN_CONTROL(uint32_t i0) { return 0x00012604 + 0x200*i0; }
952
953static inline uint32_t REG_MDP5_INTF_TPG_VIDEO_CONFIG(uint32_t i0) { return 0x00012608 + 0x200*i0; }
954
955static inline uint32_t REG_MDP5_INTF_TPG_COMPONENT_LIMITS(uint32_t i0) { return 0x0001260c + 0x200*i0; }
956
957static inline uint32_t REG_MDP5_INTF_TPG_RECTANGLE(uint32_t i0) { return 0x00012610 + 0x200*i0; }
958
959static inline uint32_t REG_MDP5_INTF_TPG_INITIAL_VALUE(uint32_t i0) { return 0x00012614 + 0x200*i0; }
960
961static inline uint32_t REG_MDP5_INTF_TPG_BLK_WHITE_PATTERN_FRAME(uint32_t i0) { return 0x00012618 + 0x200*i0; }
962
963static inline uint32_t REG_MDP5_INTF_TPG_RGB_MAPPING(uint32_t i0) { return 0x0001261c + 0x200*i0; }
964
965static inline uint32_t REG_MDP5_AD(uint32_t i0) { return 0x00013100 + 0x200*i0; }
966
967static inline uint32_t REG_MDP5_AD_BYPASS(uint32_t i0) { return 0x00013100 + 0x200*i0; }
968
969static inline uint32_t REG_MDP5_AD_CTRL_0(uint32_t i0) { return 0x00013104 + 0x200*i0; }
970
971static inline uint32_t REG_MDP5_AD_CTRL_1(uint32_t i0) { return 0x00013108 + 0x200*i0; }
972
973static inline uint32_t REG_MDP5_AD_FRAME_SIZE(uint32_t i0) { return 0x0001310c + 0x200*i0; }
974
975static inline uint32_t REG_MDP5_AD_CON_CTRL_0(uint32_t i0) { return 0x00013110 + 0x200*i0; }
976
977static inline uint32_t REG_MDP5_AD_CON_CTRL_1(uint32_t i0) { return 0x00013114 + 0x200*i0; }
978
979static inline uint32_t REG_MDP5_AD_STR_MAN(uint32_t i0) { return 0x00013118 + 0x200*i0; }
980
981static inline uint32_t REG_MDP5_AD_VAR(uint32_t i0) { return 0x0001311c + 0x200*i0; }
982
983static inline uint32_t REG_MDP5_AD_DITH(uint32_t i0) { return 0x00013120 + 0x200*i0; }
984
985static inline uint32_t REG_MDP5_AD_DITH_CTRL(uint32_t i0) { return 0x00013124 + 0x200*i0; }
986
987static inline uint32_t REG_MDP5_AD_AMP_LIM(uint32_t i0) { return 0x00013128 + 0x200*i0; }
988
989static inline uint32_t REG_MDP5_AD_SLOPE(uint32_t i0) { return 0x0001312c + 0x200*i0; }
990
991static inline uint32_t REG_MDP5_AD_BW_LVL(uint32_t i0) { return 0x00013130 + 0x200*i0; }
992
993static inline uint32_t REG_MDP5_AD_LOGO_POS(uint32_t i0) { return 0x00013134 + 0x200*i0; }
994
995static inline uint32_t REG_MDP5_AD_LUT_FI(uint32_t i0) { return 0x00013138 + 0x200*i0; }
996
997static inline uint32_t REG_MDP5_AD_LUT_CC(uint32_t i0) { return 0x0001317c + 0x200*i0; }
998
999static inline uint32_t REG_MDP5_AD_STR_LIM(uint32_t i0) { return 0x000131c8 + 0x200*i0; }
1000
1001static inline uint32_t REG_MDP5_AD_CALIB_AB(uint32_t i0) { return 0x000131cc + 0x200*i0; }
1002
1003static inline uint32_t REG_MDP5_AD_CALIB_CD(uint32_t i0) { return 0x000131d0 + 0x200*i0; }
1004
1005static inline uint32_t REG_MDP5_AD_MODE_SEL(uint32_t i0) { return 0x000131d4 + 0x200*i0; }
1006
1007static inline uint32_t REG_MDP5_AD_TFILT_CTRL(uint32_t i0) { return 0x000131d8 + 0x200*i0; }
1008
1009static inline uint32_t REG_MDP5_AD_BL_MINMAX(uint32_t i0) { return 0x000131dc + 0x200*i0; }
1010
1011static inline uint32_t REG_MDP5_AD_BL(uint32_t i0) { return 0x000131e0 + 0x200*i0; }
1012
1013static inline uint32_t REG_MDP5_AD_BL_MAX(uint32_t i0) { return 0x000131e8 + 0x200*i0; }
1014
1015static inline uint32_t REG_MDP5_AD_AL(uint32_t i0) { return 0x000131ec + 0x200*i0; }
1016
1017static inline uint32_t REG_MDP5_AD_AL_MIN(uint32_t i0) { return 0x000131f0 + 0x200*i0; }
1018
1019static inline uint32_t REG_MDP5_AD_AL_FILT(uint32_t i0) { return 0x000131f4 + 0x200*i0; }
1020
1021static inline uint32_t REG_MDP5_AD_CFG_BUF(uint32_t i0) { return 0x000131f8 + 0x200*i0; }
1022
1023static inline uint32_t REG_MDP5_AD_LUT_AL(uint32_t i0) { return 0x00013200 + 0x200*i0; }
1024
1025static inline uint32_t REG_MDP5_AD_TARG_STR(uint32_t i0) { return 0x00013244 + 0x200*i0; }
1026
1027static inline uint32_t REG_MDP5_AD_START_CALC(uint32_t i0) { return 0x00013248 + 0x200*i0; }
1028
1029static inline uint32_t REG_MDP5_AD_STR_OUT(uint32_t i0) { return 0x0001324c + 0x200*i0; }
1030
1031static inline uint32_t REG_MDP5_AD_BL_OUT(uint32_t i0) { return 0x00013254 + 0x200*i0; }
1032
1033static inline uint32_t REG_MDP5_AD_CALC_DONE(uint32_t i0) { return 0x00013258 + 0x200*i0; }
1034
1035
1036#endif /* MDP5_XML */
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
new file mode 100644
index 000000000000..71a3b2345eb3
--- /dev/null
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
@@ -0,0 +1,569 @@
1/*
2 * Copyright (C) 2013 Red Hat
3 * Author: Rob Clark <robdclark@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "mdp5_kms.h"
19
20#include <drm/drm_mode.h>
21#include "drm_crtc.h"
22#include "drm_crtc_helper.h"
23#include "drm_flip_work.h"
24
25struct mdp5_crtc {
26 struct drm_crtc base;
27 char name[8];
28 struct drm_plane *plane;
29 struct drm_plane *planes[8];
30 int id;
31 bool enabled;
32
33 /* which mixer/encoder we route output to: */
34 int mixer;
35
36 /* if there is a pending flip, these will be non-null: */
37 struct drm_pending_vblank_event *event;
38 struct msm_fence_cb pageflip_cb;
39
40#define PENDING_CURSOR 0x1
41#define PENDING_FLIP 0x2
42 atomic_t pending;
43
44 /* the fb that we logically (from PoV of KMS API) hold a ref
45 * to. Which we may not yet be scanning out (we may still
46 * be scanning out previous in case of page_flip while waiting
47 * for gpu rendering to complete:
48 */
49 struct drm_framebuffer *fb;
50
51 /* the fb that we currently hold a scanout ref to: */
52 struct drm_framebuffer *scanout_fb;
53
54 /* for unref'ing framebuffers after scanout completes: */
55 struct drm_flip_work unref_fb_work;
56
57 struct mdp_irq vblank;
58 struct mdp_irq err;
59};
60#define to_mdp5_crtc(x) container_of(x, struct mdp5_crtc, base)
61
62static struct mdp5_kms *get_kms(struct drm_crtc *crtc)
63{
64 struct msm_drm_private *priv = crtc->dev->dev_private;
65 return to_mdp5_kms(to_mdp_kms(priv->kms));
66}
67
68static void request_pending(struct drm_crtc *crtc, uint32_t pending)
69{
70 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
71
72 atomic_or(pending, &mdp5_crtc->pending);
73 mdp_irq_register(&get_kms(crtc)->base, &mdp5_crtc->vblank);
74}
75
76static void crtc_flush(struct drm_crtc *crtc)
77{
78 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
79 struct mdp5_kms *mdp5_kms = get_kms(crtc);
80 int id = mdp5_crtc->id;
81 uint32_t i, flush = 0;
82
83 for (i = 0; i < ARRAY_SIZE(mdp5_crtc->planes); i++) {
84 struct drm_plane *plane = mdp5_crtc->planes[i];
85 if (plane) {
86 enum mdp5_pipe pipe = mdp5_plane_pipe(plane);
87 flush |= pipe2flush(pipe);
88 }
89 }
90 flush |= mixer2flush(mdp5_crtc->id);
91 flush |= MDP5_CTL_FLUSH_CTL;
92
93 DBG("%s: flush=%08x", mdp5_crtc->name, flush);
94
95 mdp5_write(mdp5_kms, REG_MDP5_CTL_FLUSH(id), flush);
96}
97
98static void update_fb(struct drm_crtc *crtc, struct drm_framebuffer *new_fb)
99{
100 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
101 struct drm_framebuffer *old_fb = mdp5_crtc->fb;
102
103 /* grab reference to incoming scanout fb: */
104 drm_framebuffer_reference(new_fb);
105 mdp5_crtc->base.fb = new_fb;
106 mdp5_crtc->fb = new_fb;
107
108 if (old_fb)
109 drm_flip_work_queue(&mdp5_crtc->unref_fb_work, old_fb);
110}
111
112/* unlike update_fb(), take a ref to the new scanout fb *before* updating
113 * plane, then call this. Needed to ensure we don't unref the buffer that
114 * is actually still being scanned out.
115 *
116 * Note that this whole thing goes away with atomic.. since we can defer
117 * calling into driver until rendering is done.
118 */
119static void update_scanout(struct drm_crtc *crtc, struct drm_framebuffer *fb)
120{
121 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
122
123 /* flush updates, to make sure hw is updated to new scanout fb,
124 * so that we can safely queue unref to current fb (ie. next
125 * vblank we know hw is done w/ previous scanout_fb).
126 */
127 crtc_flush(crtc);
128
129 if (mdp5_crtc->scanout_fb)
130 drm_flip_work_queue(&mdp5_crtc->unref_fb_work,
131 mdp5_crtc->scanout_fb);
132
133 mdp5_crtc->scanout_fb = fb;
134
135 /* enable vblank to complete flip: */
136 request_pending(crtc, PENDING_FLIP);
137}
138
139/* if file!=NULL, this is preclose potential cancel-flip path */
140static void complete_flip(struct drm_crtc *crtc, struct drm_file *file)
141{
142 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
143 struct drm_device *dev = crtc->dev;
144 struct drm_pending_vblank_event *event;
145 unsigned long flags, i;
146
147 spin_lock_irqsave(&dev->event_lock, flags);
148 event = mdp5_crtc->event;
149 if (event) {
150 /* if regular vblank case (!file) or if cancel-flip from
151 * preclose on file that requested flip, then send the
152 * event:
153 */
154 if (!file || (event->base.file_priv == file)) {
155 mdp5_crtc->event = NULL;
156 drm_send_vblank_event(dev, mdp5_crtc->id, event);
157 }
158 }
159 spin_unlock_irqrestore(&dev->event_lock, flags);
160
161 for (i = 0; i < ARRAY_SIZE(mdp5_crtc->planes); i++) {
162 struct drm_plane *plane = mdp5_crtc->planes[i];
163 if (plane)
164 mdp5_plane_complete_flip(plane);
165 }
166}
167
168static void pageflip_cb(struct msm_fence_cb *cb)
169{
170 struct mdp5_crtc *mdp5_crtc =
171 container_of(cb, struct mdp5_crtc, pageflip_cb);
172 struct drm_crtc *crtc = &mdp5_crtc->base;
173 struct drm_framebuffer *fb = mdp5_crtc->fb;
174
175 if (!fb)
176 return;
177
178 drm_framebuffer_reference(fb);
179 mdp5_plane_set_scanout(mdp5_crtc->plane, fb);
180 update_scanout(crtc, fb);
181}
182
183static void unref_fb_worker(struct drm_flip_work *work, void *val)
184{
185 struct mdp5_crtc *mdp5_crtc =
186 container_of(work, struct mdp5_crtc, unref_fb_work);
187 struct drm_device *dev = mdp5_crtc->base.dev;
188
189 mutex_lock(&dev->mode_config.mutex);
190 drm_framebuffer_unreference(val);
191 mutex_unlock(&dev->mode_config.mutex);
192}
193
194static void mdp5_crtc_destroy(struct drm_crtc *crtc)
195{
196 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
197
198 mdp5_crtc->plane->funcs->destroy(mdp5_crtc->plane);
199
200 drm_crtc_cleanup(crtc);
201 drm_flip_work_cleanup(&mdp5_crtc->unref_fb_work);
202
203 kfree(mdp5_crtc);
204}
205
206static void mdp5_crtc_dpms(struct drm_crtc *crtc, int mode)
207{
208 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
209 struct mdp5_kms *mdp5_kms = get_kms(crtc);
210 bool enabled = (mode == DRM_MODE_DPMS_ON);
211
212 DBG("%s: mode=%d", mdp5_crtc->name, mode);
213
214 if (enabled != mdp5_crtc->enabled) {
215 if (enabled) {
216 mdp5_enable(mdp5_kms);
217 mdp_irq_register(&mdp5_kms->base, &mdp5_crtc->err);
218 } else {
219 mdp_irq_unregister(&mdp5_kms->base, &mdp5_crtc->err);
220 mdp5_disable(mdp5_kms);
221 }
222 mdp5_crtc->enabled = enabled;
223 }
224}
225
226static bool mdp5_crtc_mode_fixup(struct drm_crtc *crtc,
227 const struct drm_display_mode *mode,
228 struct drm_display_mode *adjusted_mode)
229{
230 return true;
231}
232
233static void blend_setup(struct drm_crtc *crtc)
234{
235 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
236 struct mdp5_kms *mdp5_kms = get_kms(crtc);
237 int id = mdp5_crtc->id;
238
239 /*
240 * Hard-coded setup for now until I figure out how the
241 * layer-mixer works
242 */
243
244 /* LM[id]: */
245 mdp5_write(mdp5_kms, REG_MDP5_LM_BLEND_COLOR_OUT(id),
246 MDP5_LM_BLEND_COLOR_OUT_STAGE0_FG_ALPHA);
247 mdp5_write(mdp5_kms, REG_MDP5_LM_BLEND_OP_MODE(id, 0),
248 MDP5_LM_BLEND_OP_MODE_FG_ALPHA(FG_CONST) |
249 MDP5_LM_BLEND_OP_MODE_BG_ALPHA(FG_PIXEL) |
250 MDP5_LM_BLEND_OP_MODE_BG_INV_ALPHA);
251 mdp5_write(mdp5_kms, REG_MDP5_LM_BLEND_FG_ALPHA(id, 0), 0xff);
252 mdp5_write(mdp5_kms, REG_MDP5_LM_BLEND_BG_ALPHA(id, 0), 0x00);
253
254 /* NOTE: seems that LM[n] and CTL[m], we do not need n==m.. but
255 * we want to be setting CTL[m].LAYER[n]. Not sure what the
256 * point of having CTL[m].LAYER[o] (for o!=n).. maybe that is
257 * used when chaining up mixers for high resolution displays?
258 */
259
260 /* CTL[id]: */
261 mdp5_write(mdp5_kms, REG_MDP5_CTL_LAYER_REG(id, 0),
262 MDP5_CTL_LAYER_REG_RGB0(STAGE0) |
263 MDP5_CTL_LAYER_REG_BORDER_COLOR);
264 mdp5_write(mdp5_kms, REG_MDP5_CTL_LAYER_REG(id, 1), 0);
265 mdp5_write(mdp5_kms, REG_MDP5_CTL_LAYER_REG(id, 2), 0);
266 mdp5_write(mdp5_kms, REG_MDP5_CTL_LAYER_REG(id, 3), 0);
267 mdp5_write(mdp5_kms, REG_MDP5_CTL_LAYER_REG(id, 4), 0);
268}
269
270static int mdp5_crtc_mode_set(struct drm_crtc *crtc,
271 struct drm_display_mode *mode,
272 struct drm_display_mode *adjusted_mode,
273 int x, int y,
274 struct drm_framebuffer *old_fb)
275{
276 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
277 struct mdp5_kms *mdp5_kms = get_kms(crtc);
278 int ret;
279
280 mode = adjusted_mode;
281
282 DBG("%s: set mode: %d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x",
283 mdp5_crtc->name, mode->base.id, mode->name,
284 mode->vrefresh, mode->clock,
285 mode->hdisplay, mode->hsync_start,
286 mode->hsync_end, mode->htotal,
287 mode->vdisplay, mode->vsync_start,
288 mode->vsync_end, mode->vtotal,
289 mode->type, mode->flags);
290
291 /* grab extra ref for update_scanout() */
292 drm_framebuffer_reference(crtc->fb);
293
294 ret = mdp5_plane_mode_set(mdp5_crtc->plane, crtc, crtc->fb,
295 0, 0, mode->hdisplay, mode->vdisplay,
296 x << 16, y << 16,
297 mode->hdisplay << 16, mode->vdisplay << 16);
298 if (ret) {
299 dev_err(crtc->dev->dev, "%s: failed to set mode on plane: %d\n",
300 mdp5_crtc->name, ret);
301 return ret;
302 }
303
304 mdp5_write(mdp5_kms, REG_MDP5_LM_OUT_SIZE(mdp5_crtc->id),
305 MDP5_LM_OUT_SIZE_WIDTH(mode->hdisplay) |
306 MDP5_LM_OUT_SIZE_HEIGHT(mode->vdisplay));
307
308 update_fb(crtc, crtc->fb);
309 update_scanout(crtc, crtc->fb);
310
311 return 0;
312}
313
314static void mdp5_crtc_prepare(struct drm_crtc *crtc)
315{
316 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
317 DBG("%s", mdp5_crtc->name);
318 /* make sure we hold a ref to mdp clks while setting up mode: */
319 mdp5_enable(get_kms(crtc));
320 mdp5_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
321}
322
323static void mdp5_crtc_commit(struct drm_crtc *crtc)
324{
325 mdp5_crtc_dpms(crtc, DRM_MODE_DPMS_ON);
326 crtc_flush(crtc);
327 /* drop the ref to mdp clk's that we got in prepare: */
328 mdp5_disable(get_kms(crtc));
329}
330
331static int mdp5_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
332 struct drm_framebuffer *old_fb)
333{
334 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
335 struct drm_plane *plane = mdp5_crtc->plane;
336 struct drm_display_mode *mode = &crtc->mode;
337 int ret;
338
339 /* grab extra ref for update_scanout() */
340 drm_framebuffer_reference(crtc->fb);
341
342 ret = mdp5_plane_mode_set(plane, crtc, crtc->fb,
343 0, 0, mode->hdisplay, mode->vdisplay,
344 x << 16, y << 16,
345 mode->hdisplay << 16, mode->vdisplay << 16);
346
347 update_fb(crtc, crtc->fb);
348 update_scanout(crtc, crtc->fb);
349
350 return ret;
351}
352
353static void mdp5_crtc_load_lut(struct drm_crtc *crtc)
354{
355}
356
357static int mdp5_crtc_page_flip(struct drm_crtc *crtc,
358 struct drm_framebuffer *new_fb,
359 struct drm_pending_vblank_event *event,
360 uint32_t page_flip_flags)
361{
362 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
363 struct drm_device *dev = crtc->dev;
364 struct drm_gem_object *obj;
365 unsigned long flags;
366
367 if (mdp5_crtc->event) {
368 dev_err(dev->dev, "already pending flip!\n");
369 return -EBUSY;
370 }
371
372 obj = msm_framebuffer_bo(new_fb, 0);
373
374 spin_lock_irqsave(&dev->event_lock, flags);
375 mdp5_crtc->event = event;
376 spin_unlock_irqrestore(&dev->event_lock, flags);
377
378 update_fb(crtc, new_fb);
379
380 return msm_gem_queue_inactive_cb(obj, &mdp5_crtc->pageflip_cb);
381}
382
383static int mdp5_crtc_set_property(struct drm_crtc *crtc,
384 struct drm_property *property, uint64_t val)
385{
386 // XXX
387 return -EINVAL;
388}
389
390static const struct drm_crtc_funcs mdp5_crtc_funcs = {
391 .set_config = drm_crtc_helper_set_config,
392 .destroy = mdp5_crtc_destroy,
393 .page_flip = mdp5_crtc_page_flip,
394 .set_property = mdp5_crtc_set_property,
395};
396
397static const struct drm_crtc_helper_funcs mdp5_crtc_helper_funcs = {
398 .dpms = mdp5_crtc_dpms,
399 .mode_fixup = mdp5_crtc_mode_fixup,
400 .mode_set = mdp5_crtc_mode_set,
401 .prepare = mdp5_crtc_prepare,
402 .commit = mdp5_crtc_commit,
403 .mode_set_base = mdp5_crtc_mode_set_base,
404 .load_lut = mdp5_crtc_load_lut,
405};
406
407static void mdp5_crtc_vblank_irq(struct mdp_irq *irq, uint32_t irqstatus)
408{
409 struct mdp5_crtc *mdp5_crtc = container_of(irq, struct mdp5_crtc, vblank);
410 struct drm_crtc *crtc = &mdp5_crtc->base;
411 struct msm_drm_private *priv = crtc->dev->dev_private;
412 unsigned pending;
413
414 mdp_irq_unregister(&get_kms(crtc)->base, &mdp5_crtc->vblank);
415
416 pending = atomic_xchg(&mdp5_crtc->pending, 0);
417
418 if (pending & PENDING_FLIP) {
419 complete_flip(crtc, NULL);
420 drm_flip_work_commit(&mdp5_crtc->unref_fb_work, priv->wq);
421 }
422}
423
424static void mdp5_crtc_err_irq(struct mdp_irq *irq, uint32_t irqstatus)
425{
426 struct mdp5_crtc *mdp5_crtc = container_of(irq, struct mdp5_crtc, err);
427 struct drm_crtc *crtc = &mdp5_crtc->base;
428 DBG("%s: error: %08x", mdp5_crtc->name, irqstatus);
429 crtc_flush(crtc);
430}
431
432uint32_t mdp5_crtc_vblank(struct drm_crtc *crtc)
433{
434 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
435 return mdp5_crtc->vblank.irqmask;
436}
437
438void mdp5_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file *file)
439{
440 DBG("cancel: %p", file);
441 complete_flip(crtc, file);
442}
443
444/* set interface for routing crtc->encoder: */
445void mdp5_crtc_set_intf(struct drm_crtc *crtc, int intf,
446 enum mdp5_intf intf_id)
447{
448 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
449 struct mdp5_kms *mdp5_kms = get_kms(crtc);
450 static const enum mdp5_intfnum intfnum[] = {
451 INTF0, INTF1, INTF2, INTF3,
452 };
453 uint32_t intf_sel;
454
455 /* now that we know what irq's we want: */
456 mdp5_crtc->err.irqmask = intf2err(intf);
457 mdp5_crtc->vblank.irqmask = intf2vblank(intf);
458
459 /* when called from modeset_init(), skip the rest until later: */
460 if (!mdp5_kms)
461 return;
462
463 intf_sel = mdp5_read(mdp5_kms, REG_MDP5_DISP_INTF_SEL);
464
465 switch (intf) {
466 case 0:
467 intf_sel &= ~MDP5_DISP_INTF_SEL_INTF0__MASK;
468 intf_sel |= MDP5_DISP_INTF_SEL_INTF0(intf_id);
469 break;
470 case 1:
471 intf_sel &= ~MDP5_DISP_INTF_SEL_INTF1__MASK;
472 intf_sel |= MDP5_DISP_INTF_SEL_INTF1(intf_id);
473 break;
474 case 2:
475 intf_sel &= ~MDP5_DISP_INTF_SEL_INTF2__MASK;
476 intf_sel |= MDP5_DISP_INTF_SEL_INTF2(intf_id);
477 break;
478 case 3:
479 intf_sel &= ~MDP5_DISP_INTF_SEL_INTF3__MASK;
480 intf_sel |= MDP5_DISP_INTF_SEL_INTF3(intf_id);
481 break;
482 default:
483 BUG();
484 break;
485 }
486
487 blend_setup(crtc);
488
489 DBG("%s: intf_sel=%08x", mdp5_crtc->name, intf_sel);
490
491 mdp5_write(mdp5_kms, REG_MDP5_DISP_INTF_SEL, intf_sel);
492 mdp5_write(mdp5_kms, REG_MDP5_CTL_OP(mdp5_crtc->id),
493 MDP5_CTL_OP_MODE(MODE_NONE) |
494 MDP5_CTL_OP_INTF_NUM(intfnum[intf]));
495
496 crtc_flush(crtc);
497}
498
499static void set_attach(struct drm_crtc *crtc, enum mdp5_pipe pipe_id,
500 struct drm_plane *plane)
501{
502 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
503
504 BUG_ON(pipe_id >= ARRAY_SIZE(mdp5_crtc->planes));
505
506 if (mdp5_crtc->planes[pipe_id] == plane)
507 return;
508
509 mdp5_crtc->planes[pipe_id] = plane;
510 blend_setup(crtc);
511 if (mdp5_crtc->enabled && (plane != mdp5_crtc->plane))
512 crtc_flush(crtc);
513}
514
515void mdp5_crtc_attach(struct drm_crtc *crtc, struct drm_plane *plane)
516{
517 set_attach(crtc, mdp5_plane_pipe(plane), plane);
518}
519
520void mdp5_crtc_detach(struct drm_crtc *crtc, struct drm_plane *plane)
521{
522 set_attach(crtc, mdp5_plane_pipe(plane), NULL);
523}
524
525/* initialize crtc */
526struct drm_crtc *mdp5_crtc_init(struct drm_device *dev,
527 struct drm_plane *plane, int id)
528{
529 struct drm_crtc *crtc = NULL;
530 struct mdp5_crtc *mdp5_crtc;
531 int ret;
532
533 mdp5_crtc = kzalloc(sizeof(*mdp5_crtc), GFP_KERNEL);
534 if (!mdp5_crtc) {
535 ret = -ENOMEM;
536 goto fail;
537 }
538
539 crtc = &mdp5_crtc->base;
540
541 mdp5_crtc->plane = plane;
542 mdp5_crtc->id = id;
543
544 mdp5_crtc->vblank.irq = mdp5_crtc_vblank_irq;
545 mdp5_crtc->err.irq = mdp5_crtc_err_irq;
546
547 snprintf(mdp5_crtc->name, sizeof(mdp5_crtc->name), "%s:%d",
548 pipe2name(mdp5_plane_pipe(plane)), id);
549
550 ret = drm_flip_work_init(&mdp5_crtc->unref_fb_work, 16,
551 "unref fb", unref_fb_worker);
552 if (ret)
553 goto fail;
554
555 INIT_FENCE_CB(&mdp5_crtc->pageflip_cb, pageflip_cb);
556
557 drm_crtc_init(dev, crtc, &mdp5_crtc_funcs);
558 drm_crtc_helper_add(crtc, &mdp5_crtc_helper_funcs);
559
560 mdp5_plane_install_properties(mdp5_crtc->plane, &crtc->base);
561
562 return crtc;
563
564fail:
565 if (crtc)
566 mdp5_crtc_destroy(crtc);
567
568 return ERR_PTR(ret);
569}
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_encoder.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_encoder.c
new file mode 100644
index 000000000000..edec7bfaa952
--- /dev/null
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_encoder.c
@@ -0,0 +1,258 @@
1/*
2 * Copyright (C) 2013 Red Hat
3 * Author: Rob Clark <robdclark@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "mdp5_kms.h"
19
20#include "drm_crtc.h"
21#include "drm_crtc_helper.h"
22
23struct mdp5_encoder {
24 struct drm_encoder base;
25 int intf;
26 enum mdp5_intf intf_id;
27 bool enabled;
28 uint32_t bsc;
29};
30#define to_mdp5_encoder(x) container_of(x, struct mdp5_encoder, base)
31
32static struct mdp5_kms *get_kms(struct drm_encoder *encoder)
33{
34 struct msm_drm_private *priv = encoder->dev->dev_private;
35 return to_mdp5_kms(to_mdp_kms(priv->kms));
36}
37
38#ifdef CONFIG_MSM_BUS_SCALING
39#include <mach/board.h>
40#include <mach/msm_bus.h>
41#include <mach/msm_bus_board.h>
42#define MDP_BUS_VECTOR_ENTRY(ab_val, ib_val) \
43 { \
44 .src = MSM_BUS_MASTER_MDP_PORT0, \
45 .dst = MSM_BUS_SLAVE_EBI_CH0, \
46 .ab = (ab_val), \
47 .ib = (ib_val), \
48 }
49
50static struct msm_bus_vectors mdp_bus_vectors[] = {
51 MDP_BUS_VECTOR_ENTRY(0, 0),
52 MDP_BUS_VECTOR_ENTRY(2000000000, 2000000000),
53};
54static struct msm_bus_paths mdp_bus_usecases[] = { {
55 .num_paths = 1,
56 .vectors = &mdp_bus_vectors[0],
57}, {
58 .num_paths = 1,
59 .vectors = &mdp_bus_vectors[1],
60} };
61static struct msm_bus_scale_pdata mdp_bus_scale_table = {
62 .usecase = mdp_bus_usecases,
63 .num_usecases = ARRAY_SIZE(mdp_bus_usecases),
64 .name = "mdss_mdp",
65};
66
67static void bs_init(struct mdp5_encoder *mdp5_encoder)
68{
69 mdp5_encoder->bsc = msm_bus_scale_register_client(
70 &mdp_bus_scale_table);
71 DBG("bus scale client: %08x", mdp5_encoder->bsc);
72}
73
74static void bs_fini(struct mdp5_encoder *mdp5_encoder)
75{
76 if (mdp5_encoder->bsc) {
77 msm_bus_scale_unregister_client(mdp5_encoder->bsc);
78 mdp5_encoder->bsc = 0;
79 }
80}
81
82static void bs_set(struct mdp5_encoder *mdp5_encoder, int idx)
83{
84 if (mdp5_encoder->bsc) {
85 DBG("set bus scaling: %d", idx);
86 /* HACK: scaling down, and then immediately back up
87 * seems to leave things broken (underflow).. so
88 * never disable:
89 */
90 idx = 1;
91 msm_bus_scale_client_update_request(mdp5_encoder->bsc, idx);
92 }
93}
94#else
95static void bs_init(struct mdp5_encoder *mdp5_encoder) {}
96static void bs_fini(struct mdp5_encoder *mdp5_encoder) {}
97static void bs_set(struct mdp5_encoder *mdp5_encoder, int idx) {}
98#endif
99
100static void mdp5_encoder_destroy(struct drm_encoder *encoder)
101{
102 struct mdp5_encoder *mdp5_encoder = to_mdp5_encoder(encoder);
103 bs_fini(mdp5_encoder);
104 drm_encoder_cleanup(encoder);
105 kfree(mdp5_encoder);
106}
107
108static const struct drm_encoder_funcs mdp5_encoder_funcs = {
109 .destroy = mdp5_encoder_destroy,
110};
111
112static void mdp5_encoder_dpms(struct drm_encoder *encoder, int mode)
113{
114 struct mdp5_encoder *mdp5_encoder = to_mdp5_encoder(encoder);
115 struct mdp5_kms *mdp5_kms = get_kms(encoder);
116 int intf = mdp5_encoder->intf;
117 bool enabled = (mode == DRM_MODE_DPMS_ON);
118
119 DBG("mode=%d", mode);
120
121 if (enabled == mdp5_encoder->enabled)
122 return;
123
124 if (enabled) {
125 bs_set(mdp5_encoder, 1);
126 mdp5_write(mdp5_kms, REG_MDP5_INTF_TIMING_ENGINE_EN(intf), 1);
127 } else {
128 mdp5_write(mdp5_kms, REG_MDP5_INTF_TIMING_ENGINE_EN(intf), 0);
129 bs_set(mdp5_encoder, 0);
130 }
131
132 mdp5_encoder->enabled = enabled;
133}
134
135static bool mdp5_encoder_mode_fixup(struct drm_encoder *encoder,
136 const struct drm_display_mode *mode,
137 struct drm_display_mode *adjusted_mode)
138{
139 return true;
140}
141
142static void mdp5_encoder_mode_set(struct drm_encoder *encoder,
143 struct drm_display_mode *mode,
144 struct drm_display_mode *adjusted_mode)
145{
146 struct mdp5_encoder *mdp5_encoder = to_mdp5_encoder(encoder);
147 struct mdp5_kms *mdp5_kms = get_kms(encoder);
148 int intf = mdp5_encoder->intf;
149 uint32_t dtv_hsync_skew, vsync_period, vsync_len, ctrl_pol;
150 uint32_t display_v_start, display_v_end;
151 uint32_t hsync_start_x, hsync_end_x;
152 uint32_t format;
153
154 mode = adjusted_mode;
155
156 DBG("set mode: %d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x",
157 mode->base.id, mode->name,
158 mode->vrefresh, mode->clock,
159 mode->hdisplay, mode->hsync_start,
160 mode->hsync_end, mode->htotal,
161 mode->vdisplay, mode->vsync_start,
162 mode->vsync_end, mode->vtotal,
163 mode->type, mode->flags);
164
165 ctrl_pol = 0;
166 if (mode->flags & DRM_MODE_FLAG_NHSYNC)
167 ctrl_pol |= MDP5_INTF_POLARITY_CTL_HSYNC_LOW;
168 if (mode->flags & DRM_MODE_FLAG_NVSYNC)
169 ctrl_pol |= MDP5_INTF_POLARITY_CTL_VSYNC_LOW;
170 /* probably need to get DATA_EN polarity from panel.. */
171
172 dtv_hsync_skew = 0; /* get this from panel? */
173 format = 0x213f; /* get this from panel? */
174
175 hsync_start_x = (mode->htotal - mode->hsync_start);
176 hsync_end_x = mode->htotal - (mode->hsync_start - mode->hdisplay) - 1;
177
178 vsync_period = mode->vtotal * mode->htotal;
179 vsync_len = (mode->vsync_end - mode->vsync_start) * mode->htotal;
180 display_v_start = (mode->vtotal - mode->vsync_start) * mode->htotal + dtv_hsync_skew;
181 display_v_end = vsync_period - ((mode->vsync_start - mode->vdisplay) * mode->htotal) + dtv_hsync_skew - 1;
182
183 mdp5_write(mdp5_kms, REG_MDP5_INTF_HSYNC_CTL(intf),
184 MDP5_INTF_HSYNC_CTL_PULSEW(mode->hsync_end - mode->hsync_start) |
185 MDP5_INTF_HSYNC_CTL_PERIOD(mode->htotal));
186 mdp5_write(mdp5_kms, REG_MDP5_INTF_VSYNC_PERIOD_F0(intf), vsync_period);
187 mdp5_write(mdp5_kms, REG_MDP5_INTF_VSYNC_LEN_F0(intf), vsync_len);
188 mdp5_write(mdp5_kms, REG_MDP5_INTF_DISPLAY_HCTL(intf),
189 MDP5_INTF_DISPLAY_HCTL_START(hsync_start_x) |
190 MDP5_INTF_DISPLAY_HCTL_END(hsync_end_x));
191 mdp5_write(mdp5_kms, REG_MDP5_INTF_DISPLAY_VSTART_F0(intf), display_v_start);
192 mdp5_write(mdp5_kms, REG_MDP5_INTF_DISPLAY_VEND_F0(intf), display_v_end);
193 mdp5_write(mdp5_kms, REG_MDP5_INTF_BORDER_COLOR(intf), 0);
194 mdp5_write(mdp5_kms, REG_MDP5_INTF_UNDERFLOW_COLOR(intf), 0xff);
195 mdp5_write(mdp5_kms, REG_MDP5_INTF_HSYNC_SKEW(intf), dtv_hsync_skew);
196 mdp5_write(mdp5_kms, REG_MDP5_INTF_POLARITY_CTL(intf), ctrl_pol);
197 mdp5_write(mdp5_kms, REG_MDP5_INTF_ACTIVE_HCTL(intf),
198 MDP5_INTF_ACTIVE_HCTL_START(0) |
199 MDP5_INTF_ACTIVE_HCTL_END(0));
200 mdp5_write(mdp5_kms, REG_MDP5_INTF_ACTIVE_VSTART_F0(intf), 0);
201 mdp5_write(mdp5_kms, REG_MDP5_INTF_ACTIVE_VEND_F0(intf), 0);
202 mdp5_write(mdp5_kms, REG_MDP5_INTF_PANEL_FORMAT(intf), format);
203 mdp5_write(mdp5_kms, REG_MDP5_INTF_FRAME_LINE_COUNT_EN(intf), 0x3); /* frame+line? */
204}
205
206static void mdp5_encoder_prepare(struct drm_encoder *encoder)
207{
208 mdp5_encoder_dpms(encoder, DRM_MODE_DPMS_OFF);
209}
210
211static void mdp5_encoder_commit(struct drm_encoder *encoder)
212{
213 struct mdp5_encoder *mdp5_encoder = to_mdp5_encoder(encoder);
214 mdp5_crtc_set_intf(encoder->crtc, mdp5_encoder->intf,
215 mdp5_encoder->intf_id);
216 mdp5_encoder_dpms(encoder, DRM_MODE_DPMS_ON);
217}
218
219static const struct drm_encoder_helper_funcs mdp5_encoder_helper_funcs = {
220 .dpms = mdp5_encoder_dpms,
221 .mode_fixup = mdp5_encoder_mode_fixup,
222 .mode_set = mdp5_encoder_mode_set,
223 .prepare = mdp5_encoder_prepare,
224 .commit = mdp5_encoder_commit,
225};
226
227/* initialize encoder */
228struct drm_encoder *mdp5_encoder_init(struct drm_device *dev, int intf,
229 enum mdp5_intf intf_id)
230{
231 struct drm_encoder *encoder = NULL;
232 struct mdp5_encoder *mdp5_encoder;
233 int ret;
234
235 mdp5_encoder = kzalloc(sizeof(*mdp5_encoder), GFP_KERNEL);
236 if (!mdp5_encoder) {
237 ret = -ENOMEM;
238 goto fail;
239 }
240
241 mdp5_encoder->intf = intf;
242 mdp5_encoder->intf_id = intf_id;
243 encoder = &mdp5_encoder->base;
244
245 drm_encoder_init(dev, encoder, &mdp5_encoder_funcs,
246 DRM_MODE_ENCODER_TMDS);
247 drm_encoder_helper_add(encoder, &mdp5_encoder_helper_funcs);
248
249 bs_init(mdp5_encoder);
250
251 return encoder;
252
253fail:
254 if (encoder)
255 mdp5_encoder_destroy(encoder);
256
257 return ERR_PTR(ret);
258}
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_irq.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_irq.c
new file mode 100644
index 000000000000..353d494a497f
--- /dev/null
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_irq.c
@@ -0,0 +1,111 @@
1/*
2 * Copyright (C) 2013 Red Hat
3 * Author: Rob Clark <robdclark@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18
19#include "msm_drv.h"
20#include "mdp5_kms.h"
21
22void mdp5_set_irqmask(struct mdp_kms *mdp_kms, uint32_t irqmask)
23{
24 mdp5_write(to_mdp5_kms(mdp_kms), REG_MDP5_INTR_EN, irqmask);
25}
26
27static void mdp5_irq_error_handler(struct mdp_irq *irq, uint32_t irqstatus)
28{
29 DRM_ERROR("errors: %08x\n", irqstatus);
30}
31
32void mdp5_irq_preinstall(struct msm_kms *kms)
33{
34 struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
35 mdp5_write(mdp5_kms, REG_MDP5_INTR_CLEAR, 0xffffffff);
36}
37
38int mdp5_irq_postinstall(struct msm_kms *kms)
39{
40 struct mdp_kms *mdp_kms = to_mdp_kms(kms);
41 struct mdp5_kms *mdp5_kms = to_mdp5_kms(mdp_kms);
42 struct mdp_irq *error_handler = &mdp5_kms->error_handler;
43
44 error_handler->irq = mdp5_irq_error_handler;
45 error_handler->irqmask = MDP5_IRQ_INTF0_UNDER_RUN |
46 MDP5_IRQ_INTF1_UNDER_RUN |
47 MDP5_IRQ_INTF2_UNDER_RUN |
48 MDP5_IRQ_INTF3_UNDER_RUN;
49
50 mdp_irq_register(mdp_kms, error_handler);
51
52 return 0;
53}
54
55void mdp5_irq_uninstall(struct msm_kms *kms)
56{
57 struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
58 mdp5_write(mdp5_kms, REG_MDP5_INTR_EN, 0x00000000);
59}
60
61static void mdp5_irq_mdp(struct mdp_kms *mdp_kms)
62{
63 struct mdp5_kms *mdp5_kms = to_mdp5_kms(mdp_kms);
64 struct drm_device *dev = mdp5_kms->dev;
65 struct msm_drm_private *priv = dev->dev_private;
66 unsigned int id;
67 uint32_t status;
68
69 status = mdp5_read(mdp5_kms, REG_MDP5_INTR_STATUS);
70 mdp5_write(mdp5_kms, REG_MDP5_INTR_CLEAR, status);
71
72 VERB("status=%08x", status);
73
74 for (id = 0; id < priv->num_crtcs; id++)
75 if (status & mdp5_crtc_vblank(priv->crtcs[id]))
76 drm_handle_vblank(dev, id);
77
78 mdp_dispatch_irqs(mdp_kms, status);
79}
80
81irqreturn_t mdp5_irq(struct msm_kms *kms)
82{
83 struct mdp_kms *mdp_kms = to_mdp_kms(kms);
84 struct mdp5_kms *mdp5_kms = to_mdp5_kms(mdp_kms);
85 uint32_t intr;
86
87 intr = mdp5_read(mdp5_kms, REG_MDP5_HW_INTR_STATUS);
88
89 VERB("intr=%08x", intr);
90
91 if (intr & MDP5_HW_INTR_STATUS_INTR_MDP)
92 mdp5_irq_mdp(mdp_kms);
93
94 if (intr & MDP5_HW_INTR_STATUS_INTR_HDMI)
95 hdmi_irq(0, mdp5_kms->hdmi);
96
97 return IRQ_HANDLED;
98}
99
100int mdp5_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc)
101{
102 mdp_update_vblank_mask(to_mdp_kms(kms),
103 mdp5_crtc_vblank(crtc), true);
104 return 0;
105}
106
107void mdp5_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc)
108{
109 mdp_update_vblank_mask(to_mdp_kms(kms),
110 mdp5_crtc_vblank(crtc), false);
111}
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
new file mode 100644
index 000000000000..ee8446c1b5f6
--- /dev/null
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
@@ -0,0 +1,350 @@
1/*
2 * Copyright (C) 2013 Red Hat
3 * Author: Rob Clark <robdclark@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18
19#include "msm_drv.h"
20#include "msm_mmu.h"
21#include "mdp5_kms.h"
22
23static struct mdp5_platform_config *mdp5_get_config(struct platform_device *dev);
24
25static int mdp5_hw_init(struct msm_kms *kms)
26{
27 struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
28 struct drm_device *dev = mdp5_kms->dev;
29 uint32_t version, major, minor;
30 int ret = 0;
31
32 pm_runtime_get_sync(dev->dev);
33
34 mdp5_enable(mdp5_kms);
35 version = mdp5_read(mdp5_kms, REG_MDP5_MDP_VERSION);
36 mdp5_disable(mdp5_kms);
37
38 major = FIELD(version, MDP5_MDP_VERSION_MAJOR);
39 minor = FIELD(version, MDP5_MDP_VERSION_MINOR);
40
41 DBG("found MDP5 version v%d.%d", major, minor);
42
43 if ((major != 1) || ((minor != 0) && (minor != 2))) {
44 dev_err(dev->dev, "unexpected MDP version: v%d.%d\n",
45 major, minor);
46 ret = -ENXIO;
47 goto out;
48 }
49
50 mdp5_kms->rev = minor;
51
52 /* Magic unknown register writes:
53 *
54 * W VBIF:0x004 00000001 (mdss_mdp.c:839)
55 * W MDP5:0x2e0 0xe9 (mdss_mdp.c:839)
56 * W MDP5:0x2e4 0x55 (mdss_mdp.c:839)
57 * W MDP5:0x3ac 0xc0000ccc (mdss_mdp.c:839)
58 * W MDP5:0x3b4 0xc0000ccc (mdss_mdp.c:839)
59 * W MDP5:0x3bc 0xcccccc (mdss_mdp.c:839)
60 * W MDP5:0x4a8 0xcccc0c0 (mdss_mdp.c:839)
61 * W MDP5:0x4b0 0xccccc0c0 (mdss_mdp.c:839)
62 * W MDP5:0x4b8 0xccccc000 (mdss_mdp.c:839)
63 *
64 * Downstream fbdev driver gets these register offsets/values
65 * from DT.. not really sure what these registers are or if
66 * different values for different boards/SoC's, etc. I guess
67 * they are the golden registers.
68 *
69 * Not setting these does not seem to cause any problem. But
70 * we may be getting lucky with the bootloader initializing
71 * them for us. OTOH, if we can always count on the bootloader
72 * setting the golden registers, then perhaps we don't need to
73 * care.
74 */
75
76 mdp5_write(mdp5_kms, REG_MDP5_DISP_INTF_SEL, 0);
77 mdp5_write(mdp5_kms, REG_MDP5_CTL_OP(0), 0);
78 mdp5_write(mdp5_kms, REG_MDP5_CTL_OP(1), 0);
79 mdp5_write(mdp5_kms, REG_MDP5_CTL_OP(2), 0);
80 mdp5_write(mdp5_kms, REG_MDP5_CTL_OP(3), 0);
81
82out:
83 pm_runtime_put_sync(dev->dev);
84
85 return ret;
86}
87
88static long mdp5_round_pixclk(struct msm_kms *kms, unsigned long rate,
89 struct drm_encoder *encoder)
90{
91 return rate;
92}
93
94static void mdp5_preclose(struct msm_kms *kms, struct drm_file *file)
95{
96 struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
97 struct msm_drm_private *priv = mdp5_kms->dev->dev_private;
98 unsigned i;
99
100 for (i = 0; i < priv->num_crtcs; i++)
101 mdp5_crtc_cancel_pending_flip(priv->crtcs[i], file);
102}
103
104static void mdp5_destroy(struct msm_kms *kms)
105{
106 struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
107 kfree(mdp5_kms);
108}
109
110static const struct mdp_kms_funcs kms_funcs = {
111 .base = {
112 .hw_init = mdp5_hw_init,
113 .irq_preinstall = mdp5_irq_preinstall,
114 .irq_postinstall = mdp5_irq_postinstall,
115 .irq_uninstall = mdp5_irq_uninstall,
116 .irq = mdp5_irq,
117 .enable_vblank = mdp5_enable_vblank,
118 .disable_vblank = mdp5_disable_vblank,
119 .get_format = mdp_get_format,
120 .round_pixclk = mdp5_round_pixclk,
121 .preclose = mdp5_preclose,
122 .destroy = mdp5_destroy,
123 },
124 .set_irqmask = mdp5_set_irqmask,
125};
126
127int mdp5_disable(struct mdp5_kms *mdp5_kms)
128{
129 DBG("");
130
131 clk_disable_unprepare(mdp5_kms->ahb_clk);
132 clk_disable_unprepare(mdp5_kms->axi_clk);
133 clk_disable_unprepare(mdp5_kms->core_clk);
134 clk_disable_unprepare(mdp5_kms->lut_clk);
135
136 return 0;
137}
138
139int mdp5_enable(struct mdp5_kms *mdp5_kms)
140{
141 DBG("");
142
143 clk_prepare_enable(mdp5_kms->ahb_clk);
144 clk_prepare_enable(mdp5_kms->axi_clk);
145 clk_prepare_enable(mdp5_kms->core_clk);
146 clk_prepare_enable(mdp5_kms->lut_clk);
147
148 return 0;
149}
150
151static int modeset_init(struct mdp5_kms *mdp5_kms)
152{
153 static const enum mdp5_pipe crtcs[] = {
154 SSPP_RGB0, SSPP_RGB1, SSPP_RGB2,
155 };
156 struct drm_device *dev = mdp5_kms->dev;
157 struct msm_drm_private *priv = dev->dev_private;
158 struct drm_encoder *encoder;
159 int i, ret;
160
161 /* construct CRTCs: */
162 for (i = 0; i < ARRAY_SIZE(crtcs); i++) {
163 struct drm_plane *plane;
164 struct drm_crtc *crtc;
165
166 plane = mdp5_plane_init(dev, crtcs[i], true);
167 if (IS_ERR(plane)) {
168 ret = PTR_ERR(plane);
169 dev_err(dev->dev, "failed to construct plane for %s (%d)\n",
170 pipe2name(crtcs[i]), ret);
171 goto fail;
172 }
173
174 crtc = mdp5_crtc_init(dev, plane, i);
175 if (IS_ERR(crtc)) {
176 ret = PTR_ERR(crtc);
177 dev_err(dev->dev, "failed to construct crtc for %s (%d)\n",
178 pipe2name(crtcs[i]), ret);
179 goto fail;
180 }
181 priv->crtcs[priv->num_crtcs++] = crtc;
182 }
183
184 /* Construct encoder for HDMI: */
185 encoder = mdp5_encoder_init(dev, 3, INTF_HDMI);
186 if (IS_ERR(encoder)) {
187 dev_err(dev->dev, "failed to construct encoder\n");
188 ret = PTR_ERR(encoder);
189 goto fail;
190 }
191
192 /* NOTE: the vsync and error irq's are actually associated with
193 * the INTF/encoder.. the easiest way to deal with this (ie. what
194 * we do now) is assume a fixed relationship between crtc's and
195 * encoders. I'm not sure if there is ever a need to more freely
196 * assign crtcs to encoders, but if there is then we need to take
197 * care of error and vblank irq's that the crtc has registered,
198 * and also update user-requested vblank_mask.
199 */
200 encoder->possible_crtcs = BIT(0);
201 mdp5_crtc_set_intf(priv->crtcs[0], 3, INTF_HDMI);
202
203 priv->encoders[priv->num_encoders++] = encoder;
204
205 /* Construct bridge/connector for HDMI: */
206 mdp5_kms->hdmi = hdmi_init(dev, encoder);
207 if (IS_ERR(mdp5_kms->hdmi)) {
208 ret = PTR_ERR(mdp5_kms->hdmi);
209 dev_err(dev->dev, "failed to initialize HDMI: %d\n", ret);
210 goto fail;
211 }
212
213 return 0;
214
215fail:
216 return ret;
217}
218
219static const char *iommu_ports[] = {
220 "mdp_0",
221};
222
223static int get_clk(struct platform_device *pdev, struct clk **clkp,
224 const char *name)
225{
226 struct device *dev = &pdev->dev;
227 struct clk *clk = devm_clk_get(dev, name);
228 if (IS_ERR(clk)) {
229 dev_err(dev, "failed to get %s (%ld)\n", name, PTR_ERR(clk));
230 return PTR_ERR(clk);
231 }
232 *clkp = clk;
233 return 0;
234}
235
236struct msm_kms *mdp5_kms_init(struct drm_device *dev)
237{
238 struct platform_device *pdev = dev->platformdev;
239 struct mdp5_platform_config *config = mdp5_get_config(pdev);
240 struct mdp5_kms *mdp5_kms;
241 struct msm_kms *kms = NULL;
242 struct msm_mmu *mmu;
243 int ret;
244
245 mdp5_kms = kzalloc(sizeof(*mdp5_kms), GFP_KERNEL);
246 if (!mdp5_kms) {
247 dev_err(dev->dev, "failed to allocate kms\n");
248 ret = -ENOMEM;
249 goto fail;
250 }
251
252 mdp_kms_init(&mdp5_kms->base, &kms_funcs);
253
254 kms = &mdp5_kms->base.base;
255
256 mdp5_kms->dev = dev;
257 mdp5_kms->smp_blk_cnt = config->smp_blk_cnt;
258
259 mdp5_kms->mmio = msm_ioremap(pdev, "mdp_phys", "MDP5");
260 if (IS_ERR(mdp5_kms->mmio)) {
261 ret = PTR_ERR(mdp5_kms->mmio);
262 goto fail;
263 }
264
265 mdp5_kms->vbif = msm_ioremap(pdev, "vbif_phys", "VBIF");
266 if (IS_ERR(mdp5_kms->vbif)) {
267 ret = PTR_ERR(mdp5_kms->vbif);
268 goto fail;
269 }
270
271 mdp5_kms->vdd = devm_regulator_get(&pdev->dev, "vdd");
272 if (IS_ERR(mdp5_kms->vdd)) {
273 ret = PTR_ERR(mdp5_kms->vdd);
274 goto fail;
275 }
276
277 ret = regulator_enable(mdp5_kms->vdd);
278 if (ret) {
279 dev_err(dev->dev, "failed to enable regulator vdd: %d\n", ret);
280 goto fail;
281 }
282
283 ret = get_clk(pdev, &mdp5_kms->axi_clk, "bus_clk") ||
284 get_clk(pdev, &mdp5_kms->ahb_clk, "iface_clk") ||
285 get_clk(pdev, &mdp5_kms->src_clk, "core_clk_src") ||
286 get_clk(pdev, &mdp5_kms->core_clk, "core_clk") ||
287 get_clk(pdev, &mdp5_kms->lut_clk, "lut_clk") ||
288 get_clk(pdev, &mdp5_kms->vsync_clk, "vsync_clk");
289 if (ret)
290 goto fail;
291
292 ret = clk_set_rate(mdp5_kms->src_clk, config->max_clk);
293
294 /* make sure things are off before attaching iommu (bootloader could
295 * have left things on, in which case we'll start getting faults if
296 * we don't disable):
297 */
298 mdp5_enable(mdp5_kms);
299 mdp5_write(mdp5_kms, REG_MDP5_INTF_TIMING_ENGINE_EN(0), 0);
300 mdp5_write(mdp5_kms, REG_MDP5_INTF_TIMING_ENGINE_EN(1), 0);
301 mdp5_write(mdp5_kms, REG_MDP5_INTF_TIMING_ENGINE_EN(2), 0);
302 mdp5_write(mdp5_kms, REG_MDP5_INTF_TIMING_ENGINE_EN(3), 0);
303 mdp5_disable(mdp5_kms);
304 mdelay(16);
305
306 if (config->iommu) {
307 mmu = msm_iommu_new(dev, config->iommu);
308 if (IS_ERR(mmu)) {
309 ret = PTR_ERR(mmu);
310 goto fail;
311 }
312 ret = mmu->funcs->attach(mmu, iommu_ports,
313 ARRAY_SIZE(iommu_ports));
314 if (ret)
315 goto fail;
316 } else {
317 dev_info(dev->dev, "no iommu, fallback to phys "
318 "contig buffers for scanout\n");
319 mmu = NULL;
320 }
321
322 mdp5_kms->id = msm_register_mmu(dev, mmu);
323 if (mdp5_kms->id < 0) {
324 ret = mdp5_kms->id;
325 dev_err(dev->dev, "failed to register mdp5 iommu: %d\n", ret);
326 goto fail;
327 }
328
329 ret = modeset_init(mdp5_kms);
330 if (ret) {
331 dev_err(dev->dev, "modeset_init failed: %d\n", ret);
332 goto fail;
333 }
334
335 return kms;
336
337fail:
338 if (kms)
339 mdp5_destroy(kms);
340 return ERR_PTR(ret);
341}
342
343static struct mdp5_platform_config *mdp5_get_config(struct platform_device *dev)
344{
345 static struct mdp5_platform_config config = {};
346#ifdef CONFIG_OF
347 /* TODO */
348#endif
349 return &config;
350}
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h
new file mode 100644
index 000000000000..c8b1a2522c25
--- /dev/null
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h
@@ -0,0 +1,213 @@
1/*
2 * Copyright (C) 2013 Red Hat
3 * Author: Rob Clark <robdclark@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __MDP5_KMS_H__
19#define __MDP5_KMS_H__
20
21#include "msm_drv.h"
22#include "msm_kms.h"
23#include "mdp/mdp_kms.h"
24#include "mdp5.xml.h"
25#include "mdp5_smp.h"
26
27struct mdp5_kms {
28 struct mdp_kms base;
29
30 struct drm_device *dev;
31
32 int rev;
33
34 /* mapper-id used to request GEM buffer mapped for scanout: */
35 int id;
36
37 /* for tracking smp allocation amongst pipes: */
38 mdp5_smp_state_t smp_state;
39 struct mdp5_client_smp_state smp_client_state[CID_MAX];
40 int smp_blk_cnt;
41
42 /* io/register spaces: */
43 void __iomem *mmio, *vbif;
44
45 struct regulator *vdd;
46
47 struct clk *axi_clk;
48 struct clk *ahb_clk;
49 struct clk *src_clk;
50 struct clk *core_clk;
51 struct clk *lut_clk;
52 struct clk *vsync_clk;
53
54 struct hdmi *hdmi;
55
56 struct mdp_irq error_handler;
57};
58#define to_mdp5_kms(x) container_of(x, struct mdp5_kms, base)
59
60/* platform config data (ie. from DT, or pdata) */
61struct mdp5_platform_config {
62 struct iommu_domain *iommu;
63 uint32_t max_clk;
64 int smp_blk_cnt;
65};
66
67static inline void mdp5_write(struct mdp5_kms *mdp5_kms, u32 reg, u32 data)
68{
69 msm_writel(data, mdp5_kms->mmio + reg);
70}
71
72static inline u32 mdp5_read(struct mdp5_kms *mdp5_kms, u32 reg)
73{
74 return msm_readl(mdp5_kms->mmio + reg);
75}
76
77static inline const char *pipe2name(enum mdp5_pipe pipe)
78{
79 static const char *names[] = {
80#define NAME(n) [SSPP_ ## n] = #n
81 NAME(VIG0), NAME(VIG1), NAME(VIG2),
82 NAME(RGB0), NAME(RGB1), NAME(RGB2),
83 NAME(DMA0), NAME(DMA1),
84#undef NAME
85 };
86 return names[pipe];
87}
88
89static inline uint32_t pipe2flush(enum mdp5_pipe pipe)
90{
91 switch (pipe) {
92 case SSPP_VIG0: return MDP5_CTL_FLUSH_VIG0;
93 case SSPP_VIG1: return MDP5_CTL_FLUSH_VIG1;
94 case SSPP_VIG2: return MDP5_CTL_FLUSH_VIG2;
95 case SSPP_RGB0: return MDP5_CTL_FLUSH_RGB0;
96 case SSPP_RGB1: return MDP5_CTL_FLUSH_RGB1;
97 case SSPP_RGB2: return MDP5_CTL_FLUSH_RGB2;
98 case SSPP_DMA0: return MDP5_CTL_FLUSH_DMA0;
99 case SSPP_DMA1: return MDP5_CTL_FLUSH_DMA1;
100 default: return 0;
101 }
102}
103
104static inline int pipe2nclients(enum mdp5_pipe pipe)
105{
106 switch (pipe) {
107 case SSPP_RGB0:
108 case SSPP_RGB1:
109 case SSPP_RGB2:
110 return 1;
111 default:
112 return 3;
113 }
114}
115
116static inline enum mdp5_client_id pipe2client(enum mdp5_pipe pipe, int plane)
117{
118 WARN_ON(plane >= pipe2nclients(pipe));
119 switch (pipe) {
120 case SSPP_VIG0: return CID_VIG0_Y + plane;
121 case SSPP_VIG1: return CID_VIG1_Y + plane;
122 case SSPP_VIG2: return CID_VIG2_Y + plane;
123 case SSPP_RGB0: return CID_RGB0;
124 case SSPP_RGB1: return CID_RGB1;
125 case SSPP_RGB2: return CID_RGB2;
126 case SSPP_DMA0: return CID_DMA0_Y + plane;
127 case SSPP_DMA1: return CID_DMA1_Y + plane;
128 default: return CID_UNUSED;
129 }
130}
131
132static inline uint32_t mixer2flush(int lm)
133{
134 switch (lm) {
135 case 0: return MDP5_CTL_FLUSH_LM0;
136 case 1: return MDP5_CTL_FLUSH_LM1;
137 case 2: return MDP5_CTL_FLUSH_LM2;
138 default: return 0;
139 }
140}
141
142static inline uint32_t intf2err(int intf)
143{
144 switch (intf) {
145 case 0: return MDP5_IRQ_INTF0_UNDER_RUN;
146 case 1: return MDP5_IRQ_INTF1_UNDER_RUN;
147 case 2: return MDP5_IRQ_INTF2_UNDER_RUN;
148 case 3: return MDP5_IRQ_INTF3_UNDER_RUN;
149 default: return 0;
150 }
151}
152
153static inline uint32_t intf2vblank(int intf)
154{
155 switch (intf) {
156 case 0: return MDP5_IRQ_INTF0_VSYNC;
157 case 1: return MDP5_IRQ_INTF1_VSYNC;
158 case 2: return MDP5_IRQ_INTF2_VSYNC;
159 case 3: return MDP5_IRQ_INTF3_VSYNC;
160 default: return 0;
161 }
162}
163
164int mdp5_disable(struct mdp5_kms *mdp5_kms);
165int mdp5_enable(struct mdp5_kms *mdp5_kms);
166
167void mdp5_set_irqmask(struct mdp_kms *mdp_kms, uint32_t irqmask);
168void mdp5_irq_preinstall(struct msm_kms *kms);
169int mdp5_irq_postinstall(struct msm_kms *kms);
170void mdp5_irq_uninstall(struct msm_kms *kms);
171irqreturn_t mdp5_irq(struct msm_kms *kms);
172int mdp5_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
173void mdp5_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
174
175static inline
176uint32_t mdp5_get_formats(enum mdp5_pipe pipe, uint32_t *pixel_formats,
177 uint32_t max_formats)
178{
179 /* TODO when we have YUV, we need to filter supported formats
180 * based on pipe id..
181 */
182 return mdp_get_formats(pixel_formats, max_formats);
183}
184
185void mdp5_plane_install_properties(struct drm_plane *plane,
186 struct drm_mode_object *obj);
187void mdp5_plane_set_scanout(struct drm_plane *plane,
188 struct drm_framebuffer *fb);
189int mdp5_plane_mode_set(struct drm_plane *plane,
190 struct drm_crtc *crtc, struct drm_framebuffer *fb,
191 int crtc_x, int crtc_y,
192 unsigned int crtc_w, unsigned int crtc_h,
193 uint32_t src_x, uint32_t src_y,
194 uint32_t src_w, uint32_t src_h);
195void mdp5_plane_complete_flip(struct drm_plane *plane);
196enum mdp5_pipe mdp5_plane_pipe(struct drm_plane *plane);
197struct drm_plane *mdp5_plane_init(struct drm_device *dev,
198 enum mdp5_pipe pipe, bool private_plane);
199
200uint32_t mdp5_crtc_vblank(struct drm_crtc *crtc);
201
202void mdp5_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file *file);
203void mdp5_crtc_set_intf(struct drm_crtc *crtc, int intf,
204 enum mdp5_intf intf_id);
205void mdp5_crtc_attach(struct drm_crtc *crtc, struct drm_plane *plane);
206void mdp5_crtc_detach(struct drm_crtc *crtc, struct drm_plane *plane);
207struct drm_crtc *mdp5_crtc_init(struct drm_device *dev,
208 struct drm_plane *plane, int id);
209
210struct drm_encoder *mdp5_encoder_init(struct drm_device *dev, int intf,
211 enum mdp5_intf intf_id);
212
213#endif /* __MDP5_KMS_H__ */
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
new file mode 100644
index 000000000000..0ac8bb5e7e85
--- /dev/null
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
@@ -0,0 +1,389 @@
1/*
2 * Copyright (C) 2013 Red Hat
3 * Author: Rob Clark <robdclark@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "mdp5_kms.h"
19
20
21struct mdp5_plane {
22 struct drm_plane base;
23 const char *name;
24
25 enum mdp5_pipe pipe;
26
27 uint32_t nformats;
28 uint32_t formats[32];
29
30 bool enabled;
31};
32#define to_mdp5_plane(x) container_of(x, struct mdp5_plane, base)
33
34static struct mdp5_kms *get_kms(struct drm_plane *plane)
35{
36 struct msm_drm_private *priv = plane->dev->dev_private;
37 return to_mdp5_kms(to_mdp_kms(priv->kms));
38}
39
40static int mdp5_plane_update(struct drm_plane *plane,
41 struct drm_crtc *crtc, struct drm_framebuffer *fb,
42 int crtc_x, int crtc_y,
43 unsigned int crtc_w, unsigned int crtc_h,
44 uint32_t src_x, uint32_t src_y,
45 uint32_t src_w, uint32_t src_h)
46{
47 struct mdp5_plane *mdp5_plane = to_mdp5_plane(plane);
48
49 mdp5_plane->enabled = true;
50
51 if (plane->fb)
52 drm_framebuffer_unreference(plane->fb);
53
54 drm_framebuffer_reference(fb);
55
56 return mdp5_plane_mode_set(plane, crtc, fb,
57 crtc_x, crtc_y, crtc_w, crtc_h,
58 src_x, src_y, src_w, src_h);
59}
60
61static int mdp5_plane_disable(struct drm_plane *plane)
62{
63 struct mdp5_plane *mdp5_plane = to_mdp5_plane(plane);
64 struct mdp5_kms *mdp5_kms = get_kms(plane);
65 enum mdp5_pipe pipe = mdp5_plane->pipe;
66 int i;
67
68 DBG("%s: disable", mdp5_plane->name);
69
70 /* update our SMP request to zero (release all our blks): */
71 for (i = 0; i < pipe2nclients(pipe); i++)
72 mdp5_smp_request(mdp5_kms, pipe2client(pipe, i), 0);
73
74 /* TODO detaching now will cause us not to get the last
75 * vblank and mdp5_smp_commit().. so other planes will
76 * still see smp blocks previously allocated to us as
77 * in-use..
78 */
79 if (plane->crtc)
80 mdp5_crtc_detach(plane->crtc, plane);
81
82 return 0;
83}
84
85static void mdp5_plane_destroy(struct drm_plane *plane)
86{
87 struct mdp5_plane *mdp5_plane = to_mdp5_plane(plane);
88
89 mdp5_plane_disable(plane);
90 drm_plane_cleanup(plane);
91
92 kfree(mdp5_plane);
93}
94
95/* helper to install properties which are common to planes and crtcs */
96void mdp5_plane_install_properties(struct drm_plane *plane,
97 struct drm_mode_object *obj)
98{
99 // XXX
100}
101
102int mdp5_plane_set_property(struct drm_plane *plane,
103 struct drm_property *property, uint64_t val)
104{
105 // XXX
106 return -EINVAL;
107}
108
109static const struct drm_plane_funcs mdp5_plane_funcs = {
110 .update_plane = mdp5_plane_update,
111 .disable_plane = mdp5_plane_disable,
112 .destroy = mdp5_plane_destroy,
113 .set_property = mdp5_plane_set_property,
114};
115
116void mdp5_plane_set_scanout(struct drm_plane *plane,
117 struct drm_framebuffer *fb)
118{
119 struct mdp5_plane *mdp5_plane = to_mdp5_plane(plane);
120 struct mdp5_kms *mdp5_kms = get_kms(plane);
121 enum mdp5_pipe pipe = mdp5_plane->pipe;
122 uint32_t nplanes = drm_format_num_planes(fb->pixel_format);
123 uint32_t iova[4];
124 int i;
125
126 for (i = 0; i < nplanes; i++) {
127 struct drm_gem_object *bo = msm_framebuffer_bo(fb, i);
128 msm_gem_get_iova(bo, mdp5_kms->id, &iova[i]);
129 }
130 for (; i < 4; i++)
131 iova[i] = 0;
132
133 mdp5_write(mdp5_kms, REG_MDP5_PIPE_SRC_STRIDE_A(pipe),
134 MDP5_PIPE_SRC_STRIDE_A_P0(fb->pitches[0]) |
135 MDP5_PIPE_SRC_STRIDE_A_P1(fb->pitches[1]));
136
137 mdp5_write(mdp5_kms, REG_MDP5_PIPE_SRC_STRIDE_B(pipe),
138 MDP5_PIPE_SRC_STRIDE_B_P2(fb->pitches[2]) |
139 MDP5_PIPE_SRC_STRIDE_B_P3(fb->pitches[3]));
140
141 mdp5_write(mdp5_kms, REG_MDP5_PIPE_SRC0_ADDR(pipe), iova[0]);
142 mdp5_write(mdp5_kms, REG_MDP5_PIPE_SRC1_ADDR(pipe), iova[1]);
143 mdp5_write(mdp5_kms, REG_MDP5_PIPE_SRC2_ADDR(pipe), iova[2]);
144 mdp5_write(mdp5_kms, REG_MDP5_PIPE_SRC3_ADDR(pipe), iova[3]);
145
146 plane->fb = fb;
147}
148
149/* NOTE: looks like if horizontal decimation is used (if we supported that)
150 * then the width used to calculate SMP block requirements is the post-
151 * decimated width. Ie. SMP buffering sits downstream of decimation (which
152 * presumably happens during the dma from scanout buffer).
153 */
154static int request_smp_blocks(struct drm_plane *plane, uint32_t format,
155 uint32_t nplanes, uint32_t width)
156{
157 struct drm_device *dev = plane->dev;
158 struct mdp5_plane *mdp5_plane = to_mdp5_plane(plane);
159 struct mdp5_kms *mdp5_kms = get_kms(plane);
160 enum mdp5_pipe pipe = mdp5_plane->pipe;
161 int i, hsub, nlines, nblks, ret;
162
163 hsub = drm_format_horz_chroma_subsampling(format);
164
165 /* different if BWC (compressed framebuffer?) enabled: */
166 nlines = 2;
167
168 for (i = 0, nblks = 0; i < nplanes; i++) {
169 int n, fetch_stride, cpp;
170
171 cpp = drm_format_plane_cpp(format, i);
172 fetch_stride = width * cpp / (i ? hsub : 1);
173
174 n = DIV_ROUND_UP(fetch_stride * nlines, SMP_BLK_SIZE);
175
176 /* for hw rev v1.00 */
177 if (mdp5_kms->rev == 0)
178 n = roundup_pow_of_two(n);
179
180 DBG("%s[%d]: request %d SMP blocks", mdp5_plane->name, i, n);
181 ret = mdp5_smp_request(mdp5_kms, pipe2client(pipe, i), n);
182 if (ret) {
183 dev_err(dev->dev, "Could not allocate %d SMP blocks: %d\n",
184 n, ret);
185 return ret;
186 }
187
188 nblks += n;
189 }
190
191 /* in success case, return total # of blocks allocated: */
192 return nblks;
193}
194
195static void set_fifo_thresholds(struct drm_plane *plane, int nblks)
196{
197 struct mdp5_plane *mdp5_plane = to_mdp5_plane(plane);
198 struct mdp5_kms *mdp5_kms = get_kms(plane);
199 enum mdp5_pipe pipe = mdp5_plane->pipe;
200 uint32_t val;
201
202 /* 1/4 of SMP pool that is being fetched */
203 val = (nblks * SMP_ENTRIES_PER_BLK) / 4;
204
205 mdp5_write(mdp5_kms, REG_MDP5_PIPE_REQPRIO_FIFO_WM_0(pipe), val * 1);
206 mdp5_write(mdp5_kms, REG_MDP5_PIPE_REQPRIO_FIFO_WM_1(pipe), val * 2);
207 mdp5_write(mdp5_kms, REG_MDP5_PIPE_REQPRIO_FIFO_WM_2(pipe), val * 3);
208
209}
210
211int mdp5_plane_mode_set(struct drm_plane *plane,
212 struct drm_crtc *crtc, struct drm_framebuffer *fb,
213 int crtc_x, int crtc_y,
214 unsigned int crtc_w, unsigned int crtc_h,
215 uint32_t src_x, uint32_t src_y,
216 uint32_t src_w, uint32_t src_h)
217{
218 struct mdp5_plane *mdp5_plane = to_mdp5_plane(plane);
219 struct mdp5_kms *mdp5_kms = get_kms(plane);
220 enum mdp5_pipe pipe = mdp5_plane->pipe;
221 const struct mdp_format *format;
222 uint32_t nplanes, config = 0;
223 uint32_t phasex_step = 0, phasey_step = 0;
224 uint32_t hdecm = 0, vdecm = 0;
225 int i, nblks;
226
227 nplanes = drm_format_num_planes(fb->pixel_format);
228
229 /* bad formats should already be rejected: */
230 if (WARN_ON(nplanes > pipe2nclients(pipe)))
231 return -EINVAL;
232
233 /* src values are in Q16 fixed point, convert to integer: */
234 src_x = src_x >> 16;
235 src_y = src_y >> 16;
236 src_w = src_w >> 16;
237 src_h = src_h >> 16;
238
239 DBG("%s: FB[%u] %u,%u,%u,%u -> CRTC[%u] %d,%d,%u,%u", mdp5_plane->name,
240 fb->base.id, src_x, src_y, src_w, src_h,
241 crtc->base.id, crtc_x, crtc_y, crtc_w, crtc_h);
242
243 /*
244 * Calculate and request required # of smp blocks:
245 */
246 nblks = request_smp_blocks(plane, fb->pixel_format, nplanes, src_w);
247 if (nblks < 0)
248 return nblks;
249
250 /*
251 * Currently we update the hw for allocations/requests immediately,
252 * but once atomic modeset/pageflip is in place, the allocation
253 * would move into atomic->check_plane_state(), while updating the
254 * hw would remain here:
255 */
256 for (i = 0; i < pipe2nclients(pipe); i++)
257 mdp5_smp_configure(mdp5_kms, pipe2client(pipe, i));
258
259 if (src_w != crtc_w) {
260 config |= MDP5_PIPE_SCALE_CONFIG_SCALEX_EN;
261 /* TODO calc phasex_step, hdecm */
262 }
263
264 if (src_h != crtc_h) {
265 config |= MDP5_PIPE_SCALE_CONFIG_SCALEY_EN;
266 /* TODO calc phasey_step, vdecm */
267 }
268
269 mdp5_write(mdp5_kms, REG_MDP5_PIPE_SRC_IMG_SIZE(pipe),
270 MDP5_PIPE_SRC_IMG_SIZE_WIDTH(src_w) |
271 MDP5_PIPE_SRC_IMG_SIZE_HEIGHT(src_h));
272
273 mdp5_write(mdp5_kms, REG_MDP5_PIPE_SRC_SIZE(pipe),
274 MDP5_PIPE_SRC_SIZE_WIDTH(src_w) |
275 MDP5_PIPE_SRC_SIZE_HEIGHT(src_h));
276
277 mdp5_write(mdp5_kms, REG_MDP5_PIPE_SRC_XY(pipe),
278 MDP5_PIPE_SRC_XY_X(src_x) |
279 MDP5_PIPE_SRC_XY_Y(src_y));
280
281 mdp5_write(mdp5_kms, REG_MDP5_PIPE_OUT_SIZE(pipe),
282 MDP5_PIPE_OUT_SIZE_WIDTH(crtc_w) |
283 MDP5_PIPE_OUT_SIZE_HEIGHT(crtc_h));
284
285 mdp5_write(mdp5_kms, REG_MDP5_PIPE_OUT_XY(pipe),
286 MDP5_PIPE_OUT_XY_X(crtc_x) |
287 MDP5_PIPE_OUT_XY_Y(crtc_y));
288
289 mdp5_plane_set_scanout(plane, fb);
290
291 format = to_mdp_format(msm_framebuffer_format(fb));
292
293 mdp5_write(mdp5_kms, REG_MDP5_PIPE_SRC_FORMAT(pipe),
294 MDP5_PIPE_SRC_FORMAT_A_BPC(format->bpc_a) |
295 MDP5_PIPE_SRC_FORMAT_R_BPC(format->bpc_r) |
296 MDP5_PIPE_SRC_FORMAT_G_BPC(format->bpc_g) |
297 MDP5_PIPE_SRC_FORMAT_B_BPC(format->bpc_b) |
298 COND(format->alpha_enable, MDP5_PIPE_SRC_FORMAT_ALPHA_ENABLE) |
299 MDP5_PIPE_SRC_FORMAT_CPP(format->cpp - 1) |
300 MDP5_PIPE_SRC_FORMAT_UNPACK_COUNT(format->unpack_count - 1) |
301 COND(format->unpack_tight, MDP5_PIPE_SRC_FORMAT_UNPACK_TIGHT) |
302 MDP5_PIPE_SRC_FORMAT_NUM_PLANES(nplanes - 1) |
303 MDP5_PIPE_SRC_FORMAT_CHROMA_SAMP(CHROMA_RGB));
304
305 mdp5_write(mdp5_kms, REG_MDP5_PIPE_SRC_UNPACK(pipe),
306 MDP5_PIPE_SRC_UNPACK_ELEM0(format->unpack[0]) |
307 MDP5_PIPE_SRC_UNPACK_ELEM1(format->unpack[1]) |
308 MDP5_PIPE_SRC_UNPACK_ELEM2(format->unpack[2]) |
309 MDP5_PIPE_SRC_UNPACK_ELEM3(format->unpack[3]));
310
311 mdp5_write(mdp5_kms, REG_MDP5_PIPE_SRC_OP_MODE(pipe),
312 MDP5_PIPE_SRC_OP_MODE_BWC(BWC_LOSSLESS));
313
314 /* not using secure mode: */
315 mdp5_write(mdp5_kms, REG_MDP5_PIPE_SRC_ADDR_SW_STATUS(pipe), 0);
316
317 mdp5_write(mdp5_kms, REG_MDP5_PIPE_SCALE_PHASE_STEP_X(pipe), phasex_step);
318 mdp5_write(mdp5_kms, REG_MDP5_PIPE_SCALE_PHASE_STEP_Y(pipe), phasey_step);
319 mdp5_write(mdp5_kms, REG_MDP5_PIPE_DECIMATION(pipe),
320 MDP5_PIPE_DECIMATION_VERT(vdecm) |
321 MDP5_PIPE_DECIMATION_HORZ(hdecm));
322 mdp5_write(mdp5_kms, REG_MDP5_PIPE_SCALE_CONFIG(pipe),
323 MDP5_PIPE_SCALE_CONFIG_SCALEX_MIN_FILTER(SCALE_FILTER_NEAREST) |
324 MDP5_PIPE_SCALE_CONFIG_SCALEY_MIN_FILTER(SCALE_FILTER_NEAREST) |
325 MDP5_PIPE_SCALE_CONFIG_SCALEX_CR_FILTER(SCALE_FILTER_NEAREST) |
326 MDP5_PIPE_SCALE_CONFIG_SCALEY_CR_FILTER(SCALE_FILTER_NEAREST) |
327 MDP5_PIPE_SCALE_CONFIG_SCALEX_MAX_FILTER(SCALE_FILTER_NEAREST) |
328 MDP5_PIPE_SCALE_CONFIG_SCALEY_MAX_FILTER(SCALE_FILTER_NEAREST));
329
330 set_fifo_thresholds(plane, nblks);
331
332 /* TODO detach from old crtc (if we had more than one) */
333 mdp5_crtc_attach(crtc, plane);
334
335 return 0;
336}
337
338void mdp5_plane_complete_flip(struct drm_plane *plane)
339{
340 struct mdp5_kms *mdp5_kms = get_kms(plane);
341 enum mdp5_pipe pipe = to_mdp5_plane(plane)->pipe;
342 int i;
343
344 for (i = 0; i < pipe2nclients(pipe); i++)
345 mdp5_smp_commit(mdp5_kms, pipe2client(pipe, i));
346}
347
348enum mdp5_pipe mdp5_plane_pipe(struct drm_plane *plane)
349{
350 struct mdp5_plane *mdp5_plane = to_mdp5_plane(plane);
351 return mdp5_plane->pipe;
352}
353
354/* initialize plane */
355struct drm_plane *mdp5_plane_init(struct drm_device *dev,
356 enum mdp5_pipe pipe, bool private_plane)
357{
358 struct drm_plane *plane = NULL;
359 struct mdp5_plane *mdp5_plane;
360 int ret;
361
362 mdp5_plane = kzalloc(sizeof(*mdp5_plane), GFP_KERNEL);
363 if (!mdp5_plane) {
364 ret = -ENOMEM;
365 goto fail;
366 }
367
368 plane = &mdp5_plane->base;
369
370 mdp5_plane->pipe = pipe;
371 mdp5_plane->name = pipe2name(pipe);
372
373 mdp5_plane->nformats = mdp5_get_formats(pipe, mdp5_plane->formats,
374 ARRAY_SIZE(mdp5_plane->formats));
375
376 drm_plane_init(dev, plane, 0xff, &mdp5_plane_funcs,
377 mdp5_plane->formats, mdp5_plane->nformats,
378 private_plane);
379
380 mdp5_plane_install_properties(plane, &plane->base);
381
382 return plane;
383
384fail:
385 if (plane)
386 mdp5_plane_destroy(plane);
387
388 return ERR_PTR(ret);
389}
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_smp.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_smp.c
new file mode 100644
index 000000000000..2d0236b963a6
--- /dev/null
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_smp.c
@@ -0,0 +1,173 @@
1/*
2 * Copyright (C) 2013 Red Hat
3 * Author: Rob Clark <robdclark@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18
19#include "mdp5_kms.h"
20#include "mdp5_smp.h"
21
22
23/* SMP - Shared Memory Pool
24 *
25 * These are shared between all the clients, where each plane in a
26 * scanout buffer is a SMP client. Ie. scanout of 3 plane I420 on
27 * pipe VIG0 => 3 clients: VIG0_Y, VIG0_CB, VIG0_CR.
28 *
29 * Based on the size of the attached scanout buffer, a certain # of
30 * blocks must be allocated to that client out of the shared pool.
31 *
32 * For each block, it can be either free, or pending/in-use by a
33 * client. The updates happen in three steps:
34 *
35 * 1) mdp5_smp_request():
36 * When plane scanout is setup, calculate required number of
37 * blocks needed per client, and request. Blocks not inuse or
38 * pending by any other client are added to client's pending
39 * set.
40 *
41 * 2) mdp5_smp_configure():
42 * As hw is programmed, before FLUSH, MDP5_SMP_ALLOC registers
43 * are configured for the union(pending, inuse)
44 *
45 * 3) mdp5_smp_commit():
46 * After next vblank, copy pending -> inuse. Optionally update
47 * MDP5_SMP_ALLOC registers if there are newly unused blocks
48 *
49 * On the next vblank after changes have been committed to hw, the
50 * client's pending blocks become it's in-use blocks (and no-longer
51 * in-use blocks become available to other clients).
52 *
53 * btw, hurray for confusing overloaded acronyms! :-/
54 *
55 * NOTE: for atomic modeset/pageflip NONBLOCK operations, step #1
56 * should happen at (or before)? atomic->check(). And we'd need
57 * an API to discard previous requests if update is aborted or
58 * (test-only).
59 *
60 * TODO would perhaps be nice to have debugfs to dump out kernel
61 * inuse and pending state of all clients..
62 */
63
64static DEFINE_SPINLOCK(smp_lock);
65
66
67/* step #1: update # of blocks pending for the client: */
68int mdp5_smp_request(struct mdp5_kms *mdp5_kms,
69 enum mdp5_client_id cid, int nblks)
70{
71 struct mdp5_client_smp_state *ps = &mdp5_kms->smp_client_state[cid];
72 int i, ret, avail, cur_nblks, cnt = mdp5_kms->smp_blk_cnt;
73 unsigned long flags;
74
75 spin_lock_irqsave(&smp_lock, flags);
76
77 avail = cnt - bitmap_weight(mdp5_kms->smp_state, cnt);
78 if (nblks > avail) {
79 ret = -ENOSPC;
80 goto fail;
81 }
82
83 cur_nblks = bitmap_weight(ps->pending, cnt);
84 if (nblks > cur_nblks) {
85 /* grow the existing pending reservation: */
86 for (i = cur_nblks; i < nblks; i++) {
87 int blk = find_first_zero_bit(mdp5_kms->smp_state, cnt);
88 set_bit(blk, ps->pending);
89 set_bit(blk, mdp5_kms->smp_state);
90 }
91 } else {
92 /* shrink the existing pending reservation: */
93 for (i = cur_nblks; i > nblks; i--) {
94 int blk = find_first_bit(ps->pending, cnt);
95 clear_bit(blk, ps->pending);
96 /* don't clear in global smp_state until _commit() */
97 }
98 }
99
100fail:
101 spin_unlock_irqrestore(&smp_lock, flags);
102 return 0;
103}
104
105static void update_smp_state(struct mdp5_kms *mdp5_kms,
106 enum mdp5_client_id cid, mdp5_smp_state_t *assigned)
107{
108 int cnt = mdp5_kms->smp_blk_cnt;
109 uint32_t blk, val;
110
111 for_each_set_bit(blk, *assigned, cnt) {
112 int idx = blk / 3;
113 int fld = blk % 3;
114
115 val = mdp5_read(mdp5_kms, REG_MDP5_SMP_ALLOC_W_REG(idx));
116
117 switch (fld) {
118 case 0:
119 val &= ~MDP5_SMP_ALLOC_W_REG_CLIENT0__MASK;
120 val |= MDP5_SMP_ALLOC_W_REG_CLIENT0(cid);
121 break;
122 case 1:
123 val &= ~MDP5_SMP_ALLOC_W_REG_CLIENT1__MASK;
124 val |= MDP5_SMP_ALLOC_W_REG_CLIENT1(cid);
125 break;
126 case 2:
127 val &= ~MDP5_SMP_ALLOC_W_REG_CLIENT2__MASK;
128 val |= MDP5_SMP_ALLOC_W_REG_CLIENT2(cid);
129 break;
130 }
131
132 mdp5_write(mdp5_kms, REG_MDP5_SMP_ALLOC_W_REG(idx), val);
133 mdp5_write(mdp5_kms, REG_MDP5_SMP_ALLOC_R_REG(idx), val);
134 }
135}
136
137/* step #2: configure hw for union(pending, inuse): */
138void mdp5_smp_configure(struct mdp5_kms *mdp5_kms, enum mdp5_client_id cid)
139{
140 struct mdp5_client_smp_state *ps = &mdp5_kms->smp_client_state[cid];
141 int cnt = mdp5_kms->smp_blk_cnt;
142 mdp5_smp_state_t assigned;
143
144 bitmap_or(assigned, ps->inuse, ps->pending, cnt);
145 update_smp_state(mdp5_kms, cid, &assigned);
146}
147
148/* step #3: after vblank, copy pending -> inuse: */
149void mdp5_smp_commit(struct mdp5_kms *mdp5_kms, enum mdp5_client_id cid)
150{
151 struct mdp5_client_smp_state *ps = &mdp5_kms->smp_client_state[cid];
152 int cnt = mdp5_kms->smp_blk_cnt;
153 mdp5_smp_state_t released;
154
155 /*
156 * Figure out if there are any blocks we where previously
157 * using, which can be released and made available to other
158 * clients:
159 */
160 if (bitmap_andnot(released, ps->inuse, ps->pending, cnt)) {
161 unsigned long flags;
162
163 spin_lock_irqsave(&smp_lock, flags);
164 /* clear released blocks: */
165 bitmap_andnot(mdp5_kms->smp_state, mdp5_kms->smp_state,
166 released, cnt);
167 spin_unlock_irqrestore(&smp_lock, flags);
168
169 update_smp_state(mdp5_kms, CID_UNUSED, &released);
170 }
171
172 bitmap_copy(ps->inuse, ps->pending, cnt);
173}
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_smp.h b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_smp.h
new file mode 100644
index 000000000000..0ab739e1a1dd
--- /dev/null
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_smp.h
@@ -0,0 +1,41 @@
1/*
2 * Copyright (C) 2013 Red Hat
3 * Author: Rob Clark <robdclark@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __MDP5_SMP_H__
19#define __MDP5_SMP_H__
20
21#include "msm_drv.h"
22
23#define MAX_SMP_BLOCKS 22
24#define SMP_BLK_SIZE 4096
25#define SMP_ENTRIES_PER_BLK (SMP_BLK_SIZE / 16)
26
27typedef DECLARE_BITMAP(mdp5_smp_state_t, MAX_SMP_BLOCKS);
28
29struct mdp5_client_smp_state {
30 mdp5_smp_state_t inuse;
31 mdp5_smp_state_t pending;
32};
33
34struct mdp5_kms;
35
36int mdp5_smp_request(struct mdp5_kms *mdp5_kms, enum mdp5_client_id cid, int nblks);
37void mdp5_smp_configure(struct mdp5_kms *mdp5_kms, enum mdp5_client_id cid);
38void mdp5_smp_commit(struct mdp5_kms *mdp5_kms, enum mdp5_client_id cid);
39
40
41#endif /* __MDP5_SMP_H__ */