Skip to content

Commit 7689ffb

Browse files
vsyrjaladanvet
authored andcommitted
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>
1 parent 0659696 commit 7689ffb

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

‎drivers/gpu/drm/drm_crtc.c‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3395,19 +3395,28 @@ EXPORT_SYMBOL(drm_property_create_enum);
33953395
struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
33963396
int flags, const char *name,
33973397
const struct drm_prop_enum_list *props,
3398-
int num_values)
3398+
int num_props,
3399+
uint64_t supported_bits)
33993400
{
34003401
struct drm_property *property;
3401-
int i, ret;
3402+
int i, ret, index = 0;
3403+
int num_values = hweight64(supported_bits);
34023404

34033405
flags |= DRM_MODE_PROP_BITMASK;
34043406

34053407
property = drm_property_create(dev, flags, name, num_values);
34063408
if (!property)
34073409
return NULL;
3410+
for (i = 0; i < num_props; i++) {
3411+
if (!(supported_bits & (1ULL << props[i].type)))
3412+
continue;
34083413

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++,
34113420
props[i].type,
34123421
props[i].name);
34133422
if (ret) {

‎drivers/gpu/drm/omapdrm/omap_plane.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,10 @@ void omap_plane_install_properties(struct drm_plane *plane,
317317
{ DRM_REFLECT_Y, "reflect-y" },
318318
};
319319
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));
321324
if (prop == NULL)
322325
return;
323326
priv->rotation_prop = prop;

‎include/drm/drm_crtc.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,8 @@ extern struct drm_property *drm_property_create_enum(struct drm_device *dev, int
10061006
struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
10071007
int flags, const char *name,
10081008
const struct drm_prop_enum_list *props,
1009-
int num_values);
1009+
int num_props,
1010+
uint64_t supported_bits);
10101011
struct drm_property *drm_property_create_range(struct drm_device *dev, int flags,
10111012
const char *name,
10121013
uint64_t min, uint64_t max);

0 commit comments

Comments
 (0)