Skip to content

Commit dc415ff

Browse files
mattroperobclark
authored andcommitted
drm: Add drm_universal_plane_init()
Add a new plane initialization interface for universal plane support that allows a specific plane type (primary, cursor, or overlay) to be specified. drm_plane_init() remains as a compatibility API to reduce churn in existing drivers. The 'bool priv' parameter has been changed to 'bool is_primary' under the assumption that all existing uses of private planes were representing primary planes. Signed-off-by: Matt Roper <matthew.d.roper@intel.com> Reviewed-by: Rob Clark <robdclark@gmail.com>
1 parent c103d1c commit dc415ff

File tree

2 files changed

+59
-30
lines changed

2 files changed

+59
-30
lines changed

drivers/gpu/drm/drm_crtc.c

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,26 +1000,25 @@ void drm_encoder_cleanup(struct drm_encoder *encoder)
10001000
EXPORT_SYMBOL(drm_encoder_cleanup);
10011001

10021002
/**
1003-
* drm_plane_init - Initialise a new plane object
1003+
* drm_universal_plane_init - Initialize a new universal plane object
10041004
* @dev: DRM device
10051005
* @plane: plane object to init
10061006
* @possible_crtcs: bitmask of possible CRTCs
10071007
* @funcs: callbacks for the new plane
10081008
* @formats: array of supported formats (%DRM_FORMAT_*)
10091009
* @format_count: number of elements in @formats
1010-
* @priv: plane is private (hidden from userspace)?
1010+
* @type: type of plane (overlay, primary, cursor)
10111011
*
1012-
* Inits a preallocate plane object created as base part of a driver plane
1013-
* object.
1012+
* Initializes a plane object of type @type.
10141013
*
10151014
* Returns:
10161015
* Zero on success, error code on failure.
10171016
*/
1018-
int drm_plane_init(struct drm_device *dev, struct drm_plane *plane,
1019-
unsigned long possible_crtcs,
1020-
const struct drm_plane_funcs *funcs,
1021-
const uint32_t *formats, uint32_t format_count,
1022-
bool priv)
1017+
int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane,
1018+
unsigned long possible_crtcs,
1019+
const struct drm_plane_funcs *funcs,
1020+
const uint32_t *formats, uint32_t format_count,
1021+
enum drm_plane_type type)
10231022
{
10241023
int ret;
10251024

@@ -1044,26 +1043,49 @@ int drm_plane_init(struct drm_device *dev, struct drm_plane *plane,
10441043
memcpy(plane->format_types, formats, format_count * sizeof(uint32_t));
10451044
plane->format_count = format_count;
10461045
plane->possible_crtcs = possible_crtcs;
1047-
plane->type = DRM_PLANE_TYPE_OVERLAY;
1046+
plane->type = type;
10481047

1049-
/* private planes are not exposed to userspace, but depending on
1050-
* display hardware, might be convenient to allow sharing programming
1051-
* for the scanout engine with the crtc implementation.
1052-
*/
1053-
if (!priv) {
1054-
list_add_tail(&plane->head, &dev->mode_config.plane_list);
1055-
dev->mode_config.num_total_plane++;
1056-
if (plane->type == DRM_PLANE_TYPE_OVERLAY)
1057-
dev->mode_config.num_overlay_plane++;
1058-
} else {
1059-
INIT_LIST_HEAD(&plane->head);
1060-
}
1048+
list_add_tail(&plane->head, &dev->mode_config.plane_list);
1049+
dev->mode_config.num_total_plane++;
1050+
if (plane->type == DRM_PLANE_TYPE_OVERLAY)
1051+
dev->mode_config.num_overlay_plane++;
10611052

10621053
out:
10631054
drm_modeset_unlock_all(dev);
10641055

10651056
return ret;
10661057
}
1058+
EXPORT_SYMBOL(drm_universal_plane_init);
1059+
1060+
/**
1061+
* drm_plane_init - Initialize a legacy plane
1062+
* @dev: DRM device
1063+
* @plane: plane object to init
1064+
* @possible_crtcs: bitmask of possible CRTCs
1065+
* @funcs: callbacks for the new plane
1066+
* @formats: array of supported formats (%DRM_FORMAT_*)
1067+
* @format_count: number of elements in @formats
1068+
* @is_primary: plane type (primary vs overlay)
1069+
*
1070+
* Legacy API to initialize a DRM plane.
1071+
*
1072+
* New drivers should call drm_universal_plane_init() instead.
1073+
*
1074+
* Returns:
1075+
* Zero on success, error code on failure.
1076+
*/
1077+
int drm_plane_init(struct drm_device *dev, struct drm_plane *plane,
1078+
unsigned long possible_crtcs,
1079+
const struct drm_plane_funcs *funcs,
1080+
const uint32_t *formats, uint32_t format_count,
1081+
bool is_primary)
1082+
{
1083+
enum drm_plane_type type;
1084+
1085+
type = is_primary ? DRM_PLANE_TYPE_PRIMARY : DRM_PLANE_TYPE_OVERLAY;
1086+
return drm_universal_plane_init(dev, plane, possible_crtcs, funcs,
1087+
formats, format_count, type);
1088+
}
10671089
EXPORT_SYMBOL(drm_plane_init);
10681090

10691091
/**
@@ -1081,13 +1103,13 @@ void drm_plane_cleanup(struct drm_plane *plane)
10811103
drm_modeset_lock_all(dev);
10821104
kfree(plane->format_types);
10831105
drm_mode_object_put(dev, &plane->base);
1084-
/* if not added to a list, it must be a private plane */
1085-
if (!list_empty(&plane->head)) {
1086-
list_del(&plane->head);
1087-
dev->mode_config.num_total_plane--;
1088-
if (plane->type == DRM_PLANE_TYPE_OVERLAY)
1089-
dev->mode_config.num_overlay_plane--;
1090-
}
1106+
1107+
BUG_ON(list_empty(&plane->head));
1108+
1109+
list_del(&plane->head);
1110+
dev->mode_config.num_total_plane--;
1111+
if (plane->type == DRM_PLANE_TYPE_OVERLAY)
1112+
dev->mode_config.num_overlay_plane--;
10911113
drm_modeset_unlock_all(dev);
10921114
}
10931115
EXPORT_SYMBOL(drm_plane_cleanup);

include/drm/drm_crtc.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,12 +874,19 @@ static inline bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
874874
return !!(encoder->possible_crtcs & drm_crtc_mask(crtc));
875875
}
876876

877+
extern int drm_universal_plane_init(struct drm_device *dev,
878+
struct drm_plane *plane,
879+
unsigned long possible_crtcs,
880+
const struct drm_plane_funcs *funcs,
881+
const uint32_t *formats,
882+
uint32_t format_count,
883+
enum drm_plane_type type);
877884
extern int drm_plane_init(struct drm_device *dev,
878885
struct drm_plane *plane,
879886
unsigned long possible_crtcs,
880887
const struct drm_plane_funcs *funcs,
881888
const uint32_t *formats, uint32_t format_count,
882-
bool priv);
889+
bool is_primary);
883890
extern void drm_plane_cleanup(struct drm_plane *plane);
884891
extern void drm_plane_force_disable(struct drm_plane *plane);
885892
extern int drm_crtc_check_viewport(const struct drm_crtc *crtc,

0 commit comments

Comments
 (0)