[Intel-gfx] [PATCH 6/7] drm/i915: Make finding unused crtc as a generic function
Durgadoss R
durgadoss.r at intel.com
Fri Dec 11 01:39:27 PST 2015
Looping over the crtc list and finding an unused crtc
has users other than load_detect(). Hence move it to
a common function so that we can re-use the logic.
Signed-off-by: Durgadoss R <durgadoss.r at intel.com>
---
drivers/gpu/drm/i915/intel_display.c | 37 ++++++++++++++++++++++--------------
drivers/gpu/drm/i915/intel_drv.h | 1 +
2 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 16ad5cd..fb0008f 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -10325,6 +10325,27 @@ static int intel_modeset_setup_plane_state(struct drm_atomic_state *state,
return 0;
}
+struct drm_crtc *intel_get_unused_crtc(struct drm_encoder *encoder)
+{
+ struct drm_crtc *possible_crtc;
+ struct drm_crtc *crtc = NULL;
+ struct drm_device *dev = encoder->dev;
+ int i = -1;
+
+ for_each_crtc(dev, possible_crtc) {
+ i++;
+ if (!(encoder->possible_crtcs & (1 << i)))
+ continue;
+ if (possible_crtc->state->enable)
+ continue;
+
+ crtc = possible_crtc;
+ break;
+ }
+
+ return crtc;
+}
+
bool intel_get_load_detect_pipe(struct drm_connector *connector,
struct drm_display_mode *mode,
struct intel_load_detect_pipe *old,
@@ -10333,7 +10354,6 @@ bool intel_get_load_detect_pipe(struct drm_connector *connector,
struct intel_crtc *intel_crtc;
struct intel_encoder *intel_encoder =
intel_attached_encoder(connector);
- struct drm_crtc *possible_crtc;
struct drm_encoder *encoder = &intel_encoder->base;
struct drm_crtc *crtc = NULL;
struct drm_device *dev = encoder->dev;
@@ -10342,7 +10362,7 @@ bool intel_get_load_detect_pipe(struct drm_connector *connector,
struct drm_atomic_state *state = NULL;
struct drm_connector_state *connector_state;
struct intel_crtc_state *crtc_state;
- int ret, i = -1;
+ int ret;
DRM_DEBUG_KMS("[CONNECTOR:%d:%s], [ENCODER:%d:%s]\n",
connector->base.id, connector->name,
@@ -10384,21 +10404,10 @@ retry:
return true;
}
- /* Find an unused one (if possible) */
- for_each_crtc(dev, possible_crtc) {
- i++;
- if (!(encoder->possible_crtcs & (1 << i)))
- continue;
- if (possible_crtc->state->enable)
- continue;
-
- crtc = possible_crtc;
- break;
- }
-
/*
* If we didn't find an unused CRTC, don't use any.
*/
+ crtc = intel_get_unused_crtc(encoder);
if (!crtc) {
DRM_DEBUG_KMS("no pipe available for load-detect\n");
goto fail;
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 5cefb0e..5912955 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1100,6 +1100,7 @@ bool intel_get_load_detect_pipe(struct drm_connector *connector,
void intel_release_load_detect_pipe(struct drm_connector *connector,
struct intel_load_detect_pipe *old,
struct drm_modeset_acquire_ctx *ctx);
+struct drm_crtc *intel_get_unused_crtc(struct drm_encoder *encoder);
int intel_pin_and_fence_fb_obj(struct drm_plane *plane,
struct drm_framebuffer *fb,
const struct drm_plane_state *plane_state);
--
1.9.1
More information about the Intel-gfx
mailing list