]> git.baikalelectronics.ru Git - kernel.git/commitdiff
Merge tag 'imx-drm-next-2021-01-04' of git://git.pengutronix.de/git/pza/linux into...
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 7 Jan 2021 10:23:38 +0000 (11:23 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 7 Jan 2021 10:24:50 +0000 (11:24 +0100)
drm/imx: fixes and drm managed resources

- Reduce stack usage in ipu-di.
- Fix imx-ldb for compile tests.
- Make drm encoder control functions optional.
- Add drm managed variants drmm_encoder_alloc(),
  drmm_simple_encoder_alloc(), drmm_universal_plane_alloc(), and
  drmm_crtc_alloc_with_planes() for drm_encoder_init(),
  drm_simple_encoder_init(), drm_universal_plane_init(), and
  drm_crtc_init_with_planes(), respectively.
- Update imx-drm to use the new functions for drm managed resource
  allocation, moving initialization from bind to probe where possible.
- Fix imx-tve clock provider leak.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
[danvet: Fix conflict between doc changes by both Philipp and Simon
Ser, see 9999587b684f ("drm: rework description of primary and cursor
planes")]
From: Philipp Zabel <p.zabel@pengutronix.de>
Link: https://patchwork.freedesktop.org/patch/msgid/c745fc1596898932c9454fd2979297b4242566a2.camel@pengutronix.de
1  2 
drivers/gpu/drm/drm_crtc.c
drivers/gpu/drm/drm_mode_config.c
drivers/gpu/drm/drm_plane.c

index a6336c7154d67b54bb9294d2658614672e3c9ec0,7e02555009ff557a6d226e230a477a2f8f1ea92e..9c4f9947b194fcaf954ada858b73a41fd680ea15
@@@ -342,8 -318,98 +318,101 @@@ static int __drm_crtc_init_with_planes(
  
        return 0;
  }
+ /**
+  * drm_crtc_init_with_planes - Initialise a new CRTC object with
+  *    specified primary and cursor planes.
+  * @dev: DRM device
+  * @crtc: CRTC object to init
+  * @primary: Primary plane for CRTC
+  * @cursor: Cursor plane for CRTC
+  * @funcs: callbacks for the new CRTC
+  * @name: printf style format string for the CRTC name, or NULL for default name
+  *
+  * Inits a new object created as base part of a driver crtc object. Drivers
+  * should use this function instead of drm_crtc_init(), which is only provided
+  * for backwards compatibility with drivers which do not yet support universal
+  * planes). For really simple hardware which has only 1 plane look at
+  * drm_simple_display_pipe_init() instead.
+  * The &drm_crtc_funcs.destroy hook should call drm_crtc_cleanup() and kfree()
+  * the crtc structure. The crtc structure should not be allocated with
+  * devm_kzalloc().
+  *
++ * The @primary and @cursor planes are only relevant for legacy uAPI, see
++ * &drm_crtc.primary and &drm_crtc.cursor.
++ *
+  * Note: consider using drmm_crtc_alloc_with_planes() instead of
+  * drm_crtc_init_with_planes() to let the DRM managed resource infrastructure
+  * take care of cleanup and deallocation.
+  *
+  * Returns:
+  * Zero on success, error code on failure.
+  */
+ int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc,
+                             struct drm_plane *primary,
+                             struct drm_plane *cursor,
+                             const struct drm_crtc_funcs *funcs,
+                             const char *name, ...)
+ {
+       va_list ap;
+       int ret;
+       WARN_ON(!funcs->destroy);
+       va_start(ap, name);
+       ret = __drm_crtc_init_with_planes(dev, crtc, primary, cursor, funcs,
+                                         name, ap);
+       va_end(ap);
+       return ret;
+ }
  EXPORT_SYMBOL(drm_crtc_init_with_planes);
  
+ static void drmm_crtc_alloc_with_planes_cleanup(struct drm_device *dev,
+                                               void *ptr)
+ {
+       struct drm_crtc *crtc = ptr;
+       drm_crtc_cleanup(crtc);
+ }
+ void *__drmm_crtc_alloc_with_planes(struct drm_device *dev,
+                                   size_t size, size_t offset,
+                                   struct drm_plane *primary,
+                                   struct drm_plane *cursor,
+                                   const struct drm_crtc_funcs *funcs,
+                                   const char *name, ...)
+ {
+       void *container;
+       struct drm_crtc *crtc;
+       va_list ap;
+       int ret;
+       if (WARN_ON(!funcs || funcs->destroy))
+               return ERR_PTR(-EINVAL);
+       container = drmm_kzalloc(dev, size, GFP_KERNEL);
+       if (!container)
+               return ERR_PTR(-ENOMEM);
+       crtc = container + offset;
+       va_start(ap, name);
+       ret = __drm_crtc_init_with_planes(dev, crtc, primary, cursor, funcs,
+                                         name, ap);
+       va_end(ap);
+       if (ret)
+               return ERR_PTR(ret);
+       ret = drmm_add_action_or_reset(dev, drmm_crtc_alloc_with_planes_cleanup,
+                                      crtc);
+       if (ret)
+               return ERR_PTR(ret);
+       return container;
+ }
+ EXPORT_SYMBOL(__drmm_crtc_alloc_with_planes);
  /**
   * drm_crtc_cleanup - Clean up the core crtc usage
   * @crtc: CRTC to cleanup
Simple merge
Simple merge