forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c
....@@ -1,13 +1,5 @@
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 <linux/iopoll.h>
....@@ -16,7 +8,6 @@
168 #include "dpu_hwio.h"
179 #include "dpu_hw_catalog.h"
1810 #include "dpu_hw_pingpong.h"
19
-#include "dpu_dbg.h"
2011 #include "dpu_kms.h"
2112 #include "dpu_trace.h"
2213
....@@ -37,8 +28,18 @@
3728 #define PP_FBC_BUDGET_CTL 0x038
3829 #define PP_FBC_LOSSY_MODE 0x03C
3930
40
-static struct dpu_pingpong_cfg *_pingpong_offset(enum dpu_pingpong pp,
41
- struct dpu_mdss_cfg *m,
31
+#define PP_DITHER_EN 0x000
32
+#define PP_DITHER_BITDEPTH 0x004
33
+#define PP_DITHER_MATRIX 0x008
34
+
35
+#define DITHER_DEPTH_MAP_INDEX 9
36
+
37
+static u32 dither_depth_map[DITHER_DEPTH_MAP_INDEX] = {
38
+ 0, 0, 0, 0, 0, 0, 0, 1, 2
39
+};
40
+
41
+static const struct dpu_pingpong_cfg *_pingpong_offset(enum dpu_pingpong pp,
42
+ const struct dpu_mdss_cfg *m,
4243 void __iomem *addr,
4344 struct dpu_hw_blk_reg_map *b)
4445 {
....@@ -56,6 +57,37 @@
5657 }
5758
5859 return ERR_PTR(-EINVAL);
60
+}
61
+
62
+static void dpu_hw_pp_setup_dither(struct dpu_hw_pingpong *pp,
63
+ struct dpu_hw_dither_cfg *cfg)
64
+{
65
+ struct dpu_hw_blk_reg_map *c;
66
+ u32 i, base, data = 0;
67
+
68
+ c = &pp->hw;
69
+ base = pp->caps->sblk->dither.base;
70
+ if (!cfg) {
71
+ DPU_REG_WRITE(c, base + PP_DITHER_EN, 0);
72
+ return;
73
+ }
74
+
75
+ data = dither_depth_map[cfg->c0_bitdepth] & REG_MASK(2);
76
+ data |= (dither_depth_map[cfg->c1_bitdepth] & REG_MASK(2)) << 2;
77
+ data |= (dither_depth_map[cfg->c2_bitdepth] & REG_MASK(2)) << 4;
78
+ data |= (dither_depth_map[cfg->c3_bitdepth] & REG_MASK(2)) << 6;
79
+ data |= (cfg->temporal_en) ? (1 << 8) : 0;
80
+
81
+ DPU_REG_WRITE(c, base + PP_DITHER_BITDEPTH, data);
82
+
83
+ for (i = 0; i < DITHER_MATRIX_SZ - 3; i += 4) {
84
+ data = (cfg->matrix[i] & REG_MASK(4)) |
85
+ ((cfg->matrix[i + 1] & REG_MASK(4)) << 4) |
86
+ ((cfg->matrix[i + 2] & REG_MASK(4)) << 8) |
87
+ ((cfg->matrix[i + 3] & REG_MASK(4)) << 12);
88
+ DPU_REG_WRITE(c, base + PP_DITHER_MATRIX + i, data);
89
+ }
90
+ DPU_REG_WRITE(c, base + PP_DITHER_EN, 1);
5991 }
6092
6193 static int dpu_hw_pp_setup_te_config(struct dpu_hw_pingpong *pp,
....@@ -177,7 +209,7 @@
177209 height = DPU_REG_READ(c, PP_SYNC_CONFIG_HEIGHT) & 0xFFFF;
178210
179211 if (height < init)
180
- goto line_count_exit;
212
+ return line;
181213
182214 line = DPU_REG_READ(c, PP_INT_COUNT_VAL) & 0xFFFF;
183215
....@@ -186,33 +218,31 @@
186218 else
187219 line -= init;
188220
189
-line_count_exit:
190221 return line;
191222 }
192223
193
-static void _setup_pingpong_ops(struct dpu_hw_pingpong_ops *ops,
194
- const struct dpu_pingpong_cfg *hw_cap)
224
+static void _setup_pingpong_ops(struct dpu_hw_pingpong *c,
225
+ unsigned long features)
195226 {
196
- ops->setup_tearcheck = dpu_hw_pp_setup_te_config;
197
- ops->enable_tearcheck = dpu_hw_pp_enable_te;
198
- ops->connect_external_te = dpu_hw_pp_connect_external_te;
199
- ops->get_vsync_info = dpu_hw_pp_get_vsync_info;
200
- ops->poll_timeout_wr_ptr = dpu_hw_pp_poll_timeout_wr_ptr;
201
- ops->get_line_count = dpu_hw_pp_get_line_count;
227
+ c->ops.setup_tearcheck = dpu_hw_pp_setup_te_config;
228
+ c->ops.enable_tearcheck = dpu_hw_pp_enable_te;
229
+ c->ops.connect_external_te = dpu_hw_pp_connect_external_te;
230
+ c->ops.get_vsync_info = dpu_hw_pp_get_vsync_info;
231
+ c->ops.poll_timeout_wr_ptr = dpu_hw_pp_poll_timeout_wr_ptr;
232
+ c->ops.get_line_count = dpu_hw_pp_get_line_count;
233
+
234
+ if (test_bit(DPU_PINGPONG_DITHER, &features))
235
+ c->ops.setup_dither = dpu_hw_pp_setup_dither;
202236 };
203237
204
-static struct dpu_hw_blk_ops dpu_hw_ops = {
205
- .start = NULL,
206
- .stop = NULL,
207
-};
238
+static struct dpu_hw_blk_ops dpu_hw_ops;
208239
209240 struct dpu_hw_pingpong *dpu_hw_pingpong_init(enum dpu_pingpong idx,
210241 void __iomem *addr,
211
- struct dpu_mdss_cfg *m)
242
+ const struct dpu_mdss_cfg *m)
212243 {
213244 struct dpu_hw_pingpong *c;
214
- struct dpu_pingpong_cfg *cfg;
215
- int rc;
245
+ const struct dpu_pingpong_cfg *cfg;
216246
217247 c = kzalloc(sizeof(*c), GFP_KERNEL);
218248 if (!c)
....@@ -226,20 +256,11 @@
226256
227257 c->idx = idx;
228258 c->caps = cfg;
229
- _setup_pingpong_ops(&c->ops, c->caps);
259
+ _setup_pingpong_ops(c, c->caps->features);
230260
231
- rc = dpu_hw_blk_init(&c->base, DPU_HW_BLK_PINGPONG, idx, &dpu_hw_ops);
232
- if (rc) {
233
- DPU_ERROR("failed to init hw blk %d\n", rc);
234
- goto blk_init_error;
235
- }
261
+ dpu_hw_blk_init(&c->base, DPU_HW_BLK_PINGPONG, idx, &dpu_hw_ops);
236262
237263 return c;
238
-
239
-blk_init_error:
240
- kzfree(c);
241
-
242
- return ERR_PTR(rc);
243264 }
244265
245266 void dpu_hw_pingpong_destroy(struct dpu_hw_pingpong *pp)