aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorMatt Roper <matthew.d.roper@intel.com>2014-04-01 18:22:36 -0400
committerRob Clark <robdclark@gmail.com>2014-04-01 20:18:08 -0400
commitdc415ff97d6b8f21cc6d264962f3a857a8d44650 (patch)
tree411cf00bd18ea38d52f58a1db867cef8b89e8424 /drivers/gpu/drm
parentc103d1cfb3543f61ec44d4d15a84c888db84794d (diff)
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>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/drm_crtc.c80
1 files changed, 51 insertions, 29 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 99e6b229bb38..60b903bdf528 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -1000,26 +1000,25 @@ void drm_encoder_cleanup(struct drm_encoder *encoder)
1000EXPORT_SYMBOL(drm_encoder_cleanup); 1000EXPORT_SYMBOL(drm_encoder_cleanup);
1001 1001
1002/** 1002/**
1003 * drm_plane_init - Initialise a new plane object 1003 * drm_universal_plane_init - Initialize a new universal plane object
1004 * @dev: DRM device 1004 * @dev: DRM device
1005 * @plane: plane object to init 1005 * @plane: plane object to init
1006 * @possible_crtcs: bitmask of possible CRTCs 1006 * @possible_crtcs: bitmask of possible CRTCs
1007 * @funcs: callbacks for the new plane 1007 * @funcs: callbacks for the new plane
1008 * @formats: array of supported formats (%DRM_FORMAT_*) 1008 * @formats: array of supported formats (%DRM_FORMAT_*)
1009 * @format_count: number of elements in @formats 1009 * @format_count: number of elements in @formats
1010 * @priv: plane is private (hidden from userspace)? 1010 * @type: type of plane (overlay, primary, cursor)
1011 * 1011 *
1012 * Inits a preallocate plane object created as base part of a driver plane 1012 * Initializes a plane object of type @type.
1013 * object.
1014 * 1013 *
1015 * Returns: 1014 * Returns:
1016 * Zero on success, error code on failure. 1015 * Zero on success, error code on failure.
1017 */ 1016 */
1018int drm_plane_init(struct drm_device *dev, struct drm_plane *plane, 1017int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane,
1019 unsigned long possible_crtcs, 1018 unsigned long possible_crtcs,
1020 const struct drm_plane_funcs *funcs, 1019 const struct drm_plane_funcs *funcs,
1021 const uint32_t *formats, uint32_t format_count, 1020 const uint32_t *formats, uint32_t format_count,
1022 bool priv) 1021 enum drm_plane_type type)
1023{ 1022{
1024 int ret; 1023 int ret;
1025 1024
@@ -1044,26 +1043,49 @@ int drm_plane_init(struct drm_device *dev, struct drm_plane *plane,
1044 memcpy(plane->format_types, formats, format_count * sizeof(uint32_t)); 1043 memcpy(plane->format_types, formats, format_count * sizeof(uint32_t));
1045 plane->format_count = format_count; 1044 plane->format_count = format_count;
1046 plane->possible_crtcs = possible_crtcs; 1045 plane->possible_crtcs = possible_crtcs;
1047 plane->type = DRM_PLANE_TYPE_OVERLAY; 1046 plane->type = type;
1048 1047
1049 /* private planes are not exposed to userspace, but depending on 1048 list_add_tail(&plane->head, &dev->mode_config.plane_list);
1050 * display hardware, might be convenient to allow sharing programming 1049 dev->mode_config.num_total_plane++;
1051 * for the scanout engine with the crtc implementation. 1050 if (plane->type == DRM_PLANE_TYPE_OVERLAY)
1052 */ 1051 dev->mode_config.num_overlay_plane++;
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 }
1061 1052
1062 out: 1053 out:
1063 drm_modeset_unlock_all(dev); 1054 drm_modeset_unlock_all(dev);
1064 1055
1065 return ret; 1056 return ret;
1066} 1057}
1058EXPORT_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 */
1077int 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}
1067EXPORT_SYMBOL(drm_plane_init); 1089EXPORT_SYMBOL(drm_plane_init);
1068 1090
1069/** 1091/**
@@ -1081,13 +1103,13 @@ void drm_plane_cleanup(struct drm_plane *plane)
1081 drm_modeset_lock_all(dev); 1103 drm_modeset_lock_all(dev);
1082 kfree(plane->format_types); 1104 kfree(plane->format_types);
1083 drm_mode_object_put(dev, &plane->base); 1105 drm_mode_object_put(dev, &plane->base);
1084 /* if not added to a list, it must be a private plane */ 1106
1085 if (!list_empty(&plane->head)) { 1107 BUG_ON(list_empty(&plane->head));
1086 list_del(&plane->head); 1108
1087 dev->mode_config.num_total_plane--; 1109 list_del(&plane->head);
1088 if (plane->type == DRM_PLANE_TYPE_OVERLAY) 1110 dev->mode_config.num_total_plane--;
1089 dev->mode_config.num_overlay_plane--; 1111 if (plane->type == DRM_PLANE_TYPE_OVERLAY)
1090 } 1112 dev->mode_config.num_overlay_plane--;
1091 drm_modeset_unlock_all(dev); 1113 drm_modeset_unlock_all(dev);
1092} 1114}
1093EXPORT_SYMBOL(drm_plane_cleanup); 1115EXPORT_SYMBOL(drm_plane_cleanup);