From patchwork Sat Oct 13 00:49:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 1588561 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 9BA223FD9C for ; Sat, 13 Oct 2012 00:53:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2B5AF9EAF4 for ; Fri, 12 Oct 2012 17:53:08 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-oa0-f49.google.com (mail-oa0-f49.google.com [209.85.219.49]) by gabe.freedesktop.org (Postfix) with ESMTP id E853B9E9BE for ; Fri, 12 Oct 2012 17:49:29 -0700 (PDT) Received: by mail-oa0-f49.google.com with SMTP id l10so3601665oag.36 for ; Fri, 12 Oct 2012 17:49:29 -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=gIHF9Tp2ndzOL+epFiY28awkJ6W630WEZw0/0TZ2Cvo=; b=q+v+b6+YbM8sasVGtdK3QNB2Ai7RGVzBguKErELj1280SXjQ66nw3jl6+vBcjP22Wd WElLp18L222A5E8pmk6J6A3m94zktLzu3XSaD90Ux2LsEJNmtTupaopKyUBmUNXwy201 3H/y4TM8s9dH/oAc+5GTojiN1eDhjm7JvQPSIDaHlE2cgVXt3JjqXC2DDsUr89xeaPaX bszLINw3/QcWOv0n6FMUqYSOK7Jqpg4fWkES67+semwUXqK5l7w7cp1Dq0D0dmet3TRS WNlSxyxR3nC8bQ99lprJj/8uJ7wFsBHnRYDYk/s+EvpMLXWBLwkzLg3PZk+98NIHV+X/ uqYw== Received: by 10.182.194.70 with SMTP id hu6mr4884381obc.4.1350089369837; Fri, 12 Oct 2012 17:49:29 -0700 (PDT) Received: from localhost (ppp-70-129-143-201.dsl.rcsntx.swbell.net. [70.129.143.201]) by mx.google.com with ESMTPS id ig3sm8256974obb.0.2012.10.12.17.49.28 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 12 Oct 2012 17:49:29 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [RFC 04/11] drm: add DRM_MODE_PROP_SIGNED property flag Date: Fri, 12 Oct 2012 19:49:05 -0500 Message-Id: <1350089352-18162-5-git-send-email-rob.clark@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1350089352-18162-1-git-send-email-rob.clark@linaro.org> References: <1350089352-18162-1-git-send-email-rob.clark@linaro.org> Cc: patches@linaro.org, daniel.vetter@ffwll.ch, Rob Clark 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 e25903d..5308a34 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -3191,9 +3191,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 f319127..219d35a 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 e03ece6..f9232e4 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;