summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/amd/display/modules/inc/mod_power.h
blob: f9814cf7bbdb142704360026588f28b424ac601d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
/* Copyright (c) 2019 Advanced Micro Devices, Inc. All rights reserved. */

#ifndef MODULES_INC_MOD_POWER_H_
#define MODULES_INC_MOD_POWER_H_

#include "dm_services.h"

struct core_power;

struct mod_power_init_params {

	bool disable_fractional_pwm;

	/* Use nits based brightness instead of brightness percentage
	 */
	bool use_nits_based_brightness;
	unsigned int panel_min_millinits;
	unsigned int panel_max_millinits;

	unsigned int min_backlight_pwm;
	unsigned int max_backlight_pwm;

	unsigned int min_abm_backlight;
	unsigned int num_backlight_levels;
	bool backlight_ramping_override;
	unsigned int backlight_ramping_reduction;
	unsigned int backlight_ramping_start;
	bool def_varibright_enable;
	unsigned int def_varibright_level;
	unsigned int varibright_level;
	unsigned int abm_config_setting;

	bool allow_psr_smu_optimizations;

	bool allow_psr_multi_disp_optimizations;

	bool use_custom_backlight_caps;
	unsigned int custom_backlight_caps_config_no;
	bool use_linear_backlight_curve;
};

struct mod_power {
	int dummy;
};

/* VariBright settings structure */
struct varibright_info {
	unsigned int level;
	bool enable;
	bool activate;
};

struct mod_power_psr_context {
    /* ddc line */
    unsigned int channel;
    /* Transmitter id */
    unsigned int transmitter_id;
    /* Engine Id is used for Dig Be source select */
    unsigned int engine_id;
    /* Controller Id used for Dig Fe source select */
    unsigned int controller_id;
    /* Pcie or Uniphy */
    unsigned int phy_type;
    /* Physical PHY Id used by SMU interpretation */
    unsigned int smu_phy_id;
    /* Vertical total pixels from crtc timing.
     * This is used for static screen detection.
     * ie. If we want to detect half a frame,
     * we use this to determine the hyst lines.
     */
    unsigned int crtc_timing_vertical_total;
    /* PSR supported from panel capabilities and
     * current display configuration
     */
    bool psr_supported_display_config;
    /* Whether fast link training is supported by the panel */
    bool psr_exit_link_training_required;
    /* If RFB setup time is greater than the total VBLANK time,
     * it is not possible for the sink to capture the video frame
     * in the same frame the SDP is sent. In this case,
     * the frame capture indication bit should be set and an extra
     * static frame should be transmitted to the sink.
     */
    bool psr_frame_capture_indication_req;
    /* Set the last possible line SDP may be transmitted without violating
     * the RFB setup time or entering the active video frame.
     */
    unsigned int sdp_transmit_line_num_deadline;
    /* The VSync rate in Hz used to calculate the
     * step size for smooth brightness feature
     */
    unsigned int vsync_rate_hz;
    unsigned int skip_psr_wait_for_pll_lock;
    unsigned int number_of_controllers;
    /* Unused, for future use. To indicate that first changed frame from
     * state3 shouldn't result in psr_inactive, but rather to perform
     * an automatic single frame rfb_update.
     */
    bool rfb_update_auto_en;
    /* Number of frame before entering static screen */
    unsigned int timehyst_frames;
    /* Partial frames before entering static screen */
    unsigned int hyst_lines;
    /* # of repeated AUX transaction attempts to make before
     * indicating failure to the driver
     */
    unsigned int aux_repeats;
    /* Controls hw blocks to power down during PSR active state */
    unsigned int psr_level;
    /* Controls additional delay after remote frame capture before
     * continuing powerd own
     */
	unsigned int frame_delay;
	bool allow_smu_optimizations;
	bool allow_multi_disp_optimizations;
	unsigned int line_time_in_us;
	/* Panel self refresh 2 selective update granularity required */
	bool su_granularity_required;
	/* psr2 selective update y granularity capability */
	uint8_t su_y_granularity;
	uint8_t rate_control_caps;
	bool os_request_force_ffu;
};

