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 identifier
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_mode_object_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_prop_value(struct drm_mode_object *obj, in __drm_object_property_get_prop_value()
301 struct drm_property *property, in __drm_object_property_get_prop_value() argument
304 int i; in __drm_object_property_get_prop_value()
306 for (i = 0; i < obj->properties->count; i++) { in __drm_object_property_get_prop_value()
307 if (obj->properties->properties[i] == property) { in __drm_object_property_get_prop_value()
308 *val = obj->properties->values[i]; in __drm_object_property_get_prop_value()
313 return -EINVAL; in __drm_object_property_get_prop_value()
316 static int __drm_object_property_get_value(struct drm_mode_object *obj, in __drm_object_property_get_value()
317 struct drm_property *property, in __drm_object_property_get_value() argument
321 /* read-only properties bypass atomic mechanism and still store in __drm_object_property_get_value()
322 * their value in obj->properties->values[].. mostly to avoid in __drm_object_property_get_value()
325 if (drm_drv_uses_atomic_modeset(property->dev) && in __drm_object_property_get_value()
326 !(property->flags & DRM_MODE_PROP_IMMUTABLE)) in __drm_object_property_get_value()
327 return drm_atomic_get_property(obj, property, val); in __drm_object_property_get_value()
329 return __drm_object_property_get_prop_value(obj, property, val); in __drm_object_property_get_value()
333 * drm_object_property_get_value - retrieve the value of a property
334 * @obj: drm mode object to get property value from
335 * @property: property to retrieve
336 * @val: storage for the property value
338 * This function retrieves the softare state of the given property for the given
339 * property. Since there is no driver callback to retrieve the current property
341 * and property.
344 * out property values through the various ->atomic_get_property callbacks.
349 int drm_object_property_get_value(struct drm_mode_object *obj, in drm_object_property_get_value()
350 struct drm_property *property, uint64_t *val) in drm_object_property_get_value() argument
352 WARN_ON(drm_drv_uses_atomic_modeset(property->dev)); in drm_object_property_get_value()
354 return __drm_object_property_get_value(obj, property, val); in drm_object_property_get_value()
359 * drm_object_property_get_default_value - retrieve the default value of a
360 * property when in atomic mode.
361 * @obj: drm mode object to get property value from
362 * @property: property to retrieve
363 * @val: storage for the property value
365 * This function retrieves the default state of the given property as passed in
368 * Only atomic drivers should call this function directly, as for non-atomic
374 int drm_object_property_get_default_value(struct drm_mode_object *obj, in drm_object_property_get_default_value()
375 struct drm_property *property, in drm_object_property_get_default_value() argument
378 WARN_ON(!drm_drv_uses_atomic_modeset(property->dev)); in drm_object_property_get_default_value()
380 return __drm_object_property_get_prop_value(obj, property, val); in drm_object_property_get_default_value()
385 int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic, in drm_mode_object_get_properties()
390 int i, ret, count; in drm_mode_object_get_properties()
392 for (i = 0, count = 0; i < obj->properties->count; i++) { in drm_mode_object_get_properties()
393 struct drm_property *prop = obj->properties->properties[i]; in drm_mode_object_get_properties()
396 if ((prop->flags & DRM_MODE_PROP_ATOMIC) && !atomic) in drm_mode_object_get_properties()
404 if (put_user(prop->base.id, prop_ptr + count)) in drm_mode_object_get_properties()
405 return -EFAULT; in drm_mode_object_get_properties()
408 return -EFAULT; in drm_mode_object_get_properties()
419 * drm_mode_obj_get_properties_ioctl - get the current value of a object's property
424 * This function retrieves the current value for an object's property. Compared
433 int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data, in drm_mode_obj_get_properties_ioctl()
439 int ret = 0; in drm_mode_obj_get_properties_ioctl()
442 return -EOPNOTSUPP; in drm_mode_obj_get_properties_ioctl()
446 obj = drm_mode_object_find(dev, file_priv, arg->obj_id, arg->obj_type); in drm_mode_obj_get_properties_ioctl()
448 ret = -ENOENT; in drm_mode_obj_get_properties_ioctl()
451 if (!obj->properties) { in drm_mode_obj_get_properties_ioctl()
452 ret = -EINVAL; in drm_mode_obj_get_properties_ioctl()
456 ret = drm_mode_object_get_properties(obj, file_priv->atomic, in drm_mode_obj_get_properties_ioctl()
457 (uint32_t __user *)(unsigned long)(arg->props_ptr), in drm_mode_obj_get_properties_ioctl()
458 (uint64_t __user *)(unsigned long)(arg->prop_values_ptr), in drm_mode_obj_get_properties_ioctl()
459 &arg->count_props); in drm_mode_obj_get_properties_ioctl()
471 int i; in drm_mode_obj_find_prop_id()
473 for (i = 0; i < obj->properties->count; i++) in drm_mode_obj_find_prop_id()
474 if (obj->properties->properties[i]->base.id == prop_id) in drm_mode_obj_find_prop_id()
475 return obj->properties->properties[i]; in drm_mode_obj_find_prop_id()
480 static int set_property_legacy(struct drm_mode_object *obj, in set_property_legacy()
484 struct drm_device *dev = prop->dev; in set_property_legacy()
487 int ret = -EINVAL; in set_property_legacy()
490 return -EINVAL; in set_property_legacy()
493 switch (obj->type) { in set_property_legacy()
511 static int set_property_atomic(struct drm_mode_object *obj, in set_property_atomic()
516 struct drm_device *dev = prop->dev; in set_property_atomic()
519 int ret; in set_property_atomic()
523 return -ENOMEM; in set_property_atomic()
526 state->acquire_ctx = &ctx; in set_property_atomic()
529 if (prop == state->dev->mode_config.dpms_property) { in set_property_atomic()
530 if (obj->type != DRM_MODE_OBJECT_CONNECTOR) { in set_property_atomic()
531 ret = -EINVAL; in set_property_atomic()
545 if (ret == -EDEADLK) { in set_property_atomic()
559 int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data, in drm_mode_obj_set_property_ioctl()
564 struct drm_property *property; in drm_mode_obj_set_property_ioctl() local
565 int ret = -EINVAL; in drm_mode_obj_set_property_ioctl()
568 return -EOPNOTSUPP; in drm_mode_obj_set_property_ioctl()
570 arg_obj = drm_mode_object_find(dev, file_priv, arg->obj_id, arg->obj_type); in drm_mode_obj_set_property_ioctl()
572 return -ENOENT; in drm_mode_obj_set_property_ioctl()
574 if (!arg_obj->properties) in drm_mode_obj_set_property_ioctl()
577 property = drm_mode_obj_find_prop_id(arg_obj, arg->prop_id); in drm_mode_obj_set_property_ioctl()
578 if (!property) in drm_mode_obj_set_property_ioctl()
581 if (drm_drv_uses_atomic_modeset(property->dev)) in drm_mode_obj_set_property_ioctl()
582 ret = set_property_atomic(arg_obj, file_priv, property, arg->value); in drm_mode_obj_set_property_ioctl()
584 ret = set_property_legacy(arg_obj, property, arg->value); in drm_mode_obj_set_property_ioctl()