Lines Matching +full:int +full:- +full:property
39 int __drm_mode_object_add(struct drm_device *dev, struct drm_mode_object *obj, in __drm_mode_object_add()
43 int ret; in __drm_mode_object_add()
45 WARN_ON(!dev->driver->load && dev->registered && !obj_free_cb); in __drm_mode_object_add()
47 mutex_lock(&dev->mode_config.idr_mutex); in __drm_mode_object_add()
48 ret = idr_alloc(&dev->mode_config.object_idr, register_obj ? obj : NULL, in __drm_mode_object_add()
55 obj->id = ret; in __drm_mode_object_add()
56 obj->type = obj_type; in __drm_mode_object_add()
58 obj->free_cb = obj_free_cb; in __drm_mode_object_add()
59 kref_init(&obj->refcount); in __drm_mode_object_add()
62 mutex_unlock(&dev->mode_config.idr_mutex); in __drm_mode_object_add()
68 * drm_mode_object_add - allocate a new modeset identifier
79 int drm_mode_object_add(struct drm_device *dev, in drm_mode_object_add()
88 mutex_lock(&dev->mode_config.idr_mutex); in drm_mode_object_register()
89 idr_replace(&dev->mode_config.object_idr, obj, obj->id); in drm_mode_object_register()
90 mutex_unlock(&dev->mode_config.idr_mutex); in drm_mode_object_register()
94 * drm_mode_object_unregister - free a modeset identifer
107 WARN_ON(!dev->driver->load && dev->registered && !object->free_cb); in drm_mode_object_unregister()
109 mutex_lock(&dev->mode_config.idr_mutex); in drm_mode_object_unregister()
110 if (object->id) { in drm_mode_object_unregister()
111 idr_remove(&dev->mode_config.object_idr, object->id); in drm_mode_object_unregister()
112 object->id = 0; in drm_mode_object_unregister()
114 mutex_unlock(&dev->mode_config.idr_mutex); in drm_mode_object_unregister()
118 * drm_lease_required - check types which must be leased to be used
142 mutex_lock(&dev->mode_config.idr_mutex); in __drm_mode_object_find()
143 obj = idr_find(&dev->mode_config.object_idr, id); in __drm_mode_object_find()
144 if (obj && type != DRM_MODE_OBJECT_ANY && obj->type != type) in __drm_mode_object_find()
146 if (obj && obj->id != id) in __drm_mode_object_find()
149 if (obj && drm_mode_object_lease_required(obj->type) && in __drm_mode_object_find()
150 !_drm_lease_held(file_priv, obj->id)) in __drm_mode_object_find()
153 if (obj && obj->free_cb) { in __drm_mode_object_find()
154 if (!kref_get_unless_zero(&obj->refcount)) in __drm_mode_object_find()
157 mutex_unlock(&dev->mode_config.idr_mutex); in __drm_mode_object_find()
163 * drm_mode_object_find - look up a drm object with static lifetime
185 * drm_mode_object_put - release a mode object reference
189 * object. It is a no-op on any other object. This is used to drop references
194 if (obj->free_cb) { in drm_mode_object_put()
195 DRM_DEBUG("OBJ ID: %d (%d)\n", obj->id, kref_read(&obj->refcount)); in drm_mode_object_put()
196 kref_put(&obj->refcount, obj->free_cb); in drm_mode_object_put()
202 * drm_mode_object_get - acquire a mode object reference
206 * object. It is a no-op on any other object. References should be dropped again
211 if (obj->free_cb) { in drm_mode_object_get()
212 DRM_DEBUG("OBJ ID: %d (%d)\n", obj->id, kref_read(&obj->refcount)); in drm_mode_object_get()
213 kref_get(&obj->refcount); in drm_mode_object_get()
219 * drm_object_attach_property - attach a property to a modeset object
221 * @property: property to attach
222 * @init_val: initial value of the property
224 * This attaches the given property to the modeset object with the given initial
232 struct drm_property *property, in drm_object_attach_property() argument
235 int count = obj->properties->count; in drm_object_attach_property()
236 struct drm_device *dev = property->dev; in drm_object_attach_property()
239 if (obj->type == DRM_MODE_OBJECT_CONNECTOR) { in drm_object_attach_property()
242 WARN_ON(!dev->driver->load && in drm_object_attach_property()
243 connector->registration_state == DRM_CONNECTOR_REGISTERED); in drm_object_attach_property()
245 WARN_ON(!dev->driver->load && dev->registered); in drm_object_attach_property()
249 WARN(1, "Failed to attach object property (type: 0x%x). Please " in drm_object_attach_property()
252 obj->type); in drm_object_attach_property()
256 obj->properties->properties[count] = property; in drm_object_attach_property()
257 obj->properties->values[count] = init_val; in drm_object_attach_property()
258 obj->properties->count++; in drm_object_attach_property()
263 * drm_object_property_set_value - set the value of a property
264 * @obj: drm mode object to set property value for
265 * @property: property to set
266 * @val: value the property should be set to
268 * This function sets a given property on a given object. This function only
269 * changes the software state of the property, it does not call into the
270 * driver's ->set_property callback.
274 * appropriate ->atomic_get_property callback. Only legacy drivers should call
281 int drm_object_property_set_value(struct drm_mode_object *obj, in drm_object_property_set_value()
282 struct drm_property *property, uint64_t val) in drm_object_property_set_value() argument
284 int i; in drm_object_property_set_value()
286 WARN_ON(drm_drv_uses_atomic_modeset(property->dev) && in drm_object_property_set_value()
287 !(property->flags & DRM_MODE_PROP_IMMUTABLE)); in drm_object_property_set_value()
289 for (i = 0; i < obj->properties->count; i++) { in drm_object_property_set_value()
290 if (obj->properties->properties[i] == property) { in drm_object_property_set_value()
291 obj->properties->values[i] = val; in drm_object_property_set_value()
296 return -EINVAL; in drm_object_property_set_value()
300 static int __drm_object_property_get_value(struct drm_mode_object *obj, in __drm_object_property_get_value()
301 struct drm_property *property, in __drm_object_property_get_value() argument
304 int i; in __drm_object_property_get_value()
306 /* read-only properties bypass atomic mechanism and still store in __drm_object_property_get_value()
307 * their value in obj->properties->values[].. mostly to avoid in __drm_object_property_get_value()
310 if (drm_drv_uses_atomic_modeset(property->dev) && in __drm_object_property_get_value()
311 !(property->flags & DRM_MODE_PROP_IMMUTABLE)) in __drm_object_property_get_value()
312 return drm_atomic_get_property(obj, property, val); in __drm_object_property_get_value()
314 for (i = 0; i < obj->properties->count; i++) { in __drm_object_property_get_value()
315 if (obj->properties->properties[i] == property) { in __drm_object_property_get_value()
316 *val = obj->properties->values[i]; in __drm_object_property_get_value()
322 return -EINVAL; in __drm_object_property_get_value()
326 * drm_object_property_get_value - retrieve the value of a property
327 * @obj: drm mode object to get property value from
328 * @property: property to retrieve
329 * @val: storage for the property value
331 * This function retrieves the softare state of the given property for the given
332 * property. Since there is no driver callback to retrieve the current property
334 * and property.
337 * out property values through the various ->atomic_get_property callbacks.
342 int drm_object_property_get_value(struct drm_mode_object *obj, in drm_object_property_get_value()
343 struct drm_property *property, uint64_t *val) in drm_object_property_get_value() argument
345 WARN_ON(drm_drv_uses_atomic_modeset(property->dev)); in drm_object_property_get_value()
347 return __drm_object_property_get_value(obj, property, val); in drm_object_property_get_value()
352 int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic, in drm_mode_object_get_properties()
357 int i, ret, count; in drm_mode_object_get_properties()
359 for (i = 0, count = 0; i < obj->properties->count; i++) { in drm_mode_object_get_properties()
360 struct drm_property *prop = obj->properties->properties[i]; in drm_mode_object_get_properties()
363 if ((prop->flags & DRM_MODE_PROP_ATOMIC) && !atomic) in drm_mode_object_get_properties()
371 if (put_user(prop->base.id, prop_ptr + count)) in drm_mode_object_get_properties()
372 return -EFAULT; in drm_mode_object_get_properties()
375 return -EFAULT; in drm_mode_object_get_properties()
386 * drm_mode_obj_get_properties_ioctl - get the current value of a object's property
391 * This function retrieves the current value for an object's property. Compared
400 int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data, in drm_mode_obj_get_properties_ioctl()
406 int ret = 0; in drm_mode_obj_get_properties_ioctl()
409 return -EOPNOTSUPP; in drm_mode_obj_get_properties_ioctl()
413 obj = drm_mode_object_find(dev, file_priv, arg->obj_id, arg->obj_type); in drm_mode_obj_get_properties_ioctl()
415 ret = -ENOENT; in drm_mode_obj_get_properties_ioctl()
418 if (!obj->properties) { in drm_mode_obj_get_properties_ioctl()
419 ret = -EINVAL; in drm_mode_obj_get_properties_ioctl()
423 ret = drm_mode_object_get_properties(obj, file_priv->atomic, in drm_mode_obj_get_properties_ioctl()
424 (uint32_t __user *)(unsigned long)(arg->props_ptr), in drm_mode_obj_get_properties_ioctl()
425 (uint64_t __user *)(unsigned long)(arg->prop_values_ptr), in drm_mode_obj_get_properties_ioctl()
426 &arg->count_props); in drm_mode_obj_get_properties_ioctl()
438 int i; in drm_mode_obj_find_prop_id()
440 for (i = 0; i < obj->properties->count; i++) in drm_mode_obj_find_prop_id()
441 if (obj->properties->properties[i]->base.id == prop_id) in drm_mode_obj_find_prop_id()
442 return obj->properties->properties[i]; in drm_mode_obj_find_prop_id()
447 static int set_property_legacy(struct drm_mode_object *obj, in set_property_legacy()
451 struct drm_device *dev = prop->dev; in set_property_legacy()
454 int ret = -EINVAL; in set_property_legacy()
457 return -EINVAL; in set_property_legacy()
460 switch (obj->type) { in set_property_legacy()
478 static int set_property_atomic(struct drm_mode_object *obj, in set_property_atomic()
483 struct drm_device *dev = prop->dev; in set_property_atomic()
486 int ret; in set_property_atomic()
490 return -ENOMEM; in set_property_atomic()
493 state->acquire_ctx = &ctx; in set_property_atomic()
496 if (prop == state->dev->mode_config.dpms_property) { in set_property_atomic()
497 if (obj->type != DRM_MODE_OBJECT_CONNECTOR) { in set_property_atomic()
498 ret = -EINVAL; in set_property_atomic()
512 if (ret == -EDEADLK) { in set_property_atomic()
526 int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data, in drm_mode_obj_set_property_ioctl()
531 struct drm_property *property; in drm_mode_obj_set_property_ioctl() local
532 int ret = -EINVAL; in drm_mode_obj_set_property_ioctl()
535 return -EOPNOTSUPP; in drm_mode_obj_set_property_ioctl()
537 arg_obj = drm_mode_object_find(dev, file_priv, arg->obj_id, arg->obj_type); in drm_mode_obj_set_property_ioctl()
539 return -ENOENT; in drm_mode_obj_set_property_ioctl()
541 if (!arg_obj->properties) in drm_mode_obj_set_property_ioctl()
544 property = drm_mode_obj_find_prop_id(arg_obj, arg->prop_id); in drm_mode_obj_set_property_ioctl()
545 if (!property) in drm_mode_obj_set_property_ioctl()
548 if (drm_drv_uses_atomic_modeset(property->dev)) in drm_mode_obj_set_property_ioctl()
549 ret = set_property_atomic(arg_obj, file_priv, property, arg->value); in drm_mode_obj_set_property_ioctl()
551 ret = set_property_legacy(arg_obj, property, arg->value); in drm_mode_obj_set_property_ioctl()