From patchwork Tue Mar 25 14:32:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sagar.a.kamble@intel.com X-Patchwork-Id: 3887971 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id ED7A8BF540 for ; Tue, 25 Mar 2014 14:31:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0E445201FD for ; Tue, 25 Mar 2014 14:31:36 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id F1F6E201F2 for ; Tue, 25 Mar 2014 14:31:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 909376E2C6; Tue, 25 Mar 2014 07:31:33 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 45CF46E2BC; Tue, 25 Mar 2014 07:31:32 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 25 Mar 2014 07:31:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,728,1389772800"; d="scan'208";a="507164553" Received: from sagar-desktop.iind.intel.com ([10.223.82.31]) by orsmga002.jf.intel.com with ESMTP; 25 Mar 2014 07:31:26 -0700 From: sagar.a.kamble@intel.com To: intel-gfx@lists.freedesktop.org Date: Tue, 25 Mar 2014 20:02:24 +0530 Message-Id: <1395757947-16492-1-git-send-email-sagar.a.kamble@intel.com> X-Mailer: git-send-email 1.8.5 In-Reply-To: <20140320135151.GO6912@strange.amr.corp.intel.com> References: <20140320135151.GO6912@strange.amr.corp.intel.com> Cc: airlied@linux.ie, Sagar Kamble , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH v2 1/4] drm: Adding new flag to restrict bitmask drm properties as 32 bit type and 32 bit value pair X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sagar Kamble With this patch new flag DRM_MODE_PROP_32BIT_PAIR is added that will help make use of 64 bit value of bitmask property as two 32 bit values. Cc: airlied@linux.ie Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Sagar Kamble --- drivers/gpu/drm/drm_crtc.c | 22 ++++++++++++++++------ include/uapi/drm/drm_mode.h | 3 +++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 4e43fc2..d0d03ec 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -2993,10 +2993,13 @@ int drm_property_add_enum(struct drm_property *property, int index, /* * Bitmask enum properties have the additional constraint of values - * from 0 to 63 + * from 0 to 63. For properties with 32BIT_PAIR Flag set this constraint + * range is 0 to 31. */ - if ((property->flags & DRM_MODE_PROP_BITMASK) && (value > 63)) - return -EINVAL; + if (property->flags & DRM_MODE_PROP_BITMASK) + if (((property->flags & DRM_MODE_PROP_32BIT_PAIR) && (value > 31)) || + (value > 63)) + return -EINVAL; if (!list_empty(&property->enum_blob_list)) { list_for_each_entry(prop_enum, &property->enum_blob_list, head) { @@ -3305,9 +3308,16 @@ static bool drm_property_change_is_valid(struct drm_property *property, } else if (property->flags & DRM_MODE_PROP_BITMASK) { int i; uint64_t valid_mask = 0; - for (i = 0; i < property->num_values; i++) - valid_mask |= (1ULL << property->values[i]); - return !(value & ~valid_mask); + uint32_t valid_32bit_mask = 0; + if (property->flags & DRM_MODE_PROP_32BIT_PAIR) { + for (i = 0; i < property->num_values; i++) + valid_32bit_mask |= (1UL << property->values[i]); + return !((value & 0xFFFFFFFF) & ~valid_32bit_mask); + } else { + for (i = 0; i < property->num_values; i++) + valid_mask |= (1ULL << property->values[i]); + return !(value & ~valid_mask); + } } else if (property->flags & DRM_MODE_PROP_BLOB) { /* Only the driver knows */ return true; diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index f104c26..5e3a7d9 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -250,6 +250,9 @@ struct drm_mode_get_connector { #define DRM_MODE_PROP_ENUM (1<<3) /* enumerated type with text strings */ #define DRM_MODE_PROP_BLOB (1<<4) #define DRM_MODE_PROP_BITMASK (1<<5) /* bitmask of enumerated types */ +#define DRM_MODE_PROP_32BIT_PAIR (1<<6) /* 32 bit bitmask of enumerated types + * and 32 bit of value of the type */ + struct drm_mode_property_enum { __u64 value;