.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* 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. |
---|
11 | 3 | */ |
---|
12 | 4 | |
---|
13 | 5 | #include <linux/iopoll.h> |
---|
.. | .. |
---|
16 | 8 | #include "dpu_hwio.h" |
---|
17 | 9 | #include "dpu_hw_catalog.h" |
---|
18 | 10 | #include "dpu_hw_pingpong.h" |
---|
19 | | -#include "dpu_dbg.h" |
---|
20 | 11 | #include "dpu_kms.h" |
---|
21 | 12 | #include "dpu_trace.h" |
---|
22 | 13 | |
---|
.. | .. |
---|
37 | 28 | #define PP_FBC_BUDGET_CTL 0x038 |
---|
38 | 29 | #define PP_FBC_LOSSY_MODE 0x03C |
---|
39 | 30 | |
---|
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, |
---|
42 | 43 | void __iomem *addr, |
---|
43 | 44 | struct dpu_hw_blk_reg_map *b) |
---|
44 | 45 | { |
---|
.. | .. |
---|
56 | 57 | } |
---|
57 | 58 | |
---|
58 | 59 | 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); |
---|
59 | 91 | } |
---|
60 | 92 | |
---|
61 | 93 | static int dpu_hw_pp_setup_te_config(struct dpu_hw_pingpong *pp, |
---|
.. | .. |
---|
177 | 209 | height = DPU_REG_READ(c, PP_SYNC_CONFIG_HEIGHT) & 0xFFFF; |
---|
178 | 210 | |
---|
179 | 211 | if (height < init) |
---|
180 | | - goto line_count_exit; |
---|
| 212 | + return line; |
---|
181 | 213 | |
---|
182 | 214 | line = DPU_REG_READ(c, PP_INT_COUNT_VAL) & 0xFFFF; |
---|
183 | 215 | |
---|
.. | .. |
---|
186 | 218 | else |
---|
187 | 219 | line -= init; |
---|
188 | 220 | |
---|
189 | | -line_count_exit: |
---|
190 | 221 | return line; |
---|
191 | 222 | } |
---|
192 | 223 | |
---|
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) |
---|
195 | 226 | { |
---|
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; |
---|
202 | 236 | }; |
---|
203 | 237 | |
---|
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; |
---|
208 | 239 | |
---|
209 | 240 | struct dpu_hw_pingpong *dpu_hw_pingpong_init(enum dpu_pingpong idx, |
---|
210 | 241 | void __iomem *addr, |
---|
211 | | - struct dpu_mdss_cfg *m) |
---|
| 242 | + const struct dpu_mdss_cfg *m) |
---|
212 | 243 | { |
---|
213 | 244 | struct dpu_hw_pingpong *c; |
---|
214 | | - struct dpu_pingpong_cfg *cfg; |
---|
215 | | - int rc; |
---|
| 245 | + const struct dpu_pingpong_cfg *cfg; |
---|
216 | 246 | |
---|
217 | 247 | c = kzalloc(sizeof(*c), GFP_KERNEL); |
---|
218 | 248 | if (!c) |
---|
.. | .. |
---|
226 | 256 | |
---|
227 | 257 | c->idx = idx; |
---|
228 | 258 | c->caps = cfg; |
---|
229 | | - _setup_pingpong_ops(&c->ops, c->caps); |
---|
| 259 | + _setup_pingpong_ops(c, c->caps->features); |
---|
230 | 260 | |
---|
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); |
---|
236 | 262 | |
---|
237 | 263 | return c; |
---|
238 | | - |
---|
239 | | -blk_init_error: |
---|
240 | | - kzfree(c); |
---|
241 | | - |
---|
242 | | - return ERR_PTR(rc); |
---|
243 | 264 | } |
---|
244 | 265 | |
---|
245 | 266 | void dpu_hw_pingpong_destroy(struct dpu_hw_pingpong *pp) |
---|