[PATCH 01/10] drm/i915/lvds: Rename intel_lvds to intel_lvds_encoder

Chris Wilson
2011-04-22T09:19:31Z

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.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
drivers/gpu/drm/i915/intel_lvds.c | 227 +++++++++++++++++++------------------
1 files changed, 114 insertions(+), 113 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index ece5440..0882e4c 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -41,7 +41,7 @@
#include <linux/acpi.h>

/* Private structure for the integrated LVDS support */
-struct intel_lvds {
+struct intel_lvds_encoder {
struct intel_encoder base;

struct edid *edid;
@@ -54,23 +54,23 @@ struct intel_lvds {
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),
- struct intel_lvds, base);
+ struct intel_lvds_encoder, base);
}

/**
* Sets the power state for the panel.
*/
-static void intel_lvds_enable(struct intel_lvds *intel_lvds)
+static void intel_lvds_encoder_enable(struct intel_lvds_encoder *lvds_encoder)
{
- struct drm_device *dev = intel_lvds->base.base.dev;
+ struct drm_device *dev = lvds_encoder->base.base.dev;
struct drm_i915_private *dev_priv = dev->dev_private;
u32 ctl_reg, lvds_reg;

@@ -84,7 +84,7 @@ static void intel_lvds_enable(struct intel_lvds *intel_lvds)

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
* fill the screen. The panel fitter should only be
@@ -92,14 +92,14 @@ static void intel_lvds_enable(struct intel_lvds *intel_lvds)
* register description and PRM.
*/
DRM_DEBUG_KMS("applying panel-fitter: %x, %x\n",
- intel_lvds->pfit_control,
- intel_lvds->pfit_pgm_ratios);
+ lvds_encoder->pfit_control,
+ lvds_encoder->pfit_pgm_ratios);
if (wait_for((I915_READ(PP_STATUS) & PP_ON) == 0, 1000)) {
DRM_ERROR("timed out waiting for panel to power off\n");
} else {
- I915_WRITE(PFIT_PGM_RATIOS, intel_lvds->pfit_pgm_ratios);
- I915_WRITE(PFIT_CONTROL, intel_lvds->pfit_control);
- intel_lvds->pfit_dirty = false;
+ I915_WRITE(PFIT_PGM_RATIOS, lvds_encoder->pfit_pgm_ratios);
+ I915_WRITE(PFIT_CONTROL, lvds_encoder->pfit_control);
+ lvds_encoder->pfit_dirty = false;
}
}

@@ -109,9 +109,9 @@ static void intel_lvds_enable(struct intel_lvds *intel_lvds)
intel_panel_enable_backlight(dev);
}