enum psr_event {
	psr_event_invalid = 0x0,
	psr_event_vsync = 0x1,
	psr_event_full_screen = 0x2,
	psr_event_defer_enable = 0x4,
	psr_event_hw_programming = 0x8,
	psr_event_test_harness_enable_psr = 0x10,
	psr_event_test_harness_disable_psr = 0x20,
	psr_event_mpo_video_selective_update = 0x40,
	psr_event_edp_panel_off_disable_psr = 0x80,
	psr_event_dynamic_display_switch = 0x100,
	psr_event_big_screen_video = 0x200,
	psr_event_dds_defer_stream_enable = 0x800,
	psr_event_dynamic_link_rate_control = 0x1000,
	psr_event_vrr_transition = 0x2000,
	psr_event_pause = 0x4000,
	psr_event_immediate_flip = 0x8000,
	psr_event_os_request_disable = 0x10000,
	psr_event_os_request_force_ffu = 0x20000,
	psr_event_os_override_hold = 0x40000,
	psr_event_crc_window_active = 0x80000,
};

enum replay_event {
	replay_event_invalid = 0x0,
	replay_event_vsync = 0x1,
	replay_event_full_screen = 0x2,
	replay_event_mpo_video_selective_update = 0x4,
	replay_event_big_screen_video = 0x8,
	replay_event_hw_programming = 0x10,
	replay_event_edp_panel_off_disable_psr = 0x20,
	replay_event_general_ui = 0x40,
	replay_event_vrr = 0x80,
	replay_event_prepare_vtotal = 0x100,
	replay_event_test_harness_enable_replay = 0x200,
	replay_event_test_harness_disable_replay = 0x400,
	replay_event_test_harness_ultra_sleep = 0x800,
	replay_event_immediate_flip = 0x1000,
	replay_event_vrr_transition = 0x2000,
	replay_event_pause = 0x4000,
	replay_event_disable_replay_while_DPMS = 0x8000,
	replay_event_test_harness_mode = 0x10000,
	replay_event_cursor_updating = 0x20000,
	replay_event_sleep_resume = 0x40000,
	replay_event_disable_in_AC = 0x80000,
	replay_event_disable_replay_while_detect_display = 0x100000,
	replay_event_disable_replay_while_switching_mux = 0x400000,
	replay_event_infopacket = 0x800000,
	replay_event_os_request_disable = 0x1000000,
	replay_event_os_request_force_ffu = 0x2000000,
	replay_event_os_override_hold = 0x4000000,
	replay_event_crc_window_active = 0x8000000,
};

enum replay_enable_option {
	pr_enable_option_static_screen = 0x1,
	pr_enable_option_mpo_video = 0x2,
	pr_enable_option_full_screen_video = 0x4,
	pr_enable_option_general_ui = 0x8,
	pr_enable_option_full_screen = 0x10,
	pr_enable_option_static_screen_coasting = 0x10000,
	pr_enable_option_mpo_video_coasting = 0x20000,
	pr_enable_option_full_screen_video_coasting = 0x40000,
	pr_enable_option_full_screen_coasting = 0x100000,
};

struct mod_power *mod_power_create(struct dc *dc,
		struct mod_power_init_params *init_params,
		unsigned int edp_num);

void mod_power_destroy(struct mod_power *mod_power);

bool mod_power_hw_init(struct mod_power *mod_power);

bool mod_power_add_stream(struct mod_power *mod_power,
		struct dc_stream_state *stream, struct psr_caps *caps);

bool mod_power_remove_stream(struct mod_power *mod_power,
		const struct dc_stream_state *stream);

bool mod_power_replace_stream(struct mod_power *mod_power,
		const struct dc_stream_state *current_stream,
		struct dc_stream_state *new_stream,
		struct psr_caps *new_caps);

