blob: fc3bea54b485d7069ef6592248dcd5ef6fd460a1 [file] [log] [blame]
Narendra Muppalla1b0b3352015-09-29 10:16:51 -07001/* Copyright (c) 2015-2016, 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 */
12
13#ifndef _SDE_HW_PINGPONG_H
14#define _SDE_HW_PINGPONG_H
15
16struct sde_hw_pingpong;
17
18struct sde_hw_tear_check {
19 /*
20 * This is ratio of MDP VSYNC clk freq(Hz) to
21 * refresh rate divided by no of lines
22 */
23 u32 vsync_count;
24 u32 sync_cfg_height;
25 u32 vsync_init_val;
26 u32 sync_threshold_start;
27 u32 sync_threshold_continue;
28 u32 start_pos;
29 u32 rd_ptr_irq;
30 u8 hw_vsync_mode;
31};
32
33struct sde_hw_autorefresh {
34 bool enable;
35 u32 frame_count;
36};
37
38struct sde_hw_pp_vsync_info {
39 u32 init_val; /* value of rd pointer at vsync edge */
40 u32 vsync_count; /* mdp clocks to complete one line */
41 u32 line_count; /* current line count */
42};
43
44struct sde_hw_dsc_cfg {
45 u8 enable;
46};
47
48/**
49 *
50 * struct sde_hw_pingpong_ops : Interface to the pingpong Hw driver functions
51 * Assumption is these functions will be called after clocks are enabled
52 * @setup_tearcheck :
53 * @enable_tearcheck :
54 * @get_vsync_info :
55 * @setup_autorefresh :
56 * #setup_dsc :
57 */
58struct sde_hw_pingpong_ops {
59 /**
60 * enables vysnc generation and sets up init value of
61 * read pointer and programs the tear check cofiguration
62 */
63 int (*setup_tearcheck)(struct sde_hw_pingpong *pp,
64 struct sde_hw_tear_check *cfg);
65
66 /**
67 * enables tear check block
68 */
69 int (*enable_tearcheck)(struct sde_hw_pingpong *pp,
70 bool enable);
71
72 /**
73 * provides the programmed and current
74 * line_count
75 */
76 int (*get_vsync_info)(struct sde_hw_pingpong *pp,
77 struct sde_hw_pp_vsync_info *info);
78
79 /**
80 * configure and enable the autorefresh config
81 */
82 int (*setup_autorefresh)(struct sde_hw_pingpong *pp,
83 struct sde_hw_autorefresh *cfg);
84
85 /**
86 * Program the dsc compression block
87 */
88 int (*setup_dsc)(struct sde_hw_pingpong *pp,
89 struct sde_hw_dsc_cfg *cfg);
90};
91
92struct sde_hw_pingpong {
93 /* base */
94 struct sde_hw_blk_reg_map hw;
95
96 /* pingpong */
97 enum sde_pingpong idx;
98 const struct sde_pingpong_cfg *pingpong_hw_cap;
99
100 /* ops */
101 struct sde_hw_pingpong_ops ops;
102};
103
104/**
Lloyd Atkinson3127a092016-05-30 13:46:55 -0400105 * sde_hw_pingpong_init - initializes the pingpong driver for the passed
106 * pingpong idx.
107 * @idx: Pingpong index for which driver object is required
108 * @addr: Mapped register io address of MDP
109 * @m: Pointer to mdss catalog data
110 * Returns: Error code or allocated sde_hw_pingpong context
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700111 */
112struct sde_hw_pingpong *sde_hw_pingpong_init(enum sde_pingpong idx,
113 void __iomem *addr,
114 struct sde_mdss_cfg *m);
115
Lloyd Atkinson3127a092016-05-30 13:46:55 -0400116/**
117 * sde_hw_pingpong_destroy - destroys pingpong driver context
118 * should be called to free the context
119 * @pp: Pointer to PP driver context returned by sde_hw_pingpong_init
120 */
121void sde_hw_pingpong_destroy(struct sde_hw_pingpong *pp);
122
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700123#endif /*_SDE_HW_PINGPONG_H */