From patchwork Tue Mar 6 12:07:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nautiyal, Ankit K" X-Patchwork-Id: 10261521 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3E137602C8 for ; Tue, 6 Mar 2018 12:14:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B52028EFE for ; Tue, 6 Mar 2018 12:14:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E35A28F30; Tue, 6 Mar 2018 12:14:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6DC8128F26 for ; Tue, 6 Mar 2018 12:14:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8B8D56E688; Tue, 6 Mar 2018 12:14:10 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id E52626E688 for ; Tue, 6 Mar 2018 12:14:08 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Mar 2018 04:14:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,431,1515484800"; d="scan'208";a="35872541" Received: from ankit-desktop.iind.intel.com ([10.223.161.14]) by fmsmga001.fm.intel.com with ESMTP; 06 Mar 2018 04:14:01 -0800 From: "Nautiyal, Ankit K" To: dri-devel@lists.freedesktop.org Subject: [PATCH v6 5/9] drm: Handle aspect-ratio info in getblob Date: Tue, 6 Mar 2018 17:37:39 +0530 Message-Id: <1520338063-13995-6-git-send-email-ankit.k.nautiyal@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520338063-13995-1-git-send-email-ankit.k.nautiyal@intel.com> References: <1520338063-13995-1-git-send-email-ankit.k.nautiyal@intel.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: Ankit Nautiyal MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Ankit Nautiyal If the user-space does not support aspect-ratio, then getblob called with the blob id of a user-mode, should clear the aspect-ratio information in the blob data. Currently for a given blob id, there is no way to determine if the blob stores user-mode or not. This can only be ascertained when the blob is used for an atomic modeset call. This patch: -adds a new field 'is_video_mode' in drm_property_blob to differentiate between the video mode blobs and the other blobs. -sets the field 'is_video_mode' when the blob is used for modeset. -removes the aspect-ratio info from the user-mode data if aspect-ratio is not supported by the user, while returning the blob to the user, in getblob ioctl. Signed-off-by: Ankit Nautiyal V6: As suggested by Ville: -added helper functions for determining if aspect-ratio is expected in user-mode and for allowing/disallowing the aspect-ratio, if its not expected. -avoided clobbering of blob-data, instead cleared the aspect-ratio in the user-mode only, so that another client with aspect-ratio cap, can still get the aspect-ratio information from getblob. --- drivers/gpu/drm/drm_atomic.c | 1 + drivers/gpu/drm/drm_modes.c | 44 ++++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_property.c | 5 +++++ include/drm/drm_modes.h | 4 ++++ include/drm/drm_property.h | 2 ++ 5 files changed, 56 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 46733d5..86b483e 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -464,6 +464,7 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc, else if (property == config->prop_mode_id) { struct drm_property_blob *mode = drm_property_lookup_blob(dev, val); + mode->is_video_mode = true; ret = drm_atomic_set_mode_prop_for_crtc(state, mode); drm_property_blob_put(mode); return ret; diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index a48672c..219890f 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -1761,3 +1761,47 @@ bool drm_mode_is_420(const struct drm_display_info *display, drm_mode_is_420_also(display, mode); } EXPORT_SYMBOL(drm_mode_is_420); + +/** + * drm_mode_aspect_ratio_allowed - checks if the aspect-ratio information + * is expected from the user-mode. + * + * If the user has set aspect-ratio cap, then the flag of the user-mode is + * allowed to contain aspect-ratio value. + * If the user does not set aspect-ratio cap, then the only value allowed in the + * flags bits is aspect-ratio NONE. + * + * @file_priv: file private structure to get the user capabilities + * @flag: 32 bit flag that contains the aspect-ratio information. + * + * Returns: + * true if the aspect-ratio info is allowed in the user-mode flags. + * false, otherwise. + */ +bool +drm_mode_aspect_ratio_allowed(const struct drm_file *file_priv, uint32_t flags) +{ + return file_priv->aspect_ratio_allowed || + (flags & DRM_MODE_FLAG_PIC_AR_MASK) == DRM_MODE_FLAG_PIC_AR_NONE; +} +EXPORT_SYMBOL(drm_mode_aspect_ratio_allowed); + +/** + * drm_mode_handle_aspect_ratio - handles the aspect-ratio bits in the user-mode + * flags. + * + * Checks if the aspect-ratio information is allowed. Resets the aspect-ratio + * bits in the user-mode flag, if aspect-ratio info is not allowed. + * + * @file_priv: file private structure to get the user capabilities. + * @flag: 32 bit flag that is to be modified, in case the aspect + * ratio info is not allowed. + * + */ +void +drm_mode_handle_aspect_ratio(const struct drm_file *file_priv, uint32_t *flags) +{ + if (!drm_mode_aspect_ratio_allowed(file_priv, *flags)) + *flags &= ~DRM_MODE_FLAG_PIC_AR_MASK; +} +EXPORT_SYMBOL(drm_mode_handle_aspect_ratio); diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c index bae50e6..4e56f84 100644 --- a/drivers/gpu/drm/drm_property.c +++ b/drivers/gpu/drm/drm_property.c @@ -753,6 +753,11 @@ int drm_mode_getblob_ioctl(struct drm_device *dev, ret = -EFAULT; goto unref; } + if (blob->is_video_mode) { + struct drm_mode_modeinfo *mode = + (struct drm_mode_modeinfo *) out_resp->data; + drm_mode_handle_aspect_ratio(file_priv, &mode->flags); + } } out_resp->length = blob->length; unref: diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h index 2f78b7e..51d1188 100644 --- a/include/drm/drm_modes.h +++ b/include/drm/drm_modes.h @@ -461,6 +461,10 @@ bool drm_mode_is_420_also(const struct drm_display_info *display, const struct drm_display_mode *mode); bool drm_mode_is_420(const struct drm_display_info *display, const struct drm_display_mode *mode); +bool drm_mode_aspect_ratio_allowed(const struct drm_file *file_priv, + uint32_t flags); +void drm_mode_handle_aspect_ratio(const struct drm_file *file_priv, + uint32_t *flags); struct drm_display_mode *drm_cvt_mode(struct drm_device *dev, int hdisplay, int vdisplay, int vrefresh, diff --git a/include/drm/drm_property.h b/include/drm/drm_property.h index 8a522b4..95e6e32 100644 --- a/include/drm/drm_property.h +++ b/include/drm/drm_property.h @@ -194,6 +194,7 @@ struct drm_property { * @head_global: entry on the global blob list in * &drm_mode_config.property_blob_list. * @head_file: entry on the per-file blob list in &drm_file.blobs list. + * @is_video_mode: flag to mark the blobs that contain drm_mode_modeinfo. * @length: size of the blob in bytes, invariant over the lifetime of the object * @data: actual data, embedded at the end of this structure * @@ -208,6 +209,7 @@ struct drm_property_blob { struct drm_device *dev; struct list_head head_global; struct list_head head_file; + bool is_video_mode; size_t length; unsigned char data[]; };