diff options
author | Matt Roper <matthew.d.roper@intel.com> | 2014-04-01 18:22:38 -0400 |
---|---|---|
committer | Rob Clark <robdclark@gmail.com> | 2014-04-01 20:18:27 -0400 |
commit | e13161af80c185ecd8dc4641d0f5df58f9e3e0af (patch) | |
tree | f91577cef047892521deed04a077c87babcfeb2c | |
parent | 9922ab5a7e4a4e089b2abfb1425590b97a7a90a3 (diff) |
drm: Add drm_crtc_init_with_planes() (v2)
Add a new drm_crtc_init_with_planes() to allow drivers to provide
specific primary and cursor planes at CRTC initialization. The existing
drm_crtc_init() interface remains to avoid driver churn in existing
drivers; it will initialize the CRTC with a plane helper-created primary
plane and no cursor plane.
v2:
- Move drm_crtc_init() to plane helper file so that nothing in the DRM
core depends on helpers. [suggested by Daniel Vetter]
- Keep cursor parameter to drm_crtc_init_with_planes() a void* until
we actually add cursor support. [suggested by Daniel Vetter]
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
-rw-r--r-- | drivers/gpu/drm/drm_crtc.c | 19 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_plane_helper.c | 21 | ||||
-rw-r--r-- | include/drm/drm_crtc.h | 11 |
3 files changed, 47 insertions, 4 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index eb2165954f18..110e5ce117f5 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c | |||
@@ -692,9 +692,12 @@ void drm_framebuffer_remove(struct drm_framebuffer *fb) | |||
692 | EXPORT_SYMBOL(drm_framebuffer_remove); | 692 | EXPORT_SYMBOL(drm_framebuffer_remove); |
693 | 693 | ||
694 | /** | 694 | /** |
695 | * drm_crtc_init - Initialise a new CRTC object | 695 | * drm_crtc_init_with_planes - Initialise a new CRTC object with |
696 | * specified primary and cursor planes. | ||
696 | * @dev: DRM device | 697 | * @dev: DRM device |
697 | * @crtc: CRTC object to init | 698 | * @crtc: CRTC object to init |
699 | * @primary: Primary plane for CRTC | ||
700 | * @cursor: Cursor plane for CRTC | ||
698 | * @funcs: callbacks for the new CRTC | 701 | * @funcs: callbacks for the new CRTC |
699 | * | 702 | * |
700 | * Inits a new object created as base part of a driver crtc object. | 703 | * Inits a new object created as base part of a driver crtc object. |
@@ -702,8 +705,10 @@ EXPORT_SYMBOL(drm_framebuffer_remove); | |||
702 | * Returns: | 705 | * Returns: |
703 | * Zero on success, error code on failure. | 706 | * Zero on success, error code on failure. |
704 | */ | 707 | */ |
705 | int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, | 708 | int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc, |
706 | const struct drm_crtc_funcs *funcs) | 709 | struct drm_plane *primary, |
710 | void *cursor, | ||
711 | const struct drm_crtc_funcs *funcs) | ||
707 | { | 712 | { |
708 | int ret; | 713 | int ret; |
709 | 714 | ||
@@ -724,12 +729,16 @@ int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, | |||
724 | list_add_tail(&crtc->head, &dev->mode_config.crtc_list); | 729 | list_add_tail(&crtc->head, &dev->mode_config.crtc_list); |
725 | dev->mode_config.num_crtc++; | 730 | dev->mode_config.num_crtc++; |
726 | 731 | ||
732 | crtc->primary = primary; | ||
733 | if (primary) | ||
734 | primary->possible_crtcs = 1 << drm_crtc_index(crtc); | ||
735 | |||
727 | out: | 736 | out: |
728 | drm_modeset_unlock_all(dev); | 737 | drm_modeset_unlock_all(dev); |
729 | 738 | ||
730 | return ret; | 739 | return ret; |
731 | } | 740 | } |
732 | EXPORT_SYMBOL(drm_crtc_init); | 741 | EXPORT_SYMBOL(drm_crtc_init_with_planes); |
733 | 742 | ||
734 | /** | 743 | /** |
735 | * drm_crtc_cleanup - Clean up the core crtc usage | 744 | * drm_crtc_cleanup - Clean up the core crtc usage |
@@ -2219,6 +2228,8 @@ int drm_mode_set_config_internal(struct drm_mode_set *set) | |||
2219 | 2228 | ||
2220 | ret = crtc->funcs->set_config(set); | 2229 | ret = crtc->funcs->set_config(set); |
2221 | if (ret == 0) { | 2230 | if (ret == 0) { |
2231 | crtc->primary->crtc = crtc; | ||
2232 | |||
2222 | /* crtc->fb must be updated by ->set_config, enforces this. */ | 2233 | /* crtc->fb must be updated by ->set_config, enforces this. */ |
2223 | WARN_ON(fb != crtc->fb); | 2234 | WARN_ON(fb != crtc->fb); |
2224 | } | 2235 | } |
diff --git a/drivers/gpu/drm/drm_plane_helper.c b/drivers/gpu/drm/drm_plane_helper.c index 2f2374aba42e..e768d35ff22e 100644 --- a/drivers/gpu/drm/drm_plane_helper.c +++ b/drivers/gpu/drm/drm_plane_helper.c | |||
@@ -310,3 +310,24 @@ struct drm_plane *drm_primary_helper_create_plane(struct drm_device *dev, | |||
310 | } | 310 | } |
311 | EXPORT_SYMBOL(drm_primary_helper_create_plane); | 311 | EXPORT_SYMBOL(drm_primary_helper_create_plane); |
312 | 312 | ||
313 | /** | ||
314 | * drm_crtc_init - Legacy CRTC initialization function | ||
315 | * @dev: DRM device | ||
316 | * @crtc: CRTC object to init | ||
317 | * @funcs: callbacks for the new CRTC | ||
318 | * | ||
319 | * Initialize a CRTC object with a default helper-provided primary plane and no | ||
320 | * cursor plane. | ||
321 | * | ||
322 | * Returns: | ||
323 | * Zero on success, error code on failure. | ||
324 | */ | ||
325 | int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, | ||
326 | const struct drm_crtc_funcs *funcs) | ||
327 | { | ||
328 | struct drm_plane *primary; | ||
329 | |||
330 | primary = drm_primary_helper_create_plane(dev, NULL, 0); | ||
331 | return drm_crtc_init_with_planes(dev, crtc, primary, NULL, funcs); | ||
332 | } | ||
333 | EXPORT_SYMBOL(drm_crtc_init); | ||
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 4c4f792588e9..46790c0de845 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h | |||
@@ -270,6 +270,8 @@ struct drm_crtc_funcs { | |||
270 | * @dev: parent DRM device | 270 | * @dev: parent DRM device |
271 | * @head: list management | 271 | * @head: list management |
272 | * @base: base KMS object for ID tracking etc. | 272 | * @base: base KMS object for ID tracking etc. |
273 | * @primary: primary plane for this CRTC | ||
274 | * @cursor: cursor plane for this CRTC | ||
273 | * @enabled: is this CRTC enabled? | 275 | * @enabled: is this CRTC enabled? |
274 | * @mode: current mode timings | 276 | * @mode: current mode timings |
275 | * @hwmode: mode timings as programmed to hw regs | 277 | * @hwmode: mode timings as programmed to hw regs |
@@ -305,6 +307,10 @@ struct drm_crtc { | |||
305 | 307 | ||
306 | struct drm_mode_object base; | 308 | struct drm_mode_object base; |
307 | 309 | ||
310 | /* primary and cursor planes for CRTC */ | ||
311 | struct drm_plane *primary; | ||
312 | struct drm_plane *cursor; | ||
313 | |||
308 | /* framebuffer the connector is currently bound to */ | 314 | /* framebuffer the connector is currently bound to */ |
309 | struct drm_framebuffer *fb; | 315 | struct drm_framebuffer *fb; |
310 | 316 | ||
@@ -824,6 +830,11 @@ extern void drm_modeset_lock_all(struct drm_device *dev); | |||
824 | extern void drm_modeset_unlock_all(struct drm_device *dev); | 830 | extern void drm_modeset_unlock_all(struct drm_device *dev); |
825 | extern void drm_warn_on_modeset_not_all_locked(struct drm_device *dev); | 831 | extern void drm_warn_on_modeset_not_all_locked(struct drm_device *dev); |
826 | 832 | ||
833 | extern int drm_crtc_init_with_planes(struct drm_device *dev, | ||
834 | struct drm_crtc *crtc, | ||
835 | struct drm_plane *primary, | ||
836 | void *cursor, | ||
837 | const struct drm_crtc_funcs *funcs); | ||
827 | extern int drm_crtc_init(struct drm_device *dev, | 838 | extern int drm_crtc_init(struct drm_device *dev, |
828 | struct drm_crtc *crtc, | 839 | struct drm_crtc *crtc, |
829 | const struct drm_crtc_funcs *funcs); | 840 | const struct drm_crtc_funcs *funcs); |