From patchwork Mon Jan 22 09:25:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 125357 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp1053987ljf; Mon, 22 Jan 2018 01:26:22 -0800 (PST) X-Google-Smtp-Source: AH8x227194E39Xvg3qQ2luJaoxkm8svIgL6ykwLuqk4skjvWPu8F8Hqp1ef86h7zIRWFJBB/CHAP X-Received: by 10.101.96.78 with SMTP id b14mr6917855pgv.339.1516613182729; Mon, 22 Jan 2018 01:26:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516613182; cv=none; d=google.com; s=arc-20160816; b=IfuKWUQX4mTo/BMjHvoyNLOJrhwOJ1OMuZDH2NGBd0S6g6cJpdRgVFv0LI6c8UclDE EVhdgOEHSCL5l3RRELGNnyKTNXXyFk+O41cMfEPyE/EK3o2doTSUwmkZJIBRGVQD6X7Y zNiA8PwlbY2l4dwUukY2xQMVNxPlPXERGbrchSMzCDhHIrTJC+OeVx0YmS/HuO9TzhKL xuhny7tRK/jWKsmQhwLE666C/FlkRBwAja8eUvpSIcuOYxpgAWT0A8OfKuOYEz/Kvc+j van4EZbCVzT1+IttERIk3X10QtP9xM3PVvGB3pnR82tXLjQa7MHN6jj8z4nOnl99eMKV yMjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:cc:references:in-reply-to:references:in-reply-to :message-id:date:subject:to:from:delivered-to :arc-authentication-results; bh=3a0Vebsla3y528T/myqmUled7NonqDwwQKw5PdFijSQ=; b=0+kv6k9WZLPdqDDpGpwE+j7aqcdBKG0Ueh6gIi2vGfGWYUouDY3xa4WcdN12PUpCSK 3MTpwDEYgVWvFIwxtZkOw4N68wLhBxiWl9xxolk1FKBpP8D66VXt4mPc3QmANBGJVRPO e759wCal/6NG+i0SmY6Ku4Du7C/gTpkVG5XpuHnOy2cNa8ZsEN3fe8QylwVMUFG9vQv+ GX1cXfUpDX9aT8GpFEri7DgaBg0jLvbXc6A8VCDmeiPcuI7rPesHiQtR/zsMn493pAHm ghVKHRmeH74e1OIf14GSatqqX4yMu2IQRi/MAofqgUDDOrpIs+nvqhsi+PnxwOX7/U31 9rzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id c80si15030105pfb.182.2018.01.22.01.26.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jan 2018 01:26:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1689D6E16C; Mon, 22 Jan 2018 09:25:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by gabe.freedesktop.org (Postfix) with ESMTP id C873F6E11D for ; Mon, 22 Jan 2018 09:25:41 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 7AAE5206FC; Mon, 22 Jan 2018 10:25:41 +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 44CEB2072C; Mon, 22 Jan 2018 10:25:31 +0100 (CET) From: Maxime Ripard To: Chen-Yu Tsai , Maxime Ripard Subject: [PATCH v4 05/13] drm/sun4i: engine: Add a custom crtc atomic_check Date: Mon, 22 Jan 2018 10:25:19 +0100 Message-Id: X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Cc: linux-arm-kernel@lists.infradead.org, thomas@vitsch.nl, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, narmstrong@baylibre.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We have some restrictions on what the planes and CRTC can provide that are tied to only one generation of display engines. For example, on the first generation, we can only have one YUV plane or one plane that uses the frontend output. Let's allow our engines to provide an atomic_check callback to validate the current configuration. Reviewed-by: Chen-Yu Tsai Reviewed-by: Neil Armstrong Signed-off-by: Maxime Ripard --- drivers/gpu/drm/sun4i/sun4i_crtc.c | 14 ++++++++++++++ drivers/gpu/drm/sun4i/sunxi_engine.h | 17 +++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/drivers/gpu/drm/sun4i/sun4i_crtc.c b/drivers/gpu/drm/sun4i/sun4i_crtc.c index 5decae0069d0..2a565325714f 100644 --- a/drivers/gpu/drm/sun4i/sun4i_crtc.c +++ b/drivers/gpu/drm/sun4i/sun4i_crtc.c @@ -46,6 +46,19 @@ static struct drm_encoder *sun4i_crtc_get_encoder(struct drm_crtc *crtc) return NULL; } +static int sun4i_crtc_atomic_check(struct drm_crtc *crtc, + struct drm_crtc_state *state) +{ + struct sun4i_crtc *scrtc = drm_crtc_to_sun4i_crtc(crtc); + struct sunxi_engine *engine = scrtc->engine; + int ret = 0; + + if (engine && engine->ops && engine->ops->atomic_check) + ret = engine->ops->atomic_check(engine, state); + + return ret; +} + static void sun4i_crtc_atomic_begin(struct drm_crtc *crtc, struct drm_crtc_state *old_state) { @@ -125,6 +138,7 @@ static void sun4i_crtc_mode_set_nofb(struct drm_crtc *crtc) } static const struct drm_crtc_helper_funcs sun4i_crtc_helper_funcs = { + .atomic_check = sun4i_crtc_atomic_check, .atomic_begin = sun4i_crtc_atomic_begin, .atomic_flush = sun4i_crtc_atomic_flush, .atomic_enable = sun4i_crtc_atomic_enable, diff --git a/drivers/gpu/drm/sun4i/sunxi_engine.h b/drivers/gpu/drm/sun4i/sunxi_engine.h index b374e074c7c3..b819d4f9f02f 100644 --- a/drivers/gpu/drm/sun4i/sunxi_engine.h +++ b/drivers/gpu/drm/sun4i/sunxi_engine.h @@ -23,6 +23,23 @@ struct sunxi_engine; */ struct sunxi_engine_ops { /** + * @atomic_check: + * + * This callback allows to validate plane-update related CRTC + * constraints specific to engines. This is mirroring the + * &drm_crtc_helper_funcs.atomic_check callback, so any + * documentation there applies. + * + * This function is optional. + * + * RETURNS: + * + * 0 on success or a negative error code. + */ + int (*atomic_check)(struct sunxi_engine *engine, + struct drm_crtc_state *state); + + /** * @commit: * * This callback will trigger the hardware switch to commit