Commit 78ab0bae authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915: Pass around dev_priv for ddi buffer programming

Make the ddi buffer programming code a bit more neat by passing
around dev_priv instead of dev.

v2: Resolve conflicts due to KBL
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> (v1)
parent cd1101cb
...@@ -301,8 +301,8 @@ static const struct bxt_ddi_buf_trans bxt_ddi_translations_hdmi[] = { ...@@ -301,8 +301,8 @@ static const struct bxt_ddi_buf_trans bxt_ddi_translations_hdmi[] = {
{ 154, 0x9A, 1, 128, true }, /* 9: 1200 0 */ { 154, 0x9A, 1, 128, true }, /* 9: 1200 0 */
}; };
static void bxt_ddi_vswing_sequence(struct drm_device *dev, u32 level, static void bxt_ddi_vswing_sequence(struct drm_i915_private *dev_priv,
enum port port, int type); u32 level, enum port port, int type);
static void ddi_get_encoder_port(struct intel_encoder *intel_encoder, static void ddi_get_encoder_port(struct intel_encoder *intel_encoder,
struct intel_digital_port **dig_port, struct intel_digital_port **dig_port,
...@@ -349,12 +349,12 @@ intel_dig_port_supports_hdmi(const struct intel_digital_port *intel_dig_port) ...@@ -349,12 +349,12 @@ intel_dig_port_supports_hdmi(const struct intel_digital_port *intel_dig_port)
} }
static const struct ddi_buf_trans * static const struct ddi_buf_trans *
skl_get_buf_trans_dp(struct drm_device *dev, int *n_entries) skl_get_buf_trans_dp(struct drm_i915_private *dev_priv, int *n_entries)
{ {
if (IS_SKL_ULX(dev) || IS_KBL_ULX(dev)) { if (IS_SKL_ULX(dev_priv) || IS_KBL_ULX(dev_priv)) {
*n_entries = ARRAY_SIZE(skl_y_ddi_translations_dp); *n_entries = ARRAY_SIZE(skl_y_ddi_translations_dp);
return skl_y_ddi_translations_dp; return skl_y_ddi_translations_dp;
} else if (IS_SKL_ULT(dev) || IS_KBL_ULT(dev)) { } else if (IS_SKL_ULT(dev_priv) || IS_KBL_ULT(dev_priv)) {
*n_entries = ARRAY_SIZE(skl_u_ddi_translations_dp); *n_entries = ARRAY_SIZE(skl_u_ddi_translations_dp);
return skl_u_ddi_translations_dp; return skl_u_ddi_translations_dp;
} else { } else {
...@@ -364,15 +364,13 @@ skl_get_buf_trans_dp(struct drm_device *dev, int *n_entries) ...@@ -364,15 +364,13 @@ skl_get_buf_trans_dp(struct drm_device *dev, int *n_entries)
} }
static const struct ddi_buf_trans * static const struct ddi_buf_trans *
skl_get_buf_trans_edp(struct drm_device *dev, int *n_entries) skl_get_buf_trans_edp(struct drm_i915_private *dev_priv, int *n_entries)
{ {
struct drm_i915_private *dev_priv = dev->dev_private;
if (dev_priv->edp_low_vswing) { if (dev_priv->edp_low_vswing) {
if (IS_SKL_ULX(dev) || IS_KBL_ULX(dev)) { if (IS_SKL_ULX(dev_priv) || IS_KBL_ULX(dev_priv)) {
*n_entries = ARRAY_SIZE(skl_y_ddi_translations_edp); *n_entries = ARRAY_SIZE(skl_y_ddi_translations_edp);
return skl_y_ddi_translations_edp; return skl_y_ddi_translations_edp;
} else if (IS_SKL_ULT(dev) || IS_KBL_ULT(dev)) { } else if (IS_SKL_ULT(dev_priv) || IS_KBL_ULT(dev_priv)) {
*n_entries = ARRAY_SIZE(skl_u_ddi_translations_edp); *n_entries = ARRAY_SIZE(skl_u_ddi_translations_edp);
return skl_u_ddi_translations_edp; return skl_u_ddi_translations_edp;
} else { } else {
...@@ -381,13 +379,13 @@ skl_get_buf_trans_edp(struct drm_device *dev, int *n_entries) ...@@ -381,13 +379,13 @@ skl_get_buf_trans_edp(struct drm_device *dev, int *n_entries)
} }
} }
return skl_get_buf_trans_dp(dev, n_entries); return skl_get_buf_trans_dp(dev_priv, n_entries);
} }
static const struct ddi_buf_trans * static const struct ddi_buf_trans *
skl_get_buf_trans_hdmi(struct drm_device *dev, int *n_entries) skl_get_buf_trans_hdmi(struct drm_i915_private *dev_priv, int *n_entries)
{ {
if (IS_SKL_ULX(dev) || IS_KBL_ULX(dev)) { if (IS_SKL_ULX(dev_priv) || IS_KBL_ULX(dev_priv)) {
*n_entries = ARRAY_SIZE(skl_y_ddi_translations_hdmi); *n_entries = ARRAY_SIZE(skl_y_ddi_translations_hdmi);
return skl_y_ddi_translations_hdmi; return skl_y_ddi_translations_hdmi;
} else { } else {
...@@ -403,10 +401,9 @@ skl_get_buf_trans_hdmi(struct drm_device *dev, int *n_entries) ...@@ -403,10 +401,9 @@ skl_get_buf_trans_hdmi(struct drm_device *dev, int *n_entries)
* in either FDI or DP modes only, as HDMI connections will work with both * in either FDI or DP modes only, as HDMI connections will work with both
* of those * of those
*/ */
static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port, static void intel_prepare_ddi_buffers(struct drm_i915_private *dev_priv,
bool supports_hdmi) enum port port, bool supports_hdmi)
{ {
struct drm_i915_private *dev_priv = dev->dev_private;
u32 iboost_bit = 0; u32 iboost_bit = 0;
int i, n_hdmi_entries, n_dp_entries, n_edp_entries, hdmi_default_entry, int i, n_hdmi_entries, n_dp_entries, n_edp_entries, hdmi_default_entry,
size; size;
...@@ -417,28 +414,28 @@ static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port, ...@@ -417,28 +414,28 @@ static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port,
const struct ddi_buf_trans *ddi_translations_hdmi; const struct ddi_buf_trans *ddi_translations_hdmi;
const struct ddi_buf_trans *ddi_translations; const struct ddi_buf_trans *ddi_translations;
if (IS_BROXTON(dev)) { if (IS_BROXTON(dev_priv)) {
if (!supports_hdmi) if (!supports_hdmi)
return; return;
/* Vswing programming for HDMI */ /* Vswing programming for HDMI */
bxt_ddi_vswing_sequence(dev, hdmi_level, port, bxt_ddi_vswing_sequence(dev_priv, hdmi_level, port,
INTEL_OUTPUT_HDMI); INTEL_OUTPUT_HDMI);
return; return;
} else if (IS_SKYLAKE(dev) || IS_KABYLAKE(dev)) { } else if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) {
ddi_translations_fdi = NULL; ddi_translations_fdi = NULL;
ddi_translations_dp = ddi_translations_dp =
skl_get_buf_trans_dp(dev, &n_dp_entries); skl_get_buf_trans_dp(dev_priv, &n_dp_entries);
ddi_translations_edp = ddi_translations_edp =
skl_get_buf_trans_edp(dev, &n_edp_entries); skl_get_buf_trans_edp(dev_priv, &n_edp_entries);
ddi_translations_hdmi = ddi_translations_hdmi =
skl_get_buf_trans_hdmi(dev, &n_hdmi_entries); skl_get_buf_trans_hdmi(dev_priv, &n_hdmi_entries);
hdmi_default_entry = 8; hdmi_default_entry = 8;
/* If we're boosting the current, set bit 31 of trans1 */ /* If we're boosting the current, set bit 31 of trans1 */
if (dev_priv->vbt.ddi_port_info[port].hdmi_boost_level || if (dev_priv->vbt.ddi_port_info[port].hdmi_boost_level ||
dev_priv->vbt.ddi_port_info[port].dp_boost_level) dev_priv->vbt.ddi_port_info[port].dp_boost_level)
iboost_bit = 1<<31; iboost_bit = 1<<31;
} else if (IS_BROADWELL(dev)) { } else if (IS_BROADWELL(dev_priv)) {
ddi_translations_fdi = bdw_ddi_translations_fdi; ddi_translations_fdi = bdw_ddi_translations_fdi;
ddi_translations_dp = bdw_ddi_translations_dp; ddi_translations_dp = bdw_ddi_translations_dp;
ddi_translations_edp = bdw_ddi_translations_edp; ddi_translations_edp = bdw_ddi_translations_edp;
...@@ -447,7 +444,7 @@ static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port, ...@@ -447,7 +444,7 @@ static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port,
n_dp_entries = ARRAY_SIZE(bdw_ddi_translations_dp); n_dp_entries = ARRAY_SIZE(bdw_ddi_translations_dp);
n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi); n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi);
hdmi_default_entry = 7; hdmi_default_entry = 7;
} else if (IS_HASWELL(dev)) { } else if (IS_HASWELL(dev_priv)) {
ddi_translations_fdi = hsw_ddi_translations_fdi; ddi_translations_fdi = hsw_ddi_translations_fdi;
ddi_translations_dp = hsw_ddi_translations_dp; ddi_translations_dp = hsw_ddi_translations_dp;
ddi_translations_edp = hsw_ddi_translations_dp; ddi_translations_edp = hsw_ddi_translations_dp;
...@@ -478,7 +475,7 @@ static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port, ...@@ -478,7 +475,7 @@ static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port,
size = n_dp_entries; size = n_dp_entries;
break; break;
case PORT_D: case PORT_D:
if (intel_dp_is_edp(dev, PORT_D)) { if (intel_dp_is_edp(dev_priv->dev, PORT_D)) {
ddi_translations = ddi_translations_edp; ddi_translations = ddi_translations_edp;
size = n_edp_entries; size = n_edp_entries;
} else { } else {
...@@ -545,7 +542,7 @@ void intel_prepare_ddi(struct drm_device *dev) ...@@ -545,7 +542,7 @@ void intel_prepare_ddi(struct drm_device *dev)
supports_hdmi = intel_dig_port && supports_hdmi = intel_dig_port &&
intel_dig_port_supports_hdmi(intel_dig_port); intel_dig_port_supports_hdmi(intel_dig_port);
intel_prepare_ddi_buffers(dev, port, supports_hdmi); intel_prepare_ddi_buffers(to_i915(dev), port, supports_hdmi);
visited[port] = true; visited[port] = true;
} }
} }
...@@ -2062,10 +2059,9 @@ void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc) ...@@ -2062,10 +2059,9 @@ void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc)
TRANS_CLK_SEL_DISABLED); TRANS_CLK_SEL_DISABLED);
} }
static void skl_ddi_set_iboost(struct drm_device *dev, u32 level, static void skl_ddi_set_iboost(struct drm_i915_private *dev_priv,
enum port port, int type) u32 level, enum port port, int type)
{ {
struct drm_i915_private *dev_priv = dev->dev_private;
const struct ddi_buf_trans *ddi_translations; const struct ddi_buf_trans *ddi_translations;
uint8_t iboost; uint8_t iboost;
uint8_t dp_iboost, hdmi_iboost; uint8_t dp_iboost, hdmi_iboost;
...@@ -2080,21 +2076,21 @@ static void skl_ddi_set_iboost(struct drm_device *dev, u32 level, ...@@ -2080,21 +2076,21 @@ static void skl_ddi_set_iboost(struct drm_device *dev, u32 level,
if (dp_iboost) { if (dp_iboost) {
iboost = dp_iboost; iboost = dp_iboost;
} else { } else {
ddi_translations = skl_get_buf_trans_dp(dev, &n_entries); ddi_translations = skl_get_buf_trans_dp(dev_priv, &n_entries);
iboost = ddi_translations[level].i_boost; iboost = ddi_translations[level].i_boost;
} }
} else if (type == INTEL_OUTPUT_EDP) { } else if (type == INTEL_OUTPUT_EDP) {
if (dp_iboost) { if (dp_iboost) {
iboost = dp_iboost; iboost = dp_iboost;
} else { } else {
ddi_translations = skl_get_buf_trans_edp(dev, &n_entries); ddi_translations = skl_get_buf_trans_edp(dev_priv, &n_entries);
iboost = ddi_translations[level].i_boost; iboost = ddi_translations[level].i_boost;
} }
} else if (type == INTEL_OUTPUT_HDMI) { } else if (type == INTEL_OUTPUT_HDMI) {
if (hdmi_iboost) { if (hdmi_iboost) {
iboost = hdmi_iboost; iboost = hdmi_iboost;
} else { } else {
ddi_translations = skl_get_buf_trans_hdmi(dev, &n_entries); ddi_translations = skl_get_buf_trans_hdmi(dev_priv, &n_entries);
iboost = ddi_translations[level].i_boost; iboost = ddi_translations[level].i_boost;
} }
} else { } else {
...@@ -2119,10 +2115,9 @@ static void skl_ddi_set_iboost(struct drm_device *dev, u32 level, ...@@ -2119,10 +2115,9 @@ static void skl_ddi_set_iboost(struct drm_device *dev, u32 level,
I915_WRITE(DISPIO_CR_TX_BMU_CR0, reg); I915_WRITE(DISPIO_CR_TX_BMU_CR0, reg);
} }
static void bxt_ddi_vswing_sequence(struct drm_device *dev, u32 level, static void bxt_ddi_vswing_sequence(struct drm_i915_private *dev_priv,
enum port port, int type) u32 level, enum port port, int type)
{ {
struct drm_i915_private *dev_priv = dev->dev_private;
const struct bxt_ddi_buf_trans *ddi_translations; const struct bxt_ddi_buf_trans *ddi_translations;
u32 n_entries, i; u32 n_entries, i;
uint32_t val; uint32_t val;
...@@ -2237,7 +2232,7 @@ static uint32_t translate_signal_level(int signal_levels) ...@@ -2237,7 +2232,7 @@ static uint32_t translate_signal_level(int signal_levels)
uint32_t ddi_signal_levels(struct intel_dp *intel_dp) uint32_t ddi_signal_levels(struct intel_dp *intel_dp)
{ {
struct intel_digital_port *dport = dp_to_dig_port(intel_dp); struct intel_digital_port *dport = dp_to_dig_port(intel_dp);
struct drm_device *dev = dport->base.base.dev; struct drm_i915_private *dev_priv = to_i915(dport->base.base.dev);
struct intel_encoder *encoder = &dport->base; struct intel_encoder *encoder = &dport->base;
uint8_t train_set = intel_dp->train_set[0]; uint8_t train_set = intel_dp->train_set[0];
int signal_levels = train_set & (DP_TRAIN_VOLTAGE_SWING_MASK | int signal_levels = train_set & (DP_TRAIN_VOLTAGE_SWING_MASK |
...@@ -2247,10 +2242,10 @@ uint32_t ddi_signal_levels(struct intel_dp *intel_dp) ...@@ -2247,10 +2242,10 @@ uint32_t ddi_signal_levels(struct intel_dp *intel_dp)
level = translate_signal_level(signal_levels); level = translate_signal_level(signal_levels);
if (IS_SKYLAKE(dev) || IS_KABYLAKE(dev)) if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv))
skl_ddi_set_iboost(dev, level, port, encoder->type); skl_ddi_set_iboost(dev_priv, level, port, encoder->type);
else if (IS_BROXTON(dev)) else if (IS_BROXTON(dev_priv))
bxt_ddi_vswing_sequence(dev, level, port, encoder->type); bxt_ddi_vswing_sequence(dev_priv, level, port, encoder->type);
return DDI_BUF_TRANS_SELECT(level); return DDI_BUF_TRANS_SELECT(level);
} }
...@@ -2333,7 +2328,7 @@ static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder) ...@@ -2333,7 +2328,7 @@ static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder)
if (IS_BROXTON(dev)) { if (IS_BROXTON(dev)) {
hdmi_level = dev_priv->vbt. hdmi_level = dev_priv->vbt.
ddi_port_info[port].hdmi_level_shift; ddi_port_info[port].hdmi_level_shift;
bxt_ddi_vswing_sequence(dev, hdmi_level, port, bxt_ddi_vswing_sequence(dev_priv, hdmi_level, port,
INTEL_OUTPUT_HDMI); INTEL_OUTPUT_HDMI);
} }
intel_hdmi->set_infoframes(encoder, intel_hdmi->set_infoframes(encoder,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment