aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2014-07-08 01:01:52 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-07-11 17:43:23 -0400
commit7689ffb32fa314cc6f128b433b5a285f2699cb70 (patch)
treef2dfa9b12a7eedb5169f86c0f2d6f15fed9b4439
parent06596961966bfeb128bc07f250b68fb9c5f177ef (diff)
drm: Add support_bits parameter to drm_property_create_bitmask()
Make drm_property_create_bitmask() a bit more generic by allowing the caller to specify which bits are in fact supported. This allows multiple callers to use the same enum list, but still create different versions of the same property with different list of supported bits. v2: Populate values[] array as non-sparse Make supported_bits 64bit Fix up omapdrm call site (Rob) Cc: dri-devel@lists.freedesktop.org Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Imre Deak <imre.deak@intel.com> Reviewed-by: Sagar Kamble <sagar.a.kamble@intel.com> Acked-by: Dave Airlie <airlied@linux.ie> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--drivers/gpu/drm/drm_crtc.c17
-rw-r--r--drivers/gpu/drm/omapdrm/omap_plane.c5
-rw-r--r--include/drm/drm_crtc.h3
3 files changed, 19 insertions, 6 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 41c7212081b8..2fbee61d632d 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -3395,19 +3395,28 @@ EXPORT_SYMBOL(drm_property_create_enum);
3395struct drm_property *drm_property_create_bitmask(struct drm_device *dev, 3395struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
3396 int flags, const char *name, 3396 int flags, const char *name,
3397 const struct drm_prop_enum_list *props, 3397 const struct drm_prop_enum_list *props,
3398 int num_values) 3398 int num_props,
3399 uint64_t supported_bits)
3399{ 3400{
3400 struct drm_property *property; 3401 struct drm_property *property;
3401 int i, ret; 3402 int i, ret, index = 0;
3403 int num_values = hweight64(supported_bits);
3402 3404
3403 flags |= DRM_MODE_PROP_BITMASK; 3405 flags |= DRM_MODE_PROP_BITMASK;
3404 3406
3405 property = drm_property_create(dev, flags, name, num_values); 3407 property = drm_property_create(dev, flags, name, num_values);
3406 if (!property) 3408 if (!property)
3407 return NULL; 3409 return NULL;
3410 for (i = 0; i < num_props; i++) {
3411 if (!(supported_bits & (1ULL << props[i].type)))
3412 continue;
3408 3413
3409 for (i = 0; i < num_values; i++) { 3414 if (WARN_ON(index >= num_values)) {
3410 ret = drm_property_add_enum(property, i, 3415 drm_property_destroy(dev, property);
3416 return NULL;
3417 }
3418
3419 ret = drm_property_add_enum(property, index++,
3411 props[i].type, 3420 props[i].type,
3412 props[i].name); 3421 props[i].name);
3413 if (ret) { 3422 if (ret) {
diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c
index 3cf31ee59aac..aff06e7a4e5f 100644
--- a/drivers/gpu/drm/omapdrm/omap_plane.c
+++ b/drivers/gpu/drm/omapdrm/omap_plane.c
@@ -317,7 +317,10 @@ void omap_plane_install_properties(struct drm_plane *plane,
317 { DRM_REFLECT_Y, "reflect-y" }, 317 { DRM_REFLECT_Y, "reflect-y" },
318 }; 318 };
319 prop = drm_property_create_bitmask(dev, 0, "rotation", 319 prop = drm_property_create_bitmask(dev, 0, "rotation",
320 props, ARRAY_SIZE(props)); 320 props, ARRAY_SIZE(props),
321 BIT(DRM_ROTATE_0) | BIT(DRM_ROTATE_90) |
322 BIT(DRM_ROTATE_180) | BIT(DRM_ROTATE_270) |
323 BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y));
321 if (prop == NULL) 324 if (prop == NULL)
322 return; 325 return;
323 priv->rotation_prop = prop; 326 priv->rotation_prop = prop;
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index bfc7235a9c0e..cb4850a2b0c1 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -1006,7 +1006,8 @@ extern struct drm_property *drm_property_create_enum(struct drm_device *dev, int
1006struct drm_property *drm_property_create_bitmask(struct drm_device *dev, 1006struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
1007 int flags, const char *name, 1007 int flags, const char *name,
1008 const struct drm_prop_enum_list *props, 1008 const struct drm_prop_enum_list *props,
1009 int num_values); 1009 int num_props,
1010 uint64_t supported_bits);
1010struct drm_property *drm_property_create_range(struct drm_device *dev, int flags, 1011struct drm_property *drm_property_create_range(struct drm_device *dev, int flags,
1011 const char *name, 1012 const char *name,
1012 uint64_t min, uint64_t max); 1013 uint64_t min, uint64_t max);