From patchwork Tue Jul 24 16:31:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haneen Mohammed X-Patchwork-Id: 10543575 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C0EDF14E2 for ; Wed, 25 Jul 2018 07:06:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE17528C3A for ; Wed, 25 Jul 2018 07:06:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A26CC29441; Wed, 25 Jul 2018 07:06:01 +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 1A5BB28C3A for ; Wed, 25 Jul 2018 07:06:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B29CC6E639; Wed, 25 Jul 2018 07:05:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by gabe.freedesktop.org (Postfix) with ESMTPS id 18FA06E5C9 for ; Tue, 24 Jul 2018 16:31:08 +0000 (UTC) Received: by mail-pg1-x544.google.com with SMTP id y5-v6so3274417pgv.1 for ; Tue, 24 Jul 2018 09:31:08 -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=fN6QSkKpq/3C1wsxhtCyl7+1J0bsUlwY7oTN0+PTLAfcioQxGNxtwzWfOS1GOIb+8T IW7tmRW3Z4mf0FnPmc5jZIMlKTfzk6fICighh3WSCu1LPnrLXy+rcVWvE7er9z295Bp8 d6TcCVst3NRx14T20bbTGcKsYNng8mKtC4iZCZeqTSTvqDvG3h3IOPjbOFlrCPvgi7h5 qetf8eWXH07IzHPQjDd1ewQBzK26YtAPxzfwlvvbwByWPHIZwPBbUwun1ZkAVyoJ4Y6h MJsRluVryFtf/KYv3jifMD1rKAE+nX/BDSp3pY5QXculJltFDUjYRBy1KCDGtYeHzGEm FKGQ== X-Gm-Message-State: AOUpUlHAXv3Sq0GLtaGs4BBszIcM9ADjmFCUFVB747yrj8Ic6Jl1mQbV pFiWXzPwTQeF+q0hA4xo0xePpnvX X-Google-Smtp-Source: AAOMgpcmhERjqqafuzz8tXP702RNaLz2da6Ul62twcJ5WcS1UJ5oB3UcvFV8U+YJqXEHGHQMW0WKCA== X-Received: by 2002:a63:144b:: with SMTP id 11-v6mr17358274pgu.219.1532449867525; Tue, 24 Jul 2018 09:31:07 -0700 (PDT) Received: from haneenDRM ([64.77.242.50]) by smtp.gmail.com with ESMTPSA id c68-v6sm29711099pfj.51.2018.07.24.09.31.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Jul 2018 09:31:07 -0700 (PDT) Date: Tue, 24 Jul 2018 19:31:05 +0300 From: Haneen Mohammed To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 4/4] drm/vkms: subclass CRTC state Message-ID: <1f3564a5a0a6c4410c5d383c86a572ddda4818a8.1532446182.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: Wed, 25 Jul 2018 07:05:01 +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, rodrigosiqueiramelo@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);