Commit 2a5c0832 authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915: s/is_sdvob/enum port/

Replace the is_sdvob bool and some sdvo_reg checks with enum port. This
makes the SDVO code look more modern, and gets rid of explicit register
offset checks in the code which will hamper register type checking.

v2: Add assert_sdvo_port_valid() (Chris)
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/1446838199-3666-1-git-send-email-ville.syrjala@linux.intel.com
parent c48b5305
...@@ -14278,7 +14278,7 @@ static void intel_setup_outputs(struct drm_device *dev) ...@@ -14278,7 +14278,7 @@ static void intel_setup_outputs(struct drm_device *dev)
if (I915_READ(PCH_HDMIB) & SDVO_DETECTED) { if (I915_READ(PCH_HDMIB) & SDVO_DETECTED) {
/* PCH SDVOB multiplex with HDMIB */ /* PCH SDVOB multiplex with HDMIB */
found = intel_sdvo_init(dev, PCH_SDVOB, true); found = intel_sdvo_init(dev, PCH_SDVOB, PORT_B);
if (!found) if (!found)
intel_hdmi_init(dev, PCH_HDMIB, PORT_B); intel_hdmi_init(dev, PCH_HDMIB, PORT_B);
if (!found && (I915_READ(PCH_DP_B) & DP_DETECTED)) if (!found && (I915_READ(PCH_DP_B) & DP_DETECTED))
...@@ -14334,7 +14334,7 @@ static void intel_setup_outputs(struct drm_device *dev) ...@@ -14334,7 +14334,7 @@ static void intel_setup_outputs(struct drm_device *dev)
if (I915_READ(GEN3_SDVOB) & SDVO_DETECTED) { if (I915_READ(GEN3_SDVOB) & SDVO_DETECTED) {
DRM_DEBUG_KMS("probing SDVOB\n"); DRM_DEBUG_KMS("probing SDVOB\n");
found = intel_sdvo_init(dev, GEN3_SDVOB, true); found = intel_sdvo_init(dev, GEN3_SDVOB, PORT_B);
if (!found && IS_G4X(dev)) { if (!found && IS_G4X(dev)) {
DRM_DEBUG_KMS("probing HDMI on SDVOB\n"); DRM_DEBUG_KMS("probing HDMI on SDVOB\n");
intel_hdmi_init(dev, GEN4_HDMIB, PORT_B); intel_hdmi_init(dev, GEN4_HDMIB, PORT_B);
...@@ -14348,7 +14348,7 @@ static void intel_setup_outputs(struct drm_device *dev) ...@@ -14348,7 +14348,7 @@ static void intel_setup_outputs(struct drm_device *dev)
if (I915_READ(GEN3_SDVOB) & SDVO_DETECTED) { if (I915_READ(GEN3_SDVOB) & SDVO_DETECTED) {
DRM_DEBUG_KMS("probing SDVOC\n"); DRM_DEBUG_KMS("probing SDVOC\n");
found = intel_sdvo_init(dev, GEN3_SDVOC, false); found = intel_sdvo_init(dev, GEN3_SDVOC, PORT_C);
} }
if (!found && (I915_READ(GEN3_SDVOC) & SDVO_DETECTED)) { if (!found && (I915_READ(GEN3_SDVOC) & SDVO_DETECTED)) {
......
...@@ -1465,7 +1465,7 @@ void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv, ...@@ -1465,7 +1465,7 @@ void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
uint32_t ilk_pipe_pixel_rate(const struct intel_crtc_state *pipe_config); uint32_t ilk_pipe_pixel_rate(const struct intel_crtc_state *pipe_config);
/* intel_sdvo.c */ /* intel_sdvo.c */
bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob); bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, enum port port);
/* intel_sprite.c */ /* intel_sprite.c */
......
...@@ -120,8 +120,7 @@ struct intel_sdvo { ...@@ -120,8 +120,7 @@ struct intel_sdvo {
*/ */
bool is_tv; bool is_tv;
/* On different gens SDVOB is at different places. */ enum port port;
bool is_sdvob;
/* This is for current tv format name */ /* This is for current tv format name */
int tv_format_index; int tv_format_index;
...@@ -245,7 +244,7 @@ static void intel_sdvo_write_sdvox(struct intel_sdvo *intel_sdvo, u32 val) ...@@ -245,7 +244,7 @@ static void intel_sdvo_write_sdvox(struct intel_sdvo *intel_sdvo, u32 val)
u32 bval = val, cval = val; u32 bval = val, cval = val;
int i; int i;
if (intel_sdvo->sdvo_reg == PCH_SDVOB) { if (HAS_PCH_SPLIT(dev_priv)) {
I915_WRITE(intel_sdvo->sdvo_reg, val); I915_WRITE(intel_sdvo->sdvo_reg, val);
POSTING_READ(intel_sdvo->sdvo_reg); POSTING_READ(intel_sdvo->sdvo_reg);
/* /*
...@@ -259,7 +258,7 @@ static void intel_sdvo_write_sdvox(struct intel_sdvo *intel_sdvo, u32 val) ...@@ -259,7 +258,7 @@ static void intel_sdvo_write_sdvox(struct intel_sdvo *intel_sdvo, u32 val)
return; return;
} }
if (intel_sdvo->sdvo_reg == GEN3_SDVOB) if (intel_sdvo->port == PORT_B)
cval = I915_READ(GEN3_SDVOC); cval = I915_READ(GEN3_SDVOC);
else else
bval = I915_READ(GEN3_SDVOB); bval = I915_READ(GEN3_SDVOB);
...@@ -422,7 +421,7 @@ static const struct _sdvo_cmd_name { ...@@ -422,7 +421,7 @@ static const struct _sdvo_cmd_name {
SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_DATA), SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_DATA),
}; };
#define SDVO_NAME(svdo) ((svdo)->is_sdvob ? "SDVOB" : "SDVOC") #define SDVO_NAME(svdo) ((svdo)->port == PORT_B ? "SDVOB" : "SDVOC")
static void intel_sdvo_debug_write(struct intel_sdvo *intel_sdvo, u8 cmd, static void intel_sdvo_debug_write(struct intel_sdvo *intel_sdvo, u8 cmd,
const void *args, int args_len) const void *args, int args_len)
...@@ -1282,14 +1281,10 @@ static void intel_sdvo_pre_enable(struct intel_encoder *intel_encoder) ...@@ -1282,14 +1281,10 @@ static void intel_sdvo_pre_enable(struct intel_encoder *intel_encoder)
sdvox |= SDVO_BORDER_ENABLE; sdvox |= SDVO_BORDER_ENABLE;
} else { } else {
sdvox = I915_READ(intel_sdvo->sdvo_reg); sdvox = I915_READ(intel_sdvo->sdvo_reg);
switch (intel_sdvo->sdvo_reg) { if (intel_sdvo->port == PORT_B)
case GEN3_SDVOB:
sdvox &= SDVOB_PRESERVE_MASK; sdvox &= SDVOB_PRESERVE_MASK;
break; else
case GEN3_SDVOC:
sdvox &= SDVOC_PRESERVE_MASK; sdvox &= SDVOC_PRESERVE_MASK;
break;
}
sdvox |= (9 << 19) | SDVO_BORDER_ENABLE; sdvox |= (9 << 19) | SDVO_BORDER_ENABLE;
} }
...@@ -2262,7 +2257,7 @@ intel_sdvo_select_ddc_bus(struct drm_i915_private *dev_priv, ...@@ -2262,7 +2257,7 @@ intel_sdvo_select_ddc_bus(struct drm_i915_private *dev_priv,
{ {
struct sdvo_device_mapping *mapping; struct sdvo_device_mapping *mapping;
if (sdvo->is_sdvob) if (sdvo->port == PORT_B)
mapping = &(dev_priv->sdvo_mappings[0]); mapping = &(dev_priv->sdvo_mappings[0]);
else else
mapping = &(dev_priv->sdvo_mappings[1]); mapping = &(dev_priv->sdvo_mappings[1]);
...@@ -2280,7 +2275,7 @@ intel_sdvo_select_i2c_bus(struct drm_i915_private *dev_priv, ...@@ -2280,7 +2275,7 @@ intel_sdvo_select_i2c_bus(struct drm_i915_private *dev_priv,
struct sdvo_device_mapping *mapping; struct sdvo_device_mapping *mapping;
u8 pin; u8 pin;
if (sdvo->is_sdvob) if (sdvo->port == PORT_B)
mapping = &dev_priv->sdvo_mappings[0]; mapping = &dev_priv->sdvo_mappings[0];
else else
mapping = &dev_priv->sdvo_mappings[1]; mapping = &dev_priv->sdvo_mappings[1];
...@@ -2318,7 +2313,7 @@ intel_sdvo_get_slave_addr(struct drm_device *dev, struct intel_sdvo *sdvo) ...@@ -2318,7 +2313,7 @@ intel_sdvo_get_slave_addr(struct drm_device *dev, struct intel_sdvo *sdvo)
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct sdvo_device_mapping *my_mapping, *other_mapping; struct sdvo_device_mapping *my_mapping, *other_mapping;
if (sdvo->is_sdvob) { if (sdvo->port == PORT_B) {
my_mapping = &dev_priv->sdvo_mappings[0]; my_mapping = &dev_priv->sdvo_mappings[0];
other_mapping = &dev_priv->sdvo_mappings[1]; other_mapping = &dev_priv->sdvo_mappings[1];
} else { } else {
...@@ -2343,7 +2338,7 @@ intel_sdvo_get_slave_addr(struct drm_device *dev, struct intel_sdvo *sdvo) ...@@ -2343,7 +2338,7 @@ intel_sdvo_get_slave_addr(struct drm_device *dev, struct intel_sdvo *sdvo)
/* No SDVO device info is found for another DVO port, /* No SDVO device info is found for another DVO port,
* so use mapping assumption we had before BIOS parsing. * so use mapping assumption we had before BIOS parsing.
*/ */
if (sdvo->is_sdvob) if (sdvo->port == PORT_B)
return 0x70; return 0x70;
else else
return 0x72; return 0x72;
...@@ -2950,18 +2945,30 @@ intel_sdvo_init_ddc_proxy(struct intel_sdvo *sdvo, ...@@ -2950,18 +2945,30 @@ intel_sdvo_init_ddc_proxy(struct intel_sdvo *sdvo,
return i2c_add_adapter(&sdvo->ddc) == 0; return i2c_add_adapter(&sdvo->ddc) == 0;
} }
bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob) static void assert_sdvo_port_valid(const struct drm_i915_private *dev_priv,
enum port port)
{
if (HAS_PCH_SPLIT(dev_priv))
WARN_ON(port != PORT_B);
else
WARN_ON(port != PORT_B && port != PORT_C);
}
bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, enum port port)
{ {
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_encoder *intel_encoder; struct intel_encoder *intel_encoder;
struct intel_sdvo *intel_sdvo; struct intel_sdvo *intel_sdvo;
int i; int i;
assert_sdvo_port_valid(dev_priv, port);
intel_sdvo = kzalloc(sizeof(*intel_sdvo), GFP_KERNEL); intel_sdvo = kzalloc(sizeof(*intel_sdvo), GFP_KERNEL);
if (!intel_sdvo) if (!intel_sdvo)
return false; return false;
intel_sdvo->sdvo_reg = sdvo_reg; intel_sdvo->sdvo_reg = sdvo_reg;
intel_sdvo->is_sdvob = is_sdvob; intel_sdvo->port = port;
intel_sdvo->slave_addr = intel_sdvo_get_slave_addr(dev, intel_sdvo) >> 1; intel_sdvo->slave_addr = intel_sdvo_get_slave_addr(dev, intel_sdvo) >> 1;
intel_sdvo_select_i2c_bus(dev_priv, intel_sdvo); intel_sdvo_select_i2c_bus(dev_priv, intel_sdvo);
if (!intel_sdvo_init_ddc_proxy(intel_sdvo, dev)) if (!intel_sdvo_init_ddc_proxy(intel_sdvo, dev))
...@@ -3011,8 +3018,10 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob) ...@@ -3011,8 +3018,10 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob)
* hotplug lines. * hotplug lines.
*/ */
if (intel_sdvo->hotplug_active) { if (intel_sdvo->hotplug_active) {
intel_encoder->hpd_pin = if (intel_sdvo->port == PORT_B)
intel_sdvo->is_sdvob ? HPD_SDVO_B : HPD_SDVO_C; intel_encoder->hpd_pin = HPD_SDVO_B;
else
intel_encoder->hpd_pin = HPD_SDVO_C;
} }
/* /*
......
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