From patchwork Thu Jul 19 00:21:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haneen Mohammed X-Patchwork-Id: 10533723 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 868DE600F4 for ; Thu, 19 Jul 2018 07:07:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72C1228CDF for ; Thu, 19 Jul 2018 07:07:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65E7E293B0; Thu, 19 Jul 2018 07:07:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1150B28CDF for ; Thu, 19 Jul 2018 07:07:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3B52B6ECFF; Thu, 19 Jul 2018 07:04:49 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8E3A36E319 for ; Thu, 19 Jul 2018 00:21:38 +0000 (UTC) Received: by mail-wr1-x444.google.com with SMTP id s11-v6so6274352wra.13 for ; Wed, 18 Jul 2018 17:21:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=1TYjZRWYsIHyXUtMXs+L4WN3zhEDWvjK3OtjY64aZ+I=; b=e+BQzSUJYfBXw4mbz8Uld/cN8fZvAkqWzN482WtZns/v2pu5kDttnBGqyg5MvhhD5X 3EiexxFGUZ7sIK4j3ErDHoan45WnCS+I55Zr/6u0FrWVIhRjLqMX2EQ4wpUgDdxv7Vlj tHZCWrYkI6gBro80rNS4xW6AIFQydQkBexV3M+j+/22PHk0gtmFieW1ovjwHvtI2IktR NO/z4oPxDvTfxQV31KSk679ERweE+iwzdnA9ceCap0iCRtPvUieJ7GUBSuVuxP4cYK/n ZWXn2h9hXI9leCIbrjjnMRgknmFiZFwfhCxzlRouiJDXP5YDhLbZFaExJtGXLoTmaSZC gTlg== X-Gm-Message-State: AOUpUlHTxT9WR6OuC5t9kO4GItZSazqh6eN+n3Xs43XMRq9A5Ei0UITP DVD1/VjNA2gWKZf4SGsQ7TW8hDpP X-Google-Smtp-Source: AAOMgperfvMewSV2ZOXmPWiAVDFjWTVauBth7ih1ebfMhhcLkQM60S6GgiwxeesJgYT0R0oZy7oAEQ== X-Received: by 2002:adf:a31b:: with SMTP id c27-v6mr5467929wrb.189.1531959697009; Wed, 18 Jul 2018 17:21:37 -0700 (PDT) Received: from haneenDRM ([188.50.2.36]) by smtp.gmail.com with ESMTPSA id r17-v6sm6485016wrt.44.2018.07.18.17.21.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 18 Jul 2018 17:21:36 -0700 (PDT) Date: Thu, 19 Jul 2018 03:21:33 +0300 From: Haneen Mohammed To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 4/5] drm/vkms: subclass CRTC state Message-ID: <0043c9268f5e3ceb4c9140cb08128e86c96cc9de.1531955948.git.hamohammed.sa@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Mailman-Approved-At: Thu, 19 Jul 2018 07:03:43 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: hamohammed.sa@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Subclass CRTC state struct to enable storing driver's private state. This patch only adds the base drm_crtc_state struct and the atomic functions that handle it. Signed-off-by: Haneen Mohammed Reviewed-by: Daniel Vetter Reviewed-by: Sean Paul --- drivers/gpu/drm/vkms/vkms_crtc.c | 53 ++++++++++++++++++++++++++++++-- drivers/gpu/drm/vkms/vkms_drv.h | 11 +++++++ 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index 875fca662ac0..26babb85ca77 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -64,13 +64,60 @@ bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe, return true; } +static void vkms_atomic_crtc_reset(struct drm_crtc *crtc) +{ + struct vkms_crtc_state *vkms_state = NULL; + + if (crtc->state) { + vkms_state = to_vkms_crtc_state(crtc->state); + __drm_atomic_helper_crtc_destroy_state(crtc->state); + kfree(vkms_state); + crtc->state = NULL; + } + + vkms_state = kzalloc(sizeof(*vkms_state), GFP_KERNEL); + if (!vkms_state) + return; + + crtc->state = &vkms_state->base; + crtc->state->crtc = crtc; +} + +static struct drm_crtc_state * +vkms_atomic_crtc_duplicate_state(struct drm_crtc *crtc) +{ + struct vkms_crtc_state *vkms_state; + + if (WARN_ON(!crtc->state)) + return NULL; + + vkms_state = kzalloc(sizeof(*vkms_state), GFP_KERNEL); + if (!vkms_state) + return NULL; + + __drm_atomic_helper_crtc_duplicate_state(crtc, &vkms_state->base); + + return &vkms_state->base; +} + +static void vkms_atomic_crtc_destroy_state(struct drm_crtc *crtc, + struct drm_crtc_state *state) +{ + struct vkms_crtc_state *vkms_state; + + vkms_state = to_vkms_crtc_state(state); + + __drm_atomic_helper_crtc_destroy_state(state); + kfree(vkms_state); +} + static const struct drm_crtc_funcs vkms_crtc_funcs = { .set_config = drm_atomic_helper_set_config, .destroy = drm_crtc_cleanup, .page_flip = drm_atomic_helper_page_flip, - .reset = drm_atomic_helper_crtc_reset, - .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, - .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, + .reset = vkms_atomic_crtc_reset, + .atomic_duplicate_state = vkms_atomic_crtc_duplicate_state, + .atomic_destroy_state = vkms_atomic_crtc_destroy_state, .enable_vblank = vkms_enable_vblank, .disable_vblank = vkms_disable_vblank, }; diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 47048f707566..75e52d61e65d 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -20,6 +20,14 @@ static const u32 vkms_formats[] = { DRM_FORMAT_XRGB8888, }; +/** + * vkms_crtc_state - Driver specific CRTC state + * @base: base CRTC state + */ +struct vkms_crtc_state { + struct drm_crtc_state base; +}; + struct vkms_output { struct drm_crtc crtc; struct drm_encoder encoder; @@ -52,6 +60,9 @@ struct vkms_gem_object { #define drm_gem_to_vkms_gem(target)\ container_of(target, struct vkms_gem_object, gem) +#define to_vkms_crtc_state(target)\ + container_of(target, struct vkms_crtc_state, base) + /* CRTC */ int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, struct drm_plane *primary, struct drm_plane *cursor);