• Home
  • Raw
  • Download

Lines Matching +full:int +full:- +full:property

35  * configuration from userspace to the kernel. Properties have a well-defined
38 * property types and ranges.
44 * Property values are only 64bit. To support bigger piles of data (like gamma
45 * tables, color correction matrices or large structures) a property can instead
49 * per-object mapping from those names to the property ID used in the atomic
50 * IOCTL and in the get/set property IOCTL.
77 * drm_property_create - create a new property type
79 * @flags: flags specifying the property type
80 * @name: name of the property
81 * @num_values: number of pre-defined values
83 * This creates a new generic drm property which can then be attached to a drm
84 * object with drm_object_attach_property(). The returned property object must
89 * A pointer to the newly created property on success, NULL on failure.
93 int num_values) in drm_property_create()
95 struct drm_property *property = NULL; in drm_property_create() local
96 int ret; in drm_property_create()
104 property = kzalloc(sizeof(struct drm_property), GFP_KERNEL); in drm_property_create()
105 if (!property) in drm_property_create()
108 property->dev = dev; in drm_property_create()
111 property->values = kcalloc(num_values, sizeof(uint64_t), in drm_property_create()
113 if (!property->values) in drm_property_create()
117 ret = drm_mode_object_add(dev, &property->base, DRM_MODE_OBJECT_PROPERTY); in drm_property_create()
121 property->flags = flags; in drm_property_create()
122 property->num_values = num_values; in drm_property_create()
123 INIT_LIST_HEAD(&property->enum_list); in drm_property_create()
125 strncpy(property->name, name, DRM_PROP_NAME_LEN); in drm_property_create()
126 property->name[DRM_PROP_NAME_LEN-1] = '\0'; in drm_property_create()
128 list_add_tail(&property->head, &dev->mode_config.property_list); in drm_property_create()
130 return property; in drm_property_create()
132 kfree(property->values); in drm_property_create()
133 kfree(property); in drm_property_create()
139 * drm_property_create_enum - create a new enumeration property type
141 * @flags: flags specifying the property type
142 * @name: name of the property
143 * @props: enumeration lists with property values
144 * @num_values: number of pre-defined values
146 * This creates a new generic drm property which can then be attached to a drm
147 * object with drm_object_attach_property(). The returned property object must
155 * A pointer to the newly created property on success, NULL on failure.
160 int num_values) in drm_property_create_enum()
162 struct drm_property *property; in drm_property_create_enum() local
163 int i, ret; in drm_property_create_enum()
167 property = drm_property_create(dev, flags, name, num_values); in drm_property_create_enum()
168 if (!property) in drm_property_create_enum()
172 ret = drm_property_add_enum(property, in drm_property_create_enum()
176 drm_property_destroy(dev, property); in drm_property_create_enum()
181 return property; in drm_property_create_enum()
186 * drm_property_create_bitmask - create a new bitmask property type
188 * @flags: flags specifying the property type
189 * @name: name of the property
190 * @props: enumeration lists with property bitflags
194 * This creates a new bitmask drm property which can then be attached to a drm
195 * object with drm_object_attach_property(). The returned property object must
200 * or'ed together combination of the predefined property bitflag values
203 * A pointer to the newly created property on success, NULL on failure.
208 int num_props, in drm_property_create_bitmask()
211 struct drm_property *property; in drm_property_create_bitmask() local
212 int i, ret; in drm_property_create_bitmask()
213 int num_values = hweight64(supported_bits); in drm_property_create_bitmask()
217 property = drm_property_create(dev, flags, name, num_values); in drm_property_create_bitmask()
218 if (!property) in drm_property_create_bitmask()
224 ret = drm_property_add_enum(property, in drm_property_create_bitmask()
228 drm_property_destroy(dev, property); in drm_property_create_bitmask()
233 return property; in drm_property_create_bitmask()
241 struct drm_property *property; in property_create_range() local
243 property = drm_property_create(dev, flags, name, 2); in property_create_range()
244 if (!property) in property_create_range()
247 property->values[0] = min; in property_create_range()
248 property->values[1] = max; in property_create_range()
250 return property; in property_create_range()
254 * drm_property_create_range - create a new unsigned ranged property type
256 * @flags: flags specifying the property type
257 * @name: name of the property
258 * @min: minimum value of the property
259 * @max: maximum value of the property
261 * This creates a new generic drm property which can then be attached to a drm
262 * object with drm_object_attach_property(). The returned property object must
270 * A pointer to the newly created property on success, NULL on failure.
282 * drm_property_create_signed_range - create a new signed ranged property type
284 * @flags: flags specifying the property type
285 * @name: name of the property
286 * @min: minimum value of the property
287 * @max: maximum value of the property
289 * This creates a new generic drm property which can then be attached to a drm
290 * object with drm_object_attach_property(). The returned property object must
298 * A pointer to the newly created property on success, NULL on failure.
310 * drm_property_create_object - create a new object property type
312 * @flags: flags specifying the property type
313 * @name: name of the property
316 * This creates a new generic drm property which can then be attached to a drm
317 * object with drm_object_attach_property(). The returned property object must
321 * Userspace is only allowed to set this to any property value of the given
325 * A pointer to the newly created property on success, NULL on failure.
331 struct drm_property *property; in drm_property_create_object() local
338 property = drm_property_create(dev, flags, name, 1); in drm_property_create_object()
339 if (!property) in drm_property_create_object()
342 property->values[0] = type; in drm_property_create_object()
344 return property; in drm_property_create_object()
349 * drm_property_create_bool - create a new boolean property type
351 * @flags: flags specifying the property type
352 * @name: name of the property
354 * This creates a new generic drm property which can then be attached to a drm
355 * object with drm_object_attach_property(). The returned property object must
359 * This is implemented as a ranged property with only {0, 1} as valid values.
362 * A pointer to the newly created property on success, NULL on failure.
372 * drm_property_add_enum - add a possible value to an enumeration property
373 * @property: enumeration property to change
377 * This functions adds enumerations to a property.
380 * to directly create the property with all enumerations already attached.
385 int drm_property_add_enum(struct drm_property *property, in drm_property_add_enum() argument
389 int index = 0; in drm_property_add_enum()
392 return -EINVAL; in drm_property_add_enum()
394 if (WARN_ON(!drm_property_type_is(property, DRM_MODE_PROP_ENUM) && in drm_property_add_enum()
395 !drm_property_type_is(property, DRM_MODE_PROP_BITMASK))) in drm_property_add_enum()
396 return -EINVAL; in drm_property_add_enum()
402 if (WARN_ON(drm_property_type_is(property, DRM_MODE_PROP_BITMASK) && in drm_property_add_enum()
404 return -EINVAL; in drm_property_add_enum()
406 list_for_each_entry(prop_enum, &property->enum_list, head) { in drm_property_add_enum()
407 if (WARN_ON(prop_enum->value == value)) in drm_property_add_enum()
408 return -EINVAL; in drm_property_add_enum()
412 if (WARN_ON(index >= property->num_values)) in drm_property_add_enum()
413 return -EINVAL; in drm_property_add_enum()
417 return -ENOMEM; in drm_property_add_enum()
419 strncpy(prop_enum->name, name, DRM_PROP_NAME_LEN); in drm_property_add_enum()
420 prop_enum->name[DRM_PROP_NAME_LEN-1] = '\0'; in drm_property_add_enum()
421 prop_enum->value = value; in drm_property_add_enum()
423 property->values[index] = value; in drm_property_add_enum()
424 list_add_tail(&prop_enum->head, &property->enum_list); in drm_property_add_enum()
430 * drm_property_destroy - destroy a drm property
432 * @property: property to destry
434 * This function frees a property including any attached resources like
437 void drm_property_destroy(struct drm_device *dev, struct drm_property *property) in drm_property_destroy() argument
441 list_for_each_entry_safe(prop_enum, pt, &property->enum_list, head) { in drm_property_destroy()
442 list_del(&prop_enum->head); in drm_property_destroy()
446 if (property->num_values) in drm_property_destroy()
447 kfree(property->values); in drm_property_destroy()
448 drm_mode_object_unregister(dev, &property->base); in drm_property_destroy()
449 list_del(&property->head); in drm_property_destroy()
450 kfree(property); in drm_property_destroy()
454 int drm_mode_getproperty_ioctl(struct drm_device *dev, in drm_mode_getproperty_ioctl()
458 struct drm_property *property; in drm_mode_getproperty_ioctl() local
459 int enum_count = 0; in drm_mode_getproperty_ioctl()
460 int value_count = 0; in drm_mode_getproperty_ioctl()
461 int i, copied; in drm_mode_getproperty_ioctl()
467 return -EINVAL; in drm_mode_getproperty_ioctl()
469 property = drm_property_find(dev, file_priv, out_resp->prop_id); in drm_mode_getproperty_ioctl()
470 if (!property) in drm_mode_getproperty_ioctl()
471 return -ENOENT; in drm_mode_getproperty_ioctl()
473 strncpy(out_resp->name, property->name, DRM_PROP_NAME_LEN); in drm_mode_getproperty_ioctl()
474 out_resp->name[DRM_PROP_NAME_LEN-1] = 0; in drm_mode_getproperty_ioctl()
475 out_resp->flags = property->flags; in drm_mode_getproperty_ioctl()
477 value_count = property->num_values; in drm_mode_getproperty_ioctl()
478 values_ptr = u64_to_user_ptr(out_resp->values_ptr); in drm_mode_getproperty_ioctl()
481 if (i < out_resp->count_values && in drm_mode_getproperty_ioctl()
482 put_user(property->values[i], values_ptr + i)) { in drm_mode_getproperty_ioctl()
483 return -EFAULT; in drm_mode_getproperty_ioctl()
486 out_resp->count_values = value_count; in drm_mode_getproperty_ioctl()
489 enum_ptr = u64_to_user_ptr(out_resp->enum_blob_ptr); in drm_mode_getproperty_ioctl()
491 if (drm_property_type_is(property, DRM_MODE_PROP_ENUM) || in drm_mode_getproperty_ioctl()
492 drm_property_type_is(property, DRM_MODE_PROP_BITMASK)) { in drm_mode_getproperty_ioctl()
493 list_for_each_entry(prop_enum, &property->enum_list, head) { in drm_mode_getproperty_ioctl()
495 if (out_resp->count_enum_blobs < enum_count) in drm_mode_getproperty_ioctl()
499 &prop_enum->value, sizeof(uint64_t))) in drm_mode_getproperty_ioctl()
500 return -EFAULT; in drm_mode_getproperty_ioctl()
503 &prop_enum->name, DRM_PROP_NAME_LEN)) in drm_mode_getproperty_ioctl()
504 return -EFAULT; in drm_mode_getproperty_ioctl()
507 out_resp->count_enum_blobs = enum_count; in drm_mode_getproperty_ioctl()
512 * property values. But nothing ever added them to the corresponding in drm_mode_getproperty_ioctl()
513 * list, userspace always used the special-purpose get_blob ioctl to in drm_mode_getproperty_ioctl()
514 * read the value for a blob property. It also doesn't make a lot of in drm_mode_getproperty_ioctl()
516 * the property itself. in drm_mode_getproperty_ioctl()
518 if (drm_property_type_is(property, DRM_MODE_PROP_BLOB)) in drm_mode_getproperty_ioctl()
519 out_resp->count_enum_blobs = 0; in drm_mode_getproperty_ioctl()
529 mutex_lock(&blob->dev->mode_config.blob_lock); in drm_property_free_blob()
530 list_del(&blob->head_global); in drm_property_free_blob()
531 mutex_unlock(&blob->dev->mode_config.blob_lock); in drm_property_free_blob()
533 drm_mode_object_unregister(blob->dev, &blob->base); in drm_property_free_blob()
539 * drm_property_create_blob - Create new blob property
540 * @dev: DRM device to create property for
544 * Creates a new blob property for a specified DRM device, optionally
546 * data must be filled out before the blob is used as the value of any property.
549 * New blob property with a single reference on success, or an ERR_PTR
557 int ret; in drm_property_create_blob()
559 if (!length || length > INT_MAX - sizeof(struct drm_property_blob)) in drm_property_create_blob()
560 return ERR_PTR(-EINVAL); in drm_property_create_blob()
564 return ERR_PTR(-ENOMEM); in drm_property_create_blob()
568 INIT_LIST_HEAD(&blob->head_file); in drm_property_create_blob()
569 blob->data = (void *)blob + sizeof(*blob); in drm_property_create_blob()
570 blob->length = length; in drm_property_create_blob()
571 blob->dev = dev; in drm_property_create_blob()
574 memcpy(blob->data, data, length); in drm_property_create_blob()
576 ret = __drm_mode_object_add(dev, &blob->base, DRM_MODE_OBJECT_BLOB, in drm_property_create_blob()
580 return ERR_PTR(-EINVAL); in drm_property_create_blob()
583 mutex_lock(&dev->mode_config.blob_lock); in drm_property_create_blob()
584 list_add_tail(&blob->head_global, in drm_property_create_blob()
585 &dev->mode_config.property_blob_list); in drm_property_create_blob()
586 mutex_unlock(&dev->mode_config.blob_lock); in drm_property_create_blob()
593 * drm_property_blob_put - release a blob property reference
594 * @blob: DRM blob property
596 * Releases a reference to a blob property. May free the object.
603 drm_mode_object_put(&blob->base); in drm_property_blob_put()
614 * blob list any more, so no need to grab dev->blob_lock. in drm_property_destroy_user_blobs()
616 list_for_each_entry_safe(blob, bt, &file_priv->blobs, head_file) { in drm_property_destroy_user_blobs()
617 list_del_init(&blob->head_file); in drm_property_destroy_user_blobs()
623 * drm_property_blob_get - acquire blob property reference
624 * @blob: DRM blob property
626 * Acquires a reference to an existing blob property. Returns @blob, which
631 drm_mode_object_get(&blob->base); in drm_property_blob_get()
637 * drm_property_lookup_blob - look up a blob property and take a reference
639 * @id: id of the blob property
641 * If successful, this takes an additional reference to the blob property.
642 * callers need to make sure to eventually unreference the returned property
662 * drm_property_replace_global_blob - replace existing blob property
664 * @replace: location of blob property pointer to be replaced
667 * @obj_holds_id: optional object for property holding blob ID
668 * @prop_holds_id: optional property holding blob ID
671 * This function will replace a global property in the blob list, optionally
672 * updating a property which holds the ID of that property.
675 * property, if specified, will be set to 0.
680 * For example, a drm_connector has a 'PATH' property, which contains the ID
681 * of a blob property with the value of the MST path information. Calling this
684 * base object, and prop_holds_id set to the path property name, will perform
688 int drm_property_replace_global_blob(struct drm_device *dev, in drm_property_replace_global_blob()
697 int ret; in drm_property_replace_global_blob()
713 new_blob->base.id : 0); in drm_property_replace_global_blob()
730 * drm_property_replace_blob - replace a blob property
752 int drm_mode_getblob_ioctl(struct drm_device *dev, in drm_mode_getblob_ioctl()
757 int ret = 0; in drm_mode_getblob_ioctl()
760 return -EINVAL; in drm_mode_getblob_ioctl()
762 blob = drm_property_lookup_blob(dev, out_resp->blob_id); in drm_mode_getblob_ioctl()
764 return -ENOENT; in drm_mode_getblob_ioctl()
766 if (out_resp->length == blob->length) { in drm_mode_getblob_ioctl()
767 if (copy_to_user(u64_to_user_ptr(out_resp->data), in drm_mode_getblob_ioctl()
768 blob->data, in drm_mode_getblob_ioctl()
769 blob->length)) { in drm_mode_getblob_ioctl()
770 ret = -EFAULT; in drm_mode_getblob_ioctl()
774 out_resp->length = blob->length; in drm_mode_getblob_ioctl()
781 int drm_mode_createblob_ioctl(struct drm_device *dev, in drm_mode_createblob_ioctl()
786 int ret = 0; in drm_mode_createblob_ioctl()
789 return -EINVAL; in drm_mode_createblob_ioctl()
791 blob = drm_property_create_blob(dev, out_resp->length, NULL); in drm_mode_createblob_ioctl()
795 if (copy_from_user(blob->data, in drm_mode_createblob_ioctl()
796 u64_to_user_ptr(out_resp->data), in drm_mode_createblob_ioctl()
797 out_resp->length)) { in drm_mode_createblob_ioctl()
798 ret = -EFAULT; in drm_mode_createblob_ioctl()
805 mutex_lock(&dev->mode_config.blob_lock); in drm_mode_createblob_ioctl()
806 out_resp->blob_id = blob->base.id; in drm_mode_createblob_ioctl()
807 list_add_tail(&blob->head_file, &file_priv->blobs); in drm_mode_createblob_ioctl()
808 mutex_unlock(&dev->mode_config.blob_lock); in drm_mode_createblob_ioctl()
817 int drm_mode_destroyblob_ioctl(struct drm_device *dev, in drm_mode_destroyblob_ioctl()
823 int ret = 0; in drm_mode_destroyblob_ioctl()
826 return -EINVAL; in drm_mode_destroyblob_ioctl()
828 blob = drm_property_lookup_blob(dev, out_resp->blob_id); in drm_mode_destroyblob_ioctl()
830 return -ENOENT; in drm_mode_destroyblob_ioctl()
832 mutex_lock(&dev->mode_config.blob_lock); in drm_mode_destroyblob_ioctl()
833 /* Ensure the property was actually created by this user. */ in drm_mode_destroyblob_ioctl()
834 list_for_each_entry(bt, &file_priv->blobs, head_file) { in drm_mode_destroyblob_ioctl()
842 ret = -EPERM; in drm_mode_destroyblob_ioctl()
848 list_del_init(&blob->head_file); in drm_mode_destroyblob_ioctl()
849 mutex_unlock(&dev->mode_config.blob_lock); in drm_mode_destroyblob_ioctl()
858 mutex_unlock(&dev->mode_config.blob_lock); in drm_mode_destroyblob_ioctl()
866 * value doesn't become invalid part way through the property update due to
868 * to drm_property_change_valid_put() after the property is set (and the
869 * object to which the property is attached has a chance to take it's own
872 bool drm_property_change_valid_get(struct drm_property *property, in drm_property_change_valid_get() argument
875 int i; in drm_property_change_valid_get()
877 if (property->flags & DRM_MODE_PROP_IMMUTABLE) in drm_property_change_valid_get()
882 if (drm_property_type_is(property, DRM_MODE_PROP_RANGE)) { in drm_property_change_valid_get()
883 if (value < property->values[0] || value > property->values[1]) in drm_property_change_valid_get()
886 } else if (drm_property_type_is(property, DRM_MODE_PROP_SIGNED_RANGE)) { in drm_property_change_valid_get()
889 if (svalue < U642I64(property->values[0]) || in drm_property_change_valid_get()
890 svalue > U642I64(property->values[1])) in drm_property_change_valid_get()
893 } else if (drm_property_type_is(property, DRM_MODE_PROP_BITMASK)) { in drm_property_change_valid_get()
896 for (i = 0; i < property->num_values; i++) in drm_property_change_valid_get()
897 valid_mask |= (1ULL << property->values[i]); in drm_property_change_valid_get()
899 } else if (drm_property_type_is(property, DRM_MODE_PROP_BLOB)) { in drm_property_change_valid_get()
905 blob = drm_property_lookup_blob(property->dev, value); in drm_property_change_valid_get()
907 *ref = &blob->base; in drm_property_change_valid_get()
912 } else if (drm_property_type_is(property, DRM_MODE_PROP_OBJECT)) { in drm_property_change_valid_get()
913 /* a zero value for an object property translates to null: */ in drm_property_change_valid_get()
917 *ref = __drm_mode_object_find(property->dev, NULL, value, in drm_property_change_valid_get()
918 property->values[0]); in drm_property_change_valid_get()
922 for (i = 0; i < property->num_values; i++) in drm_property_change_valid_get()
923 if (property->values[i] == value) in drm_property_change_valid_get()
928 void drm_property_change_valid_put(struct drm_property *property, in drm_property_change_valid_put() argument
934 if (drm_property_type_is(property, DRM_MODE_PROP_OBJECT)) { in drm_property_change_valid_put()
936 } else if (drm_property_type_is(property, DRM_MODE_PROP_BLOB)) in drm_property_change_valid_put()