Skip to content

Instantly share code, notes, and snippets.

@arno01
Last active January 17, 2019 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arno01/8115ef124fe7f42bbf1c317892013e86 to your computer and use it in GitHub Desktop.
Save arno01/8115ef124fe7f42bbf1c317892013e86 to your computer and use it in GitHub Desktop.
Patches for fixing "black screen" issue on MBP with AMD GPU on Linux >=4.18
diff -Nur linux-4.19.2.orig/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c linux-4.19.2/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
--- linux-4.19.2.orig/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 2018-11-13 20:09:00.000000000 +0100
+++ linux-4.19.2/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 2018-11-20 11:49:40.834148553 +0100
@@ -626,6 +626,11 @@
"dither",
amdgpu_dither_enum_list, sz);
+ adev->mode_info.max_bpc_property =
+ drm_property_create_range(adev->ddev, 0, "max_bpc", 8, 16);
+ if (!adev->mode_info.max_bpc_property)
+ return -ENOMEM;
+
return 0;
}
diff -Nur linux-4.19.2.orig/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h linux-4.19.2/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
--- linux-4.19.2.orig/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h 2018-11-13 20:09:00.000000000 +0100
+++ linux-4.19.2/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h 2018-11-20 11:50:33.299062353 +0100
@@ -339,6 +339,8 @@
struct drm_property *audio_property;
/* FMT dithering */
struct drm_property *dither_property;
+ /* maximum number of bits per channel for monitor color */
+ struct drm_property *max_bpc_property;
/* hardcoded DFP edid from BIOS */
struct edid *bios_hardcoded_edid;
int bios_hardcoded_edid_size;
diff -Nur linux-4.19.2.orig/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c linux-4.19.2/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
--- linux-4.19.2.orig/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 2018-11-13 20:09:00.000000000 +0100
+++ linux-4.19.2/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 2018-11-20 11:59:38.655483130 +0100
@@ -2213,8 +2213,14 @@
static enum dc_color_depth
convert_color_depth_from_display_info(const struct drm_connector *connector)
{
+ struct dm_connector_state *dm_conn_state =
+ to_dm_connector_state(connector->state);
uint32_t bpc = connector->display_info.bpc;
+ if (dm_conn_state && bpc > dm_conn_state->max_bpc)
+ /* Round down to nearest even number. */
+ bpc = dm_conn_state->max_bpc - (dm_conn_state->max_bpc & 1);
+
switch (bpc) {
case 0:
/* Temporary Work around, DRM don't parse color depth for
@@ -2796,6 +2802,9 @@
} else if (property == adev->mode_info.underscan_property) {
dm_new_state->underscan_enable = val;
ret = 0;
+ } else if (property == adev->mode_info.max_bpc_property) {
+ dm_new_state->max_bpc = val;
+ ret = 0;
}
return ret;
@@ -2838,6 +2847,9 @@
} else if (property == adev->mode_info.underscan_property) {
*val = dm_state->underscan_enable;
ret = 0;
+ } else if (property == adev->mode_info.max_bpc_property) {
+ *val = dm_state->max_bpc;
+ ret = 0;
}
return ret;
}
@@ -3658,6 +3670,9 @@
drm_object_attach_property(&aconnector->base.base,
adev->mode_info.underscan_vborder_property,
0);
+ drm_object_attach_property(&aconnector->base.base,
+ adev->mode_info.max_bpc_property,
+ 0);
}
diff -Nur linux-4.19.2.orig/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h linux-4.19.2/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
--- linux-4.19.2.orig/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h 2018-11-13 20:09:00.000000000 +0100
+++ linux-4.19.2/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h 2018-11-20 11:56:09.625271867 +0100
@@ -215,6 +215,7 @@
enum amdgpu_rmx_type scaling;
uint8_t underscan_vborder;
uint8_t underscan_hborder;
+ uint8_t max_bpc;
bool underscan_enable;
struct mod_freesync_user_enable user_enable;
bool freesync_capable;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment