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"
11 #include "dpu_hw_blk.h"
13 struct dpu_hw_pingpong
;
15 struct dpu_hw_tear_check
{
17 * This is ratio of MDP VSYNC clk freq(Hz) to
18 * refresh rate divided by no of lines
23 u32 sync_threshold_start
;
24 u32 sync_threshold_continue
;
30 struct dpu_hw_pp_vsync_info
{
31 u32 rd_ptr_init_val
; /* value of rd pointer at vsync edge */
32 u32 rd_ptr_frame_count
; /* num frames sent since enabling interface */
33 u32 rd_ptr_line_count
; /* current line on panel (rd ptr) */
34 u32 wr_ptr_line_count
; /* current line within pp fifo (wr ptr) */
39 * struct dpu_hw_pingpong_ops : Interface to the pingpong Hw driver functions
40 * Assumption is these functions will be called after clocks are enabled
41 * @setup_tearcheck : program tear check values
42 * @enable_tearcheck : enables tear check
43 * @get_vsync_info : retries timing info of the panel
44 * @setup_dither : function to program the dither hw block
45 * @get_line_count: obtain current vertical line counter
47 struct dpu_hw_pingpong_ops
{
49 * enables vysnc generation and sets up init value of
50 * read pointer and programs the tear check cofiguration
52 int (*setup_tearcheck
)(struct dpu_hw_pingpong
*pp
,
53 struct dpu_hw_tear_check
*cfg
);
56 * enables tear check block
58 int (*enable_tearcheck
)(struct dpu_hw_pingpong
*pp
,
62 * read, modify, write to either set or clear listening to external TE
63 * @Return: 1 if TE was originally connected, 0 if not, or -ERROR
65 int (*connect_external_te
)(struct dpu_hw_pingpong
*pp
,
66 bool enable_external_te
);
69 * provides the programmed and current
72 int (*get_vsync_info
)(struct dpu_hw_pingpong
*pp
,
73 struct dpu_hw_pp_vsync_info
*info
);
76 * poll until write pointer transmission starts
77 * @Return: 0 on success, -ETIMEDOUT on timeout
79 int (*poll_timeout_wr_ptr
)(struct dpu_hw_pingpong
*pp
, u32 timeout_us
);
82 * Obtain current vertical line counter
84 u32 (*get_line_count
)(struct dpu_hw_pingpong
*pp
);
87 struct dpu_hw_pingpong
{
88 struct dpu_hw_blk base
;
89 struct dpu_hw_blk_reg_map hw
;
92 enum dpu_pingpong idx
;
93 const struct dpu_pingpong_cfg
*caps
;
96 struct dpu_hw_pingpong_ops ops
;
100 * dpu_hw_pingpong_init - initializes the pingpong driver for the passed
102 * @idx: Pingpong index for which driver object is required
103 * @addr: Mapped register io address of MDP
104 * @m: Pointer to mdss catalog data
105 * Returns: Error code or allocated dpu_hw_pingpong context
107 struct dpu_hw_pingpong
*dpu_hw_pingpong_init(enum dpu_pingpong idx
,
109 const struct dpu_mdss_cfg
*m
);
112 * dpu_hw_pingpong_destroy - destroys pingpong driver context
113 * should be called to free the context
114 * @pp: Pointer to PP driver context returned by dpu_hw_pingpong_init
116 void dpu_hw_pingpong_destroy(struct dpu_hw_pingpong
*pp
);
118 #endif /*_DPU_HW_PINGPONG_H */