Skip to content

Commit 681e7ec

Browse files
mattroperobclark
authored andcommitted
drm: Allow userspace to ask for universal plane list (v2)
Userspace clients which wish to receive all DRM planes (primary and cursor planes in addition to the traditional overlay planes) may set the DRM_CLIENT_CAP_UNIVERSAL_PLANES capability. v2: Hide behind drm.universal_planes module option [suggested by Daniel Vetter] Signed-off-by: Matt Roper <matthew.d.roper@intel.com> Reviewed-by: Rob Clark <robdclark@gmail.com>
1 parent 780f598 commit 681e7ec

File tree

5 files changed

+41
-5
lines changed

5 files changed

+41
-5
lines changed

drivers/gpu/drm/drm_crtc.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,24 +1959,34 @@ int drm_mode_getplane_res(struct drm_device *dev, void *data,
19591959
struct drm_plane *plane;
19601960
uint32_t __user *plane_ptr;
19611961
int copied = 0, ret = 0;
1962+
unsigned num_planes;
19621963

19631964
if (!drm_core_check_feature(dev, DRIVER_MODESET))
19641965
return -EINVAL;
19651966

19661967
drm_modeset_lock_all(dev);
19671968
config = &dev->mode_config;
19681969

1970+
if (file_priv->universal_planes)
1971+
num_planes = config->num_total_plane;
1972+
else
1973+
num_planes = config->num_overlay_plane;
1974+
19691975
/*
19701976
* This ioctl is called twice, once to determine how much space is
19711977
* needed, and the 2nd time to fill it.
19721978
*/
1973-
if (config->num_overlay_plane &&
1974-
(plane_resp->count_planes >= config->num_overlay_plane)) {
1979+
if (num_planes &&
1980+
(plane_resp->count_planes >= num_planes)) {
19751981
plane_ptr = (uint32_t __user *)(unsigned long)plane_resp->plane_id_ptr;
19761982

19771983
list_for_each_entry(plane, &config->plane_list, head) {
1978-
/* Only advertise overlays to userspace for now. */
1979-
if (plane->type != DRM_PLANE_TYPE_OVERLAY)
1984+
/*
1985+
* Unless userspace set the 'universal planes'
1986+
* capability bit, only advertise overlays.
1987+
*/
1988+
if (plane->type != DRM_PLANE_TYPE_OVERLAY &&
1989+
!file_priv->universal_planes)
19801990
continue;
19811991

19821992
if (put_user(plane->base.id, plane_ptr + copied)) {
@@ -1986,7 +1996,7 @@ int drm_mode_getplane_res(struct drm_device *dev, void *data,
19861996
copied++;
19871997
}
19881998
}
1989-
plane_resp->count_planes = config->num_overlay_plane;
1999+
plane_resp->count_planes = num_planes;
19902000

19912001
out:
19922002
drm_modeset_unlock_all(dev);

drivers/gpu/drm/drm_ioctl.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,13 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv)
328328
return -EINVAL;
329329
file_priv->stereo_allowed = req->value;
330330
break;
331+
case DRM_CLIENT_CAP_UNIVERSAL_PLANES:
332+
if (!drm_universal_planes)
333+
return -EINVAL;
334+
if (req->value > 1)
335+
return -EINVAL;
336+
file_priv->universal_planes = req->value;
337+
break;
331338
default:
332339
return -EINVAL;
333340
}

drivers/gpu/drm/drm_stub.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ EXPORT_SYMBOL(drm_debug);
4545
unsigned int drm_rnodes = 0; /* 1 to enable experimental render nodes API */
4646
EXPORT_SYMBOL(drm_rnodes);
4747

48+
/* 1 to allow user space to request universal planes (experimental) */
49+
unsigned int drm_universal_planes = 0;
50+
EXPORT_SYMBOL(drm_universal_planes);
51+
4852
unsigned int drm_vblank_offdelay = 5000; /* Default to 5000 msecs. */
4953
EXPORT_SYMBOL(drm_vblank_offdelay);
5054

@@ -68,6 +72,7 @@ MODULE_PARM_DESC(timestamp_monotonic, "Use monotonic timestamps");
6872

6973
module_param_named(debug, drm_debug, int, 0600);
7074
module_param_named(rnodes, drm_rnodes, int, 0600);
75+
module_param_named(universal_planes, drm_universal_planes, int, 0600);
7176
module_param_named(vblankoffdelay, drm_vblank_offdelay, int, 0600);
7277
module_param_named(timestamp_precision_usec, drm_timestamp_precision, int, 0600);
7378
module_param_named(timestamp_monotonic, drm_timestamp_monotonic, int, 0600);

include/drm/drmP.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,11 @@ struct drm_file {
409409
unsigned is_master :1;
410410
/* true when the client has asked us to expose stereo 3D mode flags */
411411
unsigned stereo_allowed :1;
412+
/*
413+
* true if client understands CRTC primary planes and cursor planes
414+
* in the plane list
415+
*/
416+
unsigned universal_planes:1;
412417

413418
struct pid *pid;
414419
kuid_t uid;
@@ -1409,6 +1414,7 @@ extern void drm_put_dev(struct drm_device *dev);
14091414
extern void drm_unplug_dev(struct drm_device *dev);
14101415
extern unsigned int drm_debug;
14111416
extern unsigned int drm_rnodes;
1417+
extern unsigned int drm_universal_planes;
14121418

14131419
extern unsigned int drm_vblank_offdelay;
14141420
extern unsigned int drm_timestamp_precision;

include/uapi/drm/drm.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,14 @@ struct drm_get_cap {
637637
*/
638638
#define DRM_CLIENT_CAP_STEREO_3D 1
639639

640+
/**
641+
* DRM_CLIENT_CAP_UNIVERSAL_PLANES
642+
*
643+
* If set to 1, the DRM core will expose all planes (overlay, primary, and
644+
* cursor) to userspace.
645+
*/
646+
#define DRM_CLIENT_CAP_UNIVERSAL_PLANES 2
647+
640648
/** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
641649
struct drm_set_client_cap {
642650
__u64 capability;

0 commit comments

Comments
 (0)