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: 11375 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 803D123E29 for ; Thu, 13 Sep 2012 03:50:59 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id D0DE834B8D0C for ; Thu, 13 Sep 2012 03:50:58 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id k11so4067700iea.11 for ; Wed, 12 Sep 2012 20:50:58 -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=o7gW44msqujR+L9BI0yYPjUOmfm/icdtLe9j2NNVnqY=; b=Yi6ub/ileX3Y7hskpDvAi3Xzcx1i+ndikmBG9aZ49lS60quGrEhdCQygQFGs231aui TaxR7enCNXHgWoPqPIj8oepCjj6Iw9ttj7nsZxpIV9hi5hAqmD5fTqUzs6jyiqjZ1q8/ q8+zB9OPBzpj7KDqbua0wBCp0x0lwCkISzDsToUCuxf5BbVtJs9nl/zkmKNsTV5Y1sjJ 4tuKCWJAqyl00o6HeN8CvVw5tuoQdqHwp+AGLctvhnBXuPrE1ciqqVd+u4v9jkLf7Rzq Jbbdj+6RrZ5JV+TqXRbiFq8DUovVY2RZaCSmO8N0ng9qbWCcklsSc64Lb0xXswwal0TK gJ1Q== Received: by 10.50.207.106 with SMTP id lv10mr669970igc.0.1347508258614; Wed, 12 Sep 2012 20:50:58 -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.184.232 with SMTP id ex8csp111064igc; Wed, 12 Sep 2012 20:50:58 -0700 (PDT) Received: by 10.60.3.35 with SMTP id 3mr456012oez.139.1347508258245; Wed, 12 Sep 2012 20:50:58 -0700 (PDT) Received: from mail-ob0-f178.google.com (mail-ob0-f178.google.com [209.85.214.178]) by mx.google.com with ESMTPS id rp7si28188597obc.5.2012.09.12.20.50.58 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Sep 2012 20:50:58 -0700 (PDT) Received-SPF: pass (google.com: domain of robdclark@gmail.com designates 209.85.214.178 as permitted sender) client-ip=209.85.214.178; Authentication-Results: mx.google.com; spf=pass (google.com: domain of robdclark@gmail.com designates 209.85.214.178 as permitted sender) smtp.mail=robdclark@gmail.com; dkim=pass header.i=@gmail.com Received: by mail-ob0-f178.google.com with SMTP id wd20so4595268obb.37 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) 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, Rob Clark 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> X-Gm-Message-State: ALoCoQkf8+/Bl2gVZymDaybWq6dfgr6mzWuky0VxD2yeyQgBOIzHt/m+j+EwU9ufGVNMCrJaCKre 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;