<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;" align="Left">
[AMD Official Use Only]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi Mike,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Per error message:<br>
<br>
<font size="2"><span style="font-size:11pt"> CC drivers/gpu/drm/amd/amdgpu/../display/dc/dcn30/dcn30_optc.o<br>
clang-12: error: unknown argument: '-mpreferred-stack-boundary=4'<br>
make[4]: *** [scripts/Makefile.build:278: drivers/gpu/drm/amd/amdgpu/../display/dc/dcn30/dcn30_optc.o] Error 1</span></font><br>
<br>
Issue came from dcn30_optc. We didn't change either <font size="2"><span style="font-size:11pt">dcn30_optc</span></font>.c/.h, or
<font size="2"><span style="font-size:11pt">-mpreferred-stack-boundary</span></font> in Makefile within this patch, and the whole kernel was buildable on my side. Could it be some other patches influenced the build on your side? Also, did you try reverting
this patch and see if it's buildable?</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Zhan<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Mike Lothian <mike@fireburn.co.uk><br>
<b>Sent:</b> Wednesday, September 29, 2021 7:22 PM<br>
<b>To:</b> Liu, Zhan <Zhan.Liu@amd.com><br>
<b>Cc:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Liu, Charlene <Charlene.Liu@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; Wentland, Harry <Harry.Wentland@amd.com>; Pillai, Aurabindo <Aurabindo.Pillai@amd.com><br>
<b>Subject:</b> Re: [PATCH 02/02 v2] drm/amd/display: add cyan_skillfish display support</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Hi<br>
<br>
This patch is causing a failure for me when building with clang:<br>
<br>
<br>
Enable DCN201 support in DC (DRM_AMD_DC_DCN201) [Y/n/?] (NEW) y<br>
Enable HDCP support in DC (DRM_AMD_DC_HDCP) [Y/n/?] y<br>
AMD DC support for Southern Islands ASICs (DRM_AMD_DC_SI) [N/y/?] n<br>
Enable secure display support (DRM_AMD_SECURE_DISPLAY) [Y/n/?] y<br>
DESCEND objtool<br>
CALL scripts/atomic/check-atomics.sh<br>
CALL scripts/checksyscalls.sh<br>
CHK include/generated/compile.h<br>
UPD kernel/config_data<br>
GZIP kernel/config_data.gz<br>
CC kernel/configs.o<br>
AR kernel/built-in.a<br>
CC drivers/gpu/drm/amd/amdgpu/../display/dc/clk_mgr/clk_mgr.o<br>
CC drivers/gpu/drm/amd/amdgpu/../display/dc/dcn30/dcn30_optc.o<br>
clang-12: error: unknown argument: '-mpreferred-stack-boundary=4'<br>
make[4]: *** [scripts/Makefile.build:278:<br>
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn30/dcn30_optc.o] Error 1<br>
make[4]: *** Waiting for unfinished jobs....<br>
make[3]: *** [scripts/Makefile.build:540: drivers/gpu/drm/amd/amdgpu] Error 2<br>
make[2]: *** [scripts/Makefile.build:540: drivers/gpu/drm] Error 2<br>
make[1]: *** [scripts/Makefile.build:540: drivers/gpu] Error 2<br>
make: *** [Makefile:1868: drivers] Error 2<br>
<br>
On Mon, 27 Sept 2021 at 22:16, Liu, Zhan <Zhan.Liu@amd.com> wrote:<br>
><br>
> [Public]<br>
><br>
> [Why]<br>
> add display related cyan_skillfish files in.<br>
><br>
> makefile controlled by CONFIG_DRM_AMD_DC_DCN201 flag.<br>
><br>
> Signed-off-by: Charlene Liu <charlene.liu@amd.com><br>
> Signed-off-by: Zhan Liu <zhan.liu@amd.com><br>
> Reviewed-by: Charlene Liu <charlene.liu@amd.com><br>
> Acked-by: Jun Lei <jun.lei@amd.com><br>
> ---<br>
><br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
> index 1d6cc93..0c669e4 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
> @@ -1968,6 +1968,9 @@<br>
> case CHIP_VANGOGH:<br>
> chip_name = "vangogh";<br>
> break;<br>
> + case CHIP_CYAN_SKILLFISH:<br>
> + chip_name = "cyan_skillfish";<br>
> + break;<br>
> case CHIP_YELLOW_CARP:<br>
> chip_name = "yellow_carp";<br>
> break;<br>
> @@ -3240,6 +3243,7 @@<br>
> case CHIP_NAVI14:<br>
> case CHIP_NAVI12:<br>
> case CHIP_RENOIR:<br>
> + case CHIP_CYAN_SKILLFISH:<br>
> case CHIP_SIENNA_CICHLID:<br>
> case CHIP_NAVY_FLOUNDER:<br>
> case CHIP_DIMGREY_CAVEFISH:<br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c<br>
> index ff80786..d9a10ec 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/nv.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/nv.c<br>
> @@ -906,6 +906,8 @@<br>
> }<br>
> if (adev->enable_virtual_display || amdgpu_sriov_vf(adev))<br>
> amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block);<br>
> + else if (amdgpu_device_has_dc_support(adev))<br>
> + amdgpu_device_ip_block_add(adev, &dm_ip_block);<br>
> amdgpu_device_ip_block_add(adev, &gfx_v10_0_ip_block);<br>
> amdgpu_device_ip_block_add(adev, &sdma_v5_0_ip_block);<br>
> break;<br>
> diff --git a/drivers/gpu/drm/amd/display/Kconfig b/drivers/gpu/drm/amd/display/Kconfig<br>
> index 7dffc04..fb074a6 100644<br>
> --- a/drivers/gpu/drm/amd/display/Kconfig<br>
> +++ b/drivers/gpu/drm/amd/display/Kconfig<br>
> @@ -17,6 +17,15 @@<br>
> help<br>
> Raven, Navi, and newer family support for display engine<br>
><br>
> +config DRM_AMD_DC_DCN201<br>
> + bool "Enable DCN201 support in DC"<br>
> + default y<br>
> + depends on DRM_AMD_DC && X86<br>
> + depends on DRM_AMD_DC_DCN<br>
> + help<br>
> + Choose this option if you want to have<br>
> + 201 support for display engine<br>
> +<br>
> config DRM_AMD_DC_HDCP<br>
> bool "Enable HDCP support in DC"<br>
> depends on DRM_AMD_DC<br>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
> index e676d0a..3c7a8f8 100644<br>
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
> @@ -1352,6 +1352,9 @@<br>
> case CHIP_YELLOW_CARP:<br>
> init_data.flags.gpu_vm_support = true;<br>
> break;<br>
> + case CHIP_CYAN_SKILLFISH:<br>
> + init_data.flags.disable_dmcu = true;<br>
> + break;<br>
> default:<br>
> break;<br>
> }<br>
> @@ -1647,6 +1650,7 @@<br>
> case CHIP_BEIGE_GOBY:<br>
> case CHIP_VANGOGH:<br>
> case CHIP_YELLOW_CARP:<br>
> + case CHIP_CYAN_SKILLFISH:<br>
> return 0;<br>
> case CHIP_NAVI12:<br>
> fw_name_dmcu = FIRMWARE_NAVI12_DMCU;<br>
> @@ -4182,6 +4186,7 @@<br>
> case CHIP_DIMGREY_CAVEFISH:<br>
> case CHIP_BEIGE_GOBY:<br>
> case CHIP_VANGOGH:<br>
> + case CHIP_CYAN_SKILLFISH:<br>
> case CHIP_YELLOW_CARP:<br>
> if (dcn10_register_irq_handlers(dm->adev)) {<br>
> DRM_ERROR("DM: Failed to initialize IRQ\n");<br>
> @@ -4359,6 +4364,11 @@<br>
> adev->mode_info.num_hpd = 4;<br>
> adev->mode_info.num_dig = 4;<br>
> break;<br>
> + case CHIP_CYAN_SKILLFISH:<br>
> + adev->mode_info.num_crtc = 2;<br>
> + adev->mode_info.num_hpd = 2;<br>
> + adev->mode_info.num_dig = 2;<br>
> + break;<br>
> case CHIP_NAVI14:<br>
> case CHIP_DIMGREY_CAVEFISH:<br>
> adev->mode_info.num_crtc = 5;<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/Makefile b/drivers/gpu/drm/amd/display/dc/Makefile<br>
> index 943fcb1..520f585 100644<br>
> --- a/drivers/gpu/drm/amd/display/dc/Makefile<br>
> +++ b/drivers/gpu/drm/amd/display/dc/Makefile<br>
> @@ -30,6 +30,9 @@<br>
> DC_LIBS += dsc<br>
> DC_LIBS += dcn10 dml<br>
> DC_LIBS += dcn21<br>
> +ifdef CONFIG_DRM_AMD_DC_DCN201<br>
> +DC_LIBS += dcn201<br>
> +endif<br>
> DC_LIBS += dcn30<br>
> DC_LIBS += dcn301<br>
> DC_LIBS += dcn302<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/bios/command_table_helper2.c b/drivers/gpu/drm/amd/display/dc/bios/command_table_helper2.c<br>
> index cb3fd44..eedc553 100644<br>
> --- a/drivers/gpu/drm/amd/display/dc/bios/command_table_helper2.c<br>
> +++ b/drivers/gpu/drm/amd/display/dc/bios/command_table_helper2.c<br>
> @@ -70,6 +70,7 @@<br>
> case DCN_VERSION_1_01:<br>
> case DCN_VERSION_2_0:<br>
> case DCN_VERSION_2_1:<br>
> + case DCN_VERSION_2_01:<br>
> case DCN_VERSION_3_0:<br>
> case DCN_VERSION_3_01:<br>
> case DCN_VERSION_3_02:<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/Makefile b/drivers/gpu/drm/amd/display/dc/clk_mgr/Makefile<br>
> index 7fa0b00..7f70985 100644<br>
> --- a/drivers/gpu/drm/amd/display/dc/clk_mgr/Makefile<br>
> +++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/Makefile<br>
> @@ -93,6 +93,17 @@<br>
><br>
> AMD_DISPLAY_FILES += $(AMD_DAL_CLK_MGR_DCN20)<br>
><br>
> +ifdef CONFIG_DRM_AMD_DC_DCN201<br>
> +###############################################################################<br>
> +# DCN201<br>
> +###############################################################################<br>
> +CLK_MGR_DCN201 = dcn201_clk_mgr.o<br>
> +<br>
> +AMD_DAL_CLK_MGR_DCN201 = $(addprefix $(AMDDALPATH)/dc/clk_mgr/dcn201/,$(CLK_MGR_DCN201))<br>
> +<br>
> +AMD_DISPLAY_FILES += $(AMD_DAL_CLK_MGR_DCN201)<br>
> +endif<br>
> +<br>
> ###############################################################################<br>
> # DCN21<br>
> ###############################################################################<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/clk_mgr.c<br>
> index bb31541..421f513 100644<br>
> --- a/drivers/gpu/drm/amd/display/dc/clk_mgr/clk_mgr.c<br>
> +++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/clk_mgr.c<br>
> @@ -39,6 +39,7 @@<br>
> #include "dcn10/rv2_clk_mgr.h"<br>
> #include "dcn20/dcn20_clk_mgr.h"<br>
> #include "dcn21/rn_clk_mgr.h"<br>
> +#include "dcn201/dcn201_clk_mgr.h"<br>
> #include "dcn30/dcn30_clk_mgr.h"<br>
> #include "dcn301/vg_clk_mgr.h"<br>
> #include "dcn31/dcn31_clk_mgr.h"<br>
> @@ -256,6 +257,12 @@<br>
> dcn3_clk_mgr_construct(ctx, clk_mgr, pp_smu, dccg);<br>
> return &clk_mgr->base;<br>
> }<br>
> +#if defined(CONFIG_DRM_AMD_DC_DCN201)<br>
> + if (asic_id.chip_id == DEVICE_ID_NV_13FE) {<br>
> + dcn201_clk_mgr_construct(ctx, clk_mgr, pp_smu, dccg);<br>
> + return &clk_mgr->base;<br>
> + }<br>
> +#endif<br>
> dcn20_clk_mgr_construct(ctx, clk_mgr, pp_smu, dccg);<br>
> return &clk_mgr->base;<br>
> }<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn201/dcn201_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn201/dcn201_clk_mgr.c<br>
> new file mode 100644<br>
> index 0000000..46e7efe<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn201/dcn201_clk_mgr.c<br>
> @@ -0,0 +1,260 @@<br>
> +/*<br>
> + * Copyright 2018 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +<br>
> +#include "reg_helper.h"<br>
> +#include "core_types.h"<br>
> +#include "dccg.h"<br>
> +#include "clk_mgr_internal.h"<br>
> +#include "dcn201_clk_mgr.h"<br>
> +#include "dcn20/dcn20_clk_mgr.h"<br>
> +#include "dce100/dce_clk_mgr.h"<br>
> +#include "reg_helper.h"<br>
> +#include "core_types.h"<br>
> +#include "dm_helpers.h"<br>
> +#include "dm_services.h"<br>
> +<br>
> +#include "cyan_skillfish_ip_offset.h"<br>
> +#include "dcn/dcn_2_0_3_offset.h"<br>
> +#include "dcn/dcn_2_0_3_sh_mask.h"<br>
> +#include "clk/clk_11_0_1_offset.h"<br>
> +#include "clk/clk_11_0_1_sh_mask.h"<br>
> +<br>
> +#define REG(reg) \<br>
> + (clk_mgr->regs->reg)<br>
> +<br>
> +#define BASE_INNER(seg) DMU_BASE__INST0_SEG ## seg<br>
> +<br>
> +#define BASE(seg) BASE_INNER(seg)<br>
> +<br>
> +#define SR(reg_name)\<br>
> + .reg_name = BASE(mm ## reg_name ## _BASE_IDX) + \<br>
> + mm ## reg_name<br>
> +<br>
> +#define CLK_BASE_INNER(seg) \<br>
> + CLK_BASE__INST0_SEG ## seg<br>
> +<br>
> +#undef FN<br>
> +#define FN(reg_name, field_name) \<br>
> + clk_mgr->clk_mgr_shift->field_name, clk_mgr->clk_mgr_mask->field_name<br>
> +<br>
> +#define CTX \<br>
> + clk_mgr->base.ctx<br>
> +#define DC_LOGGER \<br>
> + clk_mgr->base.ctx->logger<br>
> +<br>
> +static const struct clk_mgr_registers clk_mgr_regs = {<br>
> + CLK_COMMON_REG_LIST_DCN_201()<br>
> +};<br>
> +<br>
> +static const struct clk_mgr_shift clk_mgr_shift = {<br>
> + CLK_COMMON_MASK_SH_LIST_DCN201_BASE(__SHIFT)<br>
> +};<br>
> +<br>
> +static const struct clk_mgr_mask clk_mgr_mask = {<br>
> + CLK_COMMON_MASK_SH_LIST_DCN201_BASE(_MASK)<br>
> +};<br>
> +<br>
> +void dcn201_update_clocks_vbios(struct clk_mgr *clk_mgr,<br>
> + struct dc_state *context,<br>
> + bool safe_to_lower)<br>
> +{<br>
> + struct dc_clocks *new_clocks = &context->bw_ctx.bw.dcn.clk;<br>
> +<br>
> + bool update_dppclk = false;<br>
> + bool update_dispclk = false;<br>
> +<br>
> + if (should_set_clock(safe_to_lower, new_clocks->dppclk_khz, clk_mgr->clks.dppclk_khz)) {<br>
> + clk_mgr->clks.dppclk_khz = new_clocks->dppclk_khz;<br>
> + update_dppclk = true;<br>
> + }<br>
> +<br>
> + if (should_set_clock(safe_to_lower, new_clocks->dispclk_khz, clk_mgr->clks.dispclk_khz)) {<br>
> + clk_mgr->clks.dispclk_khz = new_clocks->dispclk_khz;<br>
> + update_dispclk = true;<br>
> + }<br>
> +<br>
> + if (update_dppclk || update_dispclk) {<br>
> + struct bp_set_dce_clock_parameters dce_clk_params;<br>
> + struct dc_bios *bp = clk_mgr->ctx->dc_bios;<br>
> +<br>
> + if (update_dispclk) {<br>
> + memset(&dce_clk_params, 0, sizeof(dce_clk_params));<br>
> + dce_clk_params.target_clock_frequency = new_clocks->dispclk_khz;<br>
> + dce_clk_params.pll_id = CLOCK_SOURCE_ID_DFS;<br>
> + dce_clk_params.clock_type = DCECLOCK_TYPE_DISPLAY_CLOCK;<br>
> + bp->funcs->set_dce_clock(bp, &dce_clk_params);<br>
> + }<br>
> + /* currently there is no DCECLOCK_TYPE_DPPCLK type defined in VBIOS interface.<br>
> + * vbios program DPPCLK to the same DispCLK limitation<br>
> + */<br>
> + }<br>
> +}<br>
> +<br>
> +static void dcn201_init_clocks(struct clk_mgr *clk_mgr)<br>
> +{<br>
> + memset(&(clk_mgr->clks), 0, sizeof(struct dc_clocks));<br>
> + clk_mgr->clks.p_state_change_support = true;<br>
> + clk_mgr->clks.prev_p_state_change_support = true;<br>
> + clk_mgr->clks.max_supported_dppclk_khz = 1200000;<br>
> + clk_mgr->clks.max_supported_dispclk_khz = 1200000;<br>
> +}<br>
> +<br>
> +static void dcn201_update_clocks(struct clk_mgr *clk_mgr_base,<br>
> + struct dc_state *context,<br>
> + bool safe_to_lower)<br>
> +{<br>
> + struct clk_mgr_internal *clk_mgr = TO_CLK_MGR_INTERNAL(clk_mgr_base);<br>
> + struct dc_clocks *new_clocks = &context->bw_ctx.bw.dcn.clk;<br>
> + struct dc *dc = clk_mgr_base->ctx->dc;<br>
> + int display_count;<br>
> + bool update_dppclk = false;<br>
> + bool update_dispclk = false;<br>
> + bool enter_display_off = false;<br>
> + bool dpp_clock_lowered = false;<br>
> + bool force_reset = false;<br>
> + bool p_state_change_support;<br>
> + int total_plane_count;<br>
> +<br>
> + if (dc->work_arounds.skip_clock_update)<br>
> + return;<br>
> +<br>
> + if (clk_mgr_base->clks.dispclk_khz == 0 ||<br>
> + dc->debug.force_clock_mode & 0x1) {<br>
> + force_reset = true;<br>
> +<br>
> + dcn2_read_clocks_from_hw_dentist(clk_mgr_base);<br>
> + }<br>
> +<br>
> + display_count = clk_mgr_helper_get_active_display_cnt(dc, context);<br>
> +<br>
> + if (display_count == 0)<br>
> + enter_display_off = true;<br>
> +<br>
> + if (should_set_clock(safe_to_lower, new_clocks->phyclk_khz, clk_mgr_base->clks.phyclk_khz))<br>
> + clk_mgr_base->clks.phyclk_khz = new_clocks->phyclk_khz;<br>
> +<br>
> + if (dc->debug.force_min_dcfclk_mhz > 0)<br>
> + new_clocks->dcfclk_khz = (new_clocks->dcfclk_khz > (dc->debug.force_min_dcfclk_mhz * 1000)) ?<br>
> + new_clocks->dcfclk_khz : (dc->debug.force_min_dcfclk_mhz * 1000);<br>
> +<br>
> + if (should_set_clock(safe_to_lower, new_clocks->dcfclk_khz, clk_mgr_base->clks.dcfclk_khz))<br>
> + clk_mgr_base->clks.dcfclk_khz = new_clocks->dcfclk_khz;<br>
> +<br>
> + if (should_set_clock(safe_to_lower,<br>
> + new_clocks->dcfclk_deep_sleep_khz, clk_mgr_base->clks.dcfclk_deep_sleep_khz))<br>
> + clk_mgr_base->clks.dcfclk_deep_sleep_khz = new_clocks->dcfclk_deep_sleep_khz;<br>
> +<br>
> + if (should_set_clock(safe_to_lower, new_clocks->socclk_khz, clk_mgr_base->clks.socclk_khz))<br>
> + clk_mgr_base->clks.socclk_khz = new_clocks->socclk_khz;<br>
> +<br>
> + total_plane_count = clk_mgr_helper_get_active_plane_cnt(dc, context);<br>
> + p_state_change_support = new_clocks->p_state_change_support || (total_plane_count == 0);<br>
> + if (should_update_pstate_support(safe_to_lower, p_state_change_support, clk_mgr_base->clks.p_state_change_support)) {<br>
> + clk_mgr_base->clks.prev_p_state_change_support = clk_mgr_base->clks.p_state_change_support;<br>
> + clk_mgr_base->clks.p_state_change_support = p_state_change_support;<br>
> + }<br>
> +<br>
> + if (should_set_clock(safe_to_lower, new_clocks->dramclk_khz, clk_mgr_base->clks.dramclk_khz))<br>
> + clk_mgr_base->clks.dramclk_khz = new_clocks->dramclk_khz;<br>
> +<br>
> + if (should_set_clock(safe_to_lower, new_clocks->dppclk_khz, clk_mgr->base.clks.dppclk_khz)) {<br>
> + if (clk_mgr->base.clks.dppclk_khz > new_clocks->dppclk_khz)<br>
> + dpp_clock_lowered = true;<br>
> + clk_mgr->base.clks.dppclk_khz = new_clocks->dppclk_khz;<br>
> +<br>
> + update_dppclk = true;<br>
> + }<br>
> +<br>
> + if (should_set_clock(safe_to_lower, new_clocks->dispclk_khz, clk_mgr_base->clks.dispclk_khz)) {<br>
> + clk_mgr_base->clks.dispclk_khz = new_clocks->dispclk_khz;<br>
> +<br>
> + update_dispclk = true;<br>
> + }<br>
> +<br>
> + if (dc->config.forced_clocks == false || (force_reset && safe_to_lower)) {<br>
> + if (dpp_clock_lowered) {<br>
> + dcn20_update_clocks_update_dpp_dto(clk_mgr, context, safe_to_lower);<br>
> + dcn20_update_clocks_update_dentist(clk_mgr, context);<br>
> + } else {<br>
> + if (update_dppclk || update_dispclk)<br>
> + dcn20_update_clocks_update_dentist(clk_mgr, context);<br>
> + if (new_clocks->dppclk_khz >= dc->current_state->bw_ctx.bw.dcn.clk.dppclk_khz)<br>
> + dcn20_update_clocks_update_dpp_dto(clk_mgr, context, safe_to_lower);<br>
> + }<br>
> + }<br>
> +}<br>
> +<br>
> +struct clk_mgr_funcs dcn201_funcs = {<br>
> + .get_dp_ref_clk_frequency = dce12_get_dp_ref_freq_khz,<br>
> + .update_clocks = dcn201_update_clocks,<br>
> + .init_clocks = dcn201_init_clocks,<br>
> + .get_clock = dcn2_get_clock,<br>
> +};<br>
> +<br>
> +void dcn201_clk_mgr_construct(struct dc_context *ctx,<br>
> + struct clk_mgr_internal *clk_mgr,<br>
> + struct pp_smu_funcs *pp_smu,<br>
> + struct dccg *dccg)<br>
> +{<br>
> + struct dc_debug_options *debug = &ctx->dc->debug;<br>
> + struct dc_bios *bp = ctx->dc_bios;<br>
> + clk_mgr->base.ctx = ctx;<br>
> + clk_mgr->base.funcs = &dcn201_funcs;<br>
> + clk_mgr->regs = &clk_mgr_regs;<br>
> + clk_mgr->clk_mgr_shift = &clk_mgr_shift;<br>
> + clk_mgr->clk_mgr_mask = &clk_mgr_mask;<br>
> +<br>
> + clk_mgr->dccg = dccg;<br>
> +<br>
> + clk_mgr->dfs_bypass_disp_clk = 0;<br>
> +<br>
> + clk_mgr->dprefclk_ss_percentage = 0;<br>
> + clk_mgr->dprefclk_ss_divider = 1000;<br>
> + clk_mgr->ss_on_dprefclk = false;<br>
> +<br>
> + if (IS_FPGA_MAXIMUS_DC(ctx->dce_environment)) {<br>
> + dcn201_funcs.update_clocks = dcn2_update_clocks_fpga;<br>
> + clk_mgr->base.dprefclk_khz = 600000;<br>
> + clk_mgr->base.dentist_vco_freq_khz = 3000000;<br>
> + } else {<br>
> + clk_mgr->base.dprefclk_khz = REG_READ(CLK4_CLK2_CURRENT_CNT);<br>
> + clk_mgr->base.dprefclk_khz *= 100;<br>
> +<br>
> + if (clk_mgr->base.dprefclk_khz == 0)<br>
> + clk_mgr->base.dprefclk_khz = 600000;<br>
> +<br>
> + REG_GET(CLK4_CLK_PLL_REQ, FbMult_int, &clk_mgr->base.dentist_vco_freq_khz);<br>
> + clk_mgr->base.dentist_vco_freq_khz *= 100000;<br>
> +<br>
> + if (clk_mgr->base.dentist_vco_freq_khz == 0)<br>
> + clk_mgr->base.dentist_vco_freq_khz = 3000000;<br>
> + }<br>
> +<br>
> + if (!debug->disable_dfs_bypass && bp->integrated_info)<br>
> + if (bp->integrated_info->gpu_cap_info & DFS_BYPASS_ENABLE)<br>
> + clk_mgr->dfs_bypass_enabled = true;<br>
> +<br>
> + dce_clock_read_ss_info(clk_mgr);<br>
> +}<br>
> \ No newline at end of file<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn201/dcn201_clk_mgr.h b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn201/dcn201_clk_mgr.h<br>
> new file mode 100644<br>
> index 0000000..ae463ba<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn201/dcn201_clk_mgr.h<br>
> @@ -0,0 +1,34 @@<br>
> +/*<br>
> + * Copyright 2018 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +<br>
> +#ifndef __DCN201_CLK_MGR_H__<br>
> +#define __DCN201_CLK_MGR_H__<br>
> +<br>
> +void dcn201_clk_mgr_construct(struct dc_context *ctx,<br>
> + struct clk_mgr_internal *clk_mgr,<br>
> + struct pp_smu_funcs *pp_smu,<br>
> + struct dccg *dccg);<br>
> +<br>
> +#endif //__DCN201_CLK_MGR_H__<br>
> \ No newline at end of file<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c<br>
> index adc656f..fc490b7 100644<br>
> --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c<br>
> +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c<br>
> @@ -56,6 +56,7 @@<br>
> #include "dcn10/dcn10_resource.h"<br>
> #include "dcn20/dcn20_resource.h"<br>
> #include "dcn21/dcn21_resource.h"<br>
> +#include "dcn201/dcn201_resource.h"<br>
> #include "dcn30/dcn30_resource.h"<br>
> #include "dcn301/dcn301_resource.h"<br>
> #include "dcn302/dcn302_resource.h"<br>
> @@ -130,6 +131,10 @@<br>
><br>
> case FAMILY_NV:<br>
> dc_version = DCN_VERSION_2_0;<br>
> + if (asic_id.chip_id == DEVICE_ID_NV_13FE) {<br>
> + dc_version = DCN_VERSION_2_01;<br>
> + break;<br>
> + }<br>
> if (ASICREV_IS_SIENNA_CICHLID_P(asic_id.hw_internal_rev))<br>
> dc_version = DCN_VERSION_3_0;<br>
> if (ASICREV_IS_DIMGREY_CAVEFISH_P(asic_id.hw_internal_rev))<br>
> @@ -219,6 +224,11 @@<br>
> case DCN_VERSION_2_1:<br>
> res_pool = dcn21_create_resource_pool(init_data, dc);<br>
> break;<br>
> +#if defined(CONFIG_DRM_AMD_DC_DCN201)<br>
> + case DCN_VERSION_2_01:<br>
> + res_pool = dcn201_create_resource_pool(init_data, dc);<br>
> + break;<br>
> +#endif<br>
> case DCN_VERSION_3_0:<br>
> res_pool = dcn30_create_resource_pool(init_data, dc);<br>
> break;<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.h b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.h<br>
> index 3139285..692fa23 100644<br>
> --- a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.h<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.h<br>
> @@ -76,6 +76,15 @@<br>
> SRII(PIXEL_RATE_CNTL, OTG, 4),\<br>
> SRII(PIXEL_RATE_CNTL, OTG, 5)<br>
><br>
> +#define CS_COMMON_REG_LIST_DCN201(index, pllid) \<br>
> + SRI(PIXCLK_RESYNC_CNTL, PHYPLL, pllid),\<br>
> + SRII(PHASE, DP_DTO, 0),\<br>
> + SRII(PHASE, DP_DTO, 1),\<br>
> + SRII(MODULO, DP_DTO, 0),\<br>
> + SRII(MODULO, DP_DTO, 1),\<br>
> + SRII(PIXEL_RATE_CNTL, OTG, 0),\<br>
> + SRII(PIXEL_RATE_CNTL, OTG, 1)<br>
> +<br>
> #define CS_COMMON_REG_LIST_DCN2_1(index, pllid) \<br>
> SRI(PIXCLK_RESYNC_CNTL, PHYPLL, pllid),\<br>
> SRII(PHASE, DP_DTO, 0),\<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h b/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h<br>
> index 0464a8f..296b2f8 100644<br>
> --- a/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h<br>
> @@ -70,6 +70,10 @@<br>
> SRII(PIXEL_RATE_CNTL, blk, 4), \<br>
> SRII(PIXEL_RATE_CNTL, blk, 5)<br>
><br>
> +#define HWSEQ_PIXEL_RATE_REG_LIST_201(blk) \<br>
> + SRII(PIXEL_RATE_CNTL, blk, 0), \<br>
> + SRII(PIXEL_RATE_CNTL, blk, 1)<br>
> +<br>
> #define HWSEQ_PHYPLL_REG_LIST(blk) \<br>
> SRII(PHYPLL_PIXEL_RATE_CNTL, blk, 0), \<br>
> SRII(PHYPLL_PIXEL_RATE_CNTL, blk, 1), \<br>
> @@ -94,6 +98,10 @@<br>
> SRII(PHYPLL_PIXEL_RATE_CNTL, blk, 4), \<br>
> SRII(PHYPLL_PIXEL_RATE_CNTL, blk, 5)<br>
><br>
> +#define HWSEQ_PHYPLL_REG_LIST_201(blk) \<br>
> + SRII(PHYPLL_PIXEL_RATE_CNTL, blk, 0), \<br>
> + SRII(PHYPLL_PIXEL_RATE_CNTL, blk, 1)<br>
> +<br>
> #define HWSEQ_DCE11_REG_LIST_BASE() \<br>
> SR(DC_MEM_GLOBAL_PWR_REQ_CNTL), \<br>
> SR(DCFEV_CLOCK_CONTROL), \<br>
> @@ -337,6 +345,29 @@<br>
> SR(D6VGA_CONTROL), \<br>
> SR(DC_IP_REQUEST_CNTL)<br>
><br>
> +#define HWSEQ_DCN201_REG_LIST()\<br>
> + HWSEQ_DCN_REG_LIST(), \<br>
> + HWSEQ_PIXEL_RATE_REG_LIST_201(OTG), \<br>
> + HWSEQ_PHYPLL_REG_LIST_201(OTG), \<br>
> + SR(MICROSECOND_TIME_BASE_DIV), \<br>
> + SR(MILLISECOND_TIME_BASE_DIV), \<br>
> + SR(DISPCLK_FREQ_CHANGE_CNTL), \<br>
> + SR(RBBMIF_TIMEOUT_DIS), \<br>
> + SR(RBBMIF_TIMEOUT_DIS_2), \<br>
> + SR(DCHUBBUB_CRC_CTRL), \<br>
> + SR(DPP_TOP0_DPP_CRC_CTRL), \<br>
> + SR(DPP_TOP0_DPP_CRC_VAL_B_A), \<br>
> + SR(DPP_TOP0_DPP_CRC_VAL_R_G), \<br>
> + SR(MPC_CRC_CTRL), \<br>
> + SR(MPC_CRC_RESULT_GB), \<br>
> + SR(MPC_CRC_RESULT_C), \<br>
> + SR(MPC_CRC_RESULT_AR), \<br>
> + SR(AZALIA_AUDIO_DTO), \<br>
> + SR(AZALIA_CONTROLLER_CLOCK_GATING), \<br>
> + MMHUB_SR(MC_VM_FB_LOCATION_BASE), \<br>
> + MMHUB_SR(MC_VM_FB_LOCATION_TOP), \<br>
> + MMHUB_SR(MC_VM_FB_OFFSET)<br>
> +<br>
> #define HWSEQ_DCN30_REG_LIST()\<br>
> HWSEQ_DCN2_REG_LIST(),\<br>
> HWSEQ_DCN_REG_LIST(), \<br>
> @@ -637,6 +668,9 @@<br>
> uint32_t DMU_MEM_PWR_CNTL;<br>
> uint32_t MMHUBBUB_MEM_PWR_CNTL;<br>
> uint32_t DCHUBBUB_ARB_HOSTVM_CNTL;<br>
> + uint32_t MC_VM_FB_LOCATION_BASE;<br>
> + uint32_t MC_VM_FB_LOCATION_TOP;<br>
> + uint32_t MC_VM_FB_OFFSET;<br>
> };<br>
> /* set field name */<br>
> #define HWS_SF(blk_name, reg_name, field_name, post_fix)\<br>
> @@ -872,6 +906,11 @@<br>
> HWS_SF(, DOMAIN18_PG_STATUS, DOMAIN18_PGFSM_PWR_STATUS, mask_sh), \<br>
> HWS_SF(, DC_IP_REQUEST_CNTL, IP_REQUEST_EN, mask_sh)<br>
><br>
> +#define HWSEQ_DCN201_MASK_SH_LIST(mask_sh)\<br>
> + HWSEQ_DCN_MASK_SH_LIST(mask_sh), \<br>
> + HWS_SF(, DCHUBBUB_GLOBAL_TIMER_CNTL, DCHUBBUB_GLOBAL_TIMER_REFDIV, mask_sh), \<br>
> + HWS_SF(, AZALIA_AUDIO_DTO, AZALIA_AUDIO_DTO_MODULE, mask_sh)<br>
> +<br>
> #define HWSEQ_DCN30_MASK_SH_LIST(mask_sh)\<br>
> HWSEQ_DCN2_MASK_SH_LIST(mask_sh), \<br>
> HWS_SF(, AZALIA_AUDIO_DTO, AZALIA_AUDIO_DTO_MODULE, mask_sh), \<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_ipp.h b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_ipp.h<br>
> index 1ca4907..e2508d6 100644<br>
> --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_ipp.h<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_ipp.h<br>
> @@ -60,6 +60,16 @@<br>
> SRI(CURSOR_HOT_SPOT, CURSOR0_, id), \<br>
> SRI(CURSOR_DST_OFFSET, CURSOR0_, id)<br>
><br>
> +#define IPP_REG_LIST_DCN201(id) \<br>
> + IPP_REG_LIST_DCN(id), \<br>
> + SRI(CURSOR_SURFACE_ADDRESS_HIGH, CURSOR0_, id), \<br>
> + SRI(CURSOR_SURFACE_ADDRESS, CURSOR0_, id), \<br>
> + SRI(CURSOR_SIZE, CURSOR0_, id), \<br>
> + SRI(CURSOR_CONTROL, CURSOR0_, id), \<br>
> + SRI(CURSOR_POSITION, CURSOR0_, id), \<br>
> + SRI(CURSOR_HOT_SPOT, CURSOR0_, id), \<br>
> + SRI(CURSOR_DST_OFFSET, CURSOR0_, id)<br>
> +<br>
> #define CURSOR0_CURSOR_CONTROL__CURSOR_2X_MAGNIFY__SHIFT 0x4<br>
> #define CURSOR0_CURSOR_CONTROL__CURSOR_2X_MAGNIFY_MASK 0x00000010L<br>
><br>
> @@ -116,6 +126,23 @@<br>
> IPP_SF(CURSOR0_0_CURSOR_HOT_SPOT, CURSOR_HOT_SPOT_Y, mask_sh), \<br>
> IPP_SF(CURSOR0_0_CURSOR_DST_OFFSET, CURSOR_DST_X_OFFSET, mask_sh)<br>
><br>
> +#define IPP_MASK_SH_LIST_DCN201(mask_sh) \<br>
> + IPP_MASK_SH_LIST_DCN(mask_sh), \<br>
> + IPP_SF(CURSOR0_0_CURSOR_SURFACE_ADDRESS_HIGH, CURSOR_SURFACE_ADDRESS_HIGH, mask_sh), \<br>
> + IPP_SF(CURSOR0_0_CURSOR_SURFACE_ADDRESS, CURSOR_SURFACE_ADDRESS, mask_sh), \<br>
> + IPP_SF(CURSOR0_0_CURSOR_SIZE, CURSOR_WIDTH, mask_sh), \<br>
> + IPP_SF(CURSOR0_0_CURSOR_SIZE, CURSOR_HEIGHT, mask_sh), \<br>
> + IPP_SF(CURSOR0_0_CURSOR_CONTROL, CURSOR_MODE, mask_sh), \<br>
> + IPP_SF(CURSOR0_0_CURSOR_CONTROL, CURSOR_2X_MAGNIFY, mask_sh), \<br>
> + IPP_SF(CURSOR0_0_CURSOR_CONTROL, CURSOR_PITCH, mask_sh), \<br>
> + IPP_SF(CURSOR0_0_CURSOR_CONTROL, CURSOR_LINES_PER_CHUNK, mask_sh), \<br>
> + IPP_SF(CURSOR0_0_CURSOR_CONTROL, CURSOR_ENABLE, mask_sh), \<br>
> + IPP_SF(CURSOR0_0_CURSOR_POSITION, CURSOR_X_POSITION, mask_sh), \<br>
> + IPP_SF(CURSOR0_0_CURSOR_POSITION, CURSOR_Y_POSITION, mask_sh), \<br>
> + IPP_SF(CURSOR0_0_CURSOR_HOT_SPOT, CURSOR_HOT_SPOT_X, mask_sh), \<br>
> + IPP_SF(CURSOR0_0_CURSOR_HOT_SPOT, CURSOR_HOT_SPOT_Y, mask_sh), \<br>
> + IPP_SF(CURSOR0_0_CURSOR_DST_OFFSET, CURSOR_DST_X_OFFSET, mask_sh)<br>
> +<br>
> #define IPP_DCN10_REG_FIELD_LIST(type) \<br>
> type CNVC_SURFACE_PIXEL_FORMAT; \<br>
> type CNVC_BYPASS; \<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c<br>
> index aeb868a..899d0086 100644<br>
> --- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c<br>
> @@ -3167,6 +3167,9 @@<br>
> if (!context->res_ctx.pipe_ctx[i].stream)<br>
> continue;<br>
><br>
> + if (dc->ctx->dce_version == DCN_VERSION_2_01)<br>
> + cstate_en = false;<br>
> +<br>
> context->bw_ctx.dml.funcs.rq_dlg_get_dlg_reg(&context->bw_ctx.dml,<br>
> &context->res_ctx.pipe_ctx[i].dlg_regs,<br>
> &context->res_ctx.pipe_ctx[i].ttu_regs,<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/Makefile b/drivers/gpu/drm/amd/display/dc/dcn201/Makefile<br>
> new file mode 100644<br>
> index 0000000..d98d697<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/Makefile<br>
> @@ -0,0 +1,33 @@<br>
> +# SPDX-License-Identifier: MIT<br>
> +#<br>
> +# Makefile for DCN.<br>
> +DCN201 = dcn201_init.o dcn201_resource.o dcn201_hwseq.o \<br>
> + dcn201_hubbub.o\<br>
> + dcn201_mpc.o dcn201_hubp.o dcn201_opp.o dcn201_optc.o dcn201_dpp.o \<br>
> + dcn201_dccg.o dcn201_link_encoder.o<br>
> +<br>
> +ifdef CONFIG_X86<br>
> +CFLAGS_$(AMDDALPATH)/dc/dcn201/dcn201_resource.o := -mhard-float -msse<br>
> +endif<br>
> +<br>
> +ifdef CONFIG_PPC64<br>
> +CFLAGS_$(AMDDALPATH)/dc/dcn201/dcn201_resource.o := -mhard-float -maltivec<br>
> +endif<br>
> +<br>
> +ifeq ($(call cc-ifversion, -lt, 0701, y), y)<br>
> +IS_OLD_GCC = 1<br>
> +endif<br>
> +<br>
> +ifdef CONFIG_X86<br>
> +ifdef IS_OLD_GCC<br>
> +# Stack alignment mismatch, proceed with caution.<br>
> +# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3<br>
> +# (8B stack alignment).<br>
> +CFLAGS_$(AMDDALPATH)/dc/dcn201/dcn201_resource.o += -mpreferred-stack-boundary=4<br>
> +else<br>
> +CFLAGS_$(AMDDALPATH)/dc/dcn201/dcn201_resource.o += -msse2<br>
> +endif<br>
> +endif<br>
> +AMD_DAL_DCN201 = $(addprefix $(AMDDALPATH)/dc/dcn201/,$(DCN201))<br>
> +<br>
> +AMD_DISPLAY_FILES += $(AMD_DAL_DCN201)<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_dccg.c b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_dccg.c<br>
> new file mode 100644<br>
> index 0000000..f5bf04f<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_dccg.c<br>
> @@ -0,0 +1,84 @@<br>
> +/*<br>
> + * Copyright 2018 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +<br>
> +#include "dcn201_dccg.h"<br>
> +<br>
> +#include "reg_helper.h"<br>
> +#include "core_types.h"<br>
> +<br>
> +#define TO_DCN_DCCG(dccg)\<br>
> + container_of(dccg, struct dcn_dccg, base)<br>
> +<br>
> +#define REG(reg) \<br>
> + (dccg_dcn->regs->reg)<br>
> +<br>
> +#undef FN<br>
> +#define FN(reg_name, field_name) \<br>
> + dccg_dcn->dccg_shift->field_name, dccg_dcn->dccg_mask->field_name<br>
> +<br>
> +#define CTX \<br>
> + dccg_dcn->base.ctx<br>
> +<br>
> +#define DC_LOGGER \<br>
> + dccg->ctx->logger<br>
> +<br>
> +void dccg201_update_dpp_dto(struct dccg *dccg, int dpp_inst, int req_dppclk)<br>
> +{<br>
> + /* vbios handles it */<br>
> +}<br>
> +<br>
> +static const struct dccg_funcs dccg201_funcs = {<br>
> + .update_dpp_dto = dccg201_update_dpp_dto,<br>
> + .get_dccg_ref_freq = dccg2_get_dccg_ref_freq,<br>
> + .set_fifo_errdet_ovr_en = dccg2_set_fifo_errdet_ovr_en,<br>
> + .otg_add_pixel = dccg2_otg_add_pixel,<br>
> + .otg_drop_pixel = dccg2_otg_drop_pixel,<br>
> + .dccg_init = dccg2_init<br>
> +};<br>
> +<br>
> +struct dccg *dccg201_create(<br>
> + struct dc_context *ctx,<br>
> + const struct dccg_registers *regs,<br>
> + const struct dccg_shift *dccg_shift,<br>
> + const struct dccg_mask *dccg_mask)<br>
> +{<br>
> + struct dcn_dccg *dccg_dcn = kzalloc(sizeof(*dccg_dcn), GFP_KERNEL);<br>
> + struct dccg *base;<br>
> +<br>
> + if (dccg_dcn == NULL) {<br>
> + BREAK_TO_DEBUGGER();<br>
> + return NULL;<br>
> + }<br>
> +<br>
> + base = &dccg_dcn->base;<br>
> + base->ctx = ctx;<br>
> + base->funcs = &dccg201_funcs;<br>
> +<br>
> + dccg_dcn->regs = regs;<br>
> + dccg_dcn->dccg_shift = dccg_shift;<br>
> + dccg_dcn->dccg_mask = dccg_mask;<br>
> +<br>
> + return &dccg_dcn->base;<br>
> +}<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_dccg.h b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_dccg.h<br>
> new file mode 100644<br>
> index 0000000..80888b0<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_dccg.h<br>
> @@ -0,0 +1,37 @@<br>
> +/*<br>
> + * Copyright 2018 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +<br>
> +#ifndef __DCN201_DCCG_H__<br>
> +#define __DCN201_DCCG_H__<br>
> +<br>
> +#include "dcn20/dcn20_dccg.h"<br>
> +<br>
> +struct dccg *dccg201_create(<br>
> + struct dc_context *ctx,<br>
> + const struct dccg_registers *regs,<br>
> + const struct dccg_shift *dccg_shift,<br>
> + const struct dccg_mask *dccg_mask);<br>
> +<br>
> +#endif //__DCN201_DCCG_H__<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_dpp.c b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_dpp.c<br>
> new file mode 100644<br>
> index 0000000..8b6505b<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_dpp.c<br>
> @@ -0,0 +1,316 @@<br>
> +/*<br>
> + * Copyright 2016 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +<br>
> +#include "dm_services.h"<br>
> +<br>
> +#include "core_types.h"<br>
> +<br>
> +#include "reg_helper.h"<br>
> +#include "dcn201_dpp.h"<br>
> +#include "basics/conversion.h"<br>
> +<br>
> +#define REG(reg)\<br>
> + dpp->tf_regs->reg<br>
> +<br>
> +#define CTX \<br>
> + dpp->base.ctx<br>
> +<br>
> +#undef FN<br>
> +#define FN(reg_name, field_name) \<br>
> + dpp->tf_shift->field_name, dpp->tf_mask->field_name<br>
> +<br>
> +static void dpp201_cnv_setup(<br>
> + struct dpp *dpp_base,<br>
> + enum surface_pixel_format format,<br>
> + enum expansion_mode mode,<br>
> + struct dc_csc_transform input_csc_color_matrix,<br>
> + enum dc_color_space input_color_space,<br>
> + struct cnv_alpha_2bit_lut *alpha_2bit_lut)<br>
> +{<br>
> + struct dcn201_dpp *dpp = TO_DCN201_DPP(dpp_base);<br>
> + uint32_t pixel_format = 0;<br>
> + uint32_t alpha_en = 1;<br>
> + enum dc_color_space color_space = COLOR_SPACE_SRGB;<br>
> + enum dcn10_input_csc_select select = INPUT_CSC_SELECT_BYPASS;<br>
> + bool force_disable_cursor = false;<br>
> + uint32_t is_2bit = 0;<br>
> +<br>
> + REG_SET_2(FORMAT_CONTROL, 0,<br>
> + CNVC_BYPASS, 0,<br>
> + FORMAT_EXPANSION_MODE, mode);<br>
> +<br>
> + REG_UPDATE(FORMAT_CONTROL, FORMAT_CNV16, 0);<br>
> + REG_UPDATE(FORMAT_CONTROL, CNVC_BYPASS_MSB_ALIGN, 0);<br>
> + REG_UPDATE(FORMAT_CONTROL, CLAMP_POSITIVE, 0);<br>
> + REG_UPDATE(FORMAT_CONTROL, CLAMP_POSITIVE_C, 0);<br>
> +<br>
> + switch (format) {<br>
> + case SURFACE_PIXEL_FORMAT_GRPH_ARGB1555:<br>
> + pixel_format = 1;<br>
> + break;<br>
> + case SURFACE_PIXEL_FORMAT_GRPH_RGB565:<br>
> + pixel_format = 3;<br>
> + alpha_en = 0;<br>
> + break;<br>
> + case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:<br>
> + case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:<br>
> + pixel_format = 8;<br>
> + break;<br>
> + case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:<br>
> + case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:<br>
> + pixel_format = 10;<br>
> + is_2bit = 1;<br>
> + break;<br>
> + case SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr:<br>
> + force_disable_cursor = false;<br>
> + pixel_format = 65;<br>
> + color_space = COLOR_SPACE_YCBCR709;<br>
> + select = INPUT_CSC_SELECT_ICSC;<br>
> + break;<br>
> + case SURFACE_PIXEL_FORMAT_VIDEO_420_YCrCb:<br>
> + force_disable_cursor = true;<br>
> + pixel_format = 64;<br>
> + color_space = COLOR_SPACE_YCBCR709;<br>
> + select = INPUT_CSC_SELECT_ICSC;<br>
> + break;<br>
> + case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCbCr:<br>
> + force_disable_cursor = true;<br>
> + pixel_format = 67;<br>
> + color_space = COLOR_SPACE_YCBCR709;<br>
> + select = INPUT_CSC_SELECT_ICSC;<br>
> + break;<br>
> + case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb:<br>
> + force_disable_cursor = true;<br>
> + pixel_format = 66;<br>
> + color_space = COLOR_SPACE_YCBCR709;<br>
> + select = INPUT_CSC_SELECT_ICSC;<br>
> + break;<br>
> + case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616:<br>
> + pixel_format = 22;<br>
> + break;<br>
> + case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616F:<br>
> + pixel_format = 24;<br>
> + break;<br>
> + case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F:<br>
> + pixel_format = 25;<br>
> + break;<br>
> + case SURFACE_PIXEL_FORMAT_VIDEO_AYCrCb8888:<br>
> + pixel_format = 12;<br>
> + color_space = COLOR_SPACE_YCBCR709;<br>
> + select = INPUT_CSC_SELECT_ICSC;<br>
> + break;<br>
> + case SURFACE_PIXEL_FORMAT_GRPH_RGB111110_FIX:<br>
> + pixel_format = 112;<br>
> + alpha_en = 0;<br>
> + break;<br>
> + case SURFACE_PIXEL_FORMAT_GRPH_BGR101111_FIX:<br>
> + pixel_format = 113;<br>
> + alpha_en = 0;<br>
> + break;<br>
> + case SURFACE_PIXEL_FORMAT_VIDEO_ACrYCb2101010:<br>
> + pixel_format = 114;<br>
> + color_space = COLOR_SPACE_YCBCR709;<br>
> + select = INPUT_CSC_SELECT_ICSC;<br>
> + is_2bit = 1;<br>
> + break;<br>
> + case SURFACE_PIXEL_FORMAT_VIDEO_CrYCbA1010102:<br>
> + pixel_format = 115;<br>
> + color_space = COLOR_SPACE_YCBCR709;<br>
> + select = INPUT_CSC_SELECT_ICSC;<br>
> + is_2bit = 1;<br>
> + break;<br>
> + case SURFACE_PIXEL_FORMAT_GRPH_RGB111110_FLOAT:<br>
> + pixel_format = 118;<br>
> + alpha_en = 0;<br>
> + break;<br>
> + case SURFACE_PIXEL_FORMAT_GRPH_BGR101111_FLOAT:<br>
> + pixel_format = 119;<br>
> + alpha_en = 0;<br>
> + break;<br>
> + default:<br>
> + break;<br>
> + }<br>
> +<br>
> + if (is_2bit == 1 && alpha_2bit_lut != NULL) {<br>
> + REG_UPDATE(ALPHA_2BIT_LUT, ALPHA_2BIT_LUT0, alpha_2bit_lut->lut0);<br>
> + REG_UPDATE(ALPHA_2BIT_LUT, ALPHA_2BIT_LUT1, alpha_2bit_lut->lut1);<br>
> + REG_UPDATE(ALPHA_2BIT_LUT, ALPHA_2BIT_LUT2, alpha_2bit_lut->lut2);<br>
> + REG_UPDATE(ALPHA_2BIT_LUT, ALPHA_2BIT_LUT3, alpha_2bit_lut->lut3);<br>
> + }<br>
> +<br>
> + REG_SET(CNVC_SURFACE_PIXEL_FORMAT, 0,<br>
> + CNVC_SURFACE_PIXEL_FORMAT, pixel_format);<br>
> + REG_UPDATE(FORMAT_CONTROL, FORMAT_CONTROL__ALPHA_EN, alpha_en);<br>
> +<br>
> + dpp1_program_input_csc(dpp_base, color_space, select, NULL);<br>
> +<br>
> + if (force_disable_cursor) {<br>
> + REG_UPDATE(CURSOR_CONTROL,<br>
> + CURSOR_ENABLE, 0);<br>
> + REG_UPDATE(CURSOR0_CONTROL,<br>
> + CUR0_ENABLE, 0);<br>
> + }<br>
> + dpp2_power_on_obuf(dpp_base, true);<br>
> +}<br>
> +<br>
> +#define IDENTITY_RATIO(ratio) (dc_fixpt_u3d19(ratio) == (1 << 19))<br>
> +<br>
> +static bool dpp201_get_optimal_number_of_taps(<br>
> + struct dpp *dpp,<br>
> + struct scaler_data *scl_data,<br>
> + const struct scaling_taps *in_taps)<br>
> +{<br>
> + uint32_t pixel_width;<br>
> +<br>
> + if (scl_data->viewport.width > scl_data->recout.width)<br>
> + pixel_width = scl_data->recout.width;<br>
> + else<br>
> + pixel_width = scl_data->viewport.width;<br>
> +<br>
> + if (scl_data->viewport.width != scl_data->h_active &&<br>
> + scl_data->viewport.height != scl_data->v_active &&<br>
> + dpp->caps->dscl_data_proc_format == DSCL_DATA_PRCESSING_FIXED_FORMAT &&<br>
> + scl_data->format == PIXEL_FORMAT_FP16)<br>
> + return false;<br>
> +<br>
> + if (scl_data->viewport.width > scl_data->h_active &&<br>
> + dpp->ctx->dc->debug.max_downscale_src_width != 0 &&<br>
> + scl_data->viewport.width > dpp->ctx->dc->debug.max_downscale_src_width)<br>
> + return false;<br>
> +<br>
> + if (scl_data->ratios.horz.value == (8ll << 32))<br>
> + scl_data->ratios.horz.value--;<br>
> + if (scl_data->ratios.vert.value == (8ll << 32))<br>
> + scl_data->ratios.vert.value--;<br>
> + if (scl_data->ratios.horz_c.value == (8ll << 32))<br>
> + scl_data->ratios.horz_c.value--;<br>
> + if (scl_data->ratios.vert_c.value == (8ll << 32))<br>
> + scl_data->ratios.vert_c.value--;<br>
> +<br>
> + if (in_taps->h_taps == 0) {<br>
> + if (dc_fixpt_ceil(scl_data->ratios.horz) > 4)<br>
> + scl_data->taps.h_taps = 8;<br>
> + else<br>
> + scl_data->taps.h_taps = 4;<br>
> + } else<br>
> + scl_data->taps.h_taps = in_taps->h_taps;<br>
> +<br>
> + if (in_taps->v_taps == 0) {<br>
> + if (dc_fixpt_ceil(scl_data->ratios.vert) > 4)<br>
> + scl_data->taps.v_taps = 8;<br>
> + else<br>
> + scl_data->taps.v_taps = 4;<br>
> + } else<br>
> + scl_data->taps.v_taps = in_taps->v_taps;<br>
> + if (in_taps->v_taps_c == 0) {<br>
> + if (dc_fixpt_ceil(scl_data->ratios.vert_c) > 4)<br>
> + scl_data->taps.v_taps_c = 4;<br>
> + else<br>
> + scl_data->taps.v_taps_c = 2;<br>
> + } else<br>
> + scl_data->taps.v_taps_c = in_taps->v_taps_c;<br>
> + if (in_taps->h_taps_c == 0) {<br>
> + if (dc_fixpt_ceil(scl_data->ratios.horz_c) > 4)<br>
> + scl_data->taps.h_taps_c = 4;<br>
> + else<br>
> + scl_data->taps.h_taps_c = 2;<br>
> + } else if ((in_taps->h_taps_c % 2) != 0 && in_taps->h_taps_c != 1)<br>
> + scl_data->taps.h_taps_c = in_taps->h_taps_c - 1;<br>
> + else<br>
> + scl_data->taps.h_taps_c = in_taps->h_taps_c;<br>
> +<br>
> + if (!dpp->ctx->dc->debug.always_scale) {<br>
> + if (IDENTITY_RATIO(scl_data->ratios.horz))<br>
> + scl_data->taps.h_taps = 1;<br>
> + if (IDENTITY_RATIO(scl_data->ratios.vert))<br>
> + scl_data->taps.v_taps = 1;<br>
> + if (IDENTITY_RATIO(scl_data->ratios.horz_c))<br>
> + scl_data->taps.h_taps_c = 1;<br>
> + if (IDENTITY_RATIO(scl_data->ratios.vert_c))<br>
> + scl_data->taps.v_taps_c = 1;<br>
> + }<br>
> +<br>
> + return true;<br>
> +}<br>
> +<br>
> +static struct dpp_funcs dcn201_dpp_funcs = {<br>
> + .dpp_read_state = dpp20_read_state,<br>
> + .dpp_reset = dpp_reset,<br>
> + .dpp_set_scaler = dpp1_dscl_set_scaler_manual_scale,<br>
> + .dpp_get_optimal_number_of_taps = dpp201_get_optimal_number_of_taps,<br>
> + .dpp_set_gamut_remap = dpp1_cm_set_gamut_remap,<br>
> + .dpp_set_csc_adjustment = NULL,<br>
> + .dpp_set_csc_default = NULL,<br>
> + .dpp_program_regamma_pwl = oppn20_dummy_program_regamma_pwl,<br>
> + .dpp_set_degamma = dpp2_set_degamma,<br>
> + .dpp_program_input_lut = dpp2_dummy_program_input_lut,<br>
> + .dpp_full_bypass = dpp1_full_bypass,<br>
> + .dpp_setup = dpp201_cnv_setup,<br>
> + .dpp_program_degamma_pwl = dpp2_set_degamma_pwl,<br>
> + .dpp_program_blnd_lut = dpp20_program_blnd_lut,<br>
> + .dpp_program_shaper_lut = dpp20_program_shaper,<br>
> + .dpp_program_3dlut = dpp20_program_3dlut,<br>
> + .dpp_program_bias_and_scale = NULL,<br>
> + .dpp_cnv_set_alpha_keyer = dpp2_cnv_set_alpha_keyer,<br>
> + .set_cursor_attributes = dpp2_set_cursor_attributes,<br>
> + .set_cursor_position = dpp1_set_cursor_position,<br>
> + .set_optional_cursor_attributes = dpp1_cnv_set_optional_cursor_attributes,<br>
> + .dpp_dppclk_control = dpp1_dppclk_control,<br>
> + .dpp_set_hdr_multiplier = dpp2_set_hdr_multiplier,<br>
> +};<br>
> +<br>
> +static struct dpp_caps dcn201_dpp_cap = {<br>
> + .dscl_data_proc_format = DSCL_DATA_PRCESSING_FLOAT_FORMAT,<br>
> + .dscl_calc_lb_num_partitions = dscl2_calc_lb_num_partitions,<br>
> +};<br>
> +<br>
> +bool dpp201_construct(<br>
> + struct dcn201_dpp *dpp,<br>
> + struct dc_context *ctx,<br>
> + uint32_t inst,<br>
> + const struct dcn201_dpp_registers *tf_regs,<br>
> + const struct dcn201_dpp_shift *tf_shift,<br>
> + const struct dcn201_dpp_mask *tf_mask)<br>
> +{<br>
> + dpp->base.ctx = ctx;<br>
> +<br>
> + dpp->base.inst = inst;<br>
> + dpp->base.funcs = &dcn201_dpp_funcs;<br>
> + dpp->base.caps = &dcn201_dpp_cap;<br>
> +<br>
> + dpp->tf_regs = tf_regs;<br>
> + dpp->tf_shift = tf_shift;<br>
> + dpp->tf_mask = tf_mask;<br>
> +<br>
> + dpp->lb_pixel_depth_supported =<br>
> + LB_PIXEL_DEPTH_18BPP |<br>
> + LB_PIXEL_DEPTH_24BPP |<br>
> + LB_PIXEL_DEPTH_30BPP;<br>
> +<br>
> + dpp->lb_bits_per_entry = LB_BITS_PER_ENTRY;<br>
> + dpp->lb_memory_size = LB_TOTAL_NUMBER_OF_ENTRIES;<br>
> +<br>
> + return true;<br>
> +}<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_dpp.h b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_dpp.h<br>
> new file mode 100644<br>
> index 0000000..cbd5b47<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_dpp.h<br>
> @@ -0,0 +1,83 @@<br>
> +/* Copyright 2016 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +<br>
> +#ifndef __DCN201_DPP_H__<br>
> +#define __DCN201_DPP_H__<br>
> +<br>
> +#include "dcn20/dcn20_dpp.h"<br>
> +<br>
> +#define TO_DCN201_DPP(dpp)\<br>
> + container_of(dpp, struct dcn201_dpp, base)<br>
> +<br>
> +#define TF_REG_LIST_DCN201(id) \<br>
> + TF_REG_LIST_DCN20(id)<br>
> +<br>
> +#define TF_REG_LIST_SH_MASK_DCN201(mask_sh)\<br>
> + TF_REG_LIST_SH_MASK_DCN20(mask_sh)<br>
> +<br>
> +#define TF_REG_FIELD_LIST_DCN201(type) \<br>
> + TF_REG_FIELD_LIST_DCN2_0(type)<br>
> +<br>
> +struct dcn201_dpp_shift {<br>
> + TF_REG_FIELD_LIST_DCN201(uint8_t);<br>
> +};<br>
> +<br>
> +struct dcn201_dpp_mask {<br>
> + TF_REG_FIELD_LIST_DCN201(uint32_t);<br>
> +};<br>
> +<br>
> +#define DPP_DCN201_REG_VARIABLE_LIST \<br>
> + DPP_DCN2_REG_VARIABLE_LIST<br>
> +<br>
> +struct dcn201_dpp_registers {<br>
> + DPP_DCN201_REG_VARIABLE_LIST;<br>
> +};<br>
> +<br>
> +struct dcn201_dpp {<br>
> + struct dpp base;<br>
> +<br>
> + const struct dcn201_dpp_registers *tf_regs;<br>
> + const struct dcn201_dpp_shift *tf_shift;<br>
> + const struct dcn201_dpp_mask *tf_mask;<br>
> +<br>
> + const uint16_t *filter_v;<br>
> + const uint16_t *filter_h;<br>
> + const uint16_t *filter_v_c;<br>
> + const uint16_t *filter_h_c;<br>
> + int lb_pixel_depth_supported;<br>
> + int lb_memory_size;<br>
> + int lb_bits_per_entry;<br>
> + bool is_write_to_ram_a_safe;<br>
> + struct scaler_data scl_data;<br>
> + struct pwl_params pwl_data;<br>
> +};<br>
> +<br>
> +bool dpp201_construct(struct dcn201_dpp *dpp2,<br>
> + struct dc_context *ctx,<br>
> + uint32_t inst,<br>
> + const struct dcn201_dpp_registers *tf_regs,<br>
> + const struct dcn201_dpp_shift *tf_shift,<br>
> + const struct dcn201_dpp_mask *tf_mask);<br>
> +<br>
> +#endif /* __DC_HWSS_DCN201_H__ */<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hubbub.c b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hubbub.c<br>
> new file mode 100644<br>
> index 0000000..037d265<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hubbub.c<br>
> @@ -0,0 +1,107 @@<br>
> +/*<br>
> +* Copyright 2018 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +#include "dm_services.h"<br>
> +#include "dcn20/dcn20_hubbub.h"<br>
> +#include "dcn201_hubbub.h"<br>
> +#include "reg_helper.h"<br>
> +<br>
> +#define REG(reg)\<br>
> + hubbub1->regs->reg<br>
> +<br>
> +#define DC_LOGGER \<br>
> + hubbub1->base.ctx->logger<br>
> +<br>
> +#define CTX \<br>
> + hubbub1->base.ctx<br>
> +<br>
> +#undef FN<br>
> +#define FN(reg_name, field_name) \<br>
> + hubbub1->shifts->field_name, hubbub1->masks->field_name<br>
> +<br>
> +#define REG(reg)\<br>
> + hubbub1->regs->reg<br>
> +<br>
> +#define CTX \<br>
> + hubbub1->base.ctx<br>
> +<br>
> +#undef FN<br>
> +#define FN(reg_name, field_name) \<br>
> + hubbub1->shifts->field_name, hubbub1->masks->field_name<br>
> +<br>
> +static bool hubbub201_program_watermarks(<br>
> + struct hubbub *hubbub,<br>
> + struct dcn_watermark_set *watermarks,<br>
> + unsigned int refclk_mhz,<br>
> + bool safe_to_lower)<br>
> +{<br>
> + struct dcn20_hubbub *hubbub1 = TO_DCN20_HUBBUB(hubbub);<br>
> + bool wm_pending = false;<br>
> +<br>
> + if (hubbub1_program_urgent_watermarks(hubbub, watermarks, refclk_mhz, safe_to_lower))<br>
> + wm_pending = true;<br>
> +<br>
> + if (hubbub1_program_pstate_watermarks(hubbub, watermarks, refclk_mhz, safe_to_lower))<br>
> + wm_pending = true;<br>
> +<br>
> + REG_SET(DCHUBBUB_ARB_SAT_LEVEL, 0,<br>
> + DCHUBBUB_ARB_SAT_LEVEL, 60 * refclk_mhz);<br>
> + REG_UPDATE(DCHUBBUB_ARB_DF_REQ_OUTSTAND,<br>
> + DCHUBBUB_ARB_MIN_REQ_OUTSTAND, 68);<br>
> +<br>
> + hubbub1_allow_self_refresh_control(hubbub, !hubbub->ctx->dc->debug.disable_stutter);<br>
> +<br>
> + return wm_pending;<br>
> +}<br>
> +<br>
> +static const struct hubbub_funcs hubbub201_funcs = {<br>
> + .update_dchub = hubbub2_update_dchub,<br>
> + .init_dchub_sys_ctx = NULL,<br>
> + .init_vm_ctx = NULL,<br>
> + .dcc_support_swizzle = hubbub2_dcc_support_swizzle,<br>
> + .dcc_support_pixel_format = hubbub2_dcc_support_pixel_format,<br>
> + .get_dcc_compression_cap = hubbub2_get_dcc_compression_cap,<br>
> + .wm_read_state = hubbub2_wm_read_state,<br>
> + .get_dchub_ref_freq = hubbub2_get_dchub_ref_freq,<br>
> + .program_watermarks = hubbub201_program_watermarks,<br>
> + .hubbub_read_state = hubbub2_read_state,<br>
> +};<br>
> +<br>
> +void hubbub201_construct(struct dcn20_hubbub *hubbub,<br>
> + struct dc_context *ctx,<br>
> + const struct dcn_hubbub_registers *hubbub_regs,<br>
> + const struct dcn_hubbub_shift *hubbub_shift,<br>
> + const struct dcn_hubbub_mask *hubbub_mask)<br>
> +{<br>
> + hubbub->base.ctx = ctx;<br>
> +<br>
> + hubbub->base.funcs = &hubbub201_funcs;<br>
> +<br>
> + hubbub->regs = hubbub_regs;<br>
> + hubbub->shifts = hubbub_shift;<br>
> + hubbub->masks = hubbub_mask;<br>
> +<br>
> + hubbub->debug_test_index_pstate = 0xB;<br>
> + hubbub->detile_buf_size = 164 * 1024;<br>
> +}<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hubbub.h b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hubbub.h<br>
> new file mode 100644<br>
> index 0000000..a1ec699<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hubbub.h<br>
> @@ -0,0 +1,45 @@<br>
> +/*<br>
> +* Copyright 2018 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +#ifndef DAL_DC_DCN201_DCN201_HUBBUB_H_<br>
> +#define DAL_DC_DCN201_DCN201_HUBBUB_H_<br>
> +<br>
> +#include "dcn20/dcn20_hubbub.h"<br>
> +<br>
> +#define HUBBUB_REG_LIST_DCN201(id)\<br>
> + HUBBUB_REG_LIST_DCN_COMMON(), \<br>
> + HUBBUB_VM_REG_LIST(), \<br>
> + SR(DCHUBBUB_CRC_CTRL)<br>
> +<br>
> +#define HUBBUB_MASK_SH_LIST_DCN201(mask_sh)\<br>
> + HUBBUB_MASK_SH_LIST_DCN_COMMON(mask_sh), \<br>
> + HUBBUB_SF(DCHUBBUB_GLOBAL_TIMER_CNTL, DCHUBBUB_GLOBAL_TIMER_REFDIV, mask_sh)<br>
> +<br>
> +void hubbub201_construct(struct dcn20_hubbub *hubbub,<br>
> + struct dc_context *ctx,<br>
> + const struct dcn_hubbub_registers *hubbub_regs,<br>
> + const struct dcn_hubbub_shift *hubbub_shift,<br>
> + const struct dcn_hubbub_mask *hubbub_mask);<br>
> +<br>
> +#endif /* DAL_DC_DCN201_DCN201_HUBBUB_H_ */<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hubp.c b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hubp.c<br>
> new file mode 100644<br>
> index 0000000..6b6f74d<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hubp.c<br>
> @@ -0,0 +1,150 @@<br>
> +/*<br>
> + * Copyright 2012-17 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +#include "dcn201_hubp.h"<br>
> +<br>
> +#include "dm_services.h"<br>
> +#include "dce_calcs.h"<br>
> +#include "reg_helper.h"<br>
> +#include "basics/conversion.h"<br>
> +<br>
> +#define REG(reg)\<br>
> + hubp201->hubp_regs->reg<br>
> +<br>
> +#define CTX \<br>
> + hubp201->base.ctx<br>
> +<br>
> +#undef FN<br>
> +#define FN(reg_name, field_name) \<br>
> + hubp201->hubp_shift->field_name, hubp201->hubp_mask->field_name<br>
> +<br>
> +static void hubp201_program_surface_config(<br>
> + struct hubp *hubp,<br>
> + enum surface_pixel_format format,<br>
> + union dc_tiling_info *tiling_info,<br>
> + struct plane_size *plane_size,<br>
> + enum dc_rotation_angle rotation,<br>
> + struct dc_plane_dcc_param *dcc,<br>
> + bool horizontal_mirror,<br>
> + unsigned int compat_level)<br>
> +{<br>
> + hubp1_dcc_control(hubp, dcc->enable, dcc->independent_64b_blks);<br>
> + hubp1_program_tiling(hubp, tiling_info, format);<br>
> + hubp1_program_size(hubp, format, plane_size, dcc);<br>
> + hubp1_program_pixel_format(hubp, format);<br>
> +}<br>
> +<br>
> +void hubp201_program_deadline(<br>
> + struct hubp *hubp,<br>
> + struct _vcs_dpi_display_dlg_regs_st *dlg_attr,<br>
> + struct _vcs_dpi_display_ttu_regs_st *ttu_attr)<br>
> +{<br>
> + hubp1_program_deadline(hubp, dlg_attr, ttu_attr);<br>
> +}<br>
> +<br>
> +void hubp201_program_requestor(<br>
> + struct hubp *hubp,<br>
> + struct _vcs_dpi_display_rq_regs_st *rq_regs)<br>
> +{<br>
> + struct dcn201_hubp *hubp201 = TO_DCN201_HUBP(hubp);<br>
> +<br>
> + REG_UPDATE(HUBPRET_CONTROL,<br>
> + DET_BUF_PLANE1_BASE_ADDRESS, rq_regs->plane1_base_address);<br>
> +<br>
> + REG_SET_4(DCN_EXPANSION_MODE, 0,<br>
> + DRQ_EXPANSION_MODE, rq_regs->drq_expansion_mode,<br>
> + PRQ_EXPANSION_MODE, rq_regs->prq_expansion_mode,<br>
> + MRQ_EXPANSION_MODE, rq_regs->mrq_expansion_mode,<br>
> + CRQ_EXPANSION_MODE, rq_regs->crq_expansion_mode);<br>
> +<br>
> + REG_SET_5(DCHUBP_REQ_SIZE_CONFIG, 0,<br>
> + CHUNK_SIZE, rq_regs->rq_regs_l.chunk_size,<br>
> + MIN_CHUNK_SIZE, rq_regs->rq_regs_l.min_chunk_size,<br>
> + META_CHUNK_SIZE, rq_regs->rq_regs_l.meta_chunk_size,<br>
> + MIN_META_CHUNK_SIZE, rq_regs->rq_regs_l.min_meta_chunk_size,<br>
> + SWATH_HEIGHT, rq_regs->rq_regs_l.swath_height);<br>
> +<br>
> + REG_SET_5(DCHUBP_REQ_SIZE_CONFIG_C, 0,<br>
> + CHUNK_SIZE_C, rq_regs->rq_regs_c.chunk_size,<br>
> + MIN_CHUNK_SIZE_C, rq_regs->rq_regs_c.min_chunk_size,<br>
> + META_CHUNK_SIZE_C, rq_regs->rq_regs_c.meta_chunk_size,<br>
> + MIN_META_CHUNK_SIZE_C, rq_regs->rq_regs_c.min_meta_chunk_size,<br>
> + SWATH_HEIGHT_C, rq_regs->rq_regs_c.swath_height);<br>
> +}<br>
> +<br>
> +static void hubp201_setup(<br>
> + struct hubp *hubp,<br>
> + struct _vcs_dpi_display_dlg_regs_st *dlg_attr,<br>
> + struct _vcs_dpi_display_ttu_regs_st *ttu_attr,<br>
> + struct _vcs_dpi_display_rq_regs_st *rq_regs,<br>
> + struct _vcs_dpi_display_pipe_dest_params_st *pipe_dest)<br>
> +{<br>
> + hubp2_vready_at_or_After_vsync(hubp, pipe_dest);<br>
> + hubp201_program_requestor(hubp, rq_regs);<br>
> + hubp201_program_deadline(hubp, dlg_attr, ttu_attr);<br>
> +}<br>
> +<br>
> +static struct hubp_funcs dcn201_hubp_funcs = {<br>
> + .hubp_enable_tripleBuffer = hubp2_enable_triplebuffer,<br>
> + .hubp_is_triplebuffer_enabled = hubp2_is_triplebuffer_enabled,<br>
> + .hubp_program_surface_flip_and_addr = hubp1_program_surface_flip_and_addr,<br>
> + .hubp_program_surface_config = hubp201_program_surface_config,<br>
> + .hubp_is_flip_pending = hubp1_is_flip_pending,<br>
> + .hubp_setup = hubp201_setup,<br>
> + .hubp_setup_interdependent = hubp2_setup_interdependent,<br>
> + .set_cursor_attributes = hubp2_cursor_set_attributes,<br>
> + .set_cursor_position = hubp1_cursor_set_position,<br>
> + .set_blank = hubp1_set_blank,<br>
> + .dcc_control = hubp1_dcc_control,<br>
> + .mem_program_viewport = min_set_viewport,<br>
> + .hubp_clk_cntl = hubp1_clk_cntl,<br>
> + .hubp_vtg_sel = hubp1_vtg_sel,<br>
> + .dmdata_set_attributes = hubp2_dmdata_set_attributes,<br>
> + .dmdata_load = hubp2_dmdata_load,<br>
> + .dmdata_status_done = hubp2_dmdata_status_done,<br>
> + .hubp_read_state = hubp2_read_state,<br>
> + .hubp_clear_underflow = hubp1_clear_underflow,<br>
> + .hubp_set_flip_control_surface_gsl = hubp2_set_flip_control_surface_gsl,<br>
> + .hubp_init = hubp1_init,<br>
> +};<br>
> +<br>
> +bool dcn201_hubp_construct(<br>
> + struct dcn201_hubp *hubp201,<br>
> + struct dc_context *ctx,<br>
> + uint32_t inst,<br>
> + const struct dcn201_hubp_registers *hubp_regs,<br>
> + const struct dcn201_hubp_shift *hubp_shift,<br>
> + const struct dcn201_hubp_mask *hubp_mask)<br>
> +{<br>
> + hubp201->base.funcs = &dcn201_hubp_funcs;<br>
> + hubp201->base.ctx = ctx;<br>
> + hubp201->hubp_regs = hubp_regs;<br>
> + hubp201->hubp_shift = hubp_shift;<br>
> + hubp201->hubp_mask = hubp_mask;<br>
> + hubp201->base.inst = inst;<br>
> + hubp201->base.opp_id = OPP_ID_INVALID;<br>
> + hubp201->base.mpcc_id = 0xf;<br>
> +<br>
> + return true;<br>
> +}<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hubp.h b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hubp.h<br>
> new file mode 100644<br>
> index 0000000..a1e3384<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hubp.h<br>
> @@ -0,0 +1,132 @@<br>
> +/*<br>
> + * Copyright 2012-17 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +<br>
> +#ifndef __DC_MEM_INPUT_DCN201_H__<br>
> +#define __DC_MEM_INPUT_DCN201_H__<br>
> +<br>
> +#include "../dcn10/dcn10_hubp.h"<br>
> +#include "../dcn20/dcn20_hubp.h"<br>
> +<br>
> +#define TO_DCN201_HUBP(hubp)\<br>
> + container_of(hubp, struct dcn201_hubp, base)<br>
> +<br>
> +#define HUBP_REG_LIST_DCN201(id)\<br>
> + HUBP_REG_LIST_DCN(id),\<br>
> + SRI(PREFETCH_SETTINGS, HUBPREQ, id),\<br>
> + SRI(PREFETCH_SETTINGS_C, HUBPREQ, id),\<br>
> + SRI(DCSURF_FLIP_CONTROL2, HUBPREQ, id), \<br>
> + SRI(CURSOR_SETTINGS, HUBPREQ, id), \<br>
> + SRI(CURSOR_SURFACE_ADDRESS_HIGH, CURSOR0_, id), \<br>
> + SRI(CURSOR_SURFACE_ADDRESS, CURSOR0_, id), \<br>
> + SRI(CURSOR_SIZE, CURSOR0_, id), \<br>
> + SRI(CURSOR_CONTROL, CURSOR0_, id), \<br>
> + SRI(CURSOR_POSITION, CURSOR0_, id), \<br>
> + SRI(CURSOR_HOT_SPOT, CURSOR0_, id), \<br>
> + SRI(CURSOR_DST_OFFSET, CURSOR0_, id), \<br>
> + SRI(DMDATA_ADDRESS_HIGH, CURSOR0_, id), \<br>
> + SRI(DMDATA_ADDRESS_LOW, CURSOR0_, id), \<br>
> + SRI(DMDATA_CNTL, CURSOR0_, id), \<br>
> + SRI(DMDATA_SW_CNTL, CURSOR0_, id), \<br>
> + SRI(DMDATA_QOS_CNTL, CURSOR0_, id), \<br>
> + SRI(DMDATA_SW_DATA, CURSOR0_, id), \<br>
> + SRI(DMDATA_STATUS, CURSOR0_, id),\<br>
> + SRI(FLIP_PARAMETERS_0, HUBPREQ, id),\<br>
> + SRI(FLIP_PARAMETERS_2, HUBPREQ, id)<br>
> +<br>
> +#define HUBP_MASK_SH_LIST_DCN201(mask_sh)\<br>
> + HUBP_MASK_SH_LIST_DCN(mask_sh),\<br>
> + HUBP_SF(HUBPREQ0_PREFETCH_SETTINGS, DST_Y_PREFETCH, mask_sh),\<br>
> + HUBP_SF(HUBPREQ0_PREFETCH_SETTINGS, VRATIO_PREFETCH, mask_sh),\<br>
> + HUBP_SF(HUBPREQ0_PREFETCH_SETTINGS_C, VRATIO_PREFETCH_C, mask_sh),\<br>
> + HUBP_SF(HUBPREQ0_DCSURF_FLIP_CONTROL2, SURFACE_TRIPLE_BUFFER_ENABLE, mask_sh),\<br>
> + HUBP_SF(HUBPREQ0_CURSOR_SETTINGS, CURSOR0_DST_Y_OFFSET, mask_sh), \<br>
> + HUBP_SF(HUBPREQ0_CURSOR_SETTINGS, CURSOR0_CHUNK_HDL_ADJUST, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_CURSOR_SURFACE_ADDRESS_HIGH, CURSOR_SURFACE_ADDRESS_HIGH, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_CURSOR_SURFACE_ADDRESS, CURSOR_SURFACE_ADDRESS, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_CURSOR_SIZE, CURSOR_WIDTH, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_CURSOR_SIZE, CURSOR_HEIGHT, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_CURSOR_CONTROL, CURSOR_MODE, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_CURSOR_CONTROL, CURSOR_2X_MAGNIFY, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_CURSOR_CONTROL, CURSOR_PITCH, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_CURSOR_CONTROL, CURSOR_LINES_PER_CHUNK, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_CURSOR_CONTROL, CURSOR_ENABLE, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_CURSOR_POSITION, CURSOR_X_POSITION, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_CURSOR_POSITION, CURSOR_Y_POSITION, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_CURSOR_HOT_SPOT, CURSOR_HOT_SPOT_X, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_CURSOR_HOT_SPOT, CURSOR_HOT_SPOT_Y, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_CURSOR_DST_OFFSET, CURSOR_DST_X_OFFSET, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_DMDATA_ADDRESS_HIGH, DMDATA_ADDRESS_HIGH, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_DMDATA_CNTL, DMDATA_MODE, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_DMDATA_CNTL, DMDATA_UPDATED, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_DMDATA_CNTL, DMDATA_REPEAT, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_DMDATA_CNTL, DMDATA_SIZE, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_DMDATA_SW_CNTL, DMDATA_SW_UPDATED, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_DMDATA_SW_CNTL, DMDATA_SW_REPEAT, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_DMDATA_SW_CNTL, DMDATA_SW_SIZE, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_DMDATA_QOS_CNTL, DMDATA_QOS_MODE, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_DMDATA_QOS_CNTL, DMDATA_QOS_LEVEL, mask_sh), \<br>
> + HUBP_SF(CURSOR0_0_DMDATA_QOS_CNTL, DMDATA_DL_DELTA, mask_sh),\<br>
> + HUBP_SF(HUBPREQ0_FLIP_PARAMETERS_0, DST_Y_PER_VM_FLIP, mask_sh),\<br>
> + HUBP_SF(HUBPREQ0_FLIP_PARAMETERS_0, DST_Y_PER_ROW_FLIP, mask_sh),\<br>
> + HUBP_SF(HUBPREQ0_FLIP_PARAMETERS_2, REFCYC_PER_META_CHUNK_FLIP_L, mask_sh),\<br>
> + HUBP_SF(HUBP0_DCHUBP_CNTL, HUBP_VREADY_AT_OR_AFTER_VSYNC, mask_sh),\<br>
> + HUBP_SF(HUBP0_DCHUBP_CNTL, HUBP_DISABLE_STOP_DATA_DURING_VM, mask_sh),\<br>
> + HUBP_SF(HUBPREQ0_DCSURF_FLIP_CONTROL, HUBPREQ_MASTER_UPDATE_LOCK_STATUS, mask_sh)<br>
> +<br>
> +#define DCN201_HUBP_REG_VARIABLE_LIST \<br>
> + DCN2_HUBP_REG_COMMON_VARIABLE_LIST<br>
> +<br>
> +#define DCN201_HUBP_REG_FIELD_VARIABLE_LIST(type) \<br>
> + DCN2_HUBP_REG_FIELD_VARIABLE_LIST(type)<br>
> +<br>
> +struct dcn201_hubp_registers {<br>
> + DCN201_HUBP_REG_VARIABLE_LIST;<br>
> +};<br>
> +<br>
> +struct dcn201_hubp_shift {<br>
> + DCN201_HUBP_REG_FIELD_VARIABLE_LIST(uint8_t);<br>
> +};<br>
> +<br>
> +struct dcn201_hubp_mask {<br>
> + DCN201_HUBP_REG_FIELD_VARIABLE_LIST(uint32_t);<br>
> +};<br>
> +<br>
> +struct dcn201_hubp {<br>
> + struct hubp base;<br>
> + struct dcn_hubp_state state;<br>
> + const struct dcn201_hubp_registers *hubp_regs;<br>
> + const struct dcn201_hubp_shift *hubp_shift;<br>
> + const struct dcn201_hubp_mask *hubp_mask;<br>
> +};<br>
> +<br>
> +bool dcn201_hubp_construct(<br>
> + struct dcn201_hubp *hubp201,<br>
> + struct dc_context *ctx,<br>
> + uint32_t inst,<br>
> + const struct dcn201_hubp_registers *hubp_regs,<br>
> + const struct dcn201_hubp_shift *hubp_shift,<br>
> + const struct dcn201_hubp_mask *hubp_mask);<br>
> +<br>
> +#endif /* __DC_HWSS_DCN20_H__ */<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c<br>
> new file mode 100644<br>
> index 0000000..ceaaeeb<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c<br>
> @@ -0,0 +1,630 @@<br>
> +/*<br>
> + * Copyright 2016 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +<br>
> +#include "dm_services.h"<br>
> +#include "basics/dc_common.h"<br>
> +#include "core_types.h"<br>
> +#include "resource.h"<br>
> +#include "dcn201_hwseq.h"<br>
> +#include "dcn201_optc.h"<br>
> +#include "dce/dce_hwseq.h"<br>
> +#include "hubp.h"<br>
> +#include "dchubbub.h"<br>
> +#include "timing_generator.h"<br>
> +#include "opp.h"<br>
> +#include "ipp.h"<br>
> +#include "mpc.h"<br>
> +#include "dccg.h"<br>
> +#include "clk_mgr.h"<br>
> +#include "reg_helper.h"<br>
> +<br>
> +#define CTX \<br>
> + hws->ctx<br>
> +<br>
> +#define REG(reg)\<br>
> + hws->regs->reg<br>
> +<br>
> +#define DC_LOGGER \<br>
> + dc->ctx->logger<br>
> +<br>
> +#undef FN<br>
> +#define FN(reg_name, field_name) \<br>
> + hws->shifts->field_name, hws->masks->field_name<br>
> +<br>
> +static bool patch_address_for_sbs_tb_stereo(<br>
> + struct pipe_ctx *pipe_ctx, PHYSICAL_ADDRESS_LOC *addr)<br>
> +{<br>
> + struct dc_plane_state *plane_state = pipe_ctx->plane_state;<br>
> + bool sec_split = pipe_ctx->top_pipe &&<br>
> + pipe_ctx->top_pipe->plane_state == pipe_ctx->plane_state;<br>
> +<br>
> + if (sec_split && plane_state->address.type == PLN_ADDR_TYPE_GRPH_STEREO &&<br>
> + (pipe_ctx->stream->timing.timing_3d_format ==<br>
> + TIMING_3D_FORMAT_SIDE_BY_SIDE ||<br>
> + pipe_ctx->stream->timing.timing_3d_format ==<br>
> + TIMING_3D_FORMAT_TOP_AND_BOTTOM)) {<br>
> + *addr = plane_state->address.grph_stereo.left_addr;<br>
> + plane_state->address.grph_stereo.left_addr =<br>
> + plane_state->address.grph_stereo.right_addr;<br>
> + return true;<br>
> + } else {<br>
> + if (pipe_ctx->stream->view_format != VIEW_3D_FORMAT_NONE &&<br>
> + plane_state->address.type != PLN_ADDR_TYPE_GRPH_STEREO) {<br>
> + plane_state->address.type = PLN_ADDR_TYPE_GRPH_STEREO;<br>
> + plane_state->address.grph_stereo.right_addr =<br>
> + plane_state->address.grph_stereo.left_addr;<br>
> + plane_state->address.grph_stereo.right_meta_addr =<br>
> + plane_state->address.grph_stereo.left_meta_addr;<br>
> + }<br>
> + }<br>
> + return false;<br>
> +}<br>
> +<br>
> +static void gpu_addr_to_uma(struct dce_hwseq *hwseq,<br>
> + PHYSICAL_ADDRESS_LOC *addr)<br>
> +{<br>
> + bool is_in_uma;<br>
> +<br>
> + if (hwseq->fb_base.quad_part <= addr->quad_part &&<br>
> + addr->quad_part < hwseq->fb_top.quad_part) {<br>
> + addr->quad_part -= hwseq->fb_base.quad_part;<br>
> + addr->quad_part += hwseq->fb_offset.quad_part;<br>
> + is_in_uma = true;<br>
> + } else if (hwseq->fb_offset.quad_part <= addr->quad_part &&<br>
> + addr->quad_part <= hwseq->uma_top.quad_part) {<br>
> + is_in_uma = true;<br>
> + } else if (addr->quad_part == 0) {<br>
> + is_in_uma = false;<br>
> + } else {<br>
> + is_in_uma = false;<br>
> + }<br>
> +}<br>
> +<br>
> +static void plane_address_in_gpu_space_to_uma(struct dce_hwseq *hwseq,<br>
> + struct dc_plane_address *addr)<br>
> +{<br>
> + switch (addr->type) {<br>
> + case PLN_ADDR_TYPE_GRAPHICS:<br>
> + gpu_addr_to_uma(hwseq, &addr->grph.addr);<br>
> + gpu_addr_to_uma(hwseq, &addr->grph.meta_addr);<br>
> + break;<br>
> + case PLN_ADDR_TYPE_GRPH_STEREO:<br>
> + gpu_addr_to_uma(hwseq, &addr->grph_stereo.left_addr);<br>
> + gpu_addr_to_uma(hwseq, &addr->grph_stereo.left_meta_addr);<br>
> + gpu_addr_to_uma(hwseq, &addr->grph_stereo.right_addr);<br>
> + gpu_addr_to_uma(hwseq, &addr->grph_stereo.right_meta_addr);<br>
> + break;<br>
> + case PLN_ADDR_TYPE_VIDEO_PROGRESSIVE:<br>
> + gpu_addr_to_uma(hwseq, &addr->video_progressive.luma_addr);<br>
> + gpu_addr_to_uma(hwseq, &addr->video_progressive.luma_meta_addr);<br>
> + gpu_addr_to_uma(hwseq, &addr->video_progressive.chroma_addr);<br>
> + gpu_addr_to_uma(hwseq, &addr->video_progressive.chroma_meta_addr);<br>
> + break;<br>
> + default:<br>
> + BREAK_TO_DEBUGGER();<br>
> + break;<br>
> + }<br>
> +}<br>
> +<br>
> +void dcn201_update_plane_addr(const struct dc *dc, struct pipe_ctx *pipe_ctx)<br>
> +{<br>
> + bool addr_patched = false;<br>
> + PHYSICAL_ADDRESS_LOC addr;<br>
> + struct dc_plane_state *plane_state = pipe_ctx->plane_state;<br>
> + struct dce_hwseq *hws = dc->hwseq;<br>
> + struct dc_plane_address uma = plane_state->address;<br>
> +<br>
> + if (plane_state == NULL)<br>
> + return;<br>
> +<br>
> + addr_patched = patch_address_for_sbs_tb_stereo(pipe_ctx, &addr);<br>
> +<br>
> + plane_address_in_gpu_space_to_uma(hws, &uma);<br>
> +<br>
> + pipe_ctx->plane_res.hubp->funcs->hubp_program_surface_flip_and_addr(<br>
> + pipe_ctx->plane_res.hubp,<br>
> + &uma,<br>
> + plane_state->flip_immediate);<br>
> +<br>
> + plane_state->status.requested_address = plane_state->address;<br>
> +<br>
> + if (plane_state->flip_immediate)<br>
> + plane_state->status.current_address = plane_state->address;<br>
> +<br>
> + if (addr_patched)<br>
> + pipe_ctx->plane_state->address.grph_stereo.left_addr = addr;<br>
> +}<br>
> +<br>
> +/* Blank pixel data during initialization */<br>
> +void dcn201_init_blank(<br>
> + struct dc *dc,<br>
> + struct timing_generator *tg)<br>
> +{<br>
> + struct dce_hwseq *hws = dc->hwseq;<br>
> + enum dc_color_space color_space;<br>
> + struct tg_color black_color = {0};<br>
> + struct output_pixel_processor *opp = NULL;<br>
> + uint32_t num_opps, opp_id_src0, opp_id_src1;<br>
> + uint32_t otg_active_width, otg_active_height;<br>
> +<br>
> + /* program opp dpg blank color */<br>
> + color_space = COLOR_SPACE_SRGB;<br>
> + color_space_to_black_color(dc, color_space, &black_color);<br>
> +<br>
> + /* get the OTG active size */<br>
> + tg->funcs->get_otg_active_size(tg,<br>
> + &otg_active_width,<br>
> + &otg_active_height);<br>
> +<br>
> + /* get the OPTC source */<br>
> + tg->funcs->get_optc_source(tg, &num_opps, &opp_id_src0, &opp_id_src1);<br>
> + ASSERT(opp_id_src0 < dc->res_pool->res_cap->num_opp);<br>
> + opp = dc->res_pool->opps[opp_id_src0];<br>
> +<br>
> + opp->funcs->opp_set_disp_pattern_generator(<br>
> + opp,<br>
> + CONTROLLER_DP_TEST_PATTERN_SOLID_COLOR,<br>
> + CONTROLLER_DP_COLOR_SPACE_UDEFINED,<br>
> + COLOR_DEPTH_UNDEFINED,<br>
> + &black_color,<br>
> + otg_active_width,<br>
> + otg_active_height,<br>
> + 0);<br>
> +<br>
> + hws->funcs.wait_for_blank_complete(opp);<br>
> +}<br>
> +<br>
> +static void read_mmhub_vm_setup(struct dce_hwseq *hws)<br>
> +{<br>
> + uint32_t fb_base = REG_READ(MC_VM_FB_LOCATION_BASE);<br>
> + uint32_t fb_top = REG_READ(MC_VM_FB_LOCATION_TOP);<br>
> + uint32_t fb_offset = REG_READ(MC_VM_FB_OFFSET);<br>
> +<br>
> + /* MC_VM_FB_LOCATION_TOP is in pages, actual top should add 1 */<br>
> + fb_top++;<br>
> +<br>
> + /* bit 23:0 in register map to bit 47:24 in address */<br>
> + hws->fb_base.low_part = fb_base;<br>
> + hws->fb_base.quad_part <<= 24;<br>
> +<br>
> + hws->fb_top.low_part = fb_top;<br>
> + hws->fb_top.quad_part <<= 24;<br>
> + hws->fb_offset.low_part = fb_offset;<br>
> + hws->fb_offset.quad_part <<= 24;<br>
> +<br>
> + hws->uma_top.quad_part = hws->fb_top.quad_part<br>
> + - hws->fb_base.quad_part + hws->fb_offset.quad_part;<br>
> +}<br>
> +<br>
> +void dcn201_init_hw(struct dc *dc)<br>
> +{<br>
> + int i, j;<br>
> + struct dce_hwseq *hws = dc->hwseq;<br>
> + struct resource_pool *res_pool = dc->res_pool;<br>
> + struct dc_state *context = dc->current_state;<br>
> +<br>
> + if (res_pool->dccg->funcs->dccg_init)<br>
> + res_pool->dccg->funcs->dccg_init(res_pool->dccg);<br>
> +<br>
> + if (dc->clk_mgr && dc->clk_mgr->funcs->init_clocks)<br>
> + dc->clk_mgr->funcs->init_clocks(dc->clk_mgr);<br>
> +<br>
> + if (IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment)) {<br>
> + REG_WRITE(RBBMIF_TIMEOUT_DIS, 0xFFFFFFFF);<br>
> + REG_WRITE(RBBMIF_TIMEOUT_DIS_2, 0xFFFFFFFF);<br>
> +<br>
> + hws->funcs.dccg_init(hws);<br>
> +<br>
> + REG_UPDATE(DCHUBBUB_GLOBAL_TIMER_CNTL, DCHUBBUB_GLOBAL_TIMER_REFDIV, 2);<br>
> + REG_UPDATE(DCHUBBUB_GLOBAL_TIMER_CNTL, DCHUBBUB_GLOBAL_TIMER_ENABLE, 1);<br>
> + REG_WRITE(REFCLK_CNTL, 0);<br>
> + } else {<br>
> + hws->funcs.bios_golden_init(dc);<br>
> +<br>
> + if (dc->ctx->dc_bios->fw_info_valid) {<br>
> + res_pool->ref_clocks.xtalin_clock_inKhz =<br>
> + dc->ctx->dc_bios->fw_info.pll_info.crystal_frequency;<br>
> +<br>
> + if (!IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment)) {<br>
> + if (res_pool->dccg && res_pool->hubbub) {<br>
> + (res_pool->dccg->funcs->get_dccg_ref_freq)(res_pool->dccg,<br>
> + dc->ctx->dc_bios->fw_info.pll_info.crystal_frequency,<br>
> + &res_pool->ref_clocks.dccg_ref_clock_inKhz);<br>
> +<br>
> + (res_pool->hubbub->funcs->get_dchub_ref_freq)(res_pool->hubbub,<br>
> + res_pool->ref_clocks.dccg_ref_clock_inKhz,<br>
> + &res_pool->ref_clocks.dchub_ref_clock_inKhz);<br>
> + } else {<br>
> + res_pool->ref_clocks.dccg_ref_clock_inKhz =<br>
> + res_pool->ref_clocks.xtalin_clock_inKhz;<br>
> + res_pool->ref_clocks.dchub_ref_clock_inKhz =<br>
> + res_pool->ref_clocks.xtalin_clock_inKhz;<br>
> + }<br>
> + }<br>
> + } else<br>
> + ASSERT_CRITICAL(false);<br>
> + for (i = 0; i < dc->link_count; i++) {<br>
> + /* Power up AND update implementation according to the<br>
> + * required signal (which may be different from the<br>
> + * default signal on connector).<br>
> + */<br>
> + struct dc_link *link = dc->links[i];<br>
> +<br>
> + link->link_enc->funcs->hw_init(link->link_enc);<br>
> + }<br>
> + if (hws->fb_offset.quad_part == 0)<br>
> + read_mmhub_vm_setup(hws);<br>
> + }<br>
> +<br>
> + /* Blank pixel data with OPP DPG */<br>
> + for (i = 0; i < res_pool->timing_generator_count; i++) {<br>
> + struct timing_generator *tg = res_pool->timing_generators[i];<br>
> +<br>
> + if (tg->funcs->is_tg_enabled(tg)) {<br>
> + dcn201_init_blank(dc, tg);<br>
> + }<br>
> + }<br>
> +<br>
> + for (i = 0; i < res_pool->timing_generator_count; i++) {<br>
> + struct timing_generator *tg = res_pool->timing_generators[i];<br>
> +<br>
> + if (tg->funcs->is_tg_enabled(tg))<br>
> + tg->funcs->lock(tg);<br>
> + }<br>
> +<br>
> + for (i = 0; i < res_pool->pipe_count; i++) {<br>
> + struct dpp *dpp = res_pool->dpps[i];<br>
> +<br>
> + dpp->funcs->dpp_reset(dpp);<br>
> + }<br>
> +<br>
> + /* Reset all MPCC muxes */<br>
> + res_pool->mpc->funcs->mpc_init(res_pool->mpc);<br>
> +<br>
> + /* initialize OPP mpc_tree parameter */<br>
> + for (i = 0; i < res_pool->res_cap->num_opp; i++) {<br>
> + res_pool->opps[i]->mpc_tree_params.opp_id = res_pool->opps[i]->inst;<br>
> + res_pool->opps[i]->mpc_tree_params.opp_list = NULL;<br>
> + for (j = 0; j < MAX_PIPES; j++)<br>
> + res_pool->opps[i]->mpcc_disconnect_pending[j] = false;<br>
> + }<br>
> +<br>
> + for (i = 0; i < res_pool->timing_generator_count; i++) {<br>
> + struct timing_generator *tg = res_pool->timing_generators[i];<br>
> + struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];<br>
> + struct hubp *hubp = res_pool->hubps[i];<br>
> + struct dpp *dpp = res_pool->dpps[i];<br>
> +<br>
> + pipe_ctx->stream_res.tg = tg;<br>
> + pipe_ctx->pipe_idx = i;<br>
> +<br>
> + pipe_ctx->plane_res.hubp = hubp;<br>
> + pipe_ctx->plane_res.dpp = dpp;<br>
> + pipe_ctx->plane_res.mpcc_inst = dpp->inst;<br>
> + hubp->mpcc_id = dpp->inst;<br>
> + hubp->opp_id = OPP_ID_INVALID;<br>
> + hubp->power_gated = false;<br>
> + pipe_ctx->stream_res.opp = NULL;<br>
> +<br>
> + hubp->funcs->hubp_init(hubp);<br>
> +<br>
> + res_pool->opps[i]->mpcc_disconnect_pending[pipe_ctx->plane_res.mpcc_inst] = true;<br>
> + pipe_ctx->stream_res.opp = res_pool->opps[i];<br>
> + /*To do: number of MPCC != number of opp*/<br>
> + hws->funcs.plane_atomic_disconnect(dc, pipe_ctx);<br>
> + }<br>
> +<br>
> + /* initialize DWB pointer to MCIF_WB */<br>
> + for (i = 0; i < res_pool->res_cap->num_dwb; i++)<br>
> + res_pool->dwbc[i]->mcif = res_pool->mcif_wb[i];<br>
> +<br>
> + for (i = 0; i < res_pool->timing_generator_count; i++) {<br>
> + struct timing_generator *tg = res_pool->timing_generators[i];<br>
> +<br>
> + if (tg->funcs->is_tg_enabled(tg))<br>
> + tg->funcs->unlock(tg);<br>
> + }<br>
> +<br>
> + for (i = 0; i < res_pool->pipe_count; i++) {<br>
> + struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];<br>
> +<br>
> + dc->hwss.disable_plane(dc, pipe_ctx);<br>
> +<br>
> + pipe_ctx->stream_res.tg = NULL;<br>
> + pipe_ctx->plane_res.hubp = NULL;<br>
> + }<br>
> +<br>
> + for (i = 0; i < res_pool->timing_generator_count; i++) {<br>
> + struct timing_generator *tg = res_pool->timing_generators[i];<br>
> +<br>
> + tg->funcs->tg_init(tg);<br>
> + }<br>
> +<br>
> + /* end of FPGA. Below if real ASIC */<br>
> + if (IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment))<br>
> + return;<br>
> +<br>
> + for (i = 0; i < res_pool->audio_count; i++) {<br>
> + struct audio *audio = res_pool->audios[i];<br>
> +<br>
> + audio->funcs->hw_init(audio);<br>
> + }<br>
> +<br>
> + /* power AFMT HDMI memory TODO: may move to dis/en output save power*/<br>
> + REG_WRITE(DIO_MEM_PWR_CTRL, 0);<br>
> +<br>
> + if (!dc->debug.disable_clock_gate) {<br>
> + /* enable all DCN clock gating */<br>
> + REG_WRITE(DCCG_GATE_DISABLE_CNTL, 0);<br>
> +<br>
> + REG_WRITE(DCCG_GATE_DISABLE_CNTL2, 0);<br>
> +<br>
> + REG_UPDATE(DCFCLK_CNTL, DCFCLK_GATE_DIS, 0);<br>
> + }<br>
> +}<br>
> +<br>
> +/* trigger HW to start disconnect plane from stream on the next vsync */<br>
> +void dcn201_plane_atomic_disconnect(struct dc *dc, struct pipe_ctx *pipe_ctx)<br>
> +{<br>
> + struct dce_hwseq *hws = dc->hwseq;<br>
> + struct hubp *hubp = pipe_ctx->plane_res.hubp;<br>
> + int dpp_id = pipe_ctx->plane_res.dpp->inst;<br>
> + struct mpc *mpc = dc->res_pool->mpc;<br>
> + struct mpc_tree *mpc_tree_params;<br>
> + struct mpcc *mpcc_to_remove = NULL;<br>
> + struct output_pixel_processor *opp = pipe_ctx->stream_res.opp;<br>
> + bool mpcc_removed = false;<br>
> +<br>
> + mpc_tree_params = &(opp->mpc_tree_params);<br>
> +<br>
> + /* check if this plane is being used by an MPCC in the secondary blending chain */<br>
> + if (mpc->funcs->get_mpcc_for_dpp_from_secondary)<br>
> + mpcc_to_remove = mpc->funcs->get_mpcc_for_dpp_from_secondary(mpc_tree_params, dpp_id);<br>
> +<br>
> + /* remove MPCC from secondary if being used */<br>
> + if (mpcc_to_remove != NULL && mpc->funcs->remove_mpcc_from_secondary) {<br>
> + mpc->funcs->remove_mpcc_from_secondary(mpc, mpc_tree_params, mpcc_to_remove);<br>
> + mpcc_removed = true;<br>
> + }<br>
> +<br>
> + /* check if this MPCC is already being used for this plane (dpp) in the primary blending chain */<br>
> + mpcc_to_remove = mpc->funcs->get_mpcc_for_dpp(mpc_tree_params, dpp_id);<br>
> + if (mpcc_to_remove != NULL) {<br>
> + mpc->funcs->remove_mpcc(mpc, mpc_tree_params, mpcc_to_remove);<br>
> + mpcc_removed = true;<br>
> + }<br>
> +<br>
> + /*Already reset*/<br>
> + if (mpcc_removed == false)<br>
> + return;<br>
> +<br>
> + if (opp != NULL)<br>
> + opp->mpcc_disconnect_pending[pipe_ctx->plane_res.mpcc_inst] = true;<br>
> +<br>
> + dc->optimized_required = true;<br>
> +<br>
> + if (hubp->funcs->hubp_disconnect)<br>
> + hubp->funcs->hubp_disconnect(hubp);<br>
> +<br>
> + if (dc->debug.sanity_checks)<br>
> + hws->funcs.verify_allow_pstate_change_high(dc);<br>
> +}<br>
> +<br>
> +void dcn201_update_mpcc(struct dc *dc, struct pipe_ctx *pipe_ctx)<br>
> +{<br>
> + struct hubp *hubp = pipe_ctx->plane_res.hubp;<br>
> + struct mpcc_blnd_cfg blnd_cfg;<br>
> + bool per_pixel_alpha = pipe_ctx->plane_state->per_pixel_alpha && pipe_ctx->bottom_pipe;<br>
> + int mpcc_id, dpp_id;<br>
> + struct mpcc *new_mpcc;<br>
> + struct mpcc *remove_mpcc;<br>
> + struct mpc *mpc = dc->res_pool->mpc;<br>
> + struct mpc_tree *mpc_tree_params = &(pipe_ctx->stream_res.opp->mpc_tree_params);<br>
> +<br>
> + if (dc->debug.visual_confirm == VISUAL_CONFIRM_HDR) {<br>
> + get_hdr_visual_confirm_color(<br>
> + pipe_ctx, &blnd_cfg.black_color);<br>
> + } else if (dc->debug.visual_confirm == VISUAL_CONFIRM_SURFACE) {<br>
> + get_surface_visual_confirm_color(<br>
> + pipe_ctx, &blnd_cfg.black_color);<br>
> + } else {<br>
> + color_space_to_black_color(<br>
> + dc, pipe_ctx->stream->output_color_space,<br>
> + &blnd_cfg.black_color);<br>
> + }<br>
> +<br>
> + if (per_pixel_alpha)<br>
> + blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA;<br>
> + else<br>
> + blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA;<br>
> +<br>
> + blnd_cfg.overlap_only = false;<br>
> +<br>
> + if (pipe_ctx->plane_state->global_alpha_value)<br>
> + blnd_cfg.global_alpha = pipe_ctx->plane_state->global_alpha_value;<br>
> + else<br>
> + blnd_cfg.global_alpha = 0xff;<br>
> +<br>
> + blnd_cfg.global_gain = 0xff;<br>
> + blnd_cfg.background_color_bpc = 4;<br>
> + blnd_cfg.bottom_gain_mode = 0;<br>
> + blnd_cfg.top_gain = 0x1f000;<br>
> + blnd_cfg.bottom_inside_gain = 0x1f000;<br>
> + blnd_cfg.bottom_outside_gain = 0x1f000;<br>
> + /*the input to MPCC is RGB*/<br>
> + blnd_cfg.black_color.color_b_cb = 0;<br>
> + blnd_cfg.black_color.color_g_y = 0;<br>
> + blnd_cfg.black_color.color_r_cr = 0;<br>
> +<br>
> + /* DCN1.0 has output CM before MPC which seems to screw with<br>
> + * pre-multiplied alpha. This is a w/a hopefully unnecessary for DCN2.<br>
> + */<br>
> + blnd_cfg.pre_multiplied_alpha = per_pixel_alpha;<br>
> +<br>
> + /*<br>
> + * TODO: remove hack<br>
> + * Note: currently there is a bug in init_hw such that<br>
> + * on resume from hibernate, BIOS sets up MPCC0, and<br>
> + * we do mpcc_remove but the mpcc cannot go to idle<br>
> + * after remove. This cause us to pick mpcc1 here,<br>
> + * which causes a pstate hang for yet unknown reason.<br>
> + */<br>
> + dpp_id = hubp->inst;<br>
> + mpcc_id = dpp_id;<br>
> +<br>
> + /* If there is no full update, don't need to touch MPC tree*/<br>
> + if (!pipe_ctx->plane_state->update_flags.bits.full_update) {<br>
> + dc->hwss.update_visual_confirm_color(dc, pipe_ctx, &blnd_cfg.black_color, mpcc_id);<br>
> + mpc->funcs->update_blending(mpc, &blnd_cfg, mpcc_id);<br>
> + return;<br>
> + }<br>
> +<br>
> + /* check if this plane is being used by an MPCC in the secondary blending chain */<br>
> + if (mpc->funcs->get_mpcc_for_dpp_from_secondary)<br>
> + remove_mpcc = mpc->funcs->get_mpcc_for_dpp_from_secondary(mpc_tree_params, dpp_id);<br>
> +<br>
> + /* remove MPCC from secondary if being used */<br>
> + if (remove_mpcc != NULL && mpc->funcs->remove_mpcc_from_secondary)<br>
> + mpc->funcs->remove_mpcc_from_secondary(mpc, mpc_tree_params, remove_mpcc);<br>
> +<br>
> + /* check if this MPCC is already being used for this plane (dpp) in the primary blending chain */<br>
> + remove_mpcc = mpc->funcs->get_mpcc_for_dpp(mpc_tree_params, dpp_id);<br>
> + /* remove MPCC if being used */<br>
> +<br>
> + if (remove_mpcc != NULL)<br>
> + mpc->funcs->remove_mpcc(mpc, mpc_tree_params, remove_mpcc);<br>
> + else<br>
> + if (dc->debug.sanity_checks)<br>
> + mpc->funcs->assert_mpcc_idle_before_connect(<br>
> + dc->res_pool->mpc, mpcc_id);<br>
> +<br>
> + /* Call MPC to insert new plane */<br>
> + dc->hwss.update_visual_confirm_color(dc, pipe_ctx, &blnd_cfg.black_color, mpcc_id);<br>
> + new_mpcc = mpc->funcs->insert_plane(dc->res_pool->mpc,<br>
> + mpc_tree_params,<br>
> + &blnd_cfg,<br>
> + NULL,<br>
> + NULL,<br>
> + dpp_id,<br>
> + mpcc_id);<br>
> +<br>
> + ASSERT(new_mpcc != NULL);<br>
> + hubp->opp_id = pipe_ctx->stream_res.opp->inst;<br>
> + hubp->mpcc_id = mpcc_id;<br>
> +}<br>
> +<br>
> +void dcn201_pipe_control_lock(<br>
> + struct dc *dc,<br>
> + struct pipe_ctx *pipe,<br>
> + bool lock)<br>
> +{<br>
> + struct dce_hwseq *hws = dc->hwseq;<br>
> + struct hubp *hubp = NULL;<br>
> + hubp = dc->res_pool->hubps[pipe->pipe_idx];<br>
> + /* use TG master update lock to lock everything on the TG<br>
> + * therefore only top pipe need to lock<br>
> + */<br>
> + if (pipe->top_pipe)<br>
> + return;<br>
> +<br>
> + if (dc->debug.sanity_checks)<br>
> + hws->funcs.verify_allow_pstate_change_high(dc);<br>
> +<br>
> + if (pipe->plane_state != NULL && pipe->plane_state->triplebuffer_flips) {<br>
> + if (lock)<br>
> + pipe->stream_res.tg->funcs->triplebuffer_lock(pipe->stream_res.tg);<br>
> + else<br>
> + pipe->stream_res.tg->funcs->triplebuffer_unlock(pipe->stream_res.tg);<br>
> + } else {<br>
> + if (lock)<br>
> + pipe->stream_res.tg->funcs->lock(pipe->stream_res.tg);<br>
> + else<br>
> + pipe->stream_res.tg->funcs->unlock(pipe->stream_res.tg);<br>
> + }<br>
> +<br>
> + if (dc->debug.sanity_checks)<br>
> + hws->funcs.verify_allow_pstate_change_high(dc);<br>
> +}<br>
> +<br>
> +void dcn201_set_cursor_attribute(struct pipe_ctx *pipe_ctx)<br>
> +{<br>
> + struct dc_cursor_attributes *attributes = &pipe_ctx->stream->cursor_attributes;<br>
> +<br>
> + gpu_addr_to_uma(pipe_ctx->stream->ctx->dc->hwseq, &attributes->address);<br>
> +<br>
> + pipe_ctx->plane_res.hubp->funcs->set_cursor_attributes(<br>
> + pipe_ctx->plane_res.hubp, attributes);<br>
> + pipe_ctx->plane_res.dpp->funcs->set_cursor_attributes(<br>
> + pipe_ctx->plane_res.dpp, attributes);<br>
> +}<br>
> +<br>
> +void dcn201_set_dmdata_attributes(struct pipe_ctx *pipe_ctx)<br>
> +{<br>
> + struct dc_dmdata_attributes attr = { 0 };<br>
> + struct hubp *hubp = pipe_ctx->plane_res.hubp;<br>
> +<br>
> + gpu_addr_to_uma(pipe_ctx->stream->ctx->dc->hwseq,<br>
> + &pipe_ctx->stream->dmdata_address);<br>
> +<br>
> + attr.dmdata_mode = DMDATA_HW_MODE;<br>
> + attr.dmdata_size =<br>
> + dc_is_hdmi_signal(pipe_ctx->stream->signal) ? 32 : 36;<br>
> + attr.address.quad_part =<br>
> + pipe_ctx->stream->dmdata_address.quad_part;<br>
> + attr.dmdata_dl_delta = 0;<br>
> + attr.dmdata_qos_mode = 0;<br>
> + attr.dmdata_qos_level = 0;<br>
> + attr.dmdata_repeat = 1; /* always repeat */<br>
> + attr.dmdata_updated = 1;<br>
> + attr.dmdata_sw_data = NULL;<br>
> +<br>
> + hubp->funcs->dmdata_set_attributes(hubp, &attr);<br>
> +}<br>
> +<br>
> +void dcn201_unblank_stream(struct pipe_ctx *pipe_ctx,<br>
> + struct dc_link_settings *link_settings)<br>
> +{<br>
> + struct encoder_unblank_param params = { { 0 } };<br>
> + struct dc_stream_state *stream = pipe_ctx->stream;<br>
> + struct dc_link *link = stream->link;<br>
> + struct dce_hwseq *hws = link->dc->hwseq;<br>
> +<br>
> + /* only 3 items below are used by unblank */<br>
> + params.timing = pipe_ctx->stream->timing;<br>
> +<br>
> + params.link_settings.link_rate = link_settings->link_rate;<br>
> +<br>
> + if (dc_is_dp_signal(pipe_ctx->stream->signal)) {<br>
> + /*check whether it is half the rate*/<br>
> + if (optc201_is_two_pixels_per_containter(&stream->timing))<br>
> + params.timing.pix_clk_100hz /= 2;<br>
> +<br>
> + pipe_ctx->stream_res.stream_enc->funcs->dp_unblank(link, pipe_ctx->stream_res.stream_enc, ¶ms);<br>
> + }<br>
> +<br>
> + if (link->local_sink && link->local_sink->sink_signal == SIGNAL_TYPE_EDP) {<br>
> + hws->funcs.edp_backlight_control(link, true);<br>
> + }<br>
> +}<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.h b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.h<br>
> new file mode 100644<br>
> index 0000000..3ee6747<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.h<br>
> @@ -0,0 +1,46 @@<br>
> +/*<br>
> +* Copyright 2016 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +<br>
> +#ifndef __DC_HWSS_DCN201_H__<br>
> +#define __DC_HWSS_DCN201_H__<br>
> +<br>
> +#include "hw_sequencer_private.h"<br>
> +<br>
> +void dcn201_set_dmdata_attributes(struct pipe_ctx *pipe_ctx);<br>
> +void dcn201_init_hw(struct dc *dc);<br>
> +void dcn201_unblank_stream(struct pipe_ctx *pipe_ctx,<br>
> + struct dc_link_settings *link_settings);<br>
> +void dcn201_update_plane_addr(const struct dc *dc, struct pipe_ctx *pipe_ctx);<br>
> +void dcn201_plane_atomic_disconnect(struct dc *dc, struct pipe_ctx *pipe_ctx);<br>
> +void dcn201_update_mpcc(struct dc *dc, struct pipe_ctx *pipe_ctx);<br>
> +void dcn201_set_cursor_attribute(struct pipe_ctx *pipe_ctx);<br>
> +void dcn201_pipe_control_lock(<br>
> + struct dc *dc,<br>
> + struct pipe_ctx *pipe,<br>
> + bool lock);<br>
> +void dcn201_init_blank(<br>
> + struct dc *dc,<br>
> + struct timing_generator *tg);<br>
> +#endif /* __DC_HWSS_DCN201_H__ */<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_init.c b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_init.c<br>
> new file mode 100644<br>
> index 0000000..f1f89f9<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_init.c<br>
> @@ -0,0 +1,131 @@<br>
> +/*<br>
> + * Copyright 2016 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +<br>
> +#include "dce110/dce110_hw_sequencer.h"<br>
> +#include "dcn10/dcn10_hw_sequencer.h"<br>
> +#include "dcn20/dcn20_hwseq.h"<br>
> +#include "dcn201_hwseq.h"<br>
> +<br>
> +static const struct hw_sequencer_funcs dcn201_funcs = {<br>
> + .program_gamut_remap = dcn10_program_gamut_remap,<br>
> + .init_hw = dcn201_init_hw,<br>
> + .power_down_on_boot = NULL,<br>
> + .apply_ctx_to_hw = dce110_apply_ctx_to_hw,<br>
> + .apply_ctx_for_surface = NULL,<br>
> + .program_front_end_for_ctx = dcn20_program_front_end_for_ctx,<br>
> + .wait_for_pending_cleared = dcn10_wait_for_pending_cleared,<br>
> + .post_unlock_program_front_end = dcn10_post_unlock_program_front_end,<br>
> + .update_plane_addr = dcn201_update_plane_addr,<br>
> + .update_dchub = dcn10_update_dchub,<br>
> + .update_pending_status = dcn10_update_pending_status,<br>
> + .program_output_csc = dcn20_program_output_csc,<br>
> + .enable_accelerated_mode = dce110_enable_accelerated_mode,<br>
> + .enable_timing_synchronization = dcn10_enable_timing_synchronization,<br>
> + .enable_per_frame_crtc_position_reset = dcn10_enable_per_frame_crtc_position_reset,<br>
> + .update_info_frame = dce110_update_info_frame,<br>
> + .send_immediate_sdp_message = dcn10_send_immediate_sdp_message,<br>
> + .enable_stream = dce110_enable_stream,<br>
> + .disable_stream = dce110_disable_stream,<br>
> + .unblank_stream = dcn201_unblank_stream,<br>
> + .blank_stream = dce110_blank_stream,<br>
> + .enable_audio_stream = dce110_enable_audio_stream,<br>
> + .disable_audio_stream = dce110_disable_audio_stream,<br>
> + .disable_plane = dcn10_disable_plane,<br>
> + .pipe_control_lock = dcn201_pipe_control_lock,<br>
> + .interdependent_update_lock = dcn10_lock_all_pipes,<br>
> + .cursor_lock = dcn10_cursor_lock,<br>
> + .prepare_bandwidth = dcn20_prepare_bandwidth,<br>
> + .optimize_bandwidth = dcn20_optimize_bandwidth,<br>
> + .update_bandwidth = dcn20_update_bandwidth,<br>
> + .set_drr = dcn10_set_drr,<br>
> + .get_position = dcn10_get_position,<br>
> + .set_static_screen_control = dcn10_set_static_screen_control,<br>
> + .setup_stereo = dcn10_setup_stereo,<br>
> + .set_avmute = dce110_set_avmute,<br>
> + .log_hw_state = dcn10_log_hw_state,<br>
> + .get_hw_state = dcn10_get_hw_state,<br>
> + .clear_status_bits = dcn10_clear_status_bits,<br>
> + .wait_for_mpcc_disconnect = dcn10_wait_for_mpcc_disconnect,<br>
> + .edp_backlight_control = dce110_edp_backlight_control,<br>
> + .edp_power_control = dce110_edp_power_control,<br>
> + .edp_wait_for_hpd_ready = dce110_edp_wait_for_hpd_ready,<br>
> + .setup_periodic_interrupt = dcn10_setup_periodic_interrupt,<br>
> + .set_clock = dcn10_set_clock,<br>
> + .get_clock = dcn10_get_clock,<br>
> + .program_triplebuffer = dcn20_program_triple_buffer,<br>
> + .dmdata_status_done = dcn20_dmdata_status_done,<br>
> + .set_dmdata_attributes = dcn201_set_dmdata_attributes,<br>
> + .get_vupdate_offset_from_vsync = dcn10_get_vupdate_offset_from_vsync,<br>
> + .calc_vupdate_position = dcn10_calc_vupdate_position,<br>
> + .set_cursor_position = dcn10_set_cursor_position,<br>
> + .set_cursor_attribute = dcn201_set_cursor_attribute,<br>
> + .set_cursor_sdr_white_level = dcn10_set_cursor_sdr_white_level,<br>
> + .set_backlight_level = dce110_set_backlight_level,<br>
> + .set_abm_immediate_disable = dce110_set_abm_immediate_disable,<br>
> + .set_pipe = dce110_set_pipe,<br>
> + .set_disp_pattern_generator = dcn20_set_disp_pattern_generator,<br>
> + .update_visual_confirm_color = dcn20_update_visual_confirm_color,<br>
> +};<br>
> +<br>
> +static const struct hwseq_private_funcs dcn201_private_funcs = {<br>
> + .init_pipes = NULL,<br>
> + .update_plane_addr = dcn201_update_plane_addr,<br>
> + .plane_atomic_disconnect = dcn201_plane_atomic_disconnect,<br>
> + .program_pipe = dcn10_program_pipe,<br>
> + .update_mpcc = dcn201_update_mpcc,<br>
> + .set_input_transfer_func = dcn20_set_input_transfer_func,<br>
> + .set_output_transfer_func = dcn20_set_output_transfer_func,<br>
> + .power_down = dce110_power_down,<br>
> + .enable_display_power_gating = dcn10_dummy_display_power_gating,<br>
> + .blank_pixel_data = dcn20_blank_pixel_data,<br>
> + .reset_hw_ctx_wrap = dcn10_reset_hw_ctx_wrap,<br>
> + .enable_stream_timing = dcn20_enable_stream_timing,<br>
> + .edp_backlight_control = dce110_edp_backlight_control,<br>
> + .disable_stream_gating = NULL,<br>
> + .enable_stream_gating = NULL,<br>
> + .setup_vupdate_interrupt = dcn20_setup_vupdate_interrupt,<br>
> + .did_underflow_occur = dcn10_did_underflow_occur,<br>
> + .init_blank = dcn201_init_blank,<br>
> + .disable_vga = dcn10_disable_vga,<br>
> + .bios_golden_init = dcn10_bios_golden_init,<br>
> + .plane_atomic_disable = dcn10_plane_atomic_disable,<br>
> + .plane_atomic_power_down = dcn10_plane_atomic_power_down,<br>
> + .enable_power_gating_plane = dcn10_enable_power_gating_plane,<br>
> + .dpp_pg_control = dcn10_dpp_pg_control,<br>
> + .hubp_pg_control = dcn10_hubp_pg_control,<br>
> + .dsc_pg_control = NULL,<br>
> + .set_hdr_multiplier = dcn10_set_hdr_multiplier,<br>
> + .verify_allow_pstate_change_high = dcn10_verify_allow_pstate_change_high,<br>
> + .wait_for_blank_complete = dcn20_wait_for_blank_complete,<br>
> + .dccg_init = dcn20_dccg_init,<br>
> + .set_blend_lut = dcn20_set_blend_lut,<br>
> + .set_shaper_3dlut = dcn20_set_shaper_3dlut,<br>
> +};<br>
> +<br>
> +void dcn201_hw_sequencer_construct(struct dc *dc)<br>
> +{<br>
> + dc->hwss = dcn201_funcs;<br>
> + dc->hwseq->funcs = dcn201_private_funcs;<br>
> +}<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_init.h b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_init.h<br>
> new file mode 100644<br>
> index 0000000..1168887<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_init.h<br>
> @@ -0,0 +1,33 @@<br>
> +/*<br>
> + * Copyright 2016 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +<br>
> +#ifndef __DC_DCN201_INIT_H__<br>
> +#define __DC_DCN201_INIT_H__<br>
> +<br>
> +struct dc;<br>
> +<br>
> +void dcn201_hw_sequencer_construct(struct dc *dc);<br>
> +<br>
> +#endif /* __DC_DCN201_INIT_H__ */<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_link_encoder.c b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_link_encoder.c<br>
> new file mode 100644<br>
> index 0000000..a65e8f7<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_link_encoder.c<br>
> @@ -0,0 +1,209 @@<br>
> +/*<br>
> + * Copyright 2012-15 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +<br>
> +#include "reg_helper.h"<br>
> +<br>
> +#include "core_types.h"<br>
> +#include "link_encoder.h"<br>
> +#include "dcn201_link_encoder.h"<br>
> +#include "stream_encoder.h"<br>
> +#include "i2caux_interface.h"<br>
> +#include "dc_bios_types.h"<br>
> +<br>
> +#include "gpio_service_interface.h"<br>
> +<br>
> +#define CTX \<br>
> + enc10->base.ctx<br>
> +<br>
> +#define DC_LOGGER \<br>
> + enc10->base.ctx->logger<br>
> +<br>
> +#define REG(reg)\<br>
> + (enc10->link_regs->reg)<br>
> +<br>
> +#undef FN<br>
> +#define FN(reg_name, field_name) \<br>
> + enc10->link_shift->field_name, enc10->link_mask->field_name<br>
> +<br>
> +#define IND_REG(index) \<br>
> + (enc10->link_regs->index)<br>
> +<br>
> +void dcn201_link_encoder_get_max_link_cap(struct link_encoder *enc,<br>
> + struct dc_link_settings *link_settings)<br>
> +{<br>
> + uint32_t value1, value2;<br>
> + struct dcn10_link_encoder *enc10 = TO_DCN10_LINK_ENC(enc);<br>
> +<br>
> + dcn10_link_encoder_get_max_link_cap(enc, link_settings);<br>
> + REG_GET_2(RDPCSTX_PHY_CNTL2, RDPCS_PHY_DPALT_DISABLE, &value1,<br>
> + RDPCS_PHY_DPALT_DP4, &value2);<br>
> + /*limit to combo_phy*/<br>
> + if (enc->usbc_combo_phy) {<br>
> + if (!value1 && !value2 && link_settings->lane_count > LANE_COUNT_TWO)<br>
> + link_settings->lane_count = LANE_COUNT_TWO;<br>
> + }<br>
> +}<br>
> +<br>
> +bool dcn201_link_encoder_is_in_alt_mode(struct link_encoder *enc)<br>
> +{<br>
> + uint32_t value;<br>
> + struct dcn10_link_encoder *enc10 = TO_DCN10_LINK_ENC(enc);<br>
> +<br>
> + REG_GET(RDPCSTX_PHY_CNTL2, RDPCS_PHY_DPALT_DISABLE, &value);<br>
> +<br>
> + // if value == 1 alt mode is disabled, otherwise it is enabled<br>
> + return !value;<br>
> +}<br>
> +<br>
> +static const struct link_encoder_funcs dcn201_link_enc_funcs = {<br>
> + .read_state = link_enc2_read_state,<br>
> + .validate_output_with_stream =<br>
> + dcn10_link_encoder_validate_output_with_stream,<br>
> + .hw_init = enc2_hw_init,<br>
> + .setup = dcn10_link_encoder_setup,<br>
> + .enable_tmds_output = dcn10_link_encoder_enable_tmds_output,<br>
> + .enable_dp_output = dcn10_link_encoder_enable_dp_output,<br>
> + .enable_dp_mst_output = dcn10_link_encoder_enable_dp_mst_output,<br>
> + .disable_output = dcn10_link_encoder_disable_output,<br>
> + .dp_set_lane_settings = dcn10_link_encoder_dp_set_lane_settings,<br>
> + .dp_set_phy_pattern = dcn10_link_encoder_dp_set_phy_pattern,<br>
> + .update_mst_stream_allocation_table =<br>
> + dcn10_link_encoder_update_mst_stream_allocation_table,<br>
> + .psr_program_dp_dphy_fast_training =<br>
> + dcn10_psr_program_dp_dphy_fast_training,<br>
> + .psr_program_secondary_packet = dcn10_psr_program_secondary_packet,<br>
> + .connect_dig_be_to_fe = dcn10_link_encoder_connect_dig_be_to_fe,<br>
> + .enable_hpd = dcn10_link_encoder_enable_hpd,<br>
> + .disable_hpd = dcn10_link_encoder_disable_hpd,<br>
> + .is_dig_enabled = dcn10_is_dig_enabled,<br>
> + .destroy = dcn10_link_encoder_destroy,<br>
> + .fec_set_enable = enc2_fec_set_enable,<br>
> + .fec_set_ready = enc2_fec_set_ready,<br>
> + .get_dig_frontend = dcn10_get_dig_frontend,<br>
> + .fec_is_active = enc2_fec_is_active,<br>
> + .is_in_alt_mode = dcn201_link_encoder_is_in_alt_mode,<br>
> + .get_max_link_cap = dcn201_link_encoder_get_max_link_cap,<br>
> +};<br>
> +<br>
> +void dcn201_link_encoder_construct(<br>
> + struct dcn20_link_encoder *enc20,<br>
> + const struct encoder_init_data *init_data,<br>
> + const struct encoder_feature_support *enc_features,<br>
> + const struct dcn10_link_enc_registers *link_regs,<br>
> + const struct dcn10_link_enc_aux_registers *aux_regs,<br>
> + const struct dcn10_link_enc_hpd_registers *hpd_regs,<br>
> + const struct dcn10_link_enc_shift *link_shift,<br>
> + const struct dcn10_link_enc_mask *link_mask)<br>
> +{<br>
> + struct bp_encoder_cap_info bp_cap_info = {0};<br>
> + const struct dc_vbios_funcs *bp_funcs = init_data->ctx->dc_bios->funcs;<br>
> + enum bp_result result = BP_RESULT_OK;<br>
> + struct dcn10_link_encoder *enc10 = &enc20->enc10;<br>
> +<br>
> + enc10->base.funcs = &dcn201_link_enc_funcs;<br>
> + enc10->base.ctx = init_data->ctx;<br>
> + enc10->base.id = init_data->encoder;<br>
> +<br>
> + enc10->base.hpd_source = init_data->hpd_source;<br>
> + enc10->base.connector = init_data->connector;<br>
> +<br>
> + enc10->base.preferred_engine = ENGINE_ID_UNKNOWN;<br>
> +<br>
> + enc10->base.features = *enc_features;<br>
> +<br>
> + enc10->base.transmitter = init_data->transmitter;<br>
> +<br>
> + /* set the flag to indicate whether driver poll the I2C data pin<br>
> + * while doing the DP sink detect<br>
> + */<br>
> +<br>
> + /* if (dal_adapter_service_is_feature_supported(as,<br>
> + * FEATURE_DP_SINK_DETECT_POLL_DATA_PIN))<br>
> + * enc10->base.features.flags.bits.<br>
> + * DP_SINK_DETECT_POLL_DATA_PIN = true;<br>
> + */<br>
> +<br>
> + enc10->base.output_signals =<br>
> + SIGNAL_TYPE_DVI_SINGLE_LINK |<br>
> + SIGNAL_TYPE_DVI_DUAL_LINK |<br>
> + SIGNAL_TYPE_LVDS |<br>
> + SIGNAL_TYPE_DISPLAY_PORT |<br>
> + SIGNAL_TYPE_DISPLAY_PORT_MST |<br>
> + SIGNAL_TYPE_EDP |<br>
> + SIGNAL_TYPE_HDMI_TYPE_A;<br>
> +<br>
> + /* For DCE 8.0 and 8.1, by design, UNIPHY is hardwired to DIG_BE.<br>
> + * SW always assign DIG_FE 1:1 mapped to DIG_FE for non-MST UNIPHY.<br>
> + * SW assign DIG_FE to non-MST UNIPHY first and MST last. So prefer<br>
> + * DIG is per UNIPHY and used by SST DP, eDP, HDMI, DVI and LVDS.<br>
> + * Prefer DIG assignment is decided by board design.<br>
> + * For DCE 8.0, there are only max 6 UNIPHYs, we assume board design<br>
> + * and VBIOS will filter out 7 UNIPHY for DCE 8.0.<br>
> + * By this, adding DIGG should not hurt DCE 8.0.<br>
> + * This will let DCE 8.1 share DCE 8.0 as much as possible<br>
> + */<br>
> +<br>
> + enc10->link_regs = link_regs;<br>
> + enc10->aux_regs = aux_regs;<br>
> + enc10->hpd_regs = hpd_regs;<br>
> + enc10->link_shift = link_shift;<br>
> + enc10->link_mask = link_mask;<br>
> +<br>
> + switch (enc10->base.transmitter) {<br>
> + case TRANSMITTER_UNIPHY_A:<br>
> + enc10->base.preferred_engine = ENGINE_ID_DIGA;<br>
> + break;<br>
> + case TRANSMITTER_UNIPHY_B:<br>
> + enc10->base.preferred_engine = ENGINE_ID_DIGB;<br>
> + break;<br>
> + default:<br>
> + ASSERT_CRITICAL(false);<br>
> + enc10->base.preferred_engine = ENGINE_ID_UNKNOWN;<br>
> + }<br>
> +<br>
> + /* default to one to mirror Windows behavior */<br>
> + enc10->base.features.flags.bits.HDMI_6GB_EN = 1;<br>
> +<br>
> + result = bp_funcs->get_encoder_cap_info(enc10->base.ctx->dc_bios,<br>
> + enc10->base.id, &bp_cap_info);<br>
> +<br>
> + /* Override features with DCE-specific values */<br>
> + if (result == BP_RESULT_OK) {<br>
> + enc10->base.features.flags.bits.IS_HBR2_CAPABLE =<br>
> + bp_cap_info.DP_HBR2_EN;<br>
> + enc10->base.features.flags.bits.IS_HBR3_CAPABLE =<br>
> + bp_cap_info.DP_HBR3_EN;<br>
> + enc10->base.features.flags.bits.HDMI_6GB_EN = bp_cap_info.HDMI_6GB_EN;<br>
> + enc10->base.features.flags.bits.DP_IS_USB_C =<br>
> + bp_cap_info.DP_IS_USB_C;<br>
> + } else {<br>
> + DC_LOG_WARNING("%s: Failed to get encoder_cap_info from VBIOS with error code %d!\n",<br>
> + __func__,<br>
> + result);<br>
> + }<br>
> + if (enc10->base.ctx->dc->debug.hdmi20_disable) {<br>
> + enc10->base.features.flags.bits.HDMI_6GB_EN = 0;<br>
> + }<br>
> +}<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_link_encoder.h b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_link_encoder.h<br>
> new file mode 100644<br>
> index 0000000..8b95ef2<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_link_encoder.h<br>
> @@ -0,0 +1,59 @@<br>
> +/*<br>
> + * Copyright 2012-15 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +<br>
> +#ifndef __DC_LINK_ENCODER__DCN201_H__<br>
> +#define __DC_LINK_ENCODER__DCN201_H__<br>
> +<br>
> +#include "dcn20/dcn20_link_encoder.h"<br>
> +<br>
> +#define DPCS_DCN201_MASK_SH_LIST(mask_sh)\<br>
> + DPCS_MASK_SH_LIST(mask_sh),\<br>
> + LE_SF(RDPCSTX0_RDPCSTX_PHY_CNTL2, RDPCS_PHY_DPALT_DISABLE_ACK, mask_sh),\<br>
> + LE_SF(RDPCSTX0_RDPCSTX_PHY_CNTL2, RDPCS_PHY_DPALT_DISABLE, mask_sh),\<br>
> + LE_SF(RDPCSTX0_RDPCSTX_PHY_CNTL2, RDPCS_PHY_DPALT_DP4, mask_sh),\<br>
> + LE_SF(RDPCSTX0_RDPCSTX_PHY_CNTL5, RDPCS_PHY_DP_TX0_PSTATE, mask_sh),\<br>
> + LE_SF(RDPCSTX0_RDPCSTX_PHY_CNTL5, RDPCS_PHY_DP_TX1_PSTATE, mask_sh),\<br>
> + LE_SF(RDPCSTX0_RDPCSTX_PHY_CNTL5, RDPCS_PHY_DP_TX0_MPLL_EN, mask_sh),\<br>
> + LE_SF(RDPCSTX0_RDPCSTX_PHY_CNTL5, RDPCS_PHY_DP_TX1_MPLL_EN, mask_sh),\<br>
> + LE_SF(RDPCSTX0_RDPCSTX_PHY_CNTL6, RDPCS_PHY_DP_TX2_WIDTH, mask_sh),\<br>
> + LE_SF(RDPCSTX0_RDPCSTX_PHY_CNTL6, RDPCS_PHY_DP_TX2_RATE, mask_sh),\<br>
> + LE_SF(RDPCSTX0_RDPCSTX_PHY_CNTL6, RDPCS_PHY_DP_TX3_WIDTH, mask_sh),\<br>
> + LE_SF(RDPCSTX0_RDPCSTX_PHY_CNTL6, RDPCS_PHY_DP_TX3_RATE, mask_sh),\<br>
> + LE_SF(RDPCSTX0_RDPCSTX_PHY_CNTL11, RDPCS_PHY_DP_REF_CLK_EN, mask_sh)<br>
> +<br>
> +#define DPCS_DCN201_REG_LIST(id) \<br>
> + DPCS_DCN2_CMN_REG_LIST(id)<br>
> +<br>
> +void dcn201_link_encoder_construct(<br>
> + struct dcn20_link_encoder *enc20,<br>
> + const struct encoder_init_data *init_data,<br>
> + const struct encoder_feature_support *enc_features,<br>
> + const struct dcn10_link_enc_registers *link_regs,<br>
> + const struct dcn10_link_enc_aux_registers *aux_regs,<br>
> + const struct dcn10_link_enc_hpd_registers *hpd_regs,<br>
> + const struct dcn10_link_enc_shift *link_shift,<br>
> + const struct dcn10_link_enc_mask *link_mask);<br>
> +<br>
> +#endif /* __DC_LINK_ENCODER__DCN201_H__ */<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_mpc.c b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_mpc.c<br>
> new file mode 100644<br>
> index 0000000..95c4c55<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_mpc.c<br>
> @@ -0,0 +1,125 @@<br>
> +/*<br>
> + * Copyright 2012-15 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +<br>
> +#include "reg_helper.h"<br>
> +#include "dcn201_mpc.h"<br>
> +<br>
> +#define REG(reg)\<br>
> + mpc201->mpc_regs->reg<br>
> +<br>
> +#define CTX \<br>
> + mpc201->base.ctx<br>
> +<br>
> +#define DC_LOGGER \<br>
> + mpc201->base.ctx->logger<br>
> +<br>
> +#undef FN<br>
> +#define FN(reg_name, field_name) \<br>
> + mpc201->mpc_shift->field_name, mpc201->mpc_mask->field_name<br>
> +<br>
> +static void mpc201_set_out_rate_control(<br>
> + struct mpc *mpc,<br>
> + int opp_id,<br>
> + bool enable,<br>
> + bool rate_2x_mode,<br>
> + struct mpc_dwb_flow_control *flow_control)<br>
> +{<br>
> + struct dcn201_mpc *mpc201 = TO_DCN201_MPC(mpc);<br>
> +<br>
> + REG_UPDATE_2(MUX[opp_id],<br>
> + MPC_OUT_RATE_CONTROL_DISABLE, !enable,<br>
> + MPC_OUT_RATE_CONTROL, rate_2x_mode);<br>
> +<br>
> + if (flow_control)<br>
> + REG_UPDATE_3(MUX[opp_id],<br>
> + MPC_OUT_FLOW_CONTROL_MODE, flow_control->flow_ctrl_mode,<br>
> + MPC_OUT_FLOW_CONTROL_COUNT0, flow_control->flow_ctrl_cnt0,<br>
> + MPC_OUT_FLOW_CONTROL_COUNT1, flow_control->flow_ctrl_cnt1);<br>
> +}<br>
> +<br>
> +static void mpc201_init_mpcc(struct mpcc *mpcc, int mpcc_inst)<br>
> +{<br>
> + mpcc->mpcc_id = mpcc_inst;<br>
> + mpcc->dpp_id = 0xf;<br>
> + mpcc->mpcc_bot = NULL;<br>
> + mpcc->blnd_cfg.overlap_only = false;<br>
> + mpcc->blnd_cfg.global_alpha = 0xff;<br>
> + mpcc->blnd_cfg.global_gain = 0xff;<br>
> + mpcc->blnd_cfg.background_color_bpc = 4;<br>
> + mpcc->blnd_cfg.bottom_gain_mode = 0;<br>
> + mpcc->blnd_cfg.top_gain = 0x1f000;<br>
> + mpcc->blnd_cfg.bottom_inside_gain = 0x1f000;<br>
> + mpcc->blnd_cfg.bottom_outside_gain = 0x1f000;<br>
> + mpcc->sm_cfg.enable = false;<br>
> + mpcc->shared_bottom = false;<br>
> +}<br>
> +<br>
> +const struct mpc_funcs dcn201_mpc_funcs = {<br>
> + .read_mpcc_state = mpc1_read_mpcc_state,<br>
> + .insert_plane = mpc1_insert_plane,<br>
> + .remove_mpcc = mpc1_remove_mpcc,<br>
> + .mpc_init = mpc1_mpc_init,<br>
> + .mpc_init_single_inst = mpc1_mpc_init_single_inst,<br>
> + .update_blending = mpc2_update_blending,<br>
> + .cursor_lock = mpc1_cursor_lock,<br>
> + .get_mpcc_for_dpp = mpc1_get_mpcc_for_dpp,<br>
> + .get_mpcc_for_dpp_from_secondary = NULL,<br>
> + .wait_for_idle = mpc2_assert_idle_mpcc,<br>
> + .assert_mpcc_idle_before_connect = mpc2_assert_mpcc_idle_before_connect,<br>
> + .init_mpcc_list_from_hw = mpc1_init_mpcc_list_from_hw,<br>
> + .set_denorm = mpc2_set_denorm,<br>
> + .set_denorm_clamp = mpc2_set_denorm_clamp,<br>
> + .set_output_csc = mpc2_set_output_csc,<br>
> + .set_ocsc_default = mpc2_set_ocsc_default,<br>
> + .set_output_gamma = mpc2_set_output_gamma,<br>
> + .set_out_rate_control = mpc201_set_out_rate_control,<br>
> + .power_on_mpc_mem_pwr = mpc20_power_on_ogam_lut,<br>
> + .get_mpc_out_mux = mpc1_get_mpc_out_mux,<br>
> + .set_bg_color = mpc1_set_bg_color,<br>
> +};<br>
> +<br>
> +void dcn201_mpc_construct(struct dcn201_mpc *mpc201,<br>
> + struct dc_context *ctx,<br>
> + const struct dcn201_mpc_registers *mpc_regs,<br>
> + const struct dcn201_mpc_shift *mpc_shift,<br>
> + const struct dcn201_mpc_mask *mpc_mask,<br>
> + int num_mpcc)<br>
> +{<br>
> + int i;<br>
> +<br>
> + mpc201->base.ctx = ctx;<br>
> +<br>
> + mpc201->base.funcs = &dcn201_mpc_funcs;<br>
> +<br>
> + mpc201->mpc_regs = mpc_regs;<br>
> + mpc201->mpc_shift = mpc_shift;<br>
> + mpc201->mpc_mask = mpc_mask;<br>
> +<br>
> + mpc201->mpcc_in_use_mask = 0;<br>
> + mpc201->num_mpcc = num_mpcc;<br>
> +<br>
> + for (i = 0; i < MAX_MPCC; i++)<br>
> + mpc201_init_mpcc(&mpc201->base.mpcc_array[i], i);<br>
> +}<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_mpc.h b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_mpc.h<br>
> new file mode 100644<br>
> index 0000000..b9ce0c1<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_mpc.h<br>
> @@ -0,0 +1,86 @@<br>
> +/* Copyright 2012-15 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +<br>
> +#ifndef __DC_MPCC_DCN201_H__<br>
> +#define __DC_MPCC_DCN201_H__<br>
> +<br>
> +#include "dcn20/dcn20_mpc.h"<br>
> +<br>
> +#define TO_DCN201_MPC(mpc_base) \<br>
> + container_of(mpc_base, struct dcn201_mpc, base)<br>
> +<br>
> +#define MPC_REG_LIST_DCN201(inst) \<br>
> + MPC_REG_LIST_DCN2_0(inst)<br>
> +<br>
> +#define MPC_OUT_MUX_REG_LIST_DCN201(inst) \<br>
> + MPC_OUT_MUX_REG_LIST_DCN2_0(inst)<br>
> +<br>
> +#define MPC_REG_VARIABLE_LIST_DCN201 \<br>
> + MPC_REG_VARIABLE_LIST_DCN2_0<br>
> +<br>
> +#define MPC_COMMON_MASK_SH_LIST_DCN201(mask_sh) \<br>
> + MPC_COMMON_MASK_SH_LIST_DCN2_0(mask_sh),\<br>
> + SF(MPC_OUT0_MUX, MPC_OUT_RATE_CONTROL, mask_sh),\<br>
> + SF(MPC_OUT0_MUX, MPC_OUT_RATE_CONTROL_DISABLE, mask_sh),\<br>
> + SF(MPC_OUT0_MUX, MPC_OUT_FLOW_CONTROL_MODE, mask_sh),\<br>
> + SF(MPC_OUT0_MUX, MPC_OUT_FLOW_CONTROL_COUNT0, mask_sh),\<br>
> + SF(MPC_OUT0_MUX, MPC_OUT_FLOW_CONTROL_COUNT1, mask_sh)<br>
> +<br>
> +#define MPC_REG_FIELD_LIST_DCN201(type) \<br>
> + MPC_REG_FIELD_LIST_DCN2_0(type) \<br>
> + type MPC_OUT_RATE_CONTROL;\<br>
> + type MPC_OUT_RATE_CONTROL_DISABLE;\<br>
> + type MPC_OUT_FLOW_CONTROL_MODE;\<br>
> + type MPC_OUT_FLOW_CONTROL_COUNT0;\<br>
> + type MPC_OUT_FLOW_CONTROL_COUNT1;<br>
> +<br>
> +struct dcn201_mpc_registers {<br>
> + MPC_REG_VARIABLE_LIST_DCN201<br>
> +};<br>
> +<br>
> +struct dcn201_mpc_shift {<br>
> + MPC_REG_FIELD_LIST_DCN201(uint8_t)<br>
> +};<br>
> +<br>
> +struct dcn201_mpc_mask {<br>
> + MPC_REG_FIELD_LIST_DCN201(uint32_t)<br>
> +};<br>
> +<br>
> +struct dcn201_mpc {<br>
> + struct mpc base;<br>
> + int mpcc_in_use_mask;<br>
> + int num_mpcc;<br>
> + const struct dcn201_mpc_registers *mpc_regs;<br>
> + const struct dcn201_mpc_shift *mpc_shift;<br>
> + const struct dcn201_mpc_mask *mpc_mask;<br>
> +};<br>
> +<br>
> +void dcn201_mpc_construct(struct dcn201_mpc *mpc201,<br>
> + struct dc_context *ctx,<br>
> + const struct dcn201_mpc_registers *mpc_regs,<br>
> + const struct dcn201_mpc_shift *mpc_shift,<br>
> + const struct dcn201_mpc_mask *mpc_mask,<br>
> + int num_mpcc);<br>
> +<br>
> +#endif<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_opp.c b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_opp.c<br>
> new file mode 100644<br>
> index 0000000..8e77db4<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_opp.c<br>
> @@ -0,0 +1,72 @@<br>
> +/*<br>
> + * Copyright 2012-15 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +<br>
> +#include "dm_services.h"<br>
> +#include "dcn201_opp.h"<br>
> +#include "reg_helper.h"<br>
> +<br>
> +#define REG(reg) \<br>
> + (oppn201->regs->reg)<br>
> +<br>
> +#undef FN<br>
> +#define FN(reg_name, field_name) \<br>
> + oppn201->opp_shift->field_name, oppn201->opp_mask->field_name<br>
> +<br>
> +#define CTX \<br>
> + oppn201->base.ctx<br>
> +<br>
> +/*****************************************/<br>
> +/* Constructor, Destructor */<br>
> +/*****************************************/<br>
> +<br>
> +static struct opp_funcs dcn201_opp_funcs = {<br>
> + .opp_set_dyn_expansion = opp1_set_dyn_expansion,<br>
> + .opp_program_fmt = opp1_program_fmt,<br>
> + .opp_program_bit_depth_reduction = opp1_program_bit_depth_reduction,<br>
> + .opp_program_stereo = opp1_program_stereo,<br>
> + .opp_pipe_clock_control = opp1_pipe_clock_control,<br>
> + .opp_set_disp_pattern_generator = opp2_set_disp_pattern_generator,<br>
> + .opp_program_dpg_dimensions = opp2_program_dpg_dimensions,<br>
> + .dpg_is_blanked = opp2_dpg_is_blanked,<br>
> + .opp_dpg_set_blank_color = opp2_dpg_set_blank_color,<br>
> + .opp_destroy = opp1_destroy,<br>
> + .opp_program_left_edge_extra_pixel = opp2_program_left_edge_extra_pixel,<br>
> +};<br>
> +<br>
> +void dcn201_opp_construct(struct dcn201_opp *oppn201,<br>
> + struct dc_context *ctx,<br>
> + uint32_t inst,<br>
> + const struct dcn201_opp_registers *regs,<br>
> + const struct dcn201_opp_shift *opp_shift,<br>
> + const struct dcn201_opp_mask *opp_mask)<br>
> +{<br>
> + oppn201->base.ctx = ctx;<br>
> + oppn201->base.inst = inst;<br>
> + oppn201->base.funcs = &dcn201_opp_funcs;<br>
> +<br>
> + oppn201->regs = regs;<br>
> + oppn201->opp_shift = opp_shift;<br>
> + oppn201->opp_mask = opp_mask;<br>
> +}<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_opp.h b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_opp.h<br>
> new file mode 100644<br>
> index 0000000..aca389ec<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_opp.h<br>
> @@ -0,0 +1,74 @@<br>
> +/* Copyright 2012-15 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +<br>
> +#ifndef __DC_OPP_DCN201_H__<br>
> +#define __DC_OPP_DCN201_H__<br>
> +<br>
> +#include "dcn20/dcn20_opp.h"<br>
> +<br>
> +#define TO_DCN201_OPP(opp)\<br>
> + container_of(opp, struct dcn201_opp, base)<br>
> +<br>
> +#define OPP_SF(reg_name, field_name, post_fix)\<br>
> + .field_name = reg_name ## __ ## field_name ## post_fix<br>
> +<br>
> +#define OPP_REG_LIST_DCN201(id) \<br>
> + OPP_REG_LIST_DCN10(id), \<br>
> + OPP_DPG_REG_LIST(id), \<br>
> + SRI(FMT_422_CONTROL, FMT, id)<br>
> +<br>
> +#define OPP_MASK_SH_LIST_DCN201(mask_sh) \<br>
> + OPP_MASK_SH_LIST_DCN20(mask_sh)<br>
> +<br>
> +#define OPP_DCN201_REG_FIELD_LIST(type) \<br>
> + OPP_DCN20_REG_FIELD_LIST(type);<br>
> +<br>
> +struct dcn201_opp_shift {<br>
> + OPP_DCN201_REG_FIELD_LIST(uint8_t);<br>
> +};<br>
> +<br>
> +struct dcn201_opp_mask {<br>
> + OPP_DCN201_REG_FIELD_LIST(uint32_t);<br>
> +};<br>
> +<br>
> +struct dcn201_opp_registers {<br>
> + OPP_REG_VARIABLE_LIST_DCN2_0;<br>
> +};<br>
> +<br>
> +struct dcn201_opp {<br>
> + struct output_pixel_processor base;<br>
> + const struct dcn201_opp_registers *regs;<br>
> + const struct dcn201_opp_shift *opp_shift;<br>
> + const struct dcn201_opp_mask *opp_mask;<br>
> + bool is_write_to_ram_a_safe;<br>
> +};<br>
> +<br>
> +void dcn201_opp_construct(struct dcn201_opp *oppn201,<br>
> + struct dc_context *ctx,<br>
> + uint32_t inst,<br>
> + const struct dcn201_opp_registers *regs,<br>
> + const struct dcn201_opp_shift *opp_shift,<br>
> + const struct dcn201_opp_mask *opp_mask);<br>
> +<br>
> +#endif<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_optc.c b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_optc.c<br>
> new file mode 100644<br>
> index 0000000..730875d<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_optc.c<br>
> @@ -0,0 +1,203 @@<br>
> +/*<br>
> + * Copyright 2012-15 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +<br>
> +#include "reg_helper.h"<br>
> +#include "dcn201_optc.h"<br>
> +#include "dcn10/dcn10_optc.h"<br>
> +#include "dc.h"<br>
> +<br>
> +#define REG(reg)\<br>
> + optc1->tg_regs->reg<br>
> +<br>
> +#define CTX \<br>
> + optc1->base.ctx<br>
> +<br>
> +#undef FN<br>
> +#define FN(reg_name, field_name) \<br>
> + optc1->tg_shift->field_name, optc1->tg_mask->field_name<br>
> +<br>
> +/*TEMP: Need to figure out inheritance model here.*/<br>
> +bool optc201_is_two_pixels_per_containter(const struct dc_crtc_timing *timing)<br>
> +{<br>
> + return optc1_is_two_pixels_per_containter(timing);<br>
> +}<br>
> +<br>
> +static void optc201_triplebuffer_lock(struct timing_generator *optc)<br>
> +{<br>
> + struct optc *optc1 = DCN10TG_FROM_TG(optc);<br>
> +<br>
> + REG_SET(OTG_GLOBAL_CONTROL0, 0,<br>
> + OTG_MASTER_UPDATE_LOCK_SEL, optc->inst);<br>
> + REG_SET(OTG_VUPDATE_KEEPOUT, 0,<br>
> + OTG_MASTER_UPDATE_LOCK_VUPDATE_KEEPOUT_EN, 1);<br>
> + REG_SET(OTG_MASTER_UPDATE_LOCK, 0,<br>
> + OTG_MASTER_UPDATE_LOCK, 1);<br>
> +<br>
> + if (optc->ctx->dce_environment != DCE_ENV_FPGA_MAXIMUS)<br>
> + REG_WAIT(OTG_MASTER_UPDATE_LOCK,<br>
> + UPDATE_LOCK_STATUS, 1,<br>
> + 1, 10);<br>
> +}<br>
> +<br>
> +static void optc201_triplebuffer_unlock(struct timing_generator *optc)<br>
> +{<br>
> + struct optc *optc1 = DCN10TG_FROM_TG(optc);<br>
> +<br>
> + REG_SET(OTG_MASTER_UPDATE_LOCK, 0,<br>
> + OTG_MASTER_UPDATE_LOCK, 0);<br>
> + REG_SET(OTG_VUPDATE_KEEPOUT, 0,<br>
> + OTG_MASTER_UPDATE_LOCK_VUPDATE_KEEPOUT_EN, 0);<br>
> +<br>
> +}<br>
> +<br>
> +static bool optc201_validate_timing(<br>
> + struct timing_generator *optc,<br>
> + const struct dc_crtc_timing *timing)<br>
> +{<br>
> + uint32_t v_blank;<br>
> + uint32_t h_blank;<br>
> + uint32_t min_v_blank;<br>
> + struct optc *optc1 = DCN10TG_FROM_TG(optc);<br>
> +<br>
> + ASSERT(timing != NULL);<br>
> +<br>
> + v_blank = (timing->v_total - timing->v_addressable -<br>
> + timing->v_border_top - timing->v_border_bottom);<br>
> +<br>
> + h_blank = (timing->h_total - timing->h_addressable -<br>
> + timing->h_border_right -<br>
> + timing->h_border_left);<br>
> +<br>
> + if (timing->timing_3d_format != TIMING_3D_FORMAT_NONE &&<br>
> + timing->timing_3d_format != TIMING_3D_FORMAT_HW_FRAME_PACKING &&<br>
> + timing->timing_3d_format != TIMING_3D_FORMAT_TOP_AND_BOTTOM &&<br>
> + timing->timing_3d_format != TIMING_3D_FORMAT_SIDE_BY_SIDE &&<br>
> + timing->timing_3d_format != TIMING_3D_FORMAT_FRAME_ALTERNATE &&<br>
> + timing->timing_3d_format != TIMING_3D_FORMAT_INBAND_FA)<br>
> + return false;<br>
> +<br>
> + /* Check maximum number of pixels supported by Timing Generator<br>
> + * (Currently will never fail, in order to fail needs display which<br>
> + * needs more than 8192 horizontal and<br>
> + * more than 8192 vertical total pixels)<br>
> + */<br>
> + if (timing->h_total > optc1->max_h_total ||<br>
> + timing->v_total > optc1->max_v_total)<br>
> + return false;<br>
> +<br>
> + if (h_blank < optc1->min_h_blank)<br>
> + return false;<br>
> +<br>
> + if (timing->h_sync_width < optc1->min_h_sync_width ||<br>
> + timing->v_sync_width < optc1->min_v_sync_width)<br>
> + return false;<br>
> +<br>
> + min_v_blank = timing->flags.INTERLACE?optc1->min_v_blank_interlace:optc1->min_v_blank;<br>
> +<br>
> + if (v_blank < min_v_blank)<br>
> + return false;<br>
> +<br>
> + return true;<br>
> +<br>
> +}<br>
> +<br>
> +static void optc201_get_optc_source(struct timing_generator *optc,<br>
> + uint32_t *num_of_src_opp,<br>
> + uint32_t *src_opp_id_0,<br>
> + uint32_t *src_opp_id_1)<br>
> +{<br>
> + struct optc *optc1 = DCN10TG_FROM_TG(optc);<br>
> +<br>
> + REG_GET(OPTC_DATA_SOURCE_SELECT,<br>
> + OPTC_SEG0_SRC_SEL, src_opp_id_0);<br>
> +<br>
> + *num_of_src_opp = 1;<br>
> +}<br>
> +<br>
> +static struct timing_generator_funcs dcn201_tg_funcs = {<br>
> + .validate_timing = optc201_validate_timing,<br>
> + .program_timing = optc1_program_timing,<br>
> + .setup_vertical_interrupt0 = optc1_setup_vertical_interrupt0,<br>
> + .setup_vertical_interrupt1 = optc1_setup_vertical_interrupt1,<br>
> + .setup_vertical_interrupt2 = optc1_setup_vertical_interrupt2,<br>
> + .program_global_sync = optc1_program_global_sync,<br>
> + .enable_crtc = optc2_enable_crtc,<br>
> + .disable_crtc = optc1_disable_crtc,<br>
> + /* used by enable_timing_synchronization. Not need for FPGA */<br>
> + .is_counter_moving = optc1_is_counter_moving,<br>
> + .get_position = optc1_get_position,<br>
> + .get_frame_count = optc1_get_vblank_counter,<br>
> + .get_scanoutpos = optc1_get_crtc_scanoutpos,<br>
> + .get_otg_active_size = optc1_get_otg_active_size,<br>
> + .set_early_control = optc1_set_early_control,<br>
> + /* used by enable_timing_synchronization. Not need for FPGA */<br>
> + .wait_for_state = optc1_wait_for_state,<br>
> + .set_blank = optc1_set_blank,<br>
> + .is_blanked = optc1_is_blanked,<br>
> + .set_blank_color = optc1_program_blank_color,<br>
> + .did_triggered_reset_occur = optc1_did_triggered_reset_occur,<br>
> + .enable_reset_trigger = optc1_enable_reset_trigger,<br>
> + .enable_crtc_reset = optc1_enable_crtc_reset,<br>
> + .disable_reset_trigger = optc1_disable_reset_trigger,<br>
> + .triplebuffer_lock = optc201_triplebuffer_lock,<br>
> + .triplebuffer_unlock = optc201_triplebuffer_unlock,<br>
> + .lock = optc1_lock,<br>
> + .unlock = optc1_unlock,<br>
> + .enable_optc_clock = optc1_enable_optc_clock,<br>
> + .set_drr = optc1_set_drr,<br>
> + .get_last_used_drr_vtotal = NULL,<br>
> + .set_vtotal_min_max = optc1_set_vtotal_min_max,<br>
> + .set_static_screen_control = optc1_set_static_screen_control,<br>
> + .program_stereo = optc1_program_stereo,<br>
> + .is_stereo_left_eye = optc1_is_stereo_left_eye,<br>
> + .set_blank_data_double_buffer = optc1_set_blank_data_double_buffer,<br>
> + .tg_init = optc1_tg_init,<br>
> + .is_tg_enabled = optc1_is_tg_enabled,<br>
> + .is_optc_underflow_occurred = optc1_is_optc_underflow_occurred,<br>
> + .clear_optc_underflow = optc1_clear_optc_underflow,<br>
> + .get_crc = optc1_get_crc,<br>
> + .configure_crc = optc2_configure_crc,<br>
> + .set_dsc_config = optc2_set_dsc_config,<br>
> + .set_dwb_source = NULL,<br>
> + .get_optc_source = optc201_get_optc_source,<br>
> + .set_vtg_params = optc1_set_vtg_params,<br>
> + .program_manual_trigger = optc2_program_manual_trigger,<br>
> + .setup_manual_trigger = optc2_setup_manual_trigger,<br>
> + .get_hw_timing = optc1_get_hw_timing,<br>
> +};<br>
> +<br>
> +void dcn201_timing_generator_init(struct optc *optc1)<br>
> +{<br>
> + optc1->base.funcs = &dcn201_tg_funcs;<br>
> +<br>
> + optc1->max_h_total = optc1->tg_mask->OTG_H_TOTAL + 1;<br>
> + optc1->max_v_total = optc1->tg_mask->OTG_V_TOTAL + 1;<br>
> +<br>
> + optc1->min_h_blank = 32;<br>
> + optc1->min_v_blank = 3;<br>
> + optc1->min_v_blank_interlace = 5;<br>
> + optc1->min_h_sync_width = 8;<br>
> + optc1->min_v_sync_width = 1;<br>
> +}<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_optc.h b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_optc.h<br>
> new file mode 100644<br>
> index 0000000..e9545b7<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_optc.h<br>
> @@ -0,0 +1,74 @@<br>
> +/*<br>
> + * Copyright 2012-15 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +<br>
> +#ifndef __DC_OPTC_DCN201_H__<br>
> +#define __DC_OPTC_DCN201_H__<br>
> +<br>
> +#include "dcn20/dcn20_optc.h"<br>
> +<br>
> +#define TG_COMMON_REG_LIST_DCN201(inst) \<br>
> + TG_COMMON_REG_LIST_DCN(inst),\<br>
> + SRI(OTG_GLOBAL_CONTROL1, OTG, inst),\<br>
> + SRI(OTG_GLOBAL_CONTROL2, OTG, inst),\<br>
> + SRI(OTG_GSL_WINDOW_X, OTG, inst),\<br>
> + SRI(OTG_GSL_WINDOW_Y, OTG, inst),\<br>
> + SRI(OTG_VUPDATE_KEEPOUT, OTG, inst),\<br>
> + SRI(OTG_DSC_START_POSITION, OTG, inst),\<br>
> + SRI(OPTC_DATA_FORMAT_CONTROL, ODM, inst),\<br>
> + SRI(OPTC_BYTES_PER_PIXEL, ODM, inst),\<br>
> + SRI(OPTC_WIDTH_CONTROL, ODM, inst),\<br>
> + SR(DWB_SOURCE_SELECT)<br>
> +<br>
> +#define TG_COMMON_MASK_SH_LIST_DCN201(mask_sh)\<br>
> + TG_COMMON_MASK_SH_LIST_DCN(mask_sh),\<br>
> + SF(OTG0_OTG_GLOBAL_CONTROL1, MASTER_UPDATE_LOCK_DB_X, mask_sh),\<br>
> + SF(OTG0_OTG_GLOBAL_CONTROL1, MASTER_UPDATE_LOCK_DB_Y, mask_sh),\<br>
> + SF(OTG0_OTG_GLOBAL_CONTROL1, MASTER_UPDATE_LOCK_DB_EN, mask_sh),\<br>
> + SF(OTG0_OTG_GLOBAL_CONTROL2, GLOBAL_UPDATE_LOCK_EN, mask_sh),\<br>
> + SF(OTG0_OTG_DOUBLE_BUFFER_CONTROL, OTG_RANGE_TIMING_DBUF_UPDATE_MODE, mask_sh),\<br>
> + SF(OTG0_OTG_GSL_WINDOW_X, OTG_GSL_WINDOW_START_X, mask_sh),\<br>
> + SF(OTG0_OTG_GSL_WINDOW_X, OTG_GSL_WINDOW_END_X, mask_sh), \<br>
> + SF(OTG0_OTG_GSL_WINDOW_Y, OTG_GSL_WINDOW_START_Y, mask_sh),\<br>
> + SF(OTG0_OTG_GSL_WINDOW_Y, OTG_GSL_WINDOW_END_Y, mask_sh),\<br>
> + SF(OTG0_OTG_VUPDATE_KEEPOUT, OTG_MASTER_UPDATE_LOCK_VUPDATE_KEEPOUT_EN, mask_sh), \<br>
> + SF(OTG0_OTG_VUPDATE_KEEPOUT, MASTER_UPDATE_LOCK_VUPDATE_KEEPOUT_START_OFFSET, mask_sh), \<br>
> + SF(OTG0_OTG_VUPDATE_KEEPOUT, MASTER_UPDATE_LOCK_VUPDATE_KEEPOUT_END_OFFSET, mask_sh), \<br>
> + SF(OTG0_OTG_GSL_CONTROL, OTG_GSL_MASTER_MODE, mask_sh), \<br>
> + SF(OTG0_OTG_GSL_CONTROL, OTG_MASTER_UPDATE_LOCK_GSL_EN, mask_sh), \<br>
> + SF(OTG0_OTG_DSC_START_POSITION, OTG_DSC_START_POSITION_X, mask_sh), \<br>
> + SF(OTG0_OTG_DSC_START_POSITION, OTG_DSC_START_POSITION_LINE_NUM, mask_sh),\<br>
> + SF(ODM0_OPTC_DATA_SOURCE_SELECT, OPTC_SEG0_SRC_SEL, mask_sh),\<br>
> + SF(ODM0_OPTC_DATA_FORMAT_CONTROL, OPTC_DSC_MODE, mask_sh),\<br>
> + SF(ODM0_OPTC_BYTES_PER_PIXEL, OPTC_DSC_BYTES_PER_PIXEL, mask_sh),\<br>
> + SF(ODM0_OPTC_WIDTH_CONTROL, OPTC_DSC_SLICE_WIDTH, mask_sh),\<br>
> + SF(DWB_SOURCE_SELECT, OPTC_DWB0_SOURCE_SELECT, mask_sh),\<br>
> + SF(DWB_SOURCE_SELECT, OPTC_DWB1_SOURCE_SELECT, mask_sh),\<br>
> + SF(DWB_SOURCE_SELECT, OPTC_DWB1_SOURCE_SELECT, mask_sh)<br>
> +<br>
> +void dcn201_timing_generator_init(struct optc *optc);<br>
> +<br>
> +bool optc201_is_two_pixels_per_containter(const struct dc_crtc_timing *timing);<br>
> +<br>
> +#endif<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_resource.c b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_resource.c<br>
> new file mode 100644<br>
> index 0000000..aec276e<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_resource.c<br>
> @@ -0,0 +1,1307 @@<br>
> +/*<br>
> +* Copyright 2016 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +<br>
> +#include "dm_services.h"<br>
> +#include "dc.h"<br>
> +<br>
> +#include "dcn201_init.h"<br>
> +#include "dml/dcn2x/dcn2x.h"<br>
> +#include "resource.h"<br>
> +#include "include/irq_service_interface.h"<br>
> +#include "dcn201_resource.h"<br>
> +<br>
> +#include "dcn20/dcn20_resource.h"<br>
> +<br>
> +#include "dcn10/dcn10_hubp.h"<br>
> +#include "dcn10/dcn10_ipp.h"<br>
> +#include "dcn201_mpc.h"<br>
> +#include "dcn201_hubp.h"<br>
> +#include "irq/dcn201/irq_service_dcn201.h"<br>
> +#include "dcn201/dcn201_dpp.h"<br>
> +#include "dcn201/dcn201_hubbub.h"<br>
> +#include "dcn201_dccg.h"<br>
> +#include "dcn201_optc.h"<br>
> +#include "dcn201_hwseq.h"<br>
> +#include "dce110/dce110_hw_sequencer.h"<br>
> +#include "dcn201_opp.h"<br>
> +#include "dcn201/dcn201_link_encoder.h"<br>
> +#include "dcn20/dcn20_stream_encoder.h"<br>
> +#include "dce/dce_clock_source.h"<br>
> +#include "dce/dce_audio.h"<br>
> +#include "dce/dce_hwseq.h"<br>
> +#include "virtual/virtual_stream_encoder.h"<br>
> +#include "dce110/dce110_resource.h"<br>
> +#include "dce/dce_aux.h"<br>
> +#include "dce/dce_i2c.h"<br>
> +#include "dcn201_hubbub.h"<br>
> +#include "dcn10/dcn10_resource.h"<br>
> +<br>
> +#include "cyan_skillfish_ip_offset.h"<br>
> +<br>
> +#include "dcn/dcn_2_0_3_offset.h"<br>
> +#include "dcn/dcn_2_0_3_sh_mask.h"<br>
> +#include "dpcs/dpcs_2_0_3_offset.h"<br>
> +#include "dpcs/dpcs_2_0_3_sh_mask.h"<br>
> +<br>
> +#include "mmhub/mmhub_2_0_0_offset.h"<br>
> +#include "mmhub/mmhub_2_0_0_sh_mask.h"<br>
> +#include "nbio/nbio_7_4_offset.h"<br>
> +<br>
> +#include "reg_helper.h"<br>
> +<br>
> +#define MIN_DISP_CLK_KHZ 100000<br>
> +#define MIN_DPP_CLK_KHZ 100000<br>
> +<br>
> +struct _vcs_dpi_ip_params_st dcn201_ip = {<br>
> + .gpuvm_enable = 0,<br>
> + .hostvm_enable = 0,<br>
> + .gpuvm_max_page_table_levels = 4,<br>
> + .hostvm_max_page_table_levels = 4,<br>
> + .hostvm_cached_page_table_levels = 0,<br>
> + .pte_group_size_bytes = 2048,<br>
> + .rob_buffer_size_kbytes = 168,<br>
> + .det_buffer_size_kbytes = 164,<br>
> + .dpte_buffer_size_in_pte_reqs_luma = 84,<br>
> + .pde_proc_buffer_size_64k_reqs = 48,<br>
> + .dpp_output_buffer_pixels = 2560,<br>
> + .opp_output_buffer_lines = 1,<br>
> + .pixel_chunk_size_kbytes = 8,<br>
> + .pte_chunk_size_kbytes = 2,<br>
> + .meta_chunk_size_kbytes = 2,<br>
> + .writeback_chunk_size_kbytes = 2,<br>
> + .line_buffer_size_bits = 789504,<br>
> + .is_line_buffer_bpp_fixed = 0,<br>
> + .line_buffer_fixed_bpp = 0,<br>
> + .dcc_supported = true,<br>
> + .max_line_buffer_lines = 12,<br>
> + .writeback_luma_buffer_size_kbytes = 12,<br>
> + .writeback_chroma_buffer_size_kbytes = 8,<br>
> + .writeback_chroma_line_buffer_width_pixels = 4,<br>
> + .writeback_max_hscl_ratio = 1,<br>
> + .writeback_max_vscl_ratio = 1,<br>
> + .writeback_min_hscl_ratio = 1,<br>
> + .writeback_min_vscl_ratio = 1,<br>
> + .writeback_max_hscl_taps = 12,<br>
> + .writeback_max_vscl_taps = 12,<br>
> + .writeback_line_buffer_luma_buffer_size = 0,<br>
> + .writeback_line_buffer_chroma_buffer_size = 9600,<br>
> + .cursor_buffer_size = 8,<br>
> + .cursor_chunk_size = 2,<br>
> + .max_num_otg = 2,<br>
> + .max_num_dpp = 4,<br>
> + .max_num_wb = 0,<br>
> + .max_dchub_pscl_bw_pix_per_clk = 4,<br>
> + .max_pscl_lb_bw_pix_per_clk = 2,<br>
> + .max_lb_vscl_bw_pix_per_clk = 4,<br>
> + .max_vscl_hscl_bw_pix_per_clk = 4,<br>
> + .max_hscl_ratio = 8,<br>
> + .max_vscl_ratio = 8,<br>
> + .hscl_mults = 4,<br>
> + .vscl_mults = 4,<br>
> + .max_hscl_taps = 8,<br>
> + .max_vscl_taps = 8,<br>
> + .dispclk_ramp_margin_percent = 1,<br>
> + .underscan_factor = 1.10,<br>
> + .min_vblank_lines = 30,<br>
> + .dppclk_delay_subtotal = 77,<br>
> + .dppclk_delay_scl_lb_only = 16,<br>
> + .dppclk_delay_scl = 50,<br>
> + .dppclk_delay_cnvc_formatter = 8,<br>
> + .dppclk_delay_cnvc_cursor = 6,<br>
> + .dispclk_delay_subtotal = 87,<br>
> + .dcfclk_cstate_latency = 10,<br>
> + .max_inter_dcn_tile_repeaters = 8,<br>
> + .number_of_cursors = 1,<br>
> +};<br>
> +<br>
> +struct _vcs_dpi_soc_bounding_box_st dcn201_soc = {<br>
> + .clock_limits = {<br>
> + {<br>
> + .state = 0,<br>
> + .dscclk_mhz = 400.0,<br>
> + .dcfclk_mhz = 1000.0,<br>
> + .fabricclk_mhz = 200.0,<br>
> + .dispclk_mhz = 300.0,<br>
> + .dppclk_mhz = 300.0,<br>
> + .phyclk_mhz = 810.0,<br>
> + .socclk_mhz = 1254.0,<br>
> + .dram_speed_mts = 2000.0,<br>
> + },<br>
> + {<br>
> + .state = 1,<br>
> + .dscclk_mhz = 400.0,<br>
> + .dcfclk_mhz = 1000.0,<br>
> + .fabricclk_mhz = 250.0,<br>
> + .dispclk_mhz = 1200.0,<br>
> + .dppclk_mhz = 1200.0,<br>
> + .phyclk_mhz = 810.0,<br>
> + .socclk_mhz = 1254.0,<br>
> + .dram_speed_mts = 3600.0,<br>
> + },<br>
> + {<br>
> + .state = 2,<br>
> + .dscclk_mhz = 400.0,<br>
> + .dcfclk_mhz = 1000.0,<br>
> + .fabricclk_mhz = 750.0,<br>
> + .dispclk_mhz = 1200.0,<br>
> + .dppclk_mhz = 1200.0,<br>
> + .phyclk_mhz = 810.0,<br>
> + .socclk_mhz = 1254.0,<br>
> + .dram_speed_mts = 6800.0,<br>
> + },<br>
> + {<br>
> + .state = 3,<br>
> + .dscclk_mhz = 400.0,<br>
> + .dcfclk_mhz = 1000.0,<br>
> + .fabricclk_mhz = 250.0,<br>
> + .dispclk_mhz = 1200.0,<br>
> + .dppclk_mhz = 1200.0,<br>
> + .phyclk_mhz = 810.0,<br>
> + .socclk_mhz = 1254.0,<br>
> + .dram_speed_mts = 14000.0,<br>
> + },<br>
> + {<br>
> + .state = 4,<br>
> + .dscclk_mhz = 400.0,<br>
> + .dcfclk_mhz = 1000.0,<br>
> + .fabricclk_mhz = 750.0,<br>
> + .dispclk_mhz = 1200.0,<br>
> + .dppclk_mhz = 1200.0,<br>
> + .phyclk_mhz = 810.0,<br>
> + .socclk_mhz = 1254.0,<br>
> + .dram_speed_mts = 14000.0,<br>
> + }<br>
> + },<br>
> + .num_states = 4,<br>
> + .sr_exit_time_us = 9.0,<br>
> + .sr_enter_plus_exit_time_us = 11.0,<br>
> + .urgent_latency_us = 4.0,<br>
> + .urgent_latency_pixel_data_only_us = 4.0,<br>
> + .urgent_latency_pixel_mixed_with_vm_data_us = 4.0,<br>
> + .urgent_latency_vm_data_only_us = 4.0,<br>
> + .urgent_out_of_order_return_per_channel_pixel_only_bytes = 256,<br>
> + .urgent_out_of_order_return_per_channel_pixel_and_vm_bytes = 256,<br>
> + .urgent_out_of_order_return_per_channel_vm_only_bytes = 256,<br>
> + .pct_ideal_dram_sdp_bw_after_urgent_pixel_only = 80.0,<br>
> + .pct_ideal_dram_sdp_bw_after_urgent_pixel_and_vm = 80.0,<br>
> + .pct_ideal_dram_sdp_bw_after_urgent_vm_only = 80.0,<br>
> + .max_avg_sdp_bw_use_normal_percent = 80.0,<br>
> + .max_avg_dram_bw_use_normal_percent = 69.0,<br>
> + .writeback_latency_us = 12.0,<br>
> + .ideal_dram_bw_after_urgent_percent = 80.0,<br>
> + .max_request_size_bytes = 256,<br>
> + .dram_channel_width_bytes = 2,<br>
> + .fabric_datapath_to_dcn_data_return_bytes = 64,<br>
> + .dcn_downspread_percent = 0.3,<br>
> + .downspread_percent = 0.3,<br>
> + .dram_page_open_time_ns = 50.0,<br>
> + .dram_rw_turnaround_time_ns = 17.5,<br>
> + .dram_return_buffer_per_channel_bytes = 8192,<br>
> + .round_trip_ping_latency_dcfclk_cycles = 128,<br>
> + .urgent_out_of_order_return_per_channel_bytes = 256,<br>
> + .channel_interleave_bytes = 256,<br>
> + .num_banks = 8,<br>
> + .num_chans = 16,<br>
> + .vmm_page_size_bytes = 4096,<br>
> + .dram_clock_change_latency_us = 250.0,<br>
> + .writeback_dram_clock_change_latency_us = 23.0,<br>
> + .return_bus_width_bytes = 64,<br>
> + .dispclk_dppclk_vco_speed_mhz = 3000,<br>
> + .use_urgent_burst_bw = 0,<br>
> +};<br>
> +<br>
> +enum dcn20_clk_src_array_id {<br>
> + DCN20_CLK_SRC_PLL0,<br>
> + DCN20_CLK_SRC_PLL1,<br>
> + DCN20_CLK_SRC_TOTAL_DCN201<br>
> +};<br>
> +<br>
> +/* begin *********************<br>
> + * macros to expend register list macro defined in HW object header file */<br>
> +<br>
> +/* DCN */<br>
> +<br>
> +#undef BASE_INNER<br>
> +#define BASE_INNER(seg) DMU_BASE__INST0_SEG ## seg<br>
> +<br>
> +#define BASE(seg) BASE_INNER(seg)<br>
> +<br>
> +#define SR(reg_name)\<br>
> + .reg_name = BASE(mm ## reg_name ## _BASE_IDX) + \<br>
> + mm ## reg_name<br>
> +<br>
> +#define SRI(reg_name, block, id)\<br>
> + .reg_name = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \<br>
> + mm ## block ## id ## _ ## reg_name<br>
> +<br>
> +#define SRIR(var_name, reg_name, block, id)\<br>
> + .var_name = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \<br>
> + mm ## block ## id ## _ ## reg_name<br>
> +<br>
> +#define SRII(reg_name, block, id)\<br>
> + .reg_name[id] = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \<br>
> + mm ## block ## id ## _ ## reg_name<br>
> +<br>
> +#define SRI_IX(reg_name, block, id)\<br>
> + .reg_name = ix ## block ## id ## _ ## reg_name<br>
> +<br>
> +#define DCCG_SRII(reg_name, block, id)\<br>
> + .block ## _ ## reg_name[id] = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \<br>
> + mm ## block ## id ## _ ## reg_name<br>
> +<br>
> +#define VUPDATE_SRII(reg_name, block, id)\<br>
> + .reg_name[id] = BASE(mm ## reg_name ## _ ## block ## id ## _BASE_IDX) + \<br>
> + mm ## reg_name ## _ ## block ## id<br>
> +<br>
> +/* NBIO */<br>
> +#define NBIO_BASE_INNER(seg) \<br>
> + NBIO_BASE__INST0_SEG ## seg<br>
> +<br>
> +#define NBIO_BASE(seg) \<br>
> + NBIO_BASE_INNER(seg)<br>
> +<br>
> +#define NBIO_SR(reg_name)\<br>
> + .reg_name = NBIO_BASE(mm ## reg_name ## _BASE_IDX) + \<br>
> + mm ## reg_name<br>
> +<br>
> +/* MMHUB */<br>
> +#define MMHUB_BASE_INNER(seg) \<br>
> + MMHUB_BASE__INST0_SEG ## seg<br>
> +<br>
> +#define MMHUB_BASE(seg) \<br>
> + MMHUB_BASE_INNER(seg)<br>
> +<br>
> +#define MMHUB_SR(reg_name)\<br>
> + .reg_name = MMHUB_BASE(mmMM ## reg_name ## _BASE_IDX) + \<br>
> + mmMM ## reg_name<br>
> +<br>
> +static const struct bios_registers bios_regs = {<br>
> + NBIO_SR(BIOS_SCRATCH_3),<br>
> + NBIO_SR(BIOS_SCRATCH_6)<br>
> +};<br>
> +<br>
> +#define clk_src_regs(index, pllid)\<br>
> +[index] = {\<br>
> + CS_COMMON_REG_LIST_DCN201(index, pllid),\<br>
> +}<br>
> +<br>
> +static const struct dce110_clk_src_regs clk_src_regs[] = {<br>
> + clk_src_regs(0, A),<br>
> + clk_src_regs(1, B)<br>
> +};<br>
> +<br>
> +static const struct dce110_clk_src_shift cs_shift = {<br>
> + CS_COMMON_MASK_SH_LIST_DCN2_0(__SHIFT)<br>
> +};<br>
> +<br>
> +static const struct dce110_clk_src_mask cs_mask = {<br>
> + CS_COMMON_MASK_SH_LIST_DCN2_0(_MASK)<br>
> +};<br>
> +<br>
> +#define audio_regs(id)\<br>
> +[id] = {\<br>
> + AUD_COMMON_REG_LIST(id)\<br>
> +}<br>
> +<br>
> +static const struct dce_audio_registers audio_regs[] = {<br>
> + audio_regs(0),<br>
> + audio_regs(1),<br>
> +};<br>
> +<br>
> +#define DCE120_AUD_COMMON_MASK_SH_LIST(mask_sh)\<br>
> + SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_INDEX, AZALIA_ENDPOINT_REG_INDEX, mask_sh),\<br>
> + SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_DATA, AZALIA_ENDPOINT_REG_DATA, mask_sh),\<br>
> + AUD_COMMON_MASK_SH_LIST_BASE(mask_sh)<br>
> +<br>
> +static const struct dce_audio_shift audio_shift = {<br>
> + DCE120_AUD_COMMON_MASK_SH_LIST(__SHIFT)<br>
> +};<br>
> +<br>
> +static const struct dce_audio_mask audio_mask = {<br>
> + DCE120_AUD_COMMON_MASK_SH_LIST(_MASK)<br>
> +};<br>
> +<br>
> +#define stream_enc_regs(id)\<br>
> +[id] = {\<br>
> + SE_DCN2_REG_LIST(id)\<br>
> +}<br>
> +<br>
> +static const struct dcn10_stream_enc_registers stream_enc_regs[] = {<br>
> + stream_enc_regs(0),<br>
> + stream_enc_regs(1)<br>
> +};<br>
> +<br>
> +static const struct dcn10_stream_encoder_shift se_shift = {<br>
> + SE_COMMON_MASK_SH_LIST_DCN20(__SHIFT)<br>
> +};<br>
> +<br>
> +static const struct dcn10_stream_encoder_mask se_mask = {<br>
> + SE_COMMON_MASK_SH_LIST_DCN20(_MASK)<br>
> +};<br>
> +<br>
> +static const struct dce110_aux_registers_shift aux_shift = {<br>
> + DCN_AUX_MASK_SH_LIST(__SHIFT)<br>
> +};<br>
> +<br>
> +static const struct dce110_aux_registers_mask aux_mask = {<br>
> + DCN_AUX_MASK_SH_LIST(_MASK)<br>
> +};<br>
> +<br>
> +#define aux_regs(id)\<br>
> +[id] = {\<br>
> + DCN2_AUX_REG_LIST(id)\<br>
> +}<br>
> +<br>
> +static const struct dcn10_link_enc_aux_registers link_enc_aux_regs[] = {<br>
> + aux_regs(0),<br>
> + aux_regs(1),<br>
> +};<br>
> +<br>
> +#define hpd_regs(id)\<br>
> +[id] = {\<br>
> + HPD_REG_LIST(id)\<br>
> +}<br>
> +<br>
> +static const struct dcn10_link_enc_hpd_registers link_enc_hpd_regs[] = {<br>
> + hpd_regs(0),<br>
> + hpd_regs(1),<br>
> +};<br>
> +<br>
> +#define link_regs(id, phyid)\<br>
> +[id] = {\<br>
> + LE_DCN_COMMON_REG_LIST(id), \<br>
> + UNIPHY_DCN2_REG_LIST(phyid) \<br>
> +}<br>
> +<br>
> +static const struct dcn10_link_enc_registers link_enc_regs[] = {<br>
> + link_regs(0, A),<br>
> + link_regs(1, B),<br>
> +};<br>
> +<br>
> +#define LINK_ENCODER_MASK_SH_LIST_DCN201(mask_sh)\<br>
> + LINK_ENCODER_MASK_SH_LIST_DCN20(mask_sh)<br>
> +<br>
> +static const struct dcn10_link_enc_shift le_shift = {<br>
> + LINK_ENCODER_MASK_SH_LIST_DCN201(__SHIFT)<br>
> +};<br>
> +<br>
> +static const struct dcn10_link_enc_mask le_mask = {<br>
> + LINK_ENCODER_MASK_SH_LIST_DCN201(_MASK)<br>
> +};<br>
> +<br>
> +#define ipp_regs(id)\<br>
> +[id] = {\<br>
> + IPP_REG_LIST_DCN201(id),\<br>
> +}<br>
> +<br>
> +static const struct dcn10_ipp_registers ipp_regs[] = {<br>
> + ipp_regs(0),<br>
> + ipp_regs(1),<br>
> + ipp_regs(2),<br>
> + ipp_regs(3),<br>
> +};<br>
> +<br>
> +static const struct dcn10_ipp_shift ipp_shift = {<br>
> + IPP_MASK_SH_LIST_DCN201(__SHIFT)<br>
> +};<br>
> +<br>
> +static const struct dcn10_ipp_mask ipp_mask = {<br>
> + IPP_MASK_SH_LIST_DCN201(_MASK)<br>
> +};<br>
> +<br>
> +#define opp_regs(id)\<br>
> +[id] = {\<br>
> + OPP_REG_LIST_DCN201(id),\<br>
> +}<br>
> +<br>
> +static const struct dcn201_opp_registers opp_regs[] = {<br>
> + opp_regs(0),<br>
> + opp_regs(1),<br>
> +};<br>
> +<br>
> +static const struct dcn201_opp_shift opp_shift = {<br>
> + OPP_MASK_SH_LIST_DCN201(__SHIFT)<br>
> +};<br>
> +<br>
> +static const struct dcn201_opp_mask opp_mask = {<br>
> + OPP_MASK_SH_LIST_DCN201(_MASK)<br>
> +};<br>
> +<br>
> +#define aux_engine_regs(id)\<br>
> +[id] = {\<br>
> + AUX_COMMON_REG_LIST0(id), \<br>
> + .AUX_RESET_MASK = 0 \<br>
> +}<br>
> +<br>
> +static const struct dce110_aux_registers aux_engine_regs[] = {<br>
> + aux_engine_regs(0),<br>
> + aux_engine_regs(1)<br>
> +};<br>
> +<br>
> +#define tf_regs(id)\<br>
> +[id] = {\<br>
> + TF_REG_LIST_DCN201(id),\<br>
> +}<br>
> +<br>
> +static const struct dcn201_dpp_registers tf_regs[] = {<br>
> + tf_regs(0),<br>
> + tf_regs(1),<br>
> + tf_regs(2),<br>
> + tf_regs(3),<br>
> +};<br>
> +<br>
> +static const struct dcn201_dpp_shift tf_shift = {<br>
> + TF_REG_LIST_SH_MASK_DCN201(__SHIFT)<br>
> +};<br>
> +<br>
> +static const struct dcn201_dpp_mask tf_mask = {<br>
> + TF_REG_LIST_SH_MASK_DCN201(_MASK)<br>
> +};<br>
> +<br>
> +static const struct dcn201_mpc_registers mpc_regs = {<br>
> + MPC_REG_LIST_DCN201(0),<br>
> + MPC_REG_LIST_DCN201(1),<br>
> + MPC_REG_LIST_DCN201(2),<br>
> + MPC_REG_LIST_DCN201(3),<br>
> + MPC_REG_LIST_DCN201(4),<br>
> + MPC_OUT_MUX_REG_LIST_DCN201(0),<br>
> + MPC_OUT_MUX_REG_LIST_DCN201(1),<br>
> +};<br>
> +<br>
> +static const struct dcn201_mpc_shift mpc_shift = {<br>
> + MPC_COMMON_MASK_SH_LIST_DCN201(__SHIFT)<br>
> +};<br>
> +<br>
> +static const struct dcn201_mpc_mask mpc_mask = {<br>
> + MPC_COMMON_MASK_SH_LIST_DCN201(_MASK)<br>
> +};<br>
> +<br>
> +#define tg_regs_dcn201(id)\<br>
> +[id] = {TG_COMMON_REG_LIST_DCN201(id)}<br>
> +<br>
> +static const struct dcn_optc_registers tg_regs[] = {<br>
> + tg_regs_dcn201(0),<br>
> + tg_regs_dcn201(1)<br>
> +};<br>
> +<br>
> +static const struct dcn_optc_shift tg_shift = {<br>
> + TG_COMMON_MASK_SH_LIST_DCN201(__SHIFT)<br>
> +};<br>
> +<br>
> +static const struct dcn_optc_mask tg_mask = {<br>
> + TG_COMMON_MASK_SH_LIST_DCN201(_MASK)<br>
> +};<br>
> +<br>
> +#define hubp_regsDCN201(id)\<br>
> +[id] = {\<br>
> + HUBP_REG_LIST_DCN201(id)\<br>
> +}<br>
> +<br>
> +static const struct dcn201_hubp_registers hubp_regs[] = {<br>
> + hubp_regsDCN201(0),<br>
> + hubp_regsDCN201(1),<br>
> + hubp_regsDCN201(2),<br>
> + hubp_regsDCN201(3)<br>
> +};<br>
> +<br>
> +static const struct dcn201_hubp_shift hubp_shift = {<br>
> + HUBP_MASK_SH_LIST_DCN201(__SHIFT)<br>
> +};<br>
> +<br>
> +static const struct dcn201_hubp_mask hubp_mask = {<br>
> + HUBP_MASK_SH_LIST_DCN201(_MASK)<br>
> +};<br>
> +<br>
> +static const struct dcn_hubbub_registers hubbub_reg = {<br>
> + HUBBUB_REG_LIST_DCN201(0)<br>
> +};<br>
> +<br>
> +static const struct dcn_hubbub_shift hubbub_shift = {<br>
> + HUBBUB_MASK_SH_LIST_DCN201(__SHIFT)<br>
> +};<br>
> +<br>
> +static const struct dcn_hubbub_mask hubbub_mask = {<br>
> + HUBBUB_MASK_SH_LIST_DCN201(_MASK)<br>
> +};<br>
> +<br>
> +<br>
> +static const struct dccg_registers dccg_regs = {<br>
> + DCCG_COMMON_REG_LIST_DCN_BASE()<br>
> +};<br>
> +<br>
> +static const struct dccg_shift dccg_shift = {<br>
> + DCCG_COMMON_MASK_SH_LIST_DCN_COMMON_BASE(__SHIFT)<br>
> +};<br>
> +<br>
> +static const struct dccg_mask dccg_mask = {<br>
> + DCCG_COMMON_MASK_SH_LIST_DCN_COMMON_BASE(_MASK)<br>
> +};<br>
> +<br>
> +static const struct resource_caps res_cap_dnc201 = {<br>
> + .num_timing_generator = 2,<br>
> + .num_opp = 2,<br>
> + .num_video_plane = 4,<br>
> + .num_audio = 2,<br>
> + .num_stream_encoder = 2,<br>
> + .num_pll = 2,<br>
> + .num_ddc = 2,<br>
> +};<br>
> +<br>
> +static const struct dc_plane_cap plane_cap = {<br>
> + .type = DC_PLANE_TYPE_DCN_UNIVERSAL,<br>
> + .blends_with_above = true,<br>
> + .blends_with_below = true,<br>
> + .per_pixel_alpha = true,<br>
> +<br>
> + .pixel_format_support = {<br>
> + .argb8888 = true,<br>
> + .nv12 = false,<br>
> + .fp16 = true,<br>
> + .p010 = false,<br>
> + },<br>
> +<br>
> + .max_upscale_factor = {<br>
> + .argb8888 = 16000,<br>
> + .nv12 = 16000,<br>
> + .fp16 = 1<br>
> + },<br>
> +<br>
> + .max_downscale_factor = {<br>
> + .argb8888 = 250,<br>
> + .nv12 = 250,<br>
> + .fp16 = 250<br>
> + },<br>
> + 64,<br>
> + 64<br>
> +};<br>
> +<br>
> +static const struct dc_debug_options debug_defaults_drv = {<br>
> + .disable_dmcu = true,<br>
> + .force_abm_enable = false,<br>
> + .timing_trace = false,<br>
> + .clock_trace = true,<br>
> + .disable_pplib_clock_request = true,<br>
> + .pipe_split_policy = MPC_SPLIT_AVOID,<br>
> + .force_single_disp_pipe_split = false,<br>
> + .disable_dcc = DCC_ENABLE,<br>
> + .vsr_support = true,<br>
> + .performance_trace = false,<br>
> + .az_endpoint_mute_only = true,<br>
> + .max_downscale_src_width = 3840,<br>
> + .disable_pplib_wm_range = true,<br>
> + .scl_reset_length10 = true,<br>
> + .sanity_checks = false,<br>
> + .underflow_assert_delay_us = 0xFFFFFFFF,<br>
> + .enable_tri_buf = false,<br>
> +};<br>
> +<br>
> +static void dcn201_dpp_destroy(struct dpp **dpp)<br>
> +{<br>
> + kfree(TO_DCN201_DPP(*dpp));<br>
> + *dpp = NULL;<br>
> +}<br>
> +<br>
> +static struct dpp *dcn201_dpp_create(<br>
> + struct dc_context *ctx,<br>
> + uint32_t inst)<br>
> +{<br>
> + struct dcn201_dpp *dpp =<br>
> + kzalloc(sizeof(struct dcn201_dpp), GFP_ATOMIC);<br>
> +<br>
> + if (!dpp)<br>
> + return NULL;<br>
> +<br>
> + if (dpp201_construct(dpp, ctx, inst,<br>
> + &tf_regs[inst], &tf_shift, &tf_mask))<br>
> + return &dpp->base;<br>
> +<br>
> + kfree(dpp);<br>
> + return NULL;<br>
> +}<br>
> +<br>
> +static struct input_pixel_processor *dcn201_ipp_create(<br>
> + struct dc_context *ctx, uint32_t inst)<br>
> +{<br>
> + struct dcn10_ipp *ipp =<br>
> + kzalloc(sizeof(struct dcn10_ipp), GFP_ATOMIC);<br>
> +<br>
> + if (!ipp) {<br>
> + return NULL;<br>
> + }<br>
> +<br>
> + dcn20_ipp_construct(ipp, ctx, inst,<br>
> + &ipp_regs[inst], &ipp_shift, &ipp_mask);<br>
> + return &ipp->base;<br>
> +}<br>
> +<br>
> +<br>
> +static struct output_pixel_processor *dcn201_opp_create(<br>
> + struct dc_context *ctx, uint32_t inst)<br>
> +{<br>
> + struct dcn201_opp *opp =<br>
> + kzalloc(sizeof(struct dcn201_opp), GFP_ATOMIC);<br>
> +<br>
> + if (!opp) {<br>
> + return NULL;<br>
> + }<br>
> +<br>
> + dcn201_opp_construct(opp, ctx, inst,<br>
> + &opp_regs[inst], &opp_shift, &opp_mask);<br>
> + return &opp->base;<br>
> +}<br>
> +<br>
> +struct dce_aux *dcn201_aux_engine_create(<br>
> + struct dc_context *ctx,<br>
> + uint32_t inst)<br>
> +{<br>
> + struct aux_engine_dce110 *aux_engine =<br>
> + kzalloc(sizeof(struct aux_engine_dce110), GFP_ATOMIC);<br>
> +<br>
> + if (!aux_engine)<br>
> + return NULL;<br>
> +<br>
> + dce110_aux_engine_construct(aux_engine, ctx, inst,<br>
> + SW_AUX_TIMEOUT_PERIOD_MULTIPLIER * AUX_TIMEOUT_PERIOD,<br>
> + &aux_engine_regs[inst],<br>
> + &aux_mask,<br>
> + &aux_shift,<br>
> + ctx->dc->caps.extended_aux_timeout_support);<br>
> +<br>
> + return &aux_engine->base;<br>
> +}<br>
> +#define i2c_inst_regs(id) { I2C_HW_ENGINE_COMMON_REG_LIST(id) }<br>
> +<br>
> +static const struct dce_i2c_registers i2c_hw_regs[] = {<br>
> + i2c_inst_regs(1),<br>
> + i2c_inst_regs(2),<br>
> +};<br>
> +<br>
> +static const struct dce_i2c_shift i2c_shifts = {<br>
> + I2C_COMMON_MASK_SH_LIST_DCN2(__SHIFT)<br>
> +};<br>
> +<br>
> +static const struct dce_i2c_mask i2c_masks = {<br>
> + I2C_COMMON_MASK_SH_LIST_DCN2(_MASK)<br>
> +};<br>
> +<br>
> +struct dce_i2c_hw *dcn201_i2c_hw_create(<br>
> + struct dc_context *ctx,<br>
> + uint32_t inst)<br>
> +{<br>
> + struct dce_i2c_hw *dce_i2c_hw =<br>
> + kzalloc(sizeof(struct dce_i2c_hw), GFP_ATOMIC);<br>
> +<br>
> + if (!dce_i2c_hw)<br>
> + return NULL;<br>
> +<br>
> + dcn2_i2c_hw_construct(dce_i2c_hw, ctx, inst,<br>
> + &i2c_hw_regs[inst], &i2c_shifts, &i2c_masks);<br>
> +<br>
> + return dce_i2c_hw;<br>
> +}<br>
> +<br>
> +static struct mpc *dcn201_mpc_create(struct dc_context *ctx, uint32_t num_mpcc)<br>
> +{<br>
> + struct dcn201_mpc *mpc201 = kzalloc(sizeof(struct dcn201_mpc),<br>
> + GFP_ATOMIC);<br>
> +<br>
> + if (!mpc201)<br>
> + return NULL;<br>
> +<br>
> + dcn201_mpc_construct(mpc201, ctx,<br>
> + &mpc_regs,<br>
> + &mpc_shift,<br>
> + &mpc_mask,<br>
> + num_mpcc);<br>
> +<br>
> + return &mpc201->base;<br>
> +}<br>
> +<br>
> +static struct hubbub *dcn201_hubbub_create(struct dc_context *ctx)<br>
> +{<br>
> + struct dcn20_hubbub *hubbub = kzalloc(sizeof(struct dcn20_hubbub),<br>
> + GFP_ATOMIC);<br>
> +<br>
> + if (!hubbub)<br>
> + return NULL;<br>
> +<br>
> + hubbub201_construct(hubbub, ctx,<br>
> + &hubbub_reg,<br>
> + &hubbub_shift,<br>
> + &hubbub_mask);<br>
> +<br>
> + return &hubbub->base;<br>
> +}<br>
> +<br>
> +static struct timing_generator *dcn201_timing_generator_create(<br>
> + struct dc_context *ctx,<br>
> + uint32_t instance)<br>
> +{<br>
> + struct optc *tgn10 =<br>
> + kzalloc(sizeof(struct optc), GFP_ATOMIC);<br>
> +<br>
> + if (!tgn10)<br>
> + return NULL;<br>
> +<br>
> + tgn10->base.inst = instance;<br>
> + tgn10->base.ctx = ctx;<br>
> +<br>
> + tgn10->tg_regs = &tg_regs[instance];<br>
> + tgn10->tg_shift = &tg_shift;<br>
> + tgn10->tg_mask = &tg_mask;<br>
> +<br>
> + dcn201_timing_generator_init(tgn10);<br>
> +<br>
> + return &tgn10->base;<br>
> +}<br>
> +<br>
> +static const struct encoder_feature_support link_enc_feature = {<br>
> + .max_hdmi_deep_color = COLOR_DEPTH_121212,<br>
> + .max_hdmi_pixel_clock = 600000,<br>
> + .hdmi_ycbcr420_supported = true,<br>
> + .dp_ycbcr420_supported = true,<br>
> + .fec_supported = true,<br>
> + .flags.bits.IS_HBR2_CAPABLE = true,<br>
> + .flags.bits.IS_HBR3_CAPABLE = true,<br>
> + .flags.bits.IS_TPS3_CAPABLE = true,<br>
> + .flags.bits.IS_TPS4_CAPABLE = true<br>
> +};<br>
> +<br>
> +struct link_encoder *dcn201_link_encoder_create(<br>
> + const struct encoder_init_data *enc_init_data)<br>
> +{<br>
> + struct dcn20_link_encoder *enc20 =<br>
> + kzalloc(sizeof(struct dcn20_link_encoder), GFP_ATOMIC);<br>
> + struct dcn10_link_encoder *enc10 = &enc20->enc10;<br>
> +<br>
> + if (!enc20)<br>
> + return NULL;<br>
> +<br>
> + dcn201_link_encoder_construct(enc20,<br>
> + enc_init_data,<br>
> + &link_enc_feature,<br>
> + &link_enc_regs[enc_init_data->transmitter],<br>
> + &link_enc_aux_regs[enc_init_data->channel - 1],<br>
> + &link_enc_hpd_regs[enc_init_data->hpd_source],<br>
> + &le_shift,<br>
> + &le_mask);<br>
> +<br>
> + return &enc10->base;<br>
> +}<br>
> +<br>
> +struct clock_source *dcn201_clock_source_create(<br>
> + struct dc_context *ctx,<br>
> + struct dc_bios *bios,<br>
> + enum clock_source_id id,<br>
> + const struct dce110_clk_src_regs *regs,<br>
> + bool dp_clk_src)<br>
> +{<br>
> + struct dce110_clk_src *clk_src =<br>
> + kzalloc(sizeof(struct dce110_clk_src), GFP_ATOMIC);<br>
> +<br>
> + if (!clk_src)<br>
> + return NULL;<br>
> +<br>
> + if (dce112_clk_src_construct(clk_src, ctx, bios, id,<br>
> + regs, &cs_shift, &cs_mask)) {<br>
> + clk_src->base.dp_clk_src = dp_clk_src;<br>
> + return &clk_src->base;<br>
> + }<br>
> + kfree(clk_src);<br>
> + return NULL;<br>
> +}<br>
> +<br>
> +static void read_dce_straps(<br>
> + struct dc_context *ctx,<br>
> + struct resource_straps *straps)<br>
> +{<br>
> + generic_reg_get(ctx, mmDC_PINSTRAPS + BASE(mmDC_PINSTRAPS_BASE_IDX),<br>
> +<br>
> + FN(DC_PINSTRAPS, DC_PINSTRAPS_AUDIO), &straps->dc_pinstraps_audio);<br>
> +}<br>
> +<br>
> +static struct audio *dcn201_create_audio(<br>
> + struct dc_context *ctx, unsigned int inst)<br>
> +{<br>
> + return dce_audio_create(ctx, inst,<br>
> + &audio_regs[inst], &audio_shift, &audio_mask);<br>
> +}<br>
> +<br>
> +static struct stream_encoder *dcn201_stream_encoder_create(<br>
> + enum engine_id eng_id,<br>
> + struct dc_context *ctx)<br>
> +{<br>
> + struct dcn10_stream_encoder *enc1 =<br>
> + kzalloc(sizeof(struct dcn10_stream_encoder), GFP_ATOMIC);<br>
> +<br>
> + if (!enc1)<br>
> + return NULL;<br>
> +<br>
> + dcn20_stream_encoder_construct(enc1, ctx, ctx->dc_bios, eng_id,<br>
> + &stream_enc_regs[eng_id],<br>
> + &se_shift, &se_mask);<br>
> +<br>
> + return &enc1->base;<br>
> +}<br>
> +<br>
> +static const struct dce_hwseq_registers hwseq_reg = {<br>
> + HWSEQ_DCN201_REG_LIST()<br>
> +};<br>
> +<br>
> +static const struct dce_hwseq_shift hwseq_shift = {<br>
> + HWSEQ_DCN201_MASK_SH_LIST(__SHIFT)<br>
> +};<br>
> +<br>
> +static const struct dce_hwseq_mask hwseq_mask = {<br>
> + HWSEQ_DCN201_MASK_SH_LIST(_MASK)<br>
> +};<br>
> +<br>
> +static struct dce_hwseq *dcn201_hwseq_create(<br>
> + struct dc_context *ctx)<br>
> +{<br>
> + struct dce_hwseq *hws = kzalloc(sizeof(struct dce_hwseq), GFP_ATOMIC);<br>
> +<br>
> + if (hws) {<br>
> + hws->ctx = ctx;<br>
> + hws->regs = &hwseq_reg;<br>
> + hws->shifts = &hwseq_shift;<br>
> + hws->masks = &hwseq_mask;<br>
> + }<br>
> + return hws;<br>
> +}<br>
> +<br>
> +static const struct resource_create_funcs res_create_funcs = {<br>
> + .read_dce_straps = read_dce_straps,<br>
> + .create_audio = dcn201_create_audio,<br>
> + .create_stream_encoder = dcn201_stream_encoder_create,<br>
> + .create_hwseq = dcn201_hwseq_create,<br>
> +};<br>
> +<br>
> +static const struct resource_create_funcs res_create_maximus_funcs = {<br>
> + .read_dce_straps = NULL,<br>
> + .create_audio = NULL,<br>
> + .create_stream_encoder = NULL,<br>
> + .create_hwseq = dcn201_hwseq_create,<br>
> +};<br>
> +<br>
> +void dcn201_clock_source_destroy(struct clock_source **clk_src)<br>
> +{<br>
> + kfree(TO_DCE110_CLK_SRC(*clk_src));<br>
> + *clk_src = NULL;<br>
> +}<br>
> +<br>
> +static void dcn201_resource_destruct(struct dcn201_resource_pool *pool)<br>
> +{<br>
> + unsigned int i;<br>
> +<br>
> + for (i = 0; i < pool->base.stream_enc_count; i++) {<br>
> + if (pool->base.stream_enc[i] != NULL) {<br>
> + kfree(DCN10STRENC_FROM_STRENC(pool->base.stream_enc[i]));<br>
> + pool->base.stream_enc[i] = NULL;<br>
> + }<br>
> + }<br>
> +<br>
> +<br>
> + if (pool->base.mpc != NULL) {<br>
> + kfree(TO_DCN201_MPC(pool->base.mpc));<br>
> + pool->base.mpc = NULL;<br>
> + }<br>
> +<br>
> + if (pool->base.hubbub != NULL) {<br>
> + kfree(pool->base.hubbub);<br>
> + pool->base.hubbub = NULL;<br>
> + }<br>
> +<br>
> + for (i = 0; i < pool->base.pipe_count; i++) {<br>
> + if (pool->base.dpps[i] != NULL)<br>
> + dcn201_dpp_destroy(&pool->base.dpps[i]);<br>
> +<br>
> + if (pool->base.ipps[i] != NULL)<br>
> + pool->base.ipps[i]->funcs->ipp_destroy(&pool->base.ipps[i]);<br>
> +<br>
> + if (pool->base.hubps[i] != NULL) {<br>
> + kfree(TO_DCN10_HUBP(pool->base.hubps[i]));<br>
> + pool->base.hubps[i] = NULL;<br>
> + }<br>
> +<br>
> + if (pool->base.irqs != NULL) {<br>
> + dal_irq_service_destroy(&pool->base.irqs);<br>
> + }<br>
> + }<br>
> +<br>
> + for (i = 0; i < pool->base.res_cap->num_opp; i++) {<br>
> + if (pool->base.opps[i] != NULL)<br>
> + pool->base.opps[i]->funcs->opp_destroy(&pool->base.opps[i]);<br>
> + }<br>
> +<br>
> + for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) {<br>
> + if (pool->base.timing_generators[i] != NULL) {<br>
> + kfree(DCN10TG_FROM_TG(pool->base.timing_generators[i]));<br>
> + pool->base.timing_generators[i] = NULL;<br>
> + }<br>
> + }<br>
> + for (i = 0; i < pool->base.audio_count; i++) {<br>
> + if (pool->base.audios[i])<br>
> + dce_aud_destroy(&pool->base.audios[i]);<br>
> + }<br>
> +<br>
> + for (i = 0; i < pool->base.clk_src_count; i++) {<br>
> + if (pool->base.clock_sources[i] != NULL) {<br>
> + dcn201_clock_source_destroy(&pool->base.clock_sources[i]);<br>
> + pool->base.clock_sources[i] = NULL;<br>
> + }<br>
> + }<br>
> +<br>
> + if (pool->base.dp_clock_source != NULL) {<br>
> + dcn201_clock_source_destroy(&pool->base.dp_clock_source);<br>
> + pool->base.dp_clock_source = NULL;<br>
> + }<br>
> +<br>
> + if (pool->base.dccg != NULL)<br>
> + dcn_dccg_destroy(&pool->base.dccg);<br>
> +}<br>
> +<br>
> +static struct hubp *dcn201_hubp_create(<br>
> + struct dc_context *ctx,<br>
> + uint32_t inst)<br>
> +{<br>
> + struct dcn201_hubp *hubp201 =<br>
> + kzalloc(sizeof(struct dcn201_hubp), GFP_ATOMIC);<br>
> +<br>
> + if (!hubp201)<br>
> + return NULL;<br>
> +<br>
> + if (dcn201_hubp_construct(hubp201, ctx, inst,<br>
> + &hubp_regs[inst], &hubp_shift, &hubp_mask))<br>
> + return &hubp201->base;<br>
> +<br>
> + kfree(hubp201);<br>
> + return NULL;<br>
> +}<br>
> +<br>
> +static struct pipe_ctx *dcn201_acquire_idle_pipe_for_layer(<br>
> + struct dc_state *context,<br>
> + const struct resource_pool *pool,<br>
> + struct dc_stream_state *stream)<br>
> +{<br>
> + struct resource_context *res_ctx = &context->res_ctx;<br>
> + struct pipe_ctx *head_pipe = resource_get_head_pipe_for_stream(res_ctx, stream);<br>
> + struct pipe_ctx *idle_pipe = find_idle_secondary_pipe(res_ctx, pool, head_pipe);<br>
> +<br>
> + if (!head_pipe)<br>
> + ASSERT(0);<br>
> +<br>
> + if (!idle_pipe)<br>
> + return false;<br>
> +<br>
> + idle_pipe->stream = head_pipe->stream;<br>
> + idle_pipe->stream_res.tg = head_pipe->stream_res.tg;<br>
> + idle_pipe->stream_res.opp = head_pipe->stream_res.opp;<br>
> +<br>
> + idle_pipe->plane_res.hubp = pool->hubps[idle_pipe->pipe_idx];<br>
> + idle_pipe->plane_res.ipp = pool->ipps[idle_pipe->pipe_idx];<br>
> + idle_pipe->plane_res.dpp = pool->dpps[idle_pipe->pipe_idx];<br>
> + idle_pipe->plane_res.mpcc_inst = pool->dpps[idle_pipe->pipe_idx]->inst;<br>
> +<br>
> + return idle_pipe;<br>
> +}<br>
> +<br>
> +static bool dcn201_get_dcc_compression_cap(const struct dc *dc,<br>
> + const struct dc_dcc_surface_param *input,<br>
> + struct dc_surface_dcc_cap *output)<br>
> +{<br>
> + return dc->res_pool->hubbub->funcs->get_dcc_compression_cap(<br>
> + dc->res_pool->hubbub,<br>
> + input,<br>
> + output);<br>
> +}<br>
> +<br>
> +<br>
> +static void dcn201_destroy_resource_pool(struct resource_pool **pool)<br>
> +{<br>
> + struct dcn201_resource_pool *dcn201_pool = TO_DCN201_RES_POOL(*pool);<br>
> +<br>
> + dcn201_resource_destruct(dcn201_pool);<br>
> + kfree(dcn201_pool);<br>
> + *pool = NULL;<br>
> +}<br>
> +<br>
> +static void dcn201_link_init(struct dc_link *link)<br>
> +{<br>
> + if (link->ctx->dc_bios->integrated_info)<br>
> + link->dp_ss_off = !link->ctx->dc_bios->integrated_info->dp_ss_control;<br>
> +}<br>
> +<br>
> +static struct dc_cap_funcs cap_funcs = {<br>
> + .get_dcc_compression_cap = dcn201_get_dcc_compression_cap,<br>
> +};<br>
> +<br>
> +static struct resource_funcs dcn201_res_pool_funcs = {<br>
> + .link_init = dcn201_link_init,<br>
> + .destroy = dcn201_destroy_resource_pool,<br>
> + .link_enc_create = dcn201_link_encoder_create,<br>
> + .panel_cntl_create = NULL,<br>
> + .validate_bandwidth = dcn20_validate_bandwidth,<br>
> + .populate_dml_pipes = dcn20_populate_dml_pipes_from_context,<br>
> + .add_stream_to_ctx = dcn20_add_stream_to_ctx,<br>
> + .add_dsc_to_stream_resource = NULL,<br>
> + .remove_stream_from_ctx = dcn20_remove_stream_from_ctx,<br>
> + .acquire_idle_pipe_for_layer = dcn201_acquire_idle_pipe_for_layer,<br>
> + .patch_unknown_plane_state = dcn20_patch_unknown_plane_state,<br>
> + .populate_dml_writeback_from_context = dcn20_populate_dml_writeback_from_context,<br>
> + .set_mcif_arb_params = dcn20_set_mcif_arb_params,<br>
> + .find_first_free_match_stream_enc_for_link = dcn10_find_first_free_match_stream_enc_for_link<br>
> +};<br>
> +<br>
> +static bool dcn201_resource_construct(<br>
> + uint8_t num_virtual_links,<br>
> + struct dc *dc,<br>
> + struct dcn201_resource_pool *pool)<br>
> +{<br>
> + int i;<br>
> + struct dc_context *ctx = dc->ctx;<br>
> +<br>
> + ctx->dc_bios->regs = &bios_regs;<br>
> +<br>
> + pool->base.res_cap = &res_cap_dnc201;<br>
> + pool->base.funcs = &dcn201_res_pool_funcs;<br>
> +<br>
> + /*************************************************<br>
> + * Resource + asic cap harcoding *<br>
> + *************************************************/<br>
> + pool->base.underlay_pipe_index = NO_UNDERLAY_PIPE;<br>
> +<br>
> + pool->base.pipe_count = 4;<br>
> + pool->base.mpcc_count = 5;<br>
> + dc->caps.max_downscale_ratio = 200;<br>
> + dc->caps.i2c_speed_in_khz = 100;<br>
> + dc->caps.i2c_speed_in_khz_hdcp = 5; /*1.5 w/a applied by default*/<br>
> + dc->caps.max_cursor_size = 256;<br>
> + dc->caps.min_horizontal_blanking_period = 80;<br>
> + dc->caps.dmdata_alloc_size = 2048;<br>
> +<br>
> + dc->caps.max_slave_planes = 1;<br>
> + dc->caps.max_slave_yuv_planes = 1;<br>
> + dc->caps.max_slave_rgb_planes = 1;<br>
> + dc->caps.post_blend_color_processing = true;<br>
> + dc->caps.force_dp_tps4_for_cp2520 = true;<br>
> + dc->caps.extended_aux_timeout_support = true;<br>
> +<br>
> + /* Color pipeline capabilities */<br>
> + dc->caps.color.dpp.dcn_arch = 1;<br>
> + dc->caps.color.dpp.input_lut_shared = 0;<br>
> + dc->caps.color.dpp.icsc = 1;<br>
> + dc->caps.color.dpp.dgam_ram = 1;<br>
> + dc->caps.color.dpp.dgam_rom_caps.srgb = 1;<br>
> + dc->caps.color.dpp.dgam_rom_caps.bt2020 = 1;<br>
> + dc->caps.color.dpp.dgam_rom_caps.gamma2_2 = 0;<br>
> + dc->caps.color.dpp.dgam_rom_caps.pq = 0;<br>
> + dc->caps.color.dpp.dgam_rom_caps.hlg = 0;<br>
> + dc->caps.color.dpp.post_csc = 0;<br>
> + dc->caps.color.dpp.gamma_corr = 0;<br>
> + dc->caps.color.dpp.dgam_rom_for_yuv = 1;<br>
> +<br>
> + dc->caps.color.dpp.hw_3d_lut = 1;<br>
> + dc->caps.color.dpp.ogam_ram = 1;<br>
> + // no OGAM ROM on DCN2<br>
> + dc->caps.color.dpp.ogam_rom_caps.srgb = 0;<br>
> + dc->caps.color.dpp.ogam_rom_caps.bt2020 = 0;<br>
> + dc->caps.color.dpp.ogam_rom_caps.gamma2_2 = 0;<br>
> + dc->caps.color.dpp.ogam_rom_caps.pq = 0;<br>
> + dc->caps.color.dpp.ogam_rom_caps.hlg = 0;<br>
> + dc->caps.color.dpp.ocsc = 0;<br>
> +<br>
> + dc->caps.color.mpc.gamut_remap = 0;<br>
> + dc->caps.color.mpc.num_3dluts = 0;<br>
> + dc->caps.color.mpc.shared_3d_lut = 0;<br>
> + dc->caps.color.mpc.ogam_ram = 1;<br>
> + dc->caps.color.mpc.ogam_rom_caps.srgb = 0;<br>
> + dc->caps.color.mpc.ogam_rom_caps.bt2020 = 0;<br>
> + dc->caps.color.mpc.ogam_rom_caps.gamma2_2 = 0;<br>
> + dc->caps.color.mpc.ogam_rom_caps.pq = 0;<br>
> + dc->caps.color.mpc.ogam_rom_caps.hlg = 0;<br>
> + dc->caps.color.mpc.ocsc = 1;<br>
> +<br>
> + dc->debug = debug_defaults_drv;<br>
> +<br>
> + /*a0 only, remove later*/<br>
> + dc->work_arounds.no_connect_phy_config = true;<br>
> + dc->work_arounds.dedcn20_305_wa = true;<br>
> + /*************************************************<br>
> + * Create resources *<br>
> + *************************************************/<br>
> +<br>
> + pool->base.clock_sources[DCN20_CLK_SRC_PLL0] =<br>
> + dcn201_clock_source_create(ctx, ctx->dc_bios,<br>
> + CLOCK_SOURCE_COMBO_PHY_PLL0,<br>
> + &clk_src_regs[0], false);<br>
> + pool->base.clock_sources[DCN20_CLK_SRC_PLL1] =<br>
> + dcn201_clock_source_create(ctx, ctx->dc_bios,<br>
> + CLOCK_SOURCE_COMBO_PHY_PLL1,<br>
> + &clk_src_regs[1], false);<br>
> +<br>
> + pool->base.clk_src_count = DCN20_CLK_SRC_TOTAL_DCN201;<br>
> +<br>
> + /* todo: not reuse phy_pll registers */<br>
> + pool->base.dp_clock_source =<br>
> + dcn201_clock_source_create(ctx, ctx->dc_bios,<br>
> + CLOCK_SOURCE_ID_DP_DTO,<br>
> + &clk_src_regs[0], true);<br>
> +<br>
> + for (i = 0; i < pool->base.clk_src_count; i++) {<br>
> + if (pool->base.clock_sources[i] == NULL) {<br>
> + dm_error("DC: failed to create clock sources!\n");<br>
> + goto create_fail;<br>
> + }<br>
> + }<br>
> +<br>
> + pool->base.dccg = dccg201_create(ctx, &dccg_regs, &dccg_shift, &dccg_mask);<br>
> + if (pool->base.dccg == NULL) {<br>
> + dm_error("DC: failed to create dccg!\n");<br>
> + goto create_fail;<br>
> + }<br>
> +<br>
> + dcn201_ip.max_num_otg = pool->base.res_cap->num_timing_generator;<br>
> + dcn201_ip.max_num_dpp = pool->base.pipe_count;<br>
> + dml_init_instance(&dc->dml, &dcn201_soc, &dcn201_ip, DML_PROJECT_DCN201);<br>
> + {<br>
> + struct irq_service_init_data init_data;<br>
> + init_data.ctx = dc->ctx;<br>
> + pool->base.irqs = dal_irq_service_dcn201_create(&init_data);<br>
> + if (!pool->base.irqs)<br>
> + goto create_fail;<br>
> + }<br>
> +<br>
> + /* mem input -> ipp -> dpp -> opp -> TG */<br>
> + for (i = 0; i < pool->base.pipe_count; i++) {<br>
> + pool->base.hubps[i] = dcn201_hubp_create(ctx, i);<br>
> + if (pool->base.hubps[i] == NULL) {<br>
> + dm_error(<br>
> + "DC: failed to create memory input!\n");<br>
> + goto create_fail;<br>
> + }<br>
> +<br>
> + pool->base.ipps[i] = dcn201_ipp_create(ctx, i);<br>
> + if (pool->base.ipps[i] == NULL) {<br>
> + dm_error(<br>
> + "DC: failed to create input pixel processor!\n");<br>
> + goto create_fail;<br>
> + }<br>
> +<br>
> + pool->base.dpps[i] = dcn201_dpp_create(ctx, i);<br>
> + if (pool->base.dpps[i] == NULL) {<br>
> + dm_error(<br>
> + "DC: failed to create dpps!\n");<br>
> + goto create_fail;<br>
> + }<br>
> + }<br>
> +<br>
> + for (i = 0; i < pool->base.res_cap->num_opp; i++) {<br>
> + pool->base.opps[i] = dcn201_opp_create(ctx, i);<br>
> + if (pool->base.opps[i] == NULL) {<br>
> + dm_error(<br>
> + "DC: failed to create output pixel processor!\n");<br>
> + goto create_fail;<br>
> + }<br>
> + }<br>
> +<br>
> + for (i = 0; i < pool->base.res_cap->num_ddc; i++) {<br>
> + pool->base.engines[i] = dcn201_aux_engine_create(ctx, i);<br>
> + if (pool->base.engines[i] == NULL) {<br>
> + dm_error(<br>
> + "DC:failed to create aux engine!!\n");<br>
> + goto create_fail;<br>
> + }<br>
> + pool->base.hw_i2cs[i] = dcn201_i2c_hw_create(ctx, i);<br>
> + if (pool->base.hw_i2cs[i] == NULL) {<br>
> + dm_error(<br>
> + "DC:failed to create hw i2c!!\n");<br>
> + goto create_fail;<br>
> + }<br>
> + pool->base.sw_i2cs[i] = NULL;<br>
> + }<br>
> +<br>
> + for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) {<br>
> + pool->base.timing_generators[i] = dcn201_timing_generator_create(<br>
> + ctx, i);<br>
> + if (pool->base.timing_generators[i] == NULL) {<br>
> + dm_error("DC: failed to create tg!\n");<br>
> + goto create_fail;<br>
> + }<br>
> + }<br>
> +<br>
> + pool->base.timing_generator_count = i;<br>
> +<br>
> + pool->base.mpc = dcn201_mpc_create(ctx, pool->base.mpcc_count);<br>
> + if (pool->base.mpc == NULL) {<br>
> + dm_error("DC: failed to create mpc!\n");<br>
> + goto create_fail;<br>
> + }<br>
> +<br>
> + pool->base.hubbub = dcn201_hubbub_create(ctx);<br>
> + if (pool->base.hubbub == NULL) {<br>
> + dm_error("DC: failed to create hubbub!\n");<br>
> + goto create_fail;<br>
> + }<br>
> +<br>
> + if (!resource_construct(num_virtual_links, dc, &pool->base,<br>
> + (!IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment) ?<br>
> + &res_create_funcs : &res_create_maximus_funcs)))<br>
> + goto create_fail;<br>
> +<br>
> + dcn201_hw_sequencer_construct(dc);<br>
> +<br>
> + dc->caps.max_planes = pool->base.pipe_count;<br>
> +<br>
> + for (i = 0; i < dc->caps.max_planes; ++i)<br>
> + dc->caps.planes[i] = plane_cap;<br>
> +<br>
> + dc->cap_funcs = cap_funcs;<br>
> +<br>
> + return true;<br>
> +<br>
> +create_fail:<br>
> +<br>
> + dcn201_resource_destruct(pool);<br>
> +<br>
> + return false;<br>
> +}<br>
> +<br>
> +struct resource_pool *dcn201_create_resource_pool(<br>
> + const struct dc_init_data *init_data,<br>
> + struct dc *dc)<br>
> +{<br>
> + struct dcn201_resource_pool *pool =<br>
> + kzalloc(sizeof(struct dcn201_resource_pool), GFP_ATOMIC);<br>
> +<br>
> + if (!pool)<br>
> + return NULL;<br>
> +<br>
> + if (dcn201_resource_construct(init_data->num_virtual_links, dc, pool))<br>
> + return &pool->base;<br>
> +<br>
> + kfree(pool);<br>
> + return NULL;<br>
> +}<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_resource.h b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_resource.h<br>
> new file mode 100644<br>
> index 0000000..e0467d1<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_resource.h<br>
> @@ -0,0 +1,50 @@<br>
> +/*<br>
> +* Copyright 2017 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +<br>
> +#ifndef __DC_RESOURCE_DCN201_H__<br>
> +#define __DC_RESOURCE_DCN201_H__<br>
> +<br>
> +#include "core_types.h"<br>
> +<br>
> +#define RRDPCS_PHY_DP_TX_PSTATE_POWER_UP 0x00000000<br>
> +#define RRDPCS_PHY_DP_TX_PSTATE_HOLD 0x00000001<br>
> +#define RRDPCS_PHY_DP_TX_PSTATE_HOLD_OFF 0x00000002<br>
> +#define RRDPCS_PHY_DP_TX_PSTATE_POWER_DOWN 0x00000003<br>
> +<br>
> +#define TO_DCN201_RES_POOL(pool)\<br>
> + container_of(pool, struct dcn201_resource_pool, base)<br>
> +<br>
> +struct dc;<br>
> +struct resource_pool;<br>
> +struct _vcs_dpi_display_pipe_params_st;<br>
> +<br>
> +struct dcn201_resource_pool {<br>
> + struct resource_pool base;<br>
> +};<br>
> +struct resource_pool *dcn201_create_resource_pool(<br>
> + const struct dc_init_data *init_data,<br>
> + struct dc *dc);<br>
> +<br>
> +#endif /* __DC_RESOURCE_DCN201_H__ */<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dml/display_mode_lib.c b/drivers/gpu/drm/amd/display/dc/dml/display_mode_lib.c<br>
> index 8a5bd91..30db51f 100644<br>
> --- a/drivers/gpu/drm/amd/display/dc/dml/display_mode_lib.c<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dml/display_mode_lib.c<br>
> @@ -82,6 +82,7 @@<br>
> lib->project = project;<br>
> switch (project) {<br>
> case DML_PROJECT_NAVI10:<br>
> + case DML_PROJECT_DCN201:<br>
> lib->funcs = dml20_funcs;<br>
> break;<br>
> case DML_PROJECT_NAVI10v2:<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dml/display_mode_lib.h b/drivers/gpu/drm/amd/display/dc/dml/display_mode_lib.h<br>
> index 72b1957..6905ef1 100644<br>
> --- a/drivers/gpu/drm/amd/display/dc/dml/display_mode_lib.h<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dml/display_mode_lib.h<br>
> @@ -36,6 +36,7 @@<br>
> DML_PROJECT_RAVEN1,<br>
> DML_PROJECT_NAVI10,<br>
> DML_PROJECT_NAVI10v2,<br>
> + DML_PROJECT_DCN201,<br>
> DML_PROJECT_DCN21,<br>
> DML_PROJECT_DCN30,<br>
> DML_PROJECT_DCN31,<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/gpio/hw_factory.c b/drivers/gpu/drm/amd/display/dc/gpio/hw_factory.c<br>
> index c5c840a..5029d4e 100644<br>
> --- a/drivers/gpu/drm/amd/display/dc/gpio/hw_factory.c<br>
> +++ b/drivers/gpu/drm/amd/display/dc/gpio/hw_factory.c<br>
> @@ -105,6 +105,7 @@<br>
> case DCN_VERSION_2_0:<br>
> dal_hw_factory_dcn20_init(factory);<br>
> return true;<br>
> + case DCN_VERSION_2_01:<br>
> case DCN_VERSION_2_1:<br>
> dal_hw_factory_dcn21_init(factory);<br>
> return true;<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/gpio/hw_translate.c b/drivers/gpu/drm/amd/display/dc/gpio/hw_translate.c<br>
> index 4a98483..904bd30 100644<br>
> --- a/drivers/gpu/drm/amd/display/dc/gpio/hw_translate.c<br>
> +++ b/drivers/gpu/drm/amd/display/dc/gpio/hw_translate.c<br>
> @@ -100,6 +100,7 @@<br>
> case DCN_VERSION_2_0:<br>
> dal_hw_translate_dcn20_init(translate);<br>
> return true;<br>
> + case DCN_VERSION_2_01:<br>
> case DCN_VERSION_2_1:<br>
> dal_hw_translate_dcn21_init(translate);<br>
> return true;<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/clk_mgr_internal.h b/drivers/gpu/drm/amd/display/dc/inc/hw/clk_mgr_internal.h<br>
> index a262f32..1391c20 100644<br>
> --- a/drivers/gpu/drm/amd/display/dc/inc/hw/clk_mgr_internal.h<br>
> +++ b/drivers/gpu/drm/amd/display/dc/inc/hw/clk_mgr_internal.h<br>
> @@ -102,6 +102,11 @@<br>
> .MP1_SMN_C2PMSG_83 = mmMP1_SMN_C2PMSG_83, \<br>
> .MP1_SMN_C2PMSG_67 = mmMP1_SMN_C2PMSG_67<br>
><br>
> +#define CLK_COMMON_REG_LIST_DCN_201() \<br>
> + SR(DENTIST_DISPCLK_CNTL), \<br>
> + CLK_SRI(CLK4_CLK_PLL_REQ, CLK4, 0), \<br>
> + CLK_SRI(CLK4_CLK2_CURRENT_CNT, CLK4, 0)<br>
> +<br>
> #define CLK_REG_LIST_NV10() \<br>
> SR(DENTIST_DISPCLK_CNTL), \<br>
> CLK_SRI(CLK3_CLK_PLL_REQ, CLK3, 0), \<br>
> @@ -144,6 +149,12 @@<br>
> CLK_SF(CLK3_0_CLK3_CLK_PLL_REQ, FbMult_int, mask_sh),\<br>
> CLK_SF(CLK3_0_CLK3_CLK_PLL_REQ, FbMult_frac, mask_sh)<br>
><br>
> +#define CLK_COMMON_MASK_SH_LIST_DCN201_BASE(mask_sh) \<br>
> + CLK_COMMON_MASK_SH_LIST_DCN_COMMON_BASE(mask_sh),\<br>
> + CLK_SF(DENTIST_DISPCLK_CNTL, DENTIST_DPPCLK_WDIVIDER, mask_sh),\<br>
> + CLK_SF(DENTIST_DISPCLK_CNTL, DENTIST_DPPCLK_CHG_DONE, mask_sh),\<br>
> + CLK_SF(CLK4_0_CLK4_CLK_PLL_REQ, FbMult_int, mask_sh)<br>
> +<br>
> #define CLK_REG_FIELD_LIST(type) \<br>
> type DPREFCLK_SRC_SEL; \<br>
> type DENTIST_DPREFCLK_WDIVIDER; \<br>
> @@ -179,6 +190,8 @@<br>
> struct clk_mgr_registers {<br>
> uint32_t DPREFCLK_CNTL;<br>
> uint32_t DENTIST_DISPCLK_CNTL;<br>
> + uint32_t CLK4_CLK2_CURRENT_CNT;<br>
> + uint32_t CLK4_CLK_PLL_REQ;<br>
><br>
> uint32_t CLK3_CLK2_DFS_CNTL;<br>
> uint32_t CLK3_CLK_PLL_REQ;<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/dwb.h b/drivers/gpu/drm/amd/display/dc/inc/hw/dwb.h<br>
> index 9ccbb2b..fd6572b 100644<br>
> --- a/drivers/gpu/drm/amd/display/dc/inc/hw/dwb.h<br>
> +++ b/drivers/gpu/drm/amd/display/dc/inc/hw/dwb.h<br>
> @@ -172,8 +172,8 @@<br>
> bool dwb_is_drc;<br>
> int wb_src_plane_inst;/*hubp, mpcc, inst*/<br>
> uint32_t mask_id;<br>
> - int otg_inst;<br>
> - bool mvc_cfg;<br>
> + int otg_inst;<br>
> + bool mvc_cfg;<br>
> };<br>
><br>
> struct dwbc_funcs {<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/mpc.h b/drivers/gpu/drm/amd/display/dc/inc/hw/mpc.h<br>
> index 640bb432..04d6ec3 100644<br>
> --- a/drivers/gpu/drm/amd/display/dc/inc/hw/mpc.h<br>
> +++ b/drivers/gpu/drm/amd/display/dc/inc/hw/mpc.h<br>
> @@ -281,6 +281,7 @@<br>
> struct mpcc* (*get_mpcc_for_dpp_from_secondary)(<br>
> struct mpc_tree *tree,<br>
> int dpp_id);<br>
> +<br>
> struct mpcc* (*get_mpcc_for_dpp)(<br>
> struct mpc_tree *tree,<br>
> int dpp_id);<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer_private.h b/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer_private.h<br>
> index d09eed7..f324285 100644<br>
> --- a/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer_private.h<br>
> +++ b/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer_private.h<br>
> @@ -154,6 +154,10 @@<br>
> struct hwseq_wa_state wa_state;<br>
> struct hwseq_private_funcs funcs;<br>
><br>
> + PHYSICAL_ADDRESS_LOC fb_base;<br>
> + PHYSICAL_ADDRESS_LOC fb_top;<br>
> + PHYSICAL_ADDRESS_LOC fb_offset;<br>
> + PHYSICAL_ADDRESS_LOC uma_top;<br>
> };<br>
><br>
> #endif /* __DC_HW_SEQUENCER_PRIVATE_H__ */<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/irq/Makefile b/drivers/gpu/drm/amd/display/dc/irq/Makefile<br>
> index 0d09181..8a18277 100644<br>
> --- a/drivers/gpu/drm/amd/display/dc/irq/Makefile<br>
> +++ b/drivers/gpu/drm/amd/display/dc/irq/Makefile<br>
> @@ -93,6 +93,18 @@<br>
> AMD_DAL_IRQ_DCN21= $(addprefix $(AMDDALPATH)/dc/irq/dcn21/,$(IRQ_DCN21))<br>
><br>
> AMD_DISPLAY_FILES += $(AMD_DAL_IRQ_DCN21)<br>
> +<br>
> +ifdef CONFIG_DRM_AMD_DC_DCN201<br>
> +###############################################################################<br>
> +# DCN 201<br>
> +###############################################################################<br>
> +IRQ_DCN201 = irq_service_dcn201.o<br>
> +<br>
> +AMD_DAL_IRQ_DCN201 = $(addprefix $(AMDDALPATH)/dc/irq/dcn201/,$(IRQ_DCN201))<br>
> +<br>
> +AMD_DISPLAY_FILES += $(AMD_DAL_IRQ_DCN201)<br>
> +endif<br>
> +<br>
> ###############################################################################<br>
> # DCN 30<br>
> ###############################################################################<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/irq/dcn201/irq_service_dcn201.c b/drivers/gpu/drm/amd/display/dc/irq/dcn201/irq_service_dcn201.c<br>
> new file mode 100644<br>
> index 0000000..a47f686<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/irq/dcn201/irq_service_dcn201.c<br>
> @@ -0,0 +1,374 @@<br>
> +/*<br>
> + * Copyright 2018 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +<br>
> +#include "dm_services.h"<br>
> +<br>
> +#include "include/logger_interface.h"<br>
> +<br>
> +#include "../dce110/irq_service_dce110.h"<br>
> +<br>
> +#include "dcn/dcn_2_0_3_offset.h"<br>
> +#include "dcn/dcn_2_0_3_sh_mask.h"<br>
> +<br>
> +#include "cyan_skillfish_ip_offset.h"<br>
> +#include "soc15_hw_ip.h"<br>
> +<br>
> +#include "irq_service_dcn201.h"<br>
> +<br>
> +#include "ivsrcid/dcn/irqsrcs_dcn_1_0.h"<br>
> +<br>
> +enum dc_irq_source to_dal_irq_source_dcn201(<br>
> + struct irq_service *irq_service,<br>
> + uint32_t src_id,<br>
> + uint32_t ext_id)<br>
> +{<br>
> + switch (src_id) {<br>
> + case DCN_1_0__SRCID__DC_D1_OTG_VSTARTUP:<br>
> + return DC_IRQ_SOURCE_VBLANK1;<br>
> + case DCN_1_0__SRCID__DC_D2_OTG_VSTARTUP:<br>
> + return DC_IRQ_SOURCE_VBLANK2;<br>
> + case DCN_1_0__SRCID__OTG1_VERTICAL_INTERRUPT0_CONTROL:<br>
> + return DC_IRQ_SOURCE_DC1_VLINE0;<br>
> + case DCN_1_0__SRCID__OTG2_VERTICAL_INTERRUPT0_CONTROL:<br>
> + return DC_IRQ_SOURCE_DC2_VLINE0;<br>
> + case DCN_1_0__SRCID__HUBP0_FLIP_INTERRUPT:<br>
> + return DC_IRQ_SOURCE_PFLIP1;<br>
> + case DCN_1_0__SRCID__HUBP1_FLIP_INTERRUPT:<br>
> + return DC_IRQ_SOURCE_PFLIP2;<br>
> + case DCN_1_0__SRCID__OTG0_IHC_V_UPDATE_NO_LOCK_INTERRUPT:<br>
> + return DC_IRQ_SOURCE_VUPDATE1;<br>
> + case DCN_1_0__SRCID__OTG1_IHC_V_UPDATE_NO_LOCK_INTERRUPT:<br>
> + return DC_IRQ_SOURCE_VUPDATE2;<br>
> + case DCN_1_0__SRCID__DC_HPD1_INT:<br>
> + /* generic src_id for all HPD and HPDRX interrupts */<br>
> + switch (ext_id) {<br>
> + case DCN_1_0__CTXID__DC_HPD1_INT:<br>
> + return DC_IRQ_SOURCE_HPD1;<br>
> + case DCN_1_0__CTXID__DC_HPD2_INT:<br>
> + return DC_IRQ_SOURCE_HPD2;<br>
> + case DCN_1_0__CTXID__DC_HPD1_RX_INT:<br>
> + return DC_IRQ_SOURCE_HPD1RX;<br>
> + case DCN_1_0__CTXID__DC_HPD2_RX_INT:<br>
> + return DC_IRQ_SOURCE_HPD2RX;<br>
> + default:<br>
> + return DC_IRQ_SOURCE_INVALID;<br>
> + }<br>
> + break;<br>
> +<br>
> + default:<br>
> + return DC_IRQ_SOURCE_INVALID;<br>
> + }<br>
> + return DC_IRQ_SOURCE_INVALID;<br>
> +}<br>
> +<br>
> +static bool hpd_ack(<br>
> + struct irq_service *irq_service,<br>
> + const struct irq_source_info *info)<br>
> +{<br>
> + uint32_t addr = info->status_reg;<br>
> + uint32_t value = dm_read_reg(irq_service->ctx, addr);<br>
> + uint32_t current_status =<br>
> + get_reg_field_value(<br>
> + value,<br>
> + HPD0_DC_HPD_INT_STATUS,<br>
> + DC_HPD_SENSE_DELAYED);<br>
> +<br>
> + dal_irq_service_ack_generic(irq_service, info);<br>
> +<br>
> + value = dm_read_reg(irq_service->ctx, info->enable_reg);<br>
> +<br>
> + set_reg_field_value(<br>
> + value,<br>
> + current_status ? 0 : 1,<br>
> + HPD0_DC_HPD_INT_CONTROL,<br>
> + DC_HPD_INT_POLARITY);<br>
> +<br>
> + dm_write_reg(irq_service->ctx, info->enable_reg, value);<br>
> +<br>
> + return true;<br>
> +}<br>
> +<br>
> +static const struct irq_source_info_funcs hpd_irq_info_funcs = {<br>
> + .set = NULL,<br>
> + .ack = hpd_ack<br>
> +};<br>
> +<br>
> +static const struct irq_source_info_funcs hpd_rx_irq_info_funcs = {<br>
> + .set = NULL,<br>
> + .ack = NULL<br>
> +};<br>
> +<br>
> +static const struct irq_source_info_funcs pflip_irq_info_funcs = {<br>
> + .set = NULL,<br>
> + .ack = NULL<br>
> +};<br>
> +<br>
> +static const struct irq_source_info_funcs vblank_irq_info_funcs = {<br>
> + .set = NULL,<br>
> + .ack = NULL<br>
> +};<br>
> +<br>
> +static const struct irq_source_info_funcs vline0_irq_info_funcs = {<br>
> + .set = NULL,<br>
> + .ack = NULL<br>
> +};<br>
> +static const struct irq_source_info_funcs vupdate_no_lock_irq_info_funcs = {<br>
> + .set = NULL,<br>
> + .ack = NULL<br>
> +};<br>
> +<br>
> +static const struct irq_source_info_funcs dmub_outbox_irq_info_funcs = {<br>
> + .set = NULL,<br>
> + .ack = NULL<br>
> +};<br>
> +<br>
> +#undef BASE_INNER<br>
> +#define BASE_INNER(seg) DMU_BASE__INST0_SEG ## seg<br>
> +<br>
> +#define BASE(seg) BASE_INNER(seg)<br>
> +<br>
> +/* compile time expand base address. */<br>
> +#define BASE(seg) \<br>
> + BASE_INNER(seg)<br>
> +<br>
> +#define SRI(reg_name, block, id)\<br>
> + BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \<br>
> + mm ## block ## id ## _ ## reg_name<br>
> +<br>
> +#define IRQ_REG_ENTRY(block, reg_num, reg1, mask1, reg2, mask2)\<br>
> + .enable_reg = SRI(reg1, block, reg_num),\<br>
> + .enable_mask = \<br>
> + block ## reg_num ## _ ## reg1 ## __ ## mask1 ## _MASK,\<br>
> + .enable_value = {\<br>
> + block ## reg_num ## _ ## reg1 ## __ ## mask1 ## _MASK,\<br>
> + ~block ## reg_num ## _ ## reg1 ## __ ## mask1 ## _MASK \<br>
> + },\<br>
> + .ack_reg = SRI(reg2, block, reg_num),\<br>
> + .ack_mask = \<br>
> + block ## reg_num ## _ ## reg2 ## __ ## mask2 ## _MASK,\<br>
> + .ack_value = \<br>
> + block ## reg_num ## _ ## reg2 ## __ ## mask2 ## _MASK \<br>
> +<br>
> +#define hpd_int_entry(reg_num)\<br>
> + [DC_IRQ_SOURCE_HPD1 + reg_num] = {\<br>
> + IRQ_REG_ENTRY(HPD, reg_num,\<br>
> + DC_HPD_INT_CONTROL, DC_HPD_INT_EN,\<br>
> + DC_HPD_INT_CONTROL, DC_HPD_INT_ACK),\<br>
> + .status_reg = SRI(DC_HPD_INT_STATUS, HPD, reg_num),\<br>
> + .funcs = &hpd_irq_info_funcs\<br>
> + }<br>
> +<br>
> +#define hpd_rx_int_entry(reg_num)\<br>
> + [DC_IRQ_SOURCE_HPD1RX + reg_num] = {\<br>
> + IRQ_REG_ENTRY(HPD, reg_num,\<br>
> + DC_HPD_INT_CONTROL, DC_HPD_RX_INT_EN,\<br>
> + DC_HPD_INT_CONTROL, DC_HPD_RX_INT_ACK),\<br>
> + .status_reg = SRI(DC_HPD_INT_STATUS, HPD, reg_num),\<br>
> + .funcs = &hpd_rx_irq_info_funcs\<br>
> + }<br>
> +#define pflip_int_entry(reg_num)\<br>
> + [DC_IRQ_SOURCE_PFLIP1 + reg_num] = {\<br>
> + IRQ_REG_ENTRY(HUBPREQ, reg_num,\<br>
> + DCSURF_SURFACE_FLIP_INTERRUPT, SURFACE_FLIP_INT_MASK,\<br>
> + DCSURF_SURFACE_FLIP_INTERRUPT, SURFACE_FLIP_CLEAR),\<br>
> + .funcs = &pflip_irq_info_funcs\<br>
> + }<br>
> +<br>
> +#define vupdate_int_entry(reg_num)\<br>
> + [DC_IRQ_SOURCE_VUPDATE1 + reg_num] = {\<br>
> + IRQ_REG_ENTRY(OTG, reg_num,\<br>
> + OTG_GLOBAL_SYNC_STATUS, VUPDATE_INT_EN,\<br>
> + OTG_GLOBAL_SYNC_STATUS, VUPDATE_EVENT_CLEAR),\<br>
> + .funcs = &vblank_irq_info_funcs\<br>
> + }<br>
> +<br>
> +/* vupdate_no_lock_int_entry maps to DC_IRQ_SOURCE_VUPDATEx, to match semantic<br>
> + * of DCE's DC_IRQ_SOURCE_VUPDATEx.<br>
> + */<br>
> +#define vupdate_no_lock_int_entry(reg_num)\<br>
> + [DC_IRQ_SOURCE_VUPDATE1 + reg_num] = {\<br>
> + IRQ_REG_ENTRY(OTG, reg_num,\<br>
> + OTG_GLOBAL_SYNC_STATUS, VUPDATE_NO_LOCK_INT_EN,\<br>
> + OTG_GLOBAL_SYNC_STATUS, VUPDATE_NO_LOCK_EVENT_CLEAR),\<br>
> + .funcs = &vupdate_no_lock_irq_info_funcs\<br>
> + }<br>
> +#define vblank_int_entry(reg_num)\<br>
> + [DC_IRQ_SOURCE_VBLANK1 + reg_num] = {\<br>
> + IRQ_REG_ENTRY(OTG, reg_num,\<br>
> + OTG_GLOBAL_SYNC_STATUS, VSTARTUP_INT_EN,\<br>
> + OTG_GLOBAL_SYNC_STATUS, VSTARTUP_EVENT_CLEAR),\<br>
> + .funcs = &vblank_irq_info_funcs\<br>
> + }<br>
> +<br>
> +#define vline0_int_entry(reg_num)\<br>
> + [DC_IRQ_SOURCE_DC1_VLINE0 + reg_num] = {\<br>
> + IRQ_REG_ENTRY(OTG, reg_num,\<br>
> + OTG_VERTICAL_INTERRUPT0_CONTROL, OTG_VERTICAL_INTERRUPT0_INT_ENABLE,\<br>
> + OTG_VERTICAL_INTERRUPT0_CONTROL, OTG_VERTICAL_INTERRUPT0_CLEAR),\<br>
> + .funcs = &vline0_irq_info_funcs\<br>
> + }<br>
> +<br>
> +#define dummy_irq_entry() \<br>
> + {\<br>
> + .funcs = &dummy_irq_info_funcs\<br>
> + }<br>
> +<br>
> +#define i2c_int_entry(reg_num) \<br>
> + [DC_IRQ_SOURCE_I2C_DDC ## reg_num] = dummy_irq_entry()<br>
> +<br>
> +#define dp_sink_int_entry(reg_num) \<br>
> + [DC_IRQ_SOURCE_DPSINK ## reg_num] = dummy_irq_entry()<br>
> +<br>
> +#define gpio_pad_int_entry(reg_num) \<br>
> + [DC_IRQ_SOURCE_GPIOPAD ## reg_num] = dummy_irq_entry()<br>
> +<br>
> +#define dc_underflow_int_entry(reg_num) \<br>
> + [DC_IRQ_SOURCE_DC ## reg_num ## UNDERFLOW] = dummy_irq_entry()<br>
> +<br>
> +static const struct irq_source_info_funcs dummy_irq_info_funcs = {<br>
> + .set = dal_irq_service_dummy_set,<br>
> + .ack = dal_irq_service_dummy_ack<br>
> +};<br>
> +<br>
> +static const struct irq_source_info<br>
> +irq_source_info_dcn201[DAL_IRQ_SOURCES_NUMBER] = {<br>
> + [DC_IRQ_SOURCE_INVALID] = dummy_irq_entry(),<br>
> + hpd_int_entry(0),<br>
> + hpd_int_entry(1),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> + hpd_rx_int_entry(0),<br>
> + hpd_rx_int_entry(1),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> + i2c_int_entry(1),<br>
> + i2c_int_entry(2),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> + dp_sink_int_entry(1),<br>
> + dp_sink_int_entry(2),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> + [DC_IRQ_SOURCE_TIMER] = dummy_irq_entry(),<br>
> + pflip_int_entry(0),<br>
> + pflip_int_entry(1),<br>
> + pflip_int_entry(2),<br>
> + pflip_int_entry(3),<br>
> + [DC_IRQ_SOURCE_PFLIP5] = dummy_irq_entry(),<br>
> + [DC_IRQ_SOURCE_PFLIP6] = dummy_irq_entry(),<br>
> + [DC_IRQ_SOURCE_PFLIP_UNDERLAY0] = dummy_irq_entry(),<br>
> + gpio_pad_int_entry(0),<br>
> + gpio_pad_int_entry(1),<br>
> + gpio_pad_int_entry(2),<br>
> + gpio_pad_int_entry(3),<br>
> + gpio_pad_int_entry(4),<br>
> + gpio_pad_int_entry(5),<br>
> + gpio_pad_int_entry(6),<br>
> + gpio_pad_int_entry(7),<br>
> + gpio_pad_int_entry(8),<br>
> + gpio_pad_int_entry(9),<br>
> + gpio_pad_int_entry(10),<br>
> + gpio_pad_int_entry(11),<br>
> + gpio_pad_int_entry(12),<br>
> + gpio_pad_int_entry(13),<br>
> + gpio_pad_int_entry(14),<br>
> + gpio_pad_int_entry(15),<br>
> + gpio_pad_int_entry(16),<br>
> + gpio_pad_int_entry(17),<br>
> + gpio_pad_int_entry(18),<br>
> + gpio_pad_int_entry(19),<br>
> + gpio_pad_int_entry(20),<br>
> + gpio_pad_int_entry(21),<br>
> + gpio_pad_int_entry(22),<br>
> + gpio_pad_int_entry(23),<br>
> + gpio_pad_int_entry(24),<br>
> + gpio_pad_int_entry(25),<br>
> + gpio_pad_int_entry(26),<br>
> + gpio_pad_int_entry(27),<br>
> + gpio_pad_int_entry(28),<br>
> + gpio_pad_int_entry(29),<br>
> + gpio_pad_int_entry(30),<br>
> + dc_underflow_int_entry(1),<br>
> + dc_underflow_int_entry(2),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> + [DC_IRQ_SOURCE_DMCU_SCP] = dummy_irq_entry(),<br>
> + [DC_IRQ_SOURCE_VBIOS_SW] = dummy_irq_entry(),<br>
> + vupdate_no_lock_int_entry(0),<br>
> + vupdate_no_lock_int_entry(1),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> + vblank_int_entry(0),<br>
> + vblank_int_entry(1),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> + vline0_int_entry(0),<br>
> + vline0_int_entry(1),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> + dummy_irq_entry(),<br>
> +};<br>
> +<br>
> +static const struct irq_service_funcs irq_service_funcs_dcn201 = {<br>
> + .to_dal_irq_source = to_dal_irq_source_dcn201<br>
> +};<br>
> +<br>
> +static void dcn201_irq_construct(<br>
> + struct irq_service *irq_service,<br>
> + struct irq_service_init_data *init_data)<br>
> +{<br>
> + dal_irq_service_construct(irq_service, init_data);<br>
> +<br>
> + irq_service->info = irq_source_info_dcn201;<br>
> + irq_service->funcs = &irq_service_funcs_dcn201;<br>
> +}<br>
> +<br>
> +struct irq_service *dal_irq_service_dcn201_create(<br>
> + struct irq_service_init_data *init_data)<br>
> +{<br>
> + struct irq_service *irq_service = kzalloc(sizeof(*irq_service),<br>
> + GFP_KERNEL);<br>
> +<br>
> + if (!irq_service)<br>
> + return NULL;<br>
> +<br>
> + dcn201_irq_construct(irq_service, init_data);<br>
> + return irq_service;<br>
> +}<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/irq/dcn201/irq_service_dcn201.h b/drivers/gpu/drm/amd/display/dc/irq/dcn201/irq_service_dcn201.h<br>
> new file mode 100644<br>
> index 0000000..8e27c5e<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/amd/display/dc/irq/dcn201/irq_service_dcn201.h<br>
> @@ -0,0 +1,34 @@<br>
> +/*<br>
> + * Copyright 2018 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * Authors: AMD<br>
> + *<br>
> + */<br>
> +<br>
> +#ifndef __DAL_IRQ_SERVICE_DCN201_H__<br>
> +#define __DAL_IRQ_SERVICE_DCN201_H__<br>
> +<br>
> +#include "../irq_service.h"<br>
> +<br>
> +struct irq_service *dal_irq_service_dcn201_create(<br>
> + struct irq_service_init_data *init_data);<br>
> +<br>
> +#endif<br>
> diff --git a/drivers/gpu/drm/amd/display/include/dal_asic_id.h b/drivers/gpu/drm/amd/display/include/dal_asic_id.h<br>
> index 3d2f081..e4a2dfa 100644<br>
> --- a/drivers/gpu/drm/amd/display/include/dal_asic_id.h<br>
> +++ b/drivers/gpu/drm/amd/display/include/dal_asic_id.h<br>
> @@ -211,6 +211,7 @@<br>
> #ifndef ASICREV_IS_GREEN_SARDINE<br>
> #define ASICREV_IS_GREEN_SARDINE(eChipRev) ((eChipRev >= GREEN_SARDINE_A0) && (eChipRev < 0xFF))<br>
> #endif<br>
> +#define DEVICE_ID_NV_13FE 0x13FE // CYAN_SKILLFISH<br>
> #define FAMILY_VGH 144<br>
> #define DEVICE_ID_VGH_163F 0x163F<br>
> #define VANGOGH_A0 0x01<br>
> diff --git a/drivers/gpu/drm/amd/display/include/dal_types.h b/drivers/gpu/drm/amd/display/include/dal_types.h<br>
> index fe75ec8..012b7c6 100644<br>
> --- a/drivers/gpu/drm/amd/display/include/dal_types.h<br>
> +++ b/drivers/gpu/drm/amd/display/include/dal_types.h<br>
> @@ -50,6 +50,7 @@<br>
> DCN_VERSION_1_0,<br>
> DCN_VERSION_1_01,<br>
> DCN_VERSION_2_0,<br>
> + DCN_VERSION_2_01,<br>
> DCN_VERSION_2_1,<br>
> DCN_VERSION_3_0,<br>
> DCN_VERSION_3_01,<br>
</div>
</span></font></div>
</div>
</body>
</html>