[RFC] drm/i915/bxt: Add pipe_src size property

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch is adding pipesource size as property as intel property.User
application is allowed to change the pipe source size in runtime on BXT/SKL.
Added the property as inteli crtc property.

Comments and suggestions are requested for whether we can keep the
property as intel crtc property or move to drm level.

Signed-off-by: Nabendu Maiti <nabendu.bikash.maiti@xxxxxxxxx>
---
 drivers/gpu/drm/i915/i915_drv.h      |  1 +
 drivers/gpu/drm/i915/intel_atomic.c  | 66 ++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_display.c | 46 +++++++++++++++++++++++--
 drivers/gpu/drm/i915/intel_drv.h     |  9 +++++
 4 files changed, 120 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index cf7e0fc..d789841 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1867,6 +1867,7 @@ struct drm_i915_private {
 
 	struct drm_property *broadcast_rgb_property;
 	struct drm_property *force_audio_property;
+	struct drm_property *crtc_src_size_prop;
 
 	/* hda/i915 audio component */
 	struct i915_audio_component *audio_component;
diff --git a/drivers/gpu/drm/i915/intel_atomic.c b/drivers/gpu/drm/i915/intel_atomic.c
index 4625f8a..b386ba9 100644
--- a/drivers/gpu/drm/i915/intel_atomic.c
+++ b/drivers/gpu/drm/i915/intel_atomic.c
@@ -73,6 +73,72 @@ intel_connector_atomic_get_property(struct drm_connector *connector,
 	return -EINVAL;
 }
 
+/* intel_crtc_atomic_set_property - duplicate crtc state
+ * @crtc: drm crtc
+ *
+ * Allocates and returns a copy of the crtc state (both common and
+ * Intel-specific) for the specified crtc.
+ *
+ * Returns: The newly allocated crtc state, or NULL on failure.
+ */
+int
+intel_crtc_atomic_set_property(struct drm_crtc *crtc,
+			       struct drm_crtc_state *state,
+			       struct drm_property *property,
+			       uint64_t val)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+	struct intel_crtc_state *intel_crtc_state = to_intel_crtc_state(state);
+	u32 pipe_src_size = ((intel_crtc_state->pipe_src_w << 16) |
+			     (intel_crtc_state->pipe_src_h));
+	struct drm_display_mode *adjusted_mode =
+		&intel_crtc->config->base.adjusted_mode;
+
+	if (property == dev_priv->crtc_src_size_prop) {
+		if (val != pipe_src_size) {
+			if (val) {
+				intel_crtc_state->pipe_src_w = (val >> 16);
+				intel_crtc_state->pipe_src_h = val & 0x0000ffff;
+			} else {
+
+				/* for 0 set standard modeset calculated values */
+				intel_crtc_state->pipe_src_w = adjusted_mode->hdisplay;
+				intel_crtc_state->pipe_src_h = adjusted_mode->vdisplay;
+			}
+			intel_crtc_state->update_pipe = true;
+		}
+	}
+	return 0;
+}
+
+/*
+ * intel_crtc_atomic_get_property - duplicate crtc state
+ * @crtc: drm crtc
+ *
+ * Get Crtc properties.
+ *
+ * Returns: The newly allocated crtc state, or NULL on failure.
+ */
+int
+intel_crtc_atomic_get_property(struct drm_crtc *crtc,
+			       const struct drm_crtc_state *state,
+			       struct drm_property *property,
+			       uint64_t *val)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_crtc_state *intel_crtc_state = to_intel_crtc_state(state);
+	u32 pipe_src_size = ((intel_crtc_state->pipe_src_w << 16) |
+		(intel_crtc_state->pipe_src_h));
+
+	if (property == dev_priv->crtc_src_size_prop) {
+		*val = pipe_src_size;
+	}
+	return 0;
+}
+
 /*
  * intel_crtc_duplicate_state - duplicate crtc state
  * @crtc: drm crtc
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 2d0b006..ca4e26b 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -3340,6 +3340,12 @@ static void intel_update_pipe_config(struct intel_crtc *crtc,
 	 * sized surface.
 	 */
 
