drm/amd/dc: Add dc display driver (v2)
[linux-2.6-block.git] / drivers / gpu / drm / amd / display / modules / inc / mod_freesync.h
CommitLineData
4562236b
HW
1/*
2 * Copyright 2016 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: AMD
23 *
24 */
25
26
27
28
29/*
30 * Copyright 2016 Advanced Micro Devices, Inc.
31 *
32 * Permission is hereby granted, free of charge, to any person obtaining a
33 * copy of this software and associated documentation files (the "Software"),
34 * to deal in the Software without restriction, including without limitation
35 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
36 * and/or sell copies of the Software, and to permit persons to whom the
37 * Software is furnished to do so, subject to the following conditions:
38 *
39 * The above copyright notice and this permission notice shall be included in
40 * all copies or substantial portions of the Software.
41 *
42 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
45 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
46 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
47 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
48 * OTHER DEALINGS IN THE SOFTWARE.
49 *
50 * Authors: AMD
51 *
52 */
53
54#ifndef MOD_FREESYNC_H_
55#define MOD_FREESYNC_H_
56
57#include "dm_services.h"
58
59struct mod_freesync *mod_freesync_create(struct dc *dc);
60void mod_freesync_destroy(struct mod_freesync *mod_freesync);
61
62struct mod_freesync {
63 int dummy;
64};
65
66enum mod_freesync_state {
67 FREESYNC_STATE_NONE,
68 FREESYNC_STATE_FULLSCREEN,
69 FREESYNC_STATE_STATIC_SCREEN,
70 FREESYNC_STATE_VIDEO
71};
72
73enum mod_freesync_user_enable_mask {
74 FREESYNC_USER_ENABLE_STATIC = 0x1,
75 FREESYNC_USER_ENABLE_VIDEO = 0x2,
76 FREESYNC_USER_ENABLE_GAMING = 0x4
77};
78
79struct mod_freesync_user_enable {
80 bool enable_for_static;
81 bool enable_for_video;
82 bool enable_for_gaming;
83};
84
85struct mod_freesync_caps {
86 bool supported;
87 unsigned int min_refresh_in_micro_hz;
88 unsigned int max_refresh_in_micro_hz;
89
90 bool btr_supported;
91};
92
93struct mod_freesync_params {
94 enum mod_freesync_state state;
95 bool enable;
96 unsigned int update_duration_in_ns;
97 bool windowed_fullscreen;
98};
99
100/*
101 * Add stream to be tracked by module
102 */
103bool mod_freesync_add_stream(struct mod_freesync *mod_freesync,
104 const struct dc_stream *stream, struct mod_freesync_caps *caps);
105
106/*
107 * Remove stream to be tracked by module
108 */
109bool mod_freesync_remove_stream(struct mod_freesync *mod_freesync,
110 const struct dc_stream *stream);
111
112/*
113 * Build additional parameters for dc_stream when creating stream for
114 * sink to support freesync
115 */
116void mod_freesync_update_stream(struct mod_freesync *mod_freesync,
117 struct dc_stream *stream);
118
119/*
120 * Update the freesync state flags for each display and program
121 * freesync accordingly
122 */
123void mod_freesync_update_state(struct mod_freesync *mod_freesync,
124 const struct dc_stream **streams, int num_streams,
125 struct mod_freesync_params *freesync_params);
126
127bool mod_freesync_get_state(struct mod_freesync *mod_freesync,
128 const struct dc_stream *stream,
129 struct mod_freesync_params *freesync_params);
130
131bool mod_freesync_set_user_enable(struct mod_freesync *mod_freesync,
132 const struct dc_stream **streams, int num_streams,
133 struct mod_freesync_user_enable *user_enable);
134
135bool mod_freesync_get_user_enable(struct mod_freesync *mod_freesync,
136 const struct dc_stream *stream,
137 struct mod_freesync_user_enable *user_enable);
138
139void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync,
140 const struct dc_stream **streams, int num_streams);
141
142void mod_freesync_notify_mode_change(struct mod_freesync *mod_freesync,
143 const struct dc_stream **streams, int num_streams);
144
145void mod_freesync_pre_update_plane_addresses(struct mod_freesync *mod_freesync,
146 const struct dc_stream **streams, int num_streams,
147 unsigned int curr_time_stamp);
148
149#endif