Skip to content

Commit 6465964

Browse files
committed
drm/dp: Don't read back backlight mode in drm_edp_backlight_enable()
As it turns out, apparently some machines will actually leave additional backlight functionality like dynamic backlight control on before the OS loads. Currently we don't take care to disable unsupported features when writing back the backlight mode, which can lead to some rather strange looking behavior when adjusting the backlight. So, let's fix this by just not reading back the current backlight mode on initial enable. I don't think there should really be any downsides to this, and this will ensure we don't leave any unsupported functionality enabled. This should fix at least one (but not all) of the issues seen with DPCD backlight support on fi-bdw-samus v5: * Just avoid reading back DPCD register - Doug Anderson Signed-off-by: Lyude Paul <[email protected]> Fixes: 867cf9c ("drm/dp: Extract i915's eDP backlight code into DRM helpers") Reviewed-by: Douglas Anderson <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent f5dee12 commit 6465964

File tree

1 file changed

+12
-28
lines changed

1 file changed

+12
-28
lines changed

drivers/gpu/drm/drm_dp_helper.c

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3363,27 +3363,13 @@ int drm_edp_backlight_enable(struct drm_dp_aux *aux, const struct drm_edp_backli
33633363
const u16 level)
33643364
{
33653365
int ret;
3366-
u8 dpcd_buf, new_dpcd_buf;
3366+
u8 dpcd_buf = DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD;
33673367

3368-
ret = drm_dp_dpcd_readb(aux, DP_EDP_BACKLIGHT_MODE_SET_REGISTER, &dpcd_buf);
3369-
if (ret != 1) {
3370-
drm_dbg_kms(aux->drm_dev,
3371-
"%s: Failed to read backlight mode: %d\n", aux->name, ret);
3372-
return ret < 0 ? ret : -EIO;
3373-
}
3374-
3375-
new_dpcd_buf = dpcd_buf;
3376-
3377-
if ((dpcd_buf & DP_EDP_BACKLIGHT_CONTROL_MODE_MASK) != DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD) {
3378-
new_dpcd_buf &= ~DP_EDP_BACKLIGHT_CONTROL_MODE_MASK;
3379-
new_dpcd_buf |= DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD;
3380-
3381-
if (bl->pwmgen_bit_count) {
3382-
ret = drm_dp_dpcd_writeb(aux, DP_EDP_PWMGEN_BIT_COUNT, bl->pwmgen_bit_count);
3383-
if (ret != 1)
3384-
drm_dbg_kms(aux->drm_dev, "%s: Failed to write aux pwmgen bit count: %d\n",
3385-
aux->name, ret);
3386-
}
3368+
if (bl->pwmgen_bit_count) {
3369+
ret = drm_dp_dpcd_writeb(aux, DP_EDP_PWMGEN_BIT_COUNT, bl->pwmgen_bit_count);
3370+
if (ret != 1)
3371+
drm_dbg_kms(aux->drm_dev, "%s: Failed to write aux pwmgen bit count: %d\n",
3372+
aux->name, ret);
33873373
}
33883374

33893375
if (bl->pwm_freq_pre_divider) {
@@ -3393,16 +3379,14 @@ int drm_edp_backlight_enable(struct drm_dp_aux *aux, const struct drm_edp_backli
33933379
"%s: Failed to write aux backlight frequency: %d\n",
33943380
aux->name, ret);
33953381
else
3396-
new_dpcd_buf |= DP_EDP_BACKLIGHT_FREQ_AUX_SET_ENABLE;
3382+
dpcd_buf |= DP_EDP_BACKLIGHT_FREQ_AUX_SET_ENABLE;
33973383
}
33983384

3399-
if (new_dpcd_buf != dpcd_buf) {
3400-
ret = drm_dp_dpcd_writeb(aux, DP_EDP_BACKLIGHT_MODE_SET_REGISTER, new_dpcd_buf);
3401-
if (ret != 1) {
3402-
drm_dbg_kms(aux->drm_dev, "%s: Failed to write aux backlight mode: %d\n",
3403-
aux->name, ret);
3404-
return ret < 0 ? ret : -EIO;
3405-
}
3385+
ret = drm_dp_dpcd_writeb(aux, DP_EDP_BACKLIGHT_MODE_SET_REGISTER, dpcd_buf);
3386+
if (ret != 1) {
3387+
drm_dbg_kms(aux->drm_dev, "%s: Failed to write aux backlight mode: %d\n",
3388+
aux->name, ret);
3389+
return ret < 0 ? ret : -EIO;
34063390
}
34073391

34083392
ret = drm_edp_backlight_set_level(aux, bl, level);

0 commit comments

Comments
 (0)