1 /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
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.
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.
13 #ifndef _DPU_HW_PINGPONG_H
14 #define _DPU_HW_PINGPONG_H
16 #include "dpu_hw_catalog.h"
17 #include "dpu_hw_mdss.h"
18 #include "dpu_hw_util.h"
19 #include "dpu_hw_blk.h"
21 struct dpu_hw_pingpong;
23 struct dpu_hw_tear_check {
25 * This is ratio of MDP VSYNC clk freq(Hz) to
26 * refresh rate divided by no of lines
31 u32 sync_threshold_start;
32 u32 sync_threshold_continue;
38 struct dpu_hw_pp_vsync_info {
39 u32 rd_ptr_init_val; /* value of rd pointer at vsync edge */
40 u32 rd_ptr_frame_count; /* num frames sent since enabling interface */
41 u32 rd_ptr_line_count; /* current line on panel (rd ptr) */
42 u32 wr_ptr_line_count; /* current line within pp fifo (wr ptr) */
47 * struct dpu_hw_pingpong_ops : Interface to the pingpong Hw driver functions
48 * Assumption is these functions will be called after clocks are enabled
49 * @setup_tearcheck : program tear check values
50 * @enable_tearcheck : enables tear check
51 * @get_vsync_info : retries timing info of the panel
52 * @setup_dither : function to program the dither hw block
53 * @get_line_count: obtain current vertical line counter
55 struct dpu_hw_pingpong_ops {
57 * enables vysnc generation and sets up init value of
58 * read pointer and programs the tear check cofiguration
60 int (*setup_tearcheck)(struct dpu_hw_pingpong *pp,
61 struct dpu_hw_tear_check *cfg);
64 * enables tear check block
66 int (*enable_tearcheck)(struct dpu_hw_pingpong *pp,
70 * read, modify, write to either set or clear listening to external TE
71 * @Return: 1 if TE was originally connected, 0 if not, or -ERROR
73 int (*connect_external_te)(struct dpu_hw_pingpong *pp,
74 bool enable_external_te);
77 * provides the programmed and current
80 int (*get_vsync_info)(struct dpu_hw_pingpong *pp,
81 struct dpu_hw_pp_vsync_info *info);
84 * poll until write pointer transmission starts
85 * @Return: 0 on success, -ETIMEDOUT on timeout
87 int (*poll_timeout_wr_ptr)(struct dpu_hw_pingpong *pp, u32 timeout_us);
90 * Obtain current vertical line counter
92 u32 (*get_line_count)(struct dpu_hw_pingpong *pp);
95 struct dpu_hw_pingpong {
96 struct dpu_hw_blk base;
97 struct dpu_hw_blk_reg_map hw;
100 enum dpu_pingpong idx;
101 const struct dpu_pingpong_cfg *caps;
104 struct dpu_hw_pingpong_ops ops;
108 * dpu_hw_pingpong_init - initializes the pingpong driver for the passed
110 * @idx: Pingpong index for which driver object is required
111 * @addr: Mapped register io address of MDP
112 * @m: Pointer to mdss catalog data
113 * Returns: Error code or allocated dpu_hw_pingpong context
115 struct dpu_hw_pingpong *dpu_hw_pingpong_init(enum dpu_pingpong idx,
117 struct dpu_mdss_cfg *m);
120 * dpu_hw_pingpong_destroy - destroys pingpong driver context
121 * should be called to free the context
122 * @pp: Pointer to PP driver context returned by dpu_hw_pingpong_init
124 void dpu_hw_pingpong_destroy(struct dpu_hw_pingpong *pp);
126 #endif /*_DPU_HW_PINGPONG_H */