Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Matt Roper and committed by
Rob Clark
e13161af 9922ab5a

+47 -4
+15 -4
drivers/gpu/drm/drm_crtc.c
··· 692 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 697 * @dev: DRM device 697 698 * @crtc: CRTC object to init 699 + * @primary: Primary plane for CRTC 700 + * @cursor: Cursor plane for CRTC 698 701 * @funcs: callbacks for the new CRTC 699 702 * 700 703 * Inits a new object created as base part of a driver crtc object. ··· 705 702 * Returns: 706 703 * Zero on success, error code on failure. 707 704 */ 708 - int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, 709 - const struct drm_crtc_funcs *funcs) 705 + int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc, 706 + struct drm_plane *primary, 707 + void *cursor, 708 + const struct drm_crtc_funcs *funcs) 710 709 { 711 710 int ret; 712 711 ··· 729 724 list_add_tail(&crtc->head, &dev->mode_config.crtc_list); 730 725 dev->mode_config.num_crtc++; 731 726 727 + crtc->primary = primary; 728 + if (primary) 729 + primary->possible_crtcs = 1 << drm_crtc_index(crtc); 730 + 732 731 out: 733 732 drm_modeset_unlock_all(dev); 734 733 735 734 return ret; 736 735 } 737 - EXPORT_SYMBOL(drm_crtc_init); 736 + EXPORT_SYMBOL(drm_crtc_init_with_planes); 738 737 739 738 /** 740 739 * drm_crtc_cleanup - Clean up the core crtc usage ··· 2228 2219 2229 2220 ret = crtc->funcs->set_config(set); 2230 2221 if (ret == 0) { 2222 + crtc->primary->crtc = crtc; 2223 + 2231 2224 /* crtc->fb must be updated by ->set_config, enforces this. */ 2232 2225 WARN_ON(fb != crtc->fb); 2233 2226 }
+21
drivers/gpu/drm/drm_plane_helper.c
··· 310 310 } 311 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);
+11
include/drm/drm_crtc.h
··· 270 270 * @dev: parent DRM device 271 271 * @head: list management 272 272 * @base: base KMS object for ID tracking etc. 273 + * @primary: primary plane for this CRTC 274 + * @cursor: cursor plane for this CRTC 273 275 * @enabled: is this CRTC enabled? 274 276 * @mode: current mode timings 275 277 * @hwmode: mode timings as programmed to hw regs ··· 306 304 struct mutex mutex; 307 305 308 306 struct drm_mode_object base; 307 + 308 + /* primary and cursor planes for CRTC */ 309 + struct drm_plane *primary; 310 + struct drm_plane *cursor; 309 311 310 312 /* framebuffer the connector is currently bound to */ 311 313 struct drm_framebuffer *fb; ··· 830 824 extern void drm_modeset_unlock_all(struct drm_device *dev); 831 825 extern void drm_warn_on_modeset_not_all_locked(struct drm_device *dev); 832 826 827 + extern int drm_crtc_init_with_planes(struct drm_device *dev, 828 + struct drm_crtc *crtc, 829 + struct drm_plane *primary, 830 + void *cursor, 831 + const struct drm_crtc_funcs *funcs); 833 832 extern int drm_crtc_init(struct drm_device *dev, 834 833 struct drm_crtc *crtc, 835 834 const struct drm_crtc_funcs *funcs);