]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/blob - drivers/video/tegra/dc/dc_priv_defs.h
video: tegra: dc: tag vrr modes using vmode
[sojka/nv-tegra/linux-3.10.git] / drivers / video / tegra / dc / dc_priv_defs.h
1 /*
2  * drivers/video/tegra/dc/dc_priv.h
3  *
4  * Copyright (C) 2010 Google, Inc.
5  * Author: Erik Gilling <konkers@android.com>
6  *
7  * Copyright (c) 2010-2016, NVIDIA CORPORATION, All rights reserved.
8  *
9  * This software is licensed under the terms of the GNU General Public
10  * License version 2, as published by the Free Software Foundation, and
11  * may be copied, distributed, and modified under those terms.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  */
19
20 #ifndef __DRIVERS_VIDEO_TEGRA_DC_DC_PRIV_DEFS_H
21 #define __DRIVERS_VIDEO_TEGRA_DC_DC_PRIV_DEFS_H
22 #include <linux/io.h>
23 #include <linux/mutex.h>
24 #include <linux/wait.h>
25 #include <linux/fb.h>
26 #include <linux/clk.h>
27 #include <linux/completion.h>
28 #include <linux/switch.h>
29 #include <linux/nvhost.h>
30 #include <linux/types.h>
31 #include <linux/clk/tegra.h>
32 #include <linux/tegra-soc.h>
33
34 #include <mach/dc.h>
35
36 #include <mach/tegra_dc_ext.h>
37 #include <linux/platform/tegra/isomgr.h>
38
39 #include "dc_reg.h"
40
41 #define NEED_UPDATE_EMC_ON_EVERY_FRAME (windows_idle_detection_time == 0)
42
43 /* 28 bit offset for window clip number */
44 #define CURSOR_CLIP_SHIFT_BITS(win)     (win << 28)
45 #define CURSOR_CLIP_GET_WINDOW(reg)     ((reg >> 28) & 3)
46
47 #define BLANK_ALL       (~0)
48
49 static inline u32 ALL_UF_INT(void)
50 {
51         if (tegra_platform_is_fpga())
52                 return 0;
53 #if defined(CONFIG_ARCH_TEGRA_2x_SOC) || \
54         defined(CONFIG_ARCH_TEGRA_3x_SOC) || \
55         defined(CONFIG_ARCH_TEGRA_11x_SOC)
56         return WIN_A_UF_INT | WIN_B_UF_INT | WIN_C_UF_INT;
57 #elif defined(CONFIG_TEGRA_NVDISPLAY)
58         return NVDISP_UF_INT;
59 #else
60         return WIN_A_UF_INT | WIN_B_UF_INT | WIN_C_UF_INT | HC_UF_INT |
61                 WIN_D_UF_INT | WIN_T_UF_INT;
62 #endif
63 }
64
65 #if defined(CONFIG_TEGRA_EMC_TO_DDR_CLOCK)
66 #define EMC_BW_TO_FREQ(bw) (DDR_BW_TO_FREQ(bw) * CONFIG_TEGRA_EMC_TO_DDR_CLOCK)
67 #else
68 #define EMC_BW_TO_FREQ(bw) (DDR_BW_TO_FREQ(bw) * 2)
69 #endif
70
71 struct tegra_dc;
72
73 struct tegra_dc_blend {
74         unsigned z[DC_N_WINDOWS];
75         unsigned flags[DC_N_WINDOWS];
76         u8 alpha[DC_N_WINDOWS];
77 };
78
79 struct tegra_dc_out_ops {
80         /* initialize output.  dc clocks are not on at this point */
81         int (*init)(struct tegra_dc *dc);
82         /* destroy output.  dc clocks are not on at this point */
83         void (*destroy)(struct tegra_dc *dc);
84         /* shutdown output.  dc clocks are on at this point */
85         void (*shutdown)(struct tegra_dc *dc);
86         /* detect connected display.  can sleep.*/
87         bool (*detect)(struct tegra_dc *dc);
88         /* enable output.  dc clocks are on at this point */
89         void (*enable)(struct tegra_dc *dc);
90         /* enable dc client.  Panel is enable at this point */
91         void (*postpoweron)(struct tegra_dc *dc);
92         /* disable output.  dc clocks are on at this point */
93         void (*disable)(struct tegra_dc *dc);
94         /* dc client is disabled.  dc clocks are on at this point */
95         void (*postpoweroff) (struct tegra_dc *dc);
96         /* hold output.  keeps dc clocks on. */
97         void (*hold)(struct tegra_dc *dc);
98         /* release output.  dc clocks may turn off after this. */
99         void (*release)(struct tegra_dc *dc);
100         /* idle routine of output.  dc clocks may turn off after this. */
101         void (*idle)(struct tegra_dc *dc);
102         /* suspend output.  dc clocks are on at this point */
103         void (*suspend)(struct tegra_dc *dc);
104         /* resume output.  dc clocks are on at this point */
105         void (*resume)(struct tegra_dc *dc);
106         /* mode filter. to provide a list of supported modes*/
107         bool (*mode_filter)(const struct tegra_dc *dc,
108                         struct fb_videomode *mode);
109         /* setup pixel clock and parent clock programming */
110         long (*setup_clk)(struct tegra_dc *dc, struct clk *clk);
111         /*
112          * return true if display client is suspended during OSidle.
113          * If true, dc will not wait on any display client event
114          * during OSidle.
115          */
116         bool (*osidle)(struct tegra_dc *dc);
117         /* callback before new mode is programmed.
118          * dc clocks are on at this point */
119         void (*modeset_notifier)(struct tegra_dc *dc);
120         /* Set up interface and sink for partial frame update.
121          */
122         int (*partial_update) (struct tegra_dc *dc, unsigned int *xoff,
123                 unsigned int *yoff, unsigned int *width, unsigned int *height);
124         /* refcounted enable of pads and clocks before performing DDC/I2C. */
125         int (*ddc_enable)(struct tegra_dc *dc);
126         /* refcounted disable of pads and clocks after performing DDC/I2C. */
127         int (*ddc_disable)(struct tegra_dc *dc);
128         /* Enable/disable VRR */
129         void (*vrr_enable)(struct tegra_dc *dc, bool enable);
130         /* Mark VRR-compatible modes in fb_info->info->modelist */
131         void (*vrr_update_monspecs)(struct tegra_dc *dc,
132                 struct list_head *head);
133         /* return if hpd asserted or deasserted */
134         bool (*hpd_state) (struct tegra_dc *dc);
135         /* Configure controller to receive hotplug events */
136         int (*hotplug_init)(struct tegra_dc *dc);
137         int (*set_hdr)(struct tegra_dc *dc);
138 };
139
140 struct tegra_dc_shift_clk_div {
141         unsigned long mul; /* numerator */
142         unsigned long div; /* denominator */
143 };
144
145 struct tegra_dc_nvsr_data;
146
147 enum tegra_dc_cursor_size {
148         TEGRA_DC_CURSOR_SIZE_32X32 = 0,
149         TEGRA_DC_CURSOR_SIZE_64X64 = 1,
150         TEGRA_DC_CURSOR_SIZE_128X128 = 2,
151         TEGRA_DC_CURSOR_SIZE_256X256 = 3,
152 };
153
154 enum tegra_dc_cursor_format {
155         TEGRA_DC_CURSOR_FORMAT_2BIT_LEGACY = 0,
156         TEGRA_DC_CURSOR_FORMAT_RGBA_NON_PREMULT_ALPHA = 1,
157         TEGRA_DC_CURSOR_FORMAT_RGBA_PREMULT_ALPHA = 3,
158         TEGRA_DC_CURSOR_FORMAT_RGBA_XOR = 4,
159 };
160
161 struct tegra_dc {
162         struct platform_device          *ndev;
163         struct tegra_dc_platform_data   *pdata;
164
165         struct resource                 *base_res;
166         void __iomem                    *base;
167         int                             irq;
168
169         struct clk                      *clk;
170 #ifdef CONFIG_TEGRA_ISOMGR
171         tegra_isomgr_handle             isomgr_handle;
172 #else
173         struct clk                      *emc_clk;
174 #endif
175         struct clk                      *emc_la_clk;
176         long                            bw_kbps; /* bandwidth in KBps */
177         long                            new_bw_kbps;
178         struct tegra_dc_shift_clk_div   shift_clk_div;
179
180         u32                             powergate_id;
181         int                             sor_instance;
182
183         bool                            connected;
184         bool                            enabled;
185         bool                            suspended;
186         bool                            blanked;
187
188         /* Some of the setup code could reset display even if
189          * DC is already by bootloader.  This one-time mark is
190          * used to suppress such code blocks during system boot,
191          * a.k.a the call stack above tegra_dc_probe().
192          */
193         bool                            initialized;
194
195         struct tegra_dc_out             *out;
196         struct tegra_dc_out_ops         *out_ops;
197         void                            *out_data;
198
199         struct tegra_dc_mode            mode;
200         s64                             frametime_ns;
201
202 #ifndef CONFIG_TEGRA_NVDISPLAY
203         struct tegra_dc_win             windows[DC_N_WINDOWS];
204 #endif
205         struct tegra_dc_win             shadow_windows[DC_N_WINDOWS];
206
207         struct tegra_dc_blend           blend;
208         int                             n_windows;
209         struct tegra_dc_hdr             hdr;
210
211 #if defined(CONFIG_TEGRA_DC_CMU)
212         struct tegra_dc_cmu             cmu;
213 #elif defined(CONFIG_TEGRA_DC_CMU_V2)
214         struct tegra_dc_lut             cmu;
215 #endif
216
217 #if defined(CONFIG_TEGRA_DC_CMU) || defined(CONFIG_TEGRA_DC_CMU_V2)
218         struct tegra_dc_cmu             cmu_shadow;
219         bool                            cmu_dirty;
220         /* Is CMU set by bootloader */
221         bool                            is_cmu_set_bl;
222         bool                            cmu_shadow_dirty;
223         bool                            cmu_shadow_force_update;
224         bool                            cmu_enabled;
225 #endif
226         wait_queue_head_t               wq;
227         wait_queue_head_t               timestamp_wq;
228
229         struct mutex                    lp_lock;
230         struct mutex                    lock;
231         struct mutex                    one_shot_lock;
232
233         struct resource                 *fb_mem;
234         struct tegra_fb_info            *fb;
235 #ifdef CONFIG_ADF_TEGRA
236         struct tegra_adf_info           *adf;
237 #endif
238
239         u32                             vblank_syncpt;
240
241         unsigned long int               valid_windows;
242
243         unsigned long                   underflow_mask;
244         struct work_struct              reset_work;
245
246 #ifdef CONFIG_SWITCH
247         struct switch_dev               modeset_switch;
248 #endif
249
250         struct completion               frame_end_complete;
251         struct completion               crc_complete;
252         bool                            crc_pending;
253
254         struct work_struct              vblank_work;
255         long                            vblank_ref_count;
256         struct work_struct              frame_end_work;
257         struct work_struct              vpulse2_work;
258         long                            vpulse2_ref_count;
259
260         struct {
261                 u64                     underflows;
262                 u64                     underflows_a;
263                 u64                     underflows_b;
264                 u64                     underflows_c;
265                 u64                     underflows_d;
266                 u64                     underflows_h;
267                 u64                     underflows_t;
268                 u64                     underflow_frames;
269         } stats;
270
271 #ifdef CONFIG_TEGRA_DC_EXTENSIONS
272         struct tegra_dc_ext             *ext;
273 #endif
274
275         struct tegra_dc_feature         *feature;
276         int                             gen1_blend_num;
277
278 #ifdef CONFIG_DEBUG_FS
279         struct dentry                   *debugdir;
280 #endif
281         struct tegra_dc_lut             fb_lut;
282         struct delayed_work             underflow_work;
283         u32                             one_shot_delay_ms;
284         struct delayed_work             one_shot_work;
285         s64                             frame_end_timestamp;
286         atomic_t                        frame_end_ref;
287
288         bool                            mode_dirty;
289         bool                            yuv_bypass;
290         atomic_t                        holding;
291
292         u32                             reserved_bw;
293         u32                             available_bw;
294         struct tegra_dc_win             tmp_wins[DC_N_WINDOWS];
295
296         struct tegra_edid               *edid;
297
298         struct tegra_dc_nvsr_data *nvsr;
299
300         bool    disp_active_dirty;
301
302         struct tegra_dc_cursor {
303                 bool dirty;
304                 bool enabled;
305                 dma_addr_t phys_addr;
306                 u32 fg;
307                 u32 bg;
308                 unsigned clip_win;
309                 int x;
310                 int y;
311                 enum tegra_dc_cursor_size size;
312                 enum tegra_dc_cursor_format format;
313         } cursor;
314
315         int     ctrl_num;
316         bool    switchdev_registered;
317
318         struct notifier_block slgc_notifier;
319         bool    vedid;
320         u8      *vedid_data;
321         bool    hdr_cache_dirty;
322 };
323 #endif