mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-27 14:43:58 +08:00
drm/i915: Refactor code to select the DDI buf translation table
Split the code to select the correct translation table into DP, eDP and FDI specific helpers. This reduces the clutter in intel_prepare_dp_ddi_buffers(), and we'll have other uses for some of these new helper functions later on. v2: Fix typo in commit message (David) Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/20170223173507.17600-1-ville.syrjala@linux.intel.com Reviewed-by: David Weinehall <david.weinehall@linux.intel.com>
This commit is contained in:
parent
754a76591b
commit
7d1c42e679
@ -468,6 +468,59 @@ static int intel_ddi_hdmi_level(struct drm_i915_private *dev_priv, enum port por
|
|||||||
return hdmi_level;
|
return hdmi_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct ddi_buf_trans *
|
||||||
|
intel_ddi_get_buf_trans_dp(struct drm_i915_private *dev_priv,
|
||||||
|
int *n_entries)
|
||||||
|
{
|
||||||
|
if (IS_KABYLAKE(dev_priv)) {
|
||||||
|
return kbl_get_buf_trans_dp(dev_priv, n_entries);
|
||||||
|
} else if (IS_SKYLAKE(dev_priv)) {
|
||||||
|
return skl_get_buf_trans_dp(dev_priv, n_entries);
|
||||||
|
} else if (IS_BROADWELL(dev_priv)) {
|
||||||
|
*n_entries = ARRAY_SIZE(bdw_ddi_translations_dp);
|
||||||
|
return bdw_ddi_translations_dp;
|
||||||
|
} else if (IS_HASWELL(dev_priv)) {
|
||||||
|
*n_entries = ARRAY_SIZE(hsw_ddi_translations_dp);
|
||||||
|
return hsw_ddi_translations_dp;
|
||||||
|
}
|
||||||
|
|
||||||
|
*n_entries = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct ddi_buf_trans *
|
||||||
|
intel_ddi_get_buf_trans_edp(struct drm_i915_private *dev_priv,
|
||||||
|
int *n_entries)
|
||||||
|
{
|
||||||
|
if (IS_KABYLAKE(dev_priv) || IS_SKYLAKE(dev_priv)) {
|
||||||
|
return skl_get_buf_trans_edp(dev_priv, n_entries);
|
||||||
|
} else if (IS_BROADWELL(dev_priv)) {
|
||||||
|
return bdw_get_buf_trans_edp(dev_priv, n_entries);
|
||||||
|
} else if (IS_HASWELL(dev_priv)) {
|
||||||
|
*n_entries = ARRAY_SIZE(hsw_ddi_translations_dp);
|
||||||
|
return hsw_ddi_translations_dp;
|
||||||
|
}
|
||||||
|
|
||||||
|
*n_entries = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct ddi_buf_trans *
|
||||||
|
intel_ddi_get_buf_trans_fdi(struct drm_i915_private *dev_priv,
|
||||||
|
int *n_entries)
|
||||||
|
{
|
||||||
|
if (IS_BROADWELL(dev_priv)) {
|
||||||
|
*n_entries = ARRAY_SIZE(hsw_ddi_translations_fdi);
|
||||||
|
return hsw_ddi_translations_fdi;
|
||||||
|
} else if (IS_HASWELL(dev_priv)) {
|
||||||
|
*n_entries = ARRAY_SIZE(hsw_ddi_translations_fdi);
|
||||||
|
return hsw_ddi_translations_fdi;
|
||||||
|
}
|
||||||
|
|
||||||
|
*n_entries = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Starting with Haswell, DDI port buffers must be programmed with correct
|
* Starting with Haswell, DDI port buffers must be programmed with correct
|
||||||
* values in advance. This function programs the correct values for
|
* values in advance. This function programs the correct values for
|
||||||
@ -477,45 +530,29 @@ void intel_prepare_dp_ddi_buffers(struct intel_encoder *encoder)
|
|||||||
{
|
{
|
||||||
struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
|
struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
|
||||||
u32 iboost_bit = 0;
|
u32 iboost_bit = 0;
|
||||||
int i, n_dp_entries, n_edp_entries, size;
|
int i, n_entries;
|
||||||
enum port port = intel_ddi_get_encoder_port(encoder);
|
enum port port = intel_ddi_get_encoder_port(encoder);
|
||||||
const struct ddi_buf_trans *ddi_translations_fdi;
|
|
||||||
const struct ddi_buf_trans *ddi_translations_dp;
|
|
||||||
const struct ddi_buf_trans *ddi_translations_edp;
|
|
||||||
const struct ddi_buf_trans *ddi_translations;
|
const struct ddi_buf_trans *ddi_translations;
|
||||||
|
|
||||||
if (IS_GEN9_LP(dev_priv))
|
if (IS_GEN9_LP(dev_priv))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (IS_KABYLAKE(dev_priv)) {
|
switch (encoder->type) {
|
||||||
ddi_translations_fdi = NULL;
|
case INTEL_OUTPUT_EDP:
|
||||||
ddi_translations_dp =
|
ddi_translations = intel_ddi_get_buf_trans_edp(dev_priv,
|
||||||
kbl_get_buf_trans_dp(dev_priv, &n_dp_entries);
|
&n_entries);
|
||||||
ddi_translations_edp =
|
break;
|
||||||
skl_get_buf_trans_edp(dev_priv, &n_edp_entries);
|
case INTEL_OUTPUT_DP:
|
||||||
} else if (IS_SKYLAKE(dev_priv)) {
|
ddi_translations = intel_ddi_get_buf_trans_dp(dev_priv,
|
||||||
ddi_translations_fdi = NULL;
|
&n_entries);
|
||||||
ddi_translations_dp =
|
break;
|
||||||
skl_get_buf_trans_dp(dev_priv, &n_dp_entries);
|
case INTEL_OUTPUT_ANALOG:
|
||||||
ddi_translations_edp =
|
ddi_translations = intel_ddi_get_buf_trans_fdi(dev_priv,
|
||||||
skl_get_buf_trans_edp(dev_priv, &n_edp_entries);
|
&n_entries);
|
||||||
} else if (IS_BROADWELL(dev_priv)) {
|
break;
|
||||||
ddi_translations_fdi = bdw_ddi_translations_fdi;
|
default:
|
||||||
ddi_translations_dp = bdw_ddi_translations_dp;
|
MISSING_CASE(encoder->type);
|
||||||
ddi_translations_edp = bdw_get_buf_trans_edp(dev_priv, &n_edp_entries);
|
return;
|
||||||
n_dp_entries = ARRAY_SIZE(bdw_ddi_translations_dp);
|
|
||||||
} else if (IS_HASWELL(dev_priv)) {
|
|
||||||
ddi_translations_fdi = hsw_ddi_translations_fdi;
|
|
||||||
ddi_translations_dp = hsw_ddi_translations_dp;
|
|
||||||
ddi_translations_edp = hsw_ddi_translations_dp;
|
|
||||||
n_dp_entries = n_edp_entries = ARRAY_SIZE(hsw_ddi_translations_dp);
|
|
||||||
} else {
|
|
||||||
WARN(1, "ddi translation table missing\n");
|
|
||||||
ddi_translations_edp = bdw_ddi_translations_dp;
|
|
||||||
ddi_translations_fdi = bdw_ddi_translations_fdi;
|
|
||||||
ddi_translations_dp = bdw_ddi_translations_dp;
|
|
||||||
n_edp_entries = ARRAY_SIZE(bdw_ddi_translations_edp);
|
|
||||||
n_dp_entries = ARRAY_SIZE(bdw_ddi_translations_dp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_GEN9_BC(dev_priv)) {
|
if (IS_GEN9_BC(dev_priv)) {
|
||||||
@ -525,28 +562,11 @@ void intel_prepare_dp_ddi_buffers(struct intel_encoder *encoder)
|
|||||||
|
|
||||||
if (WARN_ON(encoder->type == INTEL_OUTPUT_EDP &&
|
if (WARN_ON(encoder->type == INTEL_OUTPUT_EDP &&
|
||||||
port != PORT_A && port != PORT_E &&
|
port != PORT_A && port != PORT_E &&
|
||||||
n_edp_entries > 9))
|
n_entries > 9))
|
||||||
n_edp_entries = 9;
|
n_entries = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (encoder->type) {
|
for (i = 0; i < n_entries; i++) {
|
||||||
case INTEL_OUTPUT_EDP:
|
|
||||||
ddi_translations = ddi_translations_edp;
|
|
||||||
size = n_edp_entries;
|
|
||||||
break;
|
|
||||||
case INTEL_OUTPUT_DP:
|
|
||||||
ddi_translations = ddi_translations_dp;
|
|
||||||
size = n_dp_entries;
|
|
||||||
break;
|
|
||||||
case INTEL_OUTPUT_ANALOG:
|
|
||||||
ddi_translations = ddi_translations_fdi;
|
|
||||||
size = n_dp_entries;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
BUG();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < size; i++) {
|
|
||||||
I915_WRITE(DDI_BUF_TRANS_LO(port, i),
|
I915_WRITE(DDI_BUF_TRANS_LO(port, i),
|
||||||
ddi_translations[i].trans1 | iboost_bit);
|
ddi_translations[i].trans1 | iboost_bit);
|
||||||
I915_WRITE(DDI_BUF_TRANS_HI(port, i),
|
I915_WRITE(DDI_BUF_TRANS_HI(port, i),
|
||||||
|
Loading…
Reference in New Issue
Block a user