summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/display/dc/dcn20
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 18:50:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 18:50:03 +0000
commit01a69402cf9d38ff180345d55c2ee51c7e89fbc7 (patch)
treeb406c5242a088c4f59c6e4b719b783f43aca6ae9 /drivers/gpu/drm/amd/display/dc/dcn20
parentAdding upstream version 6.7.12. (diff)
downloadlinux-01a69402cf9d38ff180345d55c2ee51c7e89fbc7.tar.xz
linux-01a69402cf9d38ff180345d55c2ee51c7e89fbc7.zip
Adding upstream version 6.8.9.upstream/6.8.9
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'drivers/gpu/drm/amd/display/dc/dcn20')
-rw-r--r--drivers/gpu/drm/amd/display/dc/dcn20/Makefile6
-rw-r--r--drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dccg.h38
-rw-r--r--drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c780
-rw-r--r--drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.h589
-rw-r--r--drivers/gpu/drm/amd/display/dc/dcn20/dcn20_init.c145
-rw-r--r--drivers/gpu/drm/amd/display/dc/dcn20/dcn20_init.h33
-rw-r--r--drivers/gpu/drm/amd/display/dc/dcn20/dcn20_opp.c14
-rw-r--r--drivers/gpu/drm/amd/display/dc/dcn20/dcn20_opp.h2
-rw-r--r--drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.c587
-rw-r--r--drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.h124
-rw-r--r--drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c2793
-rw-r--r--drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.h171
12 files changed, 55 insertions, 5227 deletions
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/Makefile b/drivers/gpu/drm/amd/display/dc/dcn20/Makefile
index d7dc9696a8..3dae3943b0 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/Makefile
@@ -2,13 +2,11 @@
#
# Makefile for DCN.
-DCN20 = dcn20_resource.o dcn20_init.o dcn20_dpp.o dcn20_dpp_cm.o dcn20_hubp.o \
- dcn20_mpc.o dcn20_opp.o dcn20_hubbub.o dcn20_optc.o dcn20_mmhubbub.o \
+DCN20 = dcn20_dpp.o dcn20_dpp_cm.o dcn20_hubp.o \
+ dcn20_mpc.o dcn20_opp.o dcn20_hubbub.o dcn20_mmhubbub.o \
dcn20_stream_encoder.o dcn20_link_encoder.o dcn20_dccg.o \
dcn20_vmid.o dcn20_dwb.o dcn20_dwb_scl.o
-DCN20 += dcn20_dsc.o
-
AMD_DAL_DCN20 = $(addprefix $(AMDDALPATH)/dc/dcn20/,$(DCN20))
AMD_DISPLAY_FILES += $(AMD_DAL_DCN20)
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dccg.h b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dccg.h
index ab6d09c6fe..ef5c22f415 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dccg.h
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dccg.h
@@ -291,7 +291,43 @@
type SYMCLKB_FE_SRC_SEL;\
type SYMCLKC_FE_SRC_SEL;\
type SYMCLKD_FE_SRC_SEL;\
- type SYMCLKE_FE_SRC_SEL;
+ type SYMCLKE_FE_SRC_SEL;\
+ type DTBCLK_P0_GATE_DISABLE;\
+ type DTBCLK_P1_GATE_DISABLE;\
+ type DTBCLK_P2_GATE_DISABLE;\
+ type DTBCLK_P3_GATE_DISABLE;\
+ type DSCCLK0_ROOT_GATE_DISABLE;\
+ type DSCCLK1_ROOT_GATE_DISABLE;\
+ type DSCCLK2_ROOT_GATE_DISABLE;\
+ type DSCCLK3_ROOT_GATE_DISABLE;\
+ type SYMCLKA_FE_ROOT_GATE_DISABLE;\
+ type SYMCLKB_FE_ROOT_GATE_DISABLE;\
+ type SYMCLKC_FE_ROOT_GATE_DISABLE;\
+ type SYMCLKD_FE_ROOT_GATE_DISABLE;\
+ type SYMCLKE_FE_ROOT_GATE_DISABLE;\
+ type DPPCLK0_ROOT_GATE_DISABLE;\
+ type DPPCLK1_ROOT_GATE_DISABLE;\
+ type DPPCLK2_ROOT_GATE_DISABLE;\
+ type DPPCLK3_ROOT_GATE_DISABLE;\
+ type HDMISTREAMCLK0_ROOT_GATE_DISABLE;\
+ type SYMCLKA_ROOT_GATE_DISABLE;\
+ type SYMCLKB_ROOT_GATE_DISABLE;\
+ type SYMCLKC_ROOT_GATE_DISABLE;\
+ type SYMCLKD_ROOT_GATE_DISABLE;\
+ type SYMCLKE_ROOT_GATE_DISABLE;\
+ type PHYA_REFCLK_ROOT_GATE_DISABLE;\
+ type PHYB_REFCLK_ROOT_GATE_DISABLE;\
+ type PHYC_REFCLK_ROOT_GATE_DISABLE;\
+ type PHYD_REFCLK_ROOT_GATE_DISABLE;\
+ type PHYE_REFCLK_ROOT_GATE_DISABLE;\
+ type DPSTREAMCLK0_ROOT_GATE_DISABLE;\
+ type DPSTREAMCLK1_ROOT_GATE_DISABLE;\
+ type DPSTREAMCLK2_ROOT_GATE_DISABLE;\
+ type DPSTREAMCLK3_ROOT_GATE_DISABLE;\
+ type DPSTREAMCLK0_GATE_DISABLE;\
+ type DPSTREAMCLK1_GATE_DISABLE;\
+ type DPSTREAMCLK2_GATE_DISABLE;\
+ type DPSTREAMCLK3_GATE_DISABLE;\
struct dccg_shift {
DCCG_REG_FIELD_LIST(uint8_t)
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c
deleted file mode 100644
index c9ae2d8f00..0000000000
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c
+++ /dev/null
@@ -1,780 +0,0 @@
-/*
- * Copyright 2017 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: AMD
- *
- */
-
-#include <drm/display/drm_dsc_helper.h>
-
-#include "reg_helper.h"
-#include "dcn20_dsc.h"
-#include "dsc/dscc_types.h"
-#include "dsc/rc_calc.h"
-
-static void dsc_write_to_registers(struct display_stream_compressor *dsc, const struct dsc_reg_values *reg_vals);
-
-/* Object I/F functions */
-static void dsc2_read_state(struct display_stream_compressor *dsc, struct dcn_dsc_state *s);
-static bool dsc2_validate_stream(struct display_stream_compressor *dsc, const struct dsc_config *dsc_cfg);
-static void dsc2_set_config(struct display_stream_compressor *dsc, const struct dsc_config *dsc_cfg,
- struct dsc_optc_config *dsc_optc_cfg);
-static void dsc2_enable(struct display_stream_compressor *dsc, int opp_pipe);
-static void dsc2_disable(struct display_stream_compressor *dsc);
-static void dsc2_disconnect(struct display_stream_compressor *dsc);
-
-static const struct dsc_funcs dcn20_dsc_funcs = {
- .dsc_get_enc_caps = dsc2_get_enc_caps,
- .dsc_read_state = dsc2_read_state,
- .dsc_validate_stream = dsc2_validate_stream,
- .dsc_set_config = dsc2_set_config,
- .dsc_get_packed_pps = dsc2_get_packed_pps,
- .dsc_enable = dsc2_enable,
- .dsc_disable = dsc2_disable,
- .dsc_disconnect = dsc2_disconnect,
-};
-
-/* Macro definitios for REG_SET macros*/
-#define CTX \
- dsc20->base.ctx
-
-#define REG(reg)\
- dsc20->dsc_regs->reg
-
-#undef FN
-#define FN(reg_name, field_name) \
- dsc20->dsc_shift->field_name, dsc20->dsc_mask->field_name
-#define DC_LOGGER \
- dsc->ctx->logger
-
-enum dsc_bits_per_comp {
- DSC_BPC_8 = 8,
- DSC_BPC_10 = 10,
- DSC_BPC_12 = 12,
- DSC_BPC_UNKNOWN
-};
-
-/* API functions (external or via structure->function_pointer) */
-
-void dsc2_construct(struct dcn20_dsc *dsc,
- struct dc_context *ctx,
- int inst,
- const struct dcn20_dsc_registers *dsc_regs,
- const struct dcn20_dsc_shift *dsc_shift,
- const struct dcn20_dsc_mask *dsc_mask)
-{
- dsc->base.ctx = ctx;
- dsc->base.inst = inst;
- dsc->base.funcs = &dcn20_dsc_funcs;
-
- dsc->dsc_regs = dsc_regs;
- dsc->dsc_shift = dsc_shift;
- dsc->dsc_mask = dsc_mask;
-
- dsc->max_image_width = 5184;
-}
-
-
-#define DCN20_MAX_PIXEL_CLOCK_Mhz 1188
-#define DCN20_MAX_DISPLAY_CLOCK_Mhz 1200
-
-/* This returns the capabilities for a single DSC encoder engine. Number of slices and total throughput
- * can be doubled, tripled etc. by using additional DSC engines.
- */
-void dsc2_get_enc_caps(struct dsc_enc_caps *dsc_enc_caps, int pixel_clock_100Hz)
-{
- dsc_enc_caps->dsc_version = 0x21; /* v1.2 - DP spec defined it in reverse order and we kept it */
-
- dsc_enc_caps->slice_caps.bits.NUM_SLICES_1 = 1;
- dsc_enc_caps->slice_caps.bits.NUM_SLICES_2 = 1;
- dsc_enc_caps->slice_caps.bits.NUM_SLICES_3 = 1;
- dsc_enc_caps->slice_caps.bits.NUM_SLICES_4 = 1;
-
- dsc_enc_caps->lb_bit_depth = 13;
- dsc_enc_caps->is_block_pred_supported = true;
-
- dsc_enc_caps->color_formats.bits.RGB = 1;
- dsc_enc_caps->color_formats.bits.YCBCR_444 = 1;
- dsc_enc_caps->color_formats.bits.YCBCR_SIMPLE_422 = 1;
- dsc_enc_caps->color_formats.bits.YCBCR_NATIVE_422 = 0;
- dsc_enc_caps->color_formats.bits.YCBCR_NATIVE_420 = 1;
-
- dsc_enc_caps->color_depth.bits.COLOR_DEPTH_8_BPC = 1;
- dsc_enc_caps->color_depth.bits.COLOR_DEPTH_10_BPC = 1;
- dsc_enc_caps->color_depth.bits.COLOR_DEPTH_12_BPC = 1;
-
- /* Maximum total throughput with all the slices combined. This is different from how DP spec specifies it.
- * Our decoder's total throughput in Pix/s is equal to DISPCLK. This is then shared between slices.
- * The value below is the absolute maximum value. The actual throughput may be lower, but it'll always
- * be sufficient to process the input pixel rate fed into a single DSC engine.
- */
- dsc_enc_caps->max_total_throughput_mps = DCN20_MAX_DISPLAY_CLOCK_Mhz;
-
- /* For pixel clock bigger than a single-pipe limit we'll need two engines, which then doubles our
- * throughput and number of slices, but also introduces a lower limit of 2 slices
- */
- if (pixel_clock_100Hz >= DCN20_MAX_PIXEL_CLOCK_Mhz*10000) {
- dsc_enc_caps->slice_caps.bits.NUM_SLICES_1 = 0;
- dsc_enc_caps->slice_caps.bits.NUM_SLICES_8 = 1;
- dsc_enc_caps->max_total_throughput_mps = DCN20_MAX_DISPLAY_CLOCK_Mhz * 2;
- }
-
- /* For pixel clock bigger than a single-pipe limit needing four engines ODM 4:1, which then quardruples our
- * throughput and number of slices
- */
- if (pixel_clock_100Hz > DCN20_MAX_PIXEL_CLOCK_Mhz*10000*2) {
- dsc_enc_caps->slice_caps.bits.NUM_SLICES_12 = 1;
- dsc_enc_caps->slice_caps.bits.NUM_SLICES_16 = 1;
- dsc_enc_caps->max_total_throughput_mps = DCN20_MAX_DISPLAY_CLOCK_Mhz * 4;
- }
-
- dsc_enc_caps->max_slice_width = 5184; /* (including 64 overlap pixels for eDP MSO mode) */
- dsc_enc_caps->bpp_increment_div = 16; /* 1/16th of a bit */
-}
-
-
-/* this function read dsc related register fields to be logged later in dcn10_log_hw_state
- * into a dcn_dsc_state struct.
- */
-static void dsc2_read_state(struct display_stream_compressor *dsc, struct dcn_dsc_state *s)
-{
- struct dcn20_dsc *dsc20 = TO_DCN20_DSC(dsc);
-
- REG_GET(DSC_TOP_CONTROL, DSC_CLOCK_EN, &s->dsc_clock_en);
- REG_GET(DSCC_PPS_CONFIG3, SLICE_WIDTH, &s->dsc_slice_width);
- REG_GET(DSCC_PPS_CONFIG1, BITS_PER_PIXEL, &s->dsc_bits_per_pixel);
- REG_GET(DSCC_PPS_CONFIG3, SLICE_HEIGHT, &s->dsc_slice_height);
- REG_GET(DSCC_PPS_CONFIG1, CHUNK_SIZE, &s->dsc_chunk_size);
- REG_GET(DSCC_PPS_CONFIG2, PIC_WIDTH, &s->dsc_pic_width);
- REG_GET(DSCC_PPS_CONFIG2, PIC_HEIGHT, &s->dsc_pic_height);
- REG_GET(DSCC_PPS_CONFIG7, SLICE_BPG_OFFSET, &s->dsc_slice_bpg_offset);
- REG_GET_2(DSCRM_DSC_FORWARD_CONFIG, DSCRM_DSC_FORWARD_EN, &s->dsc_fw_en,
- DSCRM_DSC_OPP_PIPE_SOURCE, &s->dsc_opp_source);
-}
-
-
-static bool dsc2_validate_stream(struct display_stream_compressor *dsc, const struct dsc_config *dsc_cfg)
-{
- struct dsc_optc_config dsc_optc_cfg;
- struct dcn20_dsc *dsc20 = TO_DCN20_DSC(dsc);
-
- if (dsc_cfg->pic_width > dsc20->max_image_width)
- return false;
-
- return dsc_prepare_config(dsc_cfg, &dsc20->reg_vals, &dsc_optc_cfg);
-}
-
-
-void dsc_config_log(struct display_stream_compressor *dsc, const struct dsc_config *config)
-{
- DC_LOG_DSC("\tnum_slices_h %d", config->dc_dsc_cfg.num_slices_h);
- DC_LOG_DSC("\tnum_slices_v %d", config->dc_dsc_cfg.num_slices_v);
- DC_LOG_DSC("\tbits_per_pixel %d (%d.%04d)",
- config->dc_dsc_cfg.bits_per_pixel,
- config->dc_dsc_cfg.bits_per_pixel / 16,
- ((config->dc_dsc_cfg.bits_per_pixel % 16) * 10000) / 16);
- DC_LOG_DSC("\tcolor_depth %d", config->color_depth);
-}
-
-static void dsc2_set_config(struct display_stream_compressor *dsc, const struct dsc_config *dsc_cfg,
- struct dsc_optc_config *dsc_optc_cfg)
-{
- bool is_config_ok;
- struct dcn20_dsc *dsc20 = TO_DCN20_DSC(dsc);
-
- DC_LOG_DSC("Setting DSC Config at DSC inst %d", dsc->inst);
- dsc_config_log(dsc, dsc_cfg);
- is_config_ok = dsc_prepare_config(dsc_cfg, &dsc20->reg_vals, dsc_optc_cfg);
- ASSERT(is_config_ok);
- DC_LOG_DSC("programming DSC Picture Parameter Set (PPS):");
- dsc_log_pps(dsc, &dsc20->reg_vals.pps);
- dsc_write_to_registers(dsc, &dsc20->reg_vals);
-}
-
-
-bool dsc2_get_packed_pps(struct display_stream_compressor *dsc, const struct dsc_config *dsc_cfg, uint8_t *dsc_packed_pps)
-{
- bool is_config_ok;
- struct dsc_reg_values dsc_reg_vals;
- struct dsc_optc_config dsc_optc_cfg;
-
- memset(&dsc_reg_vals, 0, sizeof(dsc_reg_vals));
- memset(&dsc_optc_cfg, 0, sizeof(dsc_optc_cfg));
-
- DC_LOG_DSC("Getting packed DSC PPS for DSC Config:");
- dsc_config_log(dsc, dsc_cfg);
- DC_LOG_DSC("DSC Picture Parameter Set (PPS):");
- is_config_ok = dsc_prepare_config(dsc_cfg, &dsc_reg_vals, &dsc_optc_cfg);
- ASSERT(is_config_ok);
- drm_dsc_pps_payload_pack((struct drm_dsc_picture_parameter_set *)dsc_packed_pps, &dsc_reg_vals.pps);
- dsc_log_pps(dsc, &dsc_reg_vals.pps);
-
- return is_config_ok;
-}
-
-
-static void dsc2_enable(struct display_stream_compressor *dsc, int opp_pipe)
-{
- struct dcn20_dsc *dsc20 = TO_DCN20_DSC(dsc);
- int dsc_clock_en;
- int dsc_fw_config;
- int enabled_opp_pipe;
-
- DC_LOG_DSC("enable DSC %d at opp pipe %d", dsc->inst, opp_pipe);
-
- REG_GET(DSC_TOP_CONTROL, DSC_CLOCK_EN, &dsc_clock_en);
- REG_GET_2(DSCRM_DSC_FORWARD_CONFIG, DSCRM_DSC_FORWARD_EN, &dsc_fw_config, DSCRM_DSC_OPP_PIPE_SOURCE, &enabled_opp_pipe);
- if ((dsc_clock_en || dsc_fw_config) && enabled_opp_pipe != opp_pipe) {
- DC_LOG_DSC("ERROR: DSC %d at opp pipe %d already enabled!", dsc->inst, enabled_opp_pipe);
- ASSERT(0);
- }
-
- REG_UPDATE(DSC_TOP_CONTROL,
- DSC_CLOCK_EN, 1);
-
- REG_UPDATE_2(DSCRM_DSC_FORWARD_CONFIG,
- DSCRM_DSC_FORWARD_EN, 1,
- DSCRM_DSC_OPP_PIPE_SOURCE, opp_pipe);
-}
-
-
-static void dsc2_disable(struct display_stream_compressor *dsc)
-{
- struct dcn20_dsc *dsc20 = TO_DCN20_DSC(dsc);
- int dsc_clock_en;
- int dsc_fw_config;
- int enabled_opp_pipe;
-
- DC_LOG_DSC("disable DSC %d", dsc->inst);
-
- REG_GET(DSC_TOP_CONTROL, DSC_CLOCK_EN, &dsc_clock_en);
- REG_GET_2(DSCRM_DSC_FORWARD_CONFIG, DSCRM_DSC_FORWARD_EN, &dsc_fw_config, DSCRM_DSC_OPP_PIPE_SOURCE, &enabled_opp_pipe);
- if (!dsc_clock_en || !dsc_fw_config) {
- DC_LOG_DSC("ERROR: DSC %d at opp pipe %d already disabled!", dsc->inst, enabled_opp_pipe);
- ASSERT(0);
- }
-
- REG_UPDATE(DSCRM_DSC_FORWARD_CONFIG,
- DSCRM_DSC_FORWARD_EN, 0);
-
- REG_UPDATE(DSC_TOP_CONTROL,
- DSC_CLOCK_EN, 0);
-}
-
-static void dsc2_disconnect(struct display_stream_compressor *dsc)
-{
- struct dcn20_dsc *dsc20 = TO_DCN20_DSC(dsc);
-
- DC_LOG_DSC("disconnect DSC %d", dsc->inst);
-
- REG_UPDATE(DSCRM_DSC_FORWARD_CONFIG,
- DSCRM_DSC_FORWARD_EN, 0);
-}
-
-/* This module's internal functions */
-void dsc_log_pps(struct display_stream_compressor *dsc, struct drm_dsc_config *pps)
-{
- int i;
- int bits_per_pixel = pps->bits_per_pixel;
-
- DC_LOG_DSC("\tdsc_version_major %d", pps->dsc_version_major);
- DC_LOG_DSC("\tdsc_version_minor %d", pps->dsc_version_minor);
- DC_LOG_DSC("\tbits_per_component %d", pps->bits_per_component);
- DC_LOG_DSC("\tline_buf_depth %d", pps->line_buf_depth);
- DC_LOG_DSC("\tblock_pred_enable %d", pps->block_pred_enable);
- DC_LOG_DSC("\tconvert_rgb %d", pps->convert_rgb);
- DC_LOG_DSC("\tsimple_422 %d", pps->simple_422);
- DC_LOG_DSC("\tvbr_enable %d", pps->vbr_enable);
- DC_LOG_DSC("\tbits_per_pixel %d (%d.%04d)", bits_per_pixel, bits_per_pixel / 16, ((bits_per_pixel % 16) * 10000) / 16);
- DC_LOG_DSC("\tpic_height %d", pps->pic_height);
- DC_LOG_DSC("\tpic_width %d", pps->pic_width);
- DC_LOG_DSC("\tslice_height %d", pps->slice_height);
- DC_LOG_DSC("\tslice_width %d", pps->slice_width);
- DC_LOG_DSC("\tslice_chunk_size %d", pps->slice_chunk_size);
- DC_LOG_DSC("\tinitial_xmit_delay %d", pps->initial_xmit_delay);
- DC_LOG_DSC("\tinitial_dec_delay %d", pps->initial_dec_delay);
- DC_LOG_DSC("\tinitial_scale_value %d", pps->initial_scale_value);
- DC_LOG_DSC("\tscale_increment_interval %d", pps->scale_increment_interval);
- DC_LOG_DSC("\tscale_decrement_interval %d", pps->scale_decrement_interval);
- DC_LOG_DSC("\tfirst_line_bpg_offset %d", pps->first_line_bpg_offset);
- DC_LOG_DSC("\tnfl_bpg_offset %d", pps->nfl_bpg_offset);
- DC_LOG_DSC("\tslice_bpg_offset %d", pps->slice_bpg_offset);
- DC_LOG_DSC("\tinitial_offset %d", pps->initial_offset);
- DC_LOG_DSC("\tfinal_offset %d", pps->final_offset);
- DC_LOG_DSC("\tflatness_min_qp %d", pps->flatness_min_qp);
- DC_LOG_DSC("\tflatness_max_qp %d", pps->flatness_max_qp);
- /* DC_LOG_DSC("\trc_parameter_set %d", pps->rc_parameter_set); */
- DC_LOG_DSC("\tnative_420 %d", pps->native_420);
- DC_LOG_DSC("\tnative_422 %d", pps->native_422);
- DC_LOG_DSC("\tsecond_line_bpg_offset %d", pps->second_line_bpg_offset);
- DC_LOG_DSC("\tnsl_bpg_offset %d", pps->nsl_bpg_offset);
- DC_LOG_DSC("\tsecond_line_offset_adj %d", pps->second_line_offset_adj);
- DC_LOG_DSC("\trc_model_size %d", pps->rc_model_size);
- DC_LOG_DSC("\trc_edge_factor %d", pps->rc_edge_factor);
- DC_LOG_DSC("\trc_quant_incr_limit0 %d", pps->rc_quant_incr_limit0);
- DC_LOG_DSC("\trc_quant_incr_limit1 %d", pps->rc_quant_incr_limit1);
- DC_LOG_DSC("\trc_tgt_offset_high %d", pps->rc_tgt_offset_high);
- DC_LOG_DSC("\trc_tgt_offset_low %d", pps->rc_tgt_offset_low);
-
- for (i = 0; i < NUM_BUF_RANGES - 1; i++)
- DC_LOG_DSC("\trc_buf_thresh[%d] %d", i, pps->rc_buf_thresh[i]);
-
- for (i = 0; i < NUM_BUF_RANGES; i++) {
- DC_LOG_DSC("\trc_range_parameters[%d].range_min_qp %d", i, pps->rc_range_params[i].range_min_qp);
- DC_LOG_DSC("\trc_range_parameters[%d].range_max_qp %d", i, pps->rc_range_params[i].range_max_qp);
- DC_LOG_DSC("\trc_range_parameters[%d].range_bpg_offset %d", i, pps->rc_range_params[i].range_bpg_offset);
- }
-}
-
-void dsc_override_rc_params(struct rc_params *rc, const struct dc_dsc_rc_params_override *override)
-{
- uint8_t i;
-
- rc->rc_model_size = override->rc_model_size;
- for (i = 0; i < DC_DSC_RC_BUF_THRESH_SIZE; i++)
- rc->rc_buf_thresh[i] = override->rc_buf_thresh[i];
- for (i = 0; i < DC_DSC_QP_SET_SIZE; i++) {
- rc->qp_min[i] = override->rc_minqp[i];
- rc->qp_max[i] = override->rc_maxqp[i];
- rc->ofs[i] = override->rc_offset[i];
- }
-
- rc->rc_tgt_offset_hi = override->rc_tgt_offset_hi;
- rc->rc_tgt_offset_lo = override->rc_tgt_offset_lo;
- rc->rc_edge_factor = override->rc_edge_factor;
- rc->rc_quant_incr_limit0 = override->rc_quant_incr_limit0;
- rc->rc_quant_incr_limit1 = override->rc_quant_incr_limit1;
-
- rc->initial_fullness_offset = override->initial_fullness_offset;
- rc->initial_xmit_delay = override->initial_delay;
-
- rc->flatness_min_qp = override->flatness_min_qp;
- rc->flatness_max_qp = override->flatness_max_qp;
- rc->flatness_det_thresh = override->flatness_det_thresh;
-}
-
-bool dsc_prepare_config(const struct dsc_config *dsc_cfg, struct dsc_reg_values *dsc_reg_vals,
- struct dsc_optc_config *dsc_optc_cfg)
-{
- struct dsc_parameters dsc_params;
- struct rc_params rc;
-
- /* Validate input parameters */
- ASSERT(dsc_cfg->dc_dsc_cfg.num_slices_h);
- ASSERT(dsc_cfg->dc_dsc_cfg.num_slices_v);
- ASSERT(dsc_cfg->dc_dsc_cfg.version_minor == 1 || dsc_cfg->dc_dsc_cfg.version_minor == 2);
- ASSERT(dsc_cfg->pic_width);
- ASSERT(dsc_cfg->pic_height);
- ASSERT((dsc_cfg->dc_dsc_cfg.version_minor == 1 &&
- (8 <= dsc_cfg->dc_dsc_cfg.linebuf_depth && dsc_cfg->dc_dsc_cfg.linebuf_depth <= 13)) ||
- (dsc_cfg->dc_dsc_cfg.version_minor == 2 &&
- ((8 <= dsc_cfg->dc_dsc_cfg.linebuf_depth && dsc_cfg->dc_dsc_cfg.linebuf_depth <= 15) ||
- dsc_cfg->dc_dsc_cfg.linebuf_depth == 0)));
- ASSERT(96 <= dsc_cfg->dc_dsc_cfg.bits_per_pixel && dsc_cfg->dc_dsc_cfg.bits_per_pixel <= 0x3ff); // 6.0 <= bits_per_pixel <= 63.9375
-
- if (!dsc_cfg->dc_dsc_cfg.num_slices_v || !dsc_cfg->dc_dsc_cfg.num_slices_h ||
- !(dsc_cfg->dc_dsc_cfg.version_minor == 1 || dsc_cfg->dc_dsc_cfg.version_minor == 2) ||
- !dsc_cfg->pic_width || !dsc_cfg->pic_height ||
- !((dsc_cfg->dc_dsc_cfg.version_minor == 1 && // v1.1 line buffer depth range:
- 8 <= dsc_cfg->dc_dsc_cfg.linebuf_depth && dsc_cfg->dc_dsc_cfg.linebuf_depth <= 13) ||
- (dsc_cfg->dc_dsc_cfg.version_minor == 2 && // v1.2 line buffer depth range:
- ((8 <= dsc_cfg->dc_dsc_cfg.linebuf_depth && dsc_cfg->dc_dsc_cfg.linebuf_depth <= 15) ||
- dsc_cfg->dc_dsc_cfg.linebuf_depth == 0))) ||
- !(96 <= dsc_cfg->dc_dsc_cfg.bits_per_pixel && dsc_cfg->dc_dsc_cfg.bits_per_pixel <= 0x3ff)) {
- dm_output_to_console("%s: Invalid parameters\n", __func__);
- return false;
- }
-
- dsc_init_reg_values(dsc_reg_vals);
-
- /* Copy input config */
- dsc_reg_vals->pixel_format = dsc_dc_pixel_encoding_to_dsc_pixel_format(dsc_cfg->pixel_encoding, dsc_cfg->dc_dsc_cfg.ycbcr422_simple);
- dsc_reg_vals->num_slices_h = dsc_cfg->dc_dsc_cfg.num_slices_h;
- dsc_reg_vals->num_slices_v = dsc_cfg->dc_dsc_cfg.num_slices_v;
- dsc_reg_vals->pps.dsc_version_minor = dsc_cfg->dc_dsc_cfg.version_minor;
- dsc_reg_vals->pps.pic_width = dsc_cfg->pic_width;
- dsc_reg_vals->pps.pic_height = dsc_cfg->pic_height;
- dsc_reg_vals->pps.bits_per_component = dsc_dc_color_depth_to_dsc_bits_per_comp(dsc_cfg->color_depth);
- dsc_reg_vals->pps.block_pred_enable = dsc_cfg->dc_dsc_cfg.block_pred_enable;
- dsc_reg_vals->pps.line_buf_depth = dsc_cfg->dc_dsc_cfg.linebuf_depth;
- dsc_reg_vals->alternate_ich_encoding_en = dsc_reg_vals->pps.dsc_version_minor == 1 ? 0 : 1;
- dsc_reg_vals->ich_reset_at_eol = (dsc_cfg->is_odm || dsc_reg_vals->num_slices_h > 1) ? 0xF : 0;
-
- // TODO: in addition to validating slice height (pic height must be divisible by slice height),
- // see what happens when the same condition doesn't apply for slice_width/pic_width.
- dsc_reg_vals->pps.slice_width = dsc_cfg->pic_width / dsc_cfg->dc_dsc_cfg.num_slices_h;
- dsc_reg_vals->pps.slice_height = dsc_cfg->pic_height / dsc_cfg->dc_dsc_cfg.num_slices_v;
-
- ASSERT(dsc_reg_vals->pps.slice_height * dsc_cfg->dc_dsc_cfg.num_slices_v == dsc_cfg->pic_height);
- if (!(dsc_reg_vals->pps.slice_height * dsc_cfg->dc_dsc_cfg.num_slices_v == dsc_cfg->pic_height)) {
- dm_output_to_console("%s: pix height %d not divisible by num_slices_v %d\n\n", __func__, dsc_cfg->pic_height, dsc_cfg->dc_dsc_cfg.num_slices_v);
- return false;
- }
-
- dsc_reg_vals->bpp_x32 = dsc_cfg->dc_dsc_cfg.bits_per_pixel << 1;
- if (dsc_reg_vals->pixel_format == DSC_PIXFMT_NATIVE_YCBCR420 || dsc_reg_vals->pixel_format == DSC_PIXFMT_NATIVE_YCBCR422)
- dsc_reg_vals->pps.bits_per_pixel = dsc_reg_vals->bpp_x32;
- else
- dsc_reg_vals->pps.bits_per_pixel = dsc_reg_vals->bpp_x32 >> 1;
-
- dsc_reg_vals->pps.convert_rgb = dsc_reg_vals->pixel_format == DSC_PIXFMT_RGB ? 1 : 0;
- dsc_reg_vals->pps.native_422 = (dsc_reg_vals->pixel_format == DSC_PIXFMT_NATIVE_YCBCR422);
- dsc_reg_vals->pps.native_420 = (dsc_reg_vals->pixel_format == DSC_PIXFMT_NATIVE_YCBCR420);
- dsc_reg_vals->pps.simple_422 = (dsc_reg_vals->pixel_format == DSC_PIXFMT_SIMPLE_YCBCR422);
-
- calc_rc_params(&rc, &dsc_reg_vals->pps);
-
- if (dsc_cfg->dc_dsc_cfg.rc_params_ovrd)
- dsc_override_rc_params(&rc, dsc_cfg->dc_dsc_cfg.rc_params_ovrd);
-
- if (dscc_compute_dsc_parameters(&dsc_reg_vals->pps, &rc, &dsc_params)) {
- dm_output_to_console("%s: DSC config failed\n", __func__);
- return false;
- }
-
- dsc_update_from_dsc_parameters(dsc_reg_vals, &dsc_params);
-
- dsc_optc_cfg->bytes_per_pixel = dsc_params.bytes_per_pixel;
- dsc_optc_cfg->slice_width = dsc_reg_vals->pps.slice_width;
- dsc_optc_cfg->is_pixel_format_444 = dsc_reg_vals->pixel_format == DSC_PIXFMT_RGB ||
- dsc_reg_vals->pixel_format == DSC_PIXFMT_YCBCR444 ||
- dsc_reg_vals->pixel_format == DSC_PIXFMT_SIMPLE_YCBCR422;
-
- return true;
-}
-
-
-enum dsc_pixel_format dsc_dc_pixel_encoding_to_dsc_pixel_format(enum dc_pixel_encoding dc_pix_enc, bool is_ycbcr422_simple)
-{
- enum dsc_pixel_format dsc_pix_fmt = DSC_PIXFMT_UNKNOWN;
-
- /* NOTE: We don't support DSC_PIXFMT_SIMPLE_YCBCR422 */
-
- switch (dc_pix_enc) {
- case PIXEL_ENCODING_RGB:
- dsc_pix_fmt = DSC_PIXFMT_RGB;
- break;
- case PIXEL_ENCODING_YCBCR422:
- if (is_ycbcr422_simple)
- dsc_pix_fmt = DSC_PIXFMT_SIMPLE_YCBCR422;
- else
- dsc_pix_fmt = DSC_PIXFMT_NATIVE_YCBCR422;
- break;
- case PIXEL_ENCODING_YCBCR444:
- dsc_pix_fmt = DSC_PIXFMT_YCBCR444;
- break;
- case PIXEL_ENCODING_YCBCR420:
- dsc_pix_fmt = DSC_PIXFMT_NATIVE_YCBCR420;
- break;
- default:
- dsc_pix_fmt = DSC_PIXFMT_UNKNOWN;
- break;
- }
-
- ASSERT(dsc_pix_fmt != DSC_PIXFMT_UNKNOWN);
- return dsc_pix_fmt;
-}
-
-
-enum dsc_bits_per_comp dsc_dc_color_depth_to_dsc_bits_per_comp(enum dc_color_depth dc_color_depth)
-{
- enum dsc_bits_per_comp bpc = DSC_BPC_UNKNOWN;
-
- switch (dc_color_depth) {
- case COLOR_DEPTH_888:
- bpc = DSC_BPC_8;
- break;
- case COLOR_DEPTH_101010:
- bpc = DSC_BPC_10;
- break;
- case COLOR_DEPTH_121212:
- bpc = DSC_BPC_12;
- break;
- default:
- bpc = DSC_BPC_UNKNOWN;
- break;
- }
-
- return bpc;
-}
-
-
-void dsc_init_reg_values(struct dsc_reg_values *reg_vals)
-{
- int i;
-
- memset(reg_vals, 0, sizeof(struct dsc_reg_values));
-
- /* Non-PPS values */
- reg_vals->dsc_clock_enable = 1;
- reg_vals->dsc_clock_gating_disable = 0;
- reg_vals->underflow_recovery_en = 0;
- reg_vals->underflow_occurred_int_en = 0;
- reg_vals->underflow_occurred_status = 0;
- reg_vals->ich_reset_at_eol = 0;
- reg_vals->alternate_ich_encoding_en = 0;
- reg_vals->rc_buffer_model_size = 0;
- /*reg_vals->disable_ich = 0;*/
- reg_vals->dsc_dbg_en = 0;
-
- for (i = 0; i < 4; i++)
- reg_vals->rc_buffer_model_overflow_int_en[i] = 0;
-
- /* PPS values */
- reg_vals->pps.dsc_version_minor = 2;
- reg_vals->pps.dsc_version_major = 1;
- reg_vals->pps.line_buf_depth = 9;
- reg_vals->pps.bits_per_component = 8;
- reg_vals->pps.block_pred_enable = 1;
- reg_vals->pps.slice_chunk_size = 0;
- reg_vals->pps.pic_width = 0;
- reg_vals->pps.pic_height = 0;
- reg_vals->pps.slice_width = 0;
- reg_vals->pps.slice_height = 0;
- reg_vals->pps.initial_xmit_delay = 170;
- reg_vals->pps.initial_dec_delay = 0;
- reg_vals->pps.initial_scale_value = 0;
- reg_vals->pps.scale_increment_interval = 0;
- reg_vals->pps.scale_decrement_interval = 0;
- reg_vals->pps.nfl_bpg_offset = 0;
- reg_vals->pps.slice_bpg_offset = 0;
- reg_vals->pps.nsl_bpg_offset = 0;
- reg_vals->pps.initial_offset = 6144;
- reg_vals->pps.final_offset = 0;
- reg_vals->pps.flatness_min_qp = 3;
- reg_vals->pps.flatness_max_qp = 12;
- reg_vals->pps.rc_model_size = 8192;
- reg_vals->pps.rc_edge_factor = 6;
- reg_vals->pps.rc_quant_incr_limit0 = 11;
- reg_vals->pps.rc_quant_incr_limit1 = 11;
- reg_vals->pps.rc_tgt_offset_low = 3;
- reg_vals->pps.rc_tgt_offset_high = 3;
-}
-
-/* Updates dsc_reg_values::reg_vals::xxx fields based on the values from computed params.
- * This is required because dscc_compute_dsc_parameters returns a modified PPS, which in turn
- * affects non-PPS register values.
- */
-void dsc_update_from_dsc_parameters(struct dsc_reg_values *reg_vals, const struct dsc_parameters *dsc_params)
-{
- int i;
-
- reg_vals->pps = dsc_params->pps;
-
- // pps_computed will have the "expanded" values; need to shift them to make them fit for regs.
- for (i = 0; i < NUM_BUF_RANGES - 1; i++)
- reg_vals->pps.rc_buf_thresh[i] = reg_vals->pps.rc_buf_thresh[i] >> 6;
-
- reg_vals->rc_buffer_model_size = dsc_params->rc_buffer_model_size;
-}
-
-static void dsc_write_to_registers(struct display_stream_compressor *dsc, const struct dsc_reg_values *reg_vals)
-{
- uint32_t temp_int;
- struct dcn20_dsc *dsc20 = TO_DCN20_DSC(dsc);
-
- REG_SET(DSC_DEBUG_CONTROL, 0,
- DSC_DBG_EN, reg_vals->dsc_dbg_en);
-
- // dsccif registers
- REG_SET_5(DSCCIF_CONFIG0, 0,
- INPUT_INTERFACE_UNDERFLOW_RECOVERY_EN, reg_vals->underflow_recovery_en,
- INPUT_INTERFACE_UNDERFLOW_OCCURRED_INT_EN, reg_vals->underflow_occurred_int_en,
- INPUT_INTERFACE_UNDERFLOW_OCCURRED_STATUS, reg_vals->underflow_occurred_status,
- INPUT_PIXEL_FORMAT, reg_vals->pixel_format,
- DSCCIF_CONFIG0__BITS_PER_COMPONENT, reg_vals->pps.bits_per_component);
-
- REG_SET_2(DSCCIF_CONFIG1, 0,
- PIC_WIDTH, reg_vals->pps.pic_width,
- PIC_HEIGHT, reg_vals->pps.pic_height);
-
- // dscc registers
- if (dsc20->dsc_mask->ICH_RESET_AT_END_OF_LINE == 0) {
- REG_SET_3(DSCC_CONFIG0, 0,
- NUMBER_OF_SLICES_PER_LINE, reg_vals->num_slices_h - 1,
- ALTERNATE_ICH_ENCODING_EN, reg_vals->alternate_ich_encoding_en,
- NUMBER_OF_SLICES_IN_VERTICAL_DIRECTION, reg_vals->num_slices_v - 1);
- } else {
- REG_SET_4(DSCC_CONFIG0, 0, ICH_RESET_AT_END_OF_LINE,
- reg_vals->ich_reset_at_eol, NUMBER_OF_SLICES_PER_LINE,
- reg_vals->num_slices_h - 1, ALTERNATE_ICH_ENCODING_EN,
- reg_vals->alternate_ich_encoding_en, NUMBER_OF_SLICES_IN_VERTICAL_DIRECTION,
- reg_vals->num_slices_v - 1);
- }
-
- REG_SET(DSCC_CONFIG1, 0,
- DSCC_RATE_CONTROL_BUFFER_MODEL_SIZE, reg_vals->rc_buffer_model_size);
- /*REG_SET_2(DSCC_CONFIG1, 0,
- DSCC_RATE_CONTROL_BUFFER_MODEL_SIZE, reg_vals->rc_buffer_model_size,
- DSCC_DISABLE_ICH, reg_vals->disable_ich);*/
-
- REG_SET_4(DSCC_INTERRUPT_CONTROL_STATUS, 0,
- DSCC_RATE_CONTROL_BUFFER_MODEL0_OVERFLOW_OCCURRED_INT_EN, reg_vals->rc_buffer_model_overflow_int_en[0],
- DSCC_RATE_CONTROL_BUFFER_MODEL1_OVERFLOW_OCCURRED_INT_EN, reg_vals->rc_buffer_model_overflow_int_en[1],
- DSCC_RATE_CONTROL_BUFFER_MODEL2_OVERFLOW_OCCURRED_INT_EN, reg_vals->rc_buffer_model_overflow_int_en[2],
- DSCC_RATE_CONTROL_BUFFER_MODEL3_OVERFLOW_OCCURRED_INT_EN, reg_vals->rc_buffer_model_overflow_int_en[3]);
-
- REG_SET_3(DSCC_PPS_CONFIG0, 0,
- DSC_VERSION_MINOR, reg_vals->pps.dsc_version_minor,
- LINEBUF_DEPTH, reg_vals->pps.line_buf_depth,
- DSCC_PPS_CONFIG0__BITS_PER_COMPONENT, reg_vals->pps.bits_per_component);
-
- if (reg_vals->pixel_format == DSC_PIXFMT_NATIVE_YCBCR420 || reg_vals->pixel_format == DSC_PIXFMT_NATIVE_YCBCR422)
- temp_int = reg_vals->bpp_x32;
- else
- temp_int = reg_vals->bpp_x32 >> 1;
-
- REG_SET_7(DSCC_PPS_CONFIG1, 0,
- BITS_PER_PIXEL, temp_int,
- SIMPLE_422, reg_vals->pixel_format == DSC_PIXFMT_SIMPLE_YCBCR422,
- CONVERT_RGB, reg_vals->pixel_format == DSC_PIXFMT_RGB,
- BLOCK_PRED_ENABLE, reg_vals->pps.block_pred_enable,
- NATIVE_422, reg_vals->pixel_format == DSC_PIXFMT_NATIVE_YCBCR422,
- NATIVE_420, reg_vals->pixel_format == DSC_PIXFMT_NATIVE_YCBCR420,
- CHUNK_SIZE, reg_vals->pps.slice_chunk_size);
-
- REG_SET_2(DSCC_PPS_CONFIG2, 0,
- PIC_WIDTH, reg_vals->pps.pic_width,
- PIC_HEIGHT, reg_vals->pps.pic_height);
-
- REG_SET_2(DSCC_PPS_CONFIG3, 0,
- SLICE_WIDTH, reg_vals->pps.slice_width,
- SLICE_HEIGHT, reg_vals->pps.slice_height);
-
- REG_SET(DSCC_PPS_CONFIG4, 0,
- INITIAL_XMIT_DELAY, reg_vals->pps.initial_xmit_delay);
-
- REG_SET_2(DSCC_PPS_CONFIG5, 0,
- INITIAL_SCALE_VALUE, reg_vals->pps.initial_scale_value,
- SCALE_INCREMENT_INTERVAL, reg_vals->pps.scale_increment_interval);
-
- REG_SET_3(DSCC_PPS_CONFIG6, 0,
- SCALE_DECREMENT_INTERVAL, reg_vals->pps.scale_decrement_interval,
- FIRST_LINE_BPG_OFFSET, reg_vals->pps.first_line_bpg_offset,
- SECOND_LINE_BPG_OFFSET, reg_vals->pps.second_line_bpg_offset);
-
- REG_SET_2(DSCC_PPS_CONFIG7, 0,
- NFL_BPG_OFFSET, reg_vals->pps.nfl_bpg_offset,
- SLICE_BPG_OFFSET, reg_vals->pps.slice_bpg_offset);
-
- REG_SET_2(DSCC_PPS_CONFIG8, 0,
- NSL_BPG_OFFSET, reg_vals->pps.nsl_bpg_offset,
- SECOND_LINE_OFFSET_ADJ, reg_vals->pps.second_line_offset_adj);
-
- REG_SET_2(DSCC_PPS_CONFIG9, 0,
- INITIAL_OFFSET, reg_vals->pps.initial_offset,
- FINAL_OFFSET, reg_vals->pps.final_offset);
-
- REG_SET_3(DSCC_PPS_CONFIG10, 0,
- FLATNESS_MIN_QP, reg_vals->pps.flatness_min_qp,
- FLATNESS_MAX_QP, reg_vals->pps.flatness_max_qp,
- RC_MODEL_SIZE, reg_vals->pps.rc_model_size);
-
- REG_SET_5(DSCC_PPS_CONFIG11, 0,
- RC_EDGE_FACTOR, reg_vals->pps.rc_edge_factor,
- RC_QUANT_INCR_LIMIT0, reg_vals->pps.rc_quant_incr_limit0,
- RC_QUANT_INCR_LIMIT1, reg_vals->pps.rc_quant_incr_limit1,
- RC_TGT_OFFSET_LO, reg_vals->pps.rc_tgt_offset_low,
- RC_TGT_OFFSET_HI, reg_vals->pps.rc_tgt_offset_high);
-
- REG_SET_4(DSCC_PPS_CONFIG12, 0,
- RC_BUF_THRESH0, reg_vals->pps.rc_buf_thresh[0],
- RC_BUF_THRESH1, reg_vals->pps.rc_buf_thresh[1],
- RC_BUF_THRESH2, reg_vals->pps.rc_buf_thresh[2],
- RC_BUF_THRESH3, reg_vals->pps.rc_buf_thresh[3]);
-
- REG_SET_4(DSCC_PPS_CONFIG13, 0,
- RC_BUF_THRESH4, reg_vals->pps.rc_buf_thresh[4],
- RC_BUF_THRESH5, reg_vals->pps.rc_buf_thresh[5],
- RC_BUF_THRESH6, reg_vals->pps.rc_buf_thresh[6],
- RC_BUF_THRESH7, reg_vals->pps.rc_buf_thresh[7]);
-
- REG_SET_4(DSCC_PPS_CONFIG14, 0,
- RC_BUF_THRESH8, reg_vals->pps.rc_buf_thresh[8],
- RC_BUF_THRESH9, reg_vals->pps.rc_buf_thresh[9],
- RC_BUF_THRESH10, reg_vals->pps.rc_buf_thresh[10],
- RC_BUF_THRESH11, reg_vals->pps.rc_buf_thresh[11]);
-
- REG_SET_5(DSCC_PPS_CONFIG15, 0,
- RC_BUF_THRESH12, reg_vals->pps.rc_buf_thresh[12],
- RC_BUF_THRESH13, reg_vals->pps.rc_buf_thresh[13],
- RANGE_MIN_QP0, reg_vals->pps.rc_range_params[0].range_min_qp,
- RANGE_MAX_QP0, reg_vals->pps.rc_range_params[0].range_max_qp,
- RANGE_BPG_OFFSET0, reg_vals->pps.rc_range_params[0].range_bpg_offset);
-
- REG_SET_6(DSCC_PPS_CONFIG16, 0,
- RANGE_MIN_QP1, reg_vals->pps.rc_range_params[1].range_min_qp,
- RANGE_MAX_QP1, reg_vals->pps.rc_range_params[1].range_max_qp,
- RANGE_BPG_OFFSET1, reg_vals->pps.rc_range_params[1].range_bpg_offset,
- RANGE_MIN_QP2, reg_vals->pps.rc_range_params[2].range_min_qp,
- RANGE_MAX_QP2, reg_vals->pps.rc_range_params[2].range_max_qp,
- RANGE_BPG_OFFSET2, reg_vals->pps.rc_range_params[2].range_bpg_offset);
-
- REG_SET_6(DSCC_PPS_CONFIG17, 0,
- RANGE_MIN_QP3, reg_vals->pps.rc_range_params[3].range_min_qp,
- RANGE_MAX_QP3, reg_vals->pps.rc_range_params[3].range_max_qp,
- RANGE_BPG_OFFSET3, reg_vals->pps.rc_range_params[3].range_bpg_offset,
- RANGE_MIN_QP4, reg_vals->pps.rc_range_params[4].range_min_qp,
- RANGE_MAX_QP4, reg_vals->pps.rc_range_params[4].range_max_qp,
- RANGE_BPG_OFFSET4, reg_vals->pps.rc_range_params[4].range_bpg_offset);
-
- REG_SET_6(DSCC_PPS_CONFIG18, 0,
- RANGE_MIN_QP5, reg_vals->pps.rc_range_params[5].range_min_qp,
- RANGE_MAX_QP5, reg_vals->pps.rc_range_params[5].range_max_qp,
- RANGE_BPG_OFFSET5, reg_vals->pps.rc_range_params[5].range_bpg_offset,
- RANGE_MIN_QP6, reg_vals->pps.rc_range_params[6].range_min_qp,
- RANGE_MAX_QP6, reg_vals->pps.rc_range_params[6].range_max_qp,
- RANGE_BPG_OFFSET6, reg_vals->pps.rc_range_params[6].range_bpg_offset);
-
- REG_SET_6(DSCC_PPS_CONFIG19, 0,
- RANGE_MIN_QP7, reg_vals->pps.rc_range_params[7].range_min_qp,
- RANGE_MAX_QP7, reg_vals->pps.rc_range_params[7].range_max_qp,
- RANGE_BPG_OFFSET7, reg_vals->pps.rc_range_params[7].range_bpg_offset,
- RANGE_MIN_QP8, reg_vals->pps.rc_range_params[8].range_min_qp,
- RANGE_MAX_QP8, reg_vals->pps.rc_range_params[8].range_max_qp,
- RANGE_BPG_OFFSET8, reg_vals->pps.rc_range_params[8].range_bpg_offset);
-
- REG_SET_6(DSCC_PPS_CONFIG20, 0,
- RANGE_MIN_QP9, reg_vals->pps.rc_range_params[9].range_min_qp,
- RANGE_MAX_QP9, reg_vals->pps.rc_range_params[9].range_max_qp,
- RANGE_BPG_OFFSET9, reg_vals->pps.rc_range_params[9].range_bpg_offset,
- RANGE_MIN_QP10, reg_vals->pps.rc_range_params[10].range_min_qp,
- RANGE_MAX_QP10, reg_vals->pps.rc_range_params[10].range_max_qp,
- RANGE_BPG_OFFSET10, reg_vals->pps.rc_range_params[10].range_bpg_offset);
-
- REG_SET_6(DSCC_PPS_CONFIG21, 0,
- RANGE_MIN_QP11, reg_vals->pps.rc_range_params[11].range_min_qp,
- RANGE_MAX_QP11, reg_vals->pps.rc_range_params[11].range_max_qp,
- RANGE_BPG_OFFSET11, reg_vals->pps.rc_range_params[11].range_bpg_offset,
- RANGE_MIN_QP12, reg_vals->pps.rc_range_params[12].range_min_qp,
- RANGE_MAX_QP12, reg_vals->pps.rc_range_params[12].range_max_qp,
- RANGE_BPG_OFFSET12, reg_vals->pps.rc_range_params[12].range_bpg_offset);
-
- REG_SET_6(DSCC_PPS_CONFIG22, 0,
- RANGE_MIN_QP13, reg_vals->pps.rc_range_params[13].range_min_qp,
- RANGE_MAX_QP13, reg_vals->pps.rc_range_params[13].range_max_qp,
- RANGE_BPG_OFFSET13, reg_vals->pps.rc_range_params[13].range_bpg_offset,
- RANGE_MIN_QP14, reg_vals->pps.rc_range_params[14].range_min_qp,
- RANGE_MAX_QP14, reg_vals->pps.rc_range_params[14].range_max_qp,
- RANGE_BPG_OFFSET14, reg_vals->pps.rc_range_params[14].range_bpg_offset);
-
-}
-
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.h b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.h
deleted file mode 100644
index ba869387c3..0000000000
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.h
+++ /dev/null
@@ -1,589 +0,0 @@
-/* Copyright 2017 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: AMD
- *
- */
-#ifndef __DCN20_DSC_H__
-#define __DCN20_DSC_H__
-
-#include "dsc.h"
-#include "dsc/dscc_types.h"
-#include <drm/display/drm_dsc.h>
-
-#define TO_DCN20_DSC(dsc)\
- container_of(dsc, struct dcn20_dsc, base)
-
-#define DSC_REG_LIST_DCN20(id) \
- SRI(DSC_TOP_CONTROL, DSC_TOP, id),\
- SRI(DSC_DEBUG_CONTROL, DSC_TOP, id),\
- SRI(DSCC_CONFIG0, DSCC, id),\
- SRI(DSCC_CONFIG1, DSCC, id),\
- SRI(DSCC_STATUS, DSCC, id),\
- SRI(DSCC_INTERRUPT_CONTROL_STATUS, DSCC, id),\
- SRI(DSCC_PPS_CONFIG0, DSCC, id),\
- SRI(DSCC_PPS_CONFIG1, DSCC, id),\
- SRI(DSCC_PPS_CONFIG2, DSCC, id),\
- SRI(DSCC_PPS_CONFIG3, DSCC, id),\
- SRI(DSCC_PPS_CONFIG4, DSCC, id),\
- SRI(DSCC_PPS_CONFIG5, DSCC, id),\
- SRI(DSCC_PPS_CONFIG6, DSCC, id),\
- SRI(DSCC_PPS_CONFIG7, DSCC, id),\
- SRI(DSCC_PPS_CONFIG8, DSCC, id),\
- SRI(DSCC_PPS_CONFIG9, DSCC, id),\
- SRI(DSCC_PPS_CONFIG10, DSCC, id),\
- SRI(DSCC_PPS_CONFIG11, DSCC, id),\
- SRI(DSCC_PPS_CONFIG12, DSCC, id),\
- SRI(DSCC_PPS_CONFIG13, DSCC, id),\
- SRI(DSCC_PPS_CONFIG14, DSCC, id),\
- SRI(DSCC_PPS_CONFIG15, DSCC, id),\
- SRI(DSCC_PPS_CONFIG16, DSCC, id),\
- SRI(DSCC_PPS_CONFIG17, DSCC, id),\
- SRI(DSCC_PPS_CONFIG18, DSCC, id),\
- SRI(DSCC_PPS_CONFIG19, DSCC, id),\
- SRI(DSCC_PPS_CONFIG20, DSCC, id),\
- SRI(DSCC_PPS_CONFIG21, DSCC, id),\
- SRI(DSCC_PPS_CONFIG22, DSCC, id),\
- SRI(DSCC_MEM_POWER_CONTROL, DSCC, id),\
- SRI(DSCC_R_Y_SQUARED_ERROR_LOWER, DSCC, id),\
- SRI(DSCC_R_Y_SQUARED_ERROR_UPPER, DSCC, id),\
- SRI(DSCC_G_CB_SQUARED_ERROR_LOWER, DSCC, id),\
- SRI(DSCC_G_CB_SQUARED_ERROR_UPPER, DSCC, id),\
- SRI(DSCC_B_CR_SQUARED_ERROR_LOWER, DSCC, id),\
- SRI(DSCC_B_CR_SQUARED_ERROR_UPPER, DSCC, id),\
- SRI(DSCC_MAX_ABS_ERROR0, DSCC, id),\
- SRI(DSCC_MAX_ABS_ERROR1, DSCC, id),\
- SRI(DSCC_RATE_BUFFER0_MAX_FULLNESS_LEVEL, DSCC, id),\
- SRI(DSCC_RATE_BUFFER1_MAX_FULLNESS_LEVEL, DSCC, id),\
- SRI(DSCC_RATE_BUFFER2_MAX_FULLNESS_LEVEL, DSCC, id),\
- SRI(DSCC_RATE_BUFFER3_MAX_FULLNESS_LEVEL, DSCC, id),\
- SRI(DSCC_RATE_CONTROL_BUFFER0_MAX_FULLNESS_LEVEL, DSCC, id),\
- SRI(DSCC_RATE_CONTROL_BUFFER1_MAX_FULLNESS_LEVEL, DSCC, id),\
- SRI(DSCC_RATE_CONTROL_BUFFER2_MAX_FULLNESS_LEVEL, DSCC, id),\
- SRI(DSCC_RATE_CONTROL_BUFFER3_MAX_FULLNESS_LEVEL, DSCC, id),\
- SRI(DSCCIF_CONFIG0, DSCCIF, id),\
- SRI(DSCCIF_CONFIG1, DSCCIF, id),\
- SRI(DSCRM_DSC_FORWARD_CONFIG, DSCRM, id)
-
-
-#define DSC_SF(reg_name, field_name, post_fix)\
- .field_name = reg_name ## __ ## field_name ## post_fix
-
-//Used in resolving the corner case with duplicate field name
-#define DSC2_SF(reg_name, field_name, post_fix)\
- .field_name = reg_name ## _ ## field_name ## post_fix
-
-#define DSC_REG_LIST_SH_MASK_DCN20(mask_sh)\
- DSC_SF(DSC_TOP0_DSC_TOP_CONTROL, DSC_CLOCK_EN, mask_sh), \
- DSC_SF(DSC_TOP0_DSC_TOP_CONTROL, DSC_DISPCLK_R_GATE_DIS, mask_sh), \
- DSC_SF(DSC_TOP0_DSC_TOP_CONTROL, DSC_DSCCLK_R_GATE_DIS, mask_sh), \
- DSC_SF(DSC_TOP0_DSC_DEBUG_CONTROL, DSC_DBG_EN, mask_sh), \
- DSC_SF(DSCC0_DSCC_CONFIG0, ICH_RESET_AT_END_OF_LINE, mask_sh), \
- DSC_SF(DSCC0_DSCC_CONFIG0, NUMBER_OF_SLICES_PER_LINE, mask_sh), \
- DSC_SF(DSCC0_DSCC_CONFIG0, ALTERNATE_ICH_ENCODING_EN, mask_sh), \
- DSC_SF(DSCC0_DSCC_CONFIG0, NUMBER_OF_SLICES_IN_VERTICAL_DIRECTION, mask_sh), \
- DSC_SF(DSCC0_DSCC_CONFIG1, DSCC_RATE_CONTROL_BUFFER_MODEL_SIZE, mask_sh), \
- /*DSC_SF(DSCC0_DSCC_CONFIG1, DSCC_DISABLE_ICH, mask_sh),*/ \
- DSC_SF(DSCC0_DSCC_STATUS, DSCC_DOUBLE_BUFFER_REG_UPDATE_PENDING, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_BUFFER0_OVERFLOW_OCCURRED, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_BUFFER1_OVERFLOW_OCCURRED, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_BUFFER2_OVERFLOW_OCCURRED, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_BUFFER3_OVERFLOW_OCCURRED, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_BUFFER0_UNDERFLOW_OCCURRED, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_BUFFER1_UNDERFLOW_OCCURRED, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_BUFFER2_UNDERFLOW_OCCURRED, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_BUFFER3_UNDERFLOW_OCCURRED, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_CONTROL_BUFFER_MODEL0_OVERFLOW_OCCURRED, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_CONTROL_BUFFER_MODEL1_OVERFLOW_OCCURRED, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_CONTROL_BUFFER_MODEL2_OVERFLOW_OCCURRED, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_CONTROL_BUFFER_MODEL3_OVERFLOW_OCCURRED, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_BUFFER0_OVERFLOW_OCCURRED_INT_EN, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_BUFFER1_OVERFLOW_OCCURRED_INT_EN, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_BUFFER2_OVERFLOW_OCCURRED_INT_EN, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_BUFFER3_OVERFLOW_OCCURRED_INT_EN, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_BUFFER0_UNDERFLOW_OCCURRED_INT_EN, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_BUFFER1_UNDERFLOW_OCCURRED_INT_EN, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_BUFFER2_UNDERFLOW_OCCURRED_INT_EN, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_BUFFER3_UNDERFLOW_OCCURRED_INT_EN, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_CONTROL_BUFFER_MODEL0_OVERFLOW_OCCURRED_INT_EN, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_CONTROL_BUFFER_MODEL1_OVERFLOW_OCCURRED_INT_EN, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_CONTROL_BUFFER_MODEL2_OVERFLOW_OCCURRED_INT_EN, mask_sh), \
- DSC_SF(DSCC0_DSCC_INTERRUPT_CONTROL_STATUS, DSCC_RATE_CONTROL_BUFFER_MODEL3_OVERFLOW_OCCURRED_INT_EN, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG0, DSC_VERSION_MINOR, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG0, DSC_VERSION_MAJOR, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG0, PPS_IDENTIFIER, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG0, LINEBUF_DEPTH, mask_sh), \
- DSC2_SF(DSCC0, DSCC_PPS_CONFIG0__BITS_PER_COMPONENT, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG1, BITS_PER_PIXEL, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG1, VBR_ENABLE, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG1, SIMPLE_422, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG1, CONVERT_RGB, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG1, BLOCK_PRED_ENABLE, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG1, NATIVE_422, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG1, NATIVE_420, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG1, CHUNK_SIZE, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG2, PIC_WIDTH, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG2, PIC_HEIGHT, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG3, SLICE_WIDTH, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG3, SLICE_HEIGHT, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG4, INITIAL_XMIT_DELAY, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG4, INITIAL_DEC_DELAY, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG5, INITIAL_SCALE_VALUE, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG5, SCALE_INCREMENT_INTERVAL, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG6, SCALE_DECREMENT_INTERVAL, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG6, FIRST_LINE_BPG_OFFSET, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG6, SECOND_LINE_BPG_OFFSET, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG7, NFL_BPG_OFFSET, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG7, SLICE_BPG_OFFSET, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG8, NSL_BPG_OFFSET, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG8, SECOND_LINE_OFFSET_ADJ, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG9, INITIAL_OFFSET, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG9, FINAL_OFFSET, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG10, FLATNESS_MIN_QP, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG10, FLATNESS_MAX_QP, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG10, RC_MODEL_SIZE, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG11, RC_EDGE_FACTOR, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG11, RC_QUANT_INCR_LIMIT0, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG11, RC_QUANT_INCR_LIMIT1, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG11, RC_TGT_OFFSET_LO, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG11, RC_TGT_OFFSET_HI, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG12, RC_BUF_THRESH0, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG12, RC_BUF_THRESH1, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG12, RC_BUF_THRESH2, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG12, RC_BUF_THRESH3, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG13, RC_BUF_THRESH4, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG13, RC_BUF_THRESH5, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG13, RC_BUF_THRESH6, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG13, RC_BUF_THRESH7, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG14, RC_BUF_THRESH8, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG14, RC_BUF_THRESH9, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG14, RC_BUF_THRESH10, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG14, RC_BUF_THRESH11, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG15, RC_BUF_THRESH12, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG15, RC_BUF_THRESH13, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG15, RANGE_MIN_QP0, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG15, RANGE_MAX_QP0, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG15, RANGE_BPG_OFFSET0, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG16, RANGE_MIN_QP1, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG16, RANGE_MAX_QP1, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG16, RANGE_BPG_OFFSET1, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG16, RANGE_MIN_QP2, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG16, RANGE_MAX_QP2, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG16, RANGE_BPG_OFFSET2, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG17, RANGE_MIN_QP3, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG17, RANGE_MAX_QP3, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG17, RANGE_BPG_OFFSET3, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG17, RANGE_MIN_QP4, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG17, RANGE_MAX_QP4, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG17, RANGE_BPG_OFFSET4, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG18, RANGE_MIN_QP5, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG18, RANGE_MAX_QP5, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG18, RANGE_BPG_OFFSET5, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG18, RANGE_MIN_QP6, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG18, RANGE_MAX_QP6, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG18, RANGE_BPG_OFFSET6, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG19, RANGE_MIN_QP7, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG19, RANGE_MAX_QP7, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG19, RANGE_BPG_OFFSET7, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG19, RANGE_MIN_QP8, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG19, RANGE_MAX_QP8, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG19, RANGE_BPG_OFFSET8, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG20, RANGE_MIN_QP9, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG20, RANGE_MAX_QP9, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG20, RANGE_BPG_OFFSET9, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG20, RANGE_MIN_QP10, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG20, RANGE_MAX_QP10, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG20, RANGE_BPG_OFFSET10, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG21, RANGE_MIN_QP11, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG21, RANGE_MAX_QP11, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG21, RANGE_BPG_OFFSET11, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG21, RANGE_MIN_QP12, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG21, RANGE_MAX_QP12, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG21, RANGE_BPG_OFFSET12, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG22, RANGE_MIN_QP13, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG22, RANGE_MAX_QP13, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG22, RANGE_BPG_OFFSET13, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG22, RANGE_MIN_QP14, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG22, RANGE_MAX_QP14, mask_sh), \
- DSC_SF(DSCC0_DSCC_PPS_CONFIG22, RANGE_BPG_OFFSET14, mask_sh), \
- DSC_SF(DSCC0_DSCC_MEM_POWER_CONTROL, DSCC_DEFAULT_MEM_LOW_POWER_STATE, mask_sh), \
- DSC_SF(DSCC0_DSCC_MEM_POWER_CONTROL, DSCC_MEM_PWR_FORCE, mask_sh), \
- DSC_SF(DSCC0_DSCC_MEM_POWER_CONTROL, DSCC_MEM_PWR_DIS, mask_sh), \
- DSC_SF(DSCC0_DSCC_MEM_POWER_CONTROL, DSCC_MEM_PWR_STATE, mask_sh), \
- DSC_SF(DSCC0_DSCC_MEM_POWER_CONTROL, DSCC_NATIVE_422_MEM_PWR_FORCE, mask_sh), \
- DSC_SF(DSCC0_DSCC_MEM_POWER_CONTROL, DSCC_NATIVE_422_MEM_PWR_DIS, mask_sh), \
- DSC_SF(DSCC0_DSCC_MEM_POWER_CONTROL, DSCC_NATIVE_422_MEM_PWR_STATE, mask_sh), \
- DSC_SF(DSCC0_DSCC_R_Y_SQUARED_ERROR_LOWER, DSCC_R_Y_SQUARED_ERROR_LOWER, mask_sh), \
- DSC_SF(DSCC0_DSCC_R_Y_SQUARED_ERROR_UPPER, DSCC_R_Y_SQUARED_ERROR_UPPER, mask_sh), \
- DSC_SF(DSCC0_DSCC_G_CB_SQUARED_ERROR_LOWER, DSCC_G_CB_SQUARED_ERROR_LOWER, mask_sh), \
- DSC_SF(DSCC0_DSCC_G_CB_SQUARED_ERROR_UPPER, DSCC_G_CB_SQUARED_ERROR_UPPER, mask_sh), \
- DSC_SF(DSCC0_DSCC_B_CR_SQUARED_ERROR_LOWER, DSCC_B_CR_SQUARED_ERROR_LOWER, mask_sh), \
- DSC_SF(DSCC0_DSCC_B_CR_SQUARED_ERROR_UPPER, DSCC_B_CR_SQUARED_ERROR_UPPER, mask_sh), \
- DSC_SF(DSCC0_DSCC_MAX_ABS_ERROR0, DSCC_R_Y_MAX_ABS_ERROR, mask_sh), \
- DSC_SF(DSCC0_DSCC_MAX_ABS_ERROR0, DSCC_G_CB_MAX_ABS_ERROR, mask_sh), \
- DSC_SF(DSCC0_DSCC_MAX_ABS_ERROR1, DSCC_B_CR_MAX_ABS_ERROR, mask_sh), \
- DSC_SF(DSCC0_DSCC_RATE_BUFFER0_MAX_FULLNESS_LEVEL, DSCC_RATE_BUFFER0_MAX_FULLNESS_LEVEL, mask_sh), \
- DSC_SF(DSCC0_DSCC_RATE_BUFFER1_MAX_FULLNESS_LEVEL, DSCC_RATE_BUFFER1_MAX_FULLNESS_LEVEL, mask_sh), \
- DSC_SF(DSCC0_DSCC_RATE_BUFFER2_MAX_FULLNESS_LEVEL, DSCC_RATE_BUFFER2_MAX_FULLNESS_LEVEL, mask_sh), \
- DSC_SF(DSCC0_DSCC_RATE_BUFFER3_MAX_FULLNESS_LEVEL, DSCC_RATE_BUFFER3_MAX_FULLNESS_LEVEL, mask_sh), \
- DSC_SF(DSCC0_DSCC_RATE_CONTROL_BUFFER0_MAX_FULLNESS_LEVEL, DSCC_RATE_CONTROL_BUFFER0_MAX_FULLNESS_LEVEL, mask_sh), \
- DSC_SF(DSCC0_DSCC_RATE_CONTROL_BUFFER1_MAX_FULLNESS_LEVEL, DSCC_RATE_CONTROL_BUFFER1_MAX_FULLNESS_LEVEL, mask_sh), \
- DSC_SF(DSCC0_DSCC_RATE_CONTROL_BUFFER2_MAX_FULLNESS_LEVEL, DSCC_RATE_CONTROL_BUFFER2_MAX_FULLNESS_LEVEL, mask_sh), \
- DSC_SF(DSCC0_DSCC_RATE_CONTROL_BUFFER3_MAX_FULLNESS_LEVEL, DSCC_RATE_CONTROL_BUFFER3_MAX_FULLNESS_LEVEL, mask_sh), \
- DSC_SF(DSCCIF0_DSCCIF_CONFIG0, INPUT_INTERFACE_UNDERFLOW_RECOVERY_EN, mask_sh), \
- DSC_SF(DSCCIF0_DSCCIF_CONFIG0, INPUT_INTERFACE_UNDERFLOW_OCCURRED_INT_EN, mask_sh), \
- DSC_SF(DSCCIF0_DSCCIF_CONFIG0, INPUT_INTERFACE_UNDERFLOW_OCCURRED_STATUS, mask_sh), \
- DSC_SF(DSCCIF0_DSCCIF_CONFIG0, INPUT_PIXEL_FORMAT, mask_sh), \
- DSC2_SF(DSCCIF0, DSCCIF_CONFIG0__BITS_PER_COMPONENT, mask_sh), \
- DSC_SF(DSCCIF0_DSCCIF_CONFIG0, DOUBLE_BUFFER_REG_UPDATE_PENDING, mask_sh), \
- DSC_SF(DSCCIF0_DSCCIF_CONFIG1, PIC_WIDTH, mask_sh), \
- DSC_SF(DSCCIF0_DSCCIF_CONFIG1, PIC_HEIGHT, mask_sh), \
- DSC_SF(DSCRM0_DSCRM_DSC_FORWARD_CONFIG, DSCRM_DSC_FORWARD_EN, mask_sh), \
- DSC_SF(DSCRM0_DSCRM_DSC_FORWARD_CONFIG, DSCRM_DSC_OPP_PIPE_SOURCE, mask_sh)
-
-
-
-#define DSC_FIELD_LIST_DCN20(type)\
- type DSC_CLOCK_EN; \
- type DSC_DISPCLK_R_GATE_DIS; \
- type DSC_DSCCLK_R_GATE_DIS; \
- type DSC_DBG_EN; \
- type DSC_TEST_CLOCK_MUX_SEL; \
- type ICH_RESET_AT_END_OF_LINE; \
- type NUMBER_OF_SLICES_PER_LINE; \
- type ALTERNATE_ICH_ENCODING_EN; \
- type NUMBER_OF_SLICES_IN_VERTICAL_DIRECTION; \
- type DSCC_RATE_CONTROL_BUFFER_MODEL_SIZE; \
- /*type DSCC_DISABLE_ICH;*/ \
- type DSCC_DOUBLE_BUFFER_REG_UPDATE_PENDING; \
- type DSCC_RATE_BUFFER0_OVERFLOW_OCCURRED; \
- type DSCC_RATE_BUFFER1_OVERFLOW_OCCURRED; \
- type DSCC_RATE_BUFFER2_OVERFLOW_OCCURRED; \
- type DSCC_RATE_BUFFER3_OVERFLOW_OCCURRED; \
- type DSCC_RATE_BUFFER0_UNDERFLOW_OCCURRED; \
- type DSCC_RATE_BUFFER1_UNDERFLOW_OCCURRED; \
- type DSCC_RATE_BUFFER2_UNDERFLOW_OCCURRED; \
- type DSCC_RATE_BUFFER3_UNDERFLOW_OCCURRED; \
- type DSCC_RATE_CONTROL_BUFFER_MODEL0_OVERFLOW_OCCURRED; \
- type DSCC_RATE_CONTROL_BUFFER_MODEL1_OVERFLOW_OCCURRED; \
- type DSCC_RATE_CONTROL_BUFFER_MODEL2_OVERFLOW_OCCURRED; \
- type DSCC_RATE_CONTROL_BUFFER_MODEL3_OVERFLOW_OCCURRED; \
- type DSCC_RATE_BUFFER0_OVERFLOW_OCCURRED_INT_EN; \
- type DSCC_RATE_BUFFER1_OVERFLOW_OCCURRED_INT_EN; \
- type DSCC_RATE_BUFFER2_OVERFLOW_OCCURRED_INT_EN; \
- type DSCC_RATE_BUFFER3_OVERFLOW_OCCURRED_INT_EN; \
- type DSCC_RATE_BUFFER0_UNDERFLOW_OCCURRED_INT_EN; \
- type DSCC_RATE_BUFFER1_UNDERFLOW_OCCURRED_INT_EN; \
- type DSCC_RATE_BUFFER2_UNDERFLOW_OCCURRED_INT_EN; \
- type DSCC_RATE_BUFFER3_UNDERFLOW_OCCURRED_INT_EN; \
- type DSCC_RATE_CONTROL_BUFFER_MODEL0_OVERFLOW_OCCURRED_INT_EN; \
- type DSCC_RATE_CONTROL_BUFFER_MODEL1_OVERFLOW_OCCURRED_INT_EN; \
- type DSCC_RATE_CONTROL_BUFFER_MODEL2_OVERFLOW_OCCURRED_INT_EN; \
- type DSCC_RATE_CONTROL_BUFFER_MODEL3_OVERFLOW_OCCURRED_INT_EN; \
- type DSC_VERSION_MINOR; \
- type DSC_VERSION_MAJOR; \
- type PPS_IDENTIFIER; \
- type LINEBUF_DEPTH; \
- type DSCC_PPS_CONFIG0__BITS_PER_COMPONENT; \
- type BITS_PER_PIXEL; \
- type VBR_ENABLE; \
- type SIMPLE_422; \
- type CONVERT_RGB; \
- type BLOCK_PRED_ENABLE; \
- type NATIVE_422; \
- type NATIVE_420; \
- type CHUNK_SIZE; \
- type PIC_WIDTH; \
- type PIC_HEIGHT; \
- type SLICE_WIDTH; \
- type SLICE_HEIGHT; \
- type INITIAL_XMIT_DELAY; \
- type INITIAL_DEC_DELAY; \
- type INITIAL_SCALE_VALUE; \
- type SCALE_INCREMENT_INTERVAL; \
- type SCALE_DECREMENT_INTERVAL; \
- type FIRST_LINE_BPG_OFFSET; \
- type SECOND_LINE_BPG_OFFSET; \
- type NFL_BPG_OFFSET; \
- type SLICE_BPG_OFFSET; \
- type NSL_BPG_OFFSET; \
- type SECOND_LINE_OFFSET_ADJ; \
- type INITIAL_OFFSET; \
- type FINAL_OFFSET; \
- type FLATNESS_MIN_QP; \
- type FLATNESS_MAX_QP; \
- type RC_MODEL_SIZE; \
- type RC_EDGE_FACTOR; \
- type RC_QUANT_INCR_LIMIT0; \
- type RC_QUANT_INCR_LIMIT1; \
- type RC_TGT_OFFSET_LO; \
- type RC_TGT_OFFSET_HI; \
- type RC_BUF_THRESH0; \
- type RC_BUF_THRESH1; \
- type RC_BUF_THRESH2; \
- type RC_BUF_THRESH3; \
- type RC_BUF_THRESH4; \
- type RC_BUF_THRESH5; \
- type RC_BUF_THRESH6; \
- type RC_BUF_THRESH7; \
- type RC_BUF_THRESH8; \
- type RC_BUF_THRESH9; \
- type RC_BUF_THRESH10; \
- type RC_BUF_THRESH11; \
- type RC_BUF_THRESH12; \
- type RC_BUF_THRESH13; \
- type RANGE_MIN_QP0; \
- type RANGE_MAX_QP0; \
- type RANGE_BPG_OFFSET0; \
- type RANGE_MIN_QP1; \
- type RANGE_MAX_QP1; \
- type RANGE_BPG_OFFSET1; \
- type RANGE_MIN_QP2; \
- type RANGE_MAX_QP2; \
- type RANGE_BPG_OFFSET2; \
- type RANGE_MIN_QP3; \
- type RANGE_MAX_QP3; \
- type RANGE_BPG_OFFSET3; \
- type RANGE_MIN_QP4; \
- type RANGE_MAX_QP4; \
- type RANGE_BPG_OFFSET4; \
- type RANGE_MIN_QP5; \
- type RANGE_MAX_QP5; \
- type RANGE_BPG_OFFSET5; \
- type RANGE_MIN_QP6; \
- type RANGE_MAX_QP6; \
- type RANGE_BPG_OFFSET6; \
- type RANGE_MIN_QP7; \
- type RANGE_MAX_QP7; \
- type RANGE_BPG_OFFSET7; \
- type RANGE_MIN_QP8; \
- type RANGE_MAX_QP8; \
- type RANGE_BPG_OFFSET8; \
- type RANGE_MIN_QP9; \
- type RANGE_MAX_QP9; \
- type RANGE_BPG_OFFSET9; \
- type RANGE_MIN_QP10; \
- type RANGE_MAX_QP10; \
- type RANGE_BPG_OFFSET10; \
- type RANGE_MIN_QP11; \
- type RANGE_MAX_QP11; \
- type RANGE_BPG_OFFSET11; \
- type RANGE_MIN_QP12; \
- type RANGE_MAX_QP12; \
- type RANGE_BPG_OFFSET12; \
- type RANGE_MIN_QP13; \
- type RANGE_MAX_QP13; \
- type RANGE_BPG_OFFSET13; \
- type RANGE_MIN_QP14; \
- type RANGE_MAX_QP14; \
- type RANGE_BPG_OFFSET14; \
- type DSCC_DEFAULT_MEM_LOW_POWER_STATE; \
- type DSCC_MEM_PWR_FORCE; \
- type DSCC_MEM_PWR_DIS; \
- type DSCC_MEM_PWR_STATE; \
- type DSCC_NATIVE_422_MEM_PWR_FORCE; \
- type DSCC_NATIVE_422_MEM_PWR_DIS; \
- type DSCC_NATIVE_422_MEM_PWR_STATE; \
- type DSCC_R_Y_SQUARED_ERROR_LOWER; \
- type DSCC_R_Y_SQUARED_ERROR_UPPER; \
- type DSCC_G_CB_SQUARED_ERROR_LOWER; \
- type DSCC_G_CB_SQUARED_ERROR_UPPER; \
- type DSCC_B_CR_SQUARED_ERROR_LOWER; \
- type DSCC_B_CR_SQUARED_ERROR_UPPER; \
- type DSCC_R_Y_MAX_ABS_ERROR; \
- type DSCC_G_CB_MAX_ABS_ERROR; \
- type DSCC_B_CR_MAX_ABS_ERROR; \
- type DSCC_RATE_BUFFER0_MAX_FULLNESS_LEVEL; \
- type DSCC_RATE_BUFFER1_MAX_FULLNESS_LEVEL; \
- type DSCC_RATE_BUFFER2_MAX_FULLNESS_LEVEL; \
- type DSCC_RATE_BUFFER3_MAX_FULLNESS_LEVEL; \
- type DSCC_RATE_CONTROL_BUFFER0_MAX_FULLNESS_LEVEL; \
- type DSCC_RATE_CONTROL_BUFFER1_MAX_FULLNESS_LEVEL; \
- type DSCC_RATE_CONTROL_BUFFER2_MAX_FULLNESS_LEVEL; \
- type DSCC_RATE_CONTROL_BUFFER3_MAX_FULLNESS_LEVEL; \
- type DSCC_UPDATE_PENDING_STATUS; \
- type DSCC_UPDATE_TAKEN_STATUS; \
- type DSCC_UPDATE_TAKEN_ACK; \
- type DSCC_RATE_BUFFER0_FULLNESS_LEVEL; \
- type DSCC_RATE_BUFFER1_FULLNESS_LEVEL; \
- type DSCC_RATE_BUFFER2_FULLNESS_LEVEL; \
- type DSCC_RATE_BUFFER3_FULLNESS_LEVEL; \
- type DSCC_RATE_CONTROL_BUFFER0_FULLNESS_LEVEL; \
- type DSCC_RATE_CONTROL_BUFFER1_FULLNESS_LEVEL; \
- type DSCC_RATE_CONTROL_BUFFER2_FULLNESS_LEVEL; \
- type DSCC_RATE_CONTROL_BUFFER3_FULLNESS_LEVEL; \
- type DSCC_RATE_BUFFER0_INITIAL_XMIT_DELAY_REACHED; \
- type DSCC_RATE_BUFFER1_INITIAL_XMIT_DELAY_REACHED; \
- type DSCC_RATE_BUFFER2_INITIAL_XMIT_DELAY_REACHED; \
- type DSCC_RATE_BUFFER3_INITIAL_XMIT_DELAY_REACHED; \
- type INPUT_INTERFACE_UNDERFLOW_RECOVERY_EN; \
- type INPUT_INTERFACE_UNDERFLOW_OCCURRED_INT_EN; \
- type INPUT_INTERFACE_UNDERFLOW_OCCURRED_STATUS; \
- type INPUT_PIXEL_FORMAT; \
- type DSCCIF_CONFIG0__BITS_PER_COMPONENT; \
- type DOUBLE_BUFFER_REG_UPDATE_PENDING; \
- type DSCCIF_UPDATE_PENDING_STATUS; \
- type DSCCIF_UPDATE_TAKEN_STATUS; \
- type DSCCIF_UPDATE_TAKEN_ACK; \
- type DSCRM_DSC_FORWARD_EN; \
- type DSCRM_DSC_OPP_PIPE_SOURCE
-
-struct dcn20_dsc_registers {
- uint32_t DSC_TOP_CONTROL;
- uint32_t DSC_DEBUG_CONTROL;
- uint32_t DSCC_CONFIG0;
- uint32_t DSCC_CONFIG1;
- uint32_t DSCC_STATUS;
- uint32_t DSCC_INTERRUPT_CONTROL_STATUS;
- uint32_t DSCC_PPS_CONFIG0;
- uint32_t DSCC_PPS_CONFIG1;
- uint32_t DSCC_PPS_CONFIG2;
- uint32_t DSCC_PPS_CONFIG3;
- uint32_t DSCC_PPS_CONFIG4;
- uint32_t DSCC_PPS_CONFIG5;
- uint32_t DSCC_PPS_CONFIG6;
- uint32_t DSCC_PPS_CONFIG7;
- uint32_t DSCC_PPS_CONFIG8;
- uint32_t DSCC_PPS_CONFIG9;
- uint32_t DSCC_PPS_CONFIG10;
- uint32_t DSCC_PPS_CONFIG11;
- uint32_t DSCC_PPS_CONFIG12;
- uint32_t DSCC_PPS_CONFIG13;
- uint32_t DSCC_PPS_CONFIG14;
- uint32_t DSCC_PPS_CONFIG15;
- uint32_t DSCC_PPS_CONFIG16;
- uint32_t DSCC_PPS_CONFIG17;
- uint32_t DSCC_PPS_CONFIG18;
- uint32_t DSCC_PPS_CONFIG19;
- uint32_t DSCC_PPS_CONFIG20;
- uint32_t DSCC_PPS_CONFIG21;
- uint32_t DSCC_PPS_CONFIG22;
- uint32_t DSCC_MEM_POWER_CONTROL;
- uint32_t DSCC_R_Y_SQUARED_ERROR_LOWER;
- uint32_t DSCC_R_Y_SQUARED_ERROR_UPPER;
- uint32_t DSCC_G_CB_SQUARED_ERROR_LOWER;
- uint32_t DSCC_G_CB_SQUARED_ERROR_UPPER;
- uint32_t DSCC_B_CR_SQUARED_ERROR_LOWER;
- uint32_t DSCC_B_CR_SQUARED_ERROR_UPPER;
- uint32_t DSCC_MAX_ABS_ERROR0;
- uint32_t DSCC_MAX_ABS_ERROR1;
- uint32_t DSCC_RATE_BUFFER0_MAX_FULLNESS_LEVEL;
- uint32_t DSCC_RATE_BUFFER1_MAX_FULLNESS_LEVEL;
- uint32_t DSCC_RATE_BUFFER2_MAX_FULLNESS_LEVEL;
- uint32_t DSCC_RATE_BUFFER3_MAX_FULLNESS_LEVEL;
- uint32_t DSCC_RATE_CONTROL_BUFFER0_MAX_FULLNESS_LEVEL;
- uint32_t DSCC_RATE_CONTROL_BUFFER1_MAX_FULLNESS_LEVEL;
- uint32_t DSCC_RATE_CONTROL_BUFFER2_MAX_FULLNESS_LEVEL;
- uint32_t DSCC_RATE_CONTROL_BUFFER3_MAX_FULLNESS_LEVEL;
- uint32_t DSCCIF_CONFIG0;
- uint32_t DSCCIF_CONFIG1;
- uint32_t DSCRM_DSC_FORWARD_CONFIG;
-};
-
-
-struct dcn20_dsc_shift {
- DSC_FIELD_LIST_DCN20(uint8_t);
-};
-
-struct dcn20_dsc_mask {
- DSC_FIELD_LIST_DCN20(uint32_t);
-};
-
-/* DSCCIF_CONFIG.INPUT_PIXEL_FORMAT values */
-enum dsc_pixel_format {
- DSC_PIXFMT_RGB,
- DSC_PIXFMT_YCBCR444,
- DSC_PIXFMT_SIMPLE_YCBCR422,
- DSC_PIXFMT_NATIVE_YCBCR422,
- DSC_PIXFMT_NATIVE_YCBCR420,
- DSC_PIXFMT_UNKNOWN
-};
-
-struct dsc_reg_values {
- /* PPS registers */
- struct drm_dsc_config pps;
-
- /* Additional registers */
- uint32_t dsc_clock_enable;
- uint32_t dsc_clock_gating_disable;
- uint32_t underflow_recovery_en;
- uint32_t underflow_occurred_int_en;
- uint32_t underflow_occurred_status;
- enum dsc_pixel_format pixel_format;
- uint32_t ich_reset_at_eol;
- uint32_t alternate_ich_encoding_en;
- uint32_t num_slices_h;
- uint32_t num_slices_v;
- uint32_t rc_buffer_model_size;
- uint32_t disable_ich;
- uint32_t bpp_x32;
- uint32_t dsc_dbg_en;
- uint32_t rc_buffer_model_overflow_int_en[4];
-};
-
-struct dcn20_dsc {
- struct display_stream_compressor base;
- const struct dcn20_dsc_registers *dsc_regs;
- const struct dcn20_dsc_shift *dsc_shift;
- const struct dcn20_dsc_mask *dsc_mask;
-
- struct dsc_reg_values reg_vals;
-
- int max_image_width;
-};
-
-void dsc_config_log(struct display_stream_compressor *dsc,
- const struct dsc_config *config);
-
-void dsc_log_pps(struct display_stream_compressor *dsc,
- struct drm_dsc_config *pps);
-
-void dsc_override_rc_params(struct rc_params *rc,
- const struct dc_dsc_rc_params_override *override);
-
-bool dsc_prepare_config(const struct dsc_config *dsc_cfg,
- struct dsc_reg_values *dsc_reg_vals,
- struct dsc_optc_config *dsc_optc_cfg);
-
-enum dsc_pixel_format dsc_dc_pixel_encoding_to_dsc_pixel_format(enum dc_pixel_encoding dc_pix_enc,
- bool is_ycbcr422_simple);
-
-enum dsc_bits_per_comp dsc_dc_color_depth_to_dsc_bits_per_comp(enum dc_color_depth dc_color_depth);
-
-void dsc_init_reg_values(struct dsc_reg_values *reg_vals);
-
-void dsc_update_from_dsc_parameters(struct dsc_reg_values *reg_vals, const struct dsc_parameters *dsc_params);
-
-void dsc2_construct(struct dcn20_dsc *dsc,
- struct dc_context *ctx,
- int inst,
- const struct dcn20_dsc_registers *dsc_regs,
- const struct dcn20_dsc_shift *dsc_shift,
- const struct dcn20_dsc_mask *dsc_mask);
-
-void dsc2_get_enc_caps(struct dsc_enc_caps *dsc_enc_caps,
- int pixel_clock_100Hz);
-
-bool dsc2_get_packed_pps(struct display_stream_compressor *dsc,
- const struct dsc_config *dsc_cfg,
- uint8_t *dsc_packed_pps);
-
-#endif
-
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_init.c b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_init.c
deleted file mode 100644
index 884e3e3233..0000000000
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_init.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright 2016 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: AMD
- *
- */
-
-#include "dce110/dce110_hwseq.h"
-#include "dcn10/dcn10_hwseq.h"
-#include "dcn20/dcn20_hwseq.h"
-
-#include "dcn20_init.h"
-
-static const struct hw_sequencer_funcs dcn20_funcs = {
- .program_gamut_remap = dcn10_program_gamut_remap,
- .init_hw = dcn10_init_hw,
- .power_down_on_boot = dcn10_power_down_on_boot,
- .apply_ctx_to_hw = dce110_apply_ctx_to_hw,
- .apply_ctx_for_surface = NULL,
- .program_front_end_for_ctx = dcn20_program_front_end_for_ctx,
- .wait_for_pending_cleared = dcn10_wait_for_pending_cleared,
- .post_unlock_program_front_end = dcn20_post_unlock_program_front_end,
- .update_plane_addr = dcn20_update_plane_addr,
- .update_dchub = dcn10_update_dchub,
- .update_pending_status = dcn10_update_pending_status,
- .program_output_csc = dcn20_program_output_csc,
- .enable_accelerated_mode = dce110_enable_accelerated_mode,
- .enable_timing_synchronization = dcn10_enable_timing_synchronization,
- .enable_vblanks_synchronization = dcn10_enable_vblanks_synchronization,
- .enable_per_frame_crtc_position_reset = dcn10_enable_per_frame_crtc_position_reset,
- .update_info_frame = dce110_update_info_frame,
- .send_immediate_sdp_message = dcn10_send_immediate_sdp_message,
- .enable_stream = dcn20_enable_stream,
- .disable_stream = dce110_disable_stream,
- .unblank_stream = dcn20_unblank_stream,
- .blank_stream = dce110_blank_stream,
- .enable_audio_stream = dce110_enable_audio_stream,
- .disable_audio_stream = dce110_disable_audio_stream,
- .disable_plane = dcn20_disable_plane,
- .pipe_control_lock = dcn20_pipe_control_lock,
- .interdependent_update_lock = dcn10_lock_all_pipes,
- .cursor_lock = dcn10_cursor_lock,
- .prepare_bandwidth = dcn20_prepare_bandwidth,
- .optimize_bandwidth = dcn20_optimize_bandwidth,
- .update_bandwidth = dcn20_update_bandwidth,
- .set_drr = dcn10_set_drr,
- .get_position = dcn10_get_position,
- .set_static_screen_control = dcn10_set_static_screen_control,
- .setup_stereo = dcn10_setup_stereo,
- .set_avmute = dce110_set_avmute,
- .log_hw_state = dcn10_log_hw_state,
- .get_hw_state = dcn10_get_hw_state,
- .clear_status_bits = dcn10_clear_status_bits,
- .wait_for_mpcc_disconnect = dcn10_wait_for_mpcc_disconnect,
- .edp_backlight_control = dce110_edp_backlight_control,
- .edp_power_control = dce110_edp_power_control,
- .edp_wait_for_hpd_ready = dce110_edp_wait_for_hpd_ready,
- .set_cursor_position = dcn10_set_cursor_position,
- .set_cursor_attribute = dcn10_set_cursor_attribute,
- .set_cursor_sdr_white_level = dcn10_set_cursor_sdr_white_level,
- .setup_periodic_interrupt = dcn10_setup_periodic_interrupt,
- .set_clock = dcn10_set_clock,
- .get_clock = dcn10_get_clock,
- .program_triplebuffer = dcn20_program_triple_buffer,
- .enable_writeback = dcn20_enable_writeback,
- .disable_writeback = dcn20_disable_writeback,
- .dmdata_status_done = dcn20_dmdata_status_done,
- .program_dmdata_engine = dcn20_program_dmdata_engine,
- .set_dmdata_attributes = dcn20_set_dmdata_attributes,
- .init_sys_ctx = dcn20_init_sys_ctx,
- .init_vm_ctx = dcn20_init_vm_ctx,
- .set_flip_control_gsl = dcn20_set_flip_control_gsl,
- .get_vupdate_offset_from_vsync = dcn10_get_vupdate_offset_from_vsync,
- .calc_vupdate_position = dcn10_calc_vupdate_position,
- .set_backlight_level = dce110_set_backlight_level,
- .set_abm_immediate_disable = dce110_set_abm_immediate_disable,
- .set_pipe = dce110_set_pipe,
- .enable_lvds_link_output = dce110_enable_lvds_link_output,
- .enable_tmds_link_output = dce110_enable_tmds_link_output,
- .enable_dp_link_output = dce110_enable_dp_link_output,
- .disable_link_output = dce110_disable_link_output,
- .set_disp_pattern_generator = dcn20_set_disp_pattern_generator,
- .get_dcc_en_bits = dcn10_get_dcc_en_bits,
- .update_visual_confirm_color = dcn10_update_visual_confirm_color,
-};
-
-static const struct hwseq_private_funcs dcn20_private_funcs = {
- .init_pipes = dcn10_init_pipes,
- .update_plane_addr = dcn20_update_plane_addr,
- .plane_atomic_disconnect = dcn10_plane_atomic_disconnect,
- .update_mpcc = dcn20_update_mpcc,
- .set_input_transfer_func = dcn20_set_input_transfer_func,
- .set_output_transfer_func = dcn20_set_output_transfer_func,
- .power_down = dce110_power_down,
- .enable_display_power_gating = dcn10_dummy_display_power_gating,
- .blank_pixel_data = dcn20_blank_pixel_data,
- .reset_hw_ctx_wrap = dcn20_reset_hw_ctx_wrap,
- .enable_stream_timing = dcn20_enable_stream_timing,
- .edp_backlight_control = dce110_edp_backlight_control,
- .disable_stream_gating = dcn20_disable_stream_gating,
- .enable_stream_gating = dcn20_enable_stream_gating,
- .setup_vupdate_interrupt = dcn20_setup_vupdate_interrupt,
- .did_underflow_occur = dcn10_did_underflow_occur,
- .init_blank = dcn20_init_blank,
- .disable_vga = dcn20_disable_vga,
- .bios_golden_init = dcn10_bios_golden_init,
- .plane_atomic_disable = dcn20_plane_atomic_disable,
- .plane_atomic_power_down = dcn10_plane_atomic_power_down,
- .enable_power_gating_plane = dcn20_enable_power_gating_plane,
- .dpp_pg_control = dcn20_dpp_pg_control,
- .hubp_pg_control = dcn20_hubp_pg_control,
- .update_odm = dcn20_update_odm,
- .dsc_pg_control = dcn20_dsc_pg_control,
- .set_hdr_multiplier = dcn10_set_hdr_multiplier,
- .verify_allow_pstate_change_high = dcn10_verify_allow_pstate_change_high,
- .wait_for_blank_complete = dcn20_wait_for_blank_complete,
- .dccg_init = dcn20_dccg_init,
- .set_blend_lut = dcn20_set_blend_lut,
- .set_shaper_3dlut = dcn20_set_shaper_3dlut,
-};
-
-void dcn20_hw_sequencer_construct(struct dc *dc)
-{
- dc->hwss = dcn20_funcs;
- dc->hwseq->funcs = dcn20_private_funcs;
-
-}
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_init.h b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_init.h
deleted file mode 100644
index 12277797cd..0000000000
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_init.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2016 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: AMD
- *
- */
-
-#ifndef __DC_DCN20_INIT_H__
-#define __DC_DCN20_INIT_H__
-
-struct dc;
-
-void dcn20_hw_sequencer_construct(struct dc *dc);
-
-#endif /* __DC_DCN20_INIT_H__ */
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_opp.c b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_opp.c
index 0784d01986..fbf1b6370e 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_opp.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_opp.c
@@ -337,6 +337,19 @@ bool opp2_dpg_is_blanked(struct output_pixel_processor *opp)
(double_buffer_pending == 0);
}
+bool opp2_dpg_is_pending(struct output_pixel_processor *opp)
+{
+ struct dcn20_opp *oppn20 = TO_DCN20_OPP(opp);
+ uint32_t double_buffer_pending;
+ uint32_t dpg_en;
+
+ REG_GET(DPG_CONTROL, DPG_EN, &dpg_en);
+
+ REG_GET(DPG_STATUS, DPG_DOUBLE_BUFFER_PENDING, &double_buffer_pending);
+
+ return (dpg_en == 1 && double_buffer_pending == 1);
+}
+
void opp2_program_left_edge_extra_pixel (
struct output_pixel_processor *opp,
bool count)
@@ -363,6 +376,7 @@ static struct opp_funcs dcn20_opp_funcs = {
.opp_set_disp_pattern_generator = opp2_set_disp_pattern_generator,
.opp_program_dpg_dimensions = opp2_program_dpg_dimensions,
.dpg_is_blanked = opp2_dpg_is_blanked,
+ .dpg_is_pending = opp2_dpg_is_pending,
.opp_dpg_set_blank_color = opp2_dpg_set_blank_color,
.opp_destroy = opp1_destroy,
.opp_program_left_edge_extra_pixel = opp2_program_left_edge_extra_pixel,
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_opp.h b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_opp.h
index 3ab221bdd2..8f186abd55 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_opp.h
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_opp.h
@@ -159,6 +159,8 @@ void opp2_program_dpg_dimensions(
bool opp2_dpg_is_blanked(struct output_pixel_processor *opp);
+bool opp2_dpg_is_pending(struct output_pixel_processor *opp);
+
void opp2_dpg_set_blank_color(
struct output_pixel_processor *opp,
const struct tg_color *color);
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.c b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.c
deleted file mode 100644
index 58bdbd859b..0000000000
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.c
+++ /dev/null
@@ -1,587 +0,0 @@
-/*
- * Copyright 2012-15 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: AMD
- *
- */
-
-#include "reg_helper.h"
-#include "dcn20_optc.h"
-#include "dc.h"
-
-#define REG(reg)\
- optc1->tg_regs->reg
-
-#define CTX \
- optc1->base.ctx
-
-#undef FN
-#define FN(reg_name, field_name) \
- optc1->tg_shift->field_name, optc1->tg_mask->field_name
-
-/**
- * optc2_enable_crtc() - Enable CRTC - call ASIC Control Object to enable Timing generator.
- *
- * @optc: timing_generator instance.
- *
- * Return: If CRTC is enabled, return true.
- *
- */
-bool optc2_enable_crtc(struct timing_generator *optc)
-{
- /* TODO FPGA wait for answer
- * OTG_MASTER_UPDATE_MODE != CRTC_MASTER_UPDATE_MODE
- * OTG_MASTER_UPDATE_LOCK != CRTC_MASTER_UPDATE_LOCK
- */
- struct optc *optc1 = DCN10TG_FROM_TG(optc);
-
- /* opp instance for OTG. For DCN1.0, ODM is remoed.
- * OPP and OPTC should 1:1 mapping
- */
- REG_UPDATE(OPTC_DATA_SOURCE_SELECT,
- OPTC_SEG0_SRC_SEL, optc->inst);
-
- /* VTG enable first is for HW workaround */
- REG_UPDATE(CONTROL,
- VTG0_ENABLE, 1);
-
- REG_SEQ_START();
-
- /* Enable CRTC */
- REG_UPDATE_2(OTG_CONTROL,
- OTG_DISABLE_POINT_CNTL, 3,
- OTG_MASTER_EN, 1);
-
- REG_SEQ_SUBMIT();
- REG_SEQ_WAIT_DONE();
-
- return true;
-}
-
-/**
- * optc2_set_gsl() - Assign OTG to GSL groups,
- * set one of the OTGs to be master & rest are slaves
- *
- * @optc: timing_generator instance.
- * @params: pointer to gsl_params
- */
-void optc2_set_gsl(struct timing_generator *optc,
- const struct gsl_params *params)
-{
- struct optc *optc1 = DCN10TG_FROM_TG(optc);
-
-/*
- * There are (MAX_OPTC+1)/2 gsl groups available for use.
- * In each group (assign an OTG to a group by setting OTG_GSLX_EN = 1,
- * set one of the OTGs to be the master (OTG_GSL_MASTER_EN = 1) and the rest are slaves.
- */
- REG_UPDATE_5(OTG_GSL_CONTROL,
- OTG_GSL0_EN, params->gsl0_en,
- OTG_GSL1_EN, params->gsl1_en,
- OTG_GSL2_EN, params->gsl2_en,
- OTG_GSL_MASTER_EN, params->gsl_master_en,
- OTG_GSL_MASTER_MODE, params->gsl_master_mode);
-}
-
-
-void optc2_set_gsl_source_select(
- struct timing_generator *optc,
- int group_idx,
- uint32_t gsl_ready_signal)
-{
- struct optc *optc1 = DCN10TG_FROM_TG(optc);
-
- switch (group_idx) {
- case 1:
- REG_UPDATE(GSL_SOURCE_SELECT, GSL0_READY_SOURCE_SEL, gsl_ready_signal);
- break;
- case 2:
- REG_UPDATE(GSL_SOURCE_SELECT, GSL1_READY_SOURCE_SEL, gsl_ready_signal);
- break;
- case 3:
- REG_UPDATE(GSL_SOURCE_SELECT, GSL2_READY_SOURCE_SEL, gsl_ready_signal);
- break;
- default:
- break;
- }
-}
-
-/* Set DSC-related configuration.
- * dsc_mode: 0 disables DSC, other values enable DSC in specified format
- * sc_bytes_per_pixel: Bytes per pixel in u3.28 format
- * dsc_slice_width: Slice width in pixels
- */
-void optc2_set_dsc_config(struct timing_generator *optc,
- enum optc_dsc_mode dsc_mode,
- uint32_t dsc_bytes_per_pixel,
- uint32_t dsc_slice_width)
-{
- struct optc *optc1 = DCN10TG_FROM_TG(optc);
-
- REG_UPDATE(OPTC_DATA_FORMAT_CONTROL,
- OPTC_DSC_MODE, dsc_mode);
-
- REG_SET(OPTC_BYTES_PER_PIXEL, 0,
- OPTC_DSC_BYTES_PER_PIXEL, dsc_bytes_per_pixel);
-
- REG_UPDATE(OPTC_WIDTH_CONTROL,
- OPTC_DSC_SLICE_WIDTH, dsc_slice_width);
-}
-
-/* Get DSC-related configuration.
- * dsc_mode: 0 disables DSC, other values enable DSC in specified format
- */
-void optc2_get_dsc_status(struct timing_generator *optc,
- uint32_t *dsc_mode)
-{
- struct optc *optc1 = DCN10TG_FROM_TG(optc);
-
- REG_GET(OPTC_DATA_FORMAT_CONTROL,
- OPTC_DSC_MODE, dsc_mode);
-}
-
-
-/*TEMP: Need to figure out inheritance model here.*/
-bool optc2_is_two_pixels_per_containter(const struct dc_crtc_timing *timing)
-{
- return optc1_is_two_pixels_per_containter(timing);
-}
-
-void optc2_set_odm_bypass(struct timing_generator *optc,
- const struct dc_crtc_timing *dc_crtc_timing)
-{
- struct optc *optc1 = DCN10TG_FROM_TG(optc);
- uint32_t h_div_2 = 0;
-
- REG_SET_3(OPTC_DATA_SOURCE_SELECT, 0,
- OPTC_NUM_OF_INPUT_SEGMENT, 0,
- OPTC_SEG0_SRC_SEL, optc->inst,
- OPTC_SEG1_SRC_SEL, 0xf);
- REG_WRITE(OTG_H_TIMING_CNTL, 0);
-
- h_div_2 = optc2_is_two_pixels_per_containter(dc_crtc_timing);
- REG_UPDATE(OTG_H_TIMING_CNTL,
- OTG_H_TIMING_DIV_BY2, h_div_2);
- REG_SET(OPTC_MEMORY_CONFIG, 0,
- OPTC_MEM_SEL, 0);
- optc1->opp_count = 1;
-}
-
-void optc2_set_odm_combine(struct timing_generator *optc, int *opp_id, int opp_cnt,
- struct dc_crtc_timing *timing)
-{
- struct optc *optc1 = DCN10TG_FROM_TG(optc);
- int mpcc_hactive = (timing->h_addressable + timing->h_border_left + timing->h_border_right)
- / opp_cnt;
- uint32_t memory_mask;
-
- ASSERT(opp_cnt == 2);
-
- /* TODO: In pseudocode but does not affect maximus, delete comment if we dont need on asic
- * REG_SET(OTG_GLOBAL_CONTROL2, 0, GLOBAL_UPDATE_LOCK_EN, 1);
- * Program OTG register MASTER_UPDATE_LOCK_DB_X/Y to the position before DP frame start
- * REG_SET_2(OTG_GLOBAL_CONTROL1, 0,
- * MASTER_UPDATE_LOCK_DB_X, 160,
- * MASTER_UPDATE_LOCK_DB_Y, 240);
- */
-
- /* 2 pieces of memory required for up to 5120 displays, 4 for up to 8192,
- * however, for ODM combine we can simplify by always using 4.
- * To make sure there's no overlap, each instance "reserves" 2 memories and
- * they are uniquely combined here.
- */
- memory_mask = 0x3 << (opp_id[0] * 2) | 0x3 << (opp_id[1] * 2);
-
- if (REG(OPTC_MEMORY_CONFIG))
- REG_SET(OPTC_MEMORY_CONFIG, 0,
- OPTC_MEM_SEL, memory_mask);
-
- REG_SET_3(OPTC_DATA_SOURCE_SELECT, 0,
- OPTC_NUM_OF_INPUT_SEGMENT, 1,
- OPTC_SEG0_SRC_SEL, opp_id[0],
- OPTC_SEG1_SRC_SEL, opp_id[1]);
-
- REG_UPDATE(OPTC_WIDTH_CONTROL,
- OPTC_SEGMENT_WIDTH, mpcc_hactive);
-
- REG_SET(OTG_H_TIMING_CNTL, 0, OTG_H_TIMING_DIV_BY2, 1);
- optc1->opp_count = opp_cnt;
-}
-
-void optc2_get_optc_source(struct timing_generator *optc,
- uint32_t *num_of_src_opp,
- uint32_t *src_opp_id_0,
- uint32_t *src_opp_id_1)
-{
- uint32_t num_of_input_segments;
- struct optc *optc1 = DCN10TG_FROM_TG(optc);
-
- REG_GET_3(OPTC_DATA_SOURCE_SELECT,
- OPTC_NUM_OF_INPUT_SEGMENT, &num_of_input_segments,
- OPTC_SEG0_SRC_SEL, src_opp_id_0,
- OPTC_SEG1_SRC_SEL, src_opp_id_1);
-
- if (num_of_input_segments == 1)
- *num_of_src_opp = 2;
- else
- *num_of_src_opp = 1;
-
- /* Work around VBIOS not updating OPTC_NUM_OF_INPUT_SEGMENT */
- if (*src_opp_id_1 == 0xf)
- *num_of_src_opp = 1;
-}
-
-static void optc2_set_dwb_source(struct timing_generator *optc,
- uint32_t dwb_pipe_inst)
-{
- struct optc *optc1 = DCN10TG_FROM_TG(optc);
-
- if (dwb_pipe_inst == 0)
- REG_UPDATE(DWB_SOURCE_SELECT,
- OPTC_DWB0_SOURCE_SELECT, optc->inst);
- else if (dwb_pipe_inst == 1)
- REG_UPDATE(DWB_SOURCE_SELECT,
- OPTC_DWB1_SOURCE_SELECT, optc->inst);
-}
-
-static void optc2_align_vblanks(
- struct timing_generator *optc_master,
- struct timing_generator *optc_slave,
- uint32_t master_pixel_clock_100Hz,
- uint32_t slave_pixel_clock_100Hz,
- uint8_t master_clock_divider,
- uint8_t slave_clock_divider)
-{
- /* accessing slave OTG registers */
- struct optc *optc1 = DCN10TG_FROM_TG(optc_slave);
-
- uint32_t master_v_active = 0;
- uint32_t master_h_total = 0;
- uint32_t slave_h_total = 0;
- uint64_t L, XY;
- uint32_t X, Y, p = 10000;
- uint32_t master_update_lock;
-
- /* disable slave OTG */
- REG_UPDATE(OTG_CONTROL, OTG_MASTER_EN, 0);
- /* wait until disabled */
- REG_WAIT(OTG_CONTROL,
- OTG_CURRENT_MASTER_EN_STATE,
- 0, 10, 5000);
-
- REG_GET(OTG_H_TOTAL, OTG_H_TOTAL, &slave_h_total);
-
- /* assign slave OTG to be controlled by master update lock */
- REG_SET(OTG_GLOBAL_CONTROL0, 0,
- OTG_MASTER_UPDATE_LOCK_SEL, optc_master->inst);
-
- /* accessing master OTG registers */
- optc1 = DCN10TG_FROM_TG(optc_master);
-
- /* saving update lock state, not sure if it's needed */
- REG_GET(OTG_MASTER_UPDATE_LOCK,
- OTG_MASTER_UPDATE_LOCK, &master_update_lock);
- /* unlocking master OTG */
- REG_SET(OTG_MASTER_UPDATE_LOCK, 0,
- OTG_MASTER_UPDATE_LOCK, 0);
-
- REG_GET(OTG_V_BLANK_START_END,
- OTG_V_BLANK_START, &master_v_active);
- REG_GET(OTG_H_TOTAL, OTG_H_TOTAL, &master_h_total);
-
- /* calculate when to enable slave OTG */
- L = (uint64_t)p * slave_h_total * master_pixel_clock_100Hz;
- L = div_u64(L, master_h_total);
- L = div_u64(L, slave_pixel_clock_100Hz);
- XY = div_u64(L, p);
- Y = master_v_active - XY - 1;
- X = div_u64(((XY + 1) * p - L) * master_h_total, p * master_clock_divider);
-
- /*
- * set master OTG to unlock when V/H
- * counters reach calculated values
- */
- REG_UPDATE(OTG_GLOBAL_CONTROL1,
- MASTER_UPDATE_LOCK_DB_EN, 1);
- REG_UPDATE_2(OTG_GLOBAL_CONTROL1,
- MASTER_UPDATE_LOCK_DB_X,
- X,
- MASTER_UPDATE_LOCK_DB_Y,
- Y);
-
- /* lock master OTG */
- REG_SET(OTG_MASTER_UPDATE_LOCK, 0,
- OTG_MASTER_UPDATE_LOCK, 1);
- REG_WAIT(OTG_MASTER_UPDATE_LOCK,
- UPDATE_LOCK_STATUS, 1, 1, 10);
-
- /* accessing slave OTG registers */
- optc1 = DCN10TG_FROM_TG(optc_slave);
-
- /*
- * enable slave OTG, the OTG is locked with
- * master's update lock, so it will not run
- */
- REG_UPDATE(OTG_CONTROL,
- OTG_MASTER_EN, 1);
-
- /* accessing master OTG registers */
- optc1 = DCN10TG_FROM_TG(optc_master);
-
- /*
- * unlock master OTG. When master H/V counters reach
- * DB_XY point, slave OTG will start
- */
- REG_SET(OTG_MASTER_UPDATE_LOCK, 0,
- OTG_MASTER_UPDATE_LOCK, 0);
-
- /* accessing slave OTG registers */
- optc1 = DCN10TG_FROM_TG(optc_slave);
-
- /* wait for slave OTG to start running*/
- REG_WAIT(OTG_CONTROL,
- OTG_CURRENT_MASTER_EN_STATE,
- 1, 10, 5000);
-
- /* accessing master OTG registers */
- optc1 = DCN10TG_FROM_TG(optc_master);
-
- /* disable the XY point*/
- REG_UPDATE(OTG_GLOBAL_CONTROL1,
- MASTER_UPDATE_LOCK_DB_EN, 0);
- REG_UPDATE_2(OTG_GLOBAL_CONTROL1,
- MASTER_UPDATE_LOCK_DB_X,
- 0,
- MASTER_UPDATE_LOCK_DB_Y,
- 0);
-
- /*restore master update lock*/
- REG_SET(OTG_MASTER_UPDATE_LOCK, 0,
- OTG_MASTER_UPDATE_LOCK, master_update_lock);
-
- /* accessing slave OTG registers */
- optc1 = DCN10TG_FROM_TG(optc_slave);
- /* restore slave to be controlled by it's own */
- REG_SET(OTG_GLOBAL_CONTROL0, 0,
- OTG_MASTER_UPDATE_LOCK_SEL, optc_slave->inst);
-
-}
-
-void optc2_triplebuffer_lock(struct timing_generator *optc)
-{
- struct optc *optc1 = DCN10TG_FROM_TG(optc);
-
- REG_SET(OTG_GLOBAL_CONTROL0, 0,
- OTG_MASTER_UPDATE_LOCK_SEL, optc->inst);
-
- REG_SET(OTG_VUPDATE_KEEPOUT, 0,
- OTG_MASTER_UPDATE_LOCK_VUPDATE_KEEPOUT_EN, 1);
-
- REG_SET(OTG_MASTER_UPDATE_LOCK, 0,
- OTG_MASTER_UPDATE_LOCK, 1);
-
- REG_WAIT(OTG_MASTER_UPDATE_LOCK,
- UPDATE_LOCK_STATUS, 1,
- 1, 10);
-}
-
-void optc2_triplebuffer_unlock(struct timing_generator *optc)
-{
- struct optc *optc1 = DCN10TG_FROM_TG(optc);
-
- REG_SET(OTG_MASTER_UPDATE_LOCK, 0,
- OTG_MASTER_UPDATE_LOCK, 0);
-
- REG_SET(OTG_VUPDATE_KEEPOUT, 0,
- OTG_MASTER_UPDATE_LOCK_VUPDATE_KEEPOUT_EN, 0);
-
-}
-
-void optc2_lock_doublebuffer_enable(struct timing_generator *optc)
-{
- struct optc *optc1 = DCN10TG_FROM_TG(optc);
- uint32_t v_blank_start = 0;
- uint32_t h_blank_start = 0;
-
- REG_UPDATE(OTG_GLOBAL_CONTROL1, MASTER_UPDATE_LOCK_DB_EN, 1);
-
- REG_UPDATE_2(OTG_GLOBAL_CONTROL2, GLOBAL_UPDATE_LOCK_EN, 1,
- DIG_UPDATE_LOCATION, 20);
-
- REG_GET(OTG_V_BLANK_START_END, OTG_V_BLANK_START, &v_blank_start);
-
- REG_GET(OTG_H_BLANK_START_END, OTG_H_BLANK_START, &h_blank_start);
-
- REG_UPDATE_2(OTG_GLOBAL_CONTROL1,
- MASTER_UPDATE_LOCK_DB_X,
- (h_blank_start - 200 - 1) / optc1->opp_count,
- MASTER_UPDATE_LOCK_DB_Y,
- v_blank_start - 1);
-
- REG_SET_3(OTG_VUPDATE_KEEPOUT, 0,
- MASTER_UPDATE_LOCK_VUPDATE_KEEPOUT_START_OFFSET, 0,
- MASTER_UPDATE_LOCK_VUPDATE_KEEPOUT_END_OFFSET, 100,
- OTG_MASTER_UPDATE_LOCK_VUPDATE_KEEPOUT_EN, 1);
-}
-
-void optc2_lock_doublebuffer_disable(struct timing_generator *optc)
-{
- struct optc *optc1 = DCN10TG_FROM_TG(optc);
-
- REG_UPDATE_2(OTG_GLOBAL_CONTROL1,
- MASTER_UPDATE_LOCK_DB_X,
- 0,
- MASTER_UPDATE_LOCK_DB_Y,
- 0);
-
- REG_UPDATE_2(OTG_GLOBAL_CONTROL2, GLOBAL_UPDATE_LOCK_EN, 0,
- DIG_UPDATE_LOCATION, 0);
-
- REG_UPDATE(OTG_GLOBAL_CONTROL1, MASTER_UPDATE_LOCK_DB_EN, 0);
-}
-
-void optc2_setup_manual_trigger(struct timing_generator *optc)
-{
- struct optc *optc1 = DCN10TG_FROM_TG(optc);
-
- /* Set the min/max selectors unconditionally so that
- * DMCUB fw may change OTG timings when necessary
- * TODO: Remove the w/a after fixing the issue in DMCUB firmware
- */
- REG_UPDATE_4(OTG_V_TOTAL_CONTROL,
- OTG_V_TOTAL_MIN_SEL, 1,
- OTG_V_TOTAL_MAX_SEL, 1,
- OTG_FORCE_LOCK_ON_EVENT, 0,
- OTG_SET_V_TOTAL_MIN_MASK, (1 << 1)); /* TRIGA */
-
- REG_SET_8(OTG_TRIGA_CNTL, 0,
- OTG_TRIGA_SOURCE_SELECT, 21,
- OTG_TRIGA_SOURCE_PIPE_SELECT, optc->inst,
- OTG_TRIGA_RISING_EDGE_DETECT_CNTL, 1,
- OTG_TRIGA_FALLING_EDGE_DETECT_CNTL, 0,
- OTG_TRIGA_POLARITY_SELECT, 0,
- OTG_TRIGA_FREQUENCY_SELECT, 0,
- OTG_TRIGA_DELAY, 0,
- OTG_TRIGA_CLEAR, 1);
-}
-
-void optc2_program_manual_trigger(struct timing_generator *optc)
-{
- struct optc *optc1 = DCN10TG_FROM_TG(optc);
-
- REG_SET(OTG_TRIGA_MANUAL_TRIG, 0,
- OTG_TRIGA_MANUAL_TRIG, 1);
-}
-
-bool optc2_configure_crc(struct timing_generator *optc,
- const struct crc_params *params)
-{
- struct optc *optc1 = DCN10TG_FROM_TG(optc);
-
- REG_SET_2(OTG_CRC_CNTL2, 0,
- OTG_CRC_DSC_MODE, params->dsc_mode,
- OTG_CRC_DATA_STREAM_COMBINE_MODE, params->odm_mode);
-
- return optc1_configure_crc(optc, params);
-}
-
-
-void optc2_get_last_used_drr_vtotal(struct timing_generator *optc, uint32_t *refresh_rate)
-{
- struct optc *optc1 = DCN10TG_FROM_TG(optc);
-
- REG_GET(OTG_DRR_CONTROL, OTG_V_TOTAL_LAST_USED_BY_DRR, refresh_rate);
-}
-
-static struct timing_generator_funcs dcn20_tg_funcs = {
- .validate_timing = optc1_validate_timing,
- .program_timing = optc1_program_timing,
- .setup_vertical_interrupt0 = optc1_setup_vertical_interrupt0,
- .setup_vertical_interrupt1 = optc1_setup_vertical_interrupt1,
- .setup_vertical_interrupt2 = optc1_setup_vertical_interrupt2,
- .program_global_sync = optc1_program_global_sync,
- .enable_crtc = optc2_enable_crtc,
- .disable_crtc = optc1_disable_crtc,
- /* used by enable_timing_synchronization. Not need for FPGA */
- .is_counter_moving = optc1_is_counter_moving,
- .get_position = optc1_get_position,
- .get_frame_count = optc1_get_vblank_counter,
- .get_scanoutpos = optc1_get_crtc_scanoutpos,
- .get_otg_active_size = optc1_get_otg_active_size,
- .set_early_control = optc1_set_early_control,
- /* used by enable_timing_synchronization. Not need for FPGA */
- .wait_for_state = optc1_wait_for_state,
- .set_blank = optc1_set_blank,
- .is_blanked = optc1_is_blanked,
- .set_blank_color = optc1_program_blank_color,
- .enable_reset_trigger = optc1_enable_reset_trigger,
- .enable_crtc_reset = optc1_enable_crtc_reset,
- .did_triggered_reset_occur = optc1_did_triggered_reset_occur,
- .triplebuffer_lock = optc2_triplebuffer_lock,
- .triplebuffer_unlock = optc2_triplebuffer_unlock,
- .disable_reset_trigger = optc1_disable_reset_trigger,
- .lock = optc1_lock,
- .unlock = optc1_unlock,
- .lock_doublebuffer_enable = optc2_lock_doublebuffer_enable,
- .lock_doublebuffer_disable = optc2_lock_doublebuffer_disable,
- .enable_optc_clock = optc1_enable_optc_clock,
- .set_drr = optc1_set_drr,
- .get_last_used_drr_vtotal = optc2_get_last_used_drr_vtotal,
- .set_vtotal_min_max = optc1_set_vtotal_min_max,
- .set_static_screen_control = optc1_set_static_screen_control,
- .program_stereo = optc1_program_stereo,
- .is_stereo_left_eye = optc1_is_stereo_left_eye,
- .set_blank_data_double_buffer = optc1_set_blank_data_double_buffer,
- .tg_init = optc1_tg_init,
- .is_tg_enabled = optc1_is_tg_enabled,
- .is_optc_underflow_occurred = optc1_is_optc_underflow_occurred,
- .clear_optc_underflow = optc1_clear_optc_underflow,
- .setup_global_swap_lock = NULL,
- .get_crc = optc1_get_crc,
- .configure_crc = optc2_configure_crc,
- .set_dsc_config = optc2_set_dsc_config,
- .get_dsc_status = optc2_get_dsc_status,
- .set_dwb_source = optc2_set_dwb_source,
- .set_odm_bypass = optc2_set_odm_bypass,
- .set_odm_combine = optc2_set_odm_combine,
- .get_optc_source = optc2_get_optc_source,
- .set_gsl = optc2_set_gsl,
- .set_gsl_source_select = optc2_set_gsl_source_select,
- .set_vtg_params = optc1_set_vtg_params,
- .program_manual_trigger = optc2_program_manual_trigger,
- .setup_manual_trigger = optc2_setup_manual_trigger,
- .get_hw_timing = optc1_get_hw_timing,
- .align_vblanks = optc2_align_vblanks,
-};
-
-void dcn20_timing_generator_init(struct optc *optc1)
-{
- optc1->base.funcs = &dcn20_tg_funcs;
-
- optc1->max_h_total = optc1->tg_mask->OTG_H_TOTAL + 1;
- optc1->max_v_total = optc1->tg_mask->OTG_V_TOTAL + 1;
-
- optc1->min_h_blank = 32;
- optc1->min_v_blank = 3;
- optc1->min_v_blank_interlace = 5;
- optc1->min_h_sync_width = 4;// Minimum HSYNC = 8 pixels asked By HW in the first place for no actual reason. Oculus Rift S will not light up with 8 as it's hsyncWidth is 6. Changing it to 4 to fix that issue.
- optc1->min_v_sync_width = 1;
-}
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.h b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.h
deleted file mode 100644
index f7968b9ca1..0000000000
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2012-15 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: AMD
- *
- */
-
-#ifndef __DC_OPTC_DCN20_H__
-#define __DC_OPTC_DCN20_H__
-
-#include "../dcn10/dcn10_optc.h"
-
-#define TG_COMMON_REG_LIST_DCN2_0(inst) \
- TG_COMMON_REG_LIST_DCN(inst),\
- SRI(OTG_GLOBAL_CONTROL1, OTG, inst),\
- SRI(OTG_GLOBAL_CONTROL2, OTG, inst),\
- SRI(OTG_GSL_WINDOW_X, OTG, inst),\
- SRI(OTG_GSL_WINDOW_Y, OTG, inst),\
- SRI(OTG_VUPDATE_KEEPOUT, OTG, inst),\
- SRI(OTG_DSC_START_POSITION, OTG, inst),\
- SRI(OTG_CRC_CNTL2, OTG, inst),\
- SRI(OPTC_DATA_FORMAT_CONTROL, ODM, inst),\
- SRI(OPTC_BYTES_PER_PIXEL, ODM, inst),\
- SRI(OPTC_WIDTH_CONTROL, ODM, inst),\
- SRI(OPTC_MEMORY_CONFIG, ODM, inst),\
- SR(DWB_SOURCE_SELECT),\
- SRI(OTG_MANUAL_FLOW_CONTROL, OTG, inst), \
- SRI(OTG_DRR_CONTROL, OTG, inst)
-
-#define TG_COMMON_MASK_SH_LIST_DCN2_0(mask_sh)\
- TG_COMMON_MASK_SH_LIST_DCN(mask_sh),\
- SF(OTG0_OTG_GLOBAL_CONTROL1, MASTER_UPDATE_LOCK_DB_X, mask_sh),\
- SF(OTG0_OTG_GLOBAL_CONTROL1, MASTER_UPDATE_LOCK_DB_Y, mask_sh),\
- SF(OTG0_OTG_GLOBAL_CONTROL1, MASTER_UPDATE_LOCK_DB_EN, mask_sh),\
- SF(OTG0_OTG_GLOBAL_CONTROL2, GLOBAL_UPDATE_LOCK_EN, mask_sh),\
- SF(OTG0_OTG_GLOBAL_CONTROL2, DIG_UPDATE_LOCATION, mask_sh),\
- SF(OTG0_OTG_DOUBLE_BUFFER_CONTROL, OTG_RANGE_TIMING_DBUF_UPDATE_MODE, mask_sh),\
- SF(OTG0_OTG_GSL_WINDOW_X, OTG_GSL_WINDOW_START_X, mask_sh),\
- SF(OTG0_OTG_GSL_WINDOW_X, OTG_GSL_WINDOW_END_X, mask_sh), \
- SF(OTG0_OTG_GSL_WINDOW_Y, OTG_GSL_WINDOW_START_Y, mask_sh),\
- SF(OTG0_OTG_GSL_WINDOW_Y, OTG_GSL_WINDOW_END_Y, mask_sh),\
- SF(OTG0_OTG_GSL_CONTROL, OTG_GSL_MASTER_MODE, mask_sh), \
- SF(OTG0_OTG_GSL_CONTROL, OTG_MASTER_UPDATE_LOCK_GSL_EN, mask_sh), \
- SF(OTG0_OTG_DSC_START_POSITION, OTG_DSC_START_POSITION_X, mask_sh), \
- SF(OTG0_OTG_DSC_START_POSITION, OTG_DSC_START_POSITION_LINE_NUM, mask_sh),\
- SF(OTG0_OTG_CRC_CNTL2, OTG_CRC_DSC_MODE, mask_sh),\
- SF(OTG0_OTG_CRC_CNTL2, OTG_CRC_DATA_STREAM_COMBINE_MODE, mask_sh),\
- SF(OTG0_OTG_CRC_CNTL2, OTG_CRC_DATA_STREAM_SPLIT_MODE, mask_sh),\
- SF(OTG0_OTG_CRC_CNTL2, OTG_CRC_DATA_FORMAT, mask_sh),\
- SF(ODM0_OPTC_DATA_SOURCE_SELECT, OPTC_SEG0_SRC_SEL, mask_sh),\
- SF(ODM0_OPTC_DATA_SOURCE_SELECT, OPTC_SEG1_SRC_SEL, mask_sh),\
- SF(ODM0_OPTC_DATA_SOURCE_SELECT, OPTC_NUM_OF_INPUT_SEGMENT, mask_sh),\
- SF(ODM0_OPTC_MEMORY_CONFIG, OPTC_MEM_SEL, mask_sh),\
- SF(ODM0_OPTC_DATA_FORMAT_CONTROL, OPTC_DATA_FORMAT, mask_sh),\
- SF(ODM0_OPTC_DATA_FORMAT_CONTROL, OPTC_DSC_MODE, mask_sh),\
- SF(ODM0_OPTC_BYTES_PER_PIXEL, OPTC_DSC_BYTES_PER_PIXEL, mask_sh),\
- SF(ODM0_OPTC_WIDTH_CONTROL, OPTC_DSC_SLICE_WIDTH, mask_sh),\
- SF(ODM0_OPTC_WIDTH_CONTROL, OPTC_SEGMENT_WIDTH, mask_sh),\
- SF(DWB_SOURCE_SELECT, OPTC_DWB0_SOURCE_SELECT, mask_sh),\
- SF(DWB_SOURCE_SELECT, OPTC_DWB1_SOURCE_SELECT, mask_sh),\
- SF(OTG0_OTG_MANUAL_FLOW_CONTROL, MANUAL_FLOW_CONTROL, mask_sh), \
- SF(OTG0_OTG_DRR_CONTROL, OTG_V_TOTAL_LAST_USED_BY_DRR, mask_sh)
-
-void dcn20_timing_generator_init(struct optc *optc);
-
-void optc2_get_last_used_drr_vtotal(struct timing_generator *optc,
- uint32_t *refresh_rate);
-
-bool optc2_enable_crtc(struct timing_generator *optc);
-
-void optc2_set_gsl(struct timing_generator *optc,
- const struct gsl_params *params);
-
-void optc2_set_gsl_source_select(struct timing_generator *optc,
- int group_idx,
- uint32_t gsl_ready_signal);
-
-void optc2_set_dsc_config(struct timing_generator *optc,
- enum optc_dsc_mode dsc_mode,
- uint32_t dsc_bytes_per_pixel,
- uint32_t dsc_slice_width);
-
-void optc2_get_dsc_status(struct timing_generator *optc,
- uint32_t *dsc_mode);
-
-void optc2_set_odm_bypass(struct timing_generator *optc,
- const struct dc_crtc_timing *dc_crtc_timing);
-
-void optc2_set_odm_combine(struct timing_generator *optc, int *opp_id, int opp_cnt,
- struct dc_crtc_timing *timing);
-
-void optc2_get_optc_source(struct timing_generator *optc,
- uint32_t *num_of_src_opp,
- uint32_t *src_opp_id_0,
- uint32_t *src_opp_id_1);
-
-void optc2_triplebuffer_lock(struct timing_generator *optc);
-void optc2_triplebuffer_unlock(struct timing_generator *optc);
-void optc2_lock_doublebuffer_disable(struct timing_generator *optc);
-void optc2_lock_doublebuffer_enable(struct timing_generator *optc);
-void optc2_setup_manual_trigger(struct timing_generator *optc);
-void optc2_program_manual_trigger(struct timing_generator *optc);
-bool optc2_is_two_pixels_per_containter(const struct dc_crtc_timing *timing);
-bool optc2_configure_crc(struct timing_generator *optc,
- const struct crc_params *params);
-#endif /* __DC_OPTC_DCN20_H__ */
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
deleted file mode 100644
index e73e597548..0000000000
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
+++ /dev/null
@@ -1,2793 +0,0 @@
-/*
-* Copyright 2016 Advanced Micro Devices, Inc.
- * Copyright 2019 Raptor Engineering, LLC
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: AMD
- *
- */
-
-#include <linux/slab.h>
-
-#include "dm_services.h"
-#include "dc.h"
-
-#include "dcn20_init.h"
-
-#include "resource.h"
-#include "include/irq_service_interface.h"
-#include "dcn20/dcn20_resource.h"
-
-#include "dml/dcn20/dcn20_fpu.h"
-
-#include "dcn10/dcn10_hubp.h"
-#include "dcn10/dcn10_ipp.h"
-#include "dcn20_hubbub.h"
-#include "dcn20_mpc.h"
-#include "dcn20_hubp.h"
-#include "irq/dcn20/irq_service_dcn20.h"
-#include "dcn20_dpp.h"
-#include "dcn20_optc.h"
-#include "dcn20/dcn20_hwseq.h"
-#include "dce110/dce110_hwseq.h"
-#include "dcn10/dcn10_resource.h"
-#include "dcn20_opp.h"
-
-#include "dcn20_dsc.h"
-
-#include "dcn20_link_encoder.h"
-#include "dcn20_stream_encoder.h"
-#include "dce/dce_clock_source.h"
-#include "dce/dce_audio.h"
-#include "dce/dce_hwseq.h"
-#include "virtual/virtual_stream_encoder.h"
-#include "dce110/dce110_resource.h"
-#include "dml/display_mode_vba.h"
-#include "dcn20_dccg.h"
-#include "dcn20_vmid.h"
-#include "dce/dce_panel_cntl.h"
-
-#include "navi10_ip_offset.h"
-
-#include "dcn/dcn_2_0_0_offset.h"
-#include "dcn/dcn_2_0_0_sh_mask.h"
-#include "dpcs/dpcs_2_0_0_offset.h"
-#include "dpcs/dpcs_2_0_0_sh_mask.h"
-
-#include "nbio/nbio_2_3_offset.h"
-
-#include "dcn20/dcn20_dwb.h"
-#include "dcn20/dcn20_mmhubbub.h"
-
-#include "mmhub/mmhub_2_0_0_offset.h"
-#include "mmhub/mmhub_2_0_0_sh_mask.h"
-
-#include "reg_helper.h"
-#include "dce/dce_abm.h"
-#include "dce/dce_dmcu.h"
-#include "dce/dce_aux.h"
-#include "dce/dce_i2c.h"
-#include "vm_helper.h"
-#include "link_enc_cfg.h"
-
-#include "amdgpu_socbb.h"
-
-#include "link.h"
-#define DC_LOGGER_INIT(logger)
-
-#ifndef mmDP0_DP_DPHY_INTERNAL_CTRL
- #define mmDP0_DP_DPHY_INTERNAL_CTRL 0x210f
- #define mmDP0_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2
- #define mmDP1_DP_DPHY_INTERNAL_CTRL 0x220f
- #define mmDP1_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2
- #define mmDP2_DP_DPHY_INTERNAL_CTRL 0x230f
- #define mmDP2_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2
- #define mmDP3_DP_DPHY_INTERNAL_CTRL 0x240f
- #define mmDP3_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2
- #define mmDP4_DP_DPHY_INTERNAL_CTRL 0x250f
- #define mmDP4_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2
- #define mmDP5_DP_DPHY_INTERNAL_CTRL 0x260f
- #define mmDP5_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2
- #define mmDP6_DP_DPHY_INTERNAL_CTRL 0x270f
- #define mmDP6_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2
-#endif
-
-
-enum dcn20_clk_src_array_id {
- DCN20_CLK_SRC_PLL0,
- DCN20_CLK_SRC_PLL1,
- DCN20_CLK_SRC_PLL2,
- DCN20_CLK_SRC_PLL3,
- DCN20_CLK_SRC_PLL4,
- DCN20_CLK_SRC_PLL5,
- DCN20_CLK_SRC_TOTAL
-};
-
-/* begin *********************
- * macros to expend register list macro defined in HW object header file */
-
-/* DCN */
-#define BASE_INNER(seg) DCN_BASE__INST0_SEG ## seg
-
-#define BASE(seg) BASE_INNER(seg)
-
-#define SR(reg_name)\
- .reg_name = BASE(mm ## reg_name ## _BASE_IDX) + \
- mm ## reg_name
-
-#define SRI(reg_name, block, id)\
- .reg_name = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
- mm ## block ## id ## _ ## reg_name
-
-#define SRI2_DWB(reg_name, block, id)\
- .reg_name = BASE(mm ## reg_name ## _BASE_IDX) + \
- mm ## reg_name
-#define SF_DWB(reg_name, field_name, post_fix)\
- .field_name = reg_name ## __ ## field_name ## post_fix
-
-#define SF_DWB2(reg_name, block, id, field_name, post_fix) \
- .field_name = reg_name ## __ ## field_name ## post_fix
-
-#define SRIR(var_name, reg_name, block, id)\
- .var_name = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
- mm ## block ## id ## _ ## reg_name
-
-#define SRII(reg_name, block, id)\
- .reg_name[id] = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
- mm ## block ## id ## _ ## reg_name
-
-#define DCCG_SRII(reg_name, block, id)\
- .block ## _ ## reg_name[id] = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
- mm ## block ## id ## _ ## reg_name
-
-#define VUPDATE_SRII(reg_name, block, id)\
- .reg_name[id] = BASE(mm ## reg_name ## _ ## block ## id ## _BASE_IDX) + \
- mm ## reg_name ## _ ## block ## id
-
-/* NBIO */
-#define NBIO_BASE_INNER(seg) \
- NBIO_BASE__INST0_SEG ## seg
-
-#define NBIO_BASE(seg) \
- NBIO_BASE_INNER(seg)
-
-#define NBIO_SR(reg_name)\
- .reg_name = NBIO_BASE(mm ## reg_name ## _BASE_IDX) + \
- mm ## reg_name
-
-/* MMHUB */
-#define MMHUB_BASE_INNER(seg) \
- MMHUB_BASE__INST0_SEG ## seg
-
-#define MMHUB_BASE(seg) \
- MMHUB_BASE_INNER(seg)
-
-#define MMHUB_SR(reg_name)\
- .reg_name = MMHUB_BASE(mmMM ## reg_name ## _BASE_IDX) + \
- mmMM ## reg_name
-
-static const struct bios_registers bios_regs = {
- NBIO_SR(BIOS_SCRATCH_3),
- NBIO_SR(BIOS_SCRATCH_6)
-};
-
-#define clk_src_regs(index, pllid)\
-[index] = {\
- CS_COMMON_REG_LIST_DCN2_0(index, pllid),\
-}
-
-static const struct dce110_clk_src_regs clk_src_regs[] = {
- clk_src_regs(0, A),
- clk_src_regs(1, B),
- clk_src_regs(2, C),
- clk_src_regs(3, D),
- clk_src_regs(4, E),
- clk_src_regs(5, F)
-};
-
-static const struct dce110_clk_src_shift cs_shift = {
- CS_COMMON_MASK_SH_LIST_DCN2_0(__SHIFT)
-};
-
-static const struct dce110_clk_src_mask cs_mask = {
- CS_COMMON_MASK_SH_LIST_DCN2_0(_MASK)
-};
-
-static const struct dce_dmcu_registers dmcu_regs = {
- DMCU_DCN10_REG_LIST()
-};
-
-static const struct dce_dmcu_shift dmcu_shift = {
- DMCU_MASK_SH_LIST_DCN10(__SHIFT)
-};
-
-static const struct dce_dmcu_mask dmcu_mask = {
- DMCU_MASK_SH_LIST_DCN10(_MASK)
-};
-
-static const struct dce_abm_registers abm_regs = {
- ABM_DCN20_REG_LIST()
-};
-
-static const struct dce_abm_shift abm_shift = {
- ABM_MASK_SH_LIST_DCN20(__SHIFT)
-};
-
-static const struct dce_abm_mask abm_mask = {
- ABM_MASK_SH_LIST_DCN20(_MASK)
-};
-
-#define audio_regs(id)\
-[id] = {\
- AUD_COMMON_REG_LIST(id)\
-}
-
-static const struct dce_audio_registers audio_regs[] = {
- audio_regs(0),
- audio_regs(1),
- audio_regs(2),
- audio_regs(3),
- audio_regs(4),
- audio_regs(5),
- audio_regs(6),
-};
-
-#define DCE120_AUD_COMMON_MASK_SH_LIST(mask_sh)\
- SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_INDEX, AZALIA_ENDPOINT_REG_INDEX, mask_sh),\
- SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_DATA, AZALIA_ENDPOINT_REG_DATA, mask_sh),\
- AUD_COMMON_MASK_SH_LIST_BASE(mask_sh)
-
-static const struct dce_audio_shift audio_shift = {
- DCE120_AUD_COMMON_MASK_SH_LIST(__SHIFT)
-};
-
-static const struct dce_audio_mask audio_mask = {
- DCE120_AUD_COMMON_MASK_SH_LIST(_MASK)
-};
-
-#define stream_enc_regs(id)\
-[id] = {\
- SE_DCN2_REG_LIST(id)\
-}
-
-static const struct dcn10_stream_enc_registers stream_enc_regs[] = {
- stream_enc_regs(0),
- stream_enc_regs(1),
- stream_enc_regs(2),
- stream_enc_regs(3),
- stream_enc_regs(4),
- stream_enc_regs(5),
-};
-
-static const struct dcn10_stream_encoder_shift se_shift = {
- SE_COMMON_MASK_SH_LIST_DCN20(__SHIFT)
-};
-
-static const struct dcn10_stream_encoder_mask se_mask = {
- SE_COMMON_MASK_SH_LIST_DCN20(_MASK)
-};
-
-
-#define aux_regs(id)\
-[id] = {\
- DCN2_AUX_REG_LIST(id)\
-}
-
-static const struct dcn10_link_enc_aux_registers link_enc_aux_regs[] = {
- aux_regs(0),
- aux_regs(1),
- aux_regs(2),
- aux_regs(3),
- aux_regs(4),
- aux_regs(5)
-};
-
-#define hpd_regs(id)\
-[id] = {\
- HPD_REG_LIST(id)\
-}
-
-static const struct dcn10_link_enc_hpd_registers link_enc_hpd_regs[] = {
- hpd_regs(0),
- hpd_regs(1),
- hpd_regs(2),
- hpd_regs(3),
- hpd_regs(4),
- hpd_regs(5)
-};
-
-#define link_regs(id, phyid)\
-[id] = {\
- LE_DCN10_REG_LIST(id), \
- UNIPHY_DCN2_REG_LIST(phyid), \
- DPCS_DCN2_REG_LIST(id), \
- SRI(DP_DPHY_INTERNAL_CTRL, DP, id) \
-}
-
-static const struct dcn10_link_enc_registers link_enc_regs[] = {
- link_regs(0, A),
- link_regs(1, B),
- link_regs(2, C),
- link_regs(3, D),
- link_regs(4, E),
- link_regs(5, F)
-};
-
-static const struct dcn10_link_enc_shift le_shift = {
- LINK_ENCODER_MASK_SH_LIST_DCN20(__SHIFT),\
- DPCS_DCN2_MASK_SH_LIST(__SHIFT)
-};
-
-static const struct dcn10_link_enc_mask le_mask = {
- LINK_ENCODER_MASK_SH_LIST_DCN20(_MASK),\
- DPCS_DCN2_MASK_SH_LIST(_MASK)
-};
-
-static const struct dce_panel_cntl_registers panel_cntl_regs[] = {
- { DCN_PANEL_CNTL_REG_LIST() }
-};
-
-static const struct dce_panel_cntl_shift panel_cntl_shift = {
- DCE_PANEL_CNTL_MASK_SH_LIST(__SHIFT)
-};
-
-static const struct dce_panel_cntl_mask panel_cntl_mask = {
- DCE_PANEL_CNTL_MASK_SH_LIST(_MASK)
-};
-
-#define ipp_regs(id)\
-[id] = {\
- IPP_REG_LIST_DCN20(id),\
-}
-
-static const struct dcn10_ipp_registers ipp_regs[] = {
- ipp_regs(0),
- ipp_regs(1),
- ipp_regs(2),
- ipp_regs(3),
- ipp_regs(4),
- ipp_regs(5),
-};
-
-static const struct dcn10_ipp_shift ipp_shift = {
- IPP_MASK_SH_LIST_DCN20(__SHIFT)
-};
-
-static const struct dcn10_ipp_mask ipp_mask = {
- IPP_MASK_SH_LIST_DCN20(_MASK),
-};
-
-#define opp_regs(id)\
-[id] = {\
- OPP_REG_LIST_DCN20(id),\
-}
-
-static const struct dcn20_opp_registers opp_regs[] = {
- opp_regs(0),
- opp_regs(1),
- opp_regs(2),
- opp_regs(3),
- opp_regs(4),
- opp_regs(5),
-};
-
-static const struct dcn20_opp_shift opp_shift = {
- OPP_MASK_SH_LIST_DCN20(__SHIFT)
-};
-
-static const struct dcn20_opp_mask opp_mask = {
- OPP_MASK_SH_LIST_DCN20(_MASK)
-};
-
-#define aux_engine_regs(id)\
-[id] = {\
- AUX_COMMON_REG_LIST0(id), \
- .AUXN_IMPCAL = 0, \
- .AUXP_IMPCAL = 0, \
- .AUX_RESET_MASK = DP_AUX0_AUX_CONTROL__AUX_RESET_MASK, \
-}
-
-static const struct dce110_aux_registers aux_engine_regs[] = {
- aux_engine_regs(0),
- aux_engine_regs(1),
- aux_engine_regs(2),
- aux_engine_regs(3),
- aux_engine_regs(4),
- aux_engine_regs(5)
-};
-
-#define tf_regs(id)\
-[id] = {\
- TF_REG_LIST_DCN20(id),\
- TF_REG_LIST_DCN20_COMMON_APPEND(id),\
-}
-
-static const struct dcn2_dpp_registers tf_regs[] = {
- tf_regs(0),
- tf_regs(1),
- tf_regs(2),
- tf_regs(3),
- tf_regs(4),
- tf_regs(5),
-};
-
-static const struct dcn2_dpp_shift tf_shift = {
- TF_REG_LIST_SH_MASK_DCN20(__SHIFT),
- TF_DEBUG_REG_LIST_SH_DCN20
-};
-
-static const struct dcn2_dpp_mask tf_mask = {
- TF_REG_LIST_SH_MASK_DCN20(_MASK),
- TF_DEBUG_REG_LIST_MASK_DCN20
-};
-
-#define dwbc_regs_dcn2(id)\
-[id] = {\
- DWBC_COMMON_REG_LIST_DCN2_0(id),\
- }
-
-static const struct dcn20_dwbc_registers dwbc20_regs[] = {
- dwbc_regs_dcn2(0),
-};
-
-static const struct dcn20_dwbc_shift dwbc20_shift = {
- DWBC_COMMON_MASK_SH_LIST_DCN2_0(__SHIFT)
-};
-
-static const struct dcn20_dwbc_mask dwbc20_mask = {
- DWBC_COMMON_MASK_SH_LIST_DCN2_0(_MASK)
-};
-
-#define mcif_wb_regs_dcn2(id)\
-[id] = {\
- MCIF_WB_COMMON_REG_LIST_DCN2_0(id),\
- }
-
-static const struct dcn20_mmhubbub_registers mcif_wb20_regs[] = {
- mcif_wb_regs_dcn2(0),
-};
-
-static const struct dcn20_mmhubbub_shift mcif_wb20_shift = {
- MCIF_WB_COMMON_MASK_SH_LIST_DCN2_0(__SHIFT)
-};
-
-static const struct dcn20_mmhubbub_mask mcif_wb20_mask = {
- MCIF_WB_COMMON_MASK_SH_LIST_DCN2_0(_MASK)
-};
-
-static const struct dcn20_mpc_registers mpc_regs = {
- MPC_REG_LIST_DCN2_0(0),
- MPC_REG_LIST_DCN2_0(1),
- MPC_REG_LIST_DCN2_0(2),
- MPC_REG_LIST_DCN2_0(3),
- MPC_REG_LIST_DCN2_0(4),
- MPC_REG_LIST_DCN2_0(5),
- MPC_OUT_MUX_REG_LIST_DCN2_0(0),
- MPC_OUT_MUX_REG_LIST_DCN2_0(1),
- MPC_OUT_MUX_REG_LIST_DCN2_0(2),
- MPC_OUT_MUX_REG_LIST_DCN2_0(3),
- MPC_OUT_MUX_REG_LIST_DCN2_0(4),
- MPC_OUT_MUX_REG_LIST_DCN2_0(5),
- MPC_DBG_REG_LIST_DCN2_0()
-};
-
-static const struct dcn20_mpc_shift mpc_shift = {
- MPC_COMMON_MASK_SH_LIST_DCN2_0(__SHIFT),
- MPC_DEBUG_REG_LIST_SH_DCN20
-};
-
-static const struct dcn20_mpc_mask mpc_mask = {
- MPC_COMMON_MASK_SH_LIST_DCN2_0(_MASK),
- MPC_DEBUG_REG_LIST_MASK_DCN20
-};
-
-#define tg_regs(id)\
-[id] = {TG_COMMON_REG_LIST_DCN2_0(id)}
-
-
-static const struct dcn_optc_registers tg_regs[] = {
- tg_regs(0),
- tg_regs(1),
- tg_regs(2),
- tg_regs(3),
- tg_regs(4),
- tg_regs(5)
-};
-
-static const struct dcn_optc_shift tg_shift = {
- TG_COMMON_MASK_SH_LIST_DCN2_0(__SHIFT)
-};
-
-static const struct dcn_optc_mask tg_mask = {
- TG_COMMON_MASK_SH_LIST_DCN2_0(_MASK)
-};
-
-#define hubp_regs(id)\
-[id] = {\
- HUBP_REG_LIST_DCN20(id)\
-}
-
-static const struct dcn_hubp2_registers hubp_regs[] = {
- hubp_regs(0),
- hubp_regs(1),
- hubp_regs(2),
- hubp_regs(3),
- hubp_regs(4),
- hubp_regs(5)
-};
-
-static const struct dcn_hubp2_shift hubp_shift = {
- HUBP_MASK_SH_LIST_DCN20(__SHIFT)
-};
-
-static const struct dcn_hubp2_mask hubp_mask = {
- HUBP_MASK_SH_LIST_DCN20(_MASK)
-};
-
-static const struct dcn_hubbub_registers hubbub_reg = {
- HUBBUB_REG_LIST_DCN20(0)
-};
-
-static const struct dcn_hubbub_shift hubbub_shift = {
- HUBBUB_MASK_SH_LIST_DCN20(__SHIFT)
-};
-
-static const struct dcn_hubbub_mask hubbub_mask = {
- HUBBUB_MASK_SH_LIST_DCN20(_MASK)
-};
-
-#define vmid_regs(id)\
-[id] = {\
- DCN20_VMID_REG_LIST(id)\
-}
-
-static const struct dcn_vmid_registers vmid_regs[] = {
- vmid_regs(0),
- vmid_regs(1),
- vmid_regs(2),
- vmid_regs(3),
- vmid_regs(4),
- vmid_regs(5),
- vmid_regs(6),
- vmid_regs(7),
- vmid_regs(8),
- vmid_regs(9),
- vmid_regs(10),
- vmid_regs(11),
- vmid_regs(12),
- vmid_regs(13),
- vmid_regs(14),
- vmid_regs(15)
-};
-
-static const struct dcn20_vmid_shift vmid_shifts = {
- DCN20_VMID_MASK_SH_LIST(__SHIFT)
-};
-
-static const struct dcn20_vmid_mask vmid_masks = {
- DCN20_VMID_MASK_SH_LIST(_MASK)
-};
-
-static const struct dce110_aux_registers_shift aux_shift = {
- DCN_AUX_MASK_SH_LIST(__SHIFT)
-};
-
-static const struct dce110_aux_registers_mask aux_mask = {
- DCN_AUX_MASK_SH_LIST(_MASK)
-};
-
-static int map_transmitter_id_to_phy_instance(
- enum transmitter transmitter)
-{
- switch (transmitter) {
- case TRANSMITTER_UNIPHY_A:
- return 0;
- break;
- case TRANSMITTER_UNIPHY_B:
- return 1;
- break;
- case TRANSMITTER_UNIPHY_C:
- return 2;
- break;
- case TRANSMITTER_UNIPHY_D:
- return 3;
- break;
- case TRANSMITTER_UNIPHY_E:
- return 4;
- break;
- case TRANSMITTER_UNIPHY_F:
- return 5;
- break;
- default:
- ASSERT(0);
- return 0;
- }
-}
-
-#define dsc_regsDCN20(id)\
-[id] = {\
- DSC_REG_LIST_DCN20(id)\
-}
-
-static const struct dcn20_dsc_registers dsc_regs[] = {
- dsc_regsDCN20(0),
- dsc_regsDCN20(1),
- dsc_regsDCN20(2),
- dsc_regsDCN20(3),
- dsc_regsDCN20(4),
- dsc_regsDCN20(5)
-};
-
-static const struct dcn20_dsc_shift dsc_shift = {
- DSC_REG_LIST_SH_MASK_DCN20(__SHIFT)
-};
-
-static const struct dcn20_dsc_mask dsc_mask = {
- DSC_REG_LIST_SH_MASK_DCN20(_MASK)
-};
-
-static const struct dccg_registers dccg_regs = {
- DCCG_REG_LIST_DCN2()
-};
-
-static const struct dccg_shift dccg_shift = {
- DCCG_MASK_SH_LIST_DCN2(__SHIFT)
-};
-
-static const struct dccg_mask dccg_mask = {
- DCCG_MASK_SH_LIST_DCN2(_MASK)
-};
-
-static const struct resource_caps res_cap_nv10 = {
- .num_timing_generator = 6,
- .num_opp = 6,
- .num_video_plane = 6,
- .num_audio = 7,
- .num_stream_encoder = 6,
- .num_pll = 6,
- .num_dwb = 1,
- .num_ddc = 6,
- .num_vmid = 16,
- .num_dsc = 6,
-};
-
-static const struct dc_plane_cap plane_cap = {
- .type = DC_PLANE_TYPE_DCN_UNIVERSAL,
- .per_pixel_alpha = true,
-
- .pixel_format_support = {
- .argb8888 = true,
- .nv12 = true,
- .fp16 = true,
- .p010 = true
- },
-
- .max_upscale_factor = {
- .argb8888 = 16000,
- .nv12 = 16000,
- .fp16 = 1
- },
-
- .max_downscale_factor = {
- .argb8888 = 250,
- .nv12 = 250,
- .fp16 = 1
- },
- 16,
- 16
-};
-static const struct resource_caps res_cap_nv14 = {
- .num_timing_generator = 5,
- .num_opp = 5,
- .num_video_plane = 5,
- .num_audio = 6,
- .num_stream_encoder = 5,
- .num_pll = 5,
- .num_dwb = 1,
- .num_ddc = 5,
- .num_vmid = 16,
- .num_dsc = 5,
-};
-
-static const struct dc_debug_options debug_defaults_drv = {
- .disable_dmcu = false,
- .force_abm_enable = false,
- .timing_trace = false,
- .clock_trace = true,
- .disable_pplib_clock_request = true,
- .pipe_split_policy = MPC_SPLIT_AVOID_MULT_DISP,
- .force_single_disp_pipe_split = false,
- .disable_dcc = DCC_ENABLE,
- .vsr_support = true,
- .performance_trace = false,
- .max_downscale_src_width = 5120,/*upto 5K*/
- .disable_pplib_wm_range = false,
- .scl_reset_length10 = true,
- .sanity_checks = false,
- .underflow_assert_delay_us = 0xFFFFFFFF,
- .enable_legacy_fast_update = true,
- .using_dml2 = false,
-};
-
-void dcn20_dpp_destroy(struct dpp **dpp)
-{
- kfree(TO_DCN20_DPP(*dpp));
- *dpp = NULL;
-}
-
-struct dpp *dcn20_dpp_create(
- struct dc_context *ctx,
- uint32_t inst)
-{
- struct dcn20_dpp *dpp =
- kzalloc(sizeof(struct dcn20_dpp), GFP_ATOMIC);
-
- if (!dpp)
- return NULL;
-
- if (dpp2_construct(dpp, ctx, inst,
- &tf_regs[inst], &tf_shift, &tf_mask))
- return &dpp->base;
-
- BREAK_TO_DEBUGGER();
- kfree(dpp);
- return NULL;
-}
-
-struct input_pixel_processor *dcn20_ipp_create(
- struct dc_context *ctx, uint32_t inst)
-{
- struct dcn10_ipp *ipp =
- kzalloc(sizeof(struct dcn10_ipp), GFP_ATOMIC);
-
- if (!ipp) {
- BREAK_TO_DEBUGGER();
- return NULL;
- }
-
- dcn20_ipp_construct(ipp, ctx, inst,
- &ipp_regs[inst], &ipp_shift, &ipp_mask);
- return &ipp->base;
-}
-
-
-struct output_pixel_processor *dcn20_opp_create(
- struct dc_context *ctx, uint32_t inst)
-{
- struct dcn20_opp *opp =
- kzalloc(sizeof(struct dcn20_opp), GFP_ATOMIC);
-
- if (!opp) {
- BREAK_TO_DEBUGGER();
- return NULL;
- }
-
- dcn20_opp_construct(opp, ctx, inst,
- &opp_regs[inst], &opp_shift, &opp_mask);
- return &opp->base;
-}
-
-struct dce_aux *dcn20_aux_engine_create(
- struct dc_context *ctx,
- uint32_t inst)
-{
- struct aux_engine_dce110 *aux_engine =
- kzalloc(sizeof(struct aux_engine_dce110), GFP_ATOMIC);
-
- if (!aux_engine)
- return NULL;
-
- dce110_aux_engine_construct(aux_engine, ctx, inst,
- SW_AUX_TIMEOUT_PERIOD_MULTIPLIER * AUX_TIMEOUT_PERIOD,
- &aux_engine_regs[inst],
- &aux_mask,
- &aux_shift,
- ctx->dc->caps.extended_aux_timeout_support);
-
- return &aux_engine->base;
-}
-#define i2c_inst_regs(id) { I2C_HW_ENGINE_COMMON_REG_LIST(id) }
-
-static const struct dce_i2c_registers i2c_hw_regs[] = {
- i2c_inst_regs(1),
- i2c_inst_regs(2),
- i2c_inst_regs(3),
- i2c_inst_regs(4),
- i2c_inst_regs(5),
- i2c_inst_regs(6),
-};
-
-static const struct dce_i2c_shift i2c_shifts = {
- I2C_COMMON_MASK_SH_LIST_DCN2(__SHIFT)
-};
-
-static const struct dce_i2c_mask i2c_masks = {
- I2C_COMMON_MASK_SH_LIST_DCN2(_MASK)
-};
-
-struct dce_i2c_hw *dcn20_i2c_hw_create(
- struct dc_context *ctx,
- uint32_t inst)
-{
- struct dce_i2c_hw *dce_i2c_hw =
- kzalloc(sizeof(struct dce_i2c_hw), GFP_ATOMIC);
-
- if (!dce_i2c_hw)
- return NULL;
-
- dcn2_i2c_hw_construct(dce_i2c_hw, ctx, inst,
- &i2c_hw_regs[inst], &i2c_shifts, &i2c_masks);
-
- return dce_i2c_hw;
-}
-struct mpc *dcn20_mpc_create(struct dc_context *ctx)
-{
- struct dcn20_mpc *mpc20 = kzalloc(sizeof(struct dcn20_mpc),
- GFP_ATOMIC);
-
- if (!mpc20)
- return NULL;
-
- dcn20_mpc_construct(mpc20, ctx,
- &mpc_regs,
- &mpc_shift,
- &mpc_mask,
- 6);
-
- return &mpc20->base;
-}
-
-struct hubbub *dcn20_hubbub_create(struct dc_context *ctx)
-{
- int i;
- struct dcn20_hubbub *hubbub = kzalloc(sizeof(struct dcn20_hubbub),
- GFP_ATOMIC);
-
- if (!hubbub)
- return NULL;
-
- hubbub2_construct(hubbub, ctx,
- &hubbub_reg,
- &hubbub_shift,
- &hubbub_mask);
-
- for (i = 0; i < res_cap_nv10.num_vmid; i++) {
- struct dcn20_vmid *vmid = &hubbub->vmid[i];
-
- vmid->ctx = ctx;
-
- vmid->regs = &vmid_regs[i];
- vmid->shifts = &vmid_shifts;
- vmid->masks = &vmid_masks;
- }
-
- return &hubbub->base;
-}
-
-struct timing_generator *dcn20_timing_generator_create(
- struct dc_context *ctx,
- uint32_t instance)
-{
- struct optc *tgn10 =
- kzalloc(sizeof(struct optc), GFP_ATOMIC);
-
- if (!tgn10)
- return NULL;
-
- tgn10->base.inst = instance;
- tgn10->base.ctx = ctx;
-
- tgn10->tg_regs = &tg_regs[instance];
- tgn10->tg_shift = &tg_shift;
- tgn10->tg_mask = &tg_mask;
-
- dcn20_timing_generator_init(tgn10);
-
- return &tgn10->base;
-}
-
-static const struct encoder_feature_support link_enc_feature = {
- .max_hdmi_deep_color = COLOR_DEPTH_121212,
- .max_hdmi_pixel_clock = 600000,
- .hdmi_ycbcr420_supported = true,
- .dp_ycbcr420_supported = true,
- .fec_supported = true,
- .flags.bits.IS_HBR2_CAPABLE = true,
- .flags.bits.IS_HBR3_CAPABLE = true,
- .flags.bits.IS_TPS3_CAPABLE = true,
- .flags.bits.IS_TPS4_CAPABLE = true
-};
-
-struct link_encoder *dcn20_link_encoder_create(
- struct dc_context *ctx,
- const struct encoder_init_data *enc_init_data)
-{
- struct dcn20_link_encoder *enc20 =
- kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL);
- int link_regs_id;
-
- if (!enc20)
- return NULL;
-
- link_regs_id =
- map_transmitter_id_to_phy_instance(enc_init_data->transmitter);
-
- dcn20_link_encoder_construct(enc20,
- enc_init_data,
- &link_enc_feature,
- &link_enc_regs[link_regs_id],
- &link_enc_aux_regs[enc_init_data->channel - 1],
- &link_enc_hpd_regs[enc_init_data->hpd_source],
- &le_shift,
- &le_mask);
-
- return &enc20->enc10.base;
-}
-
-static struct panel_cntl *dcn20_panel_cntl_create(const struct panel_cntl_init_data *init_data)
-{
- struct dce_panel_cntl *panel_cntl =
- kzalloc(sizeof(struct dce_panel_cntl), GFP_KERNEL);
-
- if (!panel_cntl)
- return NULL;
-
- dce_panel_cntl_construct(panel_cntl,
- init_data,
- &panel_cntl_regs[init_data->inst],
- &panel_cntl_shift,
- &panel_cntl_mask);
-
- return &panel_cntl->base;
-}
-
-static struct clock_source *dcn20_clock_source_create(
- struct dc_context *ctx,
- struct dc_bios *bios,
- enum clock_source_id id,
- const struct dce110_clk_src_regs *regs,
- bool dp_clk_src)
-{
- struct dce110_clk_src *clk_src =
- kzalloc(sizeof(struct dce110_clk_src), GFP_ATOMIC);
-
- if (!clk_src)
- return NULL;
-
- if (dcn20_clk_src_construct(clk_src, ctx, bios, id,
- regs, &cs_shift, &cs_mask)) {
- clk_src->base.dp_clk_src = dp_clk_src;
- return &clk_src->base;
- }
-
- kfree(clk_src);
- BREAK_TO_DEBUGGER();
- return NULL;
-}
-
-static void read_dce_straps(
- struct dc_context *ctx,
- struct resource_straps *straps)
-{
- generic_reg_get(ctx, mmDC_PINSTRAPS + BASE(mmDC_PINSTRAPS_BASE_IDX),
- FN(DC_PINSTRAPS, DC_PINSTRAPS_AUDIO), &straps->dc_pinstraps_audio);
-}
-
-static struct audio *dcn20_create_audio(
- struct dc_context *ctx, unsigned int inst)
-{
- return dce_audio_create(ctx, inst,
- &audio_regs[inst], &audio_shift, &audio_mask);
-}
-
-struct stream_encoder *dcn20_stream_encoder_create(
- enum engine_id eng_id,
- struct dc_context *ctx)
-{
- struct dcn10_stream_encoder *enc1 =
- kzalloc(sizeof(struct dcn10_stream_encoder), GFP_KERNEL);
-
- if (!enc1)
- return NULL;
-
- if (ASICREV_IS_NAVI14_M(ctx->asic_id.hw_internal_rev)) {
- if (eng_id >= ENGINE_ID_DIGD)
- eng_id++;
- }
-
- dcn20_stream_encoder_construct(enc1, ctx, ctx->dc_bios, eng_id,
- &stream_enc_regs[eng_id],
- &se_shift, &se_mask);
-
- return &enc1->base;
-}
-
-static const struct dce_hwseq_registers hwseq_reg = {
- HWSEQ_DCN2_REG_LIST()
-};
-
-static const struct dce_hwseq_shift hwseq_shift = {
- HWSEQ_DCN2_MASK_SH_LIST(__SHIFT)
-};
-
-static const struct dce_hwseq_mask hwseq_mask = {
- HWSEQ_DCN2_MASK_SH_LIST(_MASK)
-};
-
-struct dce_hwseq *dcn20_hwseq_create(
- struct dc_context *ctx)
-{
- struct dce_hwseq *hws = kzalloc(sizeof(struct dce_hwseq), GFP_KERNEL);
-
- if (hws) {
- hws->ctx = ctx;
- hws->regs = &hwseq_reg;
- hws->shifts = &hwseq_shift;
- hws->masks = &hwseq_mask;
- }
- return hws;
-}
-
-static const struct resource_create_funcs res_create_funcs = {
- .read_dce_straps = read_dce_straps,
- .create_audio = dcn20_create_audio,
- .create_stream_encoder = dcn20_stream_encoder_create,
- .create_hwseq = dcn20_hwseq_create,
-};
-
-static void dcn20_pp_smu_destroy(struct pp_smu_funcs **pp_smu);
-
-void dcn20_clock_source_destroy(struct clock_source **clk_src)
-{
- kfree(TO_DCE110_CLK_SRC(*clk_src));
- *clk_src = NULL;
-}
-
-
-struct display_stream_compressor *dcn20_dsc_create(
- struct dc_context *ctx, uint32_t inst)
-{
- struct dcn20_dsc *dsc =
- kzalloc(sizeof(struct dcn20_dsc), GFP_ATOMIC);
-
- if (!dsc) {
- BREAK_TO_DEBUGGER();
- return NULL;
- }
-
- dsc2_construct(dsc, ctx, inst, &dsc_regs[inst], &dsc_shift, &dsc_mask);
- return &dsc->base;
-}
-
-void dcn20_dsc_destroy(struct display_stream_compressor **dsc)
-{
- kfree(container_of(*dsc, struct dcn20_dsc, base));
- *dsc = NULL;
-}
-
-
-static void dcn20_resource_destruct(struct dcn20_resource_pool *pool)
-{
- unsigned int i;
-
- for (i = 0; i < pool->base.stream_enc_count; i++) {
- if (pool->base.stream_enc[i] != NULL) {
- kfree(DCN10STRENC_FROM_STRENC(pool->base.stream_enc[i]));
- pool->base.stream_enc[i] = NULL;
- }
- }
-
- for (i = 0; i < pool->base.res_cap->num_dsc; i++) {
- if (pool->base.dscs[i] != NULL)
- dcn20_dsc_destroy(&pool->base.dscs[i]);
- }
-
- if (pool->base.mpc != NULL) {
- kfree(TO_DCN20_MPC(pool->base.mpc));
- pool->base.mpc = NULL;
- }
- if (pool->base.hubbub != NULL) {
- kfree(pool->base.hubbub);
- pool->base.hubbub = NULL;
- }
- for (i = 0; i < pool->base.pipe_count; i++) {
- if (pool->base.dpps[i] != NULL)
- dcn20_dpp_destroy(&pool->base.dpps[i]);
-
- if (pool->base.ipps[i] != NULL)
- pool->base.ipps[i]->funcs->ipp_destroy(&pool->base.ipps[i]);
-
- if (pool->base.hubps[i] != NULL) {
- kfree(TO_DCN20_HUBP(pool->base.hubps[i]));
- pool->base.hubps[i] = NULL;
- }
-
- if (pool->base.irqs != NULL) {
- dal_irq_service_destroy(&pool->base.irqs);
- }
- }
-
- for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
- if (pool->base.engines[i] != NULL)
- dce110_engine_destroy(&pool->base.engines[i]);
- if (pool->base.hw_i2cs[i] != NULL) {
- kfree(pool->base.hw_i2cs[i]);
- pool->base.hw_i2cs[i] = NULL;
- }
- if (pool->base.sw_i2cs[i] != NULL) {
- kfree(pool->base.sw_i2cs[i]);
- pool->base.sw_i2cs[i] = NULL;
- }
- }
-
- for (i = 0; i < pool->base.res_cap->num_opp; i++) {
- if (pool->base.opps[i] != NULL)
- pool->base.opps[i]->funcs->opp_destroy(&pool->base.opps[i]);
- }
-
- for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) {
- if (pool->base.timing_generators[i] != NULL) {
- kfree(DCN10TG_FROM_TG(pool->base.timing_generators[i]));
- pool->base.timing_generators[i] = NULL;
- }
- }
-
- for (i = 0; i < pool->base.res_cap->num_dwb; i++) {
- if (pool->base.dwbc[i] != NULL) {
- kfree(TO_DCN20_DWBC(pool->base.dwbc[i]));
- pool->base.dwbc[i] = NULL;
- }
- if (pool->base.mcif_wb[i] != NULL) {
- kfree(TO_DCN20_MMHUBBUB(pool->base.mcif_wb[i]));
- pool->base.mcif_wb[i] = NULL;
- }
- }
-
- for (i = 0; i < pool->base.audio_count; i++) {
- if (pool->base.audios[i])
- dce_aud_destroy(&pool->base.audios[i]);
- }
-
- for (i = 0; i < pool->base.clk_src_count; i++) {
- if (pool->base.clock_sources[i] != NULL) {
- dcn20_clock_source_destroy(&pool->base.clock_sources[i]);
- pool->base.clock_sources[i] = NULL;
- }
- }
-
- if (pool->base.dp_clock_source != NULL) {
- dcn20_clock_source_destroy(&pool->base.dp_clock_source);
- pool->base.dp_clock_source = NULL;
- }
-
-
- if (pool->base.abm != NULL)
- dce_abm_destroy(&pool->base.abm);
-
- if (pool->base.dmcu != NULL)
- dce_dmcu_destroy(&pool->base.dmcu);
-
- if (pool->base.dccg != NULL)
- dcn_dccg_destroy(&pool->base.dccg);
-
- if (pool->base.pp_smu != NULL)
- dcn20_pp_smu_destroy(&pool->base.pp_smu);
-
- if (pool->base.oem_device != NULL) {
- struct dc *dc = pool->base.oem_device->ctx->dc;
-
- dc->link_srv->destroy_ddc_service(&pool->base.oem_device);
- }
-}
-
-struct hubp *dcn20_hubp_create(
- struct dc_context *ctx,
- uint32_t inst)
-{
- struct dcn20_hubp *hubp2 =
- kzalloc(sizeof(struct dcn20_hubp), GFP_ATOMIC);
-
- if (!hubp2)
- return NULL;
-
- if (hubp2_construct(hubp2, ctx, inst,
- &hubp_regs[inst], &hubp_shift, &hubp_mask))
- return &hubp2->base;
-
- BREAK_TO_DEBUGGER();
- kfree(hubp2);
- return NULL;
-}
-
-static void get_pixel_clock_parameters(
- struct pipe_ctx *pipe_ctx,
- struct pixel_clk_params *pixel_clk_params)
-{
- const struct dc_stream_state *stream = pipe_ctx->stream;
- struct pipe_ctx *odm_pipe;
- int opp_cnt = 1;
- struct dc_link *link = stream->link;
- struct link_encoder *link_enc = NULL;
- struct dc *dc = pipe_ctx->stream->ctx->dc;
- struct dce_hwseq *hws = dc->hwseq;
-
- for (odm_pipe = pipe_ctx->next_odm_pipe; odm_pipe; odm_pipe = odm_pipe->next_odm_pipe)
- opp_cnt++;
-
- pixel_clk_params->requested_pix_clk_100hz = stream->timing.pix_clk_100hz;
-
- link_enc = link_enc_cfg_get_link_enc(link);
- if (link_enc)
- pixel_clk_params->encoder_object_id = link_enc->id;
-
- pixel_clk_params->signal_type = pipe_ctx->stream->signal;
- pixel_clk_params->controller_id = pipe_ctx->stream_res.tg->inst + 1;
- /* TODO: un-hardcode*/
- /* TODO - DP2.0 HW: calculate requested_sym_clk for UHBR rates */
- pixel_clk_params->requested_sym_clk = LINK_RATE_LOW *
- LINK_RATE_REF_FREQ_IN_KHZ;
- pixel_clk_params->flags.ENABLE_SS = 0;
- pixel_clk_params->color_depth =
- stream->timing.display_color_depth;
- pixel_clk_params->flags.DISPLAY_BLANKED = 1;
- pixel_clk_params->pixel_encoding = stream->timing.pixel_encoding;
-
- if (stream->timing.pixel_encoding == PIXEL_ENCODING_YCBCR422)
- pixel_clk_params->color_depth = COLOR_DEPTH_888;
-
- if (opp_cnt == 4)
- pixel_clk_params->requested_pix_clk_100hz /= 4;
- else if (optc2_is_two_pixels_per_containter(&stream->timing) || opp_cnt == 2)
- pixel_clk_params->requested_pix_clk_100hz /= 2;
- else if (hws->funcs.is_dp_dig_pixel_rate_div_policy) {
- if (hws->funcs.is_dp_dig_pixel_rate_div_policy(pipe_ctx))
- pixel_clk_params->requested_pix_clk_100hz /= 2;
- }
-
- if (stream->timing.timing_3d_format == TIMING_3D_FORMAT_HW_FRAME_PACKING)
- pixel_clk_params->requested_pix_clk_100hz *= 2;
-
-}
-
-static void build_clamping_params(struct dc_stream_state *stream)
-{
- stream->clamping.clamping_level = CLAMPING_FULL_RANGE;
- stream->clamping.c_depth = stream->timing.display_color_depth;
- stream->clamping.pixel_encoding = stream->timing.pixel_encoding;
-}
-
-void dcn20_build_pipe_pix_clk_params(struct pipe_ctx *pipe_ctx)
-{
- get_pixel_clock_parameters(pipe_ctx, &pipe_ctx->stream_res.pix_clk_params);
- pipe_ctx->clock_source->funcs->get_pix_clk_dividers(
- pipe_ctx->clock_source,
- &pipe_ctx->stream_res.pix_clk_params,
- &pipe_ctx->pll_settings);
-}
-
-static enum dc_status build_pipe_hw_param(struct pipe_ctx *pipe_ctx)
-{
-
- dcn20_build_pipe_pix_clk_params(pipe_ctx);
-
- pipe_ctx->stream->clamping.pixel_encoding = pipe_ctx->stream->timing.pixel_encoding;
-
- resource_build_bit_depth_reduction_params(pipe_ctx->stream,
- &pipe_ctx->stream->bit_depth_params);
- build_clamping_params(pipe_ctx->stream);
-
- return DC_OK;
-}
-
-enum dc_status dcn20_build_mapped_resource(const struct dc *dc, struct dc_state *context, struct dc_stream_state *stream)
-{
- enum dc_status status = DC_OK;
- struct pipe_ctx *pipe_ctx = resource_get_otg_master_for_stream(&context->res_ctx, stream);
-
- if (!pipe_ctx)
- return DC_ERROR_UNEXPECTED;
-
-
- status = build_pipe_hw_param(pipe_ctx);
-
- return status;
-}
-
-
-void dcn20_acquire_dsc(const struct dc *dc,
- struct resource_context *res_ctx,
- struct display_stream_compressor **dsc,
- int pipe_idx)
-{
- int i;
- const struct resource_pool *pool = dc->res_pool;
- struct display_stream_compressor *dsc_old = dc->current_state->res_ctx.pipe_ctx[pipe_idx].stream_res.dsc;
-
- ASSERT(*dsc == NULL); /* If this ASSERT fails, dsc was not released properly */
- *dsc = NULL;
-
- /* Always do 1-to-1 mapping when number of DSCs is same as number of pipes */
- if (pool->res_cap->num_dsc == pool->res_cap->num_opp) {
- *dsc = pool->dscs[pipe_idx];
- res_ctx->is_dsc_acquired[pipe_idx] = true;
- return;
- }
-
- /* Return old DSC to avoid the need for re-programming */
- if (dsc_old && !res_ctx->is_dsc_acquired[dsc_old->inst]) {
- *dsc = dsc_old;
- res_ctx->is_dsc_acquired[dsc_old->inst] = true;
- return ;
- }
-
- /* Find first free DSC */
- for (i = 0; i < pool->res_cap->num_dsc; i++)
- if (!res_ctx->is_dsc_acquired[i]) {
- *dsc = pool->dscs[i];
- res_ctx->is_dsc_acquired[i] = true;
- break;
- }
-}
-
-void dcn20_release_dsc(struct resource_context *res_ctx,
- const struct resource_pool *pool,
- struct display_stream_compressor **dsc)
-{
- int i;
-
- for (i = 0; i < pool->res_cap->num_dsc; i++)
- if (pool->dscs[i] == *dsc) {
- res_ctx->is_dsc_acquired[i] = false;
- *dsc = NULL;
- break;
- }
-}
-
-
-
-enum dc_status dcn20_add_dsc_to_stream_resource(struct dc *dc,
- struct dc_state *dc_ctx,
- struct dc_stream_state *dc_stream)
-{
- enum dc_status result = DC_OK;
- int i;
-
- /* Get a DSC if required and available */
- for (i = 0; i < dc->res_pool->pipe_count; i++) {
- struct pipe_ctx *pipe_ctx = &dc_ctx->res_ctx.pipe_ctx[i];
-
- if (pipe_ctx->top_pipe)
- continue;
-
- if (pipe_ctx->stream != dc_stream)
- continue;
-
- if (pipe_ctx->stream_res.dsc)
- continue;
-
- dcn20_acquire_dsc(dc, &dc_ctx->res_ctx, &pipe_ctx->stream_res.dsc, i);
-
- /* The number of DSCs can be less than the number of pipes */
- if (!pipe_ctx->stream_res.dsc) {
- result = DC_NO_DSC_RESOURCE;
- }
-
- break;
- }
-
- return result;
-}
-
-
-static enum dc_status remove_dsc_from_stream_resource(struct dc *dc,
- struct dc_state *new_ctx,
- struct dc_stream_state *dc_stream)
-{
- struct pipe_ctx *pipe_ctx = NULL;
- int i;
-
- for (i = 0; i < MAX_PIPES; i++) {
- if (new_ctx->res_ctx.pipe_ctx[i].stream == dc_stream && !new_ctx->res_ctx.pipe_ctx[i].top_pipe) {
- pipe_ctx = &new_ctx->res_ctx.pipe_ctx[i];
-
- if (pipe_ctx->stream_res.dsc)
- dcn20_release_dsc(&new_ctx->res_ctx, dc->res_pool, &pipe_ctx->stream_res.dsc);
- }
- }
-
- if (!pipe_ctx)
- return DC_ERROR_UNEXPECTED;
- else
- return DC_OK;
-}
-
-
-enum dc_status dcn20_add_stream_to_ctx(struct dc *dc, struct dc_state *new_ctx, struct dc_stream_state *dc_stream)
-{
- enum dc_status result = DC_ERROR_UNEXPECTED;
-
- result = resource_map_pool_resources(dc, new_ctx, dc_stream);
-
- if (result == DC_OK)
- result = resource_map_phy_clock_resources(dc, new_ctx, dc_stream);
-
- /* Get a DSC if required and available */
- if (result == DC_OK && dc_stream->timing.flags.DSC)
- result = dcn20_add_dsc_to_stream_resource(dc, new_ctx, dc_stream);
-
- if (result == DC_OK)
- result = dcn20_build_mapped_resource(dc, new_ctx, dc_stream);
-
- return result;
-}
-
-
-enum dc_status dcn20_remove_stream_from_ctx(struct dc *dc, struct dc_state *new_ctx, struct dc_stream_state *dc_stream)
-{
- enum dc_status result = DC_OK;
-
- result = remove_dsc_from_stream_resource(dc, new_ctx, dc_stream);
-
- return result;
-}
-
-/**
- * dcn20_split_stream_for_odm - Check if stream can be splited for ODM
- *
- * @dc: DC object with resource pool info required for pipe split
- * @res_ctx: Persistent state of resources
- * @prev_odm_pipe: Reference to the previous ODM pipe
- * @next_odm_pipe: Reference to the next ODM pipe
- *
- * This function takes a logically active pipe and a logically free pipe and
- * halves all the scaling parameters that need to be halved while populating
- * the free pipe with the required resources and configuring the next/previous
- * ODM pipe pointers.
- *
- * Return:
- * Return true if split stream for ODM is possible, otherwise, return false.
- */
-bool dcn20_split_stream_for_odm(
- const struct dc *dc,
- struct resource_context *res_ctx,
- struct pipe_ctx *prev_odm_pipe,
- struct pipe_ctx *next_odm_pipe)
-{
- int pipe_idx = next_odm_pipe->pipe_idx;
- const struct resource_pool *pool = dc->res_pool;
-
- *next_odm_pipe = *prev_odm_pipe;
-
- next_odm_pipe->pipe_idx = pipe_idx;
- next_odm_pipe->plane_res.mi = pool->mis[next_odm_pipe->pipe_idx];
- next_odm_pipe->plane_res.hubp = pool->hubps[next_odm_pipe->pipe_idx];
- next_odm_pipe->plane_res.ipp = pool->ipps[next_odm_pipe->pipe_idx];
- next_odm_pipe->plane_res.xfm = pool->transforms[next_odm_pipe->pipe_idx];
- next_odm_pipe->plane_res.dpp = pool->dpps[next_odm_pipe->pipe_idx];
- next_odm_pipe->plane_res.mpcc_inst = pool->dpps[next_odm_pipe->pipe_idx]->inst;
- next_odm_pipe->stream_res.dsc = NULL;
- if (prev_odm_pipe->next_odm_pipe && prev_odm_pipe->next_odm_pipe != next_odm_pipe) {
- next_odm_pipe->next_odm_pipe = prev_odm_pipe->next_odm_pipe;
- next_odm_pipe->next_odm_pipe->prev_odm_pipe = next_odm_pipe;
- }
- if (prev_odm_pipe->top_pipe && prev_odm_pipe->top_pipe->next_odm_pipe) {
- prev_odm_pipe->top_pipe->next_odm_pipe->bottom_pipe = next_odm_pipe;
- next_odm_pipe->top_pipe = prev_odm_pipe->top_pipe->next_odm_pipe;
- }
- if (prev_odm_pipe->bottom_pipe && prev_odm_pipe->bottom_pipe->next_odm_pipe) {
- prev_odm_pipe->bottom_pipe->next_odm_pipe->top_pipe = next_odm_pipe;
- next_odm_pipe->bottom_pipe = prev_odm_pipe->bottom_pipe->next_odm_pipe;
- }
- prev_odm_pipe->next_odm_pipe = next_odm_pipe;
- next_odm_pipe->prev_odm_pipe = prev_odm_pipe;
-
- if (prev_odm_pipe->plane_state) {
- struct scaler_data *sd = &prev_odm_pipe->plane_res.scl_data;
- int new_width;
-
- /* HACTIVE halved for odm combine */
- sd->h_active /= 2;
- /* Calculate new vp and recout for left pipe */
- /* Need at least 16 pixels width per side */
- if (sd->recout.x + 16 >= sd->h_active)
- return false;
- new_width = sd->h_active - sd->recout.x;
- sd->viewport.width -= dc_fixpt_floor(dc_fixpt_mul_int(
- sd->ratios.horz, sd->recout.width - new_width));
- sd->viewport_c.width -= dc_fixpt_floor(dc_fixpt_mul_int(
- sd->ratios.horz_c, sd->recout.width - new_width));
- sd->recout.width = new_width;
-
- /* Calculate new vp and recout for right pipe */
- sd = &next_odm_pipe->plane_res.scl_data;
- /* HACTIVE halved for odm combine */
- sd->h_active /= 2;
- /* Need at least 16 pixels width per side */
- if (new_width <= 16)
- return false;
- new_width = sd->recout.width + sd->recout.x - sd->h_active;
- sd->viewport.width -= dc_fixpt_floor(dc_fixpt_mul_int(
- sd->ratios.horz, sd->recout.width - new_width));
- sd->viewport_c.width -= dc_fixpt_floor(dc_fixpt_mul_int(
- sd->ratios.horz_c, sd->recout.width - new_width));
- sd->recout.width = new_width;
- sd->viewport.x += dc_fixpt_floor(dc_fixpt_mul_int(
- sd->ratios.horz, sd->h_active - sd->recout.x));
- sd->viewport_c.x += dc_fixpt_floor(dc_fixpt_mul_int(
- sd->ratios.horz_c, sd->h_active - sd->recout.x));
- sd->recout.x = 0;
- }
- if (!next_odm_pipe->top_pipe)
- next_odm_pipe->stream_res.opp = pool->opps[next_odm_pipe->pipe_idx];
- else
- next_odm_pipe->stream_res.opp = next_odm_pipe->top_pipe->stream_res.opp;
- if (next_odm_pipe->stream->timing.flags.DSC == 1 && !next_odm_pipe->top_pipe) {
- dcn20_acquire_dsc(dc, res_ctx, &next_odm_pipe->stream_res.dsc, next_odm_pipe->pipe_idx);
- ASSERT(next_odm_pipe->stream_res.dsc);
- if (next_odm_pipe->stream_res.dsc == NULL)
- return false;
- }
-
- return true;
-}
-
-void dcn20_split_stream_for_mpc(
- struct resource_context *res_ctx,
- const struct resource_pool *pool,
- struct pipe_ctx *primary_pipe,
- struct pipe_ctx *secondary_pipe)
-{
- int pipe_idx = secondary_pipe->pipe_idx;
- struct pipe_ctx *sec_bot_pipe = secondary_pipe->bottom_pipe;
-
- *secondary_pipe = *primary_pipe;
- secondary_pipe->bottom_pipe = sec_bot_pipe;
-
- secondary_pipe->pipe_idx = pipe_idx;
- secondary_pipe->plane_res.mi = pool->mis[secondary_pipe->pipe_idx];
- secondary_pipe->plane_res.hubp = pool->hubps[secondary_pipe->pipe_idx];
- secondary_pipe->plane_res.ipp = pool->ipps[secondary_pipe->pipe_idx];
- secondary_pipe->plane_res.xfm = pool->transforms[secondary_pipe->pipe_idx];
- secondary_pipe->plane_res.dpp = pool->dpps[secondary_pipe->pipe_idx];
- secondary_pipe->plane_res.mpcc_inst = pool->dpps[secondary_pipe->pipe_idx]->inst;
- secondary_pipe->stream_res.dsc = NULL;
- if (primary_pipe->bottom_pipe && primary_pipe->bottom_pipe != secondary_pipe) {
- ASSERT(!secondary_pipe->bottom_pipe);
- secondary_pipe->bottom_pipe = primary_pipe->bottom_pipe;
- secondary_pipe->bottom_pipe->top_pipe = secondary_pipe;
- }
- primary_pipe->bottom_pipe = secondary_pipe;
- secondary_pipe->top_pipe = primary_pipe;
-
- ASSERT(primary_pipe->plane_state);
-}
-
-unsigned int dcn20_calc_max_scaled_time(
- unsigned int time_per_pixel,
- enum mmhubbub_wbif_mode mode,
- unsigned int urgent_watermark)
-{
- unsigned int time_per_byte = 0;
- unsigned int total_y_free_entry = 0x200; /* two memory piece for luma */
- unsigned int total_c_free_entry = 0x140; /* two memory piece for chroma */
- unsigned int small_free_entry, max_free_entry;
- unsigned int buf_lh_capability;
- unsigned int max_scaled_time;
-
- if (mode == PACKED_444) /* packed mode */
- time_per_byte = time_per_pixel/4;
- else if (mode == PLANAR_420_8BPC)
- time_per_byte = time_per_pixel;
- else if (mode == PLANAR_420_10BPC) /* p010 */
- time_per_byte = time_per_pixel * 819/1024;
-
- if (time_per_byte == 0)
- time_per_byte = 1;
-
- small_free_entry = (total_y_free_entry > total_c_free_entry) ? total_c_free_entry : total_y_free_entry;
- max_free_entry = (mode == PACKED_444) ? total_y_free_entry + total_c_free_entry : small_free_entry;
- buf_lh_capability = max_free_entry*time_per_byte*32/16; /* there is 4bit fraction */
- max_scaled_time = buf_lh_capability - urgent_watermark;
- return max_scaled_time;
-}
-
-void dcn20_set_mcif_arb_params(
- struct dc *dc,
- struct dc_state *context,
- display_e2e_pipe_params_st *pipes,
- int pipe_cnt)
-{
- enum mmhubbub_wbif_mode wbif_mode;
- struct mcif_arb_params *wb_arb_params;
- int i, j, dwb_pipe;
-
- /* Writeback MCIF_WB arbitration parameters */
- dwb_pipe = 0;
- for (i = 0; i < dc->res_pool->pipe_count; i++) {
-
- if (!context->res_ctx.pipe_ctx[i].stream)
- continue;
-
- for (j = 0; j < MAX_DWB_PIPES; j++) {
- if (context->res_ctx.pipe_ctx[i].stream->writeback_info[j].wb_enabled == false)
- continue;
-
- //wb_arb_params = &context->res_ctx.pipe_ctx[i].stream->writeback_info[j].mcif_arb_params;
- wb_arb_params = &context->bw_ctx.bw.dcn.bw_writeback.mcif_wb_arb[dwb_pipe];
-
- if (context->res_ctx.pipe_ctx[i].stream->writeback_info[j].dwb_params.out_format == dwb_scaler_mode_yuv420) {
- if (context->res_ctx.pipe_ctx[i].stream->writeback_info[j].dwb_params.output_depth == DWB_OUTPUT_PIXEL_DEPTH_8BPC)
- wbif_mode = PLANAR_420_8BPC;
- else
- wbif_mode = PLANAR_420_10BPC;
- } else
- wbif_mode = PACKED_444;
-
- DC_FP_START();
- dcn20_fpu_set_wb_arb_params(wb_arb_params, context, pipes, pipe_cnt, i);
- DC_FP_END();
-
- wb_arb_params->slice_lines = 32;
- wb_arb_params->arbitration_slice = 2;
- wb_arb_params->max_scaled_time = dcn20_calc_max_scaled_time(wb_arb_params->time_per_pixel,
- wbif_mode,
- wb_arb_params->cli_watermark[0]); /* assume 4 watermark sets have the same value */
-
- dwb_pipe++;
-
- if (dwb_pipe >= MAX_DWB_PIPES)
- return;
- }
- if (dwb_pipe >= MAX_DWB_PIPES)
- return;
- }
-}
-
-bool dcn20_validate_dsc(struct dc *dc, struct dc_state *new_ctx)
-{
- int i;
-
- /* Validate DSC config, dsc count validation is already done */
- for (i = 0; i < dc->res_pool->pipe_count; i++) {
- struct pipe_ctx *pipe_ctx = &new_ctx->res_ctx.pipe_ctx[i];
- struct dc_stream_state *stream = pipe_ctx->stream;
- struct dsc_config dsc_cfg;
- struct pipe_ctx *odm_pipe;
- int opp_cnt = 1;
-
- for (odm_pipe = pipe_ctx->next_odm_pipe; odm_pipe; odm_pipe = odm_pipe->next_odm_pipe)
- opp_cnt++;
-
- /* Only need to validate top pipe */
- if (pipe_ctx->top_pipe || pipe_ctx->prev_odm_pipe || !stream || !stream->timing.flags.DSC)
- continue;
-
- dsc_cfg.pic_width = (stream->timing.h_addressable + stream->timing.h_border_left
- + stream->timing.h_border_right) / opp_cnt;
- dsc_cfg.pic_height = stream->timing.v_addressable + stream->timing.v_border_top
- + stream->timing.v_border_bottom;
- dsc_cfg.pixel_encoding = stream->timing.pixel_encoding;
- dsc_cfg.color_depth = stream->timing.display_color_depth;
- dsc_cfg.is_odm = pipe_ctx->next_odm_pipe ? true : false;
- dsc_cfg.dc_dsc_cfg = stream->timing.dsc_cfg;
- dsc_cfg.dc_dsc_cfg.num_slices_h /= opp_cnt;
-
- if (!pipe_ctx->stream_res.dsc->funcs->dsc_validate_stream(pipe_ctx->stream_res.dsc, &dsc_cfg))
- return false;
- }
- return true;
-}
-
-struct pipe_ctx *dcn20_find_secondary_pipe(struct dc *dc,
- struct resource_context *res_ctx,
- const struct resource_pool *pool,
- const struct pipe_ctx *primary_pipe)
-{
- struct pipe_ctx *secondary_pipe = NULL;
-
- if (dc && primary_pipe) {
- int j;
- int preferred_pipe_idx = 0;
-
- /* first check the prev dc state:
- * if this primary pipe has a bottom pipe in prev. state
- * and if the bottom pipe is still available (which it should be),
- * pick that pipe as secondary
- * Same logic applies for ODM pipes
- */
- if (dc->current_state->res_ctx.pipe_ctx[primary_pipe->pipe_idx].next_odm_pipe) {
- preferred_pipe_idx = dc->current_state->res_ctx.pipe_ctx[primary_pipe->pipe_idx].next_odm_pipe->pipe_idx;
- if (res_ctx->pipe_ctx[preferred_pipe_idx].stream == NULL) {
- secondary_pipe = &res_ctx->pipe_ctx[preferred_pipe_idx];
- secondary_pipe->pipe_idx = preferred_pipe_idx;
- }
- }
- if (secondary_pipe == NULL &&
- dc->current_state->res_ctx.pipe_ctx[primary_pipe->pipe_idx].bottom_pipe) {
- preferred_pipe_idx = dc->current_state->res_ctx.pipe_ctx[primary_pipe->pipe_idx].bottom_pipe->pipe_idx;
- if (res_ctx->pipe_ctx[preferred_pipe_idx].stream == NULL) {
- secondary_pipe = &res_ctx->pipe_ctx[preferred_pipe_idx];
- secondary_pipe->pipe_idx = preferred_pipe_idx;
- }
- }
-
- /*
- * if this primary pipe does not have a bottom pipe in prev. state
- * start backward and find a pipe that did not used to be a bottom pipe in
- * prev. dc state. This way we make sure we keep the same assignment as
- * last state and will not have to reprogram every pipe
- */
- if (secondary_pipe == NULL) {
- for (j = dc->res_pool->pipe_count - 1; j >= 0; j--) {
- if (dc->current_state->res_ctx.pipe_ctx[j].top_pipe == NULL
- && dc->current_state->res_ctx.pipe_ctx[j].prev_odm_pipe == NULL) {
- preferred_pipe_idx = j;
-
- if (res_ctx->pipe_ctx[preferred_pipe_idx].stream == NULL) {
- secondary_pipe = &res_ctx->pipe_ctx[preferred_pipe_idx];
- secondary_pipe->pipe_idx = preferred_pipe_idx;
- break;
- }
- }
- }
- }
- /*
- * We should never hit this assert unless assignments are shuffled around
- * if this happens we will prob. hit a vsync tdr
- */
- ASSERT(secondary_pipe);
- /*
- * search backwards for the second pipe to keep pipe
- * assignment more consistent
- */
- if (secondary_pipe == NULL) {
- for (j = dc->res_pool->pipe_count - 1; j >= 0; j--) {
- preferred_pipe_idx = j;
-
- if (res_ctx->pipe_ctx[preferred_pipe_idx].stream == NULL) {
- secondary_pipe = &res_ctx->pipe_ctx[preferred_pipe_idx];
- secondary_pipe->pipe_idx = preferred_pipe_idx;
- break;
- }
- }
- }
- }
-
- return secondary_pipe;
-}
-
-void dcn20_merge_pipes_for_validate(
- struct dc *dc,
- struct dc_state *context)
-{
- int i;
-
- /* merge previously split odm pipes since mode support needs to make the decision */
- for (i = 0; i < dc->res_pool->pipe_count; i++) {
- struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
- struct pipe_ctx *odm_pipe = pipe->next_odm_pipe;
-
- if (pipe->prev_odm_pipe)
- continue;
-
- pipe->next_odm_pipe = NULL;
- while (odm_pipe) {
- struct pipe_ctx *next_odm_pipe = odm_pipe->next_odm_pipe;
-
- odm_pipe->plane_state = NULL;
- odm_pipe->stream = NULL;
- odm_pipe->top_pipe = NULL;
- odm_pipe->bottom_pipe = NULL;
- odm_pipe->prev_odm_pipe = NULL;
- odm_pipe->next_odm_pipe = NULL;
- if (odm_pipe->stream_res.dsc)
- dcn20_release_dsc(&context->res_ctx, dc->res_pool, &odm_pipe->stream_res.dsc);
- /* Clear plane_res and stream_res */
- memset(&odm_pipe->plane_res, 0, sizeof(odm_pipe->plane_res));
- memset(&odm_pipe->stream_res, 0, sizeof(odm_pipe->stream_res));
- odm_pipe = next_odm_pipe;
- }
- if (pipe->plane_state)
- resource_build_scaling_params(pipe);
- }
-
- /* merge previously mpc split pipes since mode support needs to make the decision */
- for (i = 0; i < dc->res_pool->pipe_count; i++) {
- struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
- struct pipe_ctx *hsplit_pipe = pipe->bottom_pipe;
-
- if (!hsplit_pipe || hsplit_pipe->plane_state != pipe->plane_state)
- continue;
-
- pipe->bottom_pipe = hsplit_pipe->bottom_pipe;
- if (hsplit_pipe->bottom_pipe)
- hsplit_pipe->bottom_pipe->top_pipe = pipe;
- hsplit_pipe->plane_state = NULL;
- hsplit_pipe->stream = NULL;
- hsplit_pipe->top_pipe = NULL;
- hsplit_pipe->bottom_pipe = NULL;
-
- /* Clear plane_res and stream_res */
- memset(&hsplit_pipe->plane_res, 0, sizeof(hsplit_pipe->plane_res));
- memset(&hsplit_pipe->stream_res, 0, sizeof(hsplit_pipe->stream_res));
- if (pipe->plane_state)
- resource_build_scaling_params(pipe);
- }
-}
-
-int dcn20_validate_apply_pipe_split_flags(
- struct dc *dc,
- struct dc_state *context,
- int vlevel,
- int *split,
- bool *merge)
-{
- int i, pipe_idx, vlevel_split;
- int plane_count = 0;
- bool force_split = false;
- bool avoid_split = dc->debug.pipe_split_policy == MPC_SPLIT_AVOID;
- struct vba_vars_st *v = &context->bw_ctx.dml.vba;
- int max_mpc_comb = v->maxMpcComb;
-
- if (context->stream_count > 1) {
- if (dc->debug.pipe_split_policy == MPC_SPLIT_AVOID_MULT_DISP)
- avoid_split = true;
- } else if (dc->debug.force_single_disp_pipe_split)
- force_split = true;
-
- for (i = 0; i < dc->res_pool->pipe_count; i++) {
- struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
-
- /**
- * Workaround for avoiding pipe-split in cases where we'd split
- * planes that are too small, resulting in splits that aren't
- * valid for the scaler.
- */
- if (pipe->plane_state &&
- (pipe->plane_state->dst_rect.width <= 16 ||
- pipe->plane_state->dst_rect.height <= 16 ||
- pipe->plane_state->src_rect.width <= 16 ||
- pipe->plane_state->src_rect.height <= 16))
- avoid_split = true;
-
- /* TODO: fix dc bugs and remove this split threshold thing */
- if (pipe->stream && !pipe->prev_odm_pipe &&
- (!pipe->top_pipe || pipe->top_pipe->plane_state != pipe->plane_state))
- ++plane_count;
- }
- if (plane_count > dc->res_pool->pipe_count / 2)
- avoid_split = true;
-
- /* W/A: Mode timing with borders may not work well with pipe split, avoid for this corner case */
- for (i = 0; i < dc->res_pool->pipe_count; i++) {
- struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
- struct dc_crtc_timing timing;
-
- if (!pipe->stream)
- continue;
- else {
- timing = pipe->stream->timing;
- if (timing.h_border_left + timing.h_border_right
- + timing.v_border_top + timing.v_border_bottom > 0) {
- avoid_split = true;
- break;
- }
- }
- }
-
- /* Avoid split loop looks for lowest voltage level that allows most unsplit pipes possible */
- if (avoid_split) {
- for (i = 0, pipe_idx = 0; i < dc->res_pool->pipe_count; i++) {
- if (!context->res_ctx.pipe_ctx[i].stream)
- continue;
-
- for (vlevel_split = vlevel; vlevel <= context->bw_ctx.dml.soc.num_states; vlevel++)
- if (v->NoOfDPP[vlevel][0][pipe_idx] == 1 &&
- v->ModeSupport[vlevel][0])
- break;
- /* Impossible to not split this pipe */
- if (vlevel > context->bw_ctx.dml.soc.num_states)
- vlevel = vlevel_split;
- else
- max_mpc_comb = 0;
- pipe_idx++;
- }
- v->maxMpcComb = max_mpc_comb;
- }
-
- /* Split loop sets which pipe should be split based on dml outputs and dc flags */
- for (i = 0, pipe_idx = 0; i < dc->res_pool->pipe_count; i++) {
- struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
- int pipe_plane = v->pipe_plane[pipe_idx];
- bool split4mpc = context->stream_count == 1 && plane_count == 1
- && dc->config.enable_4to1MPC && dc->res_pool->pipe_count >= 4;
-
- if (!context->res_ctx.pipe_ctx[i].stream)
- continue;
-
- if (split4mpc || v->NoOfDPP[vlevel][max_mpc_comb][pipe_plane] == 4)
- split[i] = 4;
- else if (force_split || v->NoOfDPP[vlevel][max_mpc_comb][pipe_plane] == 2)
- split[i] = 2;
-
- if ((pipe->stream->view_format ==
- VIEW_3D_FORMAT_SIDE_BY_SIDE ||
- pipe->stream->view_format ==
- VIEW_3D_FORMAT_TOP_AND_BOTTOM) &&
- (pipe->stream->timing.timing_3d_format ==
- TIMING_3D_FORMAT_TOP_AND_BOTTOM ||
- pipe->stream->timing.timing_3d_format ==
- TIMING_3D_FORMAT_SIDE_BY_SIDE))
- split[i] = 2;
- if (dc->debug.force_odm_combine & (1 << pipe->stream_res.tg->inst)) {
- split[i] = 2;
- v->ODMCombineEnablePerState[vlevel][pipe_plane] = dm_odm_combine_mode_2to1;
- }
- if (dc->debug.force_odm_combine_4to1 & (1 << pipe->stream_res.tg->inst)) {
- split[i] = 4;
- v->ODMCombineEnablePerState[vlevel][pipe_plane] = dm_odm_combine_mode_4to1;
- }
- /*420 format workaround*/
- if (pipe->stream->timing.h_addressable > 7680 &&
- pipe->stream->timing.pixel_encoding == PIXEL_ENCODING_YCBCR420) {
- split[i] = 4;
- }
- v->ODMCombineEnabled[pipe_plane] =
- v->ODMCombineEnablePerState[vlevel][pipe_plane];
-
- if (v->ODMCombineEnabled[pipe_plane] == dm_odm_combine_mode_disabled) {
- if (resource_get_mpc_slice_count(pipe) == 2) {
- /*If need split for mpc but 2 way split already*/
- if (split[i] == 4)
- split[i] = 2; /* 2 -> 4 MPC */
- else if (split[i] == 2)
- split[i] = 0; /* 2 -> 2 MPC */
- else if (pipe->top_pipe && pipe->top_pipe->plane_state == pipe->plane_state)
- merge[i] = true; /* 2 -> 1 MPC */
- } else if (resource_get_mpc_slice_count(pipe) == 4) {
- /*If need split for mpc but 4 way split already*/
- if (split[i] == 2 && ((pipe->top_pipe && !pipe->top_pipe->top_pipe)
- || !pipe->bottom_pipe)) {
- merge[i] = true; /* 4 -> 2 MPC */
- } else if (split[i] == 0 && pipe->top_pipe &&
- pipe->top_pipe->plane_state == pipe->plane_state)
- merge[i] = true; /* 4 -> 1 MPC */
- split[i] = 0;
- } else if (resource_get_odm_slice_count(pipe) > 1) {
- /* ODM -> MPC transition */
- if (pipe->prev_odm_pipe) {
- split[i] = 0;
- merge[i] = true;
- }
- }
- } else {
- if (resource_get_odm_slice_count(pipe) == 2) {
- /*If need split for odm but 2 way split already*/
- if (split[i] == 4)
- split[i] = 2; /* 2 -> 4 ODM */
- else if (split[i] == 2)
- split[i] = 0; /* 2 -> 2 ODM */
- else if (pipe->prev_odm_pipe) {
- ASSERT(0); /* NOT expected yet */
- merge[i] = true; /* exit ODM */
- }
- } else if (resource_get_odm_slice_count(pipe) == 4) {
- /*If need split for odm but 4 way split already*/
- if (split[i] == 2 && ((pipe->prev_odm_pipe && !pipe->prev_odm_pipe->prev_odm_pipe)
- || !pipe->next_odm_pipe)) {
- merge[i] = true; /* 4 -> 2 ODM */
- } else if (split[i] == 0 && pipe->prev_odm_pipe) {
- ASSERT(0); /* NOT expected yet */
- merge[i] = true; /* exit ODM */
- }
- split[i] = 0;
- } else if (resource_get_mpc_slice_count(pipe) > 1) {
- /* MPC -> ODM transition */
- ASSERT(0); /* NOT expected yet */
- if (pipe->top_pipe && pipe->top_pipe->plane_state == pipe->plane_state) {
- split[i] = 0;
- merge[i] = true;
- }
- }
- }
-
- /* Adjust dppclk when split is forced, do not bother with dispclk */
- if (split[i] != 0 && v->NoOfDPP[vlevel][max_mpc_comb][pipe_idx] == 1) {
- DC_FP_START();
- dcn20_fpu_adjust_dppclk(v, vlevel, max_mpc_comb, pipe_idx, false);
- DC_FP_END();
- }
- pipe_idx++;
- }
-
- return vlevel;
-}
-
-bool dcn20_fast_validate_bw(
- struct dc *dc,
- struct dc_state *context,
- display_e2e_pipe_params_st *pipes,
- int *pipe_cnt_out,
- int *pipe_split_from,
- int *vlevel_out,
- bool fast_validate)
-{
- bool out = false;
- int split[MAX_PIPES] = { 0 };
- int pipe_cnt, i, pipe_idx, vlevel;
-
- ASSERT(pipes);
- if (!pipes)
- return false;
-
- dcn20_merge_pipes_for_validate(dc, context);
-
- DC_FP_START();
- pipe_cnt = dc->res_pool->funcs->populate_dml_pipes(dc, context, pipes, fast_validate);
- DC_FP_END();
-
- *pipe_cnt_out = pipe_cnt;
-
- if (!pipe_cnt) {
- out = true;
- goto validate_out;
- }
-
- vlevel = dml_get_voltage_level(&context->bw_ctx.dml, pipes, pipe_cnt);
-
- if (vlevel > context->bw_ctx.dml.soc.num_states)
- goto validate_fail;
-
- vlevel = dcn20_validate_apply_pipe_split_flags(dc, context, vlevel, split, NULL);
-
- /*initialize pipe_just_split_from to invalid idx*/
- for (i = 0; i < MAX_PIPES; i++)
- pipe_split_from[i] = -1;
-
- for (i = 0, pipe_idx = -1; i < dc->res_pool->pipe_count; i++) {
- struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
- struct pipe_ctx *hsplit_pipe = pipe->bottom_pipe;
-
- if (!pipe->stream || pipe_split_from[i] >= 0)
- continue;
-
- pipe_idx++;
-
- if (!pipe->top_pipe && !pipe->plane_state && context->bw_ctx.dml.vba.ODMCombineEnabled[pipe_idx]) {
- hsplit_pipe = dcn20_find_secondary_pipe(dc, &context->res_ctx, dc->res_pool, pipe);
- ASSERT(hsplit_pipe);
- if (!dcn20_split_stream_for_odm(
- dc, &context->res_ctx,
- pipe, hsplit_pipe))
- goto validate_fail;
- pipe_split_from[hsplit_pipe->pipe_idx] = pipe_idx;
- dcn20_build_mapped_resource(dc, context, pipe->stream);
- }
-
- if (!pipe->plane_state)
- continue;
- /* Skip 2nd half of already split pipe */
- if (pipe->top_pipe && pipe->plane_state == pipe->top_pipe->plane_state)
- continue;
-
- /* We do not support mpo + odm at the moment */
- if (hsplit_pipe && hsplit_pipe->plane_state != pipe->plane_state
- && context->bw_ctx.dml.vba.ODMCombineEnabled[pipe_idx])
- goto validate_fail;
-
- if (split[i] == 2) {
- if (!hsplit_pipe || hsplit_pipe->plane_state != pipe->plane_state) {
- /* pipe not split previously needs split */
- hsplit_pipe = dcn20_find_secondary_pipe(dc, &context->res_ctx, dc->res_pool, pipe);
- ASSERT(hsplit_pipe);
- if (!hsplit_pipe) {
- DC_FP_START();
- dcn20_fpu_adjust_dppclk(&context->bw_ctx.dml.vba, vlevel, context->bw_ctx.dml.vba.maxMpcComb, pipe_idx, true);
- DC_FP_END();
- continue;
- }
- if (context->bw_ctx.dml.vba.ODMCombineEnabled[pipe_idx]) {
- if (!dcn20_split_stream_for_odm(
- dc, &context->res_ctx,
- pipe, hsplit_pipe))
- goto validate_fail;
- dcn20_build_mapped_resource(dc, context, pipe->stream);
- } else {
- dcn20_split_stream_for_mpc(
- &context->res_ctx, dc->res_pool,
- pipe, hsplit_pipe);
- resource_build_scaling_params(pipe);
- resource_build_scaling_params(hsplit_pipe);
- }
- pipe_split_from[hsplit_pipe->pipe_idx] = pipe_idx;
- }
- } else if (hsplit_pipe && hsplit_pipe->plane_state == pipe->plane_state) {
- /* merge should already have been done */
- ASSERT(0);
- }
- }
- /* Actual dsc count per stream dsc validation*/
- if (!dcn20_validate_dsc(dc, context)) {
- context->bw_ctx.dml.vba.ValidationStatus[context->bw_ctx.dml.vba.soc.num_states] =
- DML_FAIL_DSC_VALIDATION_FAILURE;
- goto validate_fail;
- }
-
- *vlevel_out = vlevel;
-
- out = true;
- goto validate_out;
-
-validate_fail:
- out = false;
-
-validate_out:
- return out;
-}
-
-bool dcn20_validate_bandwidth(struct dc *dc, struct dc_state *context,
- bool fast_validate)
-{
- bool voltage_supported;
- display_e2e_pipe_params_st *pipes;
-
- pipes = kcalloc(dc->res_pool->pipe_count, sizeof(display_e2e_pipe_params_st), GFP_KERNEL);
- if (!pipes)
- return false;
-
- DC_FP_START();
- voltage_supported = dcn20_validate_bandwidth_fp(dc, context, fast_validate, pipes);
- DC_FP_END();
-
- kfree(pipes);
- return voltage_supported;
-}
-
-struct pipe_ctx *dcn20_acquire_free_pipe_for_layer(
- const struct dc_state *cur_ctx,
- struct dc_state *new_ctx,
- const struct resource_pool *pool,
- const struct pipe_ctx *opp_head)
-{
- struct resource_context *res_ctx = &new_ctx->res_ctx;
- struct pipe_ctx *otg_master = resource_get_otg_master_for_stream(res_ctx, opp_head->stream);
- struct pipe_ctx *sec_dpp_pipe = resource_find_free_secondary_pipe_legacy(res_ctx, pool, otg_master);
-
- ASSERT(otg_master);
-
- if (!sec_dpp_pipe)
- return NULL;
-
- sec_dpp_pipe->stream = opp_head->stream;
- sec_dpp_pipe->stream_res.tg = opp_head->stream_res.tg;
- sec_dpp_pipe->stream_res.opp = opp_head->stream_res.opp;
-
- sec_dpp_pipe->plane_res.hubp = pool->hubps[sec_dpp_pipe->pipe_idx];
- sec_dpp_pipe->plane_res.ipp = pool->ipps[sec_dpp_pipe->pipe_idx];
- sec_dpp_pipe->plane_res.dpp = pool->dpps[sec_dpp_pipe->pipe_idx];
- sec_dpp_pipe->plane_res.mpcc_inst = pool->dpps[sec_dpp_pipe->pipe_idx]->inst;
-
- return sec_dpp_pipe;
-}
-
-bool dcn20_get_dcc_compression_cap(const struct dc *dc,
- const struct dc_dcc_surface_param *input,
- struct dc_surface_dcc_cap *output)
-{
- return dc->res_pool->hubbub->funcs->get_dcc_compression_cap(
- dc->res_pool->hubbub,
- input,
- output);
-}
-
-static void dcn20_destroy_resource_pool(struct resource_pool **pool)
-{
- struct dcn20_resource_pool *dcn20_pool = TO_DCN20_RES_POOL(*pool);
-
- dcn20_resource_destruct(dcn20_pool);
- kfree(dcn20_pool);
- *pool = NULL;
-}
-
-
-static struct dc_cap_funcs cap_funcs = {
- .get_dcc_compression_cap = dcn20_get_dcc_compression_cap
-};
-
-
-enum dc_status dcn20_patch_unknown_plane_state(struct dc_plane_state *plane_state)
-{
- enum surface_pixel_format surf_pix_format = plane_state->format;
- unsigned int bpp = resource_pixel_format_to_bpp(surf_pix_format);
-
- plane_state->tiling_info.gfx9.swizzle = DC_SW_64KB_S;
- if (bpp == 64)
- plane_state->tiling_info.gfx9.swizzle = DC_SW_64KB_D;
-
- return DC_OK;
-}
-
-void dcn20_release_pipe(struct dc_state *context,
- struct pipe_ctx *pipe,
- const struct resource_pool *pool)
-{
- if (resource_is_pipe_type(pipe, OPP_HEAD) && pipe->stream_res.dsc)
- dcn20_release_dsc(&context->res_ctx, pool, &pipe->stream_res.dsc);
- memset(pipe, 0, sizeof(*pipe));
-}
-
-static const struct resource_funcs dcn20_res_pool_funcs = {
- .destroy = dcn20_destroy_resource_pool,
- .link_enc_create = dcn20_link_encoder_create,
- .panel_cntl_create = dcn20_panel_cntl_create,
- .validate_bandwidth = dcn20_validate_bandwidth,
- .acquire_free_pipe_as_secondary_dpp_pipe = dcn20_acquire_free_pipe_for_layer,
- .release_pipe = dcn20_release_pipe,
- .add_stream_to_ctx = dcn20_add_stream_to_ctx,
- .add_dsc_to_stream_resource = dcn20_add_dsc_to_stream_resource,
- .remove_stream_from_ctx = dcn20_remove_stream_from_ctx,
- .populate_dml_writeback_from_context = dcn20_populate_dml_writeback_from_context,
- .patch_unknown_plane_state = dcn20_patch_unknown_plane_state,
- .set_mcif_arb_params = dcn20_set_mcif_arb_params,
- .populate_dml_pipes = dcn20_populate_dml_pipes_from_context,
- .find_first_free_match_stream_enc_for_link = dcn10_find_first_free_match_stream_enc_for_link
-};
-
-bool dcn20_dwbc_create(struct dc_context *ctx, struct resource_pool *pool)
-{
- int i;
- uint32_t pipe_count = pool->res_cap->num_dwb;
-
- for (i = 0; i < pipe_count; i++) {
- struct dcn20_dwbc *dwbc20 = kzalloc(sizeof(struct dcn20_dwbc),
- GFP_KERNEL);
-
- if (!dwbc20) {
- dm_error("DC: failed to create dwbc20!\n");
- return false;
- }
- dcn20_dwbc_construct(dwbc20, ctx,
- &dwbc20_regs[i],
- &dwbc20_shift,
- &dwbc20_mask,
- i);
- pool->dwbc[i] = &dwbc20->base;
- }
- return true;
-}
-
-bool dcn20_mmhubbub_create(struct dc_context *ctx, struct resource_pool *pool)
-{
- int i;
- uint32_t pipe_count = pool->res_cap->num_dwb;
-
- ASSERT(pipe_count > 0);
-
- for (i = 0; i < pipe_count; i++) {
- struct dcn20_mmhubbub *mcif_wb20 = kzalloc(sizeof(struct dcn20_mmhubbub),
- GFP_KERNEL);
-
- if (!mcif_wb20) {
- dm_error("DC: failed to create mcif_wb20!\n");
- return false;
- }
-
- dcn20_mmhubbub_construct(mcif_wb20, ctx,
- &mcif_wb20_regs[i],
- &mcif_wb20_shift,
- &mcif_wb20_mask,
- i);
-
- pool->mcif_wb[i] = &mcif_wb20->base;
- }
- return true;
-}
-
-static struct pp_smu_funcs *dcn20_pp_smu_create(struct dc_context *ctx)
-{
- struct pp_smu_funcs *pp_smu = kzalloc(sizeof(*pp_smu), GFP_ATOMIC);
-
- if (!pp_smu)
- return pp_smu;
-
- dm_pp_get_funcs(ctx, pp_smu);
-
- if (pp_smu->ctx.ver != PP_SMU_VER_NV)
- pp_smu = memset(pp_smu, 0, sizeof(struct pp_smu_funcs));
-
- return pp_smu;
-}
-
-static void dcn20_pp_smu_destroy(struct pp_smu_funcs **pp_smu)
-{
- if (pp_smu && *pp_smu) {
- kfree(*pp_smu);
- *pp_smu = NULL;
- }
-}
-
-static struct _vcs_dpi_soc_bounding_box_st *get_asic_rev_soc_bb(
- uint32_t hw_internal_rev)
-{
- if (ASICREV_IS_NAVI14_M(hw_internal_rev))
- return &dcn2_0_nv14_soc;
-
- if (ASICREV_IS_NAVI12_P(hw_internal_rev))
- return &dcn2_0_nv12_soc;
-
- return &dcn2_0_soc;
-}
-
-static struct _vcs_dpi_ip_params_st *get_asic_rev_ip_params(
- uint32_t hw_internal_rev)
-{
- /* NV14 */
- if (ASICREV_IS_NAVI14_M(hw_internal_rev))
- return &dcn2_0_nv14_ip;
-
- /* NV12 and NV10 */
- return &dcn2_0_ip;
-}
-
-static enum dml_project get_dml_project_version(uint32_t hw_internal_rev)
-{
- return DML_PROJECT_NAVI10v2;
-}
-
-static bool init_soc_bounding_box(struct dc *dc,
- struct dcn20_resource_pool *pool)
-{
- struct _vcs_dpi_soc_bounding_box_st *loaded_bb =
- get_asic_rev_soc_bb(dc->ctx->asic_id.hw_internal_rev);
- struct _vcs_dpi_ip_params_st *loaded_ip =
- get_asic_rev_ip_params(dc->ctx->asic_id.hw_internal_rev);
-
- DC_LOGGER_INIT(dc->ctx->logger);
-
- if (pool->base.pp_smu) {
- struct pp_smu_nv_clock_table max_clocks = {0};
- unsigned int uclk_states[8] = {0};
- unsigned int num_states = 0;
- enum pp_smu_status status;
- bool clock_limits_available = false;
- bool uclk_states_available = false;
-
- if (pool->base.pp_smu->nv_funcs.get_uclk_dpm_states) {
- status = (pool->base.pp_smu->nv_funcs.get_uclk_dpm_states)
- (&pool->base.pp_smu->nv_funcs.pp_smu, uclk_states, &num_states);
-
- uclk_states_available = (status == PP_SMU_RESULT_OK);
- }
-
- if (pool->base.pp_smu->nv_funcs.get_maximum_sustainable_clocks) {
- status = (*pool->base.pp_smu->nv_funcs.get_maximum_sustainable_clocks)
- (&pool->base.pp_smu->nv_funcs.pp_smu, &max_clocks);
- /* SMU cannot set DCF clock to anything equal to or higher than SOC clock
- */
- if (max_clocks.dcfClockInKhz >= max_clocks.socClockInKhz)
- max_clocks.dcfClockInKhz = max_clocks.socClockInKhz - 1000;
- clock_limits_available = (status == PP_SMU_RESULT_OK);
- }
-
- if (clock_limits_available && uclk_states_available && num_states) {
- DC_FP_START();
- dcn20_update_bounding_box(dc, loaded_bb, &max_clocks, uclk_states, num_states);
- DC_FP_END();
- } else if (clock_limits_available) {
- DC_FP_START();
- dcn20_cap_soc_clocks(loaded_bb, max_clocks);
- DC_FP_END();
- }
- }
-
- loaded_ip->max_num_otg = pool->base.res_cap->num_timing_generator;
- loaded_ip->max_num_dpp = pool->base.pipe_count;
- DC_FP_START();
- dcn20_patch_bounding_box(dc, loaded_bb);
- DC_FP_END();
- return true;
-}
-
-static bool dcn20_resource_construct(
- uint8_t num_virtual_links,
- struct dc *dc,
- struct dcn20_resource_pool *pool)
-{
- int i;
- struct dc_context *ctx = dc->ctx;
- struct irq_service_init_data init_data;
- struct ddc_service_init_data ddc_init_data = {0};
- struct _vcs_dpi_soc_bounding_box_st *loaded_bb =
- get_asic_rev_soc_bb(ctx->asic_id.hw_internal_rev);
- struct _vcs_dpi_ip_params_st *loaded_ip =
- get_asic_rev_ip_params(ctx->asic_id.hw_internal_rev);
- enum dml_project dml_project_version =
- get_dml_project_version(ctx->asic_id.hw_internal_rev);
-
- ctx->dc_bios->regs = &bios_regs;
- pool->base.funcs = &dcn20_res_pool_funcs;
-
- if (ASICREV_IS_NAVI14_M(ctx->asic_id.hw_internal_rev)) {
- pool->base.res_cap = &res_cap_nv14;
- pool->base.pipe_count = 5;
- pool->base.mpcc_count = 5;
- } else {
- pool->base.res_cap = &res_cap_nv10;
- pool->base.pipe_count = 6;
- pool->base.mpcc_count = 6;
- }
- /*************************************************
- * Resource + asic cap harcoding *
- *************************************************/
- pool->base.underlay_pipe_index = NO_UNDERLAY_PIPE;
-
- dc->caps.max_downscale_ratio = 200;
- dc->caps.i2c_speed_in_khz = 100;
- dc->caps.i2c_speed_in_khz_hdcp = 100; /*1.4 w/a not applied by default*/
- dc->caps.max_cursor_size = 256;
- dc->caps.min_horizontal_blanking_period = 80;
- dc->caps.dmdata_alloc_size = 2048;
-
- dc->caps.max_slave_planes = 1;
- dc->caps.max_slave_yuv_planes = 1;
- dc->caps.max_slave_rgb_planes = 1;
- dc->caps.post_blend_color_processing = true;
- dc->caps.force_dp_tps4_for_cp2520 = true;
- dc->caps.extended_aux_timeout_support = true;
-
- /* Color pipeline capabilities */
- dc->caps.color.dpp.dcn_arch = 1;
- dc->caps.color.dpp.input_lut_shared = 0;
- dc->caps.color.dpp.icsc = 1;
- dc->caps.color.dpp.dgam_ram = 1;
- dc->caps.color.dpp.dgam_rom_caps.srgb = 1;
- dc->caps.color.dpp.dgam_rom_caps.bt2020 = 1;
- dc->caps.color.dpp.dgam_rom_caps.gamma2_2 = 0;
- dc->caps.color.dpp.dgam_rom_caps.pq = 0;
- dc->caps.color.dpp.dgam_rom_caps.hlg = 0;
- dc->caps.color.dpp.post_csc = 0;
- dc->caps.color.dpp.gamma_corr = 0;
- dc->caps.color.dpp.dgam_rom_for_yuv = 1;
-
- dc->caps.color.dpp.hw_3d_lut = 1;
- dc->caps.color.dpp.ogam_ram = 1;
- // no OGAM ROM on DCN2, only MPC ROM
- dc->caps.color.dpp.ogam_rom_caps.srgb = 0;
- dc->caps.color.dpp.ogam_rom_caps.bt2020 = 0;
- dc->caps.color.dpp.ogam_rom_caps.gamma2_2 = 0;
- dc->caps.color.dpp.ogam_rom_caps.pq = 0;
- dc->caps.color.dpp.ogam_rom_caps.hlg = 0;
- dc->caps.color.dpp.ocsc = 0;
-
- dc->caps.color.mpc.gamut_remap = 0;
- dc->caps.color.mpc.num_3dluts = 0;
- dc->caps.color.mpc.shared_3d_lut = 0;
- dc->caps.color.mpc.ogam_ram = 1;
- dc->caps.color.mpc.ogam_rom_caps.srgb = 0;
- dc->caps.color.mpc.ogam_rom_caps.bt2020 = 0;
- dc->caps.color.mpc.ogam_rom_caps.gamma2_2 = 0;
- dc->caps.color.mpc.ogam_rom_caps.pq = 0;
- dc->caps.color.mpc.ogam_rom_caps.hlg = 0;
- dc->caps.color.mpc.ocsc = 1;
-
- dc->caps.dp_hdmi21_pcon_support = true;
-
- if (dc->ctx->dce_environment == DCE_ENV_PRODUCTION_DRV)
- dc->debug = debug_defaults_drv;
-
- //dcn2.0x
- dc->work_arounds.dedcn20_305_wa = true;
-
- // Init the vm_helper
- if (dc->vm_helper)
- vm_helper_init(dc->vm_helper, 16);
-
- /*************************************************
- * Create resources *
- *************************************************/
-
- pool->base.clock_sources[DCN20_CLK_SRC_PLL0] =
- dcn20_clock_source_create(ctx, ctx->dc_bios,
- CLOCK_SOURCE_COMBO_PHY_PLL0,
- &clk_src_regs[0], false);
- pool->base.clock_sources[DCN20_CLK_SRC_PLL1] =
- dcn20_clock_source_create(ctx, ctx->dc_bios,
- CLOCK_SOURCE_COMBO_PHY_PLL1,
- &clk_src_regs[1], false);
- pool->base.clock_sources[DCN20_CLK_SRC_PLL2] =
- dcn20_clock_source_create(ctx, ctx->dc_bios,
- CLOCK_SOURCE_COMBO_PHY_PLL2,
- &clk_src_regs[2], false);
- pool->base.clock_sources[DCN20_CLK_SRC_PLL3] =
- dcn20_clock_source_create(ctx, ctx->dc_bios,
- CLOCK_SOURCE_COMBO_PHY_PLL3,
- &clk_src_regs[3], false);
- pool->base.clock_sources[DCN20_CLK_SRC_PLL4] =
- dcn20_clock_source_create(ctx, ctx->dc_bios,
- CLOCK_SOURCE_COMBO_PHY_PLL4,
- &clk_src_regs[4], false);
- pool->base.clock_sources[DCN20_CLK_SRC_PLL5] =
- dcn20_clock_source_create(ctx, ctx->dc_bios,
- CLOCK_SOURCE_COMBO_PHY_PLL5,
- &clk_src_regs[5], false);
- pool->base.clk_src_count = DCN20_CLK_SRC_TOTAL;
- /* todo: not reuse phy_pll registers */
- pool->base.dp_clock_source =
- dcn20_clock_source_create(ctx, ctx->dc_bios,
- CLOCK_SOURCE_ID_DP_DTO,
- &clk_src_regs[0], true);
-
- for (i = 0; i < pool->base.clk_src_count; i++) {
- if (pool->base.clock_sources[i] == NULL) {
- dm_error("DC: failed to create clock sources!\n");
- BREAK_TO_DEBUGGER();
- goto create_fail;
- }
- }
-
- pool->base.dccg = dccg2_create(ctx, &dccg_regs, &dccg_shift, &dccg_mask);
- if (pool->base.dccg == NULL) {
- dm_error("DC: failed to create dccg!\n");
- BREAK_TO_DEBUGGER();
- goto create_fail;
- }
-
- pool->base.dmcu = dcn20_dmcu_create(ctx,
- &dmcu_regs,
- &dmcu_shift,
- &dmcu_mask);
- if (pool->base.dmcu == NULL) {
- dm_error("DC: failed to create dmcu!\n");
- BREAK_TO_DEBUGGER();
- goto create_fail;
- }
-
- pool->base.abm = dce_abm_create(ctx,
- &abm_regs,
- &abm_shift,
- &abm_mask);
- if (pool->base.abm == NULL) {
- dm_error("DC: failed to create abm!\n");
- BREAK_TO_DEBUGGER();
- goto create_fail;
- }
-
- pool->base.pp_smu = dcn20_pp_smu_create(ctx);
-
-
- if (!init_soc_bounding_box(dc, pool)) {
- dm_error("DC: failed to initialize soc bounding box!\n");
- BREAK_TO_DEBUGGER();
- goto create_fail;
- }
-
- dml_init_instance(&dc->dml, loaded_bb, loaded_ip, dml_project_version);
-
- if (!dc->debug.disable_pplib_wm_range) {
- struct pp_smu_wm_range_sets ranges = {0};
- int i = 0;
-
- ranges.num_reader_wm_sets = 0;
-
- if (loaded_bb->num_states == 1) {
- ranges.reader_wm_sets[0].wm_inst = i;
- ranges.reader_wm_sets[0].min_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN;
- ranges.reader_wm_sets[0].max_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX;
- ranges.reader_wm_sets[0].min_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN;
- ranges.reader_wm_sets[0].max_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX;
-
- ranges.num_reader_wm_sets = 1;
- } else if (loaded_bb->num_states > 1) {
- for (i = 0; i < 4 && i < loaded_bb->num_states; i++) {
- ranges.reader_wm_sets[i].wm_inst = i;
- ranges.reader_wm_sets[i].min_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN;
- ranges.reader_wm_sets[i].max_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX;
- DC_FP_START();
- dcn20_fpu_set_wm_ranges(i, &ranges, loaded_bb);
- DC_FP_END();
-
- ranges.num_reader_wm_sets = i + 1;
- }
-
- ranges.reader_wm_sets[0].min_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN;
- ranges.reader_wm_sets[ranges.num_reader_wm_sets - 1].max_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX;
- }
-
- ranges.num_writer_wm_sets = 1;
-
- ranges.writer_wm_sets[0].wm_inst = 0;
- ranges.writer_wm_sets[0].min_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN;
- ranges.writer_wm_sets[0].max_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX;
- ranges.writer_wm_sets[0].min_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN;
- ranges.writer_wm_sets[0].max_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX;
-
- /* Notify PP Lib/SMU which Watermarks to use for which clock ranges */
- if (pool->base.pp_smu->nv_funcs.set_wm_ranges)
- pool->base.pp_smu->nv_funcs.set_wm_ranges(&pool->base.pp_smu->nv_funcs.pp_smu, &ranges);
- }
-
- init_data.ctx = dc->ctx;
- pool->base.irqs = dal_irq_service_dcn20_create(&init_data);
- if (!pool->base.irqs)
- goto create_fail;
-
- /* mem input -> ipp -> dpp -> opp -> TG */
- for (i = 0; i < pool->base.pipe_count; i++) {
- pool->base.hubps[i] = dcn20_hubp_create(ctx, i);
- if (pool->base.hubps[i] == NULL) {
- BREAK_TO_DEBUGGER();
- dm_error(
- "DC: failed to create memory input!\n");
- goto create_fail;
- }
-
- pool->base.ipps[i] = dcn20_ipp_create(ctx, i);
- if (pool->base.ipps[i] == NULL) {
- BREAK_TO_DEBUGGER();
- dm_error(
- "DC: failed to create input pixel processor!\n");
- goto create_fail;
- }
-
- pool->base.dpps[i] = dcn20_dpp_create(ctx, i);
- if (pool->base.dpps[i] == NULL) {
- BREAK_TO_DEBUGGER();
- dm_error(
- "DC: failed to create dpps!\n");
- goto create_fail;
- }
- }
- for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
- pool->base.engines[i] = dcn20_aux_engine_create(ctx, i);
- if (pool->base.engines[i] == NULL) {
- BREAK_TO_DEBUGGER();
- dm_error(
- "DC:failed to create aux engine!!\n");
- goto create_fail;
- }
- pool->base.hw_i2cs[i] = dcn20_i2c_hw_create(ctx, i);
- if (pool->base.hw_i2cs[i] == NULL) {
- BREAK_TO_DEBUGGER();
- dm_error(
- "DC:failed to create hw i2c!!\n");
- goto create_fail;
- }
- pool->base.sw_i2cs[i] = NULL;
- }
-
- for (i = 0; i < pool->base.res_cap->num_opp; i++) {
- pool->base.opps[i] = dcn20_opp_create(ctx, i);
- if (pool->base.opps[i] == NULL) {
- BREAK_TO_DEBUGGER();
- dm_error(
- "DC: failed to create output pixel processor!\n");
- goto create_fail;
- }
- }
-
- for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) {
- pool->base.timing_generators[i] = dcn20_timing_generator_create(
- ctx, i);
- if (pool->base.timing_generators[i] == NULL) {
- BREAK_TO_DEBUGGER();
- dm_error("DC: failed to create tg!\n");
- goto create_fail;
- }
- }
-
- pool->base.timing_generator_count = i;
-
- pool->base.mpc = dcn20_mpc_create(ctx);
- if (pool->base.mpc == NULL) {
- BREAK_TO_DEBUGGER();
- dm_error("DC: failed to create mpc!\n");
- goto create_fail;
- }
-
- pool->base.hubbub = dcn20_hubbub_create(ctx);
- if (pool->base.hubbub == NULL) {
- BREAK_TO_DEBUGGER();
- dm_error("DC: failed to create hubbub!\n");
- goto create_fail;
- }
-
- for (i = 0; i < pool->base.res_cap->num_dsc; i++) {
- pool->base.dscs[i] = dcn20_dsc_create(ctx, i);
- if (pool->base.dscs[i] == NULL) {
- BREAK_TO_DEBUGGER();
- dm_error("DC: failed to create display stream compressor %d!\n", i);
- goto create_fail;
- }
- }
-
- if (!dcn20_dwbc_create(ctx, &pool->base)) {
- BREAK_TO_DEBUGGER();
- dm_error("DC: failed to create dwbc!\n");
- goto create_fail;
- }
- if (!dcn20_mmhubbub_create(ctx, &pool->base)) {
- BREAK_TO_DEBUGGER();
- dm_error("DC: failed to create mcif_wb!\n");
- goto create_fail;
- }
-
- if (!resource_construct(num_virtual_links, dc, &pool->base,
- &res_create_funcs))
- goto create_fail;
-
- dcn20_hw_sequencer_construct(dc);
-
- // IF NV12, set PG function pointer to NULL. It's not that
- // PG isn't supported for NV12, it's that we don't want to
- // program the registers because that will cause more power
- // to be consumed. We could have created dcn20_init_hw to get
- // the same effect by checking ASIC rev, but there was a
- // request at some point to not check ASIC rev on hw sequencer.
- if (ASICREV_IS_NAVI12_P(dc->ctx->asic_id.hw_internal_rev)) {
- dc->hwseq->funcs.enable_power_gating_plane = NULL;
- dc->debug.disable_dpp_power_gate = true;
- dc->debug.disable_hubp_power_gate = true;
- }
-
-
- dc->caps.max_planes = pool->base.pipe_count;
-
- for (i = 0; i < dc->caps.max_planes; ++i)
- dc->caps.planes[i] = plane_cap;
-
- dc->cap_funcs = cap_funcs;
-
- if (dc->ctx->dc_bios->fw_info.oem_i2c_present) {
- ddc_init_data.ctx = dc->ctx;
- ddc_init_data.link = NULL;
- ddc_init_data.id.id = dc->ctx->dc_bios->fw_info.oem_i2c_obj_id;
- ddc_init_data.id.enum_id = 0;
- ddc_init_data.id.type = OBJECT_TYPE_GENERIC;
- pool->base.oem_device = dc->link_srv->create_ddc_service(&ddc_init_data);
- } else {
- pool->base.oem_device = NULL;
- }
-
- return true;
-
-create_fail:
-
- dcn20_resource_destruct(pool);
-
- return false;
-}
-
-struct resource_pool *dcn20_create_resource_pool(
- const struct dc_init_data *init_data,
- struct dc *dc)
-{
- struct dcn20_resource_pool *pool =
- kzalloc(sizeof(struct dcn20_resource_pool), GFP_ATOMIC);
-
- if (!pool)
- return NULL;
-
- if (dcn20_resource_construct(init_data->num_virtual_links, dc, pool))
- return &pool->base;
-
- BREAK_TO_DEBUGGER();
- kfree(pool);
- return NULL;
-}
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.h b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.h
deleted file mode 100644
index 4cee3fa11a..0000000000
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.h
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
-* Copyright 2017 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: AMD
- *
- */
-
-#ifndef __DC_RESOURCE_DCN20_H__
-#define __DC_RESOURCE_DCN20_H__
-
-#include "core_types.h"
-#include "dml/dcn20/dcn20_fpu.h"
-
-#define TO_DCN20_RES_POOL(pool)\
- container_of(pool, struct dcn20_resource_pool, base)
-
-struct dc;
-struct resource_pool;
-struct _vcs_dpi_display_pipe_params_st;
-
-extern struct _vcs_dpi_ip_params_st dcn2_0_ip;
-extern struct _vcs_dpi_ip_params_st dcn2_0_nv14_ip;
-extern struct _vcs_dpi_soc_bounding_box_st dcn2_0_soc;
-extern struct _vcs_dpi_soc_bounding_box_st dcn2_0_nv14_soc;
-extern struct _vcs_dpi_soc_bounding_box_st dcn2_0_nv12_soc;
-
-struct dcn20_resource_pool {
- struct resource_pool base;
-};
-struct resource_pool *dcn20_create_resource_pool(
- const struct dc_init_data *init_data,
- struct dc *dc);
-
-struct link_encoder *dcn20_link_encoder_create(
- struct dc_context *ctx,
- const struct encoder_init_data *enc_init_data);
-
-unsigned int dcn20_calc_max_scaled_time(
- unsigned int time_per_pixel,
- enum mmhubbub_wbif_mode mode,
- unsigned int urgent_watermark);
-
-struct pipe_ctx *dcn20_acquire_free_pipe_for_layer(
- const struct dc_state *cur_ctx,
- struct dc_state *new_ctx,
- const struct resource_pool *pool,
- const struct pipe_ctx *opp_head_pipe);
-void dcn20_release_pipe(struct dc_state *context,
- struct pipe_ctx *pipe,
- const struct resource_pool *pool);
-struct stream_encoder *dcn20_stream_encoder_create(
- enum engine_id eng_id,
- struct dc_context *ctx);
-
-struct dce_hwseq *dcn20_hwseq_create(
- struct dc_context *ctx);
-
-bool dcn20_get_dcc_compression_cap(const struct dc *dc,
- const struct dc_dcc_surface_param *input,
- struct dc_surface_dcc_cap *output);
-
-void dcn20_dpp_destroy(struct dpp **dpp);
-
-struct dpp *dcn20_dpp_create(
- struct dc_context *ctx,
- uint32_t inst);
-
-struct input_pixel_processor *dcn20_ipp_create(
- struct dc_context *ctx, uint32_t inst);
-
-struct output_pixel_processor *dcn20_opp_create(
- struct dc_context *ctx, uint32_t inst);
-
-struct dce_aux *dcn20_aux_engine_create(
- struct dc_context *ctx, uint32_t inst);
-
-struct dce_i2c_hw *dcn20_i2c_hw_create(
- struct dc_context *ctx,
- uint32_t inst);
-
-void dcn20_clock_source_destroy(struct clock_source **clk_src);
-
-struct display_stream_compressor *dcn20_dsc_create(
- struct dc_context *ctx, uint32_t inst);
-void dcn20_dsc_destroy(struct display_stream_compressor **dsc);
-
-struct hubp *dcn20_hubp_create(
- struct dc_context *ctx,
- uint32_t inst);
-struct timing_generator *dcn20_timing_generator_create(
- struct dc_context *ctx,
- uint32_t instance);
-struct mpc *dcn20_mpc_create(struct dc_context *ctx);
-struct hubbub *dcn20_hubbub_create(struct dc_context *ctx);
-
-bool dcn20_dwbc_create(struct dc_context *ctx, struct resource_pool *pool);
-bool dcn20_mmhubbub_create(struct dc_context *ctx, struct resource_pool *pool);
-
-void dcn20_set_mcif_arb_params(
- struct dc *dc,
- struct dc_state *context,
- display_e2e_pipe_params_st *pipes,
- int pipe_cnt);
-bool dcn20_validate_bandwidth(struct dc *dc, struct dc_state *context, bool fast_validate);
-void dcn20_merge_pipes_for_validate(
- struct dc *dc,
- struct dc_state *context);
-int dcn20_validate_apply_pipe_split_flags(
- struct dc *dc,
- struct dc_state *context,
- int vlevel,
- int *split,
- bool *merge);
-void dcn20_release_dsc(struct resource_context *res_ctx,
- const struct resource_pool *pool,
- struct display_stream_compressor **dsc);
-bool dcn20_validate_dsc(struct dc *dc, struct dc_state *new_ctx);
-void dcn20_split_stream_for_mpc(
- struct resource_context *res_ctx,
- const struct resource_pool *pool,
- struct pipe_ctx *primary_pipe,
- struct pipe_ctx *secondary_pipe);
-bool dcn20_split_stream_for_odm(
- const struct dc *dc,
- struct resource_context *res_ctx,
- struct pipe_ctx *prev_odm_pipe,
- struct pipe_ctx *next_odm_pipe);
-void dcn20_acquire_dsc(const struct dc *dc,
- struct resource_context *res_ctx,
- struct display_stream_compressor **dsc,
- int pipe_idx);
-struct pipe_ctx *dcn20_find_secondary_pipe(struct dc *dc,
- struct resource_context *res_ctx,
- const struct resource_pool *pool,
- const struct pipe_ctx *primary_pipe);
-bool dcn20_fast_validate_bw(
- struct dc *dc,
- struct dc_state *context,
- display_e2e_pipe_params_st *pipes,
- int *pipe_cnt_out,
- int *pipe_split_from,
- int *vlevel_out,
- bool fast_validate);
-
-enum dc_status dcn20_build_mapped_resource(const struct dc *dc, struct dc_state *context, struct dc_stream_state *stream);
-enum dc_status dcn20_add_stream_to_ctx(struct dc *dc, struct dc_state *new_ctx, struct dc_stream_state *dc_stream);
-enum dc_status dcn20_add_dsc_to_stream_resource(struct dc *dc, struct dc_state *dc_ctx, struct dc_stream_state *dc_stream);
-enum dc_status dcn20_remove_stream_from_ctx(struct dc *dc, struct dc_state *new_ctx, struct dc_stream_state *dc_stream);
-enum dc_status dcn20_patch_unknown_plane_state(struct dc_plane_state *plane_state);
-void dcn20_build_pipe_pix_clk_params(struct pipe_ctx *pipe_ctx);
-
-#endif /* __DC_RESOURCE_DCN20_H__ */
-