2 * Copyright 2015 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.
25 #include <linux/slab.h>
28 #include "dm_services.h"
32 #include "core_status.h"
33 #include "core_types.h"
34 #include "hw_sequencer.h"
35 #include "dce/dce_hwseq.h"
40 #include "clock_source.h"
41 #include "dc_bios_types.h"
43 #include "bios_parser_interface.h"
44 #include "include/irq_service_interface.h"
45 #include "transform.h"
48 #include "timing_generator.h"
50 #include "virtual/virtual_link_encoder.h"
52 #include "link_hwss.h"
53 #include "link_encoder.h"
55 #include "dc_link_ddc.h"
56 #include "dm_helpers.h"
57 #include "mem_input.h"
60 #include "dc_link_dp.h"
61 #include "dc_dmub_srv.h"
65 #include "vm_helper.h"
67 #include "dce/dce_i2c.h"
69 #include "dmub/dmub_srv.h"
71 #include "dce/dmub_hw_lock_mgr.h"
81 static const char DC_BUILD_ID[] = "production-build";
86 * DC is the OS-agnostic component of the amdgpu DC driver.
88 * DC maintains and validates a set of structs representing the state of the
89 * driver and writes that state to AMD hardware
93 * struct dc - The central struct. One per driver. Created on driver load,
94 * destroyed on driver unload.
96 * struct dc_context - One per driver.
97 * Used as a backpointer by most other structs in dc.
99 * struct dc_link - One per connector (the physical DP, HDMI, miniDP, or eDP
100 * plugpoints). Created on driver load, destroyed on driver unload.
102 * struct dc_sink - One per display. Created on boot or hotplug.
103 * Destroyed on shutdown or hotunplug. A dc_link can have a local sink
104 * (the display directly attached). It may also have one or more remote
105 * sinks (in the Multi-Stream Transport case)
107 * struct resource_pool - One per driver. Represents the hw blocks not in the
108 * main pipeline. Not directly accessible by dm.
110 * Main dc state structs:
112 * These structs can be created and destroyed as needed. There is a full set of
113 * these structs in dc->current_state representing the currently programmed state.
115 * struct dc_state - The global DC state to track global state information,
116 * such as bandwidth values.
118 * struct dc_stream_state - Represents the hw configuration for the pipeline from
119 * a framebuffer to a display. Maps one-to-one with dc_sink.
121 * struct dc_plane_state - Represents a framebuffer. Each stream has at least one,
122 * and may have more in the Multi-Plane Overlay case.
124 * struct resource_context - Represents the programmable state of everything in
125 * the resource_pool. Not directly accessible by dm.
127 * struct pipe_ctx - A member of struct resource_context. Represents the
128 * internal hardware pipeline components. Each dc_plane_state has either
129 * one or two (in the pipe-split case).
132 /*******************************************************************************
134 ******************************************************************************/
136 static inline void elevate_update_type(enum surface_update_type *original, enum surface_update_type new)
142 static void destroy_links(struct dc *dc)
146 for (i = 0; i < dc->link_count; i++) {
147 if (NULL != dc->links[i])
148 link_destroy(&dc->links[i]);
152 static bool create_links(
154 uint32_t num_virtual_links)
158 struct dc_bios *bios = dc->ctx->dc_bios;
162 connectors_num = bios->funcs->get_connectors_number(bios);
164 if (connectors_num > ENUM_ID_COUNT) {
166 "DC: Number of connectors %d exceeds maximum of %d!\n",
172 dm_output_to_console(
173 "DC: %s: connectors_num: physical:%d, virtual:%d\n",
178 for (i = 0; i < connectors_num; i++) {
179 struct link_init_data link_init_params = {0};
180 struct dc_link *link;
182 link_init_params.ctx = dc->ctx;
183 /* next BIOS object table connector */
184 link_init_params.connector_index = i;
185 link_init_params.link_index = dc->link_count;
186 link_init_params.dc = dc;
187 link = link_create(&link_init_params);
190 bool should_destory_link = false;
192 if (link->connector_signal == SIGNAL_TYPE_EDP) {
193 if (dc->config.edp_not_connected) {
194 if (!IS_DIAG_DC(dc->ctx->dce_environment))
195 should_destory_link = true;
197 enum dc_connection_type type;
198 dc_link_detect_sink(link, &type);
199 if (type == dc_connection_none)
200 should_destory_link = true;
204 if (dc->config.force_enum_edp || !should_destory_link) {
205 dc->links[dc->link_count] = link;
214 for (i = 0; i < num_virtual_links; i++) {
215 struct dc_link *link = kzalloc(sizeof(*link), GFP_KERNEL);
216 struct encoder_init_data enc_init = {0};
223 link->link_index = dc->link_count;
224 dc->links[dc->link_count] = link;
229 link->connector_signal = SIGNAL_TYPE_VIRTUAL;
230 link->link_id.type = OBJECT_TYPE_CONNECTOR;
231 link->link_id.id = CONNECTOR_ID_VIRTUAL;
232 link->link_id.enum_id = ENUM_ID_1;
233 link->link_enc = kzalloc(sizeof(*link->link_enc), GFP_KERNEL);
235 if (!link->link_enc) {
240 link->link_status.dpcd_caps = &link->dpcd_caps;
242 enc_init.ctx = dc->ctx;
243 enc_init.channel = CHANNEL_ID_UNKNOWN;
244 enc_init.hpd_source = HPD_SOURCEID_UNKNOWN;
245 enc_init.transmitter = TRANSMITTER_UNKNOWN;
246 enc_init.connector = link->link_id;
247 enc_init.encoder.type = OBJECT_TYPE_ENCODER;
248 enc_init.encoder.id = ENCODER_ID_INTERNAL_VIRTUAL;
249 enc_init.encoder.enum_id = ENUM_ID_1;
250 virtual_link_encoder_construct(link->link_enc, &enc_init);
259 static struct dc_perf_trace *dc_perf_trace_create(void)
261 return kzalloc(sizeof(struct dc_perf_trace), GFP_KERNEL);
264 static void dc_perf_trace_destroy(struct dc_perf_trace **perf_trace)
271 *****************************************************************************
272 * Function: dc_stream_adjust_vmin_vmax
275 * Looks up the pipe context of dc_stream_state and updates the
276 * vertical_total_min and vertical_total_max of the DRR, Dynamic Refresh
277 * Rate, which is a power-saving feature that targets reducing panel
278 * refresh rate while the screen is static
280 * @param [in] dc: dc reference
281 * @param [in] stream: Initial dc stream state
282 * @param [in] adjust: Updated parameters for vertical_total_min and
284 *****************************************************************************
286 bool dc_stream_adjust_vmin_vmax(struct dc *dc,
287 struct dc_stream_state *stream,
288 struct dc_crtc_timing_adjust *adjust)
293 stream->adjust = *adjust;
295 for (i = 0; i < MAX_PIPES; i++) {
296 struct pipe_ctx *pipe = &dc->current_state->res_ctx.pipe_ctx[i];
298 if (pipe->stream == stream && pipe->stream_res.tg) {
299 dc->hwss.set_drr(&pipe,
304 adjust->v_total_mid_frame_num);
312 bool dc_stream_get_crtc_position(struct dc *dc,
313 struct dc_stream_state **streams, int num_streams,
314 unsigned int *v_pos, unsigned int *nom_v_pos)
316 /* TODO: Support multiple streams */
317 const struct dc_stream_state *stream = streams[0];
320 struct crtc_position position;
322 for (i = 0; i < MAX_PIPES; i++) {
323 struct pipe_ctx *pipe =
324 &dc->current_state->res_ctx.pipe_ctx[i];
326 if (pipe->stream == stream && pipe->stream_res.stream_enc) {
327 dc->hwss.get_position(&pipe, 1, &position);
329 *v_pos = position.vertical_count;
330 *nom_v_pos = position.nominal_vcount;
338 * dc_stream_configure_crc() - Configure CRC capture for the given stream.
340 * @stream: The stream to configure CRC on.
341 * @enable: Enable CRC if true, disable otherwise.
342 * @continuous: Capture CRC on every frame if true. Otherwise, only capture
345 * By default, only CRC0 is configured, and the entire frame is used to
348 bool dc_stream_configure_crc(struct dc *dc, struct dc_stream_state *stream,
349 struct crc_params *crc_window, bool enable, bool continuous)
352 struct pipe_ctx *pipe;
353 struct crc_params param;
354 struct timing_generator *tg;
356 for (i = 0; i < MAX_PIPES; i++) {
357 pipe = &dc->current_state->res_ctx.pipe_ctx[i];
358 if (pipe->stream == stream && !pipe->top_pipe && !pipe->prev_odm_pipe)
361 /* Stream not found */
365 /* By default, capture the full frame */
366 param.windowa_x_start = 0;
367 param.windowa_y_start = 0;
368 param.windowa_x_end = pipe->stream->timing.h_addressable;
369 param.windowa_y_end = pipe->stream->timing.v_addressable;
370 param.windowb_x_start = 0;
371 param.windowb_y_start = 0;
372 param.windowb_x_end = pipe->stream->timing.h_addressable;
373 param.windowb_y_end = pipe->stream->timing.v_addressable;
376 param.windowa_x_start = crc_window->windowa_x_start;
377 param.windowa_y_start = crc_window->windowa_y_start;
378 param.windowa_x_end = crc_window->windowa_x_end;
379 param.windowa_y_end = crc_window->windowa_y_end;
380 param.windowb_x_start = crc_window->windowb_x_start;
381 param.windowb_y_start = crc_window->windowb_y_start;
382 param.windowb_x_end = crc_window->windowb_x_end;
383 param.windowb_y_end = crc_window->windowb_y_end;
386 param.dsc_mode = pipe->stream->timing.flags.DSC ? 1:0;
387 param.odm_mode = pipe->next_odm_pipe ? 1:0;
389 /* Default to the union of both windows */
390 param.selection = UNION_WINDOW_A_B;
391 param.continuous_mode = continuous;
392 param.enable = enable;
394 tg = pipe->stream_res.tg;
396 /* Only call if supported */
397 if (tg->funcs->configure_crc)
398 return tg->funcs->configure_crc(tg, ¶m);
399 DC_LOG_WARNING("CRC capture not supported.");
404 * dc_stream_get_crc() - Get CRC values for the given stream.
406 * @stream: The DC stream state of the stream to get CRCs from.
407 * @r_cr, g_y, b_cb: CRC values for the three channels are stored here.
409 * dc_stream_configure_crc needs to be called beforehand to enable CRCs.
410 * Return false if stream is not found, or if CRCs are not enabled.
412 bool dc_stream_get_crc(struct dc *dc, struct dc_stream_state *stream,
413 uint32_t *r_cr, uint32_t *g_y, uint32_t *b_cb)
416 struct pipe_ctx *pipe;
417 struct timing_generator *tg;
419 for (i = 0; i < MAX_PIPES; i++) {
420 pipe = &dc->current_state->res_ctx.pipe_ctx[i];
421 if (pipe->stream == stream)
424 /* Stream not found */
428 tg = pipe->stream_res.tg;
430 if (tg->funcs->get_crc)
431 return tg->funcs->get_crc(tg, r_cr, g_y, b_cb);
432 DC_LOG_WARNING("CRC capture not supported.");
436 void dc_stream_set_dyn_expansion(struct dc *dc, struct dc_stream_state *stream,
437 enum dc_dynamic_expansion option)
439 /* OPP FMT dyn expansion updates*/
441 struct pipe_ctx *pipe_ctx;
443 for (i = 0; i < MAX_PIPES; i++) {
444 if (dc->current_state->res_ctx.pipe_ctx[i].stream
446 pipe_ctx = &dc->current_state->res_ctx.pipe_ctx[i];
447 pipe_ctx->stream_res.opp->dyn_expansion = option;
448 pipe_ctx->stream_res.opp->funcs->opp_set_dyn_expansion(
449 pipe_ctx->stream_res.opp,
450 COLOR_SPACE_YCBCR601,
451 stream->timing.display_color_depth,
457 void dc_stream_set_dither_option(struct dc_stream_state *stream,
458 enum dc_dither_option option)
460 struct bit_depth_reduction_params params;
461 struct dc_link *link = stream->link;
462 struct pipe_ctx *pipes = NULL;
465 for (i = 0; i < MAX_PIPES; i++) {
466 if (link->dc->current_state->res_ctx.pipe_ctx[i].stream ==
468 pipes = &link->dc->current_state->res_ctx.pipe_ctx[i];
475 if (option > DITHER_OPTION_MAX)
478 stream->dither_option = option;
480 memset(¶ms, 0, sizeof(params));
481 resource_build_bit_depth_reduction_params(stream, ¶ms);
482 stream->bit_depth_params = params;
484 if (pipes->plane_res.xfm &&
485 pipes->plane_res.xfm->funcs->transform_set_pixel_storage_depth) {
486 pipes->plane_res.xfm->funcs->transform_set_pixel_storage_depth(
487 pipes->plane_res.xfm,
488 pipes->plane_res.scl_data.lb_params.depth,
489 &stream->bit_depth_params);
492 pipes->stream_res.opp->funcs->
493 opp_program_bit_depth_reduction(pipes->stream_res.opp, ¶ms);
496 bool dc_stream_set_gamut_remap(struct dc *dc, const struct dc_stream_state *stream)
500 struct pipe_ctx *pipes;
502 for (i = 0; i < MAX_PIPES; i++) {
503 if (dc->current_state->res_ctx.pipe_ctx[i].stream == stream) {
504 pipes = &dc->current_state->res_ctx.pipe_ctx[i];
505 dc->hwss.program_gamut_remap(pipes);
513 bool dc_stream_program_csc_matrix(struct dc *dc, struct dc_stream_state *stream)
517 struct pipe_ctx *pipes;
519 for (i = 0; i < MAX_PIPES; i++) {
520 if (dc->current_state->res_ctx.pipe_ctx[i].stream
523 pipes = &dc->current_state->res_ctx.pipe_ctx[i];
524 dc->hwss.program_output_csc(dc,
526 stream->output_color_space,
527 stream->csc_color_matrix.matrix,
528 pipes->stream_res.opp->inst);
536 void dc_stream_set_static_screen_params(struct dc *dc,
537 struct dc_stream_state **streams,
539 const struct dc_static_screen_params *params)
543 struct pipe_ctx *pipes_affected[MAX_PIPES];
544 int num_pipes_affected = 0;
546 for (i = 0; i < num_streams; i++) {
547 struct dc_stream_state *stream = streams[i];
549 for (j = 0; j < MAX_PIPES; j++) {
550 if (dc->current_state->res_ctx.pipe_ctx[j].stream
552 pipes_affected[num_pipes_affected++] =
553 &dc->current_state->res_ctx.pipe_ctx[j];
558 dc->hwss.set_static_screen_control(pipes_affected, num_pipes_affected, params);
561 static void dc_destruct(struct dc *dc)
563 if (dc->current_state) {
564 dc_release_state(dc->current_state);
565 dc->current_state = NULL;
571 dc_destroy_clk_mgr(dc->clk_mgr);
575 dc_destroy_resource_pool(dc);
577 if (dc->ctx->gpio_service)
578 dal_gpio_service_destroy(&dc->ctx->gpio_service);
580 if (dc->ctx->created_bios)
581 dal_bios_parser_destroy(&dc->ctx->dc_bios);
583 dc_perf_trace_destroy(&dc->ctx->perf_trace);
594 #ifdef CONFIG_DRM_AMD_DC_DCN
602 kfree(dc->vm_helper);
603 dc->vm_helper = NULL;
607 static bool dc_construct_ctx(struct dc *dc,
608 const struct dc_init_data *init_params)
610 struct dc_context *dc_ctx;
611 enum dce_version dc_version = DCE_VERSION_UNKNOWN;
613 dc_ctx = kzalloc(sizeof(*dc_ctx), GFP_KERNEL);
617 dc_ctx->cgs_device = init_params->cgs_device;
618 dc_ctx->driver_context = init_params->driver;
620 dc_ctx->asic_id = init_params->asic_id;
621 dc_ctx->dc_sink_id_count = 0;
622 dc_ctx->dc_stream_id_count = 0;
623 dc_ctx->dce_environment = init_params->dce_environment;
627 dc_version = resource_parse_asic_id(init_params->asic_id);
628 dc_ctx->dce_version = dc_version;
630 dc_ctx->perf_trace = dc_perf_trace_create();
631 if (!dc_ctx->perf_trace) {
632 ASSERT_CRITICAL(false);
641 static bool dc_construct(struct dc *dc,
642 const struct dc_init_data *init_params)
644 struct dc_context *dc_ctx;
645 struct bw_calcs_dceip *dc_dceip;
646 struct bw_calcs_vbios *dc_vbios;
647 #ifdef CONFIG_DRM_AMD_DC_DCN
648 struct dcn_soc_bounding_box *dcn_soc;
649 struct dcn_ip_params *dcn_ip;
652 dc->config = init_params->flags;
654 // Allocate memory for the vm_helper
655 dc->vm_helper = kzalloc(sizeof(struct vm_helper), GFP_KERNEL);
656 if (!dc->vm_helper) {
657 dm_error("%s: failed to create dc->vm_helper\n", __func__);
661 memcpy(&dc->bb_overrides, &init_params->bb_overrides, sizeof(dc->bb_overrides));
663 dc_dceip = kzalloc(sizeof(*dc_dceip), GFP_KERNEL);
665 dm_error("%s: failed to create dceip\n", __func__);
669 dc->bw_dceip = dc_dceip;
671 dc_vbios = kzalloc(sizeof(*dc_vbios), GFP_KERNEL);
673 dm_error("%s: failed to create vbios\n", __func__);
677 dc->bw_vbios = dc_vbios;
678 #ifdef CONFIG_DRM_AMD_DC_DCN
679 dcn_soc = kzalloc(sizeof(*dcn_soc), GFP_KERNEL);
681 dm_error("%s: failed to create dcn_soc\n", __func__);
685 dc->dcn_soc = dcn_soc;
687 dcn_ip = kzalloc(sizeof(*dcn_ip), GFP_KERNEL);
689 dm_error("%s: failed to create dcn_ip\n", __func__);
694 dc->soc_bounding_box = init_params->soc_bounding_box;
697 if (!dc_construct_ctx(dc, init_params)) {
698 dm_error("%s: failed to create ctx\n", __func__);
704 /* Resource should construct all asic specific resources.
705 * This should be the only place where we need to parse the asic id
707 if (init_params->vbios_override)
708 dc_ctx->dc_bios = init_params->vbios_override;
710 /* Create BIOS parser */
711 struct bp_init_data bp_init_data;
713 bp_init_data.ctx = dc_ctx;
714 bp_init_data.bios = init_params->asic_id.atombios_base_address;
716 dc_ctx->dc_bios = dal_bios_parser_create(
717 &bp_init_data, dc_ctx->dce_version);
719 if (!dc_ctx->dc_bios) {
720 ASSERT_CRITICAL(false);
724 dc_ctx->created_bios = true;
727 dc->vendor_signature = init_params->vendor_signature;
729 /* Create GPIO service */
730 dc_ctx->gpio_service = dal_gpio_service_create(
732 dc_ctx->dce_environment,
735 if (!dc_ctx->gpio_service) {
736 ASSERT_CRITICAL(false);
740 dc->res_pool = dc_create_resource_pool(dc, init_params, dc_ctx->dce_version);
744 dc->clk_mgr = dc_clk_mgr_create(dc->ctx, dc->res_pool->pp_smu, dc->res_pool->dccg);
747 #ifdef CONFIG_DRM_AMD_DC_DCN
748 dc->clk_mgr->force_smu_not_present = init_params->force_smu_not_present;
751 dc->debug.force_ignore_link_settings = init_params->force_ignore_link_settings;
753 if (dc->res_pool->funcs->update_bw_bounding_box)
754 dc->res_pool->funcs->update_bw_bounding_box(dc, dc->clk_mgr->bw_params);
756 /* Creation of current_state must occur after dc->dml
757 * is initialized in dc_create_resource_pool because
758 * on creation it copies the contents of dc->dml
761 dc->current_state = dc_create_state(dc);
763 if (!dc->current_state) {
764 dm_error("%s: failed to create validate ctx\n", __func__);
768 dc_resource_state_construct(dc, dc->current_state);
770 if (!create_links(dc, init_params->num_virtual_links))
779 static void disable_all_writeback_pipes_for_stream(
781 struct dc_stream_state *stream,
782 struct dc_state *context)
786 for (i = 0; i < stream->num_wb_info; i++)
787 stream->writeback_info[i].wb_enabled = false;
790 void apply_ctx_interdependent_lock(struct dc *dc, struct dc_state *context, struct dc_stream_state *stream, bool lock)
794 /* Checks if interdependent update function pointer is NULL or not, takes care of DCE110 case */
795 if (dc->hwss.interdependent_update_lock)
796 dc->hwss.interdependent_update_lock(dc, context, lock);
798 for (i = 0; i < dc->res_pool->pipe_count; i++) {
799 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
800 struct pipe_ctx *old_pipe_ctx = &dc->current_state->res_ctx.pipe_ctx[i];
802 // Copied conditions that were previously in dce110_apply_ctx_for_surface
803 if (stream == pipe_ctx->stream) {
804 if (!pipe_ctx->top_pipe &&
805 (pipe_ctx->plane_state || old_pipe_ctx->plane_state))
806 dc->hwss.pipe_control_lock(dc, pipe_ctx, lock);
812 static void disable_dangling_plane(struct dc *dc, struct dc_state *context)
815 struct dc_state *dangling_context = dc_create_state(dc);
816 struct dc_state *current_ctx;
818 if (dangling_context == NULL)
821 dc_resource_state_copy_construct(dc->current_state, dangling_context);
823 for (i = 0; i < dc->res_pool->pipe_count; i++) {
824 struct dc_stream_state *old_stream =
825 dc->current_state->res_ctx.pipe_ctx[i].stream;
826 bool should_disable = true;
828 for (j = 0; j < context->stream_count; j++) {
829 if (old_stream == context->streams[j]) {
830 should_disable = false;
834 if (should_disable && old_stream) {
835 dc_rem_all_planes_for_stream(dc, old_stream, dangling_context);
836 disable_all_writeback_pipes_for_stream(dc, old_stream, dangling_context);
838 if (dc->hwss.apply_ctx_for_surface) {
839 apply_ctx_interdependent_lock(dc, dc->current_state, old_stream, true);
840 dc->hwss.apply_ctx_for_surface(dc, old_stream, 0, dangling_context);
841 apply_ctx_interdependent_lock(dc, dc->current_state, old_stream, false);
842 dc->hwss.post_unlock_program_front_end(dc, dangling_context);
844 if (dc->hwss.program_front_end_for_ctx) {
845 dc->hwss.interdependent_update_lock(dc, dc->current_state, true);
846 dc->hwss.program_front_end_for_ctx(dc, dangling_context);
847 dc->hwss.interdependent_update_lock(dc, dc->current_state, false);
848 dc->hwss.post_unlock_program_front_end(dc, dangling_context);
853 current_ctx = dc->current_state;
854 dc->current_state = dangling_context;
855 dc_release_state(current_ctx);
858 static void disable_vbios_mode_if_required(
860 struct dc_state *context)
864 /* check if timing_changed, disable stream*/
865 for (i = 0; i < dc->res_pool->pipe_count; i++) {
866 struct dc_stream_state *stream = NULL;
867 struct dc_link *link = NULL;
868 struct pipe_ctx *pipe = NULL;
870 pipe = &context->res_ctx.pipe_ctx[i];
871 stream = pipe->stream;
875 // only looking for first odm pipe
876 if (pipe->prev_odm_pipe)
879 if (stream->link->local_sink &&
880 stream->link->local_sink->sink_signal == SIGNAL_TYPE_EDP) {
884 if (link != NULL && link->link_enc->funcs->is_dig_enabled(link->link_enc)) {
885 unsigned int enc_inst, tg_inst = 0;
886 unsigned int pix_clk_100hz;
888 enc_inst = link->link_enc->funcs->get_dig_frontend(link->link_enc);
889 if (enc_inst != ENGINE_ID_UNKNOWN) {
890 for (j = 0; j < dc->res_pool->stream_enc_count; j++) {
891 if (dc->res_pool->stream_enc[j]->id == enc_inst) {
892 tg_inst = dc->res_pool->stream_enc[j]->funcs->dig_source_otg(
893 dc->res_pool->stream_enc[j]);
898 dc->res_pool->dp_clock_source->funcs->get_pixel_clk_frequency_100hz(
899 dc->res_pool->dp_clock_source,
900 tg_inst, &pix_clk_100hz);
902 if (link->link_status.link_active) {
903 uint32_t requested_pix_clk_100hz =
904 pipe->stream_res.pix_clk_params.requested_pix_clk_100hz;
906 if (pix_clk_100hz != requested_pix_clk_100hz) {
907 core_link_disable_stream(pipe);
908 pipe->stream->dpms_off = false;
916 static void wait_for_no_pipes_pending(struct dc *dc, struct dc_state *context)
920 for (i = 0; i < MAX_PIPES; i++) {
922 struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
924 if (!pipe->plane_state)
928 while (count < 100000) {
929 /* Must set to false to start with, due to OR in update function */
930 pipe->plane_state->status.is_flip_pending = false;
931 dc->hwss.update_pending_status(pipe);
932 if (!pipe->plane_state->status.is_flip_pending)
937 ASSERT(!pipe->plane_state->status.is_flip_pending);
942 /*******************************************************************************
944 ******************************************************************************/
946 struct dc *dc_create(const struct dc_init_data *init_params)
948 struct dc *dc = kzalloc(sizeof(*dc), GFP_KERNEL);
949 unsigned int full_pipe_count;
954 if (init_params->dce_environment == DCE_ENV_VIRTUAL_HW) {
955 if (false == dc_construct_ctx(dc, init_params)) {
960 if (false == dc_construct(dc, init_params)) {
965 full_pipe_count = dc->res_pool->pipe_count;
966 if (dc->res_pool->underlay_pipe_index != NO_UNDERLAY_PIPE)
968 dc->caps.max_streams = min(
970 dc->res_pool->stream_enc_count);
972 dc->optimize_seamless_boot_streams = 0;
973 dc->caps.max_links = dc->link_count;
974 dc->caps.max_audios = dc->res_pool->audio_count;
975 dc->caps.linear_pitch_alignment = 64;
977 dc->caps.max_dp_protocol_version = DP_VERSION_1_4;
979 if (dc->res_pool->dmcu != NULL)
980 dc->versions.dmcu_version = dc->res_pool->dmcu->dmcu_version;
983 /* Populate versioning information */
984 dc->versions.dc_ver = DC_VER;
986 dc->build_id = DC_BUILD_ID;
988 DC_LOG_DC("Display Core initialized\n");
1001 void dc_hardware_init(struct dc *dc)
1003 if (dc->ctx->dce_environment != DCE_ENV_VIRTUAL_HW)
1004 dc->hwss.init_hw(dc);
1007 void dc_init_callbacks(struct dc *dc,
1008 const struct dc_callback_init *init_params)
1010 #ifdef CONFIG_DRM_AMD_DC_HDCP
1011 dc->ctx->cp_psp = init_params->cp_psp;
1015 void dc_deinit_callbacks(struct dc *dc)
1017 #ifdef CONFIG_DRM_AMD_DC_HDCP
1018 memset(&dc->ctx->cp_psp, 0, sizeof(dc->ctx->cp_psp));
1022 void dc_destroy(struct dc **dc)
1029 static void enable_timing_multisync(
1031 struct dc_state *ctx)
1033 int i = 0, multisync_count = 0;
1034 int pipe_count = dc->res_pool->pipe_count;
1035 struct pipe_ctx *multisync_pipes[MAX_PIPES] = { NULL };
1037 for (i = 0; i < pipe_count; i++) {
1038 if (!ctx->res_ctx.pipe_ctx[i].stream ||
1039 !ctx->res_ctx.pipe_ctx[i].stream->triggered_crtc_reset.enabled)
1041 if (ctx->res_ctx.pipe_ctx[i].stream == ctx->res_ctx.pipe_ctx[i].stream->triggered_crtc_reset.event_source)
1043 multisync_pipes[multisync_count] = &ctx->res_ctx.pipe_ctx[i];
1047 if (multisync_count > 0) {
1048 dc->hwss.enable_per_frame_crtc_position_reset(
1049 dc, multisync_count, multisync_pipes);
1053 static void program_timing_sync(
1055 struct dc_state *ctx)
1058 int group_index = 0;
1060 int pipe_count = dc->res_pool->pipe_count;
1061 struct pipe_ctx *unsynced_pipes[MAX_PIPES] = { NULL };
1063 for (i = 0; i < pipe_count; i++) {
1064 if (!ctx->res_ctx.pipe_ctx[i].stream || ctx->res_ctx.pipe_ctx[i].top_pipe)
1067 unsynced_pipes[i] = &ctx->res_ctx.pipe_ctx[i];
1070 for (i = 0; i < pipe_count; i++) {
1072 struct pipe_ctx *pipe_set[MAX_PIPES];
1074 if (!unsynced_pipes[i])
1077 pipe_set[0] = unsynced_pipes[i];
1078 unsynced_pipes[i] = NULL;
1080 /* Add tg to the set, search rest of the tg's for ones with
1081 * same timing, add all tgs with same timing to the group
1083 for (j = i + 1; j < pipe_count; j++) {
1084 if (!unsynced_pipes[j])
1087 if (resource_are_streams_timing_synchronizable(
1088 unsynced_pipes[j]->stream,
1089 pipe_set[0]->stream)) {
1090 pipe_set[group_size] = unsynced_pipes[j];
1091 unsynced_pipes[j] = NULL;
1096 /* set first unblanked pipe as master */
1097 for (j = 0; j < group_size; j++) {
1100 if (pipe_set[j]->stream_res.opp->funcs->dpg_is_blanked)
1102 pipe_set[j]->stream_res.opp->funcs->dpg_is_blanked(pipe_set[j]->stream_res.opp);
1105 pipe_set[j]->stream_res.tg->funcs->is_blanked(pipe_set[j]->stream_res.tg);
1110 swap(pipe_set[0], pipe_set[j]);
1116 for (k = 0; k < group_size; k++) {
1117 struct dc_stream_status *status = dc_stream_get_status_from_state(ctx, pipe_set[k]->stream);
1119 status->timing_sync_info.group_id = num_group;
1120 status->timing_sync_info.group_size = group_size;
1122 status->timing_sync_info.master = true;
1124 status->timing_sync_info.master = false;
1127 /* remove any other unblanked pipes as they have already been synced */
1128 for (j = j + 1; j < group_size; j++) {
1131 if (pipe_set[j]->stream_res.opp->funcs->dpg_is_blanked)
1133 pipe_set[j]->stream_res.opp->funcs->dpg_is_blanked(pipe_set[j]->stream_res.opp);
1136 pipe_set[j]->stream_res.tg->funcs->is_blanked(pipe_set[j]->stream_res.tg);
1139 pipe_set[j] = pipe_set[group_size];
1144 if (group_size > 1) {
1145 dc->hwss.enable_timing_synchronization(
1146 dc, group_index, group_size, pipe_set);
1153 static bool context_changed(
1155 struct dc_state *context)
1159 if (context->stream_count != dc->current_state->stream_count)
1162 for (i = 0; i < dc->current_state->stream_count; i++) {
1163 if (dc->current_state->streams[i] != context->streams[i])
1170 bool dc_validate_seamless_boot_timing(const struct dc *dc,
1171 const struct dc_sink *sink,
1172 struct dc_crtc_timing *crtc_timing)
1174 struct timing_generator *tg;
1175 struct stream_encoder *se = NULL;
1177 struct dc_crtc_timing hw_crtc_timing = {0};
1179 struct dc_link *link = sink->link;
1180 unsigned int i, enc_inst, tg_inst = 0;
1182 // Seamless port only support single DP and EDP so far
1183 if (sink->sink_signal != SIGNAL_TYPE_DISPLAY_PORT &&
1184 sink->sink_signal != SIGNAL_TYPE_EDP)
1187 /* Check for enabled DIG to identify enabled display */
1188 if (!link->link_enc->funcs->is_dig_enabled(link->link_enc))
1191 enc_inst = link->link_enc->funcs->get_dig_frontend(link->link_enc);
1193 if (enc_inst == ENGINE_ID_UNKNOWN)
1196 for (i = 0; i < dc->res_pool->stream_enc_count; i++) {
1197 if (dc->res_pool->stream_enc[i]->id == enc_inst) {
1199 se = dc->res_pool->stream_enc[i];
1201 tg_inst = dc->res_pool->stream_enc[i]->funcs->dig_source_otg(
1202 dc->res_pool->stream_enc[i]);
1207 // tg_inst not found
1208 if (i == dc->res_pool->stream_enc_count)
1211 if (tg_inst >= dc->res_pool->timing_generator_count)
1214 tg = dc->res_pool->timing_generators[tg_inst];
1216 if (!tg->funcs->get_hw_timing)
1219 if (!tg->funcs->get_hw_timing(tg, &hw_crtc_timing))
1222 if (crtc_timing->h_total != hw_crtc_timing.h_total)
1225 if (crtc_timing->h_border_left != hw_crtc_timing.h_border_left)
1228 if (crtc_timing->h_addressable != hw_crtc_timing.h_addressable)
1231 if (crtc_timing->h_border_right != hw_crtc_timing.h_border_right)
1234 if (crtc_timing->h_front_porch != hw_crtc_timing.h_front_porch)
1237 if (crtc_timing->h_sync_width != hw_crtc_timing.h_sync_width)
1240 if (crtc_timing->v_total != hw_crtc_timing.v_total)
1243 if (crtc_timing->v_border_top != hw_crtc_timing.v_border_top)
1246 if (crtc_timing->v_addressable != hw_crtc_timing.v_addressable)
1249 if (crtc_timing->v_border_bottom != hw_crtc_timing.v_border_bottom)
1252 if (crtc_timing->v_front_porch != hw_crtc_timing.v_front_porch)
1255 if (crtc_timing->v_sync_width != hw_crtc_timing.v_sync_width)
1258 if (dc_is_dp_signal(link->connector_signal)) {
1259 unsigned int pix_clk_100hz;
1261 dc->res_pool->dp_clock_source->funcs->get_pixel_clk_frequency_100hz(
1262 dc->res_pool->dp_clock_source,
1263 tg_inst, &pix_clk_100hz);
1265 if (crtc_timing->pix_clk_100hz != pix_clk_100hz)
1268 if (!se->funcs->dp_get_pixel_format)
1271 if (!se->funcs->dp_get_pixel_format(
1273 &hw_crtc_timing.pixel_encoding,
1274 &hw_crtc_timing.display_color_depth))
1277 if (hw_crtc_timing.display_color_depth != crtc_timing->display_color_depth)
1280 if (hw_crtc_timing.pixel_encoding != crtc_timing->pixel_encoding)
1284 if (link->dpcd_caps.dprx_feature.bits.VSC_SDP_COLORIMETRY_SUPPORTED) {
1291 void dc_enable_stereo(
1293 struct dc_state *context,
1294 struct dc_stream_state *streams[],
1295 uint8_t stream_count)
1298 struct pipe_ctx *pipe;
1300 for (i = 0; i < MAX_PIPES; i++) {
1301 if (context != NULL)
1302 pipe = &context->res_ctx.pipe_ctx[i];
1304 pipe = &dc->current_state->res_ctx.pipe_ctx[i];
1305 for (j = 0 ; pipe && j < stream_count; j++) {
1306 if (streams[j] && streams[j] == pipe->stream &&
1307 dc->hwss.setup_stereo)
1308 dc->hwss.setup_stereo(pipe, dc);
1313 void dc_trigger_sync(struct dc *dc, struct dc_state *context)
1315 if (context->stream_count > 1 && !dc->debug.disable_timing_sync) {
1316 enable_timing_multisync(dc, context);
1317 program_timing_sync(dc, context);
1321 static uint8_t get_stream_mask(struct dc *dc, struct dc_state *context)
1324 unsigned int stream_mask = 0;
1326 for (i = 0; i < dc->res_pool->pipe_count; i++) {
1327 if (context->res_ctx.pipe_ctx[i].stream)
1328 stream_mask |= 1 << i;
1335 * Applies given context to HW and copy it into current context.
1336 * It's up to the user to release the src context afterwards.
1338 static enum dc_status dc_commit_state_no_check(struct dc *dc, struct dc_state *context)
1340 struct dc_bios *dcb = dc->ctx->dc_bios;
1341 enum dc_status result = DC_ERROR_UNEXPECTED;
1342 struct pipe_ctx *pipe;
1344 struct dc_stream_state *dc_streams[MAX_STREAMS] = {0};
1346 #if defined(CONFIG_DRM_AMD_DC_DCN)
1347 dc_allow_idle_optimizations(dc, false);
1350 for (i = 0; i < context->stream_count; i++)
1351 dc_streams[i] = context->streams[i];
1353 if (!dcb->funcs->is_accelerated_mode(dcb)) {
1354 disable_vbios_mode_if_required(dc, context);
1355 dc->hwss.enable_accelerated_mode(dc, context);
1358 for (i = 0; i < context->stream_count; i++)
1359 if (context->streams[i]->apply_seamless_boot_optimization)
1360 dc->optimize_seamless_boot_streams++;
1362 if (context->stream_count > dc->optimize_seamless_boot_streams ||
1363 context->stream_count == 0)
1364 dc->hwss.prepare_bandwidth(dc, context);
1366 disable_dangling_plane(dc, context);
1367 /* re-program planes for existing stream, in case we need to
1368 * free up plane resource for later use
1370 if (dc->hwss.apply_ctx_for_surface) {
1371 for (i = 0; i < context->stream_count; i++) {
1372 if (context->streams[i]->mode_changed)
1374 apply_ctx_interdependent_lock(dc, context, context->streams[i], true);
1375 dc->hwss.apply_ctx_for_surface(
1376 dc, context->streams[i],
1377 context->stream_status[i].plane_count,
1378 context); /* use new pipe config in new context */
1379 apply_ctx_interdependent_lock(dc, context, context->streams[i], false);
1380 dc->hwss.post_unlock_program_front_end(dc, context);
1384 /* Program hardware */
1385 for (i = 0; i < dc->res_pool->pipe_count; i++) {
1386 pipe = &context->res_ctx.pipe_ctx[i];
1387 dc->hwss.wait_for_mpcc_disconnect(dc, dc->res_pool, pipe);
1390 result = dc->hwss.apply_ctx_to_hw(dc, context);
1392 if (result != DC_OK)
1395 dc_trigger_sync(dc, context);
1397 /* Program all planes within new context*/
1398 if (dc->hwss.program_front_end_for_ctx) {
1399 dc->hwss.interdependent_update_lock(dc, context, true);
1400 dc->hwss.program_front_end_for_ctx(dc, context);
1401 dc->hwss.interdependent_update_lock(dc, context, false);
1402 dc->hwss.post_unlock_program_front_end(dc, context);
1404 for (i = 0; i < context->stream_count; i++) {
1405 const struct dc_link *link = context->streams[i]->link;
1407 if (!context->streams[i]->mode_changed)
1410 if (dc->hwss.apply_ctx_for_surface) {
1411 apply_ctx_interdependent_lock(dc, context, context->streams[i], true);
1412 dc->hwss.apply_ctx_for_surface(
1413 dc, context->streams[i],
1414 context->stream_status[i].plane_count,
1416 apply_ctx_interdependent_lock(dc, context, context->streams[i], false);
1417 dc->hwss.post_unlock_program_front_end(dc, context);
1422 * TODO rework dc_enable_stereo call to work with validation sets?
1424 for (k = 0; k < MAX_PIPES; k++) {
1425 pipe = &context->res_ctx.pipe_ctx[k];
1427 for (l = 0 ; pipe && l < context->stream_count; l++) {
1428 if (context->streams[l] &&
1429 context->streams[l] == pipe->stream &&
1430 dc->hwss.setup_stereo)
1431 dc->hwss.setup_stereo(pipe, dc);
1435 CONN_MSG_MODE(link, "{%dx%d, %dx%d@%dKhz}",
1436 context->streams[i]->timing.h_addressable,
1437 context->streams[i]->timing.v_addressable,
1438 context->streams[i]->timing.h_total,
1439 context->streams[i]->timing.v_total,
1440 context->streams[i]->timing.pix_clk_100hz / 10);
1443 dc_enable_stereo(dc, context, dc_streams, context->stream_count);
1445 if (context->stream_count > dc->optimize_seamless_boot_streams ||
1446 context->stream_count == 0) {
1447 /* Must wait for no flips to be pending before doing optimize bw */
1448 wait_for_no_pipes_pending(dc, context);
1449 /* pplib is notified if disp_num changed */
1450 dc->hwss.optimize_bandwidth(dc, context);
1453 if (dc->ctx->dce_version >= DCE_VERSION_MAX)
1454 TRACE_DCN_CLOCK_STATE(&context->bw_ctx.bw.dcn.clk);
1456 TRACE_DCE_CLOCK_STATE(&context->bw_ctx.bw.dce);
1458 context->stream_mask = get_stream_mask(dc, context);
1460 if (context->stream_mask != dc->current_state->stream_mask)
1461 dc_dmub_srv_notify_stream_mask(dc->ctx->dmub_srv, context->stream_mask);
1463 for (i = 0; i < context->stream_count; i++)
1464 context->streams[i]->mode_changed = false;
1466 dc_release_state(dc->current_state);
1468 dc->current_state = context;
1470 dc_retain_state(dc->current_state);
1475 bool dc_commit_state(struct dc *dc, struct dc_state *context)
1477 enum dc_status result = DC_ERROR_UNEXPECTED;
1480 if (false == context_changed(dc, context))
1483 DC_LOG_DC("%s: %d streams\n",
1484 __func__, context->stream_count);
1486 for (i = 0; i < context->stream_count; i++) {
1487 struct dc_stream_state *stream = context->streams[i];
1489 dc_stream_log(dc, stream);
1492 result = dc_commit_state_no_check(dc, context);
1494 return (result == DC_OK);
1497 #if defined(CONFIG_DRM_AMD_DC_DCN)
1498 bool dc_acquire_release_mpc_3dlut(
1499 struct dc *dc, bool acquire,
1500 struct dc_stream_state *stream,
1501 struct dc_3dlut **lut,
1502 struct dc_transfer_func **shaper)
1506 bool found_pipe_idx = false;
1507 const struct resource_pool *pool = dc->res_pool;
1508 struct resource_context *res_ctx = &dc->current_state->res_ctx;
1511 if (pool && res_ctx) {
1513 /*find pipe idx for the given stream*/
1514 for (pipe_idx = 0; pipe_idx < pool->pipe_count; pipe_idx++) {
1515 if (res_ctx->pipe_ctx[pipe_idx].stream == stream) {
1516 found_pipe_idx = true;
1517 mpcc_id = res_ctx->pipe_ctx[pipe_idx].plane_res.hubp->inst;
1522 found_pipe_idx = true;/*for release pipe_idx is not required*/
1524 if (found_pipe_idx) {
1525 if (acquire && pool->funcs->acquire_post_bldn_3dlut)
1526 ret = pool->funcs->acquire_post_bldn_3dlut(res_ctx, pool, mpcc_id, lut, shaper);
1527 else if (acquire == false && pool->funcs->release_post_bldn_3dlut)
1528 ret = pool->funcs->release_post_bldn_3dlut(res_ctx, pool, lut, shaper);
1534 static bool is_flip_pending_in_pipes(struct dc *dc, struct dc_state *context)
1537 struct pipe_ctx *pipe;
1539 for (i = 0; i < MAX_PIPES; i++) {
1540 pipe = &context->res_ctx.pipe_ctx[i];
1542 if (!pipe->plane_state)
1545 /* Must set to false to start with, due to OR in update function */
1546 pipe->plane_state->status.is_flip_pending = false;
1547 dc->hwss.update_pending_status(pipe);
1548 if (pipe->plane_state->status.is_flip_pending)
1554 void dc_post_update_surfaces_to_stream(struct dc *dc)
1557 struct dc_state *context = dc->current_state;
1559 if ((!dc->optimized_required) || dc->optimize_seamless_boot_streams > 0)
1562 post_surface_trace(dc);
1564 if (is_flip_pending_in_pipes(dc, context))
1567 for (i = 0; i < dc->res_pool->pipe_count; i++)
1568 if (context->res_ctx.pipe_ctx[i].stream == NULL ||
1569 context->res_ctx.pipe_ctx[i].plane_state == NULL) {
1570 context->res_ctx.pipe_ctx[i].pipe_idx = i;
1571 dc->hwss.disable_plane(dc, &context->res_ctx.pipe_ctx[i]);
1574 dc->hwss.optimize_bandwidth(dc, context);
1576 dc->optimized_required = false;
1577 dc->wm_optimized_required = false;
1580 static void init_state(struct dc *dc, struct dc_state *context)
1582 /* Each context must have their own instance of VBA and in order to
1583 * initialize and obtain IP and SOC the base DML instance from DC is
1584 * initially copied into every context
1586 #ifdef CONFIG_DRM_AMD_DC_DCN
1587 memcpy(&context->bw_ctx.dml, &dc->dml, sizeof(struct display_mode_lib));
1591 struct dc_state *dc_create_state(struct dc *dc)
1593 struct dc_state *context = kvzalloc(sizeof(struct dc_state),
1599 init_state(dc, context);
1601 kref_init(&context->refcount);
1606 struct dc_state *dc_copy_state(struct dc_state *src_ctx)
1609 struct dc_state *new_ctx = kvmalloc(sizeof(struct dc_state), GFP_KERNEL);
1613 memcpy(new_ctx, src_ctx, sizeof(struct dc_state));
1615 for (i = 0; i < MAX_PIPES; i++) {
1616 struct pipe_ctx *cur_pipe = &new_ctx->res_ctx.pipe_ctx[i];
1618 if (cur_pipe->top_pipe)
1619 cur_pipe->top_pipe = &new_ctx->res_ctx.pipe_ctx[cur_pipe->top_pipe->pipe_idx];
1621 if (cur_pipe->bottom_pipe)
1622 cur_pipe->bottom_pipe = &new_ctx->res_ctx.pipe_ctx[cur_pipe->bottom_pipe->pipe_idx];
1624 if (cur_pipe->prev_odm_pipe)
1625 cur_pipe->prev_odm_pipe = &new_ctx->res_ctx.pipe_ctx[cur_pipe->prev_odm_pipe->pipe_idx];
1627 if (cur_pipe->next_odm_pipe)
1628 cur_pipe->next_odm_pipe = &new_ctx->res_ctx.pipe_ctx[cur_pipe->next_odm_pipe->pipe_idx];
1632 for (i = 0; i < new_ctx->stream_count; i++) {
1633 dc_stream_retain(new_ctx->streams[i]);
1634 for (j = 0; j < new_ctx->stream_status[i].plane_count; j++)
1635 dc_plane_state_retain(
1636 new_ctx->stream_status[i].plane_states[j]);
1639 kref_init(&new_ctx->refcount);
1644 void dc_retain_state(struct dc_state *context)
1646 kref_get(&context->refcount);
1649 static void dc_state_free(struct kref *kref)
1651 struct dc_state *context = container_of(kref, struct dc_state, refcount);
1652 dc_resource_state_destruct(context);
1656 void dc_release_state(struct dc_state *context)
1658 kref_put(&context->refcount, dc_state_free);
1661 bool dc_set_generic_gpio_for_stereo(bool enable,
1662 struct gpio_service *gpio_service)
1664 enum gpio_result gpio_result = GPIO_RESULT_NON_SPECIFIC_ERROR;
1665 struct gpio_pin_info pin_info;
1666 struct gpio *generic;
1667 struct gpio_generic_mux_config *config = kzalloc(sizeof(struct gpio_generic_mux_config),
1672 pin_info = dal_gpio_get_generic_pin_info(gpio_service, GPIO_ID_GENERIC, 0);
1674 if (pin_info.mask == 0xFFFFFFFF || pin_info.offset == 0xFFFFFFFF) {
1678 generic = dal_gpio_service_create_generic_mux(
1689 gpio_result = dal_gpio_open(generic, GPIO_MODE_OUTPUT);
1691 config->enable_output_from_mux = enable;
1692 config->mux_select = GPIO_SIGNAL_SOURCE_PASS_THROUGH_STEREO_SYNC;
1694 if (gpio_result == GPIO_RESULT_OK)
1695 gpio_result = dal_mux_setup_config(generic, config);
1697 if (gpio_result == GPIO_RESULT_OK) {
1698 dal_gpio_close(generic);
1699 dal_gpio_destroy_generic_mux(&generic);
1703 dal_gpio_close(generic);
1704 dal_gpio_destroy_generic_mux(&generic);
1710 static bool is_surface_in_context(
1711 const struct dc_state *context,
1712 const struct dc_plane_state *plane_state)
1716 for (j = 0; j < MAX_PIPES; j++) {
1717 const struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j];
1719 if (plane_state == pipe_ctx->plane_state) {
1727 static enum surface_update_type get_plane_info_update_type(const struct dc_surface_update *u)
1729 union surface_update_flags *update_flags = &u->surface->update_flags;
1730 enum surface_update_type update_type = UPDATE_TYPE_FAST;
1733 return UPDATE_TYPE_FAST;
1735 if (u->plane_info->color_space != u->surface->color_space) {
1736 update_flags->bits.color_space_change = 1;
1737 elevate_update_type(&update_type, UPDATE_TYPE_MED);
1740 if (u->plane_info->horizontal_mirror != u->surface->horizontal_mirror) {
1741 update_flags->bits.horizontal_mirror_change = 1;
1742 elevate_update_type(&update_type, UPDATE_TYPE_MED);
1745 if (u->plane_info->rotation != u->surface->rotation) {
1746 update_flags->bits.rotation_change = 1;
1747 elevate_update_type(&update_type, UPDATE_TYPE_FULL);
1750 if (u->plane_info->format != u->surface->format) {
1751 update_flags->bits.pixel_format_change = 1;
1752 elevate_update_type(&update_type, UPDATE_TYPE_FULL);
1755 if (u->plane_info->stereo_format != u->surface->stereo_format) {
1756 update_flags->bits.stereo_format_change = 1;
1757 elevate_update_type(&update_type, UPDATE_TYPE_FULL);
1760 if (u->plane_info->per_pixel_alpha != u->surface->per_pixel_alpha) {
1761 update_flags->bits.per_pixel_alpha_change = 1;
1762 elevate_update_type(&update_type, UPDATE_TYPE_MED);
1765 if (u->plane_info->global_alpha_value != u->surface->global_alpha_value) {
1766 update_flags->bits.global_alpha_change = 1;
1767 elevate_update_type(&update_type, UPDATE_TYPE_MED);
1770 if (u->plane_info->dcc.enable != u->surface->dcc.enable
1771 || u->plane_info->dcc.independent_64b_blks != u->surface->dcc.independent_64b_blks
1772 || u->plane_info->dcc.meta_pitch != u->surface->dcc.meta_pitch) {
1773 update_flags->bits.dcc_change = 1;
1774 elevate_update_type(&update_type, UPDATE_TYPE_MED);
1777 if (resource_pixel_format_to_bpp(u->plane_info->format) !=
1778 resource_pixel_format_to_bpp(u->surface->format)) {
1779 /* different bytes per element will require full bandwidth
1780 * and DML calculation
1782 update_flags->bits.bpp_change = 1;
1783 elevate_update_type(&update_type, UPDATE_TYPE_FULL);
1786 if (u->plane_info->plane_size.surface_pitch != u->surface->plane_size.surface_pitch
1787 || u->plane_info->plane_size.chroma_pitch != u->surface->plane_size.chroma_pitch) {
1788 update_flags->bits.plane_size_change = 1;
1789 elevate_update_type(&update_type, UPDATE_TYPE_MED);
1793 if (memcmp(&u->plane_info->tiling_info, &u->surface->tiling_info,
1794 sizeof(union dc_tiling_info)) != 0) {
1795 update_flags->bits.swizzle_change = 1;
1796 elevate_update_type(&update_type, UPDATE_TYPE_MED);
1798 /* todo: below are HW dependent, we should add a hook to
1799 * DCE/N resource and validated there.
1801 if (u->plane_info->tiling_info.gfx9.swizzle != DC_SW_LINEAR) {
1802 /* swizzled mode requires RQ to be setup properly,
1803 * thus need to run DML to calculate RQ settings
1805 update_flags->bits.bandwidth_change = 1;
1806 elevate_update_type(&update_type, UPDATE_TYPE_FULL);
1810 /* This should be UPDATE_TYPE_FAST if nothing has changed. */
1814 static enum surface_update_type get_scaling_info_update_type(
1815 const struct dc_surface_update *u)
1817 union surface_update_flags *update_flags = &u->surface->update_flags;
1819 if (!u->scaling_info)
1820 return UPDATE_TYPE_FAST;
1822 if (u->scaling_info->clip_rect.width != u->surface->clip_rect.width
1823 || u->scaling_info->clip_rect.height != u->surface->clip_rect.height
1824 || u->scaling_info->dst_rect.width != u->surface->dst_rect.width
1825 || u->scaling_info->dst_rect.height != u->surface->dst_rect.height
1826 || u->scaling_info->scaling_quality.integer_scaling !=
1827 u->surface->scaling_quality.integer_scaling
1829 update_flags->bits.scaling_change = 1;
1831 if ((u->scaling_info->dst_rect.width < u->surface->dst_rect.width
1832 || u->scaling_info->dst_rect.height < u->surface->dst_rect.height)
1833 && (u->scaling_info->dst_rect.width < u->surface->src_rect.width
1834 || u->scaling_info->dst_rect.height < u->surface->src_rect.height))
1835 /* Making dst rect smaller requires a bandwidth change */
1836 update_flags->bits.bandwidth_change = 1;
1839 if (u->scaling_info->src_rect.width != u->surface->src_rect.width
1840 || u->scaling_info->src_rect.height != u->surface->src_rect.height) {
1842 update_flags->bits.scaling_change = 1;
1843 if (u->scaling_info->src_rect.width > u->surface->src_rect.width
1844 || u->scaling_info->src_rect.height > u->surface->src_rect.height)
1845 /* Making src rect bigger requires a bandwidth change */
1846 update_flags->bits.clock_change = 1;
1849 if (u->scaling_info->src_rect.x != u->surface->src_rect.x
1850 || u->scaling_info->src_rect.y != u->surface->src_rect.y
1851 || u->scaling_info->clip_rect.x != u->surface->clip_rect.x
1852 || u->scaling_info->clip_rect.y != u->surface->clip_rect.y
1853 || u->scaling_info->dst_rect.x != u->surface->dst_rect.x
1854 || u->scaling_info->dst_rect.y != u->surface->dst_rect.y)
1855 update_flags->bits.position_change = 1;
1857 if (update_flags->bits.clock_change
1858 || update_flags->bits.bandwidth_change
1859 || update_flags->bits.scaling_change)
1860 return UPDATE_TYPE_FULL;
1862 if (update_flags->bits.position_change)
1863 return UPDATE_TYPE_MED;
1865 return UPDATE_TYPE_FAST;
1868 static enum surface_update_type det_surface_update(const struct dc *dc,
1869 const struct dc_surface_update *u)
1871 const struct dc_state *context = dc->current_state;
1872 enum surface_update_type type;
1873 enum surface_update_type overall_type = UPDATE_TYPE_FAST;
1874 union surface_update_flags *update_flags = &u->surface->update_flags;
1877 update_flags->bits.addr_update = 1;
1879 if (!is_surface_in_context(context, u->surface) || u->surface->force_full_update) {
1880 update_flags->raw = 0xFFFFFFFF;
1881 return UPDATE_TYPE_FULL;
1884 update_flags->raw = 0; // Reset all flags
1886 type = get_plane_info_update_type(u);
1887 elevate_update_type(&overall_type, type);
1889 type = get_scaling_info_update_type(u);
1890 elevate_update_type(&overall_type, type);
1893 update_flags->bits.addr_update = 1;
1895 if (u->in_transfer_func)
1896 update_flags->bits.in_transfer_func_change = 1;
1898 if (u->input_csc_color_matrix)
1899 update_flags->bits.input_csc_change = 1;
1901 if (u->coeff_reduction_factor)
1902 update_flags->bits.coeff_reduction_change = 1;
1904 if (u->gamut_remap_matrix)
1905 update_flags->bits.gamut_remap_change = 1;
1908 enum surface_pixel_format format = SURFACE_PIXEL_FORMAT_GRPH_BEGIN;
1911 format = u->plane_info->format;
1912 else if (u->surface)
1913 format = u->surface->format;
1915 if (dce_use_lut(format))
1916 update_flags->bits.gamma_change = 1;
1919 if (u->hdr_mult.value)
1920 if (u->hdr_mult.value != u->surface->hdr_mult.value) {
1921 update_flags->bits.hdr_mult = 1;
1922 elevate_update_type(&overall_type, UPDATE_TYPE_MED);
1925 if (update_flags->bits.in_transfer_func_change) {
1926 type = UPDATE_TYPE_MED;
1927 elevate_update_type(&overall_type, type);
1930 if (update_flags->bits.input_csc_change
1931 || update_flags->bits.coeff_reduction_change
1932 || update_flags->bits.gamma_change
1933 || update_flags->bits.gamut_remap_change) {
1934 type = UPDATE_TYPE_FULL;
1935 elevate_update_type(&overall_type, type);
1938 return overall_type;
1941 static enum surface_update_type check_update_surfaces_for_stream(
1943 struct dc_surface_update *updates,
1945 struct dc_stream_update *stream_update,
1946 const struct dc_stream_status *stream_status)
1949 enum surface_update_type overall_type = UPDATE_TYPE_FAST;
1951 #if defined(CONFIG_DRM_AMD_DC_DCN)
1952 if (dc->idle_optimizations_allowed)
1953 overall_type = UPDATE_TYPE_FULL;
1956 if (stream_status == NULL || stream_status->plane_count != surface_count)
1957 overall_type = UPDATE_TYPE_FULL;
1959 /* some stream updates require passive update */
1960 if (stream_update) {
1961 union stream_update_flags *su_flags = &stream_update->stream->update_flags;
1963 if ((stream_update->src.height != 0 && stream_update->src.width != 0) ||
1964 (stream_update->dst.height != 0 && stream_update->dst.width != 0) ||
1965 stream_update->integer_scaling_update)
1966 su_flags->bits.scaling = 1;
1968 if (stream_update->out_transfer_func)
1969 su_flags->bits.out_tf = 1;
1971 if (stream_update->abm_level)
1972 su_flags->bits.abm_level = 1;
1974 if (stream_update->dpms_off)
1975 su_flags->bits.dpms_off = 1;
1977 if (stream_update->gamut_remap)
1978 su_flags->bits.gamut_remap = 1;
1980 if (stream_update->wb_update)
1981 su_flags->bits.wb_update = 1;
1983 if (stream_update->dsc_config)
1984 su_flags->bits.dsc_changed = 1;
1986 if (su_flags->raw != 0)
1987 overall_type = UPDATE_TYPE_FULL;
1989 if (stream_update->output_csc_transform || stream_update->output_color_space)
1990 su_flags->bits.out_csc = 1;
1993 for (i = 0 ; i < surface_count; i++) {
1994 enum surface_update_type type =
1995 det_surface_update(dc, &updates[i]);
1997 elevate_update_type(&overall_type, type);
2000 return overall_type;
2004 * dc_check_update_surfaces_for_stream() - Determine update type (fast, med, or full)
2006 * See :c:type:`enum surface_update_type <surface_update_type>` for explanation of update types
2008 enum surface_update_type dc_check_update_surfaces_for_stream(
2010 struct dc_surface_update *updates,
2012 struct dc_stream_update *stream_update,
2013 const struct dc_stream_status *stream_status)
2016 enum surface_update_type type;
2019 stream_update->stream->update_flags.raw = 0;
2020 for (i = 0; i < surface_count; i++)
2021 updates[i].surface->update_flags.raw = 0;
2023 type = check_update_surfaces_for_stream(dc, updates, surface_count, stream_update, stream_status);
2024 if (type == UPDATE_TYPE_FULL) {
2025 if (stream_update) {
2026 uint32_t dsc_changed = stream_update->stream->update_flags.bits.dsc_changed;
2027 stream_update->stream->update_flags.raw = 0xFFFFFFFF;
2028 stream_update->stream->update_flags.bits.dsc_changed = dsc_changed;
2030 for (i = 0; i < surface_count; i++)
2031 updates[i].surface->update_flags.raw = 0xFFFFFFFF;
2034 if (type == UPDATE_TYPE_FAST) {
2035 // If there's an available clock comparator, we use that.
2036 if (dc->clk_mgr->funcs->are_clock_states_equal) {
2037 if (!dc->clk_mgr->funcs->are_clock_states_equal(&dc->clk_mgr->clks, &dc->current_state->bw_ctx.bw.dcn.clk))
2038 dc->optimized_required = true;
2039 // Else we fallback to mem compare.
2040 } else if (memcmp(&dc->current_state->bw_ctx.bw.dcn.clk, &dc->clk_mgr->clks, offsetof(struct dc_clocks, prev_p_state_change_support)) != 0) {
2041 dc->optimized_required = true;
2044 dc->optimized_required |= dc->wm_optimized_required;
2050 static struct dc_stream_status *stream_get_status(
2051 struct dc_state *ctx,
2052 struct dc_stream_state *stream)
2056 for (i = 0; i < ctx->stream_count; i++) {
2057 if (stream == ctx->streams[i]) {
2058 return &ctx->stream_status[i];
2065 static const enum surface_update_type update_surface_trace_level = UPDATE_TYPE_FULL;
2067 static void copy_surface_update_to_plane(
2068 struct dc_plane_state *surface,
2069 struct dc_surface_update *srf_update)
2071 if (srf_update->flip_addr) {
2072 surface->address = srf_update->flip_addr->address;
2073 surface->flip_immediate =
2074 srf_update->flip_addr->flip_immediate;
2075 surface->time.time_elapsed_in_us[surface->time.index] =
2076 srf_update->flip_addr->flip_timestamp_in_us -
2077 surface->time.prev_update_time_in_us;
2078 surface->time.prev_update_time_in_us =
2079 srf_update->flip_addr->flip_timestamp_in_us;
2080 surface->time.index++;
2081 if (surface->time.index >= DC_PLANE_UPDATE_TIMES_MAX)
2082 surface->time.index = 0;
2084 surface->triplebuffer_flips = srf_update->flip_addr->triplebuffer_flips;
2087 if (srf_update->scaling_info) {
2088 surface->scaling_quality =
2089 srf_update->scaling_info->scaling_quality;
2091 srf_update->scaling_info->dst_rect;
2093 srf_update->scaling_info->src_rect;
2094 surface->clip_rect =
2095 srf_update->scaling_info->clip_rect;
2098 if (srf_update->plane_info) {
2099 surface->color_space =
2100 srf_update->plane_info->color_space;
2102 srf_update->plane_info->format;
2103 surface->plane_size =
2104 srf_update->plane_info->plane_size;
2106 srf_update->plane_info->rotation;
2107 surface->horizontal_mirror =
2108 srf_update->plane_info->horizontal_mirror;
2109 surface->stereo_format =
2110 srf_update->plane_info->stereo_format;
2111 surface->tiling_info =
2112 srf_update->plane_info->tiling_info;
2114 srf_update->plane_info->visible;
2115 surface->per_pixel_alpha =
2116 srf_update->plane_info->per_pixel_alpha;
2117 surface->global_alpha =
2118 srf_update->plane_info->global_alpha;
2119 surface->global_alpha_value =
2120 srf_update->plane_info->global_alpha_value;
2122 srf_update->plane_info->dcc;
2123 surface->layer_index =
2124 srf_update->plane_info->layer_index;
2127 if (srf_update->gamma &&
2128 (surface->gamma_correction !=
2129 srf_update->gamma)) {
2130 memcpy(&surface->gamma_correction->entries,
2131 &srf_update->gamma->entries,
2132 sizeof(struct dc_gamma_entries));
2133 surface->gamma_correction->is_identity =
2134 srf_update->gamma->is_identity;
2135 surface->gamma_correction->num_entries =
2136 srf_update->gamma->num_entries;
2137 surface->gamma_correction->type =
2138 srf_update->gamma->type;
2141 if (srf_update->in_transfer_func &&
2142 (surface->in_transfer_func !=
2143 srf_update->in_transfer_func)) {
2144 surface->in_transfer_func->sdr_ref_white_level =
2145 srf_update->in_transfer_func->sdr_ref_white_level;
2146 surface->in_transfer_func->tf =
2147 srf_update->in_transfer_func->tf;
2148 surface->in_transfer_func->type =
2149 srf_update->in_transfer_func->type;
2150 memcpy(&surface->in_transfer_func->tf_pts,
2151 &srf_update->in_transfer_func->tf_pts,
2152 sizeof(struct dc_transfer_func_distributed_points));
2155 if (srf_update->func_shaper &&
2156 (surface->in_shaper_func !=
2157 srf_update->func_shaper))
2158 memcpy(surface->in_shaper_func, srf_update->func_shaper,
2159 sizeof(*surface->in_shaper_func));
2161 if (srf_update->lut3d_func &&
2162 (surface->lut3d_func !=
2163 srf_update->lut3d_func))
2164 memcpy(surface->lut3d_func, srf_update->lut3d_func,
2165 sizeof(*surface->lut3d_func));
2167 if (srf_update->hdr_mult.value)
2169 srf_update->hdr_mult;
2171 if (srf_update->blend_tf &&
2172 (surface->blend_tf !=
2173 srf_update->blend_tf))
2174 memcpy(surface->blend_tf, srf_update->blend_tf,
2175 sizeof(*surface->blend_tf));
2177 if (srf_update->input_csc_color_matrix)
2178 surface->input_csc_color_matrix =
2179 *srf_update->input_csc_color_matrix;
2181 if (srf_update->coeff_reduction_factor)
2182 surface->coeff_reduction_factor =
2183 *srf_update->coeff_reduction_factor;
2185 if (srf_update->gamut_remap_matrix)
2186 surface->gamut_remap_matrix =
2187 *srf_update->gamut_remap_matrix;
2190 static void copy_stream_update_to_stream(struct dc *dc,
2191 struct dc_state *context,
2192 struct dc_stream_state *stream,
2193 struct dc_stream_update *update)
2195 struct dc_context *dc_ctx = dc->ctx;
2197 if (update == NULL || stream == NULL)
2200 if (update->src.height && update->src.width)
2201 stream->src = update->src;
2203 if (update->dst.height && update->dst.width)
2204 stream->dst = update->dst;
2206 if (update->out_transfer_func &&
2207 stream->out_transfer_func != update->out_transfer_func) {
2208 stream->out_transfer_func->sdr_ref_white_level =
2209 update->out_transfer_func->sdr_ref_white_level;
2210 stream->out_transfer_func->tf = update->out_transfer_func->tf;
2211 stream->out_transfer_func->type =
2212 update->out_transfer_func->type;
2213 memcpy(&stream->out_transfer_func->tf_pts,
2214 &update->out_transfer_func->tf_pts,
2215 sizeof(struct dc_transfer_func_distributed_points));
2218 if (update->hdr_static_metadata)
2219 stream->hdr_static_metadata = *update->hdr_static_metadata;
2221 if (update->abm_level)
2222 stream->abm_level = *update->abm_level;
2224 if (update->periodic_interrupt0)
2225 stream->periodic_interrupt0 = *update->periodic_interrupt0;
2227 if (update->periodic_interrupt1)
2228 stream->periodic_interrupt1 = *update->periodic_interrupt1;
2230 if (update->gamut_remap)
2231 stream->gamut_remap_matrix = *update->gamut_remap;
2233 /* Note: this being updated after mode set is currently not a use case
2234 * however if it arises OCSC would need to be reprogrammed at the
2237 if (update->output_color_space)
2238 stream->output_color_space = *update->output_color_space;
2240 if (update->output_csc_transform)
2241 stream->csc_color_matrix = *update->output_csc_transform;
2243 if (update->vrr_infopacket)
2244 stream->vrr_infopacket = *update->vrr_infopacket;
2246 if (update->dpms_off)
2247 stream->dpms_off = *update->dpms_off;
2249 if (update->vsc_infopacket)
2250 stream->vsc_infopacket = *update->vsc_infopacket;
2252 if (update->vsp_infopacket)
2253 stream->vsp_infopacket = *update->vsp_infopacket;
2255 if (update->dither_option)
2256 stream->dither_option = *update->dither_option;
2257 /* update current stream with writeback info */
2258 if (update->wb_update) {
2261 stream->num_wb_info = update->wb_update->num_wb_info;
2262 ASSERT(stream->num_wb_info <= MAX_DWB_PIPES);
2263 for (i = 0; i < stream->num_wb_info; i++)
2264 stream->writeback_info[i] =
2265 update->wb_update->writeback_info[i];
2267 if (update->dsc_config) {
2268 struct dc_dsc_config old_dsc_cfg = stream->timing.dsc_cfg;
2269 uint32_t old_dsc_enabled = stream->timing.flags.DSC;
2270 uint32_t enable_dsc = (update->dsc_config->num_slices_h != 0 &&
2271 update->dsc_config->num_slices_v != 0);
2273 /* Use temporarry context for validating new DSC config */
2274 struct dc_state *dsc_validate_context = dc_create_state(dc);
2276 if (dsc_validate_context) {
2277 dc_resource_state_copy_construct(dc->current_state, dsc_validate_context);
2279 stream->timing.dsc_cfg = *update->dsc_config;
2280 stream->timing.flags.DSC = enable_dsc;
2281 if (!dc->res_pool->funcs->validate_bandwidth(dc, dsc_validate_context, true)) {
2282 stream->timing.dsc_cfg = old_dsc_cfg;
2283 stream->timing.flags.DSC = old_dsc_enabled;
2284 update->dsc_config = NULL;
2287 dc_release_state(dsc_validate_context);
2289 DC_ERROR("Failed to allocate new validate context for DSC change\n");
2290 update->dsc_config = NULL;
2295 static void commit_planes_do_stream_update(struct dc *dc,
2296 struct dc_stream_state *stream,
2297 struct dc_stream_update *stream_update,
2298 enum surface_update_type update_type,
2299 struct dc_state *context)
2302 bool should_program_abm;
2305 for (j = 0; j < dc->res_pool->pipe_count; j++) {
2306 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j];
2308 if (!pipe_ctx->top_pipe && !pipe_ctx->prev_odm_pipe && pipe_ctx->stream == stream) {
2310 if (stream_update->periodic_interrupt0 &&
2311 dc->hwss.setup_periodic_interrupt)
2312 dc->hwss.setup_periodic_interrupt(dc, pipe_ctx, VLINE0);
2314 if (stream_update->periodic_interrupt1 &&
2315 dc->hwss.setup_periodic_interrupt)
2316 dc->hwss.setup_periodic_interrupt(dc, pipe_ctx, VLINE1);
2318 if ((stream_update->hdr_static_metadata && !stream->use_dynamic_meta) ||
2319 stream_update->vrr_infopacket ||
2320 stream_update->vsc_infopacket ||
2321 stream_update->vsp_infopacket) {
2322 resource_build_info_frame(pipe_ctx);
2323 dc->hwss.update_info_frame(pipe_ctx);
2326 if (stream_update->hdr_static_metadata &&
2327 stream->use_dynamic_meta &&
2328 dc->hwss.set_dmdata_attributes &&
2329 pipe_ctx->stream->dmdata_address.quad_part != 0)
2330 dc->hwss.set_dmdata_attributes(pipe_ctx);
2332 if (stream_update->gamut_remap)
2333 dc_stream_set_gamut_remap(dc, stream);
2335 if (stream_update->output_csc_transform)
2336 dc_stream_program_csc_matrix(dc, stream);
2338 if (stream_update->dither_option) {
2339 struct pipe_ctx *odm_pipe = pipe_ctx->next_odm_pipe;
2340 resource_build_bit_depth_reduction_params(pipe_ctx->stream,
2341 &pipe_ctx->stream->bit_depth_params);
2342 pipe_ctx->stream_res.opp->funcs->opp_program_fmt(pipe_ctx->stream_res.opp,
2343 &stream->bit_depth_params,
2346 odm_pipe->stream_res.opp->funcs->opp_program_fmt(odm_pipe->stream_res.opp,
2347 &stream->bit_depth_params,
2349 odm_pipe = odm_pipe->next_odm_pipe;
2354 if (update_type == UPDATE_TYPE_FAST)
2357 if (stream_update->dsc_config)
2358 dp_update_dsc_config(pipe_ctx);
2360 if (stream_update->dpms_off) {
2361 if (*stream_update->dpms_off) {
2362 core_link_disable_stream(pipe_ctx);
2363 /* for dpms, keep acquired resources*/
2364 if (pipe_ctx->stream_res.audio && !dc->debug.az_endpoint_mute_only)
2365 pipe_ctx->stream_res.audio->funcs->az_disable(pipe_ctx->stream_res.audio);
2367 dc->hwss.optimize_bandwidth(dc, dc->current_state);
2369 if (dc->optimize_seamless_boot_streams == 0)
2370 dc->hwss.prepare_bandwidth(dc, dc->current_state);
2372 core_link_enable_stream(dc->current_state, pipe_ctx);
2376 if (stream_update->abm_level && pipe_ctx->stream_res.abm) {
2377 should_program_abm = true;
2379 // if otg funcs defined check if blanked before programming
2380 if (pipe_ctx->stream_res.tg->funcs->is_blanked)
2381 if (pipe_ctx->stream_res.tg->funcs->is_blanked(pipe_ctx->stream_res.tg))
2382 should_program_abm = false;
2384 if (should_program_abm) {
2385 if (*stream_update->abm_level == ABM_LEVEL_IMMEDIATE_DISABLE) {
2386 dc->hwss.set_abm_immediate_disable(pipe_ctx);
2388 pipe_ctx->stream_res.abm->funcs->set_abm_level(
2389 pipe_ctx->stream_res.abm, stream->abm_level);
2397 static void commit_planes_for_stream(struct dc *dc,
2398 struct dc_surface_update *srf_updates,
2400 struct dc_stream_state *stream,
2401 struct dc_stream_update *stream_update,
2402 enum surface_update_type update_type,
2403 struct dc_state *context)
2406 struct pipe_ctx *top_pipe_to_program = NULL;
2408 if (dc->optimize_seamless_boot_streams > 0 && surface_count > 0) {
2409 /* Optimize seamless boot flag keeps clocks and watermarks high until
2410 * first flip. After first flip, optimization is required to lower
2411 * bandwidth. Important to note that it is expected UEFI will
2412 * only light up a single display on POST, therefore we only expect
2413 * one stream with seamless boot flag set.
2415 if (stream->apply_seamless_boot_optimization) {
2416 stream->apply_seamless_boot_optimization = false;
2417 dc->optimize_seamless_boot_streams--;
2419 if (dc->optimize_seamless_boot_streams == 0)
2420 dc->optimized_required = true;
2424 if (update_type == UPDATE_TYPE_FULL) {
2425 #if defined(CONFIG_DRM_AMD_DC_DCN)
2426 dc_allow_idle_optimizations(dc, false);
2429 if (dc->optimize_seamless_boot_streams == 0)
2430 dc->hwss.prepare_bandwidth(dc, context);
2432 context_clock_trace(dc, context);
2435 for (j = 0; j < dc->res_pool->pipe_count; j++) {
2436 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j];
2438 if (!pipe_ctx->top_pipe &&
2439 !pipe_ctx->prev_odm_pipe &&
2441 pipe_ctx->stream == stream) {
2442 top_pipe_to_program = pipe_ctx;
2446 if ((update_type != UPDATE_TYPE_FAST) && stream->update_flags.bits.dsc_changed)
2447 if (top_pipe_to_program->stream_res.tg->funcs->lock_doublebuffer_enable) {
2448 if (should_use_dmub_lock(stream->link)) {
2449 union dmub_hw_lock_flags hw_locks = { 0 };
2450 struct dmub_hw_lock_inst_flags inst_flags = { 0 };
2452 hw_locks.bits.lock_dig = 1;
2453 inst_flags.dig_inst = top_pipe_to_program->stream_res.tg->inst;
2455 dmub_hw_lock_mgr_cmd(dc->ctx->dmub_srv,
2460 top_pipe_to_program->stream_res.tg->funcs->lock_doublebuffer_enable(
2461 top_pipe_to_program->stream_res.tg);
2464 if ((update_type != UPDATE_TYPE_FAST) && dc->hwss.interdependent_update_lock)
2465 dc->hwss.interdependent_update_lock(dc, context, true);
2467 /* Lock the top pipe while updating plane addrs, since freesync requires
2468 * plane addr update event triggers to be synchronized.
2469 * top_pipe_to_program is expected to never be NULL
2471 dc->hwss.pipe_control_lock(dc, top_pipe_to_program, true);
2475 commit_planes_do_stream_update(dc, stream, stream_update, update_type, context);
2477 if (surface_count == 0) {
2479 * In case of turning off screen, no need to program front end a second time.
2480 * just return after program blank.
2482 if (dc->hwss.apply_ctx_for_surface)
2483 dc->hwss.apply_ctx_for_surface(dc, stream, 0, context);
2484 if (dc->hwss.program_front_end_for_ctx)
2485 dc->hwss.program_front_end_for_ctx(dc, context);
2487 if ((update_type != UPDATE_TYPE_FAST) && dc->hwss.interdependent_update_lock)
2488 dc->hwss.interdependent_update_lock(dc, context, false);
2490 dc->hwss.pipe_control_lock(dc, top_pipe_to_program, false);
2492 dc->hwss.post_unlock_program_front_end(dc, context);
2496 if (!IS_DIAG_DC(dc->ctx->dce_environment)) {
2497 for (i = 0; i < surface_count; i++) {
2498 struct dc_plane_state *plane_state = srf_updates[i].surface;
2499 /*set logical flag for lock/unlock use*/
2500 for (j = 0; j < dc->res_pool->pipe_count; j++) {
2501 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j];
2502 if (!pipe_ctx->plane_state)
2504 if (pipe_ctx->plane_state != plane_state)
2506 plane_state->triplebuffer_flips = false;
2507 if (update_type == UPDATE_TYPE_FAST &&
2508 dc->hwss.program_triplebuffer != NULL &&
2509 !plane_state->flip_immediate && dc->debug.enable_tri_buf) {
2510 /*triple buffer for VUpdate only*/
2511 plane_state->triplebuffer_flips = true;
2517 // Update Type FULL, Surface updates
2518 for (j = 0; j < dc->res_pool->pipe_count; j++) {
2519 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j];
2521 if (!pipe_ctx->top_pipe &&
2522 !pipe_ctx->prev_odm_pipe &&
2524 pipe_ctx->stream == stream) {
2525 struct dc_stream_status *stream_status = NULL;
2527 if (!pipe_ctx->plane_state)
2531 if (update_type == UPDATE_TYPE_FAST)
2534 ASSERT(!pipe_ctx->plane_state->triplebuffer_flips);
2536 if (dc->hwss.program_triplebuffer != NULL && dc->debug.enable_tri_buf) {
2537 /*turn off triple buffer for full update*/
2538 dc->hwss.program_triplebuffer(
2539 dc, pipe_ctx, pipe_ctx->plane_state->triplebuffer_flips);
2542 stream_get_status(context, pipe_ctx->stream);
2544 if (dc->hwss.apply_ctx_for_surface)
2545 dc->hwss.apply_ctx_for_surface(
2546 dc, pipe_ctx->stream, stream_status->plane_count, context);
2549 if (dc->hwss.program_front_end_for_ctx && update_type != UPDATE_TYPE_FAST) {
2550 dc->hwss.program_front_end_for_ctx(dc, context);
2551 #ifdef CONFIG_DRM_AMD_DC_DCN
2552 if (dc->debug.validate_dml_output) {
2553 for (i = 0; i < dc->res_pool->pipe_count; i++) {
2554 struct pipe_ctx cur_pipe = context->res_ctx.pipe_ctx[i];
2555 if (cur_pipe.stream == NULL)
2558 cur_pipe.plane_res.hubp->funcs->validate_dml_output(
2559 cur_pipe.plane_res.hubp, dc->ctx,
2560 &context->res_ctx.pipe_ctx[i].rq_regs,
2561 &context->res_ctx.pipe_ctx[i].dlg_regs,
2562 &context->res_ctx.pipe_ctx[i].ttu_regs);
2568 // Update Type FAST, Surface updates
2569 if (update_type == UPDATE_TYPE_FAST) {
2570 if (dc->hwss.set_flip_control_gsl)
2571 for (i = 0; i < surface_count; i++) {
2572 struct dc_plane_state *plane_state = srf_updates[i].surface;
2574 for (j = 0; j < dc->res_pool->pipe_count; j++) {
2575 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j];
2577 if (pipe_ctx->stream != stream)
2580 if (pipe_ctx->plane_state != plane_state)
2583 // GSL has to be used for flip immediate
2584 dc->hwss.set_flip_control_gsl(pipe_ctx,
2585 plane_state->flip_immediate);
2588 /* Perform requested Updates */
2589 for (i = 0; i < surface_count; i++) {
2590 struct dc_plane_state *plane_state = srf_updates[i].surface;
2592 for (j = 0; j < dc->res_pool->pipe_count; j++) {
2593 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j];
2595 if (pipe_ctx->stream != stream)
2598 if (pipe_ctx->plane_state != plane_state)
2600 /*program triple buffer after lock based on flip type*/
2601 if (dc->hwss.program_triplebuffer != NULL && dc->debug.enable_tri_buf) {
2602 /*only enable triplebuffer for fast_update*/
2603 dc->hwss.program_triplebuffer(
2604 dc, pipe_ctx, plane_state->triplebuffer_flips);
2606 if (srf_updates[i].flip_addr)
2607 dc->hwss.update_plane_addr(dc, pipe_ctx);
2612 if ((update_type != UPDATE_TYPE_FAST) && dc->hwss.interdependent_update_lock)
2613 dc->hwss.interdependent_update_lock(dc, context, false);
2615 dc->hwss.pipe_control_lock(dc, top_pipe_to_program, false);
2617 if ((update_type != UPDATE_TYPE_FAST) && stream->update_flags.bits.dsc_changed)
2618 if (top_pipe_to_program->stream_res.tg->funcs->lock_doublebuffer_enable) {
2619 top_pipe_to_program->stream_res.tg->funcs->wait_for_state(
2620 top_pipe_to_program->stream_res.tg,
2621 CRTC_STATE_VACTIVE);
2622 top_pipe_to_program->stream_res.tg->funcs->wait_for_state(
2623 top_pipe_to_program->stream_res.tg,
2625 top_pipe_to_program->stream_res.tg->funcs->wait_for_state(
2626 top_pipe_to_program->stream_res.tg,
2627 CRTC_STATE_VACTIVE);
2629 if (stream && should_use_dmub_lock(stream->link)) {
2630 union dmub_hw_lock_flags hw_locks = { 0 };
2631 struct dmub_hw_lock_inst_flags inst_flags = { 0 };
2633 hw_locks.bits.lock_dig = 1;
2634 inst_flags.dig_inst = top_pipe_to_program->stream_res.tg->inst;
2636 dmub_hw_lock_mgr_cmd(dc->ctx->dmub_srv,
2641 top_pipe_to_program->stream_res.tg->funcs->lock_doublebuffer_disable(
2642 top_pipe_to_program->stream_res.tg);
2645 if (update_type != UPDATE_TYPE_FAST)
2646 dc->hwss.post_unlock_program_front_end(dc, context);
2648 // Fire manual trigger only when bottom plane is flipped
2649 for (j = 0; j < dc->res_pool->pipe_count; j++) {
2650 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j];
2652 if (pipe_ctx->bottom_pipe || pipe_ctx->next_odm_pipe ||
2653 !pipe_ctx->stream || pipe_ctx->stream != stream ||
2654 !pipe_ctx->plane_state->update_flags.bits.addr_update)
2657 if (pipe_ctx->stream_res.tg->funcs->program_manual_trigger)
2658 pipe_ctx->stream_res.tg->funcs->program_manual_trigger(pipe_ctx->stream_res.tg);
2662 void dc_commit_updates_for_stream(struct dc *dc,
2663 struct dc_surface_update *srf_updates,
2665 struct dc_stream_state *stream,
2666 struct dc_stream_update *stream_update,
2667 struct dc_state *state)
2669 const struct dc_stream_status *stream_status;
2670 enum surface_update_type update_type;
2671 struct dc_state *context;
2672 struct dc_context *dc_ctx = dc->ctx;
2675 stream_status = dc_stream_get_status(stream);
2676 context = dc->current_state;
2678 update_type = dc_check_update_surfaces_for_stream(
2679 dc, srf_updates, surface_count, stream_update, stream_status);
2681 if (update_type >= update_surface_trace_level)
2682 update_surface_trace(dc, srf_updates, surface_count);
2685 if (update_type >= UPDATE_TYPE_FULL) {
2687 /* initialize scratch memory for building context */
2688 context = dc_create_state(dc);
2689 if (context == NULL) {
2690 DC_ERROR("Failed to allocate new validate context!\n");
2694 dc_resource_state_copy_construct(state, context);
2696 for (i = 0; i < dc->res_pool->pipe_count; i++) {
2697 struct pipe_ctx *new_pipe = &context->res_ctx.pipe_ctx[i];
2698 struct pipe_ctx *old_pipe = &dc->current_state->res_ctx.pipe_ctx[i];
2700 if (new_pipe->plane_state && new_pipe->plane_state != old_pipe->plane_state)
2701 new_pipe->plane_state->force_full_update = true;
2706 for (i = 0; i < surface_count; i++) {
2707 struct dc_plane_state *surface = srf_updates[i].surface;
2709 copy_surface_update_to_plane(surface, &srf_updates[i]);
2711 if (update_type >= UPDATE_TYPE_MED) {
2712 for (j = 0; j < dc->res_pool->pipe_count; j++) {
2713 struct pipe_ctx *pipe_ctx =
2714 &context->res_ctx.pipe_ctx[j];
2716 if (pipe_ctx->plane_state != surface)
2719 resource_build_scaling_params(pipe_ctx);
2724 copy_stream_update_to_stream(dc, context, stream, stream_update);
2726 if (update_type >= UPDATE_TYPE_FULL) {
2727 if (!dc->res_pool->funcs->validate_bandwidth(dc, context, false)) {
2728 DC_ERROR("Mode validation failed for stream update!\n");
2729 dc_release_state(context);
2734 TRACE_DC_PIPE_STATE(pipe_ctx, i, MAX_PIPES);
2736 commit_planes_for_stream(
2744 /*update current_State*/
2745 if (dc->current_state != context) {
2747 struct dc_state *old = dc->current_state;
2749 dc->current_state = context;
2750 dc_release_state(old);
2752 for (i = 0; i < dc->res_pool->pipe_count; i++) {
2753 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
2755 if (pipe_ctx->plane_state && pipe_ctx->stream == stream)
2756 pipe_ctx->plane_state->force_full_update = false;
2759 /*let's use current_state to update watermark etc*/
2760 if (update_type >= UPDATE_TYPE_FULL) {
2761 dc_post_update_surfaces_to_stream(dc);
2763 if (dc_ctx->dce_version >= DCE_VERSION_MAX)
2764 TRACE_DCN_CLOCK_STATE(&context->bw_ctx.bw.dcn.clk);
2766 TRACE_DCE_CLOCK_STATE(&context->bw_ctx.bw.dce);
2773 uint8_t dc_get_current_stream_count(struct dc *dc)
2775 return dc->current_state->stream_count;
2778 struct dc_stream_state *dc_get_stream_at_index(struct dc *dc, uint8_t i)
2780 if (i < dc->current_state->stream_count)
2781 return dc->current_state->streams[i];
2785 enum dc_irq_source dc_interrupt_to_irq_source(
2790 return dal_irq_service_to_irq_source(dc->res_pool->irqs, src_id, ext_id);
2794 * dc_interrupt_set() - Enable/disable an AMD hw interrupt source
2796 bool dc_interrupt_set(struct dc *dc, enum dc_irq_source src, bool enable)
2802 return dal_irq_service_set(dc->res_pool->irqs, src, enable);
2805 void dc_interrupt_ack(struct dc *dc, enum dc_irq_source src)
2807 dal_irq_service_ack(dc->res_pool->irqs, src);
2810 void dc_power_down_on_boot(struct dc *dc)
2812 if (dc->ctx->dce_environment != DCE_ENV_VIRTUAL_HW &&
2813 dc->hwss.power_down_on_boot)
2814 dc->hwss.power_down_on_boot(dc);
2817 void dc_set_power_state(
2819 enum dc_acpi_cm_power_state power_state)
2821 struct kref refcount;
2822 struct display_mode_lib *dml;
2824 switch (power_state) {
2825 case DC_ACPI_CM_POWER_STATE_D0:
2826 dc_resource_state_construct(dc, dc->current_state);
2828 if (dc->ctx->dmub_srv)
2829 dc_dmub_srv_wait_phy_init(dc->ctx->dmub_srv);
2831 dc->hwss.init_hw(dc);
2833 if (dc->hwss.init_sys_ctx != NULL &&
2834 dc->vm_pa_config.valid) {
2835 dc->hwss.init_sys_ctx(dc->hwseq, dc, &dc->vm_pa_config);
2840 ASSERT(dc->current_state->stream_count == 0);
2841 /* Zero out the current context so that on resume we start with
2842 * clean state, and dc hw programming optimizations will not
2843 * cause any trouble.
2845 dml = kzalloc(sizeof(struct display_mode_lib),
2852 /* Preserve refcount */
2853 refcount = dc->current_state->refcount;
2854 /* Preserve display mode lib */
2855 memcpy(dml, &dc->current_state->bw_ctx.dml, sizeof(struct display_mode_lib));
2857 dc_resource_state_destruct(dc->current_state);
2858 memset(dc->current_state, 0,
2859 sizeof(*dc->current_state));
2861 dc->current_state->refcount = refcount;
2862 dc->current_state->bw_ctx.dml = *dml;
2870 void dc_resume(struct dc *dc)
2874 for (i = 0; i < dc->link_count; i++)
2875 core_link_resume(dc->links[i]);
2878 bool dc_is_dmcu_initialized(struct dc *dc)
2880 struct dmcu *dmcu = dc->res_pool->dmcu;
2883 return dmcu->funcs->is_dmcu_initialized(dmcu);
2889 uint32_t link_index,
2890 struct i2c_command *cmd)
2893 struct dc_link *link = dc->links[link_index];
2894 struct ddc_service *ddc = link->ddc;
2895 return dce_i2c_submit_command(
2901 bool dc_submit_i2c_oem(
2903 struct i2c_command *cmd)
2905 struct ddc_service *ddc = dc->res_pool->oem_device;
2906 return dce_i2c_submit_command(
2912 static bool link_add_remote_sink_helper(struct dc_link *dc_link, struct dc_sink *sink)
2914 if (dc_link->sink_count >= MAX_SINKS_PER_LINK) {
2915 BREAK_TO_DEBUGGER();
2919 dc_sink_retain(sink);
2921 dc_link->remote_sinks[dc_link->sink_count] = sink;
2922 dc_link->sink_count++;
2928 * dc_link_add_remote_sink() - Create a sink and attach it to an existing link
2930 * EDID length is in bytes
2932 struct dc_sink *dc_link_add_remote_sink(
2933 struct dc_link *link,
2934 const uint8_t *edid,
2936 struct dc_sink_init_data *init_data)
2938 struct dc_sink *dc_sink;
2939 enum dc_edid_status edid_status;
2941 if (len > DC_MAX_EDID_BUFFER_SIZE) {
2942 dm_error("Max EDID buffer size breached!\n");
2947 BREAK_TO_DEBUGGER();
2951 if (!init_data->link) {
2952 BREAK_TO_DEBUGGER();
2956 dc_sink = dc_sink_create(init_data);
2961 memmove(dc_sink->dc_edid.raw_edid, edid, len);
2962 dc_sink->dc_edid.length = len;
2964 if (!link_add_remote_sink_helper(
2969 edid_status = dm_helpers_parse_edid_caps(
2972 &dc_sink->edid_caps);
2975 * Treat device as no EDID device if EDID
2978 if (edid_status != EDID_OK) {
2979 dc_sink->dc_edid.length = 0;
2980 dm_error("Bad EDID, status%d!\n", edid_status);
2986 dc_sink_release(dc_sink);
2991 * dc_link_remove_remote_sink() - Remove a remote sink from a dc_link
2993 * Note that this just removes the struct dc_sink - it doesn't
2994 * program hardware or alter other members of dc_link
2996 void dc_link_remove_remote_sink(struct dc_link *link, struct dc_sink *sink)
3000 if (!link->sink_count) {
3001 BREAK_TO_DEBUGGER();
3005 for (i = 0; i < link->sink_count; i++) {
3006 if (link->remote_sinks[i] == sink) {
3007 dc_sink_release(sink);
3008 link->remote_sinks[i] = NULL;
3010 /* shrink array to remove empty place */
3011 while (i < link->sink_count - 1) {
3012 link->remote_sinks[i] = link->remote_sinks[i+1];
3015 link->remote_sinks[i] = NULL;
3022 void get_clock_requirements_for_state(struct dc_state *state, struct AsicStateEx *info)
3024 info->displayClock = (unsigned int)state->bw_ctx.bw.dcn.clk.dispclk_khz;
3025 info->engineClock = (unsigned int)state->bw_ctx.bw.dcn.clk.dcfclk_khz;
3026 info->memoryClock = (unsigned int)state->bw_ctx.bw.dcn.clk.dramclk_khz;
3027 info->maxSupportedDppClock = (unsigned int)state->bw_ctx.bw.dcn.clk.max_supported_dppclk_khz;
3028 info->dppClock = (unsigned int)state->bw_ctx.bw.dcn.clk.dppclk_khz;
3029 info->socClock = (unsigned int)state->bw_ctx.bw.dcn.clk.socclk_khz;
3030 info->dcfClockDeepSleep = (unsigned int)state->bw_ctx.bw.dcn.clk.dcfclk_deep_sleep_khz;
3031 info->fClock = (unsigned int)state->bw_ctx.bw.dcn.clk.fclk_khz;
3032 info->phyClock = (unsigned int)state->bw_ctx.bw.dcn.clk.phyclk_khz;
3034 enum dc_status dc_set_clock(struct dc *dc, enum dc_clock_type clock_type, uint32_t clk_khz, uint32_t stepping)
3036 if (dc->hwss.set_clock)
3037 return dc->hwss.set_clock(dc, clock_type, clk_khz, stepping);
3038 return DC_ERROR_UNEXPECTED;
3040 void dc_get_clock(struct dc *dc, enum dc_clock_type clock_type, struct dc_clock_config *clock_cfg)
3042 if (dc->hwss.get_clock)
3043 dc->hwss.get_clock(dc, clock_type, clock_cfg);
3046 /* enable/disable eDP PSR without specify stream for eDP */
3047 bool dc_set_psr_allow_active(struct dc *dc, bool enable)
3051 for (i = 0; i < dc->current_state->stream_count ; i++) {
3052 struct dc_link *link;
3053 struct dc_stream_state *stream = dc->current_state->streams[i];
3055 link = stream->link;
3059 if (link->psr_settings.psr_feature_enabled) {
3060 if (enable && !link->psr_settings.psr_allow_active)
3061 return dc_link_set_psr_allow_active(link, true, false);
3062 else if (!enable && link->psr_settings.psr_allow_active)
3063 return dc_link_set_psr_allow_active(link, false, true);
3070 #if defined(CONFIG_DRM_AMD_DC_DCN)
3072 void dc_allow_idle_optimizations(struct dc *dc, bool allow)
3074 if (dc->debug.disable_idle_power_optimizations)
3077 if (allow == dc->idle_optimizations_allowed)
3080 if (dc->hwss.apply_idle_power_optimizations && dc->hwss.apply_idle_power_optimizations(dc, allow))
3081 dc->idle_optimizations_allowed = allow;
3085 * blank all streams, and set min and max memory clock to
3086 * lowest and highest DPM level, respectively
3088 void dc_unlock_memory_clock_frequency(struct dc *dc)
3092 for (i = 0; i < MAX_PIPES; i++)
3093 if (dc->current_state->res_ctx.pipe_ctx[i].plane_state)
3094 core_link_disable_stream(&dc->current_state->res_ctx.pipe_ctx[i]);
3096 dc->clk_mgr->funcs->set_hard_min_memclk(dc->clk_mgr, false);
3097 dc->clk_mgr->funcs->set_hard_max_memclk(dc->clk_mgr);
3101 * set min memory clock to the min required for current mode,
3102 * max to maxDPM, and unblank streams
3104 void dc_lock_memory_clock_frequency(struct dc *dc)
3108 dc->clk_mgr->funcs->get_memclk_states_from_smu(dc->clk_mgr);
3109 dc->clk_mgr->funcs->set_hard_min_memclk(dc->clk_mgr, true);
3110 dc->clk_mgr->funcs->set_hard_max_memclk(dc->clk_mgr);
3112 for (i = 0; i < MAX_PIPES; i++)
3113 if (dc->current_state->res_ctx.pipe_ctx[i].plane_state)
3114 core_link_enable_stream(dc->current_state, &dc->current_state->res_ctx.pipe_ctx[i]);
3117 bool dc_is_plane_eligible_for_idle_optimizaitons(struct dc *dc,
3118 struct dc_plane_state *plane)
3123 /* cleanup on driver unload */
3124 void dc_hardware_release(struct dc *dc)
3126 if (dc->hwss.hardware_release)
3127 dc->hwss.hardware_release(dc);