Re: [PATCH v7 1/5] drm/i915: Pass port to intel_panel_bl_funcs.get()
On Fri, 15 Jan 2021, Jani Nikula wrote: > On Thu, 14 Jan 2021, Lyude Paul wrote: >> In the next commit where we split PWM related backlight functions from >> higher-level backlight functions, we'll want to be able to retrieve the >> backlight level for the current display panel from the >> intel_panel_bl_funcs->setup() function using pwm_funcs->get(). Since >> intel_panel_bl_funcs->setup() is called before we've fully read in the >> current hardware state into our atomic state, we can't grab atomic >> modesetting locks safely anyway in intel_panel_bl_funcs->setup(), and some >> PWM backlight functions (vlv_get_backlight() in particular) require knowing >> the currently used pipe we need to be able to discern the current display >> pipe through other means. Luckily, we're already passing the current >> display pipe to intel_panel_bl_funcs->setup() so all we have to do in order >> to achieve this is pass down that parameter to intel_panel_bl_funcs->get(). >> >> So, fix this by accepting an additional pipe parameter in >> intel_panel_bl_funcs->get(), and leave figuring out the current display >> pipe up to the caller. >> >> Signed-off-by: Lyude Paul > > Much neater than anything I suggested! > > Reviewed-by: Jani Nikula And pushed this one to drm-intel-next, thanks for the patch. BR, Jani. > >> --- >> .../drm/i915/display/intel_display_types.h| 2 +- >> .../drm/i915/display/intel_dp_aux_backlight.c | 4 +- >> .../i915/display/intel_dsi_dcs_backlight.c| 2 +- >> drivers/gpu/drm/i915/display/intel_panel.c| 40 --- >> 4 files changed, 21 insertions(+), 27 deletions(-) >> >> diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h >> b/drivers/gpu/drm/i915/display/intel_display_types.h >> index 585bb1edea04..b1f4ec144207 100644 >> --- a/drivers/gpu/drm/i915/display/intel_display_types.h >> +++ b/drivers/gpu/drm/i915/display/intel_display_types.h >> @@ -228,7 +228,7 @@ struct intel_encoder { >> struct intel_panel_bl_funcs { >> /* Connector and platform specific backlight functions */ >> int (*setup)(struct intel_connector *connector, enum pipe pipe); >> -u32 (*get)(struct intel_connector *connector); >> +u32 (*get)(struct intel_connector *connector, enum pipe pipe); >> void (*set)(const struct drm_connector_state *conn_state, u32 level); >> void (*disable)(const struct drm_connector_state *conn_state, u32 >> level); >> void (*enable)(const struct intel_crtc_state *crtc_state, >> diff --git a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c >> b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c >> index 9775f33d1aac..de764dae1e66 100644 >> --- a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c >> +++ b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c >> @@ -128,7 +128,7 @@ static bool intel_dp_aux_vesa_backlight_dpcd_mode(struct >> intel_connector *connec >> * Read the current backlight value from DPCD register(s) based >> * on if 8-bit(MSB) or 16-bit(MSB and LSB) values are supported >> */ >> -static u32 intel_dp_aux_vesa_get_backlight(struct intel_connector >> *connector) >> +static u32 intel_dp_aux_vesa_get_backlight(struct intel_connector >> *connector, enum pipe unused) >> { >> struct intel_dp *intel_dp = intel_attached_dp(connector); >> struct drm_i915_private *i915 = dp_to_i915(intel_dp); >> @@ -381,7 +381,7 @@ static int intel_dp_aux_vesa_setup_backlight(struct >> intel_connector *connector, >> return -ENODEV; >> >> panel->backlight.min = 0; >> -panel->backlight.level = intel_dp_aux_vesa_get_backlight(connector); >> +panel->backlight.level = intel_dp_aux_vesa_get_backlight(connector, >> pipe); >> panel->backlight.enabled = >> intel_dp_aux_vesa_backlight_dpcd_mode(connector) && >> panel->backlight.level != 0; >> >> diff --git a/drivers/gpu/drm/i915/display/intel_dsi_dcs_backlight.c >> b/drivers/gpu/drm/i915/display/intel_dsi_dcs_backlight.c >> index 88628764956d..584c14c4cbd0 100644 >> --- a/drivers/gpu/drm/i915/display/intel_dsi_dcs_backlight.c >> +++ b/drivers/gpu/drm/i915/display/intel_dsi_dcs_backlight.c >> @@ -43,7 +43,7 @@ >> >> #define PANEL_PWM_MAX_VALUE 0xFF >> >> -static u32 dcs_get_backlight(struct intel_connector *connector) >> +static u32 dcs_get_backlight(struct intel_connector *connector, enum pipe >> unused) >> { >> struct intel_encoder *encoder = intel_attached_encoder(connector); >> struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder); >> diff --git a/drivers/gpu/drm/i915/display/intel_panel.c >> b/drivers/gpu/drm/i915/display/intel_panel.c >> index 7a4239d1c241..7587aaefc7a0 100644 >> --- a/drivers/gpu/drm/i915/display/intel_panel.c >> +++ b/drivers/gpu/drm/i915/display/intel_panel.c >> @@ -530,21 +530,21 @@ static u32 intel_panel_compute_brightness(struct >> intel_connector *connector, >> return val; >> } >> >> -static u32 lpt_get_backlight(struct
Re: [PATCH v7 1/5] drm/i915: Pass port to intel_panel_bl_funcs.get()
On Thu, 14 Jan 2021, Lyude Paul wrote: > In the next commit where we split PWM related backlight functions from > higher-level backlight functions, we'll want to be able to retrieve the > backlight level for the current display panel from the > intel_panel_bl_funcs->setup() function using pwm_funcs->get(). Since > intel_panel_bl_funcs->setup() is called before we've fully read in the > current hardware state into our atomic state, we can't grab atomic > modesetting locks safely anyway in intel_panel_bl_funcs->setup(), and some > PWM backlight functions (vlv_get_backlight() in particular) require knowing > the currently used pipe we need to be able to discern the current display > pipe through other means. Luckily, we're already passing the current > display pipe to intel_panel_bl_funcs->setup() so all we have to do in order > to achieve this is pass down that parameter to intel_panel_bl_funcs->get(). > > So, fix this by accepting an additional pipe parameter in > intel_panel_bl_funcs->get(), and leave figuring out the current display > pipe up to the caller. > > Signed-off-by: Lyude Paul Much neater than anything I suggested! Reviewed-by: Jani Nikula > --- > .../drm/i915/display/intel_display_types.h| 2 +- > .../drm/i915/display/intel_dp_aux_backlight.c | 4 +- > .../i915/display/intel_dsi_dcs_backlight.c| 2 +- > drivers/gpu/drm/i915/display/intel_panel.c| 40 --- > 4 files changed, 21 insertions(+), 27 deletions(-) > > diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h > b/drivers/gpu/drm/i915/display/intel_display_types.h > index 585bb1edea04..b1f4ec144207 100644 > --- a/drivers/gpu/drm/i915/display/intel_display_types.h > +++ b/drivers/gpu/drm/i915/display/intel_display_types.h > @@ -228,7 +228,7 @@ struct intel_encoder { > struct intel_panel_bl_funcs { > /* Connector and platform specific backlight functions */ > int (*setup)(struct intel_connector *connector, enum pipe pipe); > - u32 (*get)(struct intel_connector *connector); > + u32 (*get)(struct intel_connector *connector, enum pipe pipe); > void (*set)(const struct drm_connector_state *conn_state, u32 level); > void (*disable)(const struct drm_connector_state *conn_state, u32 > level); > void (*enable)(const struct intel_crtc_state *crtc_state, > diff --git a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c > b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c > index 9775f33d1aac..de764dae1e66 100644 > --- a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c > +++ b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c > @@ -128,7 +128,7 @@ static bool intel_dp_aux_vesa_backlight_dpcd_mode(struct > intel_connector *connec > * Read the current backlight value from DPCD register(s) based > * on if 8-bit(MSB) or 16-bit(MSB and LSB) values are supported > */ > -static u32 intel_dp_aux_vesa_get_backlight(struct intel_connector *connector) > +static u32 intel_dp_aux_vesa_get_backlight(struct intel_connector > *connector, enum pipe unused) > { > struct intel_dp *intel_dp = intel_attached_dp(connector); > struct drm_i915_private *i915 = dp_to_i915(intel_dp); > @@ -381,7 +381,7 @@ static int intel_dp_aux_vesa_setup_backlight(struct > intel_connector *connector, > return -ENODEV; > > panel->backlight.min = 0; > - panel->backlight.level = intel_dp_aux_vesa_get_backlight(connector); > + panel->backlight.level = intel_dp_aux_vesa_get_backlight(connector, > pipe); > panel->backlight.enabled = > intel_dp_aux_vesa_backlight_dpcd_mode(connector) && > panel->backlight.level != 0; > > diff --git a/drivers/gpu/drm/i915/display/intel_dsi_dcs_backlight.c > b/drivers/gpu/drm/i915/display/intel_dsi_dcs_backlight.c > index 88628764956d..584c14c4cbd0 100644 > --- a/drivers/gpu/drm/i915/display/intel_dsi_dcs_backlight.c > +++ b/drivers/gpu/drm/i915/display/intel_dsi_dcs_backlight.c > @@ -43,7 +43,7 @@ > > #define PANEL_PWM_MAX_VALUE 0xFF > > -static u32 dcs_get_backlight(struct intel_connector *connector) > +static u32 dcs_get_backlight(struct intel_connector *connector, enum pipe > unused) > { > struct intel_encoder *encoder = intel_attached_encoder(connector); > struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder); > diff --git a/drivers/gpu/drm/i915/display/intel_panel.c > b/drivers/gpu/drm/i915/display/intel_panel.c > index 7a4239d1c241..7587aaefc7a0 100644 > --- a/drivers/gpu/drm/i915/display/intel_panel.c > +++ b/drivers/gpu/drm/i915/display/intel_panel.c > @@ -530,21 +530,21 @@ static u32 intel_panel_compute_brightness(struct > intel_connector *connector, > return val; > } > > -static u32 lpt_get_backlight(struct intel_connector *connector) > +static u32 lpt_get_backlight(struct intel_connector *connector, enum pipe > unused) > { > struct drm_i915_private *dev_priv = to_i915(connector->base.dev); > > return
[PATCH v7 1/5] drm/i915: Pass port to intel_panel_bl_funcs.get()
In the next commit where we split PWM related backlight functions from higher-level backlight functions, we'll want to be able to retrieve the backlight level for the current display panel from the intel_panel_bl_funcs->setup() function using pwm_funcs->get(). Since intel_panel_bl_funcs->setup() is called before we've fully read in the current hardware state into our atomic state, we can't grab atomic modesetting locks safely anyway in intel_panel_bl_funcs->setup(), and some PWM backlight functions (vlv_get_backlight() in particular) require knowing the currently used pipe we need to be able to discern the current display pipe through other means. Luckily, we're already passing the current display pipe to intel_panel_bl_funcs->setup() so all we have to do in order to achieve this is pass down that parameter to intel_panel_bl_funcs->get(). So, fix this by accepting an additional pipe parameter in intel_panel_bl_funcs->get(), and leave figuring out the current display pipe up to the caller. Signed-off-by: Lyude Paul --- .../drm/i915/display/intel_display_types.h| 2 +- .../drm/i915/display/intel_dp_aux_backlight.c | 4 +- .../i915/display/intel_dsi_dcs_backlight.c| 2 +- drivers/gpu/drm/i915/display/intel_panel.c| 40 --- 4 files changed, 21 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h index 585bb1edea04..b1f4ec144207 100644 --- a/drivers/gpu/drm/i915/display/intel_display_types.h +++ b/drivers/gpu/drm/i915/display/intel_display_types.h @@ -228,7 +228,7 @@ struct intel_encoder { struct intel_panel_bl_funcs { /* Connector and platform specific backlight functions */ int (*setup)(struct intel_connector *connector, enum pipe pipe); - u32 (*get)(struct intel_connector *connector); + u32 (*get)(struct intel_connector *connector, enum pipe pipe); void (*set)(const struct drm_connector_state *conn_state, u32 level); void (*disable)(const struct drm_connector_state *conn_state, u32 level); void (*enable)(const struct intel_crtc_state *crtc_state, diff --git a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c index 9775f33d1aac..de764dae1e66 100644 --- a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c +++ b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c @@ -128,7 +128,7 @@ static bool intel_dp_aux_vesa_backlight_dpcd_mode(struct intel_connector *connec * Read the current backlight value from DPCD register(s) based * on if 8-bit(MSB) or 16-bit(MSB and LSB) values are supported */ -static u32 intel_dp_aux_vesa_get_backlight(struct intel_connector *connector) +static u32 intel_dp_aux_vesa_get_backlight(struct intel_connector *connector, enum pipe unused) { struct intel_dp *intel_dp = intel_attached_dp(connector); struct drm_i915_private *i915 = dp_to_i915(intel_dp); @@ -381,7 +381,7 @@ static int intel_dp_aux_vesa_setup_backlight(struct intel_connector *connector, return -ENODEV; panel->backlight.min = 0; - panel->backlight.level = intel_dp_aux_vesa_get_backlight(connector); + panel->backlight.level = intel_dp_aux_vesa_get_backlight(connector, pipe); panel->backlight.enabled = intel_dp_aux_vesa_backlight_dpcd_mode(connector) && panel->backlight.level != 0; diff --git a/drivers/gpu/drm/i915/display/intel_dsi_dcs_backlight.c b/drivers/gpu/drm/i915/display/intel_dsi_dcs_backlight.c index 88628764956d..584c14c4cbd0 100644 --- a/drivers/gpu/drm/i915/display/intel_dsi_dcs_backlight.c +++ b/drivers/gpu/drm/i915/display/intel_dsi_dcs_backlight.c @@ -43,7 +43,7 @@ #define PANEL_PWM_MAX_VALUE0xFF -static u32 dcs_get_backlight(struct intel_connector *connector) +static u32 dcs_get_backlight(struct intel_connector *connector, enum pipe unused) { struct intel_encoder *encoder = intel_attached_encoder(connector); struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder); diff --git a/drivers/gpu/drm/i915/display/intel_panel.c b/drivers/gpu/drm/i915/display/intel_panel.c index 7a4239d1c241..7587aaefc7a0 100644 --- a/drivers/gpu/drm/i915/display/intel_panel.c +++ b/drivers/gpu/drm/i915/display/intel_panel.c @@ -530,21 +530,21 @@ static u32 intel_panel_compute_brightness(struct intel_connector *connector, return val; } -static u32 lpt_get_backlight(struct intel_connector *connector) +static u32 lpt_get_backlight(struct intel_connector *connector, enum pipe unused) { struct drm_i915_private *dev_priv = to_i915(connector->base.dev); return intel_de_read(dev_priv, BLC_PWM_PCH_CTL2) & BACKLIGHT_DUTY_CYCLE_MASK; } -static u32 pch_get_backlight(struct intel_connector *connector) +static u32 pch_get_backlight(struct intel_connector *connector, enum pipe unused) { struct drm_i915_private