178c77382SAnthony Koo /*
278c77382SAnthony Koo  * Copyright 2016 Advanced Micro Devices, Inc.
378c77382SAnthony Koo  *
478c77382SAnthony Koo  * Permission is hereby granted, free of charge, to any person obtaining a
578c77382SAnthony Koo  * copy of this software and associated documentation files (the "Software"),
678c77382SAnthony Koo  * to deal in the Software without restriction, including without limitation
778c77382SAnthony Koo  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
878c77382SAnthony Koo  * and/or sell copies of the Software, and to permit persons to whom the
978c77382SAnthony Koo  * Software is furnished to do so, subject to the following conditions:
1078c77382SAnthony Koo  *
1178c77382SAnthony Koo  * The above copyright notice and this permission notice shall be included in
1278c77382SAnthony Koo  * all copies or substantial portions of the Software.
1378c77382SAnthony Koo  *
1478c77382SAnthony Koo  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1578c77382SAnthony Koo  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1678c77382SAnthony Koo  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1778c77382SAnthony Koo  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
1878c77382SAnthony Koo  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1978c77382SAnthony Koo  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2078c77382SAnthony Koo  * OTHER DEALINGS IN THE SOFTWARE.
2178c77382SAnthony Koo  *
2278c77382SAnthony Koo  * Authors: AMD
2378c77382SAnthony Koo  *
2478c77382SAnthony Koo  */
2578c77382SAnthony Koo 
2678c77382SAnthony Koo #include "dce110/dce110_hw_sequencer.h"
2778c77382SAnthony Koo #include "dcn10/dcn10_hw_sequencer.h"
2878c77382SAnthony Koo #include "dcn20_hwseq.h"
2978c77382SAnthony Koo 
3078c77382SAnthony Koo static const struct hw_sequencer_funcs dcn20_funcs = {
3178c77382SAnthony Koo 	.program_gamut_remap = dcn10_program_gamut_remap,
3278c77382SAnthony Koo 	.init_hw = dcn10_init_hw,
33ca751df2SSung Lee 	.power_down_on_boot =  dcn10_power_down_on_boot,
3478c77382SAnthony Koo 	.apply_ctx_to_hw = dce110_apply_ctx_to_hw,
3578c77382SAnthony Koo 	.apply_ctx_for_surface = NULL,
3678c77382SAnthony Koo 	.program_front_end_for_ctx = dcn20_program_front_end_for_ctx,
37bbf5f6c3SAnthony Koo 	.post_unlock_program_front_end = dcn20_post_unlock_program_front_end,
3878c77382SAnthony Koo 	.update_plane_addr = dcn20_update_plane_addr,
3978c77382SAnthony Koo 	.update_dchub = dcn10_update_dchub,
4078c77382SAnthony Koo 	.update_pending_status = dcn10_update_pending_status,
4178c77382SAnthony Koo 	.program_output_csc = dcn20_program_output_csc,
4278c77382SAnthony Koo 	.enable_accelerated_mode = dce110_enable_accelerated_mode,
4378c77382SAnthony Koo 	.enable_timing_synchronization = dcn10_enable_timing_synchronization,
4478c77382SAnthony Koo 	.enable_per_frame_crtc_position_reset = dcn10_enable_per_frame_crtc_position_reset,
4578c77382SAnthony Koo 	.update_info_frame = dce110_update_info_frame,
4678c77382SAnthony Koo 	.send_immediate_sdp_message = dcn10_send_immediate_sdp_message,
4778c77382SAnthony Koo 	.enable_stream = dcn20_enable_stream,
4878c77382SAnthony Koo 	.disable_stream = dce110_disable_stream,
4978c77382SAnthony Koo 	.unblank_stream = dcn20_unblank_stream,
5078c77382SAnthony Koo 	.blank_stream = dce110_blank_stream,
5178c77382SAnthony Koo 	.enable_audio_stream = dce110_enable_audio_stream,
5278c77382SAnthony Koo 	.disable_audio_stream = dce110_disable_audio_stream,
5378c77382SAnthony Koo 	.disable_plane = dcn20_disable_plane,
5478c77382SAnthony Koo 	.pipe_control_lock = dcn20_pipe_control_lock,
55009114f6SAnthony Koo 	.interdependent_update_lock = dcn10_lock_all_pipes,
561e461c37SAric Cyr 	.cursor_lock = dcn10_cursor_lock,
5778c77382SAnthony Koo 	.prepare_bandwidth = dcn20_prepare_bandwidth,
5878c77382SAnthony Koo 	.optimize_bandwidth = dcn20_optimize_bandwidth,
5978c77382SAnthony Koo 	.update_bandwidth = dcn20_update_bandwidth,
6078c77382SAnthony Koo 	.set_drr = dcn10_set_drr,
6178c77382SAnthony Koo 	.get_position = dcn10_get_position,
6278c77382SAnthony Koo 	.set_static_screen_control = dcn10_set_static_screen_control,
6378c77382SAnthony Koo 	.setup_stereo = dcn10_setup_stereo,
6478c77382SAnthony Koo 	.set_avmute = dce110_set_avmute,
6578c77382SAnthony Koo 	.log_hw_state = dcn10_log_hw_state,
6678c77382SAnthony Koo 	.get_hw_state = dcn10_get_hw_state,
6778c77382SAnthony Koo 	.clear_status_bits = dcn10_clear_status_bits,
6878c77382SAnthony Koo 	.wait_for_mpcc_disconnect = dcn10_wait_for_mpcc_disconnect,
6978c77382SAnthony Koo 	.edp_power_control = dce110_edp_power_control,
7078c77382SAnthony Koo 	.edp_wait_for_hpd_ready = dce110_edp_wait_for_hpd_ready,
7178c77382SAnthony Koo 	.set_cursor_position = dcn10_set_cursor_position,
7278c77382SAnthony Koo 	.set_cursor_attribute = dcn10_set_cursor_attribute,
7378c77382SAnthony Koo 	.set_cursor_sdr_white_level = dcn10_set_cursor_sdr_white_level,
7478c77382SAnthony Koo 	.setup_periodic_interrupt = dcn10_setup_periodic_interrupt,
7578c77382SAnthony Koo 	.set_clock = dcn10_set_clock,
7678c77382SAnthony Koo 	.get_clock = dcn10_get_clock,
77f42ea55bSAnthony Koo 	.program_triplebuffer = dcn20_program_triple_buffer,
78f42ea55bSAnthony Koo 	.enable_writeback = dcn20_enable_writeback,
79f42ea55bSAnthony Koo 	.disable_writeback = dcn20_disable_writeback,
80f42ea55bSAnthony Koo 	.dmdata_status_done = dcn20_dmdata_status_done,
81f42ea55bSAnthony Koo 	.program_dmdata_engine = dcn20_program_dmdata_engine,
82f42ea55bSAnthony Koo 	.set_dmdata_attributes = dcn20_set_dmdata_attributes,
83f42ea55bSAnthony Koo 	.init_sys_ctx = dcn20_init_sys_ctx,
84f42ea55bSAnthony Koo 	.init_vm_ctx = dcn20_init_vm_ctx,
85f42ea55bSAnthony Koo 	.set_flip_control_gsl = dcn20_set_flip_control_gsl,
86f42ea55bSAnthony Koo 	.get_vupdate_offset_from_vsync = dcn10_get_vupdate_offset_from_vsync,
8763731e73SNicholas Kazlauskas 	.calc_vupdate_position = dcn10_calc_vupdate_position,
884b0e95d1SYongqiang Sun 	.set_backlight_level = dce110_set_backlight_level,
893ba01817SYongqiang Sun 	.set_abm_immediate_disable = dce110_set_abm_immediate_disable,
90474ac4a8SYongqiang Sun 	.set_pipe = dce110_set_pipe,
91cc0f379dSReza Amini #ifndef TRIM_FSFT
92cc0f379dSReza Amini 	.optimize_timing_for_fsft = dcn20_optimize_timing_for_fsft,
93cc0f379dSReza Amini #endif
94f42ea55bSAnthony Koo };
95f42ea55bSAnthony Koo 
96f42ea55bSAnthony Koo static const struct hwseq_private_funcs dcn20_private_funcs = {
97f42ea55bSAnthony Koo 	.init_pipes = dcn10_init_pipes,
98f42ea55bSAnthony Koo 	.update_plane_addr = dcn20_update_plane_addr,
99f42ea55bSAnthony Koo 	.plane_atomic_disconnect = dcn10_plane_atomic_disconnect,
100f42ea55bSAnthony Koo 	.update_mpcc = dcn20_update_mpcc,
101f42ea55bSAnthony Koo 	.set_input_transfer_func = dcn20_set_input_transfer_func,
102f42ea55bSAnthony Koo 	.set_output_transfer_func = dcn20_set_output_transfer_func,
103f42ea55bSAnthony Koo 	.power_down = dce110_power_down,
104f42ea55bSAnthony Koo 	.enable_display_power_gating = dcn10_dummy_display_power_gating,
105f42ea55bSAnthony Koo 	.blank_pixel_data = dcn20_blank_pixel_data,
106f42ea55bSAnthony Koo 	.reset_hw_ctx_wrap = dcn20_reset_hw_ctx_wrap,
107f42ea55bSAnthony Koo 	.enable_stream_timing = dcn20_enable_stream_timing,
108f42ea55bSAnthony Koo 	.edp_backlight_control = dce110_edp_backlight_control,
109f42ea55bSAnthony Koo 	.disable_stream_gating = dcn20_disable_stream_gating,
110f42ea55bSAnthony Koo 	.enable_stream_gating = dcn20_enable_stream_gating,
111f42ea55bSAnthony Koo 	.setup_vupdate_interrupt = dcn20_setup_vupdate_interrupt,
11278c77382SAnthony Koo 	.did_underflow_occur = dcn10_did_underflow_occur,
11378c77382SAnthony Koo 	.init_blank = dcn20_init_blank,
11478c77382SAnthony Koo 	.disable_vga = dcn20_disable_vga,
11578c77382SAnthony Koo 	.bios_golden_init = dcn10_bios_golden_init,
11678c77382SAnthony Koo 	.plane_atomic_disable = dcn20_plane_atomic_disable,
11778c77382SAnthony Koo 	.plane_atomic_power_down = dcn10_plane_atomic_power_down,
11878c77382SAnthony Koo 	.enable_power_gating_plane = dcn20_enable_power_gating_plane,
11978c77382SAnthony Koo 	.dpp_pg_control = dcn20_dpp_pg_control,
12078c77382SAnthony Koo 	.hubp_pg_control = dcn20_hubp_pg_control,
12178c77382SAnthony Koo 	.update_odm = dcn20_update_odm,
12278c77382SAnthony Koo 	.dsc_pg_control = dcn20_dsc_pg_control,
12378c77382SAnthony Koo 	.get_surface_visual_confirm_color = dcn10_get_surface_visual_confirm_color,
12478c77382SAnthony Koo 	.get_hdr_visual_confirm_color = dcn10_get_hdr_visual_confirm_color,
12578c77382SAnthony Koo 	.set_hdr_multiplier = dcn10_set_hdr_multiplier,
12678c77382SAnthony Koo 	.verify_allow_pstate_change_high = dcn10_verify_allow_pstate_change_high,
12778c77382SAnthony Koo 	.wait_for_blank_complete = dcn20_wait_for_blank_complete,
12878c77382SAnthony Koo 	.dccg_init = dcn20_dccg_init,
12978c77382SAnthony Koo 	.set_blend_lut = dcn20_set_blend_lut,
13078c77382SAnthony Koo 	.set_shaper_3dlut = dcn20_set_shaper_3dlut,
13178c77382SAnthony Koo };
13278c77382SAnthony Koo 
13378c77382SAnthony Koo void dcn20_hw_sequencer_construct(struct dc *dc)
13478c77382SAnthony Koo {
13578c77382SAnthony Koo 	dc->hwss = dcn20_funcs;
136f42ea55bSAnthony Koo 	dc->hwseq->funcs = dcn20_private_funcs;
13778c77382SAnthony Koo 
13878c77382SAnthony Koo 	if (IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment)) {
13978c77382SAnthony Koo 		dc->hwss.init_hw = dcn20_fpga_init_hw;
140f42ea55bSAnthony Koo 		dc->hwseq->funcs.init_pipes = NULL;
14178c77382SAnthony Koo 	}
14278c77382SAnthony Koo }
143