Lines Matching +full:bool +full:- +full:property
40 * configuration from userspace to the kernel. Properties have a well-defined
43 * property types and ranges.
49 * Property values are only 64bit. To support bigger piles of data (like gamma
50 * tables, color correction matrices or large structures) a property can instead
54 * per-object mapping from those names to the property ID used in the atomic
55 * IOCTL and in the get/set property IOCTL.
58 static bool drm_property_flags_valid(u32 flags) in drm_property_flags_valid()
82 * drm_property_create - create a new property type
84 * @flags: flags specifying the property type
85 * @name: name of the property
86 * @num_values: number of pre-defined values
88 * This creates a new generic drm property which can then be attached to a drm
89 * object with drm_object_attach_property(). The returned property object must
94 * A pointer to the newly created property on success, NULL on failure.
100 struct drm_property *property = NULL; in drm_property_create() local
109 property = kzalloc(sizeof(struct drm_property), GFP_KERNEL); in drm_property_create()
110 if (!property) in drm_property_create()
113 property->dev = dev; in drm_property_create()
116 property->values = kcalloc(num_values, sizeof(uint64_t), in drm_property_create()
118 if (!property->values) in drm_property_create()
122 ret = drm_mode_object_add(dev, &property->base, DRM_MODE_OBJECT_PROPERTY); in drm_property_create()
126 property->flags = flags; in drm_property_create()
127 property->num_values = num_values; in drm_property_create()
128 INIT_LIST_HEAD(&property->enum_list); in drm_property_create()
130 strscpy_pad(property->name, name, DRM_PROP_NAME_LEN); in drm_property_create()
132 list_add_tail(&property->head, &dev->mode_config.property_list); in drm_property_create()
134 return property; in drm_property_create()
136 kfree(property->values); in drm_property_create()
137 kfree(property); in drm_property_create()
143 * drm_property_create_enum - create a new enumeration property type
145 * @flags: flags specifying the property type
146 * @name: name of the property
147 * @props: enumeration lists with property values
148 * @num_values: number of pre-defined values
150 * This creates a new generic drm property which can then be attached to a drm
151 * object with drm_object_attach_property(). The returned property object must
159 * A pointer to the newly created property on success, NULL on failure.
166 struct drm_property *property; in drm_property_create_enum() local
171 property = drm_property_create(dev, flags, name, num_values); in drm_property_create_enum()
172 if (!property) in drm_property_create_enum()
176 ret = drm_property_add_enum(property, in drm_property_create_enum()
180 drm_property_destroy(dev, property); in drm_property_create_enum()
185 return property; in drm_property_create_enum()
190 * drm_property_create_bitmask - create a new bitmask property type
192 * @flags: flags specifying the property type
193 * @name: name of the property
194 * @props: enumeration lists with property bitflags
198 * This creates a new bitmask drm property which can then be attached to a drm
199 * object with drm_object_attach_property(). The returned property object must
204 * or'ed together combination of the predefined property bitflag values
207 * A pointer to the newly created property on success, NULL on failure.
215 struct drm_property *property; in drm_property_create_bitmask() local
221 property = drm_property_create(dev, flags, name, num_values); in drm_property_create_bitmask()
222 if (!property) in drm_property_create_bitmask()
228 ret = drm_property_add_enum(property, in drm_property_create_bitmask()
232 drm_property_destroy(dev, property); in drm_property_create_bitmask()
237 return property; in drm_property_create_bitmask()
245 struct drm_property *property; in property_create_range() local
247 property = drm_property_create(dev, flags, name, 2); in property_create_range()
248 if (!property) in property_create_range()
251 property->values[0] = min; in property_create_range()
252 property->values[1] = max; in property_create_range()
254 return property; in property_create_range()
258 * drm_property_create_range - create a new unsigned ranged property type
260 * @flags: flags specifying the property type
261 * @name: name of the property
262 * @min: minimum value of the property
263 * @max: maximum value of the property
265 * This creates a new generic drm property which can then be attached to a drm
266 * object with drm_object_attach_property(). The returned property object must
274 * A pointer to the newly created property on success, NULL on failure.
286 * drm_property_create_signed_range - create a new signed ranged property type
288 * @flags: flags specifying the property type
289 * @name: name of the property
290 * @min: minimum value of the property
291 * @max: maximum value of the property
293 * This creates a new generic drm property which can then be attached to a drm
294 * object with drm_object_attach_property(). The returned property object must
302 * A pointer to the newly created property on success, NULL on failure.
314 * drm_property_create_object - create a new object property type
316 * @flags: flags specifying the property type
317 * @name: name of the property
320 * This creates a new generic drm property which can then be attached to a drm
321 * object with drm_object_attach_property(). The returned property object must
325 * Userspace is only allowed to set this to any property value of the given
329 * A pointer to the newly created property on success, NULL on failure.
335 struct drm_property *property; in drm_property_create_object() local
342 property = drm_property_create(dev, flags, name, 1); in drm_property_create_object()
343 if (!property) in drm_property_create_object()
346 property->values[0] = type; in drm_property_create_object()
348 return property; in drm_property_create_object()
353 * drm_property_create_bool - create a new boolean property type
355 * @flags: flags specifying the property type
356 * @name: name of the property
358 * This creates a new generic drm property which can then be attached to a drm
359 * object with drm_object_attach_property(). The returned property object must
363 * This is implemented as a ranged property with only {0, 1} as valid values.
366 * A pointer to the newly created property on success, NULL on failure.
376 * drm_property_add_enum - add a possible value to an enumeration property
377 * @property: enumeration property to change
381 * This functions adds enumerations to a property.
384 * to directly create the property with all enumerations already attached.
389 int drm_property_add_enum(struct drm_property *property, in drm_property_add_enum() argument
396 return -EINVAL; in drm_property_add_enum()
398 if (WARN_ON(!drm_property_type_is(property, DRM_MODE_PROP_ENUM) && in drm_property_add_enum()
399 !drm_property_type_is(property, DRM_MODE_PROP_BITMASK))) in drm_property_add_enum()
400 return -EINVAL; in drm_property_add_enum()
406 if (WARN_ON(drm_property_type_is(property, DRM_MODE_PROP_BITMASK) && in drm_property_add_enum()
408 return -EINVAL; in drm_property_add_enum()
410 list_for_each_entry(prop_enum, &property->enum_list, head) { in drm_property_add_enum()
411 if (WARN_ON(prop_enum->value == value)) in drm_property_add_enum()
412 return -EINVAL; in drm_property_add_enum()
416 if (WARN_ON(index >= property->num_values)) in drm_property_add_enum()
417 return -EINVAL; in drm_property_add_enum()
421 return -ENOMEM; in drm_property_add_enum()
423 strscpy_pad(prop_enum->name, name, DRM_PROP_NAME_LEN); in drm_property_add_enum()
424 prop_enum->value = value; in drm_property_add_enum()
426 property->values[index] = value; in drm_property_add_enum()
427 list_add_tail(&prop_enum->head, &property->enum_list); in drm_property_add_enum()
433 * drm_property_destroy - destroy a drm property
435 * @property: property to destroy
437 * This function frees a property including any attached resources like
440 void drm_property_destroy(struct drm_device *dev, struct drm_property *property) in drm_property_destroy() argument
444 list_for_each_entry_safe(prop_enum, pt, &property->enum_list, head) { in drm_property_destroy()
445 list_del(&prop_enum->head); in drm_property_destroy()
449 if (property->num_values) in drm_property_destroy()
450 kfree(property->values); in drm_property_destroy()
451 drm_mode_object_unregister(dev, &property->base); in drm_property_destroy()
452 list_del(&property->head); in drm_property_destroy()
453 kfree(property); in drm_property_destroy()
461 struct drm_property *property; in drm_mode_getproperty_ioctl() local
470 return -EOPNOTSUPP; in drm_mode_getproperty_ioctl()
472 property = drm_property_find(dev, file_priv, out_resp->prop_id); in drm_mode_getproperty_ioctl()
473 if (!property) in drm_mode_getproperty_ioctl()
474 return -ENOENT; in drm_mode_getproperty_ioctl()
476 strscpy_pad(out_resp->name, property->name, DRM_PROP_NAME_LEN); in drm_mode_getproperty_ioctl()
477 out_resp->flags = property->flags; in drm_mode_getproperty_ioctl()
479 value_count = property->num_values; in drm_mode_getproperty_ioctl()
480 values_ptr = u64_to_user_ptr(out_resp->values_ptr); in drm_mode_getproperty_ioctl()
483 if (i < out_resp->count_values && in drm_mode_getproperty_ioctl()
484 put_user(property->values[i], values_ptr + i)) { in drm_mode_getproperty_ioctl()
485 return -EFAULT; in drm_mode_getproperty_ioctl()
488 out_resp->count_values = value_count; in drm_mode_getproperty_ioctl()
491 enum_ptr = u64_to_user_ptr(out_resp->enum_blob_ptr); in drm_mode_getproperty_ioctl()
493 if (drm_property_type_is(property, DRM_MODE_PROP_ENUM) || in drm_mode_getproperty_ioctl()
494 drm_property_type_is(property, DRM_MODE_PROP_BITMASK)) { in drm_mode_getproperty_ioctl()
495 list_for_each_entry(prop_enum, &property->enum_list, head) { in drm_mode_getproperty_ioctl()
497 if (out_resp->count_enum_blobs < enum_count) in drm_mode_getproperty_ioctl()
501 &prop_enum->value, sizeof(uint64_t))) in drm_mode_getproperty_ioctl()
502 return -EFAULT; in drm_mode_getproperty_ioctl()
505 &prop_enum->name, DRM_PROP_NAME_LEN)) in drm_mode_getproperty_ioctl()
506 return -EFAULT; in drm_mode_getproperty_ioctl()
509 out_resp->count_enum_blobs = enum_count; in drm_mode_getproperty_ioctl()
514 * property values. But nothing ever added them to the corresponding in drm_mode_getproperty_ioctl()
515 * list, userspace always used the special-purpose get_blob ioctl to in drm_mode_getproperty_ioctl()
516 * read the value for a blob property. It also doesn't make a lot of in drm_mode_getproperty_ioctl()
518 * the property itself. in drm_mode_getproperty_ioctl()
520 if (drm_property_type_is(property, DRM_MODE_PROP_BLOB)) in drm_mode_getproperty_ioctl()
521 out_resp->count_enum_blobs = 0; in drm_mode_getproperty_ioctl()
531 mutex_lock(&blob->dev->mode_config.blob_lock); in drm_property_free_blob()
532 list_del(&blob->head_global); in drm_property_free_blob()
533 mutex_unlock(&blob->dev->mode_config.blob_lock); in drm_property_free_blob()
535 drm_mode_object_unregister(blob->dev, &blob->base); in drm_property_free_blob()
541 * drm_property_create_blob - Create new blob property
542 * @dev: DRM device to create property for
546 * Creates a new blob property for a specified DRM device, optionally
548 * data must be filled out before the blob is used as the value of any property.
551 * New blob property with a single reference on success, or an ERR_PTR
561 if (!length || length > INT_MAX - sizeof(struct drm_property_blob)) in drm_property_create_blob()
562 return ERR_PTR(-EINVAL); in drm_property_create_blob()
566 return ERR_PTR(-ENOMEM); in drm_property_create_blob()
570 INIT_LIST_HEAD(&blob->head_file); in drm_property_create_blob()
571 blob->data = (void *)blob + sizeof(*blob); in drm_property_create_blob()
572 blob->length = length; in drm_property_create_blob()
573 blob->dev = dev; in drm_property_create_blob()
576 memcpy(blob->data, data, length); in drm_property_create_blob()
578 ret = __drm_mode_object_add(dev, &blob->base, DRM_MODE_OBJECT_BLOB, in drm_property_create_blob()
582 return ERR_PTR(-EINVAL); in drm_property_create_blob()
585 mutex_lock(&dev->mode_config.blob_lock); in drm_property_create_blob()
586 list_add_tail(&blob->head_global, in drm_property_create_blob()
587 &dev->mode_config.property_blob_list); in drm_property_create_blob()
588 mutex_unlock(&dev->mode_config.blob_lock); in drm_property_create_blob()
595 * drm_property_blob_put - release a blob property reference
596 * @blob: DRM blob property
598 * Releases a reference to a blob property. May free the object.
605 drm_mode_object_put(&blob->base); in drm_property_blob_put()
616 * blob list any more, so no need to grab dev->blob_lock. in drm_property_destroy_user_blobs()
618 list_for_each_entry_safe(blob, bt, &file_priv->blobs, head_file) { in drm_property_destroy_user_blobs()
619 list_del_init(&blob->head_file); in drm_property_destroy_user_blobs()
625 * drm_property_blob_get - acquire blob property reference
626 * @blob: DRM blob property
628 * Acquires a reference to an existing blob property. Returns @blob, which
633 drm_mode_object_get(&blob->base); in drm_property_blob_get()
639 * drm_property_lookup_blob - look up a blob property and take a reference
641 * @id: id of the blob property
643 * If successful, this takes an additional reference to the blob property.
644 * callers need to make sure to eventually unreferenced the returned property
664 * drm_property_replace_global_blob - replace existing blob property
666 * @replace: location of blob property pointer to be replaced
669 * @obj_holds_id: optional object for property holding blob ID
670 * @prop_holds_id: optional property holding blob ID
673 * This function will replace a global property in the blob list, optionally
674 * updating a property which holds the ID of that property.
677 * property, if specified, will be set to 0.
682 * For example, a drm_connector has a 'PATH' property, which contains the ID
683 * of a blob property with the value of the MST path information. Calling this
686 * base object, and prop_holds_id set to the path property name, will perform
715 new_blob->base.id : 0); in drm_property_replace_global_blob()
732 * drm_property_replace_blob - replace a blob property
738 bool drm_property_replace_blob(struct drm_property_blob **blob, in drm_property_replace_blob()
762 return -EOPNOTSUPP; in drm_mode_getblob_ioctl()
764 blob = drm_property_lookup_blob(dev, out_resp->blob_id); in drm_mode_getblob_ioctl()
766 return -ENOENT; in drm_mode_getblob_ioctl()
768 if (out_resp->length == blob->length) { in drm_mode_getblob_ioctl()
769 if (copy_to_user(u64_to_user_ptr(out_resp->data), in drm_mode_getblob_ioctl()
770 blob->data, in drm_mode_getblob_ioctl()
771 blob->length)) { in drm_mode_getblob_ioctl()
772 ret = -EFAULT; in drm_mode_getblob_ioctl()
776 out_resp->length = blob->length; in drm_mode_getblob_ioctl()
791 return -EOPNOTSUPP; in drm_mode_createblob_ioctl()
793 blob = drm_property_create_blob(dev, out_resp->length, NULL); in drm_mode_createblob_ioctl()
797 if (copy_from_user(blob->data, in drm_mode_createblob_ioctl()
798 u64_to_user_ptr(out_resp->data), in drm_mode_createblob_ioctl()
799 out_resp->length)) { in drm_mode_createblob_ioctl()
800 ret = -EFAULT; in drm_mode_createblob_ioctl()
807 mutex_lock(&dev->mode_config.blob_lock); in drm_mode_createblob_ioctl()
808 out_resp->blob_id = blob->base.id; in drm_mode_createblob_ioctl()
809 list_add_tail(&blob->head_file, &file_priv->blobs); in drm_mode_createblob_ioctl()
810 mutex_unlock(&dev->mode_config.blob_lock); in drm_mode_createblob_ioctl()
824 bool found = false; in drm_mode_destroyblob_ioctl()
828 return -EOPNOTSUPP; in drm_mode_destroyblob_ioctl()
830 blob = drm_property_lookup_blob(dev, out_resp->blob_id); in drm_mode_destroyblob_ioctl()
832 return -ENOENT; in drm_mode_destroyblob_ioctl()
834 mutex_lock(&dev->mode_config.blob_lock); in drm_mode_destroyblob_ioctl()
835 /* Ensure the property was actually created by this user. */ in drm_mode_destroyblob_ioctl()
836 list_for_each_entry(bt, &file_priv->blobs, head_file) { in drm_mode_destroyblob_ioctl()
844 ret = -EPERM; in drm_mode_destroyblob_ioctl()
850 list_del_init(&blob->head_file); in drm_mode_destroyblob_ioctl()
851 mutex_unlock(&dev->mode_config.blob_lock); in drm_mode_destroyblob_ioctl()
860 mutex_unlock(&dev->mode_config.blob_lock); in drm_mode_destroyblob_ioctl()
868 * value doesn't become invalid part way through the property update due to
870 * to drm_property_change_valid_put() after the property is set (and the
871 * object to which the property is attached has a chance to take its own
874 bool drm_property_change_valid_get(struct drm_property *property, in drm_property_change_valid_get() argument
879 if (property->flags & DRM_MODE_PROP_IMMUTABLE) in drm_property_change_valid_get()
884 if (drm_property_type_is(property, DRM_MODE_PROP_RANGE)) { in drm_property_change_valid_get()
885 if (value < property->values[0] || value > property->values[1]) in drm_property_change_valid_get()
888 } else if (drm_property_type_is(property, DRM_MODE_PROP_SIGNED_RANGE)) { in drm_property_change_valid_get()
891 if (svalue < U642I64(property->values[0]) || in drm_property_change_valid_get()
892 svalue > U642I64(property->values[1])) in drm_property_change_valid_get()
895 } else if (drm_property_type_is(property, DRM_MODE_PROP_BITMASK)) { in drm_property_change_valid_get()
898 for (i = 0; i < property->num_values; i++) in drm_property_change_valid_get()
899 valid_mask |= (1ULL << property->values[i]); in drm_property_change_valid_get()
901 } else if (drm_property_type_is(property, DRM_MODE_PROP_BLOB)) { in drm_property_change_valid_get()
907 blob = drm_property_lookup_blob(property->dev, value); in drm_property_change_valid_get()
909 *ref = &blob->base; in drm_property_change_valid_get()
914 } else if (drm_property_type_is(property, DRM_MODE_PROP_OBJECT)) { in drm_property_change_valid_get()
915 /* a zero value for an object property translates to null: */ in drm_property_change_valid_get()
919 *ref = __drm_mode_object_find(property->dev, NULL, value, in drm_property_change_valid_get()
920 property->values[0]); in drm_property_change_valid_get()
924 for (i = 0; i < property->num_values; i++) in drm_property_change_valid_get()
925 if (property->values[i] == value) in drm_property_change_valid_get()
930 void drm_property_change_valid_put(struct drm_property *property, in drm_property_change_valid_put() argument
936 if (drm_property_type_is(property, DRM_MODE_PROP_OBJECT)) { in drm_property_change_valid_put()
938 } else if (drm_property_type_is(property, DRM_MODE_PROP_BLOB)) in drm_property_change_valid_put()