[PATCH 07/10] drm/i915: Move the fixed_mode away from drm_i915_private and to the panel

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

... as matches usage.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
drivers/gpu/drm/i915/i915_drv.h | 1 -
drivers/gpu/drm/i915/intel_dp.c | 43 +++++++++++++++++----------------
drivers/gpu/drm/i915/intel_drv.h | 4 ++-
drivers/gpu/drm/i915/intel_lvds.c | 45 ++++++++++++++++-------------------
drivers/gpu/drm/i915/intel_panel.c | 9 ++++++-
5 files changed, 54 insertions(+), 48 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 4c96dfc..8abc98f 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -340,7 +340,6 @@ typedef struct drm_i915_private {
/* LVDS info */
int backlight_level; /* restore backlight to this value */
bool backlight_enabled;
- struct drm_display_mode *panel_fixed_mode;
struct drm_display_mode *lfp_lvds_vbt_mode; /* if any */
struct drm_display_mode *sdvo_lvds_vbt_mode; /* if any */

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 3ef944f..384017c 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -202,16 +202,14 @@ intel_dp_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode)
{
struct intel_dp *intel_dp = intel_attached_dp(connector);
- struct drm_device *dev = connector->dev;
- struct drm_i915_private *dev_priv = dev->dev_private;
int max_link_clock = intel_dp_link_clock(intel_dp_max_link_bw(intel_dp));
int max_lanes = intel_dp_max_lane_count(intel_dp);

- if (is_edp(intel_dp) && dev_priv->panel_fixed_mode) {
- if (mode->hdisplay > dev_priv->panel_fixed_mode->hdisplay)
+ if (is_edp(intel_dp) && intel_dp->panel.fixed_mode) {
+ if (mode->hdisplay > intel_dp->panel.fixed_mode->hdisplay)
return MODE_PANEL;

- if (mode->vdisplay > dev_priv->panel_fixed_mode->vdisplay)
+ if (mode->vdisplay > intel_dp->panel.fixed_mode->vdisplay)
return MODE_PANEL;
}

@@ -592,22 +590,22 @@ intel_dp_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_dp *intel_dp = enc_to_intel_dp(encoder);
int lane_count, clock;
int max_lane_count = intel_dp_max_lane_count(intel_dp);
int max_clock = intel_dp_max_link_bw(intel_dp) == DP_LINK_BW_2_7 ? 1 : 0;
static int bws[2] = { DP_LINK_BW_1_62, DP_LINK_BW_2_7 };

- if (is_edp(intel_dp) && dev_priv->panel_fixed_mode) {
- intel_fixed_panel_mode(dev_priv->panel_fixed_mode, adjusted_mode);
+ if (is_edp(intel_dp) && intel_dp->panel.fixed_mode) {
+ intel_fixed_panel_mode(intel_dp->panel.fixed_mode,
+ adjusted_mode);
intel_pch_panel_fitting(dev, DRM_MODE_SCALE_FULLSCREEN,
mode, adjusted_mode);
/*
* the mode->clock is used to calculate the Data&Link M/N
* of the pipe. For the eDP the fixed clock should be used.
*/
- mode->clock = dev_priv->panel_fixed_mode->clock;
+ mode->clock = intel_dp->panel.fixed_mode->clock;
}

for (lane_count = 1; lane_count <= max_lane_count; lane_count <<= 1) {
@@ -1625,7 +1623,6 @@ static int intel_dp_get_modes(struct drm_connector *connector)
{
struct intel_dp *intel_dp = intel_attached_dp(connector);
struct drm_device *dev = intel_dp->base.base.dev;
- struct drm_i915_private *dev_priv = dev->dev_private;
int ret;

/* We should parse the EDID data and find out if it has an audio sink
@@ -1633,12 +1630,12 @@ static int intel_dp_get_modes(struct drm_connector *connector)

ret = intel_ddc_get_modes(connector, &intel_dp->adapter);
if (ret) {
- if (is_edp(intel_dp) && !dev_priv->panel_fixed_mode) {
+ if (is_edp(intel_dp) && !intel_dp->panel.fixed_mode) {
struct drm_display_mode *newmode;
list_for_each_entry(newmode, &connector->probed_modes,
head) {
if (newmode->type & DRM_MODE_TYPE_PREFERRED) {
- dev_priv->panel_fixed_mode =
+ intel_dp->panel.fixed_mode =
drm_mode_duplicate(dev, newmode);
break;
}
@@ -1650,9 +1647,10 @@ static int intel_dp_get_modes(struct drm_connector *connector)

/* if eDP has no EDID, try to use fixed panel mode from VBT */
if (is_edp(intel_dp)) {
- if (dev_priv->panel_fixed_mode != NULL) {
+ if (intel_dp->panel.fixed_mode != NULL) {
struct drm_display_mode *mode;
- mode = drm_mode_duplicate(dev, dev_priv->panel_fixed_mode);
+ mode = drm_mode_duplicate(dev,
+ intel_dp->panel.fixed_mode);
drm_mode_probed_add(connector, mode);
return 1;
}
@@ -1971,17 +1969,20 @@ intel_dp_init(struct drm_device *dev, int output_reg)
intel_encoder->hot_plug = intel_dp_hot_plug;

if (is_edp(intel_dp)) {
+ struct drm_display_mode *fixed_mode = NULL;
+
/* initialize panel mode from VBT if available for eDP */
if (dev_priv->lfp_lvds_vbt_mode) {
- dev_priv->panel_fixed_mode =
- drm_mode_duplicate(dev, dev_priv->lfp_lvds_vbt_mode);
- if (dev_priv->panel_fixed_mode) {
- dev_priv->panel_fixed_mode->type |=
- DRM_MODE_TYPE_PREFERRED;
- }
+ fixed_mode =
+ drm_mode_duplicate(dev,
+ dev_priv->lfp_lvds_vbt_mode);
+ if (fixed_mode)
+ fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
}

- intel_panel_init(&intel_dp->panel, intel_connector);
+ intel_panel_init(&intel_dp->panel,
+ intel_connector,
+ fixed_mode);
}

intel_dp_add_properties(intel_dp, connector);
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 7ca9003..09bfc6b0 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -259,10 +259,12 @@ extern bool intel_encoder_is_pch_edp(struct drm_encoder *encoder);
/* intel_panel.c */
struct intel_panel {
struct intel_connector *connector;
+ struct drm_display_mode *fixed_mode;
struct notifier_block lid_notifier;
};
extern int intel_panel_init(struct intel_panel *panel,
- struct intel_connector *connector);
+ struct intel_connector *connector,
+ struct drm_display_mode *fixed_mode);
extern void intel_panel_fini(struct intel_panel *panel);

extern void intel_fixed_panel_mode(struct drm_display_mode *fixed_mode,
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index 20d6235..68f03ea 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -43,7 +43,6 @@ struct intel_lvds_connector {
struct intel_connector base;
struct intel_panel panel;

- struct drm_display_mode *fixed_mode;
struct edid *edid;

int fitting_mode;
@@ -159,7 +158,7 @@ static int intel_lvds_connector_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode)
{
struct intel_lvds_connector *lvds_connector = to_lvds_connector(connector);
- struct drm_display_mode *fixed_mode = lvds_connector->fixed_mode;
+ struct drm_display_mode *fixed_mode = lvds_connector->panel.fixed_mode;

if (mode->hdisplay > fixed_mode->hdisplay)
return MODE_PANEL;
@@ -259,7 +258,7 @@ static bool intel_lvds_encoder_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(lvds_connector->fixed_mode, adjusted_mode);
+ intel_fixed_panel_mode(lvds_connector->panel.fixed_mode, adjusted_mode);

if (HAS_PCH_SPLIT(dev)) {
intel_pch_panel_fitting(dev, lvds_connector->fitting_mode,
@@ -499,7 +498,7 @@ static int intel_lvds_connector_get_modes(struct drm_connector *connector)
if (lvds_connector->edid)
return drm_add_edid_modes(connector, lvds_connector->edid);

- mode = drm_mode_duplicate(dev, lvds_connector->fixed_mode);
+ mode = drm_mode_duplicate(dev, lvds_connector->panel.fixed_mode);
if (mode == NULL)
return 0;

@@ -786,6 +785,7 @@ bool intel_lvds_init(struct drm_device *dev)
struct drm_connector *connector;
struct drm_encoder *encoder;
struct drm_display_mode *scan; /* *modes, *bios_mode; */
+ struct drm_display_mode *fixed_mode = NULL;
struct drm_crtc *crtc;
u32 lvds;
int pipe;
@@ -908,11 +908,8 @@ bool intel_lvds_init(struct drm_device *dev)

list_for_each_entry(scan, &connector->probed_modes, head) {
if (scan->type & DRM_MODE_TYPE_PREFERRED) {
- lvds_connector->fixed_mode =
- drm_mode_duplicate(dev, scan);
- intel_find_lvds_downclock(dev,
- lvds_connector->fixed_mode,
- connector);
+ fixed_mode = drm_mode_duplicate(dev, scan);
+ intel_find_lvds_downclock(dev, fixed_mode, connector);
goto out;
}
}
@@ -927,11 +924,10 @@ bool intel_lvds_init(struct drm_device *dev)
if (drm_mode_parse_command_line_for_connector(i915_lvds_fixed_mode,
connector,
&mode)) {
- lvds_connector->fixed_mode =
+ fixed_mode =
drm_mode_create_from_cmdline_mode(dev, &mode);
- if (lvds_connector->fixed_mode) {
- lvds_connector->fixed_mode->type |=
- DRM_MODE_TYPE_PREFERRED;
+ if (fixed_mode) {
+ fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
goto out;
}
}
@@ -939,11 +935,9 @@ bool intel_lvds_init(struct drm_device *dev)

/* Failed to get EDID, no override, what about VBT? */
if (dev_priv->lfp_lvds_vbt_mode) {
- lvds_connector->fixed_mode =
- drm_mode_duplicate(dev, dev_priv->lfp_lvds_vbt_mode);
- if (lvds_connector->fixed_mode) {
- lvds_connector->fixed_mode->type |=
- DRM_MODE_TYPE_PREFERRED;
+ fixed_mode = drm_mode_duplicate(dev, dev_priv->lfp_lvds_vbt_mode);
+ if (fixed_mode) {
+ fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
goto out;
}
}
@@ -963,16 +957,15 @@ bool intel_lvds_init(struct drm_device *dev)
crtc = intel_get_crtc_for_pipe(dev, pipe);

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

/* If we still don't have a mode after all that, give up. */
- if (!lvds_connector->fixed_mode)
+ if (!fixed_mode)
goto failed;

out:
@@ -996,7 +989,9 @@ out:
I915_WRITE(BLC_PWM_PCH_CTL1, pwm);
}

- intel_panel_init(&lvds_connector->panel, &lvds_connector->base);
+ intel_panel_init(&lvds_connector->panel,
+ &lvds_connector->base,
+ fixed_mode);
drm_sysfs_connector_add(connector);
return true;

@@ -1004,6 +999,8 @@ failed:
DRM_DEBUG_KMS("No LVDS modes found, disabling.\n");
drm_connector_cleanup(connector);
drm_encoder_cleanup(encoder);
+ if (fixed_mode)
+ drm_mode_destroy(dev, fixed_mode);
kfree(lvds_encoder);
kfree(lvds_connector);
return false;
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index d2dc066..b7329be 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -183,9 +183,12 @@ static int intel_panel_lid_notify(struct notifier_block *nb, unsigned long val,
return NOTIFY_OK;
}

-int intel_panel_init(struct intel_panel *panel, struct intel_connector *connector)
+int intel_panel_init(struct intel_panel *panel,
+ struct intel_connector *connector,
+ struct drm_display_mode *fixed_mode)
{
panel->connector = connector;
+ panel->fixed_mode = fixed_mode;

panel->lid_notifier.notifier_call = intel_panel_lid_notify;
if (acpi_lid_notifier_register(&panel->lid_notifier)) {
@@ -200,6 +203,10 @@ void intel_panel_fini(struct intel_panel *panel)
{
if (panel->lid_notifier.notifier_call)
acpi_lid_notifier_unregister(&panel->lid_notifier);
+
+ if (panel->fixed_mode)
+ drm_mode_destroy(panel->connector->base.dev,
+ panel->fixed_mode);
}

/* Panel backlight controls */
--
1.7.4.1