Commit 29b99b48 authored by Jani Nikula's avatar Jani Nikula Committed by Daniel Vetter

drm/i915/lvds: Rename intel_lvds to intel_lvds_encoder

In preparation for introducing intel_lvds_connector to move some of the
LVDS specific storage away from drm_i915_private, first rename the encoder
to avoid potential confusion.

Based on earlier work by Chris Wilson <chris@chris-wilson.co.uk>

CC: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Reviewed-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent c2fb7916
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#include <linux/acpi.h> #include <linux/acpi.h>
/* Private structure for the integrated LVDS support */ /* Private structure for the integrated LVDS support */
struct intel_lvds { struct intel_lvds_encoder {
struct intel_encoder base; struct intel_encoder base;
struct edid *edid; struct edid *edid;
...@@ -53,15 +53,15 @@ struct intel_lvds { ...@@ -53,15 +53,15 @@ struct intel_lvds {
struct drm_display_mode *fixed_mode; struct drm_display_mode *fixed_mode;
}; };
static struct intel_lvds *to_intel_lvds(struct drm_encoder *encoder) static struct intel_lvds_encoder *to_lvds_encoder(struct drm_encoder *encoder)
{ {
return container_of(encoder, struct intel_lvds, base.base); return container_of(encoder, struct intel_lvds_encoder, base.base);
} }
static struct intel_lvds *intel_attached_lvds(struct drm_connector *connector) static struct intel_lvds_encoder *intel_attached_lvds(struct drm_connector *connector)
{ {
return container_of(intel_attached_encoder(connector), return container_of(intel_attached_encoder(connector),
struct intel_lvds, base); struct intel_lvds_encoder, base);
} }
static bool intel_lvds_get_hw_state(struct intel_encoder *encoder, static bool intel_lvds_get_hw_state(struct intel_encoder *encoder,
...@@ -96,7 +96,7 @@ static bool intel_lvds_get_hw_state(struct intel_encoder *encoder, ...@@ -96,7 +96,7 @@ static bool intel_lvds_get_hw_state(struct intel_encoder *encoder,
static void intel_enable_lvds(struct intel_encoder *encoder) static void intel_enable_lvds(struct intel_encoder *encoder)
{ {
struct drm_device *dev = encoder->base.dev; struct drm_device *dev = encoder->base.dev;
struct intel_lvds *intel_lvds = to_intel_lvds(&encoder->base); struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
u32 ctl_reg, lvds_reg, stat_reg; u32 ctl_reg, lvds_reg, stat_reg;
...@@ -113,7 +113,7 @@ static void intel_enable_lvds(struct intel_encoder *encoder) ...@@ -113,7 +113,7 @@ static void intel_enable_lvds(struct intel_encoder *encoder)
I915_WRITE(lvds_reg, I915_READ(lvds_reg) | LVDS_PORT_EN); I915_WRITE(lvds_reg, I915_READ(lvds_reg) | LVDS_PORT_EN);
if (intel_lvds->pfit_dirty) { if (lvds_encoder->pfit_dirty) {
/* /*
* Enable automatic panel scaling so that non-native modes * Enable automatic panel scaling so that non-native modes
* fill the screen. The panel fitter should only be * fill the screen. The panel fitter should only be
...@@ -121,12 +121,12 @@ static void intel_enable_lvds(struct intel_encoder *encoder) ...@@ -121,12 +121,12 @@ static void intel_enable_lvds(struct intel_encoder *encoder)
* register description and PRM. * register description and PRM.
*/ */
DRM_DEBUG_KMS("applying panel-fitter: %x, %x\n", DRM_DEBUG_KMS("applying panel-fitter: %x, %x\n",
intel_lvds->pfit_control, lvds_encoder->pfit_control,
intel_lvds->pfit_pgm_ratios); lvds_encoder->pfit_pgm_ratios);
I915_WRITE(PFIT_PGM_RATIOS, intel_lvds->pfit_pgm_ratios); I915_WRITE(PFIT_PGM_RATIOS, lvds_encoder->pfit_pgm_ratios);
I915_WRITE(PFIT_CONTROL, intel_lvds->pfit_control); I915_WRITE(PFIT_CONTROL, lvds_encoder->pfit_control);
intel_lvds->pfit_dirty = false; lvds_encoder->pfit_dirty = false;
} }
I915_WRITE(ctl_reg, I915_READ(ctl_reg) | POWER_TARGET_ON); I915_WRITE(ctl_reg, I915_READ(ctl_reg) | POWER_TARGET_ON);
...@@ -140,7 +140,7 @@ static void intel_enable_lvds(struct intel_encoder *encoder) ...@@ -140,7 +140,7 @@ static void intel_enable_lvds(struct intel_encoder *encoder)
static void intel_disable_lvds(struct intel_encoder *encoder) static void intel_disable_lvds(struct intel_encoder *encoder)
{ {
struct drm_device *dev = encoder->base.dev; struct drm_device *dev = encoder->base.dev;
struct intel_lvds *intel_lvds = to_intel_lvds(&encoder->base); struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
u32 ctl_reg, lvds_reg, stat_reg; u32 ctl_reg, lvds_reg, stat_reg;
...@@ -160,9 +160,9 @@ static void intel_disable_lvds(struct intel_encoder *encoder) ...@@ -160,9 +160,9 @@ static void intel_disable_lvds(struct intel_encoder *encoder)
if (wait_for((I915_READ(stat_reg) & PP_ON) == 0, 1000)) if (wait_for((I915_READ(stat_reg) & PP_ON) == 0, 1000))
DRM_ERROR("timed out waiting for panel to power off\n"); DRM_ERROR("timed out waiting for panel to power off\n");
if (intel_lvds->pfit_control) { if (lvds_encoder->pfit_control) {
I915_WRITE(PFIT_CONTROL, 0); I915_WRITE(PFIT_CONTROL, 0);
intel_lvds->pfit_dirty = true; lvds_encoder->pfit_dirty = true;
} }
I915_WRITE(lvds_reg, I915_READ(lvds_reg) & ~LVDS_PORT_EN); I915_WRITE(lvds_reg, I915_READ(lvds_reg) & ~LVDS_PORT_EN);
...@@ -172,8 +172,8 @@ static void intel_disable_lvds(struct intel_encoder *encoder) ...@@ -172,8 +172,8 @@ static void intel_disable_lvds(struct intel_encoder *encoder)
static int intel_lvds_mode_valid(struct drm_connector *connector, static int intel_lvds_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode) struct drm_display_mode *mode)
{ {
struct intel_lvds *intel_lvds = intel_attached_lvds(connector); struct intel_lvds_encoder *lvds_encoder = intel_attached_lvds(connector);
struct drm_display_mode *fixed_mode = intel_lvds->fixed_mode; struct drm_display_mode *fixed_mode = lvds_encoder->fixed_mode;
if (mode->hdisplay > fixed_mode->hdisplay) if (mode->hdisplay > fixed_mode->hdisplay)
return MODE_PANEL; return MODE_PANEL;
...@@ -249,8 +249,8 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder, ...@@ -249,8 +249,8 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder,
{ {
struct drm_device *dev = encoder->dev; struct drm_device *dev = encoder->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_lvds *intel_lvds = to_intel_lvds(encoder); struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(encoder);
struct intel_crtc *intel_crtc = intel_lvds->base.new_crtc; struct intel_crtc *intel_crtc = lvds_encoder->base.new_crtc;
u32 pfit_control = 0, pfit_pgm_ratios = 0, border = 0; u32 pfit_control = 0, pfit_pgm_ratios = 0, border = 0;
int pipe; int pipe;
...@@ -260,7 +260,7 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder, ...@@ -260,7 +260,7 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder,
return false; return false;
} }
if (intel_encoder_check_is_cloned(&intel_lvds->base)) if (intel_encoder_check_is_cloned(&lvds_encoder->base))
return false; return false;
/* /*
...@@ -269,10 +269,10 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder, ...@@ -269,10 +269,10 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder,
* with the panel scaling set up to source from the H/VDisplay * with the panel scaling set up to source from the H/VDisplay
* of the original mode. * of the original mode.
*/ */
intel_fixed_panel_mode(intel_lvds->fixed_mode, adjusted_mode); intel_fixed_panel_mode(lvds_encoder->fixed_mode, adjusted_mode);
if (HAS_PCH_SPLIT(dev)) { if (HAS_PCH_SPLIT(dev)) {
intel_pch_panel_fitting(dev, intel_lvds->fitting_mode, intel_pch_panel_fitting(dev, lvds_encoder->fitting_mode,
mode, adjusted_mode); mode, adjusted_mode);
return true; return true;
} }
...@@ -298,7 +298,7 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder, ...@@ -298,7 +298,7 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder,
drm_mode_set_crtcinfo(adjusted_mode, 0); drm_mode_set_crtcinfo(adjusted_mode, 0);
switch (intel_lvds->fitting_mode) { switch (lvds_encoder->fitting_mode) {
case DRM_MODE_SCALE_CENTER: case DRM_MODE_SCALE_CENTER:
/* /*
* For centered modes, we have to calculate border widths & * For centered modes, we have to calculate border widths &
...@@ -396,11 +396,11 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder, ...@@ -396,11 +396,11 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder,
if (INTEL_INFO(dev)->gen < 4 && dev_priv->lvds_dither) if (INTEL_INFO(dev)->gen < 4 && dev_priv->lvds_dither)
pfit_control |= PANEL_8TO6_DITHER_ENABLE; pfit_control |= PANEL_8TO6_DITHER_ENABLE;
if (pfit_control != intel_lvds->pfit_control || if (pfit_control != lvds_encoder->pfit_control ||
pfit_pgm_ratios != intel_lvds->pfit_pgm_ratios) { pfit_pgm_ratios != lvds_encoder->pfit_pgm_ratios) {
intel_lvds->pfit_control = pfit_control; lvds_encoder->pfit_control = pfit_control;
intel_lvds->pfit_pgm_ratios = pfit_pgm_ratios; lvds_encoder->pfit_pgm_ratios = pfit_pgm_ratios;
intel_lvds->pfit_dirty = true; lvds_encoder->pfit_dirty = true;
} }
dev_priv->lvds_border_bits = border; dev_priv->lvds_border_bits = border;
...@@ -449,14 +449,14 @@ intel_lvds_detect(struct drm_connector *connector, bool force) ...@@ -449,14 +449,14 @@ intel_lvds_detect(struct drm_connector *connector, bool force)
*/ */
static int intel_lvds_get_modes(struct drm_connector *connector) static int intel_lvds_get_modes(struct drm_connector *connector)
{ {
struct intel_lvds *intel_lvds = intel_attached_lvds(connector); struct intel_lvds_encoder *lvds_encoder = intel_attached_lvds(connector);
struct drm_device *dev = connector->dev; struct drm_device *dev = connector->dev;
struct drm_display_mode *mode; struct drm_display_mode *mode;
if (intel_lvds->edid) if (lvds_encoder->edid)
return drm_add_edid_modes(connector, intel_lvds->edid); return drm_add_edid_modes(connector, lvds_encoder->edid);
mode = drm_mode_duplicate(dev, intel_lvds->fixed_mode); mode = drm_mode_duplicate(dev, lvds_encoder->fixed_mode);
if (mode == NULL) if (mode == NULL)
return 0; return 0;
...@@ -557,22 +557,22 @@ static int intel_lvds_set_property(struct drm_connector *connector, ...@@ -557,22 +557,22 @@ static int intel_lvds_set_property(struct drm_connector *connector,
struct drm_property *property, struct drm_property *property,
uint64_t value) uint64_t value)
{ {
struct intel_lvds *intel_lvds = intel_attached_lvds(connector); struct intel_lvds_encoder *lvds_encoder = intel_attached_lvds(connector);
struct drm_device *dev = connector->dev; struct drm_device *dev = connector->dev;
if (property == dev->mode_config.scaling_mode_property) { if (property == dev->mode_config.scaling_mode_property) {
struct drm_crtc *crtc = intel_lvds->base.base.crtc; struct drm_crtc *crtc = lvds_encoder->base.base.crtc;
if (value == DRM_MODE_SCALE_NONE) { if (value == DRM_MODE_SCALE_NONE) {
DRM_DEBUG_KMS("no scaling not supported\n"); DRM_DEBUG_KMS("no scaling not supported\n");
return -EINVAL; return -EINVAL;
} }
if (intel_lvds->fitting_mode == value) { if (lvds_encoder->fitting_mode == value) {
/* the LVDS scaling property is not changed */ /* the LVDS scaling property is not changed */
return 0; return 0;
} }
intel_lvds->fitting_mode = value; lvds_encoder->fitting_mode = value;
if (crtc && crtc->enabled) { if (crtc && crtc->enabled) {
/* /*
* If the CRTC is enabled, the display will be changed * If the CRTC is enabled, the display will be changed
...@@ -904,7 +904,7 @@ static bool intel_lvds_supported(struct drm_device *dev) ...@@ -904,7 +904,7 @@ static bool intel_lvds_supported(struct drm_device *dev)
bool intel_lvds_init(struct drm_device *dev) bool intel_lvds_init(struct drm_device *dev)
{ {
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_lvds *intel_lvds; struct intel_lvds_encoder *lvds_encoder;
struct intel_encoder *intel_encoder; struct intel_encoder *intel_encoder;
struct intel_connector *intel_connector; struct intel_connector *intel_connector;
struct drm_connector *connector; struct drm_connector *connector;
...@@ -937,22 +937,21 @@ bool intel_lvds_init(struct drm_device *dev) ...@@ -937,22 +937,21 @@ bool intel_lvds_init(struct drm_device *dev)
} }
} }
intel_lvds = kzalloc(sizeof(struct intel_lvds), GFP_KERNEL); lvds_encoder = kzalloc(sizeof(struct intel_lvds_encoder), GFP_KERNEL);
if (!intel_lvds) { if (!lvds_encoder)
return false; return false;
}
intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL); intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL);
if (!intel_connector) { if (!intel_connector) {
kfree(intel_lvds); kfree(lvds_encoder);
return false; return false;
} }
if (!HAS_PCH_SPLIT(dev)) { if (!HAS_PCH_SPLIT(dev)) {
intel_lvds->pfit_control = I915_READ(PFIT_CONTROL); lvds_encoder->pfit_control = I915_READ(PFIT_CONTROL);
} }
intel_encoder = &intel_lvds->base; intel_encoder = &lvds_encoder->base;
encoder = &intel_encoder->base; encoder = &intel_encoder->base;
connector = &intel_connector->base; connector = &intel_connector->base;
drm_connector_init(dev, &intel_connector->base, &intel_lvds_connector_funcs, drm_connector_init(dev, &intel_connector->base, &intel_lvds_connector_funcs,
...@@ -992,7 +991,7 @@ bool intel_lvds_init(struct drm_device *dev) ...@@ -992,7 +991,7 @@ bool intel_lvds_init(struct drm_device *dev)
drm_connector_attach_property(&intel_connector->base, drm_connector_attach_property(&intel_connector->base,
dev->mode_config.scaling_mode_property, dev->mode_config.scaling_mode_property,
DRM_MODE_SCALE_ASPECT); DRM_MODE_SCALE_ASPECT);
intel_lvds->fitting_mode = DRM_MODE_SCALE_ASPECT; lvds_encoder->fitting_mode = DRM_MODE_SCALE_ASPECT;
/* /*
* LVDS discovery: * LVDS discovery:
* 1) check for EDID on DDC * 1) check for EDID on DDC
...@@ -1007,20 +1006,18 @@ bool intel_lvds_init(struct drm_device *dev) ...@@ -1007,20 +1006,18 @@ bool intel_lvds_init(struct drm_device *dev)
* Attempt to get the fixed panel mode from DDC. Assume that the * Attempt to get the fixed panel mode from DDC. Assume that the
* preferred mode is the right one. * preferred mode is the right one.
*/ */
intel_lvds->edid = drm_get_edid(connector, lvds_encoder->edid = drm_get_edid(connector,
intel_gmbus_get_adapter(dev_priv, intel_gmbus_get_adapter(dev_priv, pin));
pin)); if (lvds_encoder->edid) {
if (intel_lvds->edid) { if (drm_add_edid_modes(connector, lvds_encoder->edid)) {
if (drm_add_edid_modes(connector,
intel_lvds->edid)) {
drm_mode_connector_update_edid_property(connector, drm_mode_connector_update_edid_property(connector,
intel_lvds->edid); lvds_encoder->edid);
} else { } else {
kfree(intel_lvds->edid); kfree(lvds_encoder->edid);
intel_lvds->edid = NULL; lvds_encoder->edid = NULL;
} }
} }
if (!intel_lvds->edid) { if (!lvds_encoder->edid) {
/* Didn't get an EDID, so /* Didn't get an EDID, so
* Set wide sync ranges so we get all modes * Set wide sync ranges so we get all modes
* handed to valid_mode for checking * handed to valid_mode for checking
...@@ -1033,10 +1030,8 @@ bool intel_lvds_init(struct drm_device *dev) ...@@ -1033,10 +1030,8 @@ bool intel_lvds_init(struct drm_device *dev)
list_for_each_entry(scan, &connector->probed_modes, head) { list_for_each_entry(scan, &connector->probed_modes, head) {
if (scan->type & DRM_MODE_TYPE_PREFERRED) { if (scan->type & DRM_MODE_TYPE_PREFERRED) {
intel_lvds->fixed_mode = lvds_encoder->fixed_mode = drm_mode_duplicate(dev, scan);
drm_mode_duplicate(dev, scan); intel_find_lvds_downclock(dev, lvds_encoder->fixed_mode,
intel_find_lvds_downclock(dev,
intel_lvds->fixed_mode,
connector); connector);
goto out; goto out;
} }
...@@ -1044,11 +1039,10 @@ bool intel_lvds_init(struct drm_device *dev) ...@@ -1044,11 +1039,10 @@ bool intel_lvds_init(struct drm_device *dev)
/* Failed to get EDID, what about VBT? */ /* Failed to get EDID, what about VBT? */
if (dev_priv->lfp_lvds_vbt_mode) { if (dev_priv->lfp_lvds_vbt_mode) {
intel_lvds->fixed_mode = lvds_encoder->fixed_mode =
drm_mode_duplicate(dev, dev_priv->lfp_lvds_vbt_mode); drm_mode_duplicate(dev, dev_priv->lfp_lvds_vbt_mode);
if (intel_lvds->fixed_mode) { if (lvds_encoder->fixed_mode) {
intel_lvds->fixed_mode->type |= lvds_encoder->fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
DRM_MODE_TYPE_PREFERRED;
goto out; goto out;
} }
} }
...@@ -1068,16 +1062,15 @@ bool intel_lvds_init(struct drm_device *dev) ...@@ -1068,16 +1062,15 @@ bool intel_lvds_init(struct drm_device *dev)
crtc = intel_get_crtc_for_pipe(dev, pipe); crtc = intel_get_crtc_for_pipe(dev, pipe);
if (crtc && (lvds & LVDS_PORT_EN)) { if (crtc && (lvds & LVDS_PORT_EN)) {
intel_lvds->fixed_mode = intel_crtc_mode_get(dev, crtc); lvds_encoder->fixed_mode = intel_crtc_mode_get(dev, crtc);
if (intel_lvds->fixed_mode) { if (lvds_encoder->fixed_mode) {
intel_lvds->fixed_mode->type |= lvds_encoder->fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
DRM_MODE_TYPE_PREFERRED;
goto out; goto out;
} }
} }
/* If we still don't have a mode after all that, give up. */ /* If we still don't have a mode after all that, give up. */
if (!intel_lvds->fixed_mode) if (!lvds_encoder->fixed_mode)
goto failed; goto failed;
out: out:
...@@ -1109,7 +1102,7 @@ bool intel_lvds_init(struct drm_device *dev) ...@@ -1109,7 +1102,7 @@ bool intel_lvds_init(struct drm_device *dev)
DRM_DEBUG_KMS("No LVDS modes found, disabling.\n"); DRM_DEBUG_KMS("No LVDS modes found, disabling.\n");
drm_connector_cleanup(connector); drm_connector_cleanup(connector);
drm_encoder_cleanup(encoder); drm_encoder_cleanup(encoder);
kfree(intel_lvds); kfree(lvds_encoder);
kfree(intel_connector); kfree(intel_connector);
return false; return false;
} }
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