Commit dd06f90e authored by Jani Nikula's avatar Jani Nikula Committed by Daniel Vetter

drm/i915: Move the fixed mode to intel_panel

Pave the way for sharing some logic between eDP and LVDS.

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 1d508706
...@@ -121,9 +121,10 @@ intel_edp_target_clock(struct intel_encoder *intel_encoder, ...@@ -121,9 +121,10 @@ intel_edp_target_clock(struct intel_encoder *intel_encoder,
struct drm_display_mode *mode) struct drm_display_mode *mode)
{ {
struct intel_dp *intel_dp = container_of(intel_encoder, struct intel_dp, base); struct intel_dp *intel_dp = container_of(intel_encoder, struct intel_dp, base);
struct intel_connector *intel_connector = intel_dp->attached_connector;
if (intel_dp->panel_fixed_mode) if (intel_connector->panel.fixed_mode)
return intel_dp->panel_fixed_mode->clock; return intel_connector->panel.fixed_mode->clock;
else else
return mode->clock; return mode->clock;
} }
...@@ -227,12 +228,14 @@ intel_dp_mode_valid(struct drm_connector *connector, ...@@ -227,12 +228,14 @@ intel_dp_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode) struct drm_display_mode *mode)
{ {
struct intel_dp *intel_dp = intel_attached_dp(connector); struct intel_dp *intel_dp = intel_attached_dp(connector);
struct intel_connector *intel_connector = to_intel_connector(connector);
struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
if (is_edp(intel_dp) && intel_dp->panel_fixed_mode) { if (is_edp(intel_dp) && fixed_mode) {
if (mode->hdisplay > intel_dp->panel_fixed_mode->hdisplay) if (mode->hdisplay > fixed_mode->hdisplay)
return MODE_PANEL; return MODE_PANEL;
if (mode->vdisplay > intel_dp->panel_fixed_mode->vdisplay) if (mode->vdisplay > fixed_mode->vdisplay)
return MODE_PANEL; return MODE_PANEL;
} }
...@@ -699,14 +702,16 @@ intel_dp_mode_fixup(struct drm_encoder *encoder, ...@@ -699,14 +702,16 @@ intel_dp_mode_fixup(struct drm_encoder *encoder,
{ {
struct drm_device *dev = encoder->dev; struct drm_device *dev = encoder->dev;
struct intel_dp *intel_dp = enc_to_intel_dp(encoder); struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
struct intel_connector *intel_connector = intel_dp->attached_connector;
int lane_count, clock; int lane_count, clock;
int max_lane_count = intel_dp_max_lane_count(intel_dp); 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; int max_clock = intel_dp_max_link_bw(intel_dp) == DP_LINK_BW_2_7 ? 1 : 0;
int bpp, mode_rate; int bpp, mode_rate;
static int bws[2] = { DP_LINK_BW_1_62, DP_LINK_BW_2_7 }; static int bws[2] = { DP_LINK_BW_1_62, DP_LINK_BW_2_7 };
if (is_edp(intel_dp) && intel_dp->panel_fixed_mode) { if (is_edp(intel_dp) && intel_connector->panel.fixed_mode) {
intel_fixed_panel_mode(intel_dp->panel_fixed_mode, adjusted_mode); intel_fixed_panel_mode(intel_connector->panel.fixed_mode,
adjusted_mode);
intel_pch_panel_fitting(dev, DRM_MODE_SCALE_FULLSCREEN, intel_pch_panel_fitting(dev, DRM_MODE_SCALE_FULLSCREEN,
mode, adjusted_mode); mode, adjusted_mode);
} }
...@@ -2400,6 +2405,7 @@ intel_dp_detect(struct drm_connector *connector, bool force) ...@@ -2400,6 +2405,7 @@ intel_dp_detect(struct drm_connector *connector, bool force)
static int intel_dp_get_modes(struct drm_connector *connector) static int intel_dp_get_modes(struct drm_connector *connector)
{ {
struct intel_dp *intel_dp = intel_attached_dp(connector); struct intel_dp *intel_dp = intel_attached_dp(connector);
struct intel_connector *intel_connector = to_intel_connector(connector);
struct drm_device *dev = intel_dp->base.base.dev; struct drm_device *dev = intel_dp->base.base.dev;
int ret; int ret;
...@@ -2411,9 +2417,10 @@ static int intel_dp_get_modes(struct drm_connector *connector) ...@@ -2411,9 +2417,10 @@ static int intel_dp_get_modes(struct drm_connector *connector)
return ret; return ret;
/* if eDP has no EDID, fall back to fixed mode */ /* if eDP has no EDID, fall back to fixed mode */
if (is_edp(intel_dp) && intel_dp->panel_fixed_mode) { if (is_edp(intel_dp) && intel_connector->panel.fixed_mode) {
struct drm_display_mode *mode; struct drm_display_mode *mode;
mode = drm_mode_duplicate(dev, intel_dp->panel_fixed_mode); mode = drm_mode_duplicate(dev,
intel_connector->panel.fixed_mode);
if (mode) { if (mode) {
drm_mode_probed_add(connector, mode); drm_mode_probed_add(connector, mode);
return 1; return 1;
...@@ -2633,6 +2640,7 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port) ...@@ -2633,6 +2640,7 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port)
return; return;
} }
intel_encoder = &intel_dp->base; intel_encoder = &intel_dp->base;
intel_dp->attached_connector = intel_connector;
if (HAS_PCH_SPLIT(dev) && output_reg == PCH_DP_D) if (HAS_PCH_SPLIT(dev) && output_reg == PCH_DP_D)
if (intel_dpd_is_edp(dev)) if (intel_dpd_is_edp(dev))
...@@ -2824,7 +2832,6 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port) ...@@ -2824,7 +2832,6 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port)
if (fixed_mode) if (fixed_mode)
fixed_mode->type |= DRM_MODE_TYPE_PREFERRED; fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
} }
intel_dp->panel_fixed_mode = fixed_mode;
ironlake_edp_panel_vdd_off(intel_dp, false); ironlake_edp_panel_vdd_off(intel_dp, false);
} }
...@@ -2832,7 +2839,7 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port) ...@@ -2832,7 +2839,7 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port)
intel_encoder->hot_plug = intel_dp_hot_plug; intel_encoder->hot_plug = intel_dp_hot_plug;
if (is_edp(intel_dp)) { if (is_edp(intel_dp)) {
intel_panel_init(&intel_connector->panel); intel_panel_init(&intel_connector->panel, fixed_mode);
intel_panel_setup_backlight(connector); intel_panel_setup_backlight(connector);
} }
......
...@@ -164,6 +164,7 @@ struct intel_encoder { ...@@ -164,6 +164,7 @@ struct intel_encoder {
}; };
struct intel_panel { struct intel_panel {
struct drm_display_mode *fixed_mode;
}; };
struct intel_connector { struct intel_connector {
...@@ -364,11 +365,11 @@ struct intel_dp { ...@@ -364,11 +365,11 @@ struct intel_dp {
int panel_power_cycle_delay; int panel_power_cycle_delay;
int backlight_on_delay; int backlight_on_delay;
int backlight_off_delay; int backlight_off_delay;
struct drm_display_mode *panel_fixed_mode; /* for eDP */
struct delayed_work panel_vdd_work; struct delayed_work panel_vdd_work;
bool want_panel_vdd; bool want_panel_vdd;
struct edid *edid; /* cached EDID for eDP */ struct edid *edid; /* cached EDID for eDP */
int edid_mode_count; int edid_mode_count;
struct intel_connector *attached_connector;
}; };
static inline struct drm_crtc * static inline struct drm_crtc *
...@@ -442,7 +443,8 @@ extern void intel_flush_display_plane(struct drm_i915_private *dev_priv, ...@@ -442,7 +443,8 @@ extern void intel_flush_display_plane(struct drm_i915_private *dev_priv,
enum plane plane); enum plane plane);
/* intel_panel.c */ /* intel_panel.c */
extern int intel_panel_init(struct intel_panel *panel); extern int intel_panel_init(struct intel_panel *panel,
struct drm_display_mode *fixed_mode);
extern void intel_panel_fini(struct intel_panel *panel); extern void intel_panel_fini(struct intel_panel *panel);
extern void intel_fixed_panel_mode(struct drm_display_mode *fixed_mode, extern void intel_fixed_panel_mode(struct drm_display_mode *fixed_mode,
......
...@@ -44,7 +44,6 @@ struct intel_lvds_connector { ...@@ -44,7 +44,6 @@ struct intel_lvds_connector {
struct intel_connector base; struct intel_connector base;
struct notifier_block lid_notifier; struct notifier_block lid_notifier;
struct drm_display_mode *fixed_mode;
struct edid *edid; struct edid *edid;
int fitting_mode; int fitting_mode;
}; };
...@@ -177,8 +176,8 @@ static void intel_disable_lvds(struct intel_encoder *encoder) ...@@ -177,8 +176,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_connector *lvds_connector = to_lvds_connector(connector); struct intel_connector *intel_connector = to_intel_connector(connector);
struct drm_display_mode *fixed_mode = lvds_connector->fixed_mode; struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
if (mode->hdisplay > fixed_mode->hdisplay) if (mode->hdisplay > fixed_mode->hdisplay)
return MODE_PANEL; return MODE_PANEL;
...@@ -276,7 +275,8 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder, ...@@ -276,7 +275,8 @@ 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(lvds_connector->fixed_mode, adjusted_mode); intel_fixed_panel_mode(lvds_connector->base.panel.fixed_mode,
adjusted_mode);
if (HAS_PCH_SPLIT(dev)) { if (HAS_PCH_SPLIT(dev)) {
intel_pch_panel_fitting(dev, lvds_connector->fitting_mode, intel_pch_panel_fitting(dev, lvds_connector->fitting_mode,
...@@ -463,7 +463,7 @@ static int intel_lvds_get_modes(struct drm_connector *connector) ...@@ -463,7 +463,7 @@ static int intel_lvds_get_modes(struct drm_connector *connector)
if (lvds_connector->edid) if (lvds_connector->edid)
return drm_add_edid_modes(connector, 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->base.panel.fixed_mode);
if (mode == NULL) if (mode == NULL)
return 0; return 0;
...@@ -921,6 +921,7 @@ bool intel_lvds_init(struct drm_device *dev) ...@@ -921,6 +921,7 @@ bool intel_lvds_init(struct drm_device *dev)
struct drm_connector *connector; struct drm_connector *connector;
struct drm_encoder *encoder; struct drm_encoder *encoder;
struct drm_display_mode *scan; /* *modes, *bios_mode; */ struct drm_display_mode *scan; /* *modes, *bios_mode; */
struct drm_display_mode *fixed_mode = NULL;
struct drm_crtc *crtc; struct drm_crtc *crtc;
u32 lvds; u32 lvds;
int pipe; int pipe;
...@@ -1044,20 +1045,17 @@ bool intel_lvds_init(struct drm_device *dev) ...@@ -1044,20 +1045,17 @@ 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) {
lvds_connector->fixed_mode = drm_mode_duplicate(dev, scan); fixed_mode = drm_mode_duplicate(dev, scan);
intel_find_lvds_downclock(dev, intel_find_lvds_downclock(dev, fixed_mode, connector);
lvds_connector->fixed_mode,
connector);
goto out; goto out;
} }
} }
/* 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) {
lvds_connector->fixed_mode = fixed_mode = drm_mode_duplicate(dev, dev_priv->lfp_lvds_vbt_mode);
drm_mode_duplicate(dev, dev_priv->lfp_lvds_vbt_mode); if (fixed_mode) {
if (lvds_connector->fixed_mode) { fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
lvds_connector->fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
goto out; goto out;
} }
} }
...@@ -1077,15 +1075,15 @@ bool intel_lvds_init(struct drm_device *dev) ...@@ -1077,15 +1075,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)) {
lvds_connector->fixed_mode = intel_crtc_mode_get(dev, crtc); fixed_mode = intel_crtc_mode_get(dev, crtc);
if (lvds_connector->fixed_mode) { if (fixed_mode) {
lvds_connector->fixed_mode->type |= DRM_MODE_TYPE_PREFERRED; fixed_mode->type |= 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 (!lvds_connector->fixed_mode) if (!fixed_mode)
goto failed; goto failed;
out: out:
...@@ -1107,7 +1105,7 @@ bool intel_lvds_init(struct drm_device *dev) ...@@ -1107,7 +1105,7 @@ bool intel_lvds_init(struct drm_device *dev)
} }
drm_sysfs_connector_add(connector); drm_sysfs_connector_add(connector);
intel_panel_init(&intel_connector->panel); intel_panel_init(&intel_connector->panel, fixed_mode);
intel_panel_setup_backlight(connector); intel_panel_setup_backlight(connector);
return true; return true;
...@@ -1116,6 +1114,8 @@ bool intel_lvds_init(struct drm_device *dev) ...@@ -1116,6 +1114,8 @@ 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);
if (fixed_mode)
drm_mode_destroy(dev, fixed_mode);
kfree(lvds_encoder); kfree(lvds_encoder);
kfree(lvds_connector); kfree(lvds_connector);
return false; return false;
......
...@@ -465,11 +465,19 @@ void intel_panel_destroy_backlight(struct drm_device *dev) ...@@ -465,11 +465,19 @@ void intel_panel_destroy_backlight(struct drm_device *dev)
} }
#endif #endif
int intel_panel_init(struct intel_panel *panel) int intel_panel_init(struct intel_panel *panel,
struct drm_display_mode *fixed_mode)
{ {
panel->fixed_mode = fixed_mode;
return 0; return 0;
} }
void intel_panel_fini(struct intel_panel *panel) void intel_panel_fini(struct intel_panel *panel)
{ {
struct intel_connector *intel_connector =
container_of(panel, struct intel_connector, panel);
if (panel->fixed_mode)
drm_mode_destroy(intel_connector->base.dev, panel->fixed_mode);
} }
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