From patchwork Thu May 24 16:41:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liviu Dudau X-Patchwork-Id: 136752 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2446825lji; Thu, 24 May 2018 09:41:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrvfkxKVHRAJLGerahOXmLJQizrf0/ok7zqGPbzJpOH6nDGg70iiFL5DsWekl+o4gD4hqcf X-Received: by 2002:a62:e801:: with SMTP id c1-v6mr8109713pfi.184.1527180081286; Thu, 24 May 2018 09:41:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527180081; cv=none; d=google.com; s=arc-20160816; b=jbp9kfZh0u7zdLf5vdSvncrNENO8IMq6bOq7owBTQjo1KjA1XhbzQMcNaMaFFtD1q4 FdWXyQZDmx65SwvjSmS7qNlJ9zHuqCj69lShPFSO0p3DOk+HXrW1fd1PFOz4VLXlW7c+ fYC2l5r2+7INsm4FdOTvR7abuXU8F20bnTK81wHOcG9vXna5BtAyuwSr7DPKCH1kYYNH /DohnGk+n/7mV2ZRqYhhYKGNwSDHoHRsv5Y5AQ32HC8PBdbHvCp53OqOrrqaJpBkXf3z NgZ5BIgQwom+aLXIWEN0yPpzDymbtLtxGBiIVN5H9MJlek1SwTJomAGwqWLLVbTJCJsh Azuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:delivered-to:arc-authentication-results; bh=REWCuS/DFjzO/HlUz9IVLy6BpbVFDgbH7gwyM3srlus=; b=CVChWAq8B4AkqqpoNjYJAacNQMDd/ZHce1+OpbnycVr2uv4QI/aCypOT1sW10KqL/+ GhjHsbyYxbUKXDNGMUqGxhJcbjlaJbHmRccssZDwFqjkYGuTWav7fDjxdZzYOydYGnNJ C2iLqJby26UW8Lb0Ing0gZdGSvdd77lCsvZXtOsmKAqvg84f2mDr21pMwnamE1muSMCA urMdgddSYvvbESmk/ZmYD31Ugil49mCT7as2eVY2FgSgzaM709wR3bAq6ayDWG/4jmmj 9mmeOia5A8pbuNqTtWAHc30vFPMWX9Uz8KUsVUpILfdMcI8AS03IGqTzKLSR4G7AfLa2 XUUA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id x128-v6si21714368pfb.237.2018.05.24.09.41.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 May 2018 09:41:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B1ADC6E6A6; Thu, 24 May 2018 16:41:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by gabe.freedesktop.org (Postfix) with ESMTPS id D14676E64C for ; Thu, 24 May 2018 16:41:17 +0000 (UTC) Received: from e110455-lin.cambridge.arm.com (e110455-lin.cambridge.arm.com [10.2.131.15]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id w4OGf3qu030243; Thu, 24 May 2018 17:41:05 +0100 From: Liviu Dudau To: Gustavo Padovan Subject: [PATCH v9 3/3] drm: writeback: Add client capability for exposing writeback connectors Date: Thu, 24 May 2018 17:41:03 +0100 Message-Id: <20180524164103.8378-4-Liviu.Dudau@arm.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524164103.8378-1-Liviu.Dudau@arm.com> References: <20180524164103.8378-1-Liviu.Dudau@arm.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , Daniel Stone , Jonathan Corbet , David Airlie , Liviu Dudau , Boris Brezillon , Alexandru-Cosmin Gheorghe , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. - update the capability number to fix conflict with the aspect ratio Reviewed-by: Eric Anholt Re-requested-by: Sean Paul Cc: Brian Starkey Signed-off-by: Liviu Dudau --- drivers/gpu/drm/drm_ioctl.c | 7 +++++++ drivers/gpu/drm/drm_mode_config.c | 5 +++++ include/drm/drm_file.h | 7 +++++++ include/uapi/drm/drm.h | 9 +++++++++ 4 files changed, 28 insertions(+) diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 0d4cfb232576f..fe49fb0356b5a 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -334,6 +334,13 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv) return -EINVAL; file_priv->aspect_ratio_allowed = req->value; break; + case DRM_CLIENT_CAP_WRITEBACK_CONNECTORS: + if (!file_priv->atomic) + return -EINVAL; + if (req->value > 1) + return -EINVAL; + file_priv->writeback_connectors = req->value; + break; default: return -EINVAL; } diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c index e5c653357024d..21e353bd3948e 100644 --- a/drivers/gpu/drm/drm_mode_config.c +++ b/drivers/gpu/drm/drm_mode_config.c @@ -145,6 +145,11 @@ int drm_mode_getresources(struct drm_device *dev, void *data, count = 0; connector_id = u64_to_user_ptr(card_res->connector_id_ptr); drm_for_each_connector_iter(connector, &conn_iter) { + /* only expose writeback connectors if userspace understands them */ + if (!file_priv->writeback_connectors && + (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)) + continue; + if (drm_lease_held(file_priv, connector->base.id)) { if (count < card_res->count_connectors && put_user(connector->base.id, connector_id + count)) { diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h index 027ac16da3d15..26485acc51d79 100644 --- a/include/drm/drm_file.h +++ b/include/drm/drm_file.h @@ -192,6 +192,13 @@ struct drm_file { */ unsigned aspect_ratio_allowed:1; + /** + * @writeback_connectors: + * + * True if client understands writeback connectors + */ + unsigned writeback_connectors:1; + /** * @is_master: * diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index 9c660e1688abe..300f336633f28 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -687,6 +687,15 @@ struct drm_get_cap { */ #define DRM_CLIENT_CAP_ASPECT_RATIO 4 +/** + * DRM_CLIENT_CAP_WRITEBACK_CONNECTORS + * + * If set to 1, the DRM core will expose special connectors to be used for + * writing back to memory the scene setup in the commit. Depends on client + * also supporting DRM_CLIENT_CAP_ATOMIC + */ +#define DRM_CLIENT_CAP_WRITEBACK_CONNECTORS 5 + /** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */ struct drm_set_client_cap { __u64 capability;