2 * Copyright 2012-14 Advanced Micro Devices, Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
30 #include "grph_object_defs.h"
32 /*******************************************************************************
34 ******************************************************************************/
36 struct dc_stream_status {
40 struct dc_plane_state *plane_states[MAX_SURFACE_NUM];
43 * link this stream passes through
48 // TODO: References to this needs to be removed..
49 struct freesync_context {
53 struct dc_stream_state {
55 struct dc_crtc_timing timing;
56 struct dc_crtc_timing_adjust adjust;
57 struct dc_info_packet vrr_infopacket;
58 struct dc_info_packet vsc_infopacket;
59 struct dc_info_packet vsp_infopacket;
61 struct rect src; /* composition area */
62 struct rect dst; /* stream addressable area */
64 // TODO: References to this needs to be removed..
65 struct freesync_context freesync_ctx;
67 struct audio_info audio_info;
69 struct dc_info_packet hdr_static_metadata;
70 PHYSICAL_ADDRESS_LOC dmdata_address;
71 bool use_dynamic_meta;
73 struct dc_transfer_func *out_transfer_func;
74 struct colorspace_transform gamut_remap_matrix;
75 struct dc_csc_transform csc_color_matrix;
77 enum dc_color_space output_color_space;
78 enum dc_dither_option dither_option;
80 enum view_3d_format view_format;
82 bool ignore_msa_timing_param;
84 unsigned long long periodic_fn_vsync_delta;
86 /* TODO: custom INFO packets */
87 /* TODO: ABM info (DMCU) */
89 unsigned char psr_version;
93 unsigned int abm_level;
94 unsigned int bl_pwm_level;
96 /* from core_stream struct */
97 struct dc_context *ctx;
99 /* used by DCP and FMT */
100 struct bit_depth_reduction_params bit_depth_params;
101 struct clamping_and_pixel_encoding_params clamping;
104 enum signal_type signal;
106 bool apply_edp_fast_boot_optimization;
108 struct dc_cursor_attributes cursor_attributes;
109 struct dc_cursor_position cursor_position;
110 uint32_t sdr_white_level; // for boosting (SDR) cursor in HDR mode
112 /* from stream struct */
113 struct kref refcount;
115 struct crtc_trigger_info triggered_crtc_reset;
117 /* Computed state bits */
118 bool mode_changed : 1;
122 struct dc_stream_update {
125 struct dc_transfer_func *out_transfer_func;
126 struct dc_info_packet *hdr_static_metadata;
127 unsigned int *abm_level;
129 unsigned long long *periodic_fn_vsync_delta;
130 struct dc_crtc_timing_adjust *adjust;
131 struct dc_info_packet *vrr_infopacket;
132 struct dc_info_packet *vsc_infopacket;
133 struct dc_info_packet *vsp_infopacket;
137 struct colorspace_transform *gamut_remap;
138 enum dc_color_space *output_color_space;
139 enum dc_dither_option *dither_option;
141 struct dc_csc_transform *output_csc_transform;
145 bool dc_is_stream_unchanged(
146 struct dc_stream_state *old_stream, struct dc_stream_state *stream);
147 bool dc_is_stream_scaling_unchanged(
148 struct dc_stream_state *old_stream, struct dc_stream_state *stream);
151 * Set up surface attributes and associate to a stream
152 * The surfaces parameter is an absolute set of all surface active for the stream.
153 * If no surfaces are provided, the stream will be blanked; no memory read.
154 * Any flip related attribute changes must be done through this interface.
157 * Surfaces attributes are programmed and configured to be composed into stream.
158 * This does not trigger a flip. No surface address is programmed.
161 void dc_commit_updates_for_stream(struct dc *dc,
162 struct dc_surface_update *srf_updates,
164 struct dc_stream_state *stream,
165 struct dc_stream_update *stream_update,
166 struct dc_plane_state **plane_states,
167 struct dc_state *state);
169 * Log the current stream state.
171 void dc_stream_log(const struct dc *dc, const struct dc_stream_state *stream);
173 uint8_t dc_get_current_stream_count(struct dc *dc);
174 struct dc_stream_state *dc_get_stream_at_index(struct dc *dc, uint8_t i);
177 * Return the current frame counter.
179 uint32_t dc_stream_get_vblank_counter(const struct dc_stream_state *stream);
181 /* TODO: Return parsed values rather than direct register read
182 * This has a dependency on the caller (amdgpu_display_get_crtc_scanoutpos)
183 * being refactored properly to be dce-specific
185 bool dc_stream_get_scanoutpos(const struct dc_stream_state *stream,
186 uint32_t *v_blank_start,
187 uint32_t *v_blank_end,
188 uint32_t *h_position,
189 uint32_t *v_position);
191 enum dc_status dc_add_stream_to_ctx(
193 struct dc_state *new_ctx,
194 struct dc_stream_state *stream);
196 enum dc_status dc_remove_stream_from_ctx(
198 struct dc_state *new_ctx,
199 struct dc_stream_state *stream);
202 bool dc_add_plane_to_context(
204 struct dc_stream_state *stream,
205 struct dc_plane_state *plane_state,
206 struct dc_state *context);
208 bool dc_remove_plane_from_context(
210 struct dc_stream_state *stream,
211 struct dc_plane_state *plane_state,
212 struct dc_state *context);
214 bool dc_rem_all_planes_for_stream(
216 struct dc_stream_state *stream,
217 struct dc_state *context);
219 bool dc_add_all_planes_for_stream(
221 struct dc_stream_state *stream,
222 struct dc_plane_state * const *plane_states,
224 struct dc_state *context);
226 enum dc_status dc_validate_stream(struct dc *dc, struct dc_stream_state *stream);
229 * Set up streams and links associated to drive sinks
230 * The streams parameter is an absolute set of all active streams.
233 * Phy, Encoder, Timing Generator are programmed and enabled.
234 * New streams are enabled with blank stream; no memory read.
237 * Enable stereo when commit_streams is not required,
238 * for example, frame alternate.
240 bool dc_enable_stereo(
242 struct dc_state *context,
243 struct dc_stream_state *streams[],
244 uint8_t stream_count);
247 enum surface_update_type dc_check_update_surfaces_for_stream(
249 struct dc_surface_update *updates,
251 struct dc_stream_update *stream_update,
252 const struct dc_stream_status *stream_status);
255 * Create a new default stream for the requested sink
257 struct dc_stream_state *dc_create_stream_for_sink(struct dc_sink *dc_sink);
259 void update_stream_signal(struct dc_stream_state *stream);
261 void dc_stream_retain(struct dc_stream_state *dc_stream);
262 void dc_stream_release(struct dc_stream_state *dc_stream);
264 struct dc_stream_status *dc_stream_get_status(
265 struct dc_stream_state *dc_stream);
267 /*******************************************************************************
268 * Cursor interfaces - To manages the cursor within a stream
269 ******************************************************************************/
270 /* TODO: Deprecated once we switch to dc_set_cursor_position */
271 bool dc_stream_set_cursor_attributes(
272 struct dc_stream_state *stream,
273 const struct dc_cursor_attributes *attributes);
275 bool dc_stream_set_cursor_position(
276 struct dc_stream_state *stream,
277 const struct dc_cursor_position *position);
280 bool dc_stream_adjust_vmin_vmax(struct dc *dc,
281 struct dc_stream_state *stream,
282 struct dc_crtc_timing_adjust *adjust);
284 bool dc_stream_get_crtc_position(struct dc *dc,
285 struct dc_stream_state **stream,
288 unsigned int *nom_v_pos);
290 bool dc_stream_configure_crc(struct dc *dc,
291 struct dc_stream_state *stream,
295 bool dc_stream_get_crc(struct dc *dc,
296 struct dc_stream_state *stream,
301 void dc_stream_set_static_screen_events(struct dc *dc,
302 struct dc_stream_state **stream,
304 const struct dc_static_screen_events *events);
306 void dc_stream_set_dither_option(struct dc_stream_state *stream,
307 enum dc_dither_option option);
309 bool dc_stream_set_gamut_remap(struct dc *dc,
310 const struct dc_stream_state *stream);
312 bool dc_stream_program_csc_matrix(struct dc *dc,
313 struct dc_stream_state *stream);
315 bool dc_stream_get_crtc_position(struct dc *dc,
316 struct dc_stream_state **stream,
319 unsigned int *nom_v_pos);
321 #endif /* DC_STREAM_H_ */