[PATCH 3/5] drm/i915/bios: Enable parse of two integrated panels backlight data
Animesh Manna
animesh.manna at intel.com
Wed May 25 16:53:19 UTC 2022
From: Nischal Varide <nischal.varide at intel.com>
Continuing the conversion from single integrated VBT data to two and
now handling backlight data.
Signed-off-by: Nischal Varide <nischal.varide at intel.com>
Signed-off-by: Animesh Manna <animesh.manna at intel.com>
---
.../gpu/drm/i915/display/intel_backlight.c | 41 ++++++-------
drivers/gpu/drm/i915/display/intel_bios.c | 59 ++++++++++---------
drivers/gpu/drm/i915/display/intel_bios.h | 2 +-
.../drm/i915/display/intel_dp_aux_backlight.c | 10 +++-
.../i915/display/intel_dsi_dcs_backlight.c | 16 +----
drivers/gpu/drm/i915/display/intel_pps.c | 8 ++-
drivers/gpu/drm/i915/i915_drv.h | 20 +++----
7 files changed, 77 insertions(+), 79 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_backlight.c b/drivers/gpu/drm/i915/display/intel_backlight.c
index c8e1fc53a881..0d3e761f18b4 100644
--- a/drivers/gpu/drm/i915/display/intel_backlight.c
+++ b/drivers/gpu/drm/i915/display/intel_backlight.c
@@ -1159,20 +1159,13 @@ static u32 vlv_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
return DIV_ROUND_CLOSEST(clock, pwm_freq_hz * mul);
}
-static u16 get_vbt_pwm_freq(struct drm_i915_private *dev_priv)
+static u16 get_vbt_pwm_freq(struct intel_connector *connector)
{
- u16 pwm_freq_hz = dev_priv->vbt.backlight.pwm_freq_hz;
+ const struct vbt_backlight_info *backlight_info;
+ u16 pwm_freq_hz;
- if (pwm_freq_hz) {
- drm_dbg_kms(&dev_priv->drm,
- "VBT defined backlight frequency %u Hz\n",
- pwm_freq_hz);
- } else {
- pwm_freq_hz = 200;
- drm_dbg_kms(&dev_priv->drm,
- "default backlight frequency %u Hz\n",
- pwm_freq_hz);
- }
+ backlight_info = intel_bios_backlight_info(connector->encoder);
+ pwm_freq_hz = backlight_info->pwm_freq_hz;
return pwm_freq_hz;
}
@@ -1181,7 +1174,7 @@ static u32 get_backlight_max_vbt(struct intel_connector *connector)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
- u16 pwm_freq_hz = get_vbt_pwm_freq(dev_priv);
+ u16 pwm_freq_hz = get_vbt_pwm_freq(connector);
u32 pwm;
if (!panel->backlight.pwm_funcs->hz_to_pwm) {
@@ -1206,6 +1199,7 @@ static u32 get_backlight_max_vbt(struct intel_connector *connector)
static u32 get_backlight_min_vbt(struct intel_connector *connector)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
+ const struct vbt_backlight_info *backlight_info = NULL;
struct intel_panel *panel = &connector->panel;
int min;
@@ -1218,12 +1212,8 @@ static u32 get_backlight_min_vbt(struct intel_connector *connector)
* against this by letting the minimum be at most (arbitrarily chosen)
* 25% of the max.
*/
- min = clamp_t(int, dev_priv->vbt.backlight.min_brightness, 0, 64);
- if (min != dev_priv->vbt.backlight.min_brightness) {
- drm_dbg_kms(&dev_priv->drm,
- "clamping VBT min backlight %d/255 to %d/255\n",
- dev_priv->vbt.backlight.min_brightness, min);
- }
+ backlight_info = intel_bios_backlight_info(connector->encoder);
+ min = clamp_t(int, backlight_info->min_brightness, 0, 64);
/* vbt value is a coefficient in range [0..255] */
return scale(min, 0, 255, 0, panel->backlight.pwm_level_max);
@@ -1408,10 +1398,12 @@ static int
bxt_setup_backlight(struct intel_connector *connector, enum pipe unused)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
+ const struct vbt_backlight_info *backlight_info;
struct intel_panel *panel = &connector->panel;
u32 pwm_ctl, val;
- panel->backlight.controller = dev_priv->vbt.backlight.controller;
+ backlight_info = intel_bios_backlight_info(connector->encoder);
+ panel->backlight.controller = backlight_info->controller;
pwm_ctl = intel_de_read(dev_priv,
BXT_BLC_PWM_CTL(panel->backlight.controller));
@@ -1513,11 +1505,11 @@ static int ext_pwm_setup_backlight(struct intel_connector *connector,
drm_dbg_kms(&dev_priv->drm, "PWM already enabled at freq %ld, VBT freq %d, level %d\n",
NSEC_PER_SEC / (unsigned long)panel->backlight.pwm_state.period,
- get_vbt_pwm_freq(dev_priv), level);
+ get_vbt_pwm_freq(connector), level);
} else {
/* Set period from VBT frequency, leave other settings at 0. */
panel->backlight.pwm_state.period =
- NSEC_PER_SEC / get_vbt_pwm_freq(dev_priv);
+ NSEC_PER_SEC / get_vbt_pwm_freq(connector);
}
drm_info(&dev_priv->drm, "Using %s PWM for LCD backlight control\n",
@@ -1600,9 +1592,12 @@ int intel_backlight_setup(struct intel_connector *connector, enum pipe pipe)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
+ const struct vbt_backlight_info *backlight_info;
int ret;
- if (!dev_priv->vbt.backlight.present) {
+ backlight_info = intel_bios_backlight_info(connector->encoder);
+ if (!backlight_info->present) {
+
if (dev_priv->quirks & QUIRK_BACKLIGHT_PRESENT) {
drm_dbg_kms(&dev_priv->drm,
"no backlight present per VBT, but present per quirk\n");
diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c
index 19b14b23ca68..5e2fededd7db 100644
--- a/drivers/gpu/drm/i915/display/intel_bios.c
+++ b/drivers/gpu/drm/i915/display/intel_bios.c
@@ -899,11 +899,12 @@ parse_generic_dtd(struct drm_i915_private *i915,
}
static void
-parse_lfp_backlight(struct drm_i915_private *i915)
+parse_lfp_backlight(struct drm_i915_private *i915,
+ struct intel_bios_port_info *info,
+ int panel_index)
{
const struct bdb_lfp_backlight_data *backlight_data;
const struct lfp_backlight_data_entry *entry;
- int panel_type = i915->vbt.panel_type;
u16 level;
backlight_data = find_section(i915, BDB_LVDS_BACKLIGHT);
@@ -917,17 +918,17 @@ parse_lfp_backlight(struct drm_i915_private *i915)
return;
}
- entry = &backlight_data->data[panel_type];
+ entry = &backlight_data->data[panel_index];
- i915->vbt.backlight.present = entry->type == BDB_BACKLIGHT_TYPE_PWM;
- if (!i915->vbt.backlight.present) {
+ info->backlight.present = entry->type == BDB_BACKLIGHT_TYPE_PWM;
+ if (!info->backlight.present) {
drm_dbg_kms(&i915->drm,
"PWM backlight not present in VBT (type %u)\n",
entry->type);
return;
}
- i915->vbt.backlight.type = INTEL_BACKLIGHT_DISPLAY_DDI;
+ info->backlight.type = INTEL_BACKLIGHT_DISPLAY_DDI;
if (i915->vbt.version >= 191) {
size_t exp_size;
@@ -941,24 +942,24 @@ parse_lfp_backlight(struct drm_i915_private *i915)
if (get_blocksize(backlight_data) >= exp_size) {
const struct lfp_backlight_control_method *method;
- method = &backlight_data->backlight_control[panel_type];
- i915->vbt.backlight.type = method->type;
- i915->vbt.backlight.controller = method->controller;
+ method = &backlight_data->backlight_control[panel_index];
+ info->backlight.type = method->type;
+ info->backlight.controller = method->controller;
}
}
- i915->vbt.backlight.pwm_freq_hz = entry->pwm_freq_hz;
- i915->vbt.backlight.active_low_pwm = entry->active_low_pwm;
+ info->backlight.pwm_freq_hz = entry->pwm_freq_hz;
+ info->backlight.active_low_pwm = entry->active_low_pwm;
if (i915->vbt.version >= 234) {
u16 min_level;
bool scale;
- level = backlight_data->brightness_level[panel_type].level;
- min_level = backlight_data->brightness_min_level[panel_type].level;
+ level = backlight_data->brightness_level[panel_index].level;
+ min_level = backlight_data->brightness_min_level[panel_index].level;
if (i915->vbt.version >= 236)
- scale = backlight_data->brightness_precision_bits[panel_type] == 16;
+ scale = backlight_data->brightness_precision_bits[panel_index] == 16;
else
scale = level > 255;
@@ -969,23 +970,20 @@ parse_lfp_backlight(struct drm_i915_private *i915)
drm_warn(&i915->drm, "Brightness min level > 255\n");
level = 255;
}
- i915->vbt.backlight.min_brightness = min_level;
-
- i915->vbt.backlight.brightness_precision_bits =
- backlight_data->brightness_precision_bits[panel_type];
+ info->backlight.min_brightness = min_level;
} else {
- level = backlight_data->level[panel_type];
- i915->vbt.backlight.min_brightness = entry->min_brightness;
+ level = backlight_data->level[panel_index];
+ info->backlight.min_brightness = entry->min_brightness;
}
drm_dbg_kms(&i915->drm,
"VBT backlight PWM modulation frequency %u Hz, "
"active %s, min brightness %u, level %u, controller %u\n",
- i915->vbt.backlight.pwm_freq_hz,
- i915->vbt.backlight.active_low_pwm ? "low" : "high",
- i915->vbt.backlight.min_brightness,
+ info->backlight.pwm_freq_hz,
+ info->backlight.active_low_pwm ? "low" : "high",
+ info->backlight.min_brightness,
level,
- i915->vbt.backlight.controller);
+ info->backlight.controller);
}
/* Try to find sdvo panel data */
@@ -2531,6 +2529,7 @@ static void parse_integrated_panel(struct drm_i915_private *i915,
parse_driver_features_drrs_only(i915, bdb, info);
parse_generic_dtd(i915, info, panel_index);
parse_lfp_data(i915, info, panel_index);
+ parse_lfp_backlight(i915, info, panel_index);
}
static void parse_ddi_port(struct drm_i915_private *i915,
@@ -2740,9 +2739,6 @@ init_vbt_defaults(struct drm_i915_private *i915)
{
i915->vbt.crt_ddc_pin = GMBUS_PIN_VGADDC;
- /* Default to having backlight */
- i915->vbt.backlight.present = true;
-
/* SDVO panel data */
i915->vbt.sdvo_lvds_vbt_mode = NULL;
@@ -3045,7 +3041,6 @@ void intel_bios_init(struct drm_i915_private *i915)
parse_general_features(i915);
parse_general_definitions(i915);
parse_panel_type(i915);
- parse_lfp_backlight(i915);
parse_sdvo_panel_data(i915);
parse_driver_features(i915);
parse_edp(i915);
@@ -3612,3 +3607,11 @@ intel_bios_drrs_type(struct intel_encoder *encoder)
return i915->vbt.port_info[encoder->port].drrs_type;
}
+
+const struct vbt_backlight_info *
+intel_bios_backlight_info(struct intel_encoder *encoder)
+{
+ struct drm_i915_private *i915 = to_i915(encoder->base.dev);
+
+ return &i915->vbt.port_info[encoder->port].backlight;
+}
diff --git a/drivers/gpu/drm/i915/display/intel_bios.h b/drivers/gpu/drm/i915/display/intel_bios.h
index 8e743101b2f6..a0bf235eb4d2 100644
--- a/drivers/gpu/drm/i915/display/intel_bios.h
+++ b/drivers/gpu/drm/i915/display/intel_bios.h
@@ -267,5 +267,5 @@ int intel_bios_encoder_dp_boost_level(const struct intel_bios_encoder_data *devd
int intel_bios_encoder_hdmi_boost_level(const struct intel_bios_encoder_data *devdata);
enum drrs_type intel_bios_drrs_type(struct intel_encoder *encoder);
-
+const struct vbt_backlight_info *intel_bios_backlight_info(struct intel_encoder *encoder);
#endif /* _INTEL_BIOS_H_ */
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 fb6cf30ee628..cf83de61f836 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
@@ -365,12 +365,14 @@ static int intel_dp_aux_vesa_setup_backlight(struct intel_connector *connector,
struct intel_dp *intel_dp = intel_attached_dp(connector);
struct intel_panel *panel = &connector->panel;
struct drm_i915_private *i915 = dp_to_i915(intel_dp);
+ const struct vbt_backlight_info *backlight_info;
u16 current_level;
u8 current_mode;
int ret;
+ backlight_info = intel_bios_backlight_info(connector->encoder);
ret = drm_edp_backlight_init(&intel_dp->aux, &panel->backlight.edp.vesa.info,
- i915->vbt.backlight.pwm_freq_hz, intel_dp->edp_dpcd,
+ backlight_info->pwm_freq_hz, intel_dp->edp_dpcd,
¤t_level, ¤t_mode);
if (ret < 0)
return ret;
@@ -446,7 +448,9 @@ int intel_dp_aux_init_backlight_funcs(struct intel_connector *connector)
struct intel_dp *intel_dp = enc_to_intel_dp(connector->encoder);
struct drm_i915_private *i915 = dp_to_i915(intel_dp);
bool try_intel_interface = false, try_vesa_interface = false;
+ const struct vbt_backlight_info *backlight_info;
+ backlight_info = intel_bios_backlight_info(connector->encoder);
/* Check the VBT and user's module parameters to figure out which
* interfaces to probe
*/
@@ -454,7 +458,7 @@ int intel_dp_aux_init_backlight_funcs(struct intel_connector *connector)
case INTEL_DP_AUX_BACKLIGHT_OFF:
return -ENODEV;
case INTEL_DP_AUX_BACKLIGHT_AUTO:
- switch (i915->vbt.backlight.type) {
+ switch (backlight_info->type) {
case INTEL_BACKLIGHT_VESA_EDP_AUX_INTERFACE:
try_vesa_interface = true;
break;
@@ -466,7 +470,7 @@ int intel_dp_aux_init_backlight_funcs(struct intel_connector *connector)
}
break;
case INTEL_DP_AUX_BACKLIGHT_ON:
- if (i915->vbt.backlight.type != INTEL_BACKLIGHT_VESA_EDP_AUX_INTERFACE)
+ if (backlight_info->type != INTEL_BACKLIGHT_VESA_EDP_AUX_INTERFACE)
try_intel_interface = true;
try_vesa_interface = true;
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 7d234429e71e..05b66942e072 100644
--- a/drivers/gpu/drm/i915/display/intel_dsi_dcs_backlight.c
+++ b/drivers/gpu/drm/i915/display/intel_dsi_dcs_backlight.c
@@ -160,17 +160,6 @@ static void dcs_enable_backlight(const struct intel_crtc_state *crtc_state,
static int dcs_setup_backlight(struct intel_connector *connector,
enum pipe unused)
{
- struct drm_device *dev = connector->base.dev;
- struct drm_i915_private *dev_priv = to_i915(dev);
- struct intel_panel *panel = &connector->panel;
-
- if (dev_priv->vbt.backlight.brightness_precision_bits > 8)
- panel->backlight.max = (1 << dev_priv->vbt.backlight.brightness_precision_bits) - 1;
- else
- panel->backlight.max = PANEL_PWM_MAX_VALUE;
-
- panel->backlight.level = panel->backlight.max;
-
return 0;
}
@@ -185,11 +174,12 @@ static const struct intel_panel_bl_funcs dcs_bl_funcs = {
int intel_dsi_dcs_init_backlight_funcs(struct intel_connector *intel_connector)
{
struct drm_device *dev = intel_connector->base.dev;
- struct drm_i915_private *dev_priv = to_i915(dev);
struct intel_encoder *encoder = intel_attached_encoder(intel_connector);
struct intel_panel *panel = &intel_connector->panel;
+ const struct vbt_backlight_info *backlight_info;
- if (dev_priv->vbt.backlight.type != INTEL_BACKLIGHT_DSI_DCS)
+ backlight_info = intel_bios_backlight_info(encoder);
+ if (backlight_info->type != INTEL_BACKLIGHT_DSI_DCS)
return -ENODEV;
if (drm_WARN_ON(dev, encoder->type != INTEL_OUTPUT_DSI))
diff --git a/drivers/gpu/drm/i915/display/intel_pps.c b/drivers/gpu/drm/i915/display/intel_pps.c
index 4bc0563dde92..d318dda24142 100644
--- a/drivers/gpu/drm/i915/display/intel_pps.c
+++ b/drivers/gpu/drm/i915/display/intel_pps.c
@@ -209,7 +209,13 @@ static int
bxt_power_sequencer_idx(struct intel_dp *intel_dp)
{
struct drm_i915_private *dev_priv = dp_to_i915(intel_dp);
- int backlight_controller = dev_priv->vbt.backlight.controller;
+ struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
+ struct intel_encoder *encoder = &dig_port->base;
+ const struct vbt_backlight_info *backlight_info;
+ int backlight_controller;
+
+ backlight_info = intel_bios_backlight_info(encoder);
+ backlight_controller = backlight_info->controller;
lockdep_assert_held(&dev_priv->pps_mutex);
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 7123a7d4cf6c..586a44a7cdc1 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -307,6 +307,16 @@ i915_fence_timeout(const struct drm_i915_private *i915)
struct intel_bios_port_info {
enum drrs_type drrs_type;
struct drm_display_mode *lfp_lvds_vbt_mode; /* if any */
+
+ struct vbt_backlight_info {
+ u16 pwm_freq_hz;
+ bool present;
+ bool active_low_pwm;
+ u8 min_brightness; /* min_brightness/255 of max */
+ u8 controller; /* brightness controller number */
+ enum intel_backlight_type type;
+ } backlight;
+
};
struct intel_vbt_data {
@@ -356,16 +366,6 @@ struct intel_vbt_data {
int psr2_tp2_tp3_wakeup_time_us;
} psr;
- struct {
- u16 pwm_freq_hz;
- u16 brightness_precision_bits;
- bool present;
- bool active_low_pwm;
- u8 min_brightness; /* min_brightness/255 of max */
- u8 controller; /* brightness controller number */
- enum intel_backlight_type type;
- } backlight;
-
/* MIPI DSI */
struct {
u16 panel_id;
--
2.29.0
More information about the Intel-gfx-trybot
mailing list