diff mbox series

[CI,03/10] drm/i915/bios: Enable parse of two integrated panels timing data

Message ID 20210729215545.192606-3-jose.souza@intel.com (mailing list archive)
State New, archived
Headers show
Series [CI,01/10] drm/i915/bios: Allow DSI ports to be parsed by parse_ddi_port() | expand

Commit Message

Souza, Jose July 29, 2021, 9:55 p.m. UTC
Continuing the conversion from single integrated VBT data to two.

Reviewed-by: Matt Atwood <matthew.s.atwood@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
---
 drivers/gpu/drm/i915/display/intel_bios.c    | 53 +++++++++++++-------
 drivers/gpu/drm/i915/display/intel_bios.h    |  1 +
 drivers/gpu/drm/i915/display/intel_dsi_vbt.c |  7 ++-
 drivers/gpu/drm/i915/display/intel_panel.c   |  7 +--
 drivers/gpu/drm/i915/i915_drv.h              |  3 +-
 5 files changed, 48 insertions(+), 23 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c
index 9439bfe32b136..fdde8777854ee 100644
--- a/drivers/gpu/drm/i915/display/intel_bios.c
+++ b/drivers/gpu/drm/i915/display/intel_bios.c
@@ -289,14 +289,15 @@  parse_panel_options(struct drm_i915_private *i915,
 /* Try to find integrated panel timing data */
 static void
 parse_lfp_panel_dtd(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_lvds_lfp_data *lvds_lfp_data;
 	const struct bdb_lvds_lfp_data_ptrs *lvds_lfp_data_ptrs;
 	const struct lvds_dvo_timing *panel_dvo_timing;
 	const struct lvds_fp_timing *fp_timing;
 	struct drm_display_mode *panel_fixed_mode;
-	int panel_type = i915->vbt.panel_type;
 
 	lvds_lfp_data = find_section(bdb, BDB_LVDS_LFP_DATA);
 	if (!lvds_lfp_data)
@@ -308,7 +309,7 @@  parse_lfp_panel_dtd(struct drm_i915_private *i915,
 
 	panel_dvo_timing = get_lvds_dvo_timing(lvds_lfp_data,
 					       lvds_lfp_data_ptrs,
-					       panel_type);
+					       panel_index);
 
 	panel_fixed_mode = kzalloc(sizeof(*panel_fixed_mode), GFP_KERNEL);
 	if (!panel_fixed_mode)
@@ -316,7 +317,7 @@  parse_lfp_panel_dtd(struct drm_i915_private *i915,
 
 	fill_detail_timing_data(panel_fixed_mode, panel_dvo_timing);
 
-	i915->vbt.lfp_lvds_vbt_mode = panel_fixed_mode;
+	info->lfp_lvds_vbt_mode = panel_fixed_mode;
 
 	drm_dbg_kms(&i915->drm,
 		    "Found panel mode in BIOS VBT legacy lfp table:\n");
@@ -324,7 +325,7 @@  parse_lfp_panel_dtd(struct drm_i915_private *i915,
 
 	fp_timing = get_lvds_fp_timing(bdb, lvds_lfp_data,
 				       lvds_lfp_data_ptrs,
-				       panel_type);
+				       panel_index);
 	if (fp_timing) {
 		/* check the resolution, just to be sure */
 		if (fp_timing->x_res == panel_fixed_mode->hdisplay &&
@@ -339,7 +340,9 @@  parse_lfp_panel_dtd(struct drm_i915_private *i915,
 
 static void
 parse_generic_dtd(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_generic_dtd *generic_dtd;
 	const struct generic_dtd_entry *dtd;
@@ -363,14 +366,14 @@  parse_generic_dtd(struct drm_i915_private *i915,
 
 	num_dtd = (get_blocksize(generic_dtd) -
 		   sizeof(struct bdb_generic_dtd)) / generic_dtd->gdtd_size;
-	if (i915->vbt.panel_type >= num_dtd) {
+	if (panel_index >= num_dtd) {
 		drm_err(&i915->drm,
-			"Panel type %d not found in table of %d DTD's\n",
-			i915->vbt.panel_type, num_dtd);
+			"Panel index %d not found in table of %d DTD's\n",
+			panel_index, num_dtd);
 		return;
 	}
 
-	dtd = &generic_dtd->dtd[i915->vbt.panel_type];
+	dtd = &generic_dtd->dtd[panel_index];
 
 	panel_fixed_mode = kzalloc(sizeof(*panel_fixed_mode), GFP_KERNEL);
 	if (!panel_fixed_mode)
@@ -413,12 +416,14 @@  parse_generic_dtd(struct drm_i915_private *i915,
 		    "Found panel mode in BIOS VBT generic dtd table:\n");
 	drm_mode_debug_printmodeline(panel_fixed_mode);
 
-	i915->vbt.lfp_lvds_vbt_mode = panel_fixed_mode;
+	info->lfp_lvds_vbt_mode = panel_fixed_mode;
 }
 
 static void
 parse_panel_dtd(struct drm_i915_private *i915,
-		const struct bdb_header *bdb)
+		const struct bdb_header *bdb,
+		struct ddi_vbt_port_info *info,
+		int panel_index)
 {
 	/*
 	 * Older VBTs provided provided DTD information for internal displays
@@ -429,9 +434,9 @@  parse_panel_dtd(struct drm_i915_private *i915,
 	 * back to trying the old LFP block if that fails.
 	 */
 	if (bdb->version >= 229)
-		parse_generic_dtd(i915, bdb);
-	if (!i915->vbt.lfp_lvds_vbt_mode)
-		parse_lfp_panel_dtd(i915, bdb);
+		parse_generic_dtd(i915, bdb, info, panel_index);
+	if (!info->lfp_lvds_vbt_mode)
+		parse_lfp_panel_dtd(i915, bdb, info, panel_index);
 }
 
 static void
@@ -1981,6 +1986,7 @@  static void parse_integrated_panel(struct drm_i915_private *i915,
 	parse_panel_options(i915, bdb, info, panel_index);
 	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);
 }
 
 static void parse_ddi_port(struct drm_i915_private *i915,
@@ -2476,7 +2482,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_panel_dtd(i915, bdb);
 	parse_lfp_backlight(i915, bdb);
 	parse_sdvo_panel_data(i915, bdb);
 	parse_driver_features(i915, bdb);
@@ -2509,6 +2514,7 @@  void intel_bios_init(struct drm_i915_private *i915)
 void intel_bios_driver_remove(struct drm_i915_private *i915)
 {
 	struct intel_bios_encoder_data *devdata, *n;
+	int i;
 
 	list_for_each_entry_safe(devdata, n, &i915->vbt.display_devices, node) {
 		list_del(&devdata->node);
@@ -2516,10 +2522,13 @@  void intel_bios_driver_remove(struct drm_i915_private *i915)
 		kfree(devdata);
 	}
 
+	for (i = 0; i < I915_MAX_PORTS; i++) {
+		kfree(i915->vbt.ddi_port_info[i].lfp_lvds_vbt_mode);
+		i915->vbt.ddi_port_info[i].lfp_lvds_vbt_mode = NULL;
+	}
+
 	kfree(i915->vbt.sdvo_lvds_vbt_mode);
 	i915->vbt.sdvo_lvds_vbt_mode = NULL;
-	kfree(i915->vbt.lfp_lvds_vbt_mode);
-	i915->vbt.lfp_lvds_vbt_mode = NULL;
 	kfree(i915->vbt.dsi.data);
 	i915->vbt.dsi.data = NULL;
 	kfree(i915->vbt.dsi.pps);
@@ -3107,3 +3116,11 @@  intel_bios_drrs_type(struct intel_encoder *encoder)
 
 	return i915->vbt.ddi_port_info[encoder->port].drrs_type;
 }
+
+const struct drm_display_mode *
+intel_bios_lfp_lvds_info(struct intel_encoder *encoder)
+{
+	struct drm_i915_private *i915 = to_i915(encoder->base.dev);
+
+	return i915->vbt.ddi_port_info[encoder->port].lfp_lvds_vbt_mode;
+}
diff --git a/drivers/gpu/drm/i915/display/intel_bios.h b/drivers/gpu/drm/i915/display/intel_bios.h
index bad282b64c5e6..f133c51c155cd 100644
--- a/drivers/gpu/drm/i915/display/intel_bios.h
+++ b/drivers/gpu/drm/i915/display/intel_bios.h
@@ -267,5 +267,6 @@  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_support_type intel_bios_drrs_type(struct intel_encoder *encoder);
+const struct drm_display_mode *intel_bios_lfp_lvds_info(struct intel_encoder *encoder);
 
 #endif /* _INTEL_BIOS_H_ */
diff --git a/drivers/gpu/drm/i915/display/intel_dsi_vbt.c b/drivers/gpu/drm/i915/display/intel_dsi_vbt.c
index c2a2cd1f84dc5..2218de0773bf0 100644
--- a/drivers/gpu/drm/i915/display/intel_dsi_vbt.c
+++ b/drivers/gpu/drm/i915/display/intel_dsi_vbt.c
@@ -729,10 +729,15 @@  bool intel_dsi_vbt_init(struct intel_dsi *intel_dsi, u16 panel_id)
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct mipi_config *mipi_config = dev_priv->vbt.dsi.config;
 	struct mipi_pps_data *pps = dev_priv->vbt.dsi.pps;
-	struct drm_display_mode *mode = dev_priv->vbt.lfp_lvds_vbt_mode;
+	const struct drm_display_mode *mode = intel_bios_lfp_lvds_info(&intel_dsi->base);
 	u16 burst_mode_ratio;
 	enum port port;
 
+	if (!mode) {
+		drm_dbg_kms(&dev_priv->drm, "lfp_lvds_vbt_mode not set\n");
+		return false;
+	}
+
 	drm_dbg_kms(&dev_priv->drm, "\n");
 
 	intel_dsi->eotp_pkt = mipi_config->eot_pkt_disabled ? 0 : 1;
diff --git a/drivers/gpu/drm/i915/display/intel_panel.c b/drivers/gpu/drm/i915/display/intel_panel.c
index 7d7a60b4d2de7..a88e30c966fe7 100644
--- a/drivers/gpu/drm/i915/display/intel_panel.c
+++ b/drivers/gpu/drm/i915/display/intel_panel.c
@@ -153,12 +153,13 @@  intel_panel_vbt_fixed_mode(struct intel_connector *connector)
 	struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
 	struct drm_display_info *info = &connector->base.display_info;
 	struct drm_display_mode *fixed_mode;
+	const struct drm_display_mode *lfp_lvds_vbt_mode;
 
-	if (!dev_priv->vbt.lfp_lvds_vbt_mode)
+	lfp_lvds_vbt_mode = intel_bios_lfp_lvds_info(connector->encoder);
+	if (!lfp_lvds_vbt_mode)
 		return NULL;
 
-	fixed_mode = drm_mode_duplicate(&dev_priv->drm,
-					dev_priv->vbt.lfp_lvds_vbt_mode);
+	fixed_mode = drm_mode_duplicate(&dev_priv->drm, lfp_lvds_vbt_mode);
 	if (!fixed_mode)
 		return NULL;
 
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index df096a283d52a..ef3a86e4aba02 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -652,6 +652,8 @@  struct ddi_vbt_port_info {
 	int dp_max_link_rate;		/* 0 for not limited by VBT */
 
 	enum drrs_support_type drrs_type;
+
+	struct drm_display_mode *lfp_lvds_vbt_mode; /* if any */
 };
 
 enum psr_lines_to_wait {
@@ -665,7 +667,6 @@  struct intel_vbt_data {
 	/* bdb version */
 	u16 version;
 
-	struct drm_display_mode *lfp_lvds_vbt_mode; /* if any */
 	struct drm_display_mode *sdvo_lvds_vbt_mode; /* if any */
 
 	/* Feature bits */