2 * Copyright 2012-17 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
26 #if defined(CONFIG_DRM_AMD_DC_DCN)
28 #include "reg_helper.h"
31 #include "dcn10_dwb.h"
35 dwbc10->dwbc_regs->reg
41 #define FN(reg_name, field_name) \
42 dwbc10->dwbc_shift->field_name, dwbc10->dwbc_mask->field_name
44 #define TO_DCN10_DWBC(dwbc_base) \
45 container_of(dwbc_base, struct dcn10_dwbc, base)
47 static bool dwb1_get_caps(struct dwbc
*dwbc
, struct dwb_caps
*caps
)
50 caps
->adapter_id
= 0; /* we only support 1 adapter currently */
51 caps
->hw_version
= DCN_VERSION_1_0
;
53 memset(&caps
->reserved
, 0, sizeof(caps
->reserved
));
54 memset(&caps
->reserved2
, 0, sizeof(caps
->reserved2
));
55 caps
->sw_version
= dwb_ver_1_0
;
56 caps
->caps
.support_dwb
= true;
57 caps
->caps
.support_ogam
= false;
58 caps
->caps
.support_wbscl
= true;
59 caps
->caps
.support_ocsc
= false;
66 static bool dwb1_enable(struct dwbc
*dwbc
, struct dc_dwb_params
*params
)
68 struct dcn10_dwbc
*dwbc10
= TO_DCN10_DWBC(dwbc
);
71 dwbc
->funcs
->disable(dwbc
);
73 /* disable power gating */
74 REG_UPDATE_5(WB_EC_CONFIG
, DISPCLK_R_WB_GATE_DIS
, 1,
75 DISPCLK_G_WB_GATE_DIS
, 1, DISPCLK_G_WBSCL_GATE_DIS
, 1,
76 WB_LB_LS_DIS
, 1, WB_LUT_LS_DIS
, 1);
78 REG_UPDATE(WB_ENABLE
, WB_ENABLE
, 1);
83 static bool dwb1_disable(struct dwbc
*dwbc
)
85 struct dcn10_dwbc
*dwbc10
= TO_DCN10_DWBC(dwbc
);
88 REG_UPDATE(CNV_MODE
, CNV_FRAME_CAPTURE_EN
, 0);
91 REG_UPDATE(WB_ENABLE
, WB_ENABLE
, 0);
94 REG_UPDATE(WB_SOFT_RESET
, WB_SOFT_RESET
, 1);
95 REG_UPDATE(WB_SOFT_RESET
, WB_SOFT_RESET
, 0);
97 /* enable power gating */
98 REG_UPDATE_5(WB_EC_CONFIG
, DISPCLK_R_WB_GATE_DIS
, 0,
99 DISPCLK_G_WB_GATE_DIS
, 0, DISPCLK_G_WBSCL_GATE_DIS
, 0,
100 WB_LB_LS_DIS
, 0, WB_LUT_LS_DIS
, 0);
105 const struct dwbc_funcs dcn10_dwbc_funcs
= {
106 .get_caps
= dwb1_get_caps
,
107 .enable
= dwb1_enable
,
108 .disable
= dwb1_disable
,
111 .set_new_content
= NULL
,
113 .dwb_set_scaler
= NULL
,
116 void dcn10_dwbc_construct(struct dcn10_dwbc
*dwbc10
,
117 struct dc_context
*ctx
,
118 const struct dcn10_dwbc_registers
*dwbc_regs
,
119 const struct dcn10_dwbc_shift
*dwbc_shift
,
120 const struct dcn10_dwbc_mask
*dwbc_mask
,
123 dwbc10
->base
.ctx
= ctx
;
125 dwbc10
->base
.inst
= inst
;
126 dwbc10
->base
.funcs
= &dcn10_dwbc_funcs
;
128 dwbc10
->dwbc_regs
= dwbc_regs
;
129 dwbc10
->dwbc_shift
= dwbc_shift
;
130 dwbc10
->dwbc_mask
= dwbc_mask
;