-static void intel_lvds_disable(struct intel_lvds *intel_lvds)
+static void intel_lvds_encoder_disable(struct intel_lvds_encoder *lvds_encoder)
{
- struct drm_device *dev = intel_lvds->base.base.dev;
+ struct drm_device *dev = lvds_encoder->base.base.dev;
struct drm_i915_private *dev_priv = dev->dev_private;
u32 ctl_reg, lvds_reg;

@@ -127,35 +127,35 @@ static void intel_lvds_disable(struct intel_lvds *intel_lvds)

I915_WRITE(ctl_reg, I915_READ(ctl_reg) & ~POWER_TARGET_ON);

- if (intel_lvds->pfit_control) {
+ if (lvds_encoder->pfit_control) {
if (wait_for((I915_READ(PP_STATUS) & PP_ON) == 0, 1000))
DRM_ERROR("timed out waiting for panel to power off\n");

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);
POSTING_READ(lvds_reg);
}

-static void intel_lvds_dpms(struct drm_encoder *encoder, int mode)
+static void intel_lvds_encoder_dpms(struct drm_encoder *encoder, int mode)
{
- struct intel_lvds *intel_lvds = to_intel_lvds(encoder);
+ struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(encoder);

if (mode == DRM_MODE_DPMS_ON)
- intel_lvds_enable(intel_lvds);
+ intel_lvds_encoder_enable(lvds_encoder);
else
- intel_lvds_disable(intel_lvds);
+ intel_lvds_encoder_disable(lvds_encoder);

/* XXX: We never power down the LVDS pairs. */
}

-static int intel_lvds_mode_valid(struct drm_connector *connector,
- struct drm_display_mode *mode)
+static int intel_lvds_connector_mode_valid(struct drm_connector *connector,
+ struct drm_display_mode *mode)
{
- struct intel_lvds *intel_lvds = intel_attached_lvds(connector);
- struct drm_display_mode *fixed_mode = intel_lvds->fixed_mode;
+ struct intel_lvds_encoder *lvds_encoder = intel_attached_lvds(connector);
+ struct drm_display_mode *fixed_mode = lvds_encoder->fixed_mode;

if (mode->hdisplay > fixed_mode->hdisplay)
return MODE_PANEL;
@@ -221,14 +221,14 @@ static inline u32 panel_fitter_scaling(u32 source, u32 target)
return (FACTOR * ratio + FACTOR/2) / FACTOR;
}

-static bool intel_lvds_mode_fixup(struct drm_encoder *encoder,
- struct drm_display_mode *mode,
- struct drm_display_mode *adjusted_mode)
+static bool intel_lvds_encoder_mode_fixup(struct drm_encoder *encoder,
+ struct drm_display_mode *mode,
+ struct drm_display_mode *adjusted_mode)
{
struct drm_device *dev = encoder->dev;
struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
- struct intel_lvds *intel_lvds = to_intel_lvds(encoder);
+ struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(encoder);
struct drm_encoder *tmp_encoder;
u32 pfit_control = 0, pfit_pgm_ratios = 0, border = 0;
int pipe;
@@ -254,10 +254,10 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder,
* with the panel scaling set up to source from the H/VDisplay
* 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)) {
- intel_pch_panel_fitting(dev, intel_lvds->fitting_mode,
+ intel_pch_panel_fitting(dev, lvds_encoder->fitting_mode,
mode, adjusted_mode);
return true;
}
@@ -281,7 +281,7 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder,
for_each_pipe(pipe)
I915_WRITE(BCLRPAT(pipe), 0);

- switch (intel_lvds->fitting_mode) {
+ switch (lvds_encoder->fitting_mode) {
case DRM_MODE_SCALE_CENTER:
/*
* For centered modes, we have to calculate border widths &
@@ -379,11 +379,11 @@ out:
if (INTEL_INFO(dev)->gen < 4 && dev_priv->lvds_dither)
pfit_control |= PANEL_8TO6_DITHER_ENABLE;

- if (pfit_control != intel_lvds->pfit_control ||
- pfit_pgm_ratios != intel_lvds->pfit_pgm_ratios) {
- intel_lvds->pfit_control = pfit_control;
- intel_lvds->pfit_pgm_ratios = pfit_pgm_ratios;
- intel_lvds->pfit_dirty = true;
+ if (pfit_control != lvds_encoder->pfit_control ||
+ pfit_pgm_ratios != lvds_encoder->pfit_pgm_ratios) {
+ lvds_encoder->pfit_control = pfit_control;
+ lvds_encoder->pfit_pgm_ratios = pfit_pgm_ratios;
+ lvds_encoder->pfit_dirty = true;
}
dev_priv->lvds_border_bits = border;

@@ -396,11 +396,11 @@ out:
return true;
}

-static void intel_lvds_prepare(struct drm_encoder *encoder)
+static void intel_lvds_encoder_prepare(struct drm_encoder *encoder)
{
struct drm_device *dev = encoder->dev;
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);

/* We try to do the minimum that is necessary in order to unlock
* the registers for mode setting.
@@ -416,7 +416,7 @@ static void intel_lvds_prepare(struct drm_encoder *encoder)
if (HAS_PCH_SPLIT(dev)) {
I915_WRITE(PCH_PP_CONTROL,
I915_READ(PCH_PP_CONTROL) | PANEL_UNLOCK_REGS);
- } else if (intel_lvds->pfit_dirty) {
+ } else if (lvds_encoder->pfit_dirty) {
I915_WRITE(PP_CONTROL,
(I915_READ(PP_CONTROL) | PANEL_UNLOCK_REGS)
& ~POWER_TARGET_ON);
@@ -426,11 +426,11 @@ static void intel_lvds_prepare(struct drm_encoder *encoder)
}
}

-static void intel_lvds_commit(struct drm_encoder *encoder)
+static void intel_lvds_encoder_commit(struct drm_encoder *encoder)
{
struct drm_device *dev = encoder->dev;
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);

/* Undo any unlocking done in prepare to prevent accidental
* adjustment of the registers.
@@ -448,12 +448,12 @@ static void intel_lvds_commit(struct drm_encoder *encoder)
/* Always do a full power on as we do not know what state
* we were left in.
*/
- intel_lvds_enable(intel_lvds);
+ intel_lvds_encoder_enable(lvds_encoder);
}

-static void intel_lvds_mode_set(struct drm_encoder *encoder,
- struct drm_display_mode *mode,
- struct drm_display_mode *adjusted_mode)
+static void intel_lvds_encoder_mode_set(struct drm_encoder *encoder,
+ struct drm_display_mode *mode,
+ struct drm_display_mode *adjusted_mode)
{
/*
* The LVDS pin pair will already have been turned on in the
@@ -470,7 +470,7 @@ static void intel_lvds_mode_set(struct drm_encoder *encoder,
* needed, using lid status notification from the input layer.
*/
static enum drm_connector_status
-intel_lvds_detect(struct drm_connector *connector, bool force)
+intel_lvds_connector_detect(struct drm_connector *connector, bool force)
{
struct drm_device *dev = connector->dev;
enum drm_connector_status status;
@@ -485,16 +485,16 @@ intel_lvds_detect(struct drm_connector *connector, bool force)
/**
* Return the list of DDC modes if available, or the BIOS fixed mode otherwise.
*/
-static int intel_lvds_get_modes(struct drm_connector *connector)
+static int intel_lvds_connector_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_display_mode *mode;

- if (intel_lvds->edid)
- return drm_add_edid_modes(connector, intel_lvds->edid);
+ if (lvds_encoder->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)
return 0;

@@ -568,13 +568,13 @@ static int intel_lid_notify(struct notifier_block *nb, unsigned long val,
}

/**
- * intel_lvds_destroy - unregister and free LVDS structures
+ * intel_lvds_encoder_destroy - unregister and free LVDS structures
* @connector: connector to free
*
* Unregister the DDC bus for this connector then free the driver private
* structure.
*/
-static void intel_lvds_destroy(struct drm_connector *connector)
+static void intel_lvds_connector_destroy(struct drm_connector *connector)
{
struct drm_device *dev = connector->dev;
struct drm_i915_private *dev_priv = dev->dev_private;
@@ -586,26 +586,26 @@ static void intel_lvds_destroy(struct drm_connector *connector)
kfree(connector);
}

-static int intel_lvds_set_property(struct drm_connector *connector,
- struct drm_property *property,
- uint64_t value)
+static int intel_lvds_connector_set_property(struct drm_connector *connector,
+ struct drm_property *property,
+ 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;

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) {
DRM_DEBUG_KMS("no scaling not supported\n");
return -EINVAL;
}

- if (intel_lvds->fitting_mode == value) {
+ if (lvds_encoder->fitting_mode == value) {
/* the LVDS scaling property is not changed */
return 0;
}
- intel_lvds->fitting_mode = value;
+ lvds_encoder->fitting_mode = value;
if (crtc && crtc->enabled) {
/*
* If the CRTC is enabled, the display will be changed
@@ -619,29 +619,29 @@ static int intel_lvds_set_property(struct drm_connector *connector,
return 0;
}

-static const struct drm_encoder_helper_funcs intel_lvds_helper_funcs = {
- .dpms = intel_lvds_dpms,
- .mode_fixup = intel_lvds_mode_fixup,
- .prepare = intel_lvds_prepare,
- .mode_set = intel_lvds_mode_set,
- .commit = intel_lvds_commit,
+static const struct drm_encoder_helper_funcs intel_lvds_encoder_helper_funcs = {
+ .dpms = intel_lvds_encoder_dpms,
+ .mode_fixup = intel_lvds_encoder_mode_fixup,
+ .prepare = intel_lvds_encoder_prepare,
+ .mode_set = intel_lvds_encoder_mode_set,
+ .commit = intel_lvds_encoder_commit,
};

static const struct drm_connector_helper_funcs intel_lvds_connector_helper_funcs = {
- .get_modes = intel_lvds_get_modes,
- .mode_valid = intel_lvds_mode_valid,
+ .get_modes = intel_lvds_connector_get_modes,
+ .mode_valid = intel_lvds_connector_mode_valid,
.best_encoder = intel_best_encoder,
};

static const struct drm_connector_funcs intel_lvds_connector_funcs = {
.dpms = drm_helper_connector_dpms,
- .detect = intel_lvds_detect,
+ .detect = intel_lvds_connector_detect,
.fill_modes = drm_helper_probe_single_connector_modes,
- .set_property = intel_lvds_set_property,
- .destroy = intel_lvds_destroy,
+ .set_property = intel_lvds_connector_set_property,
+ .destroy = intel_lvds_connector_destroy,
};

-static const struct drm_encoder_funcs intel_lvds_enc_funcs = {
+static const struct drm_encoder_funcs intel_lvds_encoder_enc_funcs = {
.destroy = intel_encoder_destroy,
};

@@ -830,17 +830,16 @@ static bool lvds_is_present_in_vbt(struct drm_device *dev,
}

/**
- * intel_lvds_init - setup LVDS connectors on this device
+ * intel_lvds_encoder_init - setup LVDS connectors on this device
* @dev: drm device
*
* Create the connector, register the LVDS DDC bus, and try to figure out what
* modes we can display on the LVDS panel (if present).
*/
-bool intel_lvds_init(struct drm_device *dev)
+bool intel_lvds_encoder_init(struct drm_device *dev)
{
struct drm_i915_private *dev_priv = dev->dev_private;
- struct intel_lvds *intel_lvds;
- struct intel_encoder *intel_encoder;
+ struct intel_lvds_encoder *lvds_encoder;
struct intel_connector *intel_connector;
struct drm_connector *connector;
struct drm_encoder *encoder;
@@ -869,38 +868,40 @@ bool intel_lvds_init(struct drm_device *dev)
}
}

- intel_lvds = kzalloc(sizeof(struct intel_lvds), GFP_KERNEL);
- if (!intel_lvds) {
+ lvds_encoder = kzalloc(sizeof(struct intel_lvds_encoder), GFP_KERNEL);
+ if (!lvds_encoder) {
return false;
}

intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL);
if (!intel_connector) {
- kfree(intel_lvds);
+ kfree(lvds_encoder);
return false;
}

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;
- encoder = &intel_encoder->base;
+ encoder = &lvds_encoder->base.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,
DRM_MODE_CONNECTOR_LVDS);

- drm_encoder_init(dev, &intel_encoder->base, &intel_lvds_enc_funcs,
+ drm_encoder_init(dev, &lvds_encoder->base.base,
+ &intel_lvds_encoder_enc_funcs,
DRM_MODE_ENCODER_LVDS);

- intel_connector_attach_encoder(intel_connector, intel_encoder);
- intel_encoder->type = INTEL_OUTPUT_LVDS;
+ intel_connector_attach_encoder(intel_connector, &lvds_encoder->base);
+ lvds_encoder->base.type = INTEL_OUTPUT_LVDS;

- intel_encoder->clone_mask = (1 << INTEL_LVDS_CLONE_BIT);
- intel_encoder->crtc_mask = (1 << 1);
+ lvds_encoder->base.clone_mask = (1 << INTEL_LVDS_CLONE_BIT);
+ lvds_encoder->base.crtc_mask = (1 << 1);
if (INTEL_INFO(dev)->gen >= 5)
- intel_encoder->crtc_mask |= (1 << 0);
- drm_encoder_helper_add(encoder, &intel_lvds_helper_funcs);
+ lvds_encoder->base.crtc_mask |= (1 << 0);
+ drm_encoder_helper_add(encoder, &intel_lvds_encoder_helper_funcs);
drm_connector_helper_add(connector, &intel_lvds_connector_helper_funcs);
connector->display_info.subpixel_order = SubPixelHorizontalRGB;
connector->interlace_allowed = false;
@@ -915,7 +916,7 @@ bool intel_lvds_init(struct drm_device *dev)
drm_connector_attach_property(&intel_connector->base,
dev->mode_config.scaling_mode_property,
DRM_MODE_SCALE_ASPECT);
- intel_lvds->fitting_mode = DRM_MODE_SCALE_ASPECT;
+ lvds_encoder->fitting_mode = DRM_MODE_SCALE_ASPECT;

/*
* LVDS discovery:
@@ -937,19 +938,19 @@ bool intel_lvds_init(struct drm_device *dev)
* Attempt to get the fixed panel mode from DDC. Assume that the
* preferred mode is the right one.
*/
- intel_lvds->edid = drm_get_edid(connector,
- &dev_priv->gmbus[pin].adapter);
- if (intel_lvds->edid) {
+ lvds_encoder->edid = drm_get_edid(connector,
+ &dev_priv->gmbus[pin].adapter);
+ if (lvds_encoder->edid) {
if (drm_add_edid_modes(connector,
- intel_lvds->edid)) {
+ lvds_encoder->edid)) {
drm_mode_connector_update_edid_property(connector,
- intel_lvds->edid);
+ lvds_encoder->edid);
} else {
- kfree(intel_lvds->edid);
- intel_lvds->edid = NULL;
+ kfree(lvds_encoder->edid);
+ lvds_encoder->edid = NULL;
}
}
- if (!intel_lvds->edid) {
+ if (!lvds_encoder->edid) {
/* Didn't get an EDID, so
* Set wide sync ranges so we get all modes
* handed to valid_mode for checking
@@ -962,10 +963,10 @@ bool intel_lvds_init(struct drm_device *dev)

list_for_each_entry(scan, &connector->probed_modes, head) {
if (scan->type & DRM_MODE_TYPE_PREFERRED) {
- intel_lvds->fixed_mode =
+ lvds_encoder->fixed_mode =
drm_mode_duplicate(dev, scan);
intel_find_lvds_downclock(dev,
- intel_lvds->fixed_mode,
+ lvds_encoder->fixed_mode,
connector);
goto out;
}
@@ -981,10 +982,10 @@ bool intel_lvds_init(struct drm_device *dev)
if (drm_mode_parse_command_line_for_connector(i915_lvds_fixed_mode,
connector,
&mode)) {
- intel_lvds->fixed_mode =
+ lvds_encoder->fixed_mode =
drm_mode_create_from_cmdline_mode(dev, &mode);
- if (intel_lvds->fixed_mode) {
- intel_lvds->fixed_mode->type |=
+ if (lvds_encoder->fixed_mode) {
+ lvds_encoder->fixed_mode->type |=
DRM_MODE_TYPE_PREFERRED;
goto out;
}
@@ -993,10 +994,10 @@ bool intel_lvds_init(struct drm_device *dev)

/* Failed to get EDID, no override, what about VBT? */
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);
- if (intel_lvds->fixed_mode) {
- intel_lvds->fixed_mode->type |=
+ if (lvds_encoder->fixed_mode) {
+ lvds_encoder->fixed_mode->type |=
DRM_MODE_TYPE_PREFERRED;
goto out;
}
@@ -1017,16 +1018,16 @@ bool intel_lvds_init(struct drm_device *dev)
crtc = intel_get_crtc_for_pipe(dev, pipe);

if (crtc && (lvds & LVDS_PORT_EN)) {
- intel_lvds->fixed_mode = intel_crtc_mode_get(dev, crtc);
- if (intel_lvds->fixed_mode) {
- intel_lvds->fixed_mode->type |=
+ lvds_encoder->fixed_mode = intel_crtc_mode_get(dev, crtc);
+ if (lvds_encoder->fixed_mode) {
+ lvds_encoder->fixed_mode->type |=
DRM_MODE_TYPE_PREFERRED;
goto out;
}
}

/* 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;

out:
@@ -1063,7 +1064,7 @@ failed:
DRM_DEBUG_KMS("No LVDS modes found, disabling.\n");
drm_connector_cleanup(connector);
drm_encoder_cleanup(encoder);
- kfree(intel_lvds);
+ kfree(lvds_encoder);
kfree(intel_connector);
return false;
}
--
1.7.4.1