[Intel-gfx] [RFC 26/30] drm/i915: create intel_digital_port and use it
Paulo Zanoni
przanoni at gmail.com
Wed Aug 29 00:06:57 CEST 2012
From: Paulo Zanoni <paulo.r.zanoni at intel.com>
The goal is to have one single encoder capable of controlling both DP
and HDMI outputs. This patch just adds the initial infrastructure, no
functional changes.
Previously, both intel_dp and intel_hdmi were intel_encoders. Now,
these 2 structs do not have intel_encoder as members anymore. The new
struct intel_digital_port has intel_encoder as a member, and it also
includes intel_dp and intel_hdmi as members. See the changes inside
intel_drv.h: it's the most important change, everything else is only
to make it compile and work.
For now, each intel_digital_port is still only able to control one of
HDMI or DP, but not both together.
Signed-off-by: Paulo Zanoni <paulo.r.zanoni at intel.com>
---
drivers/gpu/drm/i915/intel_ddi.c | 66 ++++++++++++++------------------------
drivers/gpu/drm/i915/intel_dp.c | 67 ++++++++++++++++++++++++---------------
drivers/gpu/drm/i915/intel_drv.h | 30 +++++++++++++++---
drivers/gpu/drm/i915/intel_hdmi.c | 28 +++++++++-------
4 files changed, 106 insertions(+), 85 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 055a1e8..c884b5c 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -652,21 +652,22 @@ bool intel_ddi_pll_mode_set(struct drm_crtc *crtc)
uint32_t wrpll_reg[] = {WRPLL_CTL1, WRPLL_CTL2};
uint32_t wrpll_sel[] = {PORT_CLK_SEL_WRPLL1, PORT_CLK_SEL_WRPLL2};
uint32_t temp;
+ struct intel_digital_port *intel_dig_port = NULL;
struct intel_dp *intel_dp = NULL;
- struct intel_hdmi *intel_hdmi = NULL;
for_each_encoder_on_crtc(dev, crtc, intel_encoder) {
switch (intel_encoder->type) {
case INTEL_OUTPUT_DISPLAYPORT:
case INTEL_OUTPUT_EDP:
is_dp = true;
- intel_dp = enc_to_intel_dp(&intel_encoder->base);
- port = intel_dp->port;
+ intel_dig_port = enc_to_dig_port(&intel_encoder->base);
+ intel_dp = &intel_dig_port->dp;
+ port = intel_dig_port->port;
break;
case INTEL_OUTPUT_HDMI:
is_hdmi = true;
- intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base);
- port = intel_hdmi->ddi_port;
+ intel_dig_port = enc_to_dig_port(&intel_encoder->base);
+ port = intel_dig_port->port;
break;
case INTEL_OUTPUT_ANALOG:
is_crt = true;
@@ -799,20 +800,13 @@ static void intel_ddi_enable_pipe(struct intel_encoder *intel_encoder)
struct drm_crtc *crtc = encoder->crtc;
struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
struct drm_display_mode *mode = &crtc->mode;
- int port;
int pipe = intel_crtc->pipe;
enum transcoder transcoder = intel_crtc->transcoder;
u32 func_val, msa_val;
- struct intel_hdmi *intel_hdmi = NULL;
- struct intel_dp *intel_dp = NULL;
-
- if (intel_encoder->type == INTEL_OUTPUT_HDMI) {
- intel_hdmi = enc_to_intel_hdmi(encoder);
- port = intel_hdmi->ddi_port;
- } else {
- intel_dp = enc_to_intel_dp(encoder);
- port = intel_dp->port;
- }
+ struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder);
+ struct intel_hdmi *intel_hdmi = &intel_dig_port->hdmi;
+ struct intel_dp *intel_dp = &intel_dig_port->dp;
+ int port = intel_dig_port->port;
if (transcoder != TRANSCODER_EDP)
I915_WRITE(PIPE_CLK_SEL(pipe), PIPE_CLK_SEL_PORT(port));
@@ -909,20 +903,12 @@ void intel_ddi_mode_set(struct drm_encoder *encoder,
{
struct drm_crtc *crtc = encoder->crtc;
struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
- struct intel_encoder *intel_encoder = to_intel_encoder(encoder);
- struct intel_hdmi *intel_hdmi = NULL;
- struct intel_dp *intel_dp = NULL;
- int port;
+ struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder);
+ struct intel_encoder *intel_encoder = &intel_dig_port->base;
+ struct intel_dp *intel_dp = &intel_dig_port->dp;
+ int port = intel_dig_port->port;
int pipe = intel_crtc->pipe;
- if (intel_encoder->type == INTEL_OUTPUT_HDMI) {
- intel_hdmi = enc_to_intel_hdmi(encoder);
- port = intel_hdmi->ddi_port;
- } else {
- intel_dp = enc_to_intel_dp(encoder);
- port = intel_dp->port;
- }
-
DRM_DEBUG_KMS("Preparing DDI mode for Haswell on port %c, pipe %c\n",
port_name(port), pipe_name(pipe));
@@ -967,8 +953,8 @@ void intel_ddi_dpms(struct drm_encoder *encoder, int mode)
{
struct drm_device *dev = encoder->dev;
struct drm_i915_private *dev_priv = dev->dev_private;
- struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
- int port = intel_hdmi->ddi_port;
+ struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder);
+ int port = intel_dig_port->port;
u32 temp;
temp = I915_READ(DDI_BUF_CTL(port));
@@ -1074,16 +1060,8 @@ void intel_ddi_disable(struct drm_encoder *encoder)
{
struct drm_i915_private *dev_priv = encoder->dev->dev_private;
struct drm_crtc *crtc = encoder->crtc;
- struct intel_encoder *intel_encoder = to_intel_encoder(encoder);
- int port;
-
- if (intel_encoder->type == INTEL_OUTPUT_HDMI) {
- struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
- port = intel_hdmi->ddi_port;
- } else {
- struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
- port = intel_dp->port;
- }
+ struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder);
+ int port = intel_dig_port->port;
if (intel_ddi_port_disabled(dev_priv, port))
return;
@@ -1156,10 +1134,12 @@ void intel_ddi_pll_init(struct drm_device *dev)
static void intel_ddi_enable_dp_port(struct intel_encoder *intel_encoder)
{
- struct drm_device *dev = intel_encoder->base.dev;
+ struct drm_encoder *encoder = &intel_encoder->base;
+ struct drm_device *dev = encoder->dev;
struct drm_i915_private *dev_priv = dev->dev_private;
- struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base);
- int port = intel_dp->port;
+ struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder);
+ struct intel_dp *intel_dp = &intel_dig_port->dp;
+ int port = intel_dig_port->port;
uint32_t tp_val;
tp_val = DP_TP_CTL_ENABLE | DP_TP_CTL_MODE_SST |
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index ffe61a8..fad2959 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -49,7 +49,9 @@
*/
static bool is_edp(struct intel_dp *intel_dp)
{
- return intel_dp->base.type == INTEL_OUTPUT_EDP;
+ struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
+
+ return intel_dig_port->base.type == INTEL_OUTPUT_EDP;
}
/**
@@ -78,7 +80,9 @@ static bool is_cpu_edp(struct intel_dp *intel_dp)
static struct drm_device *intel_dp_to_dev(struct intel_dp *intel_dp)
{
- return intel_dp->base.base.dev;
+ struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
+
+ return intel_dig_port->base.base.dev;
}
static struct intel_dp *intel_attached_dp(struct drm_connector *connector)
@@ -345,7 +349,8 @@ intel_dp_aux_ch(struct intel_dp *intel_dp,
uint8_t *recv, int recv_size)
{
uint32_t output_reg = intel_dp->output_reg;
- struct drm_device *dev = intel_dp_to_dev(intel_dp);
+ struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
+ struct drm_device *dev = intel_dig_port->base.base.dev;
struct drm_i915_private *dev_priv = dev->dev_private;
uint32_t ch_ctl = output_reg + 0x10;
uint32_t ch_data = ch_ctl + 4;
@@ -356,7 +361,7 @@ intel_dp_aux_ch(struct intel_dp *intel_dp,
int try, precharge;
if (IS_HASWELL(dev)) {
- switch (intel_dp->port) {
+ switch (intel_dig_port->port) {
case PORT_A:
ch_ctl = DPA_AUX_CH_CTL;
ch_data = DPA_AUX_CH_DATA1;
@@ -374,7 +379,8 @@ intel_dp_aux_ch(struct intel_dp *intel_dp,
ch_data = PCH_DPD_AUX_CH_DATA;
break;
default:
- WARN(1, "Invalid port %c\n", port_name(intel_dp->port));
+ WARN(1, "Invalid port %c\n",
+ port_name(intel_dig_port->port));
break;
}
}
@@ -1716,13 +1722,15 @@ intel_dp_set_link_train(struct intel_dp *intel_dp,
uint32_t dp_reg_value,
uint8_t dp_train_pat)
{
+ struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
struct drm_device *dev = intel_dp_to_dev(intel_dp);
struct drm_i915_private *dev_priv = dev->dev_private;
+ enum port port = intel_dig_port->port;
int ret;
uint32_t temp;
if (IS_HASWELL(dev)) {
- temp = I915_READ(DP_TP_CTL(intel_dp->port));
+ temp = I915_READ(DP_TP_CTL(port));
if (dp_train_pat & DP_LINK_SCRAMBLING_DISABLE)
temp |= DP_TP_CTL_SCRAMBLE_DISABLE;
@@ -1733,9 +1741,9 @@ intel_dp_set_link_train(struct intel_dp *intel_dp,
switch (dp_train_pat & DP_TRAINING_PATTERN_MASK) {
case DP_TRAINING_PATTERN_DISABLE:
temp |= DP_TP_CTL_LINK_TRAIN_IDLE;
- I915_WRITE(DP_TP_CTL(intel_dp->port), temp);
+ I915_WRITE(DP_TP_CTL(port), temp);
- if (wait_for((I915_READ(DP_TP_STATUS(intel_dp->port)) &
+ if (wait_for((I915_READ(DP_TP_STATUS(port)) &
DP_TP_STATUS_IDLE_DONE) == 0, 1))
DRM_ERROR("Timed out waiting for DP idle patterns\n");
@@ -1753,7 +1761,7 @@ intel_dp_set_link_train(struct intel_dp *intel_dp,
temp |= DP_TP_CTL_LINK_TRAIN_PAT3;
break;
}
- I915_WRITE(DP_TP_CTL(intel_dp->port), temp);
+ I915_WRITE(DP_TP_CTL(port), temp);
} else if (HAS_PCH_CPT(dev) &&
(IS_GEN7(dev) || !is_cpu_edp(intel_dp))) {
@@ -1819,10 +1827,10 @@ intel_dp_set_link_train(struct intel_dp *intel_dp,
static void
intel_dp_start_link_train(struct intel_dp *intel_dp)
{
- struct drm_encoder *encoder = &intel_dp->base.base;
+ struct drm_encoder *encoder = &dp_to_dig_port(intel_dp)->base.base;
struct drm_device *dev = encoder->dev;
struct drm_i915_private *dev_priv = dev->dev_private;
- struct intel_crtc *intel_crtc = to_intel_crtc(intel_dp->base.base.crtc);
+ struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
int i;
uint8_t voltage;
bool clock_recovery = false;
@@ -2009,12 +2017,13 @@ intel_dp_complete_link_train(struct intel_dp *intel_dp)
static void
intel_dp_link_down(struct intel_dp *intel_dp)
{
- struct drm_device *dev = intel_dp_to_dev(intel_dp);
+ struct intel_encoder *intel_encoder = &dp_to_dig_port(intel_dp)->base;
+ struct drm_device *dev = intel_encoder->base.dev;
struct drm_i915_private *dev_priv = dev->dev_private;
uint32_t DP = intel_dp->DP;
if (IS_HASWELL(dev)) {
- intel_ddi_disable(&intel_dp->base.base);
+ intel_ddi_disable(&intel_encoder->base);
return;
}
@@ -2050,7 +2059,7 @@ intel_dp_link_down(struct intel_dp *intel_dp)
if (HAS_PCH_IBX(dev) &&
I915_READ(intel_dp->output_reg) & DP_PIPEB_SELECT) {
- struct drm_crtc *crtc = intel_dp->base.base.crtc;
+ struct drm_crtc *crtc = intel_encoder->base.crtc;
/* Hardware workaround: leaving our transcoder select
* set to transcoder B while it's off will prevent the
@@ -2153,13 +2162,14 @@ intel_dp_handle_test_request(struct intel_dp *intel_dp)
static void
intel_dp_check_link_status(struct intel_dp *intel_dp)
{
+ struct intel_encoder *intel_encoder = &dp_to_dig_port(intel_dp)->base;
u8 sink_irq_vector;
u8 link_status[DP_LINK_STATUS_SIZE];
if (intel_dp->dpms_mode != DRM_MODE_DPMS_ON)
return;
- if (!intel_dp->base.base.crtc)
+ if (!intel_encoder->base.crtc)
return;
/* Try to read receiver status if the link appears to be up */
@@ -2190,7 +2200,7 @@ intel_dp_check_link_status(struct intel_dp *intel_dp)
if (!intel_channel_eq_ok(intel_dp, link_status)) {
DRM_DEBUG_KMS("%s: channel EQ not ok, retraining\n",
- drm_get_encoder_name(&intel_dp->base.base));
+ drm_get_encoder_name(&intel_encoder->base));
intel_dp_start_link_train(intel_dp);
intel_dp_complete_link_train(intel_dp);
}
@@ -2409,7 +2419,8 @@ intel_dp_set_property(struct drm_connector *connector,
uint64_t val)
{
struct drm_i915_private *dev_priv = connector->dev->dev_private;
- struct intel_dp *intel_dp = intel_attached_dp(connector);
+ struct intel_encoder *intel_encoder = intel_attached_encoder(connector);
+ struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base);
int ret;
ret = drm_connector_property_set_value(connector, property, val);
@@ -2448,8 +2459,8 @@ intel_dp_set_property(struct drm_connector *connector,
return -EINVAL;
done:
- if (intel_dp->base.base.crtc) {
- struct drm_crtc *crtc = intel_dp->base.base.crtc;
+ if (intel_encoder->base.crtc) {
+ struct drm_crtc *crtc = intel_encoder->base.crtc;
drm_crtc_helper_set_mode(crtc, &crtc->mode,
crtc->x, crtc->y,
crtc->fb);
@@ -2473,7 +2484,8 @@ intel_dp_destroy(struct drm_connector *connector)
static void intel_dp_encoder_destroy(struct drm_encoder *encoder)
{
- struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
+ struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder);
+ struct intel_dp *intel_dp = &intel_dig_port->dp;
i2c_del_adapter(&intel_dp->adapter);
drm_encoder_cleanup(encoder);
@@ -2482,7 +2494,7 @@ static void intel_dp_encoder_destroy(struct drm_encoder *encoder)
cancel_delayed_work_sync(&intel_dp->panel_vdd_work);
ironlake_panel_vdd_off_sync(intel_dp);
}
- kfree(intel_dp);
+ kfree(intel_dig_port);
}
static const struct drm_encoder_helper_funcs intel_dp_helper_funcs_hsw = {
@@ -2582,23 +2594,26 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port)
struct intel_dp *intel_dp;
struct intel_encoder *intel_encoder;
struct intel_connector *intel_connector;
+ struct intel_digital_port *intel_dig_port;
const char *name = NULL;
int type;
- intel_dp = kzalloc(sizeof(struct intel_dp), GFP_KERNEL);
- if (!intel_dp)
+ intel_dig_port = kzalloc(sizeof(struct intel_digital_port), GFP_KERNEL);
+ if (!intel_dig_port)
return;
+ intel_dig_port->port = port;
+
+ intel_dp = &intel_dig_port->dp;
intel_dp->output_reg = output_reg;
- intel_dp->port = port;
intel_dp->dpms_mode = -1;
intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL);
if (!intel_connector) {
- kfree(intel_dp);
+ kfree(intel_dig_port);
return;
}
- intel_encoder = &intel_dp->base;
+ intel_encoder = &intel_dig_port->base;
if (HAS_PCH_SPLIT(dev) && output_reg == PCH_DP_D)
if (intel_dpd_is_edp(dev))
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 01173d4..d096d4d 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -282,10 +282,8 @@ struct dip_infoframe {
} __attribute__((packed));
struct intel_hdmi {
- struct intel_encoder base;
u32 sdvox_reg;
int ddc_bus;
- int ddi_port;
uint32_t color_range;
bool has_hdmi_sink;
bool has_audio;
@@ -300,13 +298,11 @@ struct intel_hdmi {
#define DP_LINK_CONFIGURATION_SIZE 9
struct intel_dp {
- struct intel_encoder base;
uint32_t output_reg;
uint32_t DP;
uint8_t link_configuration[DP_LINK_CONFIGURATION_SIZE];
bool has_audio;
enum hdmi_force_audio force_audio;
- enum port port;
uint32_t color_range;
int dpms_mode;
uint8_t link_bw;
@@ -328,6 +324,13 @@ struct intel_dp {
int edid_mode_count;
};
+struct intel_digital_port {
+ struct intel_encoder base;
+ enum port port;
+ struct intel_dp dp;
+ struct intel_hdmi hdmi;
+};
+
static inline struct drm_crtc *
intel_get_crtc_for_pipe(struct drm_device *dev, int pipe)
{
@@ -425,7 +428,24 @@ static inline struct intel_encoder *intel_attached_encoder(struct drm_connector
}
static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
{
- return container_of(encoder, struct intel_dp, base.base);
+ struct intel_digital_port *intel_dig_port =
+ container_of(encoder, struct intel_digital_port, base.base);
+ return &intel_dig_port->dp;
+}
+static inline struct intel_digital_port *
+enc_to_dig_port(struct drm_encoder *encoder)
+{
+ return container_of(encoder, struct intel_digital_port, base.base);
+}
+static inline struct intel_digital_port *
+dp_to_dig_port(struct intel_dp *intel_dp)
+{
+ return container_of(intel_dp, struct intel_digital_port, dp);
+}
+static inline struct intel_digital_port *
+hdmi_to_dig_port(struct intel_hdmi *intel_hdmi)
+{
+ return container_of(intel_hdmi, struct intel_digital_port, hdmi);
}
extern void intel_connector_attach_encoder(struct intel_connector *connector,
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
index 543b1f1..97c01e8 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -39,7 +39,7 @@
static struct drm_device *intel_hdmi_to_dev(struct intel_hdmi *intel_hdmi)
{
- return intel_hdmi->base.base.dev;
+ return hdmi_to_dig_port(intel_hdmi)->base.base.dev;
}
static void
@@ -57,13 +57,15 @@ assert_hdmi_port_disabled(struct intel_hdmi *intel_hdmi)
struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder)
{
- return container_of(encoder, struct intel_hdmi, base.base);
+ struct intel_digital_port *intel_dig_port =
+ container_of(encoder, struct intel_digital_port, base.base);
+
+ return &intel_dig_port->hdmi;
}
static struct intel_hdmi *intel_attached_hdmi(struct drm_connector *connector)
{
- return container_of(intel_attached_encoder(connector),
- struct intel_hdmi, base);
+ return enc_to_intel_hdmi(&intel_attached_encoder(connector)->base);
}
void intel_dip_infoframe_csum(struct dip_infoframe *frame)
@@ -797,6 +799,8 @@ intel_hdmi_set_property(struct drm_connector *connector,
uint64_t val)
{
struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
+ struct intel_encoder *intel_encoder =
+ &hdmi_to_dig_port(intel_hdmi)->base;
struct drm_i915_private *dev_priv = connector->dev->dev_private;
int ret;
@@ -836,8 +840,8 @@ intel_hdmi_set_property(struct drm_connector *connector,
return -EINVAL;
done:
- if (intel_hdmi->base.base.crtc) {
- struct drm_crtc *crtc = intel_hdmi->base.base.crtc;
+ if (intel_encoder->base.crtc) {
+ struct drm_crtc *crtc = intel_encoder->base.crtc;
drm_crtc_helper_set_mode(crtc, &crtc->mode,
crtc->x, crtc->y,
crtc->fb);
@@ -901,19 +905,21 @@ void intel_hdmi_init(struct drm_device *dev, int sdvox_reg, enum port port)
struct drm_connector *connector;
struct intel_encoder *intel_encoder;
struct intel_connector *intel_connector;
+ struct intel_digital_port *intel_dig_port;
struct intel_hdmi *intel_hdmi;
- intel_hdmi = kzalloc(sizeof(struct intel_hdmi), GFP_KERNEL);
- if (!intel_hdmi)
+ intel_dig_port = kzalloc(sizeof(struct intel_digital_port), GFP_KERNEL);
+ if (!intel_dig_port)
return;
intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL);
if (!intel_connector) {
- kfree(intel_hdmi);
+ kfree(intel_dig_port);
return;
}
- intel_encoder = &intel_hdmi->base;
+ intel_hdmi = &intel_dig_port->hdmi;
+ intel_encoder = &intel_dig_port->base;
drm_encoder_init(dev, &intel_encoder->base, &intel_hdmi_enc_funcs,
DRM_MODE_ENCODER_TMDS);
@@ -931,7 +937,7 @@ void intel_hdmi_init(struct drm_device *dev, int sdvox_reg, enum port port)
intel_encoder->cloneable = false;
- intel_hdmi->ddi_port = port;
+ intel_dig_port->port = port;
switch (port) {
case PORT_B:
intel_hdmi->ddc_bus = GMBUS_PORT_DPB;
--
1.7.11.2
More information about the Intel-gfx
mailing list