aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2014-01-02 16:27:33 -0500
committerThierry Reding <treding@nvidia.com>2014-01-14 08:35:02 -0500
commitdb5f7a6e78303fd96dc87487d6976145f70ab84a (patch)
tree67e1794359724795088e92c4ded11fff46e58007
parentff5009ef8df87908a956412619e4f1bf1078ef5d (diff)
drm: provide a helper for the encoder possible_crtcs mask
The encoder possible_crtcs mask identifies which CRTCs can be bound to a particular encoder. Each bit from bit 0 defines an index in the list of CRTCs held in the DRM mode_config crtc_list. Rather than having drivers trying to track the position of their CRTCs in the list, expose the code which already exists for calculating the appropriate mask bit for a CRTC. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Reviewed-by: David Herrmann <dh.herrmann@gmail.com> Reviewed-by: Jani Nikula <jani.nikula@intel.com> [treding@nvidia.com: add drm_crtc_index(), move to core] Signed-off-by: Thierry Reding <treding@nvidia.com>
-rw-r--r--drivers/gpu/drm/drm_crtc.c23
-rw-r--r--drivers/gpu/drm/drm_crtc_helper.c18
-rw-r--r--include/drm/drm_crtc.h13
3 files changed, 37 insertions, 17 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index d6cf77c472e7..452bcbd0eab9 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -675,6 +675,29 @@ void drm_crtc_cleanup(struct drm_crtc *crtc)
675EXPORT_SYMBOL(drm_crtc_cleanup); 675EXPORT_SYMBOL(drm_crtc_cleanup);
676 676
677/** 677/**
678 * drm_crtc_index - find the index of a registered CRTC
679 * @crtc: CRTC to find index for
680 *
681 * Given a registered CRTC, return the index of that CRTC within a DRM
682 * device's list of CRTCs.
683 */
684unsigned int drm_crtc_index(struct drm_crtc *crtc)
685{
686 unsigned int index = 0;
687 struct drm_crtc *tmp;
688
689 list_for_each_entry(tmp, &crtc->dev->mode_config.crtc_list, head) {
690 if (tmp == crtc)
691 return index;
692
693 index++;
694 }
695
696 BUG();
697}
698EXPORT_SYMBOL(drm_crtc_index);
699
700/**
678 * drm_mode_probed_add - add a mode to a connector's probed mode list 701 * drm_mode_probed_add - add a mode to a connector's probed mode list
679 * @connector: connector the new mode 702 * @connector: connector the new mode
680 * @mode: mode data 703 * @mode: mode data
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index 01361aba033b..940c678cf012 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -334,23 +334,7 @@ EXPORT_SYMBOL(drm_helper_disable_unused_functions);
334static bool drm_encoder_crtc_ok(struct drm_encoder *encoder, 334static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
335 struct drm_crtc *crtc) 335 struct drm_crtc *crtc)
336{ 336{
337 struct drm_device *dev; 337 return !!(encoder->possible_crtcs & drm_crtc_mask(crtc));
338 struct drm_crtc *tmp;
339 int crtc_mask = 1;
340
341 WARN(!crtc, "checking null crtc?\n");
342
343 dev = crtc->dev;
344
345 list_for_each_entry(tmp, &dev->mode_config.crtc_list, head) {
346 if (tmp == crtc)
347 break;
348 crtc_mask <<= 1;
349 }
350
351 if (encoder->possible_crtcs & crtc_mask)
352 return true;
353 return false;
354} 338}
355 339
356/* 340/*
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index f32c5cd51f41..4f2e3e82f014 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -929,6 +929,19 @@ extern int drm_crtc_init(struct drm_device *dev,
929 struct drm_crtc *crtc, 929 struct drm_crtc *crtc,
930 const struct drm_crtc_funcs *funcs); 930 const struct drm_crtc_funcs *funcs);
931extern void drm_crtc_cleanup(struct drm_crtc *crtc); 931extern void drm_crtc_cleanup(struct drm_crtc *crtc);
932extern unsigned int drm_crtc_index(struct drm_crtc *crtc);
933
934/**
935 * drm_crtc_mask - find the mask of a registered CRTC
936 * @crtc: CRTC to find mask for
937 *
938 * Given a registered CRTC, return the mask bit of that CRTC for an
939 * encoder's possible_crtcs field.
940 */
941static inline uint32_t drm_crtc_mask(struct drm_crtc *crtc)
942{
943 return 1 << drm_crtc_index(crtc);
944}
932 945
933extern void drm_connector_ida_init(void); 946extern void drm_connector_ida_init(void);
934extern void drm_connector_ida_destroy(void); 947extern void drm_connector_ida_destroy(void);