Skip to content

Commit a2511a5

Browse files
committed
drm/doc: Polish docs for drm_mode_object
I figured an overview section here is overkill, and better to just document the 2 structures themselves well enough. v2: Review from Archit: - Appease checkpatch in moved code. - Spelling fixes in the kerneldoc. Reviewed-by: Archit Taneja <architt@codeaurora.org> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/20160829082757.17913-5-daniel.vetter@ffwll.ch
1 parent f094d88 commit a2511a5

2 files changed

Lines changed: 60 additions & 7 deletions

File tree

‎drivers/gpu/drm/drm_mode_object.c‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void drm_mode_object_register(struct drm_device *dev,
9797
* for reference counted modeset objects like framebuffers.
9898
*/
9999
void drm_mode_object_unregister(struct drm_device *dev,
100-
struct drm_mode_object *object)
100+
struct drm_mode_object *object)
101101
{
102102
mutex_lock(&dev->mode_config.idr_mutex);
103103
if (object->id) {
@@ -152,7 +152,7 @@ EXPORT_SYMBOL(drm_mode_object_find);
152152
* drm_mode_object_unreference - decr the object refcnt
153153
* @obj: mode_object
154154
*
155-
* This functions decrements the object's refcount if it is a refcounted modeset
155+
* This function decrements the object's refcount if it is a refcounted modeset
156156
* object. It is a no-op on any other object. This is used to drop references
157157
* acquired with drm_mode_object_reference().
158158
*/
@@ -169,7 +169,7 @@ EXPORT_SYMBOL(drm_mode_object_unreference);
169169
* drm_mode_object_reference - incr the object refcnt
170170
* @obj: mode_object
171171
*
172-
* This functions increments the object's refcount if it is a refcounted modeset
172+
* This function increments the object's refcount if it is a refcounted modeset
173173
* object. It is a no-op on any other object. References should be dropped again
174174
* by calling drm_mode_object_unreference().
175175
*/
@@ -218,10 +218,16 @@ EXPORT_SYMBOL(drm_object_attach_property);
218218
* @property: property to set
219219
* @val: value the property should be set to
220220
*
221-
* This functions sets a given property on a given object. This function only
221+
* This function sets a given property on a given object. This function only
222222
* changes the software state of the property, it does not call into the
223223
* driver's ->set_property callback.
224224
*
225+
* Note that atomic drivers should not have any need to call this, the core will
226+
* ensure consistency of values reported back to userspace through the
227+
* appropriate ->atomic_get_property callback. Only legacy drivers should call
228+
* this function to update the tracked value (after clamping and other
229+
* restrictions have been applied).
230+
*
225231
* Returns:
226232
* Zero on success, error code on failure.
227233
*/
@@ -252,6 +258,9 @@ EXPORT_SYMBOL(drm_object_property_set_value);
252258
* value this might be out of sync with the hardware, depending upon the driver
253259
* and property.
254260
*
261+
* Atomic drivers should never call this function directly, the core will read
262+
* out property values through the various ->atomic_get_property callbacks.
263+
*
255264
* Returns:
256265
* Zero on success, error code on failure.
257266
*/

‎include/drm/drm_mode_object.h‎

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,28 @@
2727
struct drm_object_properties;
2828
struct drm_property;
2929

30+
/**
31+
* struct drm_mode_object - base structure for modeset objects
32+
* @id: userspace visible identifier
33+
* @type: type of the object, one of DRM_MODE_OBJECT\_\*
34+
* @properties: properties attached to this object, including values
35+
* @refcount: reference count for objects which with dynamic lifetime
36+
* @free_cb: free function callback, only set for objects with dynamic lifetime
37+
*
38+
* Base structure for modeset objects visible to userspace. Objects can be
39+
* looked up using drm_mode_object_find(). Besides basic uapi interface
40+
* properties like @id and @type it provides two services:
41+
*
42+
* - It tracks attached properties and their values. This is used by &drm_crtc,
43+
* &drm_plane and &drm_connector. Properties are attached by calling
44+
* drm_object_attach_property() before the object is visible to userspace.
45+
*
46+
* - For objects with dynamic lifetimes (as indicated by a non-NULL @free_cb) it
47+
* provides reference counting through drm_mode_object_reference() and
48+
* drm_mode_object_unreference(). This is used by &drm_framebuffer,
49+
* &drm_connector and &drm_property_blob. These objects provide specialized
50+
* reference counting wrappers.
51+
*/
3052
struct drm_mode_object {
3153
uint32_t id;
3254
uint32_t type;
@@ -36,16 +58,38 @@ struct drm_mode_object {
3658
};
3759

3860
#define DRM_OBJECT_MAX_PROPERTY 24
61+
/**
62+
* struct drm_object_properties - property tracking for &drm_mode_object
63+
*/
3964
struct drm_object_properties {
65+
/**
66+
* @count: number of valid properties, must be less than or equal to
67+
* DRM_OBJECT_MAX_PROPERTY.
68+
*/
69+
4070
int count;
41-
/* NOTE: if we ever start dynamically destroying properties (ie.
71+
/**
72+
* @properties: Array of pointers to &drm_property.
73+
*
74+
* NOTE: if we ever start dynamically destroying properties (ie.
4275
* not at drm_mode_config_cleanup() time), then we'd have to do
4376
* a better job of detaching property from mode objects to avoid
4477
* dangling property pointers:
4578
*/
4679
struct drm_property *properties[DRM_OBJECT_MAX_PROPERTY];
47-
/* do not read/write values directly, but use drm_object_property_get_value()
48-
* and drm_object_property_set_value():
80+
81+
/**
82+
* @values: Array to store the property values, matching @properties. Do
83+
* not read/write values directly, but use
84+
* drm_object_property_get_value() and drm_object_property_set_value().
85+
*
86+
* Note that atomic drivers do not store mutable properties in this
87+
* array, but only the decoded values in the corresponding state
88+
* structure. The decoding is done using the ->atomic_get_property and
89+
* ->atomic_set_property hooks of the corresponding object. Hence atomic
90+
* drivers should not use drm_object_property_set_value() and
91+
* drm_object_property_get_value() on mutable objects, i.e. those
92+
* without the DRM_MODE_PROP_IMMUTABLE flag set.
4993
*/
5094
uint64_t values[DRM_OBJECT_MAX_PROPERTY];
5195
};

0 commit comments

Comments
 (0)