From patchwork Thu Mar 19 04:33:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Stone X-Patchwork-Id: 6045961 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C54FCBF90F for ; Thu, 19 Mar 2015 04:34:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EDE49204B0 for ; Thu, 19 Mar 2015 04:34:16 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 00897204C9 for ; Thu, 19 Mar 2015 04:34:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 252026E964; Wed, 18 Mar 2015 21:34:12 -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 D29766E964 for ; Wed, 18 Mar 2015 21:34:10 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: daniels) with ESMTPSA id 705B5600EAE From: Daniel Stone To: dri-devel@lists.freedesktop.org Subject: [RFC PATCH 34/37] drm: atomic: Add MODE_ID property Date: Thu, 19 Mar 2015 04:33:33 +0000 Message-Id: <1426739616-10635-34-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 Atomic modesetting: now with modesetting support. Signed-off-by: Daniel Stone --- drivers/gpu/drm/drm_atomic.c | 35 ++++++++++++++++++++++++++++++++++- drivers/gpu/drm/drm_crtc.c | 7 +++++++ include/drm/drm_crtc.h | 1 + 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 5d3abe3..9085e04 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -179,6 +179,34 @@ void drm_atomic_state_free(struct drm_atomic_state *state) EXPORT_SYMBOL(drm_atomic_state_free); /** + * drm_atomic_set_mode_for_crtc - set mode for CRTC + * @crtc_state: atomic state object for the CRTC + * @mode: mode to use for the plane + * + * Changing the display mode for a CRTC requires us to grab a reference + * to the new mode and drop the reference to the old mode, if there is one. + * This function takes care of all these details besides updating the pointer + * in the state object itself. + */ +static void +drm_atomic_set_mode_for_crtc(struct drm_crtc_state *crtc_state, + struct drm_display_mode *mode) +{ + if (mode) + drm_mode_reference(mode); + if (crtc_state->mode) + drm_mode_destroy(crtc_state->crtc->dev, crtc_state->mode); + crtc_state->mode = mode; + + if (mode) + DRM_DEBUG_ATOMIC("Set [MODE:%d] for CRTC state %p\n", + mode->base.id, crtc_state); + else + DRM_DEBUG_ATOMIC("Set [NOMODE] for CRTC state %p\n", + crtc_state); +} + +/** * drm_atomic_get_crtc_state - get crtc state * @state: global atomic state object * @crtc: crtc to get state object for @@ -247,9 +275,12 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc, struct drm_device *dev = crtc->dev; struct drm_mode_config *config = &dev->mode_config; - /* FIXME: Mode prop is missing, which also controls ->enable. */ if (property == config->prop_active) state->active = val; + else if (property == config->prop_mode_id) { + struct drm_display_mode *mode = drm_mode_find(dev, val); + drm_atomic_set_mode_for_crtc(state, mode); + } else if (crtc->funcs->atomic_set_property) return crtc->funcs->atomic_set_property(crtc, state, property, val); else @@ -274,6 +305,8 @@ int drm_atomic_crtc_get_property(struct drm_crtc *crtc, if (property == config->prop_active) *val = state->active; + else if (property == config->prop_mode_id) + *val = (state->mode) ? state->mode->base.id : 0; else if (crtc->funcs->atomic_get_property) return crtc->funcs->atomic_get_property(crtc, state, property, val); else diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 3ef0332..c1b3801 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -683,6 +683,7 @@ int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc, if (drm_core_check_feature(dev, DRIVER_ATOMIC)) { drm_object_attach_property(&crtc->base, config->prop_active, 0); + drm_object_attach_property(&crtc->base, config->prop_mode_id, 0); } return 0; @@ -1429,6 +1430,12 @@ static int drm_mode_create_standard_properties(struct drm_device *dev) return -ENOMEM; dev->mode_config.prop_active = prop; + prop = drm_property_create_object(dev, DRM_MODE_PROP_ATOMIC, + "MODE_ID", DRM_MODE_OBJECT_MODE); + if (!prop) + return -ENOMEM; + dev->mode_config.prop_mode_id = prop; + return 0; } diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 3ab70a7..5c8cb25 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -1122,6 +1122,7 @@ struct drm_mode_config { struct drm_property *prop_fb_id; struct drm_property *prop_crtc_id; struct drm_property *prop_active; + struct drm_property *prop_mode_id; /* DVI-I properties */ struct drm_property *dvi_i_subconnector_property;