1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
5 #ifndef _DPU_HW_PINGPONG_H
6 #define _DPU_HW_PINGPONG_H
8 #include "dpu_hw_catalog.h"
9 #include "dpu_hw_mdss.h"
10 #include "dpu_hw_util.h"
12 #define DITHER_MATRIX_SZ 16
14 struct dpu_hw_pingpong;
16 struct dpu_hw_tear_check {
18 * This is ratio of MDP VSYNC clk freq(Hz) to
19 * refresh rate divided by no of lines
24 u32 sync_threshold_start;
25 u32 sync_threshold_continue;
31 struct dpu_hw_pp_vsync_info {
32 u32 rd_ptr_init_val; /* value of rd pointer at vsync edge */
33 u32 rd_ptr_frame_count; /* num frames sent since enabling interface */
34 u32 rd_ptr_line_count; /* current line on panel (rd ptr) */
35 u32 wr_ptr_line_count; /* current line within pp fifo (wr ptr) */
39 * struct dpu_hw_dither_cfg - dither feature structure
40 * @flags: for customizing operations
41 * @temporal_en: temperal dither enable
42 * @c0_bitdepth: c0 component bit depth
43 * @c1_bitdepth: c1 component bit depth
44 * @c2_bitdepth: c2 component bit depth
45 * @c3_bitdepth: c2 component bit depth
46 * @matrix: dither strength matrix
48 struct dpu_hw_dither_cfg {
55 u32 matrix[DITHER_MATRIX_SZ];
60 * struct dpu_hw_pingpong_ops : Interface to the pingpong Hw driver functions
61 * Assumption is these functions will be called after clocks are enabled
62 * @setup_tearcheck : program tear check values
63 * @enable_tearcheck : enables tear check
64 * @get_vsync_info : retries timing info of the panel
65 * @setup_autorefresh : configure and enable the autorefresh config
66 * @get_autorefresh : retrieve autorefresh config from hardware
67 * @setup_dither : function to program the dither hw block
68 * @get_line_count: obtain current vertical line counter
70 struct dpu_hw_pingpong_ops {
72 * enables vysnc generation and sets up init value of
73 * read pointer and programs the tear check cofiguration
75 int (*setup_tearcheck)(struct dpu_hw_pingpong *pp,
76 struct dpu_hw_tear_check *cfg);
79 * enables tear check block
81 int (*enable_tearcheck)(struct dpu_hw_pingpong *pp,
85 * read, modify, write to either set or clear listening to external TE
86 * @Return: 1 if TE was originally connected, 0 if not, or -ERROR
88 int (*connect_external_te)(struct dpu_hw_pingpong *pp,
89 bool enable_external_te);
92 * provides the programmed and current
95 int (*get_vsync_info)(struct dpu_hw_pingpong *pp,
96 struct dpu_hw_pp_vsync_info *info);
99 * configure and enable the autorefresh config
101 void (*setup_autorefresh)(struct dpu_hw_pingpong *pp,
102 u32 frame_count, bool enable);
105 * retrieve autorefresh config from hardware
107 bool (*get_autorefresh)(struct dpu_hw_pingpong *pp,
111 * poll until write pointer transmission starts
112 * @Return: 0 on success, -ETIMEDOUT on timeout
114 int (*poll_timeout_wr_ptr)(struct dpu_hw_pingpong *pp, u32 timeout_us);
117 * Obtain current vertical line counter
119 u32 (*get_line_count)(struct dpu_hw_pingpong *pp);
122 * Setup dither matix for pingpong block
124 void (*setup_dither)(struct dpu_hw_pingpong *pp,
125 struct dpu_hw_dither_cfg *cfg);
129 int (*enable_dsc)(struct dpu_hw_pingpong *pp);
134 void (*disable_dsc)(struct dpu_hw_pingpong *pp);
139 int (*setup_dsc)(struct dpu_hw_pingpong *pp);
142 struct dpu_hw_merge_3d;
144 struct dpu_hw_pingpong {
145 struct dpu_hw_blk base;
146 struct dpu_hw_blk_reg_map hw;
149 enum dpu_pingpong idx;
150 const struct dpu_pingpong_cfg *caps;
151 struct dpu_hw_merge_3d *merge_3d;
154 struct dpu_hw_pingpong_ops ops;
158 * to_dpu_hw_pingpong - convert base object dpu_hw_base to container
159 * @hw: Pointer to base hardware block
160 * return: Pointer to hardware block container
162 static inline struct dpu_hw_pingpong *to_dpu_hw_pingpong(struct dpu_hw_blk *hw)
164 return container_of(hw, struct dpu_hw_pingpong, base);
168 * dpu_hw_pingpong_init() - initializes the pingpong driver for the passed
169 * pingpong catalog entry.
170 * @cfg: Pingpong catalog entry for which driver object is required
171 * @addr: Mapped register io address of MDP
172 * Return: Error code or allocated dpu_hw_pingpong context
174 struct dpu_hw_pingpong *dpu_hw_pingpong_init(const struct dpu_pingpong_cfg *cfg,
178 * dpu_hw_pingpong_destroy - destroys pingpong driver context
179 * should be called to free the context
180 * @pp: Pointer to PP driver context returned by dpu_hw_pingpong_init
182 void dpu_hw_pingpong_destroy(struct dpu_hw_pingpong *pp);
184 #endif /*_DPU_HW_PINGPONG_H */