Commit 837f9324 authored by Lyude Paul's avatar Lyude Paul

drm/i915/dpcd_bl: Print return codes for VESA backlight failures

Also, stop printing the DPCD register that failed, and just describe it
instead. Saves us from having to look up each register offset when reading
through kernel logs (plus, DPCD dumping with drm.debug |= 0x100 will give
us that anyway).
Signed-off-by: default avatarLyude Paul <lyude@redhat.com>
Reviewed-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210514181504.565252-8-lyude@redhat.com
parent 17917ff6
...@@ -274,14 +274,12 @@ static bool intel_dp_aux_vesa_backlight_dpcd_mode(struct intel_connector *connec ...@@ -274,14 +274,12 @@ static bool intel_dp_aux_vesa_backlight_dpcd_mode(struct intel_connector *connec
{ {
struct intel_dp *intel_dp = intel_attached_dp(connector); struct intel_dp *intel_dp = intel_attached_dp(connector);
struct drm_i915_private *i915 = dp_to_i915(intel_dp); struct drm_i915_private *i915 = dp_to_i915(intel_dp);
int ret;
u8 mode_reg; u8 mode_reg;
if (drm_dp_dpcd_readb(&intel_dp->aux, ret = drm_dp_dpcd_readb(&intel_dp->aux, DP_EDP_BACKLIGHT_MODE_SET_REGISTER, &mode_reg);
DP_EDP_BACKLIGHT_MODE_SET_REGISTER, if (ret != 1) {
&mode_reg) != 1) { drm_dbg_kms(&i915->drm, "Failed to read backlight mode: %d\n", ret);
drm_dbg_kms(&i915->drm,
"Failed to read the DPCD register 0x%x\n",
DP_EDP_BACKLIGHT_MODE_SET_REGISTER);
return false; return false;
} }
...@@ -297,6 +295,7 @@ static u32 intel_dp_aux_vesa_get_backlight(struct intel_connector *connector, en ...@@ -297,6 +295,7 @@ static u32 intel_dp_aux_vesa_get_backlight(struct intel_connector *connector, en
{ {
struct intel_dp *intel_dp = intel_attached_dp(connector); struct intel_dp *intel_dp = intel_attached_dp(connector);
struct drm_i915_private *i915 = dp_to_i915(intel_dp); struct drm_i915_private *i915 = dp_to_i915(intel_dp);
int ret;
u8 read_val[2] = { 0x0 }; u8 read_val[2] = { 0x0 };
u16 level = 0; u16 level = 0;
...@@ -307,10 +306,10 @@ static u32 intel_dp_aux_vesa_get_backlight(struct intel_connector *connector, en ...@@ -307,10 +306,10 @@ static u32 intel_dp_aux_vesa_get_backlight(struct intel_connector *connector, en
if (!intel_dp_aux_vesa_backlight_dpcd_mode(connector)) if (!intel_dp_aux_vesa_backlight_dpcd_mode(connector))
return connector->panel.backlight.max; return connector->panel.backlight.max;
if (drm_dp_dpcd_read(&intel_dp->aux, DP_EDP_BACKLIGHT_BRIGHTNESS_MSB, &read_val, ret = drm_dp_dpcd_read(&intel_dp->aux, DP_EDP_BACKLIGHT_BRIGHTNESS_MSB, &read_val,
sizeof(read_val)) != sizeof(read_val)) { sizeof(read_val));
drm_dbg_kms(&i915->drm, "Failed to read DPCD register 0x%x\n", if (ret != sizeof(read_val)) {
DP_EDP_BACKLIGHT_BRIGHTNESS_MSB); drm_dbg_kms(&i915->drm, "Failed to read brightness level: %d\n", ret);
return 0; return 0;
} }
...@@ -333,6 +332,7 @@ intel_dp_aux_vesa_set_backlight(const struct drm_connector_state *conn_state, ...@@ -333,6 +332,7 @@ intel_dp_aux_vesa_set_backlight(const struct drm_connector_state *conn_state,
struct intel_connector *connector = to_intel_connector(conn_state->connector); struct intel_connector *connector = to_intel_connector(conn_state->connector);
struct intel_dp *intel_dp = intel_attached_dp(connector); struct intel_dp *intel_dp = intel_attached_dp(connector);
struct drm_i915_private *i915 = dp_to_i915(intel_dp); struct drm_i915_private *i915 = dp_to_i915(intel_dp);
int ret;
u8 vals[2] = { 0x0 }; u8 vals[2] = { 0x0 };
/* Write the MSB and/or LSB */ /* Write the MSB and/or LSB */
...@@ -343,10 +343,10 @@ intel_dp_aux_vesa_set_backlight(const struct drm_connector_state *conn_state, ...@@ -343,10 +343,10 @@ intel_dp_aux_vesa_set_backlight(const struct drm_connector_state *conn_state,
vals[0] = level; vals[0] = level;
} }
if (drm_dp_dpcd_write(&intel_dp->aux, DP_EDP_BACKLIGHT_BRIGHTNESS_MSB, vals, ret = drm_dp_dpcd_write(&intel_dp->aux, DP_EDP_BACKLIGHT_BRIGHTNESS_MSB, vals,
sizeof(vals)) != sizeof(vals)) { sizeof(vals));
drm_dbg_kms(&i915->drm, if (ret != sizeof(vals)) {
"Failed to write aux backlight level\n"); drm_dbg_kms(&i915->drm, "Failed to write aux backlight level: %d\n", ret);
return; return;
} }
} }
...@@ -355,26 +355,28 @@ static void set_vesa_backlight_enable(struct intel_connector *connector, bool en ...@@ -355,26 +355,28 @@ static void set_vesa_backlight_enable(struct intel_connector *connector, bool en
{ {
struct intel_dp *intel_dp = intel_attached_dp(connector); struct intel_dp *intel_dp = intel_attached_dp(connector);
struct drm_i915_private *i915 = dp_to_i915(intel_dp); struct drm_i915_private *i915 = dp_to_i915(intel_dp);
int ret;
u8 reg_val = 0; u8 reg_val = 0;
/* Early return when display use other mechanism to enable backlight. */ /* Early return when display use other mechanism to enable backlight. */
if (!connector->panel.backlight.edp.vesa.aux_enable) if (!connector->panel.backlight.edp.vesa.aux_enable)
return; return;
if (drm_dp_dpcd_readb(&intel_dp->aux, DP_EDP_DISPLAY_CONTROL_REGISTER, &reg_val) != 1) { ret = drm_dp_dpcd_readb(&intel_dp->aux, DP_EDP_DISPLAY_CONTROL_REGISTER, &reg_val);
drm_dbg_kms(&i915->drm, "Failed to read DPCD register 0x%x\n", if (ret != 1) {
DP_EDP_DISPLAY_CONTROL_REGISTER); drm_dbg_kms(&i915->drm, "Failed to read eDP display control register: %d\n", ret);
return; return;
} }
if (enable) if (enable)
reg_val |= DP_EDP_BACKLIGHT_ENABLE; reg_val |= DP_EDP_BACKLIGHT_ENABLE;
else else
reg_val &= ~(DP_EDP_BACKLIGHT_ENABLE); reg_val &= ~(DP_EDP_BACKLIGHT_ENABLE);
if (drm_dp_dpcd_writeb(&intel_dp->aux, DP_EDP_DISPLAY_CONTROL_REGISTER, ret = drm_dp_dpcd_writeb(&intel_dp->aux, DP_EDP_DISPLAY_CONTROL_REGISTER, reg_val);
reg_val) != 1) { if (ret != 1) {
drm_dbg_kms(&i915->drm, "Failed to %s aux backlight\n", drm_dbg_kms(&i915->drm, "Failed to %s aux backlight: %d\n",
enabledisable(enable)); enabledisable(enable), ret);
} }
} }
...@@ -386,13 +388,13 @@ intel_dp_aux_vesa_enable_backlight(const struct intel_crtc_state *crtc_state, ...@@ -386,13 +388,13 @@ intel_dp_aux_vesa_enable_backlight(const struct intel_crtc_state *crtc_state,
struct intel_dp *intel_dp = intel_attached_dp(connector); struct intel_dp *intel_dp = intel_attached_dp(connector);
struct drm_i915_private *i915 = dp_to_i915(intel_dp); struct drm_i915_private *i915 = dp_to_i915(intel_dp);
struct intel_panel *panel = &connector->panel; struct intel_panel *panel = &connector->panel;
int ret;
u8 dpcd_buf, new_dpcd_buf; u8 dpcd_buf, new_dpcd_buf;
u8 pwmgen_bit_count = panel->backlight.edp.vesa.pwmgen_bit_count; u8 pwmgen_bit_count = panel->backlight.edp.vesa.pwmgen_bit_count;
if (drm_dp_dpcd_readb(&intel_dp->aux, ret = drm_dp_dpcd_readb(&intel_dp->aux, DP_EDP_BACKLIGHT_MODE_SET_REGISTER, &dpcd_buf);
DP_EDP_BACKLIGHT_MODE_SET_REGISTER, &dpcd_buf) != 1) { if (ret != 1) {
drm_dbg_kms(&i915->drm, "Failed to read DPCD register 0x%x\n", drm_dbg_kms(&i915->drm, "Failed to read backlight mode: %d\n", ret);
DP_EDP_BACKLIGHT_MODE_SET_REGISTER);
return; return;
} }
...@@ -402,24 +404,26 @@ intel_dp_aux_vesa_enable_backlight(const struct intel_crtc_state *crtc_state, ...@@ -402,24 +404,26 @@ intel_dp_aux_vesa_enable_backlight(const struct intel_crtc_state *crtc_state,
new_dpcd_buf &= ~DP_EDP_BACKLIGHT_CONTROL_MODE_MASK; new_dpcd_buf &= ~DP_EDP_BACKLIGHT_CONTROL_MODE_MASK;
new_dpcd_buf |= DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD; new_dpcd_buf |= DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD;
if (drm_dp_dpcd_writeb(&intel_dp->aux, DP_EDP_PWMGEN_BIT_COUNT, ret = drm_dp_dpcd_writeb(&intel_dp->aux, DP_EDP_PWMGEN_BIT_COUNT, pwmgen_bit_count);
pwmgen_bit_count) != 1) if (ret != 1)
drm_dbg_kms(&i915->drm, drm_dbg_kms(&i915->drm, "Failed to write aux pwmgen bit count: %d\n", ret);
"Failed to write aux pwmgen bit count\n");
} }
if (panel->backlight.edp.vesa.pwm_freq_pre_divider) { if (panel->backlight.edp.vesa.pwm_freq_pre_divider) {
if (drm_dp_dpcd_writeb(&intel_dp->aux, DP_EDP_BACKLIGHT_FREQ_SET, ret = drm_dp_dpcd_writeb(&intel_dp->aux, DP_EDP_BACKLIGHT_FREQ_SET,
panel->backlight.edp.vesa.pwm_freq_pre_divider) == 1) panel->backlight.edp.vesa.pwm_freq_pre_divider);
if (ret == 1)
new_dpcd_buf |= DP_EDP_BACKLIGHT_FREQ_AUX_SET_ENABLE; new_dpcd_buf |= DP_EDP_BACKLIGHT_FREQ_AUX_SET_ENABLE;
else else
drm_dbg_kms(&i915->drm, "Failed to write aux backlight frequency\n"); drm_dbg_kms(&i915->drm, "Failed to write aux backlight frequency: %d\n",
ret);
} }
if (new_dpcd_buf != dpcd_buf) { if (new_dpcd_buf != dpcd_buf) {
if (drm_dp_dpcd_writeb(&intel_dp->aux, DP_EDP_BACKLIGHT_MODE_SET_REGISTER, ret = drm_dp_dpcd_writeb(&intel_dp->aux, DP_EDP_BACKLIGHT_MODE_SET_REGISTER,
new_dpcd_buf) != 1) new_dpcd_buf);
drm_dbg_kms(&i915->drm, "Failed to write aux backlight mode\n"); if (ret != 1)
drm_dbg_kms(&i915->drm, "Failed to write aux backlight mode: %d\n", ret);
} }
intel_dp_aux_vesa_set_backlight(conn_state, level); intel_dp_aux_vesa_set_backlight(conn_state, level);
...@@ -446,11 +450,12 @@ static u32 intel_dp_aux_vesa_calc_max_backlight(struct intel_connector *connecto ...@@ -446,11 +450,12 @@ static u32 intel_dp_aux_vesa_calc_max_backlight(struct intel_connector *connecto
struct intel_dp *intel_dp = intel_attached_dp(connector); struct intel_dp *intel_dp = intel_attached_dp(connector);
struct intel_panel *panel = &connector->panel; struct intel_panel *panel = &connector->panel;
u32 max_backlight = 0; u32 max_backlight = 0;
int freq, fxp, fxp_min, fxp_max, fxp_actual, f = 1; int ret, freq, fxp, fxp_min, fxp_max, fxp_actual, f = 1;
u8 pn, pn_min, pn_max; u8 pn, pn_min, pn_max;
if (drm_dp_dpcd_readb(&intel_dp->aux, DP_EDP_PWMGEN_BIT_COUNT, &pn) != 1) { ret = drm_dp_dpcd_readb(&intel_dp->aux, DP_EDP_PWMGEN_BIT_COUNT, &pn);
drm_dbg_kms(&i915->drm, "Failed to read pwmgen bit count cap\n"); if (ret != 1) {
drm_dbg_kms(&i915->drm, "Failed to read pwmgen bit count cap: %d\n", ret);
return 0; return 0;
} }
...@@ -479,16 +484,14 @@ static u32 intel_dp_aux_vesa_calc_max_backlight(struct intel_connector *connecto ...@@ -479,16 +484,14 @@ static u32 intel_dp_aux_vesa_calc_max_backlight(struct intel_connector *connecto
* - FxP is within 25% of desired value. * - FxP is within 25% of desired value.
* Note: 25% is arbitrary value and may need some tweak. * Note: 25% is arbitrary value and may need some tweak.
*/ */
if (drm_dp_dpcd_readb(&intel_dp->aux, ret = drm_dp_dpcd_readb(&intel_dp->aux, DP_EDP_PWMGEN_BIT_COUNT_CAP_MIN, &pn_min);
DP_EDP_PWMGEN_BIT_COUNT_CAP_MIN, &pn_min) != 1) { if (ret != 1) {
drm_dbg_kms(&i915->drm, drm_dbg_kms(&i915->drm, "Failed to read pwmgen bit count cap min: %d\n", ret);
"Failed to read pwmgen bit count cap min\n");
return max_backlight; return max_backlight;
} }
if (drm_dp_dpcd_readb(&intel_dp->aux, ret = drm_dp_dpcd_readb(&intel_dp->aux, DP_EDP_PWMGEN_BIT_COUNT_CAP_MAX, &pn_max);
DP_EDP_PWMGEN_BIT_COUNT_CAP_MAX, &pn_max) != 1) { if (ret != 1) {
drm_dbg_kms(&i915->drm, drm_dbg_kms(&i915->drm, "Failed to read pwmgen bit count cap max: %d\n", ret);
"Failed to read pwmgen bit count cap max\n");
return max_backlight; return max_backlight;
} }
pn_min &= DP_EDP_PWMGEN_BIT_COUNT_MASK; pn_min &= DP_EDP_PWMGEN_BIT_COUNT_MASK;
...@@ -512,9 +515,9 @@ static u32 intel_dp_aux_vesa_calc_max_backlight(struct intel_connector *connecto ...@@ -512,9 +515,9 @@ static u32 intel_dp_aux_vesa_calc_max_backlight(struct intel_connector *connecto
} }
drm_dbg_kms(&i915->drm, "Using eDP pwmgen bit count of %d\n", pn); drm_dbg_kms(&i915->drm, "Using eDP pwmgen bit count of %d\n", pn);
if (drm_dp_dpcd_writeb(&intel_dp->aux, DP_EDP_PWMGEN_BIT_COUNT, pn) != 1) { ret = drm_dp_dpcd_writeb(&intel_dp->aux, DP_EDP_PWMGEN_BIT_COUNT, pn);
drm_dbg_kms(&i915->drm, if (ret != 1) {
"Failed to write aux pwmgen bit count\n"); drm_dbg_kms(&i915->drm, "Failed to write aux pwmgen bit count: %d\n", ret);
return max_backlight; return max_backlight;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment