blob: e775d7aa062fa9d746944ac7178bb2a5d890610b [file] [log] [blame]
Harry Wentland45622362017-09-12 15:58:20 -04001/*
2 * Copyright 2015 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#ifndef __DC_HW_SEQUENCER_H__
27#define __DC_HW_SEQUENCER_H__
Bhawanpreet Lakhafb3466a2017-08-01 15:00:25 -040028#include "dc_types.h"
29#include "clock_source.h"
30#include "inc/hw/timing_generator.h"
Yue Hin Laub51adc77e2017-12-04 16:58:11 -050031#include "inc/hw/opp.h"
Andrew Jiang87401962017-09-25 18:03:14 -040032#include "inc/hw/link_encoder.h"
Bhawanpreet Lakhafb3466a2017-08-01 15:00:25 -040033#include "core_status.h"
Harry Wentland45622362017-09-12 15:58:20 -040034
Harry Wentland45622362017-09-12 15:58:20 -040035enum pipe_gating_control {
36 PIPE_GATING_CONTROL_DISABLE = 0,
37 PIPE_GATING_CONTROL_ENABLE,
38 PIPE_GATING_CONTROL_INIT
39};
40
Yongqiang Sund6001ae2019-01-25 14:40:14 -050041enum vline_select {
42 VLINE0,
43 VLINE1
44};
45
Charlene Liuf0828112017-02-28 15:23:38 -050046struct dce_hwseq_wa {
47 bool blnd_crtc_trigger;
Yongqiang Sun7f914a62017-11-06 14:40:31 -050048 bool DEGVIDCN10_253;
Yongqiang Sun5cc26872017-11-15 16:21:34 -050049 bool false_optc_underflow;
Dmytro Laktyushkin7144d3c2018-06-05 13:14:13 -040050 bool DEGVIDCN10_254;
Bhawanpreet Lakhaaa919162019-07-26 17:16:47 -040051 bool DEGVIDCN21;
Yongqiang Sun7f914a62017-11-06 14:40:31 -050052};
53
54struct hwseq_wa_state {
55 bool DEGVIDCN10_253_applied;
Charlene Liuf0828112017-02-28 15:23:38 -050056};
57
58struct dce_hwseq {
59 struct dc_context *ctx;
60 const struct dce_hwseq_registers *regs;
61 const struct dce_hwseq_shift *shifts;
62 const struct dce_hwseq_mask *masks;
63 struct dce_hwseq_wa wa;
Yongqiang Sun7f914a62017-11-06 14:40:31 -050064 struct hwseq_wa_state wa_state;
Charlene Liuf0828112017-02-28 15:23:38 -050065};
66
Bhawanpreet Lakhafb3466a2017-08-01 15:00:25 -040067struct pipe_ctx;
Jerry Zuo608ac7b2017-08-25 16:16:10 -040068struct dc_state;
Harry Wentland7ed4e632019-02-22 16:52:08 -050069#if defined(CONFIG_DRM_AMD_DC_DCN2_0)
70struct dc_stream_status;
71struct dc_writeback_info;
72#endif
Bhawanpreet Lakhafb3466a2017-08-01 15:00:25 -040073struct dchub_init_data;
74struct dc_static_screen_events;
75struct resource_pool;
76struct resource_context;
Eric Bernstein31582232018-04-09 17:19:27 -040077struct stream_resource;
Harry Wentland7ed4e632019-02-22 16:52:08 -050078#ifdef CONFIG_DRM_AMD_DC_DCN2_0
Dmytro Laktyushkinbda9afd2019-05-22 18:05:41 -040079struct dc_phy_addr_space_config;
80struct dc_virtual_addr_space_config;
Harry Wentland7ed4e632019-02-22 16:52:08 -050081#endif
Martin Leung8a318202019-07-09 15:15:17 -040082struct hubp;
83struct dpp;
Harry Wentland45622362017-09-12 15:58:20 -040084
85struct hw_sequencer_funcs {
86
Gary Kattan240d09d2019-01-25 15:04:14 -080087 void (*disable_stream_gating)(struct dc *dc, struct pipe_ctx *pipe_ctx);
88
89 void (*enable_stream_gating)(struct dc *dc, struct pipe_ctx *pipe_ctx);
90
Bhawanpreet Lakhafb3466a2017-08-01 15:00:25 -040091 void (*init_hw)(struct dc *dc);
Harry Wentland45622362017-09-12 15:58:20 -040092
Anthony Koofb555462019-01-20 01:23:07 -050093 void (*init_pipes)(struct dc *dc, struct dc_state *context);
94
Harry Wentland45622362017-09-12 15:58:20 -040095 enum dc_status (*apply_ctx_to_hw)(
Jerry Zuo608ac7b2017-08-25 16:16:10 -040096 struct dc *dc, struct dc_state *context);
Harry Wentland45622362017-09-12 15:58:20 -040097
98 void (*reset_hw_ctx_wrap)(
Jerry Zuo608ac7b2017-08-25 16:16:10 -040099 struct dc *dc, struct dc_state *context);
Harry Wentland45622362017-09-12 15:58:20 -0400100
Harry Wentland45622362017-09-12 15:58:20 -0400101 void (*apply_ctx_for_surface)(
Bhawanpreet Lakhafb3466a2017-08-01 15:00:25 -0400102 struct dc *dc,
Eric Yang3e9ad6162017-08-03 00:22:25 -0400103 const struct dc_stream_state *stream,
104 int num_planes,
Jerry Zuo608ac7b2017-08-25 16:16:10 -0400105 struct dc_state *context);
Harry Wentland45622362017-09-12 15:58:20 -0400106
Zeyu Fan1bf56e62017-06-02 17:25:49 -0400107 void (*program_gamut_remap)(
108 struct pipe_ctx *pipe_ctx);
109
Eric Bernstein8e357612018-04-09 15:47:42 -0400110 void (*program_output_csc)(struct dc *dc,
111 struct pipe_ctx *pipe_ctx,
112 enum dc_color_space colorspace,
113 uint16_t *matrix,
114 int opp_id);
115
Harry Wentland7ed4e632019-02-22 16:52:08 -0500116#if defined(CONFIG_DRM_AMD_DC_DCN2_0)
Dmytro Laktyushkinb6e881c2019-09-13 18:00:28 -0500117 void (*program_front_end_for_ctx)(
118 struct dc *dc,
119 struct dc_state *context);
Harry Wentland7ed4e632019-02-22 16:52:08 -0500120 void (*program_triplebuffer)(
121 const struct dc *dc,
122 struct pipe_ctx *pipe_ctx,
123 bool enableTripleBuffer);
124 void (*set_flip_control_gsl)(
125 struct pipe_ctx *pipe_ctx,
126 bool flip_immediate);
127#endif
128
Harry Wentland45622362017-09-12 15:58:20 -0400129 void (*update_plane_addr)(
Bhawanpreet Lakhafb3466a2017-08-01 15:00:25 -0400130 const struct dc *dc,
Harry Wentland45622362017-09-12 15:58:20 -0400131 struct pipe_ctx *pipe_ctx);
132
Eric Bernsteinc2437b12018-05-16 16:19:50 -0400133 void (*plane_atomic_disconnect)(
134 struct dc *dc,
135 struct pipe_ctx *pipe_ctx);
136
Zeyu Fan08b16882017-07-23 18:30:15 -0400137 void (*update_dchub)(
138 struct dce_hwseq *hws,
139 struct dchub_init_data *dh_data);
140
Harry Wentland7ed4e632019-02-22 16:52:08 -0500141#ifdef CONFIG_DRM_AMD_DC_DCN2_0
Dmytro Laktyushkinbda9afd2019-05-22 18:05:41 -0400142 int (*init_sys_ctx)(
143 struct dce_hwseq *hws,
144 struct dc *dc,
145 struct dc_phy_addr_space_config *pa_config);
146 void (*init_vm_ctx)(
147 struct dce_hwseq *hws,
148 struct dc *dc,
149 struct dc_virtual_addr_space_config *va_config,
150 int vmid);
Harry Wentland7ed4e632019-02-22 16:52:08 -0500151#endif
Eric Bernsteinc2437b12018-05-16 16:19:50 -0400152 void (*update_mpcc)(
153 struct dc *dc,
154 struct pipe_ctx *pipe_ctx);
155
Harry Wentland45622362017-09-12 15:58:20 -0400156 void (*update_pending_status)(
157 struct pipe_ctx *pipe_ctx);
158
Anthony Koo90e508b2016-12-15 12:09:46 -0500159 bool (*set_input_transfer_func)(
Anthony Koofb735a92016-12-13 13:59:41 -0500160 struct pipe_ctx *pipe_ctx,
Harry Wentland3be5262e2017-07-27 09:55:38 -0400161 const struct dc_plane_state *plane_state);
Harry Wentland45622362017-09-12 15:58:20 -0400162
Anthony Koo90e508b2016-12-15 12:09:46 -0500163 bool (*set_output_transfer_func)(
164 struct pipe_ctx *pipe_ctx,
Harry Wentland0971c402017-07-27 09:33:33 -0400165 const struct dc_stream_state *stream);
Anthony Koo90e508b2016-12-15 12:09:46 -0500166
Bhawanpreet Lakhafb3466a2017-08-01 15:00:25 -0400167 void (*power_down)(struct dc *dc);
Harry Wentland45622362017-09-12 15:58:20 -0400168
Yongqiang Sun25292022017-12-19 11:51:40 -0500169 void (*enable_accelerated_mode)(struct dc *dc, struct dc_state *context);
Harry Wentland45622362017-09-12 15:58:20 -0400170
171 void (*enable_timing_synchronization)(
Bhawanpreet Lakhafb3466a2017-08-01 15:00:25 -0400172 struct dc *dc,
Harry Wentland45622362017-09-12 15:58:20 -0400173 int group_index,
174 int group_size,
175 struct pipe_ctx *grouped_pipes[]);
176
Mikita Lipskifa2123d2017-10-17 15:29:22 -0400177 void (*enable_per_frame_crtc_position_reset)(
178 struct dc *dc,
179 int group_size,
180 struct pipe_ctx *grouped_pipes[]);
181
Harry Wentland45622362017-09-12 15:58:20 -0400182 void (*enable_display_pipe_clock_gating)(
183 struct dc_context *ctx,
184 bool clock_gating);
185
186 bool (*enable_display_power_gating)(
Bhawanpreet Lakhafb3466a2017-08-01 15:00:25 -0400187 struct dc *dc,
Harry Wentland45622362017-09-12 15:58:20 -0400188 uint8_t controller_id,
189 struct dc_bios *dcb,
190 enum pipe_gating_control power_gating);
191
Yongqiang Sun7f914a62017-11-06 14:40:31 -0500192 void (*disable_plane)(struct dc *dc, struct pipe_ctx *pipe_ctx);
Yongqiang Sun18f7a1e2017-03-23 10:34:06 -0400193
Harry Wentland45622362017-09-12 15:58:20 -0400194 void (*update_info_frame)(struct pipe_ctx *pipe_ctx);
195
Leo (Hanghong) Ma88ccdf12019-04-16 11:07:22 -0400196 void (*send_immediate_sdp_message)(
197 struct pipe_ctx *pipe_ctx,
198 const uint8_t *custom_sdp_message,
199 unsigned int sdp_message_size);
200
Harry Wentland45622362017-09-12 15:58:20 -0400201 void (*enable_stream)(struct pipe_ctx *pipe_ctx);
202
Su Sung Chung57430402019-07-25 14:43:55 -0400203 void (*disable_stream)(struct pipe_ctx *pipe_ctx);
Harry Wentland45622362017-09-12 15:58:20 -0400204
205 void (*unblank_stream)(struct pipe_ctx *pipe_ctx,
206 struct dc_link_settings *link_settings);
207
Charlene Liu41b49742018-01-11 15:31:26 -0500208 void (*blank_stream)(struct pipe_ctx *pipe_ctx);
Anthony Koo1a058732018-05-10 14:21:47 -0400209
210 void (*enable_audio_stream)(struct pipe_ctx *pipe_ctx);
211
Su Sung Chung57430402019-07-25 14:43:55 -0400212 void (*disable_audio_stream)(struct pipe_ctx *pipe_ctx);
Anthony Koo1a058732018-05-10 14:21:47 -0400213
Harry Wentland45622362017-09-12 15:58:20 -0400214 void (*pipe_control_lock)(
Bhawanpreet Lakhafb3466a2017-08-01 15:00:25 -0400215 struct dc *dc,
Charlene Liuf0828112017-02-28 15:23:38 -0500216 struct pipe_ctx *pipe,
Harry Wentland45622362017-09-12 15:58:20 -0400217 bool lock);
Wenjing Liu6c5be4a2019-03-05 19:28:10 -0500218
Wenjing Liuc23f95a2019-03-05 19:28:10 -0500219 void (*pipe_control_lock_global)(
220 struct dc *dc,
221 struct pipe_ctx *pipe,
222 bool lock);
Eric Bernstein31582232018-04-09 17:19:27 -0400223 void (*blank_pixel_data)(
224 struct dc *dc,
Eric Bernsteinea4a2022018-05-01 15:21:42 -0400225 struct pipe_ctx *pipe_ctx,
Eric Bernstein31582232018-04-09 17:19:27 -0400226 bool blank);
Harry Wentland45622362017-09-12 15:58:20 -0400227
Dmytro Laktyushkin9566b672018-09-18 15:00:49 -0400228 void (*prepare_bandwidth)(
Bhawanpreet Lakhafb3466a2017-08-01 15:00:25 -0400229 struct dc *dc,
Dmytro Laktyushkin9566b672018-09-18 15:00:49 -0400230 struct dc_state *context);
231 void (*optimize_bandwidth)(
232 struct dc *dc,
233 struct dc_state *context);
Harry Wentland45622362017-09-12 15:58:20 -0400234
Joseph Gravenor9ae1b272019-09-04 12:43:05 -0400235 void (*exit_optimized_pwr_state)(
236 const struct dc *dc,
237 struct dc_state *context);
238 void (*optimize_pwr_state)(
239 const struct dc *dc,
240 struct dc_state *context);
241
Harry Wentland7ed4e632019-02-22 16:52:08 -0500242#if defined(CONFIG_DRM_AMD_DC_DCN2_0)
243 bool (*update_bandwidth)(
244 struct dc *dc,
245 struct dc_state *context);
Julian Parkinf5913442019-07-03 13:59:26 -0400246 void (*program_dmdata_engine)(struct pipe_ctx *pipe_ctx);
Harry Wentland7ed4e632019-02-22 16:52:08 -0500247 bool (*dmdata_status_done)(struct pipe_ctx *pipe_ctx);
248#endif
249
Harry Wentland45622362017-09-12 15:58:20 -0400250 void (*set_drr)(struct pipe_ctx **pipe_ctx, int num_pipes,
Bayan Zabihiyan470e2ca2019-08-08 11:08:52 -0400251 unsigned int vmin, unsigned int vmax,
252 unsigned int vmid, unsigned int vmid_frame_number);
Harry Wentland45622362017-09-12 15:58:20 -0400253
Eric Cook72ada5f2017-04-18 15:24:50 -0400254 void (*get_position)(struct pipe_ctx **pipe_ctx, int num_pipes,
255 struct crtc_position *position);
256
Harry Wentland45622362017-09-12 15:58:20 -0400257 void (*set_static_screen_control)(struct pipe_ctx **pipe_ctx,
Sylvia Tsai94267b32017-04-21 15:29:55 -0400258 int num_pipes, const struct dc_static_screen_events *events);
Harry Wentland45622362017-09-12 15:58:20 -0400259
Eric Bernstein31582232018-04-09 17:19:27 -0400260 enum dc_status (*enable_stream_timing)(
Harry Wentland45622362017-09-12 15:58:20 -0400261 struct pipe_ctx *pipe_ctx,
Jerry Zuo608ac7b2017-08-25 16:16:10 -0400262 struct dc_state *context,
Bhawanpreet Lakhafb3466a2017-08-01 15:00:25 -0400263 struct dc *dc);
Vitaly Prosyak9edba552017-06-07 12:23:59 -0500264
265 void (*setup_stereo)(
266 struct pipe_ctx *pipe_ctx,
Bhawanpreet Lakhafb3466a2017-08-01 15:00:25 -0400267 struct dc *dc);
Charlene Liu15e17332017-07-17 16:04:02 -0400268
269 void (*set_avmute)(struct pipe_ctx *pipe_ctx, bool enable);
Tony Cheng6d244be2017-07-20 00:12:20 -0400270
Nicholas Kazlauskas46659a82018-08-15 12:00:23 -0400271 void (*log_hw_state)(struct dc *dc,
272 struct dc_log_buffer_ctx *log_ctx);
Jun Leidd730432018-08-08 11:53:39 -0400273 void (*get_hw_state)(struct dc *dc, char *pBuf, unsigned int bufSize, unsigned int mask);
Jun Leieb6b29d2018-10-23 12:12:50 -0400274 void (*clear_status_bits)(struct dc *dc, unsigned int mask);
Eric Yang87480682017-07-23 15:18:57 -0400275
Bhawanpreet Lakhafb3466a2017-08-01 15:00:25 -0400276 void (*wait_for_mpcc_disconnect)(struct dc *dc,
Eric Yang6be425f2017-07-24 10:47:02 -0400277 struct resource_pool *res_pool,
278 struct pipe_ctx *pipe_ctx);
Hersen Wu41f97c02017-08-24 17:40:00 -0400279
Andrew Jiang87401962017-09-25 18:03:14 -0400280 void (*edp_power_control)(
Andrew Jiang069d4182017-09-26 19:45:43 -0400281 struct dc_link *link,
Andrew Jiang87401962017-09-25 18:03:14 -0400282 bool enable);
283 void (*edp_backlight_control)(
Yue Hin Lau5eefbc42017-09-15 17:42:20 -0400284 struct dc_link *link,
285 bool enable);
Yongqiang Sun904623e2017-11-24 16:31:03 -0500286 void (*edp_wait_for_hpd_ready)(struct dc_link *link, bool power_up);
Hersen Wu631aaa02017-10-31 15:55:15 -0400287
Eric Yang33fd17d92018-01-18 19:07:54 -0500288 void (*set_cursor_position)(struct pipe_ctx *pipe);
289 void (*set_cursor_attribute)(struct pipe_ctx *pipe);
Krunoslav Kovac6d92b5c2018-06-27 18:23:37 -0400290 void (*set_cursor_sdr_white_level)(struct pipe_ctx *pipe);
Eric Bernstein8e357612018-04-09 15:47:42 -0400291
Yongqiang Sund6001ae2019-01-25 14:40:14 -0500292 void (*setup_periodic_interrupt)(struct pipe_ctx *pipe_ctx, enum vline_select vline);
293 void (*setup_vupdate_interrupt)(struct pipe_ctx *pipe_ctx);
Thomas Lim1a7d2962019-04-29 16:05:42 -0400294 bool (*did_underflow_occur)(struct dc *dc, struct pipe_ctx *pipe_ctx);
Yongqiang Sund6001ae2019-01-25 14:40:14 -0500295
Martin Leung8a318202019-07-09 15:15:17 -0400296 void (*init_blank)(struct dc *dc, struct timing_generator *tg);
297 void (*disable_vga)(struct dce_hwseq *hws);
298 void (*bios_golden_init)(struct dc *dc);
299 void (*plane_atomic_power_down)(struct dc *dc,
300 struct dpp *dpp,
301 struct hubp *hubp);
302
303 void (*plane_atomic_disable)(
304 struct dc *dc, struct pipe_ctx *pipe_ctx);
305
306 void (*enable_power_gating_plane)(
307 struct dce_hwseq *hws,
308 bool enable);
309
310 void (*dpp_pg_control)(
311 struct dce_hwseq *hws,
312 unsigned int dpp_inst,
313 bool power_on);
314
315 void (*hubp_pg_control)(
316 struct dce_hwseq *hws,
317 unsigned int hubp_inst,
318 bool power_on);
319
320 void (*dsc_pg_control)(
321 struct dce_hwseq *hws,
322 unsigned int dsc_inst,
323 bool power_on);
324
325
Harry Wentland7ed4e632019-02-22 16:52:08 -0500326#if defined(CONFIG_DRM_AMD_DC_DCN2_0)
327 void (*update_odm)(struct dc *dc, struct dc_state *context, struct pipe_ctx *pipe_ctx);
328 void (*program_all_writeback_pipes_in_tree)(
329 struct dc *dc,
330 const struct dc_stream_state *stream,
331 struct dc_state *context);
332 void (*update_writeback)(struct dc *dc,
333 const struct dc_stream_status *stream_status,
Julian Parkinedb922b02019-08-29 17:06:05 -0400334 struct dc_writeback_info *wb_info,
335 struct dc_state *context);
Harry Wentland7ed4e632019-02-22 16:52:08 -0500336 void (*enable_writeback)(struct dc *dc,
337 const struct dc_stream_status *stream_status,
Julian Parkinedb922b02019-08-29 17:06:05 -0400338 struct dc_writeback_info *wb_info,
339 struct dc_state *context);
Harry Wentland7ed4e632019-02-22 16:52:08 -0500340 void (*disable_writeback)(struct dc *dc,
341 unsigned int dwb_pipe_inst);
342#endif
Charlene Liu925f5662019-06-27 18:16:21 -0400343 enum dc_status (*set_clock)(struct dc *dc,
344 enum dc_clock_type clock_type,
345 uint32_t clk_khz,
346 uint32_t stepping);
347
348 void (*get_clock)(struct dc *dc,
349 enum dc_clock_type clock_type,
350 struct dc_clock_config *clock_cfg);
351
Harry Wentland45622362017-09-12 15:58:20 -0400352};
353
354void color_space_to_black_color(
Bhawanpreet Lakhafb3466a2017-08-01 15:00:25 -0400355 const struct dc *dc,
Harry Wentland45622362017-09-12 15:58:20 -0400356 enum dc_color_space colorspace,
357 struct tg_color *black_color);
358
Hersen Wu4b5e7d62017-01-06 16:23:18 -0500359bool hwss_wait_for_blank_complete(
360 struct timing_generator *tg);
361
Vitaly Prosyak38cb3e92017-12-01 11:42:18 -0600362const uint16_t *find_color_matrix(
363 enum dc_color_space color_space,
364 uint32_t *array_size);
365
Harry Wentland45622362017-09-12 15:58:20 -0400366#endif /* __DC_HW_SEQUENCER_H__ */