bool mod_power_set_backlight_nits(struct mod_power *mod_power,
		struct dc_stream_state *streams,
		unsigned int backlight_millinit,
		unsigned int transition_time_millisec,
		bool skip_aux,
		bool is_hdr);

bool mod_power_set_backlight_percent(struct mod_power *mod_power,
		struct dc_stream_state *stream,
		unsigned int backlight_millipercent,
		unsigned int transition_time_millisec,
		bool is_hdr);

void mod_power_update_backlight(struct mod_power *mod_power,
		struct dc_stream_state *stream,
		unsigned int backlight_millipercent);

void mod_power_update_backlight_nits(struct mod_power *mod_power,
		struct dc_stream_state *stream,
		unsigned int backlight_millinit);

bool mod_power_get_backlight_pwm(struct mod_power *mod_power,
		unsigned int *backlight_pwm,
		unsigned int inst);

bool mod_power_get_backlight_nits(struct mod_power *mod_power,
		unsigned int *backlight_millinit,
		unsigned int inst);

bool mod_power_get_backlight_percent(struct mod_power *mod_power,
		unsigned int *backlight_millipercent,
		unsigned int inst);

bool mod_power_get_hw_target_backlight_pwm_nits(
		struct mod_power *mod_power,
		const struct dc_link *link,
		unsigned int *backlight_millinit,
		unsigned int inst);

bool mod_power_get_hw_target_backlight_pwm_percent(
		struct mod_power *mod_power,
		const struct dc_link *link,
		unsigned int *backlight_millipercent,
		unsigned int inst);

bool mod_power_get_hw_target_backlight_pwm(
		struct mod_power *mod_power,
		const struct dc_link *link,
		unsigned int *backlight_u16_16);

bool mod_power_get_hw_backlight_pwm(
		struct mod_power *mod_power,
		const struct dc_link *link,
		unsigned int *backlight);

bool mod_power_get_hw_backlight_pwm_nits(
		struct mod_power *mod_power,
		const struct dc_link *link,
		unsigned int *backlight_millinit,
		unsigned int inst);

bool mod_power_get_hw_backlight_aux_nits(
		struct mod_power *mod_power,
		struct dc_stream_state **streams, int num_streams,
		unsigned int *backlight_millinit_avg,
		unsigned int *backlight_millinit_peak);

bool mod_power_get_hw_backlight_pwm_percent(
		struct mod_power *mod_power,
		const struct dc_link *link,
		unsigned int *backlight_millipercent,
		unsigned int inst);

void mod_power_initialize_backlight_caps
		(struct mod_power *mod_power);

bool mod_power_get_panel_backlight_boundaries
				(struct mod_power *mod_power,
				unsigned int *out_min_backlight,
				unsigned int *out_max_backlight,
				unsigned int *out_ac_backlight_percent,
				unsigned int *out_dc_backlight_percent,
				unsigned int inst);

bool mod_power_set_smooth_brightness(struct mod_power *mod_power,
		bool enable_brightness,
		unsigned int inst);

bool mod_power_notify_mode_change(struct mod_power *mod_power,
		const struct dc_stream_state *stream,
		bool is_hdr);

bool mod_power_get_varibright_level(struct mod_power *mod_power,
		unsigned int *varibright_level);

bool mod_power_get_varibright_hw_level(struct mod_power *mod_power,
		unsigned int *varibright_level);

bool mod_power_get_varibright_default_level(struct mod_power *mod_power,
		unsigned int *varibright_level);

bool mod_power_get_varibright_enable(struct mod_power *mod_power,
		bool *varibright_enable);

bool mod_power_varibright_activate(struct mod_power	*mod_power,
		bool activate, struct dc_stream_update *stream_update);

bool mod_power_varibright_feature_enable(struct mod_power *mod_power,
		bool enable, struct dc_stream_update *stream_update);


bool mod_power_varibright_set_level(struct mod_power *mod_power,
		unsigned int level, struct dc_stream_update *stream_update);

bool mod_power_varibright_set_hw_level(struct mod_power *mod_power,
		unsigned int level,	struct dc_stream_update *stream_update);

