From: Rob Clark <robdclark@gmail.com>
To: dri-devel@lists.freedesktop.org
Subject: [PATCH 4/8] drm: add signed-range property type
Date: Fri, 30 May 2014 13:12:06 -0400 [thread overview]
Message-ID: <1401469930-32750-5-git-send-email-robdclark@gmail.com> (raw)
In-Reply-To: <1401469930-32750-1-git-send-email-robdclark@gmail.com>
Like range, but values are signed.
Signed-off-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
---
drivers/gpu/drm/drm_crtc.c | 45 +++++++++++++++++++++++++++++++++------------
include/drm/drm_crtc.h | 12 ++++++++++++
include/uapi/drm/drm_mode.h | 1 +
3 files changed, 46 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 8fdd5b3..ae3d302 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -3232,6 +3232,22 @@ struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
}
EXPORT_SYMBOL(drm_property_create_bitmask);
+static struct drm_property *property_create_range(struct drm_device *dev,
+ int flags, const char *name,
+ uint64_t min, uint64_t max)
+{
+ struct drm_property *property;
+
+ property = drm_property_create(dev, flags, name, 2);
+ if (!property)
+ return NULL;
+
+ property->values[0] = min;
+ property->values[1] = max;
+
+ return property;
+}
+
/**
* drm_property_create - create a new ranged property type
* @dev: drm device
@@ -3254,21 +3270,20 @@ struct drm_property *drm_property_create_range(struct drm_device *dev, int flags
const char *name,
uint64_t min, uint64_t max)
{
- struct drm_property *property;
-
- flags |= DRM_MODE_PROP_RANGE;
-
- property = drm_property_create(dev, flags, name, 2);
- if (!property)
- return NULL;
-
- property->values[0] = min;
- property->values[1] = max;
-
- return property;
+ return property_create_range(dev, DRM_MODE_PROP_RANGE | flags,
+ name, min, max);
}
EXPORT_SYMBOL(drm_property_create_range);
+struct drm_property *drm_property_create_signed_range(struct drm_device *dev,
+ int flags, const char *name,
+ int64_t min, int64_t max)
+{
+ return property_create_range(dev, DRM_MODE_PROP_SIGNED_RANGE | flags,
+ name, I642U64(min), I642U64(max));
+}
+EXPORT_SYMBOL(drm_property_create_signed_range);
+
struct drm_property *drm_property_create_object(struct drm_device *dev,
int flags, const char *name, uint32_t type)
{
@@ -3704,6 +3719,12 @@ static bool drm_property_change_is_valid(struct drm_property *property,
if (value < property->values[0] || value > property->values[1])
return false;
return true;
+ } else if (drm_property_type_is(property, DRM_MODE_PROP_SIGNED_RANGE)) {
+ int64_t svalue = U642I64(value);
+ if (svalue < U642I64(property->values[0]) ||
+ svalue > U642I64(property->values[1]))
+ return false;
+ return true;
} else if (drm_property_type_is(property, DRM_MODE_PROP_BITMASK)) {
int i;
uint64_t valid_mask = 0;
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index c63df87..f7dd3c6 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -65,6 +65,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);
+}
+
enum drm_connector_force {
DRM_FORCE_UNSPECIFIED,
DRM_FORCE_OFF,
@@ -983,6 +992,9 @@ struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
struct drm_property *drm_property_create_range(struct drm_device *dev, int flags,
const char *name,
uint64_t min, uint64_t max);
+struct drm_property *drm_property_create_signed_range(struct drm_device *dev,
+ int flags, const char *name,
+ int64_t min, int64_t max);
struct drm_property *drm_property_create_object(struct drm_device *dev,
int flags, const char *name, uint32_t type);
extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index 5b530c7..ded505e 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -264,6 +264,7 @@ struct drm_mode_get_connector {
#define DRM_MODE_PROP_EXTENDED_TYPE 0x0000ffc0
#define DRM_MODE_PROP_TYPE(n) ((n) << 6)
#define DRM_MODE_PROP_OBJECT DRM_MODE_PROP_TYPE(1)
+#define DRM_MODE_PROP_SIGNED_RANGE DRM_MODE_PROP_TYPE(2)
struct drm_mode_property_enum {
__u64 value;
--
1.9.3
next prev parent reply other threads:[~2014-05-30 17:12 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-30 17:12 [PATCH 0/8] prepare for preparing for atomic (v2) Rob Clark
2014-05-30 17:12 ` [PATCH 1/8] drm: helpers to find mode objects Rob Clark
2014-06-03 13:22 ` Daniel Vetter
2014-05-30 17:12 ` [PATCH 2/8] drm: add extended property types Rob Clark
2014-06-03 13:25 ` Daniel Vetter
2014-05-30 17:12 ` [PATCH 3/8] drm: add object property type Rob Clark
2014-06-03 13:24 ` Daniel Vetter
2014-05-30 17:12 ` Rob Clark [this message]
2014-05-30 17:12 ` [PATCH 5/8] drm: spiff out FB refcnting traces Rob Clark
2014-05-30 17:12 ` [PATCH 6/8] drm: Split connection_mutex out of mode_config.mutex (v3) Rob Clark
2014-05-30 17:12 ` [PATCH 7/8] drm: convert crtc and connection_mutex to ww_mutex (v3) Rob Clark
2014-06-03 13:29 ` Daniel Vetter
2014-06-04 3:38 ` Dave Airlie
2014-06-04 9:21 ` Daniel Vetter
2014-05-30 17:12 ` [PATCH 8/8] drm: add drm_fb_helper_restore_fbdev_mode_unlocked() Rob Clark
2014-06-03 13:33 ` Daniel Vetter
2014-06-03 14:44 ` Rob Clark
2014-06-02 8:11 ` [PATCH 0/8] prepare for preparing for atomic (v2) Daniel Vetter
2014-06-02 15:33 ` Rob Clark
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1401469930-32750-5-git-send-email-robdclark@gmail.com \
--to=robdclark@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox