forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c
....@@ -1,19 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
2
- *
3
- * This program is free software; you can redistribute it and/or modify
4
- * it under the terms of the GNU General Public License version 2 and
5
- * only version 2 as published by the Free Software Foundation.
6
- *
7
- * This program is distributed in the hope that it will be useful,
8
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
- * GNU General Public License for more details.
113 */
124
135 #include "dpu_hwio.h"
146 #include "dpu_hw_catalog.h"
157 #include "dpu_hw_intf.h"
16
-#include "dpu_dbg.h"
178 #include "dpu_kms.h"
189
1910 #define INTF_TIMING_ENGINE_EN 0x000
....@@ -60,16 +51,10 @@
6051 #define INTF_TPG_RGB_MAPPING 0x11C
6152 #define INTF_PROG_FETCH_START 0x170
6253 #define INTF_PROG_ROT_START 0x174
54
+#define INTF_MUX 0x25C
6355
64
-#define INTF_FRAME_LINE_COUNT_EN 0x0A8
65
-#define INTF_FRAME_COUNT 0x0AC
66
-#define INTF_LINE_COUNT 0x0B0
67
-
68
-#define INTF_MISR_CTRL 0x180
69
-#define INTF_MISR_SIGNATURE 0x184
70
-
71
-static struct dpu_intf_cfg *_intf_offset(enum dpu_intf intf,
72
- struct dpu_mdss_cfg *m,
56
+static const struct dpu_intf_cfg *_intf_offset(enum dpu_intf intf,
57
+ const struct dpu_mdss_cfg *m,
7358 void __iomem *addr,
7459 struct dpu_hw_blk_reg_map *b)
7560 {
....@@ -117,11 +102,6 @@
117102 display_v_end = ((vsync_period - p->v_front_porch) * hsync_period) +
118103 p->hsync_skew - 1;
119104
120
- if (ctx->cap->type == INTF_EDP || ctx->cap->type == INTF_DP) {
121
- display_v_start += p->hsync_pulse_width + p->h_back_porch;
122
- display_v_end -= p->h_front_porch;
123
- }
124
-
125105 hsync_start_x = p->h_back_porch + p->hsync_pulse_width;
126106 hsync_end_x = hsync_period - p->h_front_porch - 1;
127107
....@@ -154,10 +134,26 @@
154134 hsync_ctl = (hsync_period << 16) | p->hsync_pulse_width;
155135 display_hctl = (hsync_end_x << 16) | hsync_start_x;
156136
137
+ if (ctx->cap->type == INTF_EDP || ctx->cap->type == INTF_DP) {
138
+ active_h_start = hsync_start_x;
139
+ active_h_end = active_h_start + p->xres - 1;
140
+ active_v_start = display_v_start;
141
+ active_v_end = active_v_start + (p->yres * hsync_period) - 1;
142
+
143
+ display_v_start += p->hsync_pulse_width + p->h_back_porch;
144
+ display_v_end -= p->h_front_porch;
145
+
146
+ active_hctl = (active_h_end << 16) | active_h_start;
147
+ display_hctl = active_hctl;
148
+ }
149
+
157150 den_polarity = 0;
158151 if (ctx->cap->type == INTF_HDMI) {
159152 hsync_polarity = p->yres >= 720 ? 0 : 1;
160153 vsync_polarity = p->yres >= 720 ? 0 : 1;
154
+ } else if (ctx->cap->type == INTF_DP) {
155
+ hsync_polarity = p->hsync_polarity;
156
+ vsync_polarity = p->vsync_polarity;
161157 } else {
162158 hsync_polarity = 0;
163159 vsync_polarity = 0;
....@@ -230,6 +226,25 @@
230226 DPU_REG_WRITE(c, INTF_CONFIG, fetch_enable);
231227 }
232228
229
+static void dpu_hw_intf_bind_pingpong_blk(
230
+ struct dpu_hw_intf *intf,
231
+ bool enable,
232
+ const enum dpu_pingpong pp)
233
+{
234
+ struct dpu_hw_blk_reg_map *c = &intf->hw;
235
+ u32 mux_cfg;
236
+
237
+ mux_cfg = DPU_REG_READ(c, INTF_MUX);
238
+ mux_cfg &= ~0xf;
239
+
240
+ if (enable)
241
+ mux_cfg |= (pp - PINGPONG_0) & 0x7;
242
+ else
243
+ mux_cfg |= 0xf;
244
+
245
+ DPU_REG_WRITE(c, INTF_MUX, mux_cfg);
246
+}
247
+
233248 static void dpu_hw_intf_get_status(
234249 struct dpu_hw_intf *intf,
235250 struct intf_status *s)
....@@ -244,30 +259,6 @@
244259 s->line_count = 0;
245260 s->frame_count = 0;
246261 }
247
-}
248
-
249
-static void dpu_hw_intf_setup_misr(struct dpu_hw_intf *intf,
250
- bool enable, u32 frame_count)
251
-{
252
- struct dpu_hw_blk_reg_map *c = &intf->hw;
253
- u32 config = 0;
254
-
255
- DPU_REG_WRITE(c, INTF_MISR_CTRL, MISR_CTRL_STATUS_CLEAR);
256
- /* clear misr data */
257
- wmb();
258
-
259
- if (enable)
260
- config = (frame_count & MISR_FRAME_COUNT_MASK) |
261
- MISR_CTRL_ENABLE | INTF_MISR_CTRL_FREE_RUN_MASK;
262
-
263
- DPU_REG_WRITE(c, INTF_MISR_CTRL, config);
264
-}
265
-
266
-static u32 dpu_hw_intf_collect_misr(struct dpu_hw_intf *intf)
267
-{
268
- struct dpu_hw_blk_reg_map *c = &intf->hw;
269
-
270
- return DPU_REG_READ(c, INTF_MISR_SIGNATURE);
271262 }
272263
273264 static u32 dpu_hw_intf_get_line_count(struct dpu_hw_intf *intf)
....@@ -289,23 +280,19 @@
289280 ops->setup_prg_fetch = dpu_hw_intf_setup_prg_fetch;
290281 ops->get_status = dpu_hw_intf_get_status;
291282 ops->enable_timing = dpu_hw_intf_enable_timing_engine;
292
- ops->setup_misr = dpu_hw_intf_setup_misr;
293
- ops->collect_misr = dpu_hw_intf_collect_misr;
294283 ops->get_line_count = dpu_hw_intf_get_line_count;
284
+ if (cap & BIT(DPU_INTF_INPUT_CTRL))
285
+ ops->bind_pingpong_blk = dpu_hw_intf_bind_pingpong_blk;
295286 }
296287
297
-static struct dpu_hw_blk_ops dpu_hw_ops = {
298
- .start = NULL,
299
- .stop = NULL,
300
-};
288
+static struct dpu_hw_blk_ops dpu_hw_ops;
301289
302290 struct dpu_hw_intf *dpu_hw_intf_init(enum dpu_intf idx,
303291 void __iomem *addr,
304
- struct dpu_mdss_cfg *m)
292
+ const struct dpu_mdss_cfg *m)
305293 {
306294 struct dpu_hw_intf *c;
307
- struct dpu_intf_cfg *cfg;
308
- int rc;
295
+ const struct dpu_intf_cfg *cfg;
309296
310297 c = kzalloc(sizeof(*c), GFP_KERNEL);
311298 if (!c)
....@@ -326,18 +313,9 @@
326313 c->mdss = m;
327314 _setup_intf_ops(&c->ops, c->cap->features);
328315
329
- rc = dpu_hw_blk_init(&c->base, DPU_HW_BLK_INTF, idx, &dpu_hw_ops);
330
- if (rc) {
331
- DPU_ERROR("failed to init hw blk %d\n", rc);
332
- goto blk_init_error;
333
- }
316
+ dpu_hw_blk_init(&c->base, DPU_HW_BLK_INTF, idx, &dpu_hw_ops);
334317
335318 return c;
336
-
337
-blk_init_error:
338
- kzfree(c);
339
-
340
- return ERR_PTR(rc);
341319 }
342320
343321 void dpu_hw_intf_destroy(struct dpu_hw_intf *intf)