From patchwork Sat Jul 28 09:11:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haneen Mohammed X-Patchwork-Id: 10547977 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 586F0139A for ; Sat, 28 Jul 2018 13:24:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 474E22B34E for ; Sat, 28 Jul 2018 13:24:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39B8A2B793; Sat, 28 Jul 2018 13:24:51 +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 E27002B34E for ; Sat, 28 Jul 2018 13:24:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A01E26E2AA; Sat, 28 Jul 2018 13:24:15 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1B9636E063 for ; Sat, 28 Jul 2018 09:11:12 +0000 (UTC) Received: by mail-pg1-x541.google.com with SMTP id z8-v6so4555863pgu.8 for ; Sat, 28 Jul 2018 02:11:12 -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=KE5EK5QssnHkws6xULAm3sFqggjNn1PHnLxH8LZQy+M=; b=F/5FnaYSZq5B2zOmoBgAv0UTziF970qbAJ5gA9Q5MKobvWgdvtMCJRmU0yo6XauU0J lHRlUjzWhKkj3JyllmDisqJD8eBEQt08zBJ3GNxS4M/xsPoqcZIXpQAFwk0IOQUYK8vq PxNkPMXwjeMEShbqcbsviJBg7jx/KGBpZCdB6//F/J7MpdotOA0E8MHuG2dH+RtHFps/ FXZvhMHHjcTSxG52F4A+zEkptDK7quIIcpJIeX4EaVa3jkLSBgp18MG9P9woj4WTelZg VkC04jzvSjwukcz9Cdpekq5VdXaHFMHNmR572aAdFBmpdk3JCK7fpAbASZMpkte76eQS Hxag== X-Gm-Message-State: AOUpUlG0nTD14jRP/VkQh0fk8lGaFfXLTDcxnXr+EAEtCyJHMKqlIMeb vPWmX8rvqnm+JE3+lvbT+RUPhWjf X-Google-Smtp-Source: AAOMgpeKLHiLnW1SEdC/9QtqOqVrbV8rjeUxtWpW1228l9E1KJWWrPvXwwYs/4kJXLgB/FUnCejv3A== X-Received: by 2002:a62:6283:: with SMTP id w125-v6mr9965570pfb.108.1532769071483; Sat, 28 Jul 2018 02:11:11 -0700 (PDT) Received: from haneenDRM ([64.77.242.50]) by smtp.gmail.com with ESMTPSA id c1-v6sm8370270pfi.142.2018.07.28.02.11.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 28 Jul 2018 02:11:11 -0700 (PDT) Date: Sat, 28 Jul 2018 12:11:08 +0300 From: Haneen Mohammed To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/2] drm/vkms: Subclass plane state Message-ID: <698d87d7fea0f5574975d82c058291b6ae3dd8ce.1532767204.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: Sat, 28 Jul 2018 13:23:10 +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 plane state struct to enable storing driver's private state. This patch only adds the base drm_plane_state struct and the atomic functions that handle it. Signed-off-by: Haneen Mohammed Reviewed-by: Sean Paul --- drivers/gpu/drm/vkms/vkms_drv.h | 10 +++++++ drivers/gpu/drm/vkms/vkms_plane.c | 47 +++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 75e52d61e65d..aa2632ff5f06 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -20,6 +20,13 @@ static const u32 vkms_formats[] = { DRM_FORMAT_XRGB8888, }; +/* vkms_plane_state - Driver specific plane state + * @base: base plane state + */ +struct vkms_plane_state { + struct drm_plane_state base; +}; + /** * vkms_crtc_state - Driver specific CRTC state * @base: base CRTC state @@ -63,6 +70,9 @@ struct vkms_gem_object { #define to_vkms_crtc_state(target)\ container_of(target, struct vkms_crtc_state, base) +#define to_vkms_plane_state(target)\ + container_of(target, struct vkms_plane_state, base) + /* CRTC */ int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, struct drm_plane *primary, struct drm_plane *cursor); diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 8191940844e5..70fca22bc51b 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -12,13 +12,54 @@ #include #include +static struct drm_plane_state * +vkms_plane_duplicate_state(struct drm_plane *plane) +{ + struct vkms_plane_state *vkms_state; + + vkms_state = kzalloc(sizeof(*vkms_state), GFP_KERNEL); + if (!vkms_state) + return NULL; + + __drm_atomic_helper_plane_duplicate_state(plane, + &vkms_state->base); + + return &vkms_state->base; +} + +static void vkms_plane_destroy_state(struct drm_plane *plane, + struct drm_plane_state *old_state) +{ + struct vkms_plane_state *vkms_state = to_vkms_plane_state(old_state); + + __drm_atomic_helper_plane_destroy_state(old_state); + kfree(vkms_state); +} + +static void vkms_plane_reset(struct drm_plane *plane) +{ + struct vkms_plane_state *vkms_state; + + if (plane->state) + vkms_plane_destroy_state(plane, plane->state); + + vkms_state = kzalloc(sizeof(*vkms_state), GFP_KERNEL); + if (!vkms_state) { + DRM_ERROR("Cannot allocate vkms_plane_state\n"); + return; + } + + plane->state = &vkms_state->base; + plane->state->plane = plane; +} + static const struct drm_plane_funcs vkms_plane_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, .destroy = drm_plane_cleanup, - .reset = drm_atomic_helper_plane_reset, - .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, - .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, + .reset = vkms_plane_reset, + .atomic_duplicate_state = vkms_plane_duplicate_state, + .atomic_destroy_state = vkms_plane_destroy_state, }; static void vkms_primary_plane_update(struct drm_plane *plane,