From patchwork Thu Mar 19 04:33:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Stone X-Patchwork-Id: 6045931 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5A7329F2A9 for ; Thu, 19 Mar 2015 04:34:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 80057204C9 for ; Thu, 19 Mar 2015 04:34:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id BA41C20465 for ; Thu, 19 Mar 2015 04:34:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 835626E961; Wed, 18 Mar 2015 21:34:07 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [93.93.135.160]) by gabe.freedesktop.org (Postfix) with ESMTP id 2D1236E97C for ; Wed, 18 Mar 2015 21:34:04 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: daniels) with ESMTPSA id DE2176007B0 From: Daniel Stone To: dri-devel@lists.freedesktop.org Subject: [RFC PATCH 29/37] drm: mode: Add drm_mode_reference Date: Thu, 19 Mar 2015 04:33:28 +0000 Message-Id: <1426739616-10635-29-git-send-email-daniels@collabora.com> X-Mailer: git-send-email 2.3.2 In-Reply-To: <1426739616-10635-1-git-send-email-daniels@collabora.com> References: <1426739556-10429-1-git-send-email-daniels@collabora.com> <1426739616-10635-1-git-send-email-daniels@collabora.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Does what it says on the box. Signed-off-by: Daniel Stone --- 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(+) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 90bf355..3ef0332 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -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)); } } diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index e87f547..86bb5c1 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -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; } diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h index 70a6c71..a8aaf4b 100644 --- a/include/drm/drm_modes.h +++ b/include/drm/drm_modes.h @@ -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);