bool mod_power_is_abm_active(struct mod_power *mod_power,
		const struct dc_link *link,
		unsigned int inst);


bool mod_power_set_psr_event(struct mod_power *mod_power,
		struct dc_stream_state *stream, bool set_event,
		enum psr_event event, bool wait);

bool mod_power_get_psr_event(struct mod_power *mod_power,
			struct dc_stream_state *stream,
			unsigned int *active_psr_events);

bool mod_power_get_psr_state(struct mod_power *mod_power,
		const struct dc_stream_state *stream,
		enum dc_psr_state *state);

bool mod_power_get_psr_enabled_status(struct mod_power *mod_power,
		const struct dc_stream_state *stream,
		bool *psr_enabled);

bool mod_power_set_replay_event(struct mod_power *mod_power,
	struct dc_stream_state *stream, bool set_event,
	enum replay_event event, bool wait_for_disable);

bool mod_power_get_replay_event(struct mod_power *mod_power,
	struct dc_stream_state *stream,
	unsigned int *active_replay_events);

bool mod_power_get_replay_active_status(const struct dc_stream_state *stream,
	bool *replay_active);

bool mod_power_replay_set_coasting_vtotal(struct mod_power *mod_power,
	const struct dc_stream_state *stream,
	uint32_t coasting_vtotal, uint16_t frame_skip_number);

void mod_power_replay_residency(const struct dc_stream_state *stream,
	unsigned int *residency, const bool is_start, const bool is_alpm);

bool mod_power_replay_set_power_opt_and_coasting_vtotal(struct mod_power *mod_power,
	const struct dc_stream_state *stream, unsigned int active_replay_events, uint32_t coasting_vtotal,
	bool is_ultra_sleep_mode, uint16_t frame_skip_number);

void mod_power_replay_set_timing_sync_supported(struct mod_power *mod_power,
	const struct dc_stream_state *stream);

void mod_power_replay_disabled_adaptive_sync_sdp(struct mod_power *mod_power,
	const struct dc_stream_state *stream, bool force_disabled);

void mod_power_replay_disabled_desync_error_detection(struct mod_power *mod_power,
	const struct dc_stream_state *stream,  bool force_disabled);
void mod_power_set_low_rr_activate(struct mod_power *mod_power,
	const struct dc_stream_state *stream, bool low_rr_supported);

void mod_power_set_video_conferencing_activate(struct mod_power *mod_power,
	const struct dc_stream_state *stream, bool video_conferencing_activate);

void mod_power_set_live_capture_with_cvt_activate(struct mod_power *mod_power,
	const struct dc_stream_state *stream, bool live_capture_with_cvt_activate);

void mod_power_set_replay_continuously_resync(struct mod_power *mod_power,
	const struct dc_stream_state *stream, bool enable);

void mod_power_set_coasting_vtotal_without_frame_update(struct mod_power *mod_power,
	const struct dc_stream_state *stream, uint32_t coasting_vtotal);



void mod_power_psr_residency(struct mod_power *mod_power,
		const struct dc_stream_state *stream,
		unsigned int *residency,
		const uint8_t mode);
bool mod_power_psr_get_active_psr_events(struct mod_power *mod_power,
		const struct dc_stream_state *stream, unsigned int *active_psr_events);
bool mod_power_psr_set_sink_vtotal_in_psr_active(struct mod_power *mod_power,
		const struct dc_stream_state *stream,
		uint16_t psr_vtotal_idle,
		uint16_t psr_vtotal_su);



bool mod_power_backlight_percent_to_nits(struct mod_power *mod_power,
		struct dc_stream_state *stream,
		unsigned int backlight_millipercent,
		unsigned int *backlight_millinit);
bool mod_power_backlight_nits_to_percent(struct mod_power *mod_power,
		struct dc_stream_state *stream,
		unsigned int backlight_millinit,
		unsigned int *backlight_millipercent);

#endif /* MODULES_INC_MOD_POWER_H_ */