All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiong Zhang <xiong.y.zhang@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 4/4] drm/i915: Adding panel filter for VGA
Date: Mon, 10 Aug 2015 15:26:11 +0800	[thread overview]
Message-ID: <1439191571-25847-4-git-send-email-xiong.y.zhang@intel.com> (raw)
In-Reply-To: <1439191571-25847-1-git-send-email-xiong.y.zhang@intel.com>

Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com>
---
 drivers/gpu/drm/i915/intel_crt.c | 81 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 77 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
index 521af2c..f8eedfc 100644
--- a/drivers/gpu/drm/i915/intel_crt.c
+++ b/drivers/gpu/drm/i915/intel_crt.c
@@ -288,24 +288,37 @@ intel_crt_mode_valid(struct drm_connector *connector,
 		     struct drm_display_mode *mode)
 {
 	struct drm_device *dev = connector->dev;
+	struct intel_connector *intel_connector = to_intel_connector(connector);
+	struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
+	int max_clock = 0, clock;
 
-	int max_clock = 0;
 	if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
 		return MODE_NO_DBLESCAN;
 
-	if (mode->clock < 25000)
+	clock = mode->clock;
+	if (!intel_panel_scale_none(&intel_connector->panel)) {
+		if (mode->hdisplay > fixed_mode->hdisplay)
+			return MODE_PANEL;
+
+		if (mode->vdisplay > fixed_mode->vdisplay)
+			return MODE_PANEL;
+
+		clock = fixed_mode->clock;
+	}
+
+	if (clock < 25000)
 		return MODE_CLOCK_LOW;
 
 	if (IS_GEN2(dev))
 		max_clock = 350000;
 	else
 		max_clock = 400000;
-	if (mode->clock > max_clock)
+	if (clock > max_clock)
 		return MODE_CLOCK_HIGH;
 
 	/* The FDI receiver on LPT only supports 8bpc and only has 2 lanes. */
 	if (HAS_PCH_LPT(dev) &&
-	    (ironlake_get_lanes_required(mode->clock, 270000, 24) > 2))
+	    (ironlake_get_lanes_required(clock, 270000, 24) > 2))
 		return MODE_CLOCK_HIGH;
 
 	return MODE_OK;
@@ -315,6 +328,22 @@ static bool intel_crt_compute_config(struct intel_encoder *encoder,
 				     struct intel_crtc_state *pipe_config)
 {
 	struct drm_device *dev = encoder->base.dev;
+	struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;
+	struct intel_crtc *intel_crtc = to_intel_crtc(pipe_config->base.crtc);
+	struct intel_crt *intel_crt = intel_encoder_to_crt(encoder);
+	struct intel_connector *intel_connector = intel_crt->connector;
+
+	if (!intel_panel_scale_none(&intel_connector->panel)) {
+		intel_fixed_panel_mode(intel_connector->panel.fixed_mode,
+				       adjusted_mode);
+
+		if (!HAS_PCH_SPLIT(dev))
+			intel_gmch_panel_fitting(intel_crtc, pipe_config,
+				     intel_connector->panel.fitting_mode);
+		else
+			intel_pch_panel_fitting(intel_crtc, pipe_config,
+				    intel_connector->panel.fitting_mode);
+	}
 
 	if (HAS_PCH_SPLIT(dev))
 		pipe_config->has_pch_encoder = true;
@@ -489,6 +518,7 @@ static struct edid *intel_crt_get_edid(struct drm_connector *connector,
 static int intel_crt_ddc_get_modes(struct drm_connector *connector,
 				struct i2c_adapter *adapter)
 {
+	struct intel_connector *intel_connector = to_intel_connector(connector);
 	struct edid *edid;
 	int ret;
 
@@ -499,6 +529,20 @@ static int intel_crt_ddc_get_modes(struct drm_connector *connector,
 	ret = intel_connector_update_modes(connector, edid);
 	kfree(edid);
 
+	if (ret && intel_connector->panel.fixed_mode == NULL) {
+		struct drm_display_mode *fixed_mode = NULL, *scan;
+
+		list_for_each_entry(scan, &connector->probed_modes, head) {
+			if (scan->type & DRM_MODE_TYPE_PREFERRED)
+				fixed_mode = drm_mode_duplicate(connector->dev,
+								scan);
+		}
+
+		if (fixed_mode)
+			intel_panel_init(&intel_connector->panel,
+					 fixed_mode, NULL);
+	}
+
 	return ret;
 }
 
@@ -768,6 +812,18 @@ static int intel_crt_set_property(struct drm_connector *connector,
 				  struct drm_property *property,
 				  uint64_t value)
 {
+	struct intel_connector *intel_connector = to_intel_connector(connector);
+
+	if (property == connector->dev->mode_config.scaling_mode_property) {
+		if (intel_connector->panel.fitting_mode == value)
+			return 0;
+
+		intel_connector->panel.fitting_mode = value;
+
+		if (connector->encoder && connector->encoder->crtc)
+			intel_crtc_restore_mode(connector->encoder->crtc);
+	}
+
 	return 0;
 }
 
@@ -844,6 +900,21 @@ static const struct dmi_system_id intel_no_crt[] = {
 	{ }
 };
 
+static void
+intel_crt_add_properties(struct drm_connector *connector)
+{
+	struct intel_connector *intel_connector = to_intel_connector(connector);
+
+	/* Each pipe has pannel filter since Ironlake. */
+	if (INTEL_INFO(connector->dev)->gen >= 5) {
+		drm_mode_create_scaling_mode_property(connector->dev);
+		drm_object_attach_property(&connector->base,
+				connector->dev->mode_config.scaling_mode_property,
+				DRM_MODE_SCALE_NONE);
+		intel_connector->panel.fitting_mode = DRM_MODE_SCALE_NONE;
+	}
+}
+
 void intel_crt_init(struct drm_device *dev)
 {
 	struct drm_connector *connector;
@@ -870,6 +941,8 @@ void intel_crt_init(struct drm_device *dev)
 	drm_connector_init(dev, &intel_connector->base,
 			   &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA);
 
+	intel_crt_add_properties(connector);
+
 	drm_encoder_init(dev, &crt->base.base, &intel_crt_enc_funcs,
 			 DRM_MODE_ENCODER_DAC);
 
-- 
1.8.2.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2015-08-10  7:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-10  7:26 [PATCH 1/4] drm/i915: Adding intel_panel_scale_none() helper function Xiong Zhang
2015-08-10  7:26 ` [PATCH 2/4] drm/i915: Adding Panel Filter function for DP Xiong Zhang
2015-08-13 15:44   ` Ville Syrjälä
2015-08-14  5:12     ` Zhang, Xiong Y
2015-08-14 16:28       ` Ville Syrjälä
2015-08-18 12:38         ` Ville Syrjälä
2015-08-19  9:11           ` Zhang, Xiong Y
2015-08-19 11:40             ` Ville Syrjälä
2015-08-19 12:47             ` Simon Farnsworth
2015-08-10  7:26 ` [PATCH 3/4] drm/i915: Adding panel filter for HDMI Xiong Zhang
2015-08-10  7:26 ` Xiong Zhang [this message]
2015-08-10  7:45 ` [PATCH 1/4] drm/i915: Adding intel_panel_scale_none() helper function Xiong Zhang
2015-08-10 18:23   ` Rodrigo Vivi
2015-08-12 13:00     ` Daniel Vetter
2015-08-14  5:18       ` Zhang, Xiong Y
2016-10-14 13:03         ` Timo Aaltonen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1439191571-25847-4-git-send-email-xiong.y.zhang@intel.com \
    --to=xiong.y.zhang@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.