1 /*
2  * Copyright 2022 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_LINK_EDP_PANEL_CONTROL_H__
27 #define __DC_LINK_EDP_PANEL_CONTROL_H__
28 #include "link.h"
29 
30 enum dp_panel_mode dp_get_panel_mode(struct dc_link *link);
31 void dp_set_panel_mode(struct dc_link *link, enum dp_panel_mode panel_mode);
32 bool set_default_brightness_aux(struct dc_link *link);
33 void edp_panel_backlight_power_on(struct dc_link *link, bool wait_for_hpd);
34 int edp_get_backlight_level(const struct dc_link *link);
35 bool edp_get_backlight_level_nits(struct dc_link *link,
36 		uint32_t *backlight_millinits_avg,
37 		uint32_t *backlight_millinits_peak);
38 bool edp_set_backlight_level(const struct dc_link *link,
39 		uint32_t backlight_pwm_u16_16,
40 		uint32_t frame_ramp);
41 bool edp_set_backlight_level_nits(struct dc_link *link,
42 		bool isHDR,
43 		uint32_t backlight_millinits,
44 		uint32_t transition_time_in_ms);
45 int edp_get_target_backlight_pwm(const struct dc_link *link);
46 bool edp_get_psr_state(const struct dc_link *link, enum dc_psr_state *state);
47 bool edp_set_psr_allow_active(struct dc_link *link, const bool *allow_active,
48 		bool wait, bool force_static, const unsigned int *power_opts);
49 bool edp_setup_psr(struct dc_link *link,
50 		const struct dc_stream_state *stream, struct psr_config *psr_config,
51 		struct psr_context *psr_context);
52 bool edp_set_sink_vtotal_in_psr_active(const struct dc_link *link,
53        uint16_t psr_vtotal_idle, uint16_t psr_vtotal_su);
54 void edp_get_psr_residency(const struct dc_link *link, uint32_t *residency, enum psr_residency_mode mode);
55 bool edp_set_replay_allow_active(struct dc_link *dc_link, const bool *enable,
56 	bool wait, bool force_static, const unsigned int *power_opts);
57 bool edp_setup_replay(struct dc_link *link,
58 		const struct dc_stream_state *stream);
59 bool edp_send_replay_cmd(struct dc_link *link,
60 			enum replay_FW_Message_type msg,
61 			union dmub_replay_cmd_set *cmd_data);
62 bool edp_set_coasting_vtotal(struct dc_link *link, uint32_t coasting_vtotal);
63 bool edp_replay_residency(const struct dc_link *link,
64 	unsigned int *residency, const bool is_start, const enum pr_residency_mode mode);
65 bool edp_get_replay_state(const struct dc_link *link, uint64_t *state);
66 bool edp_set_replay_power_opt_and_coasting_vtotal(struct dc_link *link,
67 	const unsigned int *power_opts, uint32_t coasting_vtotal);
68 bool edp_wait_for_t12(struct dc_link *link);
69 bool edp_is_ilr_optimization_required(struct dc_link *link,
70        struct dc_crtc_timing *crtc_timing);
71 bool edp_is_ilr_optimization_enabled(struct dc_link *link);
72 enum dc_link_rate get_max_edp_link_rate(struct dc_link *link);
73 bool edp_backlight_enable_aux(struct dc_link *link, bool enable);
74 void edp_add_delay_for_T9(struct dc_link *link);
75 bool edp_receiver_ready_T9(struct dc_link *link);
76 bool edp_receiver_ready_T7(struct dc_link *link);
77 bool edp_power_alpm_dpcd_enable(struct dc_link *link, bool enable);
78 void edp_set_panel_power(struct dc_link *link, bool powerOn);
79 void edp_set_panel_assr(struct dc_link *link, struct pipe_ctx *pipe_ctx,
80 		enum dp_panel_mode *panel_mode, bool enable);
81 #endif /* __DC_LINK_EDP_POWER_CONTROL_H__ */
82