Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Ville Syrjälä and committed by
Daniel Vetter
7689ffb3 06596961

+19 -6
+13 -4
drivers/gpu/drm/drm_crtc.c
··· 3395 3395 struct drm_property *drm_property_create_bitmask(struct drm_device *dev, 3396 3396 int flags, const char *name, 3397 3397 const struct drm_prop_enum_list *props, 3398 - int num_values) 3398 + int num_props, 3399 + uint64_t supported_bits) 3399 3400 { 3400 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 3405 flags |= DRM_MODE_PROP_BITMASK; 3404 3406 3405 3407 property = drm_property_create(dev, flags, name, num_values); 3406 3408 if (!property) 3407 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++) { 3410 - ret = drm_property_add_enum(property, i, 3414 + if (WARN_ON(index >= num_values)) { 3415 + drm_property_destroy(dev, property); 3416 + return NULL; 3417 + } 3418 + 3419 + ret = drm_property_add_enum(property, index++, 3411 3420 props[i].type, 3412 3421 props[i].name); 3413 3422 if (ret) {
+4 -1
drivers/gpu/drm/omapdrm/omap_plane.c
··· 317 317 { DRM_REFLECT_Y, "reflect-y" }, 318 318 }; 319 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 324 if (prop == NULL) 322 325 return; 323 326 priv->rotation_prop = prop;
+2 -1
include/drm/drm_crtc.h
··· 1006 1006 struct drm_property *drm_property_create_bitmask(struct drm_device *dev, 1007 1007 int flags, const char *name, 1008 1008 const struct drm_prop_enum_list *props, 1009 - int num_values); 1009 + int num_props, 1010 + uint64_t supported_bits); 1010 1011 struct drm_property *drm_property_create_range(struct drm_device *dev, int flags, 1011 1012 const char *name, 1012 1013 uint64_t min, uint64_t max);