From patchwork Thu Aug 2 01:08:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haneen Mohammed X-Patchwork-Id: 10553311 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 3E12215E2 for ; Thu, 2 Aug 2018 07:23:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 278C42AF7A for ; Thu, 2 Aug 2018 07:23:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BE462AF8B; Thu, 2 Aug 2018 07:23:59 +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 C42052AF7A for ; Thu, 2 Aug 2018 07:23:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3C2696E411; Thu, 2 Aug 2018 07:19:58 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl0-x243.google.com (mail-pl0-x243.google.com [IPv6:2607:f8b0:400e:c01::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0E65B6E4F1 for ; Thu, 2 Aug 2018 01:08:26 +0000 (UTC) Received: by mail-pl0-x243.google.com with SMTP id s17-v6so225851plp.7 for ; Wed, 01 Aug 2018 18:08:26 -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=4Ouw26Xh/8BxzZB8zATpqAb8c/m96kuLmknM9Vc1ECg=; b=ISvjclmw3duPBDOc41l46oQ/TkUIttLrG6LCbFAZykyUpnVEdT0CAQSSNqRESUGOWe /lqLPvRcPLEstuquReSf8cRBmmzEfUMiwZ3m/fTkXYOtwlfk1KfoIZvxLrMJdWNhrW1O ylm8KDUSCm261GBxDpmnBIBzgYDw/bZX+mNNyZj/mPMBiVdlVvqu0KQ6RqiAm1p/fPVh 3i86h0kIR51ongL0LbaAOft8ryery+4ASi8DYkWuCNmQPE++lMYh88FiXjH2sAz66Acl alhQ/kyLAJU7ZAfjLBBnwcYXGTu1gEdyYUdWmu8U55tPQMCLPq0jmPI44T4QPczkgdDj VsLQ== X-Gm-Message-State: AOUpUlH8X1DdK473kvzHoUPUpd3S6qwAQ6jif3tq66UWXF9685DqGXGL 5fFmaYfp2Nh+4QcZZWntvgaACveA X-Google-Smtp-Source: AAOMgpemD02sWxvlN/gsh1Sy7mPq9E7ykRqhx9SQBYd9sNrwOFGriin8cvLutx+TGgwBHRD/ZqsyvA== X-Received: by 2002:a17:902:8494:: with SMTP id c20-v6mr505224plo.336.1533172105350; Wed, 01 Aug 2018 18:08:25 -0700 (PDT) Received: from haneenDRM ([64.77.242.50]) by smtp.gmail.com with ESMTPSA id x2-v6sm410015pfi.166.2018.08.01.18.08.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Aug 2018 18:08:24 -0700 (PDT) Date: Thu, 2 Aug 2018 04:08:22 +0300 From: Haneen Mohammed To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 1/2] drm/vkms: Subclass plane state Message-ID: 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, 02 Aug 2018 07:19: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 | 11 ++++++++ drivers/gpu/drm/vkms/vkms_plane.c | 47 +++++++++++++++++++++++++++++-- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 75e52d61e65d..a1b206643c10 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_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 +71,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,