summaryrefslogtreecommitdiffstats
path: root/include/drm
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2020-12-10 16:38:28 +0100
committerPhilipp Zabel <p.zabel@pengutronix.de>2021-01-04 12:59:33 +0100
commitca5092d04d86986c03b6e0042e2f1cd119c50f5d (patch)
treed57afe50a2e83282754e87521510c20324521690 /include/drm
parentf35a2a99100fbed583efaf07919ef071cd75b059 (diff)
downloadlinux-stable-ca5092d04d86986c03b6e0042e2f1cd119c50f5d.tar.gz
linux-stable-ca5092d04d86986c03b6e0042e2f1cd119c50f5d.tar.bz2
linux-stable-ca5092d04d86986c03b6e0042e2f1cd119c50f5d.zip
drm: add drmm_encoder_alloc()
Add an alternative to drm_encoder_init() that allocates and initializes an encoder and registers drm_encoder_cleanup() with drmm_add_action_or_reset(). Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'include/drm')
-rw-r--r--include/drm/drm_encoder.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/include/drm/drm_encoder.h b/include/drm/drm_encoder.h
index 833123637fbf..5bf78b5bcb2b 100644
--- a/include/drm/drm_encoder.h
+++ b/include/drm/drm_encoder.h
@@ -194,6 +194,36 @@ int drm_encoder_init(struct drm_device *dev,
const struct drm_encoder_funcs *funcs,
int encoder_type, const char *name, ...);
+__printf(6, 7)
+void *__drmm_encoder_alloc(struct drm_device *dev,
+ size_t size, size_t offset,
+ const struct drm_encoder_funcs *funcs,
+ int encoder_type,
+ const char *name, ...);
+
+/**
+ * drmm_encoder_alloc - Allocate and initialize an encoder
+ * @dev: drm device
+ * @type: the type of the struct which contains struct &drm_encoder
+ * @member: the name of the &drm_encoder within @type
+ * @funcs: callbacks for this encoder (optional)
+ * @encoder_type: user visible type of the encoder
+ * @name: printf style format string for the encoder name, or NULL for default name
+ *
+ * Allocates and initializes an encoder. Encoder should be subclassed as part of
+ * driver encoder objects. Cleanup is automatically handled through registering
+ * drm_encoder_cleanup() with drmm_add_action().
+ *
+ * The @drm_encoder_funcs.destroy hook must be NULL.
+ *
+ * Returns:
+ * Pointer to new encoder, or ERR_PTR on failure.
+ */
+#define drmm_encoder_alloc(dev, type, member, funcs, encoder_type, name, ...) \
+ ((type *)__drmm_encoder_alloc(dev, sizeof(type), \
+ offsetof(type, member), funcs, \
+ encoder_type, name, ##__VA_ARGS__))
+
/**
* drm_encoder_index - find the index of a registered encoder
* @encoder: encoder to find index for