Lines Matching +full:int +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.
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.
98 int num_values) in drm_property_create()
100 struct drm_property *property = NULL; in drm_property_create() local
101 int ret; in drm_property_create()
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 strncpy(property->name, name, DRM_PROP_NAME_LEN); in drm_property_create()
131 property->name[DRM_PROP_NAME_LEN-1] = '\0'; in drm_property_create()
133 list_add_tail(&property->head, &dev->mode_config.property_list); in drm_property_create()
135 return property; in drm_property_create()
137 kfree(property->values); in drm_property_create()
138 kfree(property); in drm_property_create()
144 * drm_property_create_enum - create a new enumeration property type
146 * @flags: flags specifying the property type
147 * @name: name of the property
148 * @props: enumeration lists with property values
149 * @num_values: number of pre-defined values
151 * This creates a new generic drm property which can then be attached to a drm
152 * object with drm_object_attach_property(). The returned property object must
160 * A pointer to the newly created property on success, NULL on failure.
165 int num_values) in drm_property_create_enum()
167 struct drm_property *property; in drm_property_create_enum() local
168 int i, ret; in drm_property_create_enum()
172 property = drm_property_create(dev, flags, name, num_values); in drm_property_create_enum()
173 if (!property) in drm_property_create_enum()
177 ret = drm_property_add_enum(property, in drm_property_create_enum()
181 drm_property_destroy(dev, property); in drm_property_create_enum()
186 return property; in drm_property_create_enum()
191 * drm_property_create_bitmask - create a new bitmask property type
193 * @flags: flags specifying the property type
194 * @name: name of the property
195 * @props: enumeration lists with property bitflags
199 * This creates a new bitmask drm property which can then be attached to a drm
200 * object with drm_object_attach_property(). The returned property object must
205 * or'ed together combination of the predefined property bitflag values
208 * A pointer to the newly created property on success, NULL on failure.
213 int num_props, in drm_property_create_bitmask()
216 struct drm_property *property; in drm_property_create_bitmask() local
217 int i, ret; in drm_property_create_bitmask()
218 int num_values = hweight64(supported_bits); in drm_property_create_bitmask()
222 property = drm_property_create(dev, flags, name, num_values); in drm_property_create_bitmask()
223 if (!property) in drm_property_create_bitmask()
229 ret = drm_property_add_enum(property, in drm_property_create_bitmask()
233 drm_property_destroy(dev, property); in drm_property_create_bitmask()
238 return property; in drm_property_create_bitmask()
246 struct drm_property *property; in property_create_range() local
248 property = drm_property_create(dev, flags, name, 2); in property_create_range()
249 if (!property) in property_create_range()
252 property->values[0] = min; in property_create_range()
253 property->values[1] = max; in property_create_range()
255 return property; in property_create_range()
259 * drm_property_create_range - create a new unsigned ranged property type
261 * @flags: flags specifying the property type
262 * @name: name of the property
263 * @min: minimum value of the property
264 * @max: maximum value of the property
266 * This creates a new generic drm property which can then be attached to a drm
267 * object with drm_object_attach_property(). The returned property object must
275 * A pointer to the newly created property on success, NULL on failure.
287 * drm_property_create_signed_range - create a new signed ranged property type
289 * @flags: flags specifying the property type
290 * @name: name of the property
291 * @min: minimum value of the property
292 * @max: maximum value of the property
294 * This creates a new generic drm property which can then be attached to a drm
295 * object with drm_object_attach_property(). The returned property object must
303 * A pointer to the newly created property on success, NULL on failure.
315 * drm_property_create_object - create a new object property type
317 * @flags: flags specifying the property type
318 * @name: name of the property
321 * This creates a new generic drm property which can then be attached to a drm
322 * object with drm_object_attach_property(). The returned property object must
326 * Userspace is only allowed to set this to any property value of the given
330 * A pointer to the newly created property on success, NULL on failure.
336 struct drm_property *property; in drm_property_create_object() local
343 property = drm_property_create(dev, flags, name, 1); in drm_property_create_object()
344 if (!property) in drm_property_create_object()
347 property->values[0] = type; in drm_property_create_object()
349 return property; in drm_property_create_object()
354 * drm_property_create_bool - create a new boolean property type
356 * @flags: flags specifying the property type
357 * @name: name of the property
359 * This creates a new generic drm property which can then be attached to a drm
360 * object with drm_object_attach_property(). The returned property object must
364 * This is implemented as a ranged property with only {0, 1} as valid values.
367 * A pointer to the newly created property on success, NULL on failure.
377 * drm_property_add_enum - add a possible value to an enumeration property
378 * @property: enumeration property to change
382 * This functions adds enumerations to a property.
385 * to directly create the property with all enumerations already attached.
390 int drm_property_add_enum(struct drm_property *property, in drm_property_add_enum() argument
394 int index = 0; in drm_property_add_enum()
397 return -EINVAL; in drm_property_add_enum()
399 if (WARN_ON(!drm_property_type_is(property, DRM_MODE_PROP_ENUM) && in drm_property_add_enum()
400 !drm_property_type_is(property, DRM_MODE_PROP_BITMASK))) in drm_property_add_enum()
401 return -EINVAL; in drm_property_add_enum()
407 if (WARN_ON(drm_property_type_is(property, DRM_MODE_PROP_BITMASK) && in drm_property_add_enum()
409 return -EINVAL; in drm_property_add_enum()
411 list_for_each_entry(prop_enum, &property->enum_list, head) { in drm_property_add_enum()
412 if (WARN_ON(prop_enum->value == value)) in drm_property_add_enum()
413 return -EINVAL; in drm_property_add_enum()
417 if (WARN_ON(index >= property->num_values)) in drm_property_add_enum()
418 return -EINVAL; in drm_property_add_enum()
422 return -ENOMEM; in drm_property_add_enum()
424 strncpy(prop_enum->name, name, DRM_PROP_NAME_LEN); in drm_property_add_enum()
425 prop_enum->name[DRM_PROP_NAME_LEN-1] = '\0'; in drm_property_add_enum()
426 prop_enum->value = value; in drm_property_add_enum()
428 property->values[index] = value; in drm_property_add_enum()
429 list_add_tail(&prop_enum->head, &property->enum_list); in drm_property_add_enum()
435 * drm_property_destroy - destroy a drm property
437 * @property: property to destry
439 * This function frees a property including any attached resources like
442 void drm_property_destroy(struct drm_device *dev, struct drm_property *property) in drm_property_destroy() argument
446 list_for_each_entry_safe(prop_enum, pt, &property->enum_list, head) { in drm_property_destroy()
447 list_del(&prop_enum->head); in drm_property_destroy()
451 if (property->num_values) in drm_property_destroy()
452 kfree(property->values); in drm_property_destroy()
453 drm_mode_object_unregister(dev, &property->base); in drm_property_destroy()
454 list_del(&property->head); in drm_property_destroy()
455 kfree(property); in drm_property_destroy()
459 int drm_mode_getproperty_ioctl(struct drm_device *dev, in drm_mode_getproperty_ioctl()
463 struct drm_property *property; in drm_mode_getproperty_ioctl() local
464 int enum_count = 0; in drm_mode_getproperty_ioctl()
465 int value_count = 0; in drm_mode_getproperty_ioctl()
466 int i, copied; in drm_mode_getproperty_ioctl()
472 return -EOPNOTSUPP; in drm_mode_getproperty_ioctl()
474 property = drm_property_find(dev, file_priv, out_resp->prop_id); in drm_mode_getproperty_ioctl()
475 if (!property) in drm_mode_getproperty_ioctl()
476 return -ENOENT; in drm_mode_getproperty_ioctl()
478 strncpy(out_resp->name, property->name, DRM_PROP_NAME_LEN); in drm_mode_getproperty_ioctl()
479 out_resp->name[DRM_PROP_NAME_LEN-1] = 0; in drm_mode_getproperty_ioctl()
480 out_resp->flags = property->flags; in drm_mode_getproperty_ioctl()
482 value_count = property->num_values; in drm_mode_getproperty_ioctl()
483 values_ptr = u64_to_user_ptr(out_resp->values_ptr); in drm_mode_getproperty_ioctl()
486 if (i < out_resp->count_values && in drm_mode_getproperty_ioctl()
487 put_user(property->values[i], values_ptr + i)) { in drm_mode_getproperty_ioctl()
488 return -EFAULT; in drm_mode_getproperty_ioctl()
491 out_resp->count_values = value_count; in drm_mode_getproperty_ioctl()
494 enum_ptr = u64_to_user_ptr(out_resp->enum_blob_ptr); in drm_mode_getproperty_ioctl()
496 if (drm_property_type_is(property, DRM_MODE_PROP_ENUM) || in drm_mode_getproperty_ioctl()
497 drm_property_type_is(property, DRM_MODE_PROP_BITMASK)) { in drm_mode_getproperty_ioctl()
498 list_for_each_entry(prop_enum, &property->enum_list, head) { in drm_mode_getproperty_ioctl()
500 if (out_resp->count_enum_blobs < enum_count) in drm_mode_getproperty_ioctl()
504 &prop_enum->value, sizeof(uint64_t))) in drm_mode_getproperty_ioctl()
505 return -EFAULT; in drm_mode_getproperty_ioctl()
508 &prop_enum->name, DRM_PROP_NAME_LEN)) in drm_mode_getproperty_ioctl()
509 return -EFAULT; in drm_mode_getproperty_ioctl()
512 out_resp->count_enum_blobs = enum_count; in drm_mode_getproperty_ioctl()
517 * property values. But nothing ever added them to the corresponding in drm_mode_getproperty_ioctl()
518 * list, userspace always used the special-purpose get_blob ioctl to in drm_mode_getproperty_ioctl()
519 * read the value for a blob property. It also doesn't make a lot of in drm_mode_getproperty_ioctl()
521 * the property itself. in drm_mode_getproperty_ioctl()
523 if (drm_property_type_is(property, DRM_MODE_PROP_BLOB)) in drm_mode_getproperty_ioctl()
524 out_resp->count_enum_blobs = 0; in drm_mode_getproperty_ioctl()
534 mutex_lock(&blob->dev->mode_config.blob_lock); in drm_property_free_blob()
535 list_del(&blob->head_global); in drm_property_free_blob()
536 mutex_unlock(&blob->dev->mode_config.blob_lock); in drm_property_free_blob()
538 drm_mode_object_unregister(blob->dev, &blob->base); in drm_property_free_blob()
544 * drm_property_create_blob - Create new blob property
545 * @dev: DRM device to create property for
549 * Creates a new blob property for a specified DRM device, optionally
551 * data must be filled out before the blob is used as the value of any property.
554 * New blob property with a single reference on success, or an ERR_PTR
562 int ret; in drm_property_create_blob()
564 if (!length || length > INT_MAX - sizeof(struct drm_property_blob)) in drm_property_create_blob()
565 return ERR_PTR(-EINVAL); in drm_property_create_blob()
569 return ERR_PTR(-ENOMEM); in drm_property_create_blob()
573 INIT_LIST_HEAD(&blob->head_file); in drm_property_create_blob()
574 blob->data = (void *)blob + sizeof(*blob); in drm_property_create_blob()
575 blob->length = length; in drm_property_create_blob()
576 blob->dev = dev; in drm_property_create_blob()
579 memcpy(blob->data, data, length); in drm_property_create_blob()
581 ret = __drm_mode_object_add(dev, &blob->base, DRM_MODE_OBJECT_BLOB, in drm_property_create_blob()
585 return ERR_PTR(-EINVAL); in drm_property_create_blob()
588 mutex_lock(&dev->mode_config.blob_lock); in drm_property_create_blob()
589 list_add_tail(&blob->head_global, in drm_property_create_blob()
590 &dev->mode_config.property_blob_list); in drm_property_create_blob()
591 mutex_unlock(&dev->mode_config.blob_lock); in drm_property_create_blob()
598 * drm_property_blob_put - release a blob property reference
599 * @blob: DRM blob property
601 * Releases a reference to a blob property. May free the object.
608 drm_mode_object_put(&blob->base); in drm_property_blob_put()
619 * blob list any more, so no need to grab dev->blob_lock. in drm_property_destroy_user_blobs()
621 list_for_each_entry_safe(blob, bt, &file_priv->blobs, head_file) { in drm_property_destroy_user_blobs()
622 list_del_init(&blob->head_file); in drm_property_destroy_user_blobs()
628 * drm_property_blob_get - acquire blob property reference
629 * @blob: DRM blob property
631 * Acquires a reference to an existing blob property. Returns @blob, which
636 drm_mode_object_get(&blob->base); in drm_property_blob_get()
642 * drm_property_lookup_blob - look up a blob property and take a reference
644 * @id: id of the blob property
646 * If successful, this takes an additional reference to the blob property.
647 * callers need to make sure to eventually unreference the returned property
667 * drm_property_replace_global_blob - replace existing blob property
669 * @replace: location of blob property pointer to be replaced
672 * @obj_holds_id: optional object for property holding blob ID
673 * @prop_holds_id: optional property holding blob ID
676 * This function will replace a global property in the blob list, optionally
677 * updating a property which holds the ID of that property.
680 * property, if specified, will be set to 0.
685 * For example, a drm_connector has a 'PATH' property, which contains the ID
686 * of a blob property with the value of the MST path information. Calling this
689 * base object, and prop_holds_id set to the path property name, will perform
693 int drm_property_replace_global_blob(struct drm_device *dev, in drm_property_replace_global_blob()
702 int ret; in drm_property_replace_global_blob()
718 new_blob->base.id : 0); in drm_property_replace_global_blob()
735 * drm_property_replace_blob - replace a blob property
757 int drm_mode_getblob_ioctl(struct drm_device *dev, in drm_mode_getblob_ioctl()
762 int ret = 0; in drm_mode_getblob_ioctl()
765 return -EOPNOTSUPP; in drm_mode_getblob_ioctl()
767 blob = drm_property_lookup_blob(dev, out_resp->blob_id); in drm_mode_getblob_ioctl()
769 return -ENOENT; in drm_mode_getblob_ioctl()
771 if (out_resp->length == blob->length) { in drm_mode_getblob_ioctl()
772 if (copy_to_user(u64_to_user_ptr(out_resp->data), in drm_mode_getblob_ioctl()
773 blob->data, in drm_mode_getblob_ioctl()
774 blob->length)) { in drm_mode_getblob_ioctl()
775 ret = -EFAULT; in drm_mode_getblob_ioctl()
779 out_resp->length = blob->length; in drm_mode_getblob_ioctl()
786 int drm_mode_createblob_ioctl(struct drm_device *dev, in drm_mode_createblob_ioctl()
791 int ret = 0; in drm_mode_createblob_ioctl()
794 return -EOPNOTSUPP; in drm_mode_createblob_ioctl()
796 blob = drm_property_create_blob(dev, out_resp->length, NULL); in drm_mode_createblob_ioctl()
800 if (copy_from_user(blob->data, in drm_mode_createblob_ioctl()
801 u64_to_user_ptr(out_resp->data), in drm_mode_createblob_ioctl()
802 out_resp->length)) { in drm_mode_createblob_ioctl()
803 ret = -EFAULT; in drm_mode_createblob_ioctl()
810 mutex_lock(&dev->mode_config.blob_lock); in drm_mode_createblob_ioctl()
811 out_resp->blob_id = blob->base.id; in drm_mode_createblob_ioctl()
812 list_add_tail(&blob->head_file, &file_priv->blobs); in drm_mode_createblob_ioctl()
813 mutex_unlock(&dev->mode_config.blob_lock); in drm_mode_createblob_ioctl()
822 int drm_mode_destroyblob_ioctl(struct drm_device *dev, in drm_mode_destroyblob_ioctl()
828 int ret = 0; in drm_mode_destroyblob_ioctl()
831 return -EOPNOTSUPP; in drm_mode_destroyblob_ioctl()
833 blob = drm_property_lookup_blob(dev, out_resp->blob_id); in drm_mode_destroyblob_ioctl()
835 return -ENOENT; in drm_mode_destroyblob_ioctl()
837 mutex_lock(&dev->mode_config.blob_lock); in drm_mode_destroyblob_ioctl()
838 /* Ensure the property was actually created by this user. */ in drm_mode_destroyblob_ioctl()
839 list_for_each_entry(bt, &file_priv->blobs, head_file) { in drm_mode_destroyblob_ioctl()
847 ret = -EPERM; in drm_mode_destroyblob_ioctl()
853 list_del_init(&blob->head_file); in drm_mode_destroyblob_ioctl()
854 mutex_unlock(&dev->mode_config.blob_lock); in drm_mode_destroyblob_ioctl()
863 mutex_unlock(&dev->mode_config.blob_lock); in drm_mode_destroyblob_ioctl()
871 * value doesn't become invalid part way through the property update due to
873 * to drm_property_change_valid_put() after the property is set (and the
874 * object to which the property is attached has a chance to take its own
877 bool drm_property_change_valid_get(struct drm_property *property, in drm_property_change_valid_get() argument
880 int i; in drm_property_change_valid_get()
882 if (property->flags & DRM_MODE_PROP_IMMUTABLE) in drm_property_change_valid_get()
887 if (drm_property_type_is(property, DRM_MODE_PROP_RANGE)) { in drm_property_change_valid_get()
888 if (value < property->values[0] || value > property->values[1]) in drm_property_change_valid_get()
891 } else if (drm_property_type_is(property, DRM_MODE_PROP_SIGNED_RANGE)) { in drm_property_change_valid_get()
894 if (svalue < U642I64(property->values[0]) || in drm_property_change_valid_get()
895 svalue > U642I64(property->values[1])) in drm_property_change_valid_get()
898 } else if (drm_property_type_is(property, DRM_MODE_PROP_BITMASK)) { in drm_property_change_valid_get()
901 for (i = 0; i < property->num_values; i++) in drm_property_change_valid_get()
902 valid_mask |= (1ULL << property->values[i]); in drm_property_change_valid_get()
904 } else if (drm_property_type_is(property, DRM_MODE_PROP_BLOB)) { in drm_property_change_valid_get()
910 blob = drm_property_lookup_blob(property->dev, value); in drm_property_change_valid_get()
912 *ref = &blob->base; in drm_property_change_valid_get()
917 } else if (drm_property_type_is(property, DRM_MODE_PROP_OBJECT)) { in drm_property_change_valid_get()
918 /* a zero value for an object property translates to null: */ in drm_property_change_valid_get()
922 *ref = __drm_mode_object_find(property->dev, NULL, value, in drm_property_change_valid_get()
923 property->values[0]); in drm_property_change_valid_get()
927 for (i = 0; i < property->num_values; i++) in drm_property_change_valid_get()
928 if (property->values[i] == value) in drm_property_change_valid_get()
933 void drm_property_change_valid_put(struct drm_property *property, in drm_property_change_valid_put() argument
939 if (drm_property_type_is(property, DRM_MODE_PROP_OBJECT)) { in drm_property_change_valid_put()
941 } else if (drm_property_type_is(property, DRM_MODE_PROP_BLOB)) in drm_property_change_valid_put()