Commit e27dde3e authored by Matt Roper's avatar Matt Roper Committed by Rob Clark

drm: Add support for multiple plane types (v2)

The DRM core currently only tracks "overlay"-style planes.  Start
refactoring the plane handling to allow other plane types (primary and
cursor) to also be placed on the DRM plane list.

v2: Add drm_for_each_legacy_plane() iterator to smooth transition
    of drivers with plane loops.
Signed-off-by: default avatarMatt Roper <matthew.d.roper@intel.com>
Reviewed-by: default avatarRob Clark <robdclark@gmail.com>
parent c32fc9c8
...@@ -1044,6 +1044,7 @@ int drm_plane_init(struct drm_device *dev, struct drm_plane *plane, ...@@ -1044,6 +1044,7 @@ int drm_plane_init(struct drm_device *dev, struct drm_plane *plane,
memcpy(plane->format_types, formats, format_count * sizeof(uint32_t)); memcpy(plane->format_types, formats, format_count * sizeof(uint32_t));
plane->format_count = format_count; plane->format_count = format_count;
plane->possible_crtcs = possible_crtcs; plane->possible_crtcs = possible_crtcs;
plane->type = DRM_PLANE_TYPE_OVERLAY;
/* private planes are not exposed to userspace, but depending on /* private planes are not exposed to userspace, but depending on
* display hardware, might be convenient to allow sharing programming * display hardware, might be convenient to allow sharing programming
...@@ -1051,7 +1052,9 @@ int drm_plane_init(struct drm_device *dev, struct drm_plane *plane, ...@@ -1051,7 +1052,9 @@ int drm_plane_init(struct drm_device *dev, struct drm_plane *plane,
*/ */
if (!priv) { if (!priv) {
list_add_tail(&plane->head, &dev->mode_config.plane_list); list_add_tail(&plane->head, &dev->mode_config.plane_list);
dev->mode_config.num_plane++; dev->mode_config.num_total_plane++;
if (plane->type == DRM_PLANE_TYPE_OVERLAY)
dev->mode_config.num_overlay_plane++;
} else { } else {
INIT_LIST_HEAD(&plane->head); INIT_LIST_HEAD(&plane->head);
} }
...@@ -1081,7 +1084,9 @@ void drm_plane_cleanup(struct drm_plane *plane) ...@@ -1081,7 +1084,9 @@ void drm_plane_cleanup(struct drm_plane *plane)
/* if not added to a list, it must be a private plane */ /* if not added to a list, it must be a private plane */
if (!list_empty(&plane->head)) { if (!list_empty(&plane->head)) {
list_del(&plane->head); list_del(&plane->head);
dev->mode_config.num_plane--; dev->mode_config.num_total_plane--;
if (plane->type == DRM_PLANE_TYPE_OVERLAY)
dev->mode_config.num_overlay_plane--;
} }
drm_modeset_unlock_all(dev); drm_modeset_unlock_all(dev);
} }
...@@ -1908,11 +1913,15 @@ int drm_mode_getplane_res(struct drm_device *dev, void *data, ...@@ -1908,11 +1913,15 @@ int drm_mode_getplane_res(struct drm_device *dev, void *data,
* This ioctl is called twice, once to determine how much space is * This ioctl is called twice, once to determine how much space is
* needed, and the 2nd time to fill it. * needed, and the 2nd time to fill it.
*/ */
if (config->num_plane && if (config->num_overlay_plane &&
(plane_resp->count_planes >= config->num_plane)) { (plane_resp->count_planes >= config->num_overlay_plane)) {
plane_ptr = (uint32_t __user *)(unsigned long)plane_resp->plane_id_ptr; plane_ptr = (uint32_t __user *)(unsigned long)plane_resp->plane_id_ptr;
list_for_each_entry(plane, &config->plane_list, head) { list_for_each_entry(plane, &config->plane_list, head) {
/* Only advertise overlays to userspace for now. */
if (plane->type != DRM_PLANE_TYPE_OVERLAY)
continue;
if (put_user(plane->base.id, plane_ptr + copied)) { if (put_user(plane->base.id, plane_ptr + copied)) {
ret = -EFAULT; ret = -EFAULT;
goto out; goto out;
...@@ -1920,7 +1929,7 @@ int drm_mode_getplane_res(struct drm_device *dev, void *data, ...@@ -1920,7 +1929,7 @@ int drm_mode_getplane_res(struct drm_device *dev, void *data,
copied++; copied++;
} }
} }
plane_resp->count_planes = config->num_plane; plane_resp->count_planes = config->num_overlay_plane;
out: out:
drm_modeset_unlock_all(dev); drm_modeset_unlock_all(dev);
...@@ -4534,6 +4543,8 @@ void drm_mode_config_init(struct drm_device *dev) ...@@ -4534,6 +4543,8 @@ void drm_mode_config_init(struct drm_device *dev)
dev->mode_config.num_connector = 0; dev->mode_config.num_connector = 0;
dev->mode_config.num_crtc = 0; dev->mode_config.num_crtc = 0;
dev->mode_config.num_encoder = 0; dev->mode_config.num_encoder = 0;
dev->mode_config.num_overlay_plane = 0;
dev->mode_config.num_total_plane = 0;
} }
EXPORT_SYMBOL(drm_mode_config_init); EXPORT_SYMBOL(drm_mode_config_init);
......
...@@ -291,6 +291,7 @@ bool drm_fb_helper_restore_fbdev_mode(struct drm_fb_helper *fb_helper) ...@@ -291,6 +291,7 @@ bool drm_fb_helper_restore_fbdev_mode(struct drm_fb_helper *fb_helper)
drm_warn_on_modeset_not_all_locked(dev); drm_warn_on_modeset_not_all_locked(dev);
list_for_each_entry(plane, &dev->mode_config.plane_list, head) list_for_each_entry(plane, &dev->mode_config.plane_list, head)
if (plane->type != DRM_PLANE_TYPE_PRIMARY)
drm_plane_force_disable(plane); drm_plane_force_disable(plane);
for (i = 0; i < fb_helper->crtc_count; i++) { for (i = 0; i < fb_helper->crtc_count; i++) {
......
...@@ -541,6 +541,12 @@ struct drm_plane_funcs { ...@@ -541,6 +541,12 @@ struct drm_plane_funcs {
struct drm_property *property, uint64_t val); struct drm_property *property, uint64_t val);
}; };
enum drm_plane_type {
DRM_PLANE_TYPE_OVERLAY,
DRM_PLANE_TYPE_PRIMARY,
DRM_PLANE_TYPE_CURSOR,
};
/** /**
* drm_plane - central DRM plane control structure * drm_plane - central DRM plane control structure
* @dev: DRM device this plane belongs to * @dev: DRM device this plane belongs to
...@@ -553,6 +559,7 @@ struct drm_plane_funcs { ...@@ -553,6 +559,7 @@ struct drm_plane_funcs {
* @fb: currently bound fb * @fb: currently bound fb
* @funcs: helper functions * @funcs: helper functions
* @properties: property tracking for this plane * @properties: property tracking for this plane
* @type: type of plane (overlay, primary, cursor)
*/ */
struct drm_plane { struct drm_plane {
struct drm_device *dev; struct drm_device *dev;
...@@ -570,6 +577,8 @@ struct drm_plane { ...@@ -570,6 +577,8 @@ struct drm_plane {
const struct drm_plane_funcs *funcs; const struct drm_plane_funcs *funcs;
struct drm_object_properties properties; struct drm_object_properties properties;
enum drm_plane_type type;
}; };
/** /**
...@@ -732,7 +741,15 @@ struct drm_mode_config { ...@@ -732,7 +741,15 @@ struct drm_mode_config {
struct list_head bridge_list; struct list_head bridge_list;
int num_encoder; int num_encoder;
struct list_head encoder_list; struct list_head encoder_list;
int num_plane;
/*
* Track # of overlay planes separately from # of total planes. By
* default we only advertise overlay planes to userspace; if userspace
* sets the "universal plane" capability bit, we'll go ahead and
* expose all planes.
*/
int num_overlay_plane;
int num_total_plane;
struct list_head plane_list; struct list_head plane_list;
int num_crtc; int num_crtc;
...@@ -1036,4 +1053,9 @@ static inline struct drm_encoder *drm_encoder_find(struct drm_device *dev, ...@@ -1036,4 +1053,9 @@ static inline struct drm_encoder *drm_encoder_find(struct drm_device *dev,
return mo ? obj_to_encoder(mo) : NULL; return mo ? obj_to_encoder(mo) : NULL;
} }
/* Plane list iterator for legacy (overlay only) planes. */
#define drm_for_each_legacy_plane(plane, planelist) \
list_for_each_entry(plane, planelist, head) \
if (plane->type == DRM_PLANE_TYPE_OVERLAY)
#endif /* __DRM_CRTC_H__ */ #endif /* __DRM_CRTC_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment