diff options
author | Lewis Huang <Lewis.Huang@amd.com> | 2018-10-18 05:52:19 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-11-05 14:21:45 -0500 |
commit | d2b1d6bbc56afab8ebae9d52d7ca0ea3569bd600 (patch) | |
tree | 2391c23793bd94192f277c16291dd780a2399b1d | |
parent | ff83a9a0d15d3be46b3288346a1180777f1a4e41 (diff) |
drm/amd/display: Add condition to sync eDP SW status and HW status
[Why]
Need to disable EDP backlight when enter S4 with EDP only
and resume from S4 with secondary only.
[How]
Align the real hw and sw state via vBios scratch register in
function enable_accelerated_mode when resume from S4.
Signed-off-by: Lewis Huang <Lewis.Huang@amd.com>
Reviewed-by: Charlene Liu <Charlene.Liu@amd.com>
Acked-by: Leo Li <sunpeng.li@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 files changed, 120 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c b/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c index ff764da21b6f..751bb614fc0e 100644 --- a/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c +++ b/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c | |||
@@ -1884,6 +1884,8 @@ static const struct dc_vbios_funcs vbios_funcs = { | |||
1884 | 1884 | ||
1885 | .is_accelerated_mode = bios_parser_is_accelerated_mode, | 1885 | .is_accelerated_mode = bios_parser_is_accelerated_mode, |
1886 | 1886 | ||
1887 | .is_active_display = bios_is_active_display, | ||
1888 | |||
1887 | .set_scratch_critical_state = bios_parser_set_scratch_critical_state, | 1889 | .set_scratch_critical_state = bios_parser_set_scratch_critical_state, |
1888 | 1890 | ||
1889 | 1891 | ||
diff --git a/drivers/gpu/drm/amd/display/dc/bios/bios_parser_helper.c b/drivers/gpu/drm/amd/display/dc/bios/bios_parser_helper.c index d4589470985c..fdda8aa8e303 100644 --- a/drivers/gpu/drm/amd/display/dc/bios/bios_parser_helper.c +++ b/drivers/gpu/drm/amd/display/dc/bios/bios_parser_helper.c | |||
@@ -88,3 +88,96 @@ uint32_t bios_get_vga_enabled_displays( | |||
88 | return active_disp; | 88 | return active_disp; |
89 | } | 89 | } |
90 | 90 | ||
91 | bool bios_is_active_display( | ||
92 | struct dc_bios *bios, | ||
93 | enum signal_type signal, | ||
94 | const struct connector_device_tag_info *device_tag) | ||
95 | { | ||
96 | uint32_t active = 0; | ||
97 | uint32_t connected = 0; | ||
98 | uint32_t bios_scratch_0 = 0; | ||
99 | uint32_t bios_scratch_3 = 0; | ||
100 | |||
101 | switch (signal) { | ||
102 | case SIGNAL_TYPE_DVI_SINGLE_LINK: | ||
103 | case SIGNAL_TYPE_DVI_DUAL_LINK: | ||
104 | case SIGNAL_TYPE_HDMI_TYPE_A: | ||
105 | case SIGNAL_TYPE_DISPLAY_PORT: | ||
106 | case SIGNAL_TYPE_DISPLAY_PORT_MST: | ||
107 | { | ||
108 | if (device_tag->dev_id.device_type == DEVICE_TYPE_DFP) { | ||
109 | switch (device_tag->dev_id.enum_id) { | ||
110 | case 1: | ||
111 | { | ||
112 | active = ATOM_S3_DFP1_ACTIVE; | ||
113 | connected = 0x0008; //ATOM_DISPLAY_DFP1_CONNECT | ||
114 | } | ||
115 | break; | ||
116 | |||
117 | case 2: | ||
118 | { | ||
119 | active = ATOM_S3_DFP2_ACTIVE; | ||
120 | connected = 0x0080; //ATOM_DISPLAY_DFP2_CONNECT | ||
121 | } | ||
122 | break; | ||
123 | |||
124 | case 3: | ||
125 | { | ||
126 | active = ATOM_S3_DFP3_ACTIVE; | ||
127 | connected = 0x0200; //ATOM_DISPLAY_DFP3_CONNECT | ||
128 | } | ||
129 | break; | ||
130 | |||
131 | case 4: | ||
132 | { | ||
133 | active = ATOM_S3_DFP4_ACTIVE; | ||
134 | connected = 0x0400; //ATOM_DISPLAY_DFP4_CONNECT | ||
135 | } | ||
136 | break; | ||
137 | |||
138 | case 5: | ||
139 | { | ||
140 | active = ATOM_S3_DFP5_ACTIVE; | ||
141 | connected = 0x0800; //ATOM_DISPLAY_DFP5_CONNECT | ||
142 | } | ||
143 | break; | ||
144 | |||
145 | case 6: | ||
146 | { | ||
147 | active = ATOM_S3_DFP6_ACTIVE; | ||
148 | connected = 0x0040; //ATOM_DISPLAY_DFP6_CONNECT | ||
149 | } | ||
150 | break; | ||
151 | |||
152 | default: | ||
153 | break; | ||
154 | } | ||
155 | } | ||
156 | } | ||
157 | break; | ||
158 | |||
159 | case SIGNAL_TYPE_LVDS: | ||
160 | case SIGNAL_TYPE_EDP: | ||
161 | { | ||
162 | active = ATOM_S3_LCD1_ACTIVE; | ||
163 | connected = 0x0002; //ATOM_DISPLAY_LCD1_CONNECT | ||
164 | } | ||
165 | break; | ||
166 | |||
167 | default: | ||
168 | break; | ||
169 | } | ||
170 | |||
171 | |||
172 | if (bios->regs->BIOS_SCRATCH_0) /*follow up with other asic, todo*/ | ||
173 | bios_scratch_0 = REG_READ(BIOS_SCRATCH_0); | ||
174 | if (bios->regs->BIOS_SCRATCH_3) /*follow up with other asic, todo*/ | ||
175 | bios_scratch_3 = REG_READ(BIOS_SCRATCH_3); | ||
176 | |||
177 | bios_scratch_3 &= ATOM_S3_DEVICE_ACTIVE_MASK; | ||
178 | if ((active & bios_scratch_3) && (connected & bios_scratch_0)) | ||
179 | return true; | ||
180 | |||
181 | return false; | ||
182 | } | ||
183 | |||
diff --git a/drivers/gpu/drm/amd/display/dc/bios/bios_parser_helper.h b/drivers/gpu/drm/amd/display/dc/bios/bios_parser_helper.h index 75a29e68fb27..f33cac2147e3 100644 --- a/drivers/gpu/drm/amd/display/dc/bios/bios_parser_helper.h +++ b/drivers/gpu/drm/amd/display/dc/bios/bios_parser_helper.h | |||
@@ -35,6 +35,10 @@ bool bios_is_accelerated_mode(struct dc_bios *bios); | |||
35 | void bios_set_scratch_acc_mode_change(struct dc_bios *bios); | 35 | void bios_set_scratch_acc_mode_change(struct dc_bios *bios); |
36 | void bios_set_scratch_critical_state(struct dc_bios *bios, bool state); | 36 | void bios_set_scratch_critical_state(struct dc_bios *bios, bool state); |
37 | uint32_t bios_get_vga_enabled_displays(struct dc_bios *bios); | 37 | uint32_t bios_get_vga_enabled_displays(struct dc_bios *bios); |
38 | bool bios_is_active_display( | ||
39 | struct dc_bios *bios, | ||
40 | enum signal_type signal, | ||
41 | const struct connector_device_tag_info *device_tag); | ||
38 | 42 | ||
39 | #define GET_IMAGE(type, offset) ((type *) bios_get_image(&bp->base, offset, sizeof(type))) | 43 | #define GET_IMAGE(type, offset) ((type *) bios_get_image(&bp->base, offset, sizeof(type))) |
40 | 44 | ||
diff --git a/drivers/gpu/drm/amd/display/dc/dc_bios_types.h b/drivers/gpu/drm/amd/display/dc/dc_bios_types.h index 8130b95ccc53..a8b3cedf9431 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_bios_types.h +++ b/drivers/gpu/drm/amd/display/dc/dc_bios_types.h | |||
@@ -86,6 +86,10 @@ struct dc_vbios_funcs { | |||
86 | 86 | ||
87 | bool (*is_accelerated_mode)( | 87 | bool (*is_accelerated_mode)( |
88 | struct dc_bios *bios); | 88 | struct dc_bios *bios); |
89 | bool (*is_active_display)( | ||
90 | struct dc_bios *bios, | ||
91 | enum signal_type signal, | ||
92 | const struct connector_device_tag_info *device_tag); | ||
89 | void (*set_scratch_critical_state)( | 93 | void (*set_scratch_critical_state)( |
90 | struct dc_bios *bios, | 94 | struct dc_bios *bios, |
91 | bool state); | 95 | bool state); |
@@ -141,6 +145,7 @@ struct dc_vbios_funcs { | |||
141 | }; | 145 | }; |
142 | 146 | ||
143 | struct bios_registers { | 147 | struct bios_registers { |
148 | uint32_t BIOS_SCRATCH_0; | ||
144 | uint32_t BIOS_SCRATCH_3; | 149 | uint32_t BIOS_SCRATCH_3; |
145 | uint32_t BIOS_SCRATCH_6; | 150 | uint32_t BIOS_SCRATCH_6; |
146 | }; | 151 | }; |
diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c index 8873a6092052..4789270c29d9 100644 --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c | |||
@@ -1546,6 +1546,7 @@ void dce110_enable_accelerated_mode(struct dc *dc, struct dc_state *context) | |||
1546 | int i; | 1546 | int i; |
1547 | struct dc_link *edp_link_to_turnoff = NULL; | 1547 | struct dc_link *edp_link_to_turnoff = NULL; |
1548 | struct dc_link *edp_link = get_link_for_edp(dc); | 1548 | struct dc_link *edp_link = get_link_for_edp(dc); |
1549 | struct dc_bios *bios = dc->ctx->dc_bios; | ||
1549 | bool can_edp_fast_boot_optimize = false; | 1550 | bool can_edp_fast_boot_optimize = false; |
1550 | bool apply_edp_fast_boot_optimization = false; | 1551 | bool apply_edp_fast_boot_optimization = false; |
1551 | 1552 | ||
@@ -1572,6 +1573,20 @@ void dce110_enable_accelerated_mode(struct dc *dc, struct dc_state *context) | |||
1572 | if (context->streams[i]->signal == SIGNAL_TYPE_EDP) { | 1573 | if (context->streams[i]->signal == SIGNAL_TYPE_EDP) { |
1573 | context->streams[i]->apply_edp_fast_boot_optimization = true; | 1574 | context->streams[i]->apply_edp_fast_boot_optimization = true; |
1574 | apply_edp_fast_boot_optimization = true; | 1575 | apply_edp_fast_boot_optimization = true; |
1576 | |||
1577 | /* When after S4 and S5, vbios may post edp and previous dpms_off | ||
1578 | * doesn't make sense. | ||
1579 | * Update dpms_off state to align hw and sw state via check | ||
1580 | * vBios scratch register. | ||
1581 | */ | ||
1582 | if (bios->funcs->is_active_display) { | ||
1583 | const struct connector_device_tag_info *device_tag = &(edp_link->device_tag); | ||
1584 | |||
1585 | if (bios->funcs->is_active_display(bios, | ||
1586 | context->streams[i]->signal, | ||
1587 | device_tag)) | ||
1588 | context->streams[i]->dpms_off = false; | ||
1589 | } | ||
1575 | } | 1590 | } |
1576 | } | 1591 | } |
1577 | } | 1592 | } |
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c index acb917ddaba9..47dbe4bb294a 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c | |||
@@ -438,6 +438,7 @@ static const struct dcn_optc_mask tg_mask = { | |||
438 | 438 | ||
439 | 439 | ||
440 | static const struct bios_registers bios_regs = { | 440 | static const struct bios_registers bios_regs = { |
441 | NBIO_SR(BIOS_SCRATCH_0), | ||
441 | NBIO_SR(BIOS_SCRATCH_3), | 442 | NBIO_SR(BIOS_SCRATCH_3), |
442 | NBIO_SR(BIOS_SCRATCH_6) | 443 | NBIO_SR(BIOS_SCRATCH_6) |
443 | }; | 444 | }; |