From patchwork Mon Dec 18 14:57:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 122221 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2936425qgn; Mon, 18 Dec 2017 06:58:29 -0800 (PST) X-Google-Smtp-Source: ACJfBotA+EiFBXi29Jl/9JSx/MmGXQ3U1z3lHfvqSZwmCVT0cLW+oZMOjcrzA75mFKGIcPkCeddc X-Received: by 10.98.92.194 with SMTP id q185mr105599pfb.115.1513609109159; Mon, 18 Dec 2017 06:58:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513609109; cv=none; d=google.com; s=arc-20160816; b=OtbHeCDGbEfX6T4MNj/L1aT2SpaFHjt8PepuZtvTugUId3VcQD4pCVLapCKuvES/l+ EgslbgyIcnLZ7Sph4LnLVkiwWW9pGqsQh/kSDpzPpRHPo0GOalZ4KwGysYly2+mH8P+g zLHj7AJvUIvDoSFTDNWPHeHR+iVoKTJPprvJamQwLskIASfVgVMf+59FeKDuXFOgcw8r B03cFX+cdT3PS+np5Olg3KEsplhQDUMqpjHtSvpAD+pIMqRcLxuRQPUqwEyO0lLpO1vb y4g3zgCId4tc+oDsR6WUrOo6V3WKfEfbebT7CEEYaAIZekCqbmJ6o6EQuXnMPcsjcHA6 PNDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Y53xYM6Ic6C7CqWwXr727H296mAfoZ0TH1PYqM31Lxw=; b=iUwhHRbjjsea4eN/ABFPeSrEhsnqRqCIxK3iLvuNC8BVrbjC1tRDazOHiCfipifELd HlgR3iuTxiBP8vjANktprhuf6c800Cm+/6xpc1yeaO/xHjNVP4vT8n39typs4vqDulkU i5lHN+tOv6L/zJlddKAXyDXCgWz1ndoiZk2GRAt3VvcylKmmn05YspHDKlKb4r91lKlf 9sIlWiYfReKJt2Ix798X/fz1/HjMIBGvI4dzA0Tl8ENw0Uy5zstuzUIW/nSRFEL+N0vw NqZ81DerMpIlO35Ec9hNq/KGcxg4VsiEt2w2/P/eKxmxw5k9QJ97zCragDnPrQ/7ayFC vgxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3si9386071pld.566.2017.12.18.06.58.28; Mon, 18 Dec 2017 06:58:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758773AbdLRO6M (ORCPT + 28 others); Mon, 18 Dec 2017 09:58:12 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:55283 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758543AbdLRO6G (ORCPT ); Mon, 18 Dec 2017 09:58:06 -0500 Received: by mail.free-electrons.com (Postfix, from userid 110) id 5878C20503; Mon, 18 Dec 2017 15:58:04 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 2B03520378; Mon, 18 Dec 2017 15:58:04 +0100 (CET) From: Maxime Ripard To: Daniel Vetter , David Airlie , Chen-Yu Tsai , Maxime Ripard Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Thomas Petazzoni , narmstrong@baylibre.com, thomas@vitsch.nl Subject: [PATCH v2 03/12] drm/sun4i: backend: Add a custom plane state Date: Mon, 18 Dec 2017 15:57:50 +0100 Message-Id: <9c850622d6328524094769ba1393e4c5891d4b7f.1513609024.git-series.maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We will need to store some additional data in the future to the state. Create a custom plane state that will embed those data, in order to store the pipe or whether or not that plane should use the frontend. Reviewed-by: Neil Armstrong Signed-off-by: Maxime Ripard --- drivers/gpu/drm/sun4i/sun4i_layer.c | 50 ++++++++++++++++++++++++++++-- drivers/gpu/drm/sun4i/sun4i_layer.h | 10 ++++++- 2 files changed, 57 insertions(+), 3 deletions(-) -- git-series 0.9.1 diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.c b/drivers/gpu/drm/sun4i/sun4i_layer.c index 7bddf12548d3..b85a9a02d166 100644 --- a/drivers/gpu/drm/sun4i/sun4i_layer.c +++ b/drivers/gpu/drm/sun4i/sun4i_layer.c @@ -25,6 +25,50 @@ struct sun4i_plane_desc { uint32_t nformats; }; +static void sun4i_backend_layer_reset(struct drm_plane *plane) +{ + struct sun4i_layer_state *state; + + if (plane->state) { + state = state_to_sun4i_layer_state(plane->state); + + __drm_atomic_helper_plane_destroy_state(&state->state); + + kfree(state); + plane->state = NULL; + } + + state = kzalloc(sizeof(*state), GFP_KERNEL); + if (state) { + plane->state = &state->state; + plane->state->plane = plane; + } +} + +static struct drm_plane_state * +sun4i_backend_layer_duplicate_state(struct drm_plane *plane) +{ + struct sun4i_layer_state *copy; + + copy = kzalloc(sizeof(*copy), GFP_KERNEL); + if (!copy) + return NULL; + + __drm_atomic_helper_plane_duplicate_state(plane, ©->state); + + return ©->state; +} + +static void sun4i_backend_layer_destroy_state(struct drm_plane *plane, + struct drm_plane_state *state) +{ + struct sun4i_layer_state *s_state = state_to_sun4i_layer_state(state); + + __drm_atomic_helper_plane_destroy_state(state); + + kfree(s_state); +} + static void sun4i_backend_layer_atomic_disable(struct drm_plane *plane, struct drm_plane_state *old_state) { @@ -52,11 +96,11 @@ static const struct drm_plane_helper_funcs sun4i_backend_layer_helper_funcs = { }; static const struct drm_plane_funcs sun4i_backend_layer_funcs = { - .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, - .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, + .atomic_destroy_state = sun4i_backend_layer_destroy_state, + .atomic_duplicate_state = sun4i_backend_layer_duplicate_state, .destroy = drm_plane_cleanup, .disable_plane = drm_atomic_helper_disable_plane, - .reset = drm_atomic_helper_plane_reset, + .reset = sun4i_backend_layer_reset, .update_plane = drm_atomic_helper_update_plane, }; diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.h b/drivers/gpu/drm/sun4i/sun4i_layer.h index 4e84f438b346..d2c19348d1b0 100644 --- a/drivers/gpu/drm/sun4i/sun4i_layer.h +++ b/drivers/gpu/drm/sun4i/sun4i_layer.h @@ -22,12 +22,22 @@ struct sun4i_layer { int id; }; +struct sun4i_layer_state { + struct drm_plane_state state; +}; + static inline struct sun4i_layer * plane_to_sun4i_layer(struct drm_plane *plane) { return container_of(plane, struct sun4i_layer, plane); } +static inline struct sun4i_layer_state * +state_to_sun4i_layer_state(struct drm_plane_state *state) +{ + return container_of(state, struct sun4i_layer_state, state); +} + struct drm_plane **sun4i_layers_init(struct drm_device *drm, struct sunxi_engine *engine);