[Intel-gfx] [PATCH 07/15] drm/i915: Add BUILD_BUG_ON()s for DDI translation table sizes

ville.syrjala at linux.intel.com ville.syrjala at linux.intel.com
Tue Dec 8 09:59:42 PST 2015


From: Ville Syrjälä <ville.syrjala at linux.intel.com>

The DDI translation tables are supposed to be of certain size,
so let's add some compile time asserts to enforce that..

Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 drivers/gpu/drm/i915/intel_ddi.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 5d0b03d6d388..838cbbe33517 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -351,6 +351,10 @@ intel_dig_port_supports_hdmi(const struct intel_digital_port *intel_dig_port)
 static const struct ddi_buf_trans *
 skl_get_buf_trans_dp(struct drm_i915_private *dev_priv, int *n_entries)
 {
+	BUILD_BUG_ON(ARRAY_SIZE(skl_y_ddi_translations_dp) != 9);
+	BUILD_BUG_ON(ARRAY_SIZE(skl_u_ddi_translations_dp) != 9);
+	BUILD_BUG_ON(ARRAY_SIZE(skl_ddi_translations_dp) != 9);
+
 	if (IS_SKL_ULX(dev_priv)) {
 		*n_entries = ARRAY_SIZE(skl_y_ddi_translations_dp);
 		return skl_y_ddi_translations_dp;
@@ -366,6 +370,10 @@ skl_get_buf_trans_dp(struct drm_i915_private *dev_priv, int *n_entries)
 static const struct ddi_buf_trans *
 skl_get_buf_trans_edp(struct drm_i915_private *dev_priv, int *n_entries)
 {
+	BUILD_BUG_ON(ARRAY_SIZE(skl_y_ddi_translations_edp) != 10);
+	BUILD_BUG_ON(ARRAY_SIZE(skl_u_ddi_translations_edp) != 10);
+	BUILD_BUG_ON(ARRAY_SIZE(skl_ddi_translations_edp) != 10);
+
 	if (dev_priv->edp_low_vswing) {
 		if (IS_SKL_ULX(dev_priv)) {
 			*n_entries = ARRAY_SIZE(skl_y_ddi_translations_edp);
@@ -436,6 +444,10 @@ static void intel_prepare_ddi_buffers(struct drm_i915_private *dev_priv,
 		    dev_priv->vbt.ddi_port_info[port].dp_boost_level)
 			iboost_bit = 1<<31;
 	} else if (IS_BROADWELL(dev_priv)) {
+		BUILD_BUG_ON(ARRAY_SIZE(bdw_ddi_translations_fdi) != 9);
+		BUILD_BUG_ON(ARRAY_SIZE(bdw_ddi_translations_dp) != 9);
+		BUILD_BUG_ON(ARRAY_SIZE(bdw_ddi_translations_edp) != 9);
+
 		ddi_translations_fdi = bdw_ddi_translations_fdi;
 		ddi_translations_dp = bdw_ddi_translations_dp;
 		ddi_translations_edp = bdw_ddi_translations_edp;
@@ -445,6 +457,9 @@ static void intel_prepare_ddi_buffers(struct drm_i915_private *dev_priv,
 		n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi);
 		hdmi_default_entry = 7;
 	} else if (IS_HASWELL(dev_priv)) {
+		BUILD_BUG_ON(ARRAY_SIZE(hsw_ddi_translations_fdi) != 9);
+		BUILD_BUG_ON(ARRAY_SIZE(hsw_ddi_translations_dp) != 9);
+
 		ddi_translations_fdi = hsw_ddi_translations_fdi;
 		ddi_translations_dp = hsw_ddi_translations_dp;
 		ddi_translations_edp = hsw_ddi_translations_dp;
-- 
2.4.10



More information about the Intel-gfx mailing list