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: 12199 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id E11E823EFB for ; Sat, 13 Oct 2012 00:49:30 +0000 (UTC) Received: from mail-ia0-f180.google.com (mail-ia0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 954CCA18888 for ; Sat, 13 Oct 2012 00:49:30 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id f6so2398032iag.11 for ; Fri, 12 Oct 2012 17:49:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :dkim-signature:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=gIHF9Tp2ndzOL+epFiY28awkJ6W630WEZw0/0TZ2Cvo=; b=E2VCE3ftcWUEL+VQDH7gBYLS23gMI+hgyi2nQi1YYalbgt+Jb+cEvxpBTJ/fRB+CP0 uWjhFcxD2GftB518J6oir288orxaMgTB6QA6C4zK/QoSlOw7xkpVEh6JSMzX4WRnkqI/ yBtgpuyQ8Ul4oa3qhUJfrtdw6DbpZLohIgAw9n5WJvAQX+xmK296yZxzDR/yI5CWIZfu a4eWhsPE2AOsn4l1jBskeW08oBcqAEHakJ/zEIgw63iV6OSUWBbM6NSDsYebmeeq/601 e8kC124GTn6O3/Xrbh4tEGaIq9fi10W9nU2JlhQ41FmmRvZxxd517dIm4NeF/fPFMOld lGxw== Received: by 10.50.91.195 with SMTP id cg3mr3645850igb.57.1350089370381; Fri, 12 Oct 2012 17:49:30 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp274618igt; Fri, 12 Oct 2012 17:49:30 -0700 (PDT) Received: by 10.182.152.74 with SMTP id uw10mr1487781obb.45.1350089369975; Fri, 12 Oct 2012 17:49:29 -0700 (PDT) Received: from mail-oa0-f50.google.com (mail-oa0-f50.google.com [209.85.219.50]) by mx.google.com with ESMTPS id d7si101453oea.52.2012.10.12.17.49.29 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 12 Oct 2012 17:49:29 -0700 (PDT) Received-SPF: pass (google.com: domain of robdclark@gmail.com designates 209.85.219.50 as permitted sender) client-ip=209.85.219.50; Authentication-Results: mx.google.com; spf=pass (google.com: domain of robdclark@gmail.com designates 209.85.219.50 as permitted sender) smtp.mail=robdclark@gmail.com; dkim=pass header.i=@gmail.com Received: by mail-oa0-f50.google.com with SMTP id n16so4214146oag.37 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) Sender: Rob Clark From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: patches@linaro.org, ville.syrjala@linux.intel.com, jbarnes@virtuousgeek.org, daniel.vetter@ffwll.ch, krh@bitplanet.net, Rob Clark 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> X-Gm-Message-State: ALoCoQnn81HMb5Cy4Em7dTZsj83NsgNZy1a8smDu4iNErdd59yyhfS9jNfzexR8n/zmxlGd78Csm 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;