Skip to content

Commit d67b6a2

Browse files
committed
drm: writeback: Add client capability for exposing writeback connectors
Due to the fact that writeback connectors behave in a special way in DRM (they always report being disconnected) we might confuse some userspace. Add a client capability for writeback connectors that will filter them out for clients that don't understand the capability. Changelog: - only accept the capability if the client has already set the DRM_CLIENT_CAP_ATOMIC one. Cc: Sean Paul <[email protected]> Cc: Brian Starkey <[email protected]> Signed-off-by: Liviu Dudau <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Brian Starkey <[email protected]> Link: https://patchwork.freedesktop.org/patch/229038/
1 parent b13cc8d commit d67b6a2

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

drivers/gpu/drm/drm_ioctl.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,13 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv)
334334
return -EINVAL;
335335
file_priv->aspect_ratio_allowed = req->value;
336336
break;
337+
case DRM_CLIENT_CAP_WRITEBACK_CONNECTORS:
338+
if (!file_priv->atomic)
339+
return -EINVAL;
340+
if (req->value > 1)
341+
return -EINVAL;
342+
file_priv->writeback_connectors = req->value;
343+
break;
337344
default:
338345
return -EINVAL;
339346
}

drivers/gpu/drm/drm_mode_config.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ int drm_mode_getresources(struct drm_device *dev, void *data,
145145
count = 0;
146146
connector_id = u64_to_user_ptr(card_res->connector_id_ptr);
147147
drm_for_each_connector_iter(connector, &conn_iter) {
148+
/* only expose writeback connectors if userspace understands them */
149+
if (!file_priv->writeback_connectors &&
150+
(connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK))
151+
continue;
152+
148153
if (drm_lease_held(file_priv, connector->base.id)) {
149154
if (count < card_res->count_connectors &&
150155
put_user(connector->base.id, connector_id + count)) {

include/drm/drm_file.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,13 @@ struct drm_file {
192192
*/
193193
unsigned aspect_ratio_allowed:1;
194194

195+
/**
196+
* @writeback_connectors:
197+
*
198+
* True if client understands writeback connectors
199+
*/
200+
unsigned writeback_connectors:1;
201+
195202
/**
196203
* @is_master:
197204
*

include/uapi/drm/drm.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,15 @@ struct drm_get_cap {
687687
*/
688688
#define DRM_CLIENT_CAP_ASPECT_RATIO 4
689689

690+
/**
691+
* DRM_CLIENT_CAP_WRITEBACK_CONNECTORS
692+
*
693+
* If set to 1, the DRM core will expose special connectors to be used for
694+
* writing back to memory the scene setup in the commit. Depends on client
695+
* also supporting DRM_CLIENT_CAP_ATOMIC
696+
*/
697+
#define DRM_CLIENT_CAP_WRITEBACK_CONNECTORS 5
698+
690699
/** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
691700
struct drm_set_client_cap {
692701
__u64 capability;

0 commit comments

Comments
 (0)