@@ -4382,6 +4382,17 @@ bool drm_property_change_valid_get(struct drm_property *property,
} else {
return false;
}
+ } else if (property->values[0] == DRM_MODE_OBJECT_MODE) {
+ struct drm_display_mode *mode;
+ mode = drm_mode_find(property->dev, value);
+ if (mode) {
+ drm_mode_reference(mode);
+ *ref = &mode->base;
+ return true;
+ } else {
+ return false;
+ }
+
} else {
return _object_find(property->dev, value, property->values[0]) != NULL;
}
@@ -4402,6 +4413,8 @@ void drm_property_change_valid_put(struct drm_property *property,
if (drm_property_type_is(property, DRM_MODE_PROP_OBJECT)) {
if (property->values[0] == DRM_MODE_OBJECT_FB)
drm_framebuffer_unreference(obj_to_fb(ref));
+ else if (property->values[0] == DRM_MODE_OBJECT_MODE)
+ drm_mode_destroy(property->dev, obj_to_mode(ref));
}
}
@@ -123,6 +123,13 @@ void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode)
}
EXPORT_SYMBOL(drm_mode_destroy);
+struct drm_display_mode *drm_mode_reference(struct drm_display_mode *mode)
+{
+ kref_get(&mode->refcount);
+ return mode;
+}
+EXPORT_SYMBOL(drm_mode_reference);
+
/**
* drm_mode_probed_add - add a mode to a connector's probed_mode list
* @connector: connector the new mode
@@ -881,6 +888,7 @@ void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *
*dst = *src;
dst->refcount = refcount;
+ dst->base.type = DRM_MODE_OBJECT_MODE;
dst->base.id = id;
dst->head = head;
}
@@ -188,6 +188,7 @@ struct drm_connector;
struct drm_cmdline_mode;
struct drm_display_mode *drm_mode_create(struct drm_device *dev);
+struct drm_display_mode *drm_mode_reference(struct drm_display_mode *mode);
void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode);
void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode);
void drm_mode_debug_printmodeline(const struct drm_display_mode *mode);
Does what it says on the box. Signed-off-by: Daniel Stone <daniels@collabora.com> --- drivers/gpu/drm/drm_crtc.c | 13 +++++++++++++ drivers/gpu/drm/drm_modes.c | 8 ++++++++ include/drm/drm_modes.h | 1 + 3 files changed, 22 insertions(+)