+	/* Restore modeset values */
+	if (!crtc->config->pipe_src_w && crtc->config->pipe_src_h) {
+		crtc->config->pipe_src_w = adjusted_mode->crtc_hdisplay;
+		crtc->config->pipe_src_h = adjusted_mode->crtc_vdisplay;
+	}
+
 	I915_WRITE(PIPESRC(crtc->pipe),
 		   ((pipe_config->pipe_src_w - 1) << 16) |
 		   (pipe_config->pipe_src_h - 1));
@@ -12068,9 +12074,23 @@ static int intel_crtc_atomic_check(struct drm_crtc *crtc,
 	}
 
 	if (INTEL_INFO(dev)->gen >= 9) {
-		if (mode_changed)
-			ret = skl_update_scaler_crtc(pipe_config);
+		struct intel_connector *intel_connector;
+		for_each_intel_connector(dev, intel_connector) {
+			if (intel_connector->encoder->base.crtc  != crtc)
+				continue;
+
+			if ((intel_connector != NULL) && ((mode_changed) ||
+							  (pipe_config->update_pipe))) {
+				ret = skl_update_scaler_crtc(pipe_config);
 
+				if (HAS_GMCH_DISPLAY(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 (!ret)
 			ret = intel_atomic_setup_scalers(dev, intel_crtc,
 							 pipe_config);
@@ -13674,6 +13694,8 @@ static const struct drm_crtc_funcs intel_crtc_funcs = {
 	.page_flip = intel_crtc_page_flip,
 	.atomic_duplicate_state = intel_crtc_duplicate_state,
 	.atomic_destroy_state = intel_crtc_destroy_state,
+	.atomic_set_property = intel_crtc_atomic_set_property,
+	.atomic_get_property = intel_crtc_atomic_get_property,
 };
 
 static bool ibx_pch_dpll_get_hw_state(struct drm_i915_private *dev_priv,
@@ -14097,6 +14119,23 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev,
 	return &primary->base;
 }
 
+void intel_create_crtc_properties(struct drm_device *dev,
+				  struct intel_crtc *intel_crtc)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	if (!dev_priv->crtc_src_size_prop) {
+		dev_priv->crtc_src_size_prop =
+			drm_property_create_range(dev, DRM_MODE_PROP_ATOMIC,
+			"crtc_src_size", 0, UINT_MAX);
+	}
+
+	/*FIXME: Add modeseted values ?*/
+	if (dev_priv->crtc_src_size_prop)
+		drm_object_attach_property(&intel_crtc->base.base,
+				dev_priv->crtc_src_size_prop, 0);
+}
+
 void intel_create_rotation_property(struct drm_device *dev, struct intel_plane *plane)
 {
 	if (!dev->mode_config.rotation_property) {
@@ -14319,6 +14358,9 @@ static void intel_crtc_init(struct drm_device *dev, int pipe)
 	if (ret)
 		goto fail;
 
+	if (INTEL_INFO(dev)->gen >= 9)
+		intel_create_crtc_properties(dev, intel_crtc);
+
 	drm_mode_crtc_set_gamma_size(&intel_crtc->base, 256);
 	for (i = 0; i < 256; i++) {
 		intel_crtc->lut_r[i] = i;
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 0438b57..c787f0b 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1586,6 +1586,15 @@ int intel_connector_atomic_get_property(struct drm_connector *connector,
 					struct drm_property *property,
 					uint64_t *val);
 struct drm_crtc_state *intel_crtc_duplicate_state(struct drm_crtc *crtc);
+int intel_crtc_atomic_set_property(struct drm_crtc *crtc,
+				   struct drm_crtc_state *state,
+				   struct drm_property *property, uint64_t val);
+int
+intel_crtc_atomic_get_property(struct drm_crtc *crtc,
+			       const struct drm_crtc_state *state,
+			       struct drm_property *property,
+			       uint64_t *val);
+
 void intel_crtc_destroy_state(struct drm_crtc *crtc,
 			       struct drm_crtc_state *state);
 struct drm_atomic_state *intel_atomic_state_alloc(struct drm_device *dev);
-- 
1.9.1

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




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux