From patchwork Thu Jul 22 05:43:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Souza, Jose" X-Patchwork-Id: 12393073 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEC20C63793 for ; Thu, 22 Jul 2021 05:39:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7189161001 for ; Thu, 22 Jul 2021 05:39:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7189161001 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 384476EDFB; Thu, 22 Jul 2021 05:39:32 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 46F3E6E92E for ; Thu, 22 Jul 2021 05:39:25 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10052"; a="208456071" X-IronPort-AV: E=Sophos;i="5.84,260,1620716400"; d="scan'208";a="208456071" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2021 22:39:24 -0700 X-IronPort-AV: E=Sophos;i="5.84,260,1620716400"; d="scan'208";a="470415078" Received: from jkandi-mobl.amr.corp.intel.com (HELO josouza-mobl2.intel.com) ([10.209.170.189]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2021 22:39:24 -0700 From: =?utf-8?q?Jos=C3=A9_Roberto_de_Souza?= To: intel-gfx@lists.freedesktop.org Date: Wed, 21 Jul 2021 22:43:32 -0700 Message-Id: <20210722054338.12891-4-jose.souza@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210722054338.12891-1-jose.souza@intel.com> References: <20210722054338.12891-1-jose.souza@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 04/10] drm/i915/bios: Enable parse of two integrated panels backlight data X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jani Nikula Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Continuing the conversion from single integrated VBT data to two, now handling backlight data. Cc: Ville Syrjälä Cc: Jani Nikula Signed-off-by: José Roberto de Souza Reviewed-by: Matt Atwood --- drivers/gpu/drm/i915/display/intel_bios.c | 59 +++++++++++-------- drivers/gpu/drm/i915/display/intel_bios.h | 1 + .../drm/i915/display/intel_dp_aux_backlight.c | 11 ++-- .../i915/display/intel_dsi_dcs_backlight.c | 5 +- drivers/gpu/drm/i915/display/intel_panel.c | 32 ++++++---- drivers/gpu/drm/i915/display/intel_pps.c | 8 ++- drivers/gpu/drm/i915/i915_drv.h | 18 +++--- 7 files changed, 83 insertions(+), 51 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c index 5906e9fa8f976..6770ed8b260be 100644 --- a/drivers/gpu/drm/i915/display/intel_bios.c +++ b/drivers/gpu/drm/i915/display/intel_bios.c @@ -441,11 +441,12 @@ parse_panel_dtd(struct drm_i915_private *i915, static void parse_lfp_backlight(struct drm_i915_private *i915, - const struct bdb_header *bdb) + const struct bdb_header *bdb, + struct ddi_vbt_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(bdb, BDB_LVDS_BACKLIGHT); @@ -459,38 +460,38 @@ 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 (bdb->version >= 191 && get_blocksize(backlight_data) >= sizeof(*backlight_data)) { 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 (bdb->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 (bdb->version >= 236) - scale = backlight_data->brightness_precision_bits[panel_type] == 16; + scale = backlight_data->brightness_precision_bits[panel_index] == 16; else scale = level > 255; @@ -501,20 +502,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; + 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 */ @@ -1987,6 +1988,7 @@ static void parse_integrated_panel(struct drm_i915_private *i915, parse_power_conservation_features(i915, bdb, info, panel_index); parse_driver_features_drrs_only(i915, bdb, info); parse_panel_dtd(i915, bdb, info, panel_index); + parse_lfp_backlight(i915, bdb, info, panel_index); } static void parse_ddi_port(struct drm_i915_private *i915, @@ -2120,6 +2122,9 @@ static void parse_ddi_port(struct drm_i915_private *i915, port_name(port), info->dp_max_link_rate); } + /* Default to having backlight */ + info->backlight.present = true; + parse_integrated_panel(i915, devdata, info); info->devdata = devdata; @@ -2245,9 +2250,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; @@ -2481,7 +2483,6 @@ void intel_bios_init(struct drm_i915_private *i915) parse_general_features(i915, bdb); parse_general_definitions(i915, bdb); parse_panel_type(i915, bdb); - parse_lfp_backlight(i915, bdb); parse_sdvo_panel_data(i915, bdb); parse_driver_features(i915, bdb); parse_edp(i915, bdb); @@ -3123,3 +3124,11 @@ intel_bios_lfp_lvds_info(struct intel_encoder *encoder) return i915->vbt.ddi_port_info[encoder->port].lfp_lvds_vbt_mode; } + +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.ddi_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 f133c51c155cd..5b6167c97a8d9 100644 --- a/drivers/gpu/drm/i915/display/intel_bios.h +++ b/drivers/gpu/drm/i915/display/intel_bios.h @@ -268,5 +268,6 @@ int intel_bios_encoder_hdmi_boost_level(const struct intel_bios_encoder_data *de enum drrs_support_type intel_bios_drrs_type(struct intel_encoder *encoder); const struct drm_display_mode *intel_bios_lfp_lvds_info(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 6ac568617ef37..401a9d9533158 100644 --- a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c +++ b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c @@ -310,13 +310,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; @@ -383,7 +384,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 */ @@ -391,7 +394,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; @@ -403,7 +406,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 584c14c4cbd0e..4dbd0c6754af9 100644 --- a/drivers/gpu/drm/i915/display/intel_dsi_dcs_backlight.c +++ b/drivers/gpu/drm/i915/display/intel_dsi_dcs_backlight.c @@ -166,11 +166,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_panel.c b/drivers/gpu/drm/i915/display/intel_panel.c index a88e30c966fe7..9c892476d8621 100644 --- a/drivers/gpu/drm/i915/display/intel_panel.c +++ b/drivers/gpu/drm/i915/display/intel_panel.c @@ -1596,9 +1596,14 @@ 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; + struct drm_i915_private *dev_priv = to_i915(connector->base.dev); + const struct vbt_backlight_info *backlight_info; + u16 pwm_freq_hz; + + backlight_info = intel_bios_backlight_info(connector->encoder); + pwm_freq_hz = backlight_info->pwm_freq_hz; if (pwm_freq_hz) { drm_dbg_kms(&dev_priv->drm, @@ -1618,7 +1623,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) { @@ -1643,11 +1648,14 @@ 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; struct intel_panel *panel = &connector->panel; int min; drm_WARN_ON(&dev_priv->drm, panel->backlight.pwm_level_max == 0); + backlight_info = intel_bios_backlight_info(connector->encoder); + /* * XXX: If the vbt value is 255, it makes min equal to max, which leads * to problems. There are such machines out there. Either our @@ -1655,11 +1663,11 @@ 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) { + min = clamp_t(int, backlight_info->min_brightness, 0, 64); + if (min != backlight_info->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->min_brightness, min); } /* vbt value is a coefficient in range [0..255] */ @@ -1845,10 +1853,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)); @@ -1950,11 +1960,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", @@ -2037,10 +2047,12 @@ int intel_panel_setup_backlight(struct drm_connector *connector, enum pipe pipe) { struct drm_i915_private *dev_priv = to_i915(connector->dev); struct intel_connector *intel_connector = to_intel_connector(connector); + const struct vbt_backlight_info *backlight_info; struct intel_panel *panel = &intel_connector->panel; int ret; - if (!dev_priv->vbt.backlight.present) { + backlight_info = intel_bios_backlight_info(intel_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_pps.c b/drivers/gpu/drm/i915/display/intel_pps.c index a36ec4a818ff5..96894d70a92c1 100644 --- a/drivers/gpu/drm/i915/display/intel_pps.c +++ b/drivers/gpu/drm/i915/display/intel_pps.c @@ -207,7 +207,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 62a0c1f64f870..047f0d2fc971f 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -660,6 +660,15 @@ struct ddi_vbt_port_info { enum drrs_support_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; }; enum psr_lines_to_wait { @@ -710,15 +719,6 @@ struct intel_vbt_data { int psr2_tp2_tp3_wakeup_time_us; } psr; - struct { - 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; - /* MIPI DSI */ struct { u16 panel_id;