From patchwork Thu Sep 13 03:49:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 1450961 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 8A9B9DF24C for ; Thu, 13 Sep 2012 09:36:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 72B7F9E967 for ; Thu, 13 Sep 2012 02:36:43 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ob0-f177.google.com (mail-ob0-f177.google.com [209.85.214.177]) by gabe.freedesktop.org (Postfix) with ESMTP id 688EF9F381 for ; Wed, 12 Sep 2012 20:50:58 -0700 (PDT) Received: by mail-ob0-f177.google.com with SMTP id ta17so3999161obb.36 for ; Wed, 12 Sep 2012 20:50:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=o7gW44msqujR+L9BI0yYPjUOmfm/icdtLe9j2NNVnqY=; b=0XLoYBtRi4yhwj68lvXZgnbZQeXJ7sCUiPKza386X4kONpPM9z8S5m9DaaLikVajRz v1Z4zANLY2zJxlvAGROJZ2lVfpPmkC2V+2gK13Y/kWduq9DOP/iNxqwzFC8VdsbkC9nJ WLptl31NbxvjrF3ft1KsOluQ7lC8hOUY4bRuxHRsiFkyuPUK/8xx3YVAFtRd9IHEUxa9 wn/kWGYjiTVGDaKfm/OV80WQPI36BYremYS6A79uW8DfLhdnByku6/bIxJxGf/Wh/9/d IGjbcDg+XkaL03YWgwWmN20VECpVSp20FoaVy3TqBenzwBrxSWZHOWkDjd8B8TQHBUZ6 ySQA== Received: by 10.182.169.105 with SMTP id ad9mr441777obc.90.1347508258066; Wed, 12 Sep 2012 20:50:58 -0700 (PDT) Received: from localhost (ppp-70-129-131-42.dsl.rcsntx.swbell.net. [70.129.131.42]) by mx.google.com with ESMTPS id d6sm22533935obx.15.2012.09.12.20.50.56 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Sep 2012 20:50:57 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [RFC 04/11] drm: add DRM_MODE_PROP_SIGNED property flag Date: Wed, 12 Sep 2012 22:49:50 -0500 Message-Id: <1347508195-14939-5-git-send-email-rob.clark@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1347508195-14939-1-git-send-email-rob.clark@linaro.org> References: <1347508195-14939-1-git-send-email-rob.clark@linaro.org> Cc: daniel.vetter@ffwll.ch, Rob Clark , patches@linaro.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org From: Rob Clark Flag for range property types indicating that the value is a signed integer rather than unsigned. For range properties, the signed flag will trigger use of signed integer comparisions, to handle negative values properly. --- drivers/gpu/drm/drm_crtc.c | 10 ++++++++-- include/drm/drm_crtc.h | 9 +++++++++ include/drm/drm_mode.h | 2 ++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 2b4526e..e62ae6a 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -3210,9 +3210,15 @@ EXPORT_SYMBOL(drm_mode_connector_update_edid_property); static bool drm_property_change_is_valid(struct drm_property *property, uint64_t value) { - if (property->flags & DRM_MODE_PROP_IMMUTABLE) + if (property->flags & DRM_MODE_PROP_IMMUTABLE) { return false; - if (property->flags & DRM_MODE_PROP_RANGE) { + } else if (property->flags & (DRM_MODE_PROP_RANGE|DRM_MODE_PROP_SIGNED)) { + int64_t svalue = U642I64(value); + if (svalue < U642I64(property->values[0]) || + svalue > U642I64(property->values[1])) + return false; + return true; + } else if (property->flags & DRM_MODE_PROP_RANGE) { if (value < property->values[0] || value > property->values[1]) return false; return true; diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 0dbf2be..dc67f5f 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -61,6 +61,15 @@ struct drm_object_properties { uint64_t values[DRM_OBJECT_MAX_PROPERTY]; }; +static inline int64_t U642I64(uint64_t val) +{ + return (int64_t)*((int64_t *)&val); +} +static inline uint64_t I642U64(int64_t val) +{ + return (uint64_t)*((uint64_t *)&val); +} + /* * Note on terminology: here, for brevity and convenience, we refer to connector * control chips as 'CRTCs'. They can control any type of connector, VGA, LVDS, diff --git a/include/drm/drm_mode.h b/include/drm/drm_mode.h index 15689d4..9cc0336 100644 --- a/include/drm/drm_mode.h +++ b/include/drm/drm_mode.h @@ -241,6 +241,8 @@ struct drm_mode_get_connector { * be changed dynamically, assuming the pixel format does not change. */ #define DRM_MODE_PROP_DYNAMIC (1<<24) +/* Indicates that numeric property values are signed rather than unsigned: */ +#define DRM_MODE_PROP_SIGNED (1<<25) struct drm_mode_property_enum { __u64 value;