From patchwork Mon Jul 9 15:48:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haneen Mohammed X-Patchwork-Id: 10516221 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 7EDBF6020F for ; Tue, 10 Jul 2018 06:56:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D24328C13 for ; Tue, 10 Jul 2018 06:56:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60CD128C4D; Tue, 10 Jul 2018 06:56:41 +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 1989728C13 for ; Tue, 10 Jul 2018 06:56:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1103E6E7A3; Tue, 10 Jul 2018 06:55:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2F51D6E47F for ; Mon, 9 Jul 2018 15:48:41 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id w16-v6so21560158wmc.2 for ; Mon, 09 Jul 2018 08:48:41 -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=yH3iTsB12IIymYrRUHjOFRK929snanR9Pbhk3Tp8Fko=; b=pELGOPbxbN3+ZguogciMZQu0i4cfy6WKMqn4Y7uL6a9nMxQvkskRxM5lVrT2/S6FcM V92kRFIol6tV+BcOPKfhXa9K3GXtZK+qabyZrirXLID8628pAVbOGe5pFaH9Sm7zXsk/ ZB2MX0JQFPuFS9tYrs+b+GYcNHRn9nk7O4fZ1T0eT06mujcHnqR6axEIHlEBFaz4ffun 35Aq928RnhxO1n4+guece9Mcyo0aWG6fqLZGPKc5Fs/yGN/4/CKCRt4YQ+CHhprF8y1c it6/6/bO4r25xydL8qgTwfZ5KfEptSpcFGHBXVoucb8d5SqbgC8rrSgJOQwwrTh4gii1 Ni1w== X-Gm-Message-State: AOUpUlHEUpJKtSR0EfguV/63dRkt1IWlYRgB7KfOXlSzfz9uMvTPEdAu qMJu9wm+DbR5pbh+MgHKy2cCsTv1 X-Google-Smtp-Source: AAOMgpd72kurSelVeK4nPTDc5rSSvtmXcMb+g/9MDPitBzJpa7Dyq3vuFaTLj3d1gkIG012aQmlFtQ== X-Received: by 2002:a1c:5e48:: with SMTP id s69-v6mr1464204wmb.19.1531151319611; Mon, 09 Jul 2018 08:48:39 -0700 (PDT) Received: from haneen-vb ([78.191.177.254]) by smtp.gmail.com with ESMTPSA id z193-v6sm20816023wmc.14.2018.07.09.08.48.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jul 2018 08:48:39 -0700 (PDT) Date: Mon, 9 Jul 2018 18:48:36 +0300 From: Haneen Mohammed To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/4] drm/vkms: subclass CRTC state Message-ID: <81bbb86ef375ec82bf589e40358191db28dfb833.1531149873.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: Tue, 10 Jul 2018 06:55:25 +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 --- drivers/gpu/drm/vkms/vkms_crtc.c | 55 ++++++++++++++++++++++++++++++-- drivers/gpu/drm/vkms/vkms_drv.h | 8 +++++ 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index 84cc05506b09..56206437647d 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -10,13 +10,62 @@ #include #include +static void vkms_crtc_reset(struct drm_crtc *crtc) +{ + struct vkms_crtc_state *state = NULL; + + if (crtc->state) { + state = container_of(crtc->state, struct vkms_crtc_state, + base); + __drm_atomic_helper_crtc_destroy_state(crtc->state); + kfree(state); + crtc->state = NULL; + } + + state = kzalloc(sizeof(*state), GFP_KERNEL); + if (!state) + return; + + crtc->state = &state->base; + crtc->state->crtc = crtc; +} + +static struct drm_crtc_state * +vkms_crtc_duplicate_state(struct drm_crtc *crtc) +{ + struct vkms_crtc_state *state; + + if (WARN_ON(!crtc->state)) + return NULL; + + state = kzalloc(sizeof(*state), GFP_KERNEL); + if (!state) + return NULL; + + __drm_atomic_helper_crtc_duplicate_state(crtc, &state->base); + + return &state->base; +} + +static void vkms_crtc_destroy_state(struct drm_crtc *crtc, + struct drm_crtc_state *state) +{ + struct vkms_crtc_state *vkms_state; + + vkms_state = container_of(state, struct vkms_crtc_state, base); + + __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_crtc_reset, + .atomic_duplicate_state = vkms_crtc_duplicate_state, + .atomic_destroy_state = vkms_crtc_destroy_state, }; static int vkms_crtc_atomic_check(struct drm_crtc *crtc, diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index d339a8108d85..61e367d32308 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -19,6 +19,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;