From patchwork Tue Nov 5 21:10:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 11228635 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 302E313A4 for ; Tue, 5 Nov 2019 21:10:59 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2153E2087E for ; Tue, 5 Nov 2019 21:10:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2153E2087E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=poorly.run Authentication-Results: mail.kernel.org; spf=none 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 CF9DE6E9F7; Tue, 5 Nov 2019 21:10:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yw1-xc41.google.com (mail-yw1-xc41.google.com [IPv6:2607:f8b0:4864:20::c41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 26BD76E9D9 for ; Tue, 5 Nov 2019 21:10:55 +0000 (UTC) Received: by mail-yw1-xc41.google.com with SMTP id i2so8820842ywg.13 for ; Tue, 05 Nov 2019 13:10:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=47K5oOg7WLw5/3p9dwg+0DGsBD3xNcb5zwIbofYoaPA=; b=kNhFeXWtkrWpF3XPQU7U/xp2A9mq9OBuvRQj+U3RAUh7F65YTGC56/P3kaq87dvj2X Ft5XXU+TjuEJMqo3QC5S7m7eXzNtzRALGqi+Xh5QS4y/4G14Lf8GmeSN/vSGenBaIdtm 9zcm10i8jhGkzhUOjckJYbbL6WUUpwwktDEpJQd2fp0KNphgkm/t+lquAnS7HrDGFZMf KERoZOqSO4FgupOPQCnRPmbjWbZdX1b5C4bXYdZq/6Dc1vom1B5b++KQ+3BF6Vg0D7Dy 83AUZQq6sPlNsyrTklchD3PtKCAypOOalYvXjJbGg+ckmpQSMDsZ7wy0lM3PaUwJbpxG VKfQ== X-Gm-Message-State: APjAAAVpR5FMBcbtGXKp4KTX6mTmA9Oo84Ay+5YxBXb2ONsjfc0F363u tRj9VbO1GHt7YLpYB/KshCOtkSKKZJQ= X-Google-Smtp-Source: APXvYqwa5e6g0vw3L3tFhW0BtB4ETIxgip1pNsXJmRwcKlnn/4sNZ5kkBKbaTE9F2U4hGDttwHOBxg== X-Received: by 2002:a81:db07:: with SMTP id u7mr4709820ywm.126.1572988253967; Tue, 05 Nov 2019 13:10:53 -0800 (PST) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id j66sm1815216ywb.101.2019.11.05.13.10.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2019 13:10:53 -0800 (PST) From: Sean Paul To: dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2 3/7] drm/mediatek: Add plumbing for layer_check hook Date: Tue, 5 Nov 2019 16:10:20 -0500 Message-Id: <20191105211034.123937-4-sean@poorly.run> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog In-Reply-To: <20191105211034.123937-1-sean@poorly.run> References: <20191105211034.123937-1-sean@poorly.run> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=47K5oOg7WLw5/3p9dwg+0DGsBD3xNcb5zwIbofYoaPA=; b=CWNIiMSHLVnAufWZgrmvlq1asdA7IwpWS/kZgw6NLjJTJTgeYxEfGOldA6SUYIn36/ /XlzTYjXGfnqwPIlshx5rIUyuA210kV1lo+8QucYHMdWnRSGIXYOvA0Knm0op+7zFD1s nb/3HMlqMnYKEn8KKAcVudt1XHSAyRl2fbpsIehgiznPgxQfgf8grLlQipXhSnACYR87 QmM1jNs5KHPflI2HM+s/W2tNhTjf0g2GltXN0UlTxDc9yyUYsgia56eXCwNEiTchzaA9 q8Ozr+sw2Ric7EQ3d/lulCZyQz8W/oWYyrtDtc8cgQhyIXSA5fmHYQjgalMlgZ5cPgIe qTFQ== 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: dcastagna@chromium.org, matthias.bgg@gmail.com, mcasas@chromium.org, Sean Paul , frkoenig@chromium.org, linux-arm-kernel@lists.infradead.org, markyacoub@google.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Sean Paul This allows components to implement a .layer_check callback for their layers which is called during atomic_check. Signed-off-by: Sean Paul --- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 10 ++++++++++ drivers/gpu/drm/mediatek/mtk_drm_crtc.h | 2 ++ drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 12 ++++++++++++ drivers/gpu/drm/mediatek/mtk_drm_plane.c | 6 ++++++ 4 files changed, 30 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index ccf395f17a99..04e7e4bdbdb5 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -394,6 +394,16 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc) } } +int mtk_drm_crtc_plane_check(struct drm_crtc *crtc, struct drm_plane *plane, + struct mtk_plane_state *state) +{ + unsigned int local_layer; + struct mtk_ddp_comp *comp; + + comp = mtk_drm_ddp_comp_for_plane(crtc, plane, &local_layer); + return mtk_ddp_comp_layer_check(comp, local_layer, state); +} + static void mtk_drm_crtc_atomic_enable(struct drm_crtc *crtc, struct drm_crtc_state *old_state) { diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.h b/drivers/gpu/drm/mediatek/mtk_drm_crtc.h index fcc134eb00c9..6afe1c19557a 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.h @@ -19,5 +19,7 @@ void mtk_crtc_ddp_irq(struct drm_crtc *crtc, struct mtk_ddp_comp *comp); int mtk_drm_crtc_create(struct drm_device *drm_dev, const enum mtk_ddp_comp_id *path, unsigned int path_len); +int mtk_drm_crtc_plane_check(struct drm_crtc *crtc, struct drm_plane *plane, + struct mtk_plane_state *state); #endif /* MTK_DRM_CRTC_H */ diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h index 26441f4d1ad3..3de371e28bdf 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h @@ -80,6 +80,9 @@ struct mtk_ddp_comp_funcs { unsigned int (*layer_nr)(struct mtk_ddp_comp *comp); void (*layer_on)(struct mtk_ddp_comp *comp, unsigned int idx); void (*layer_off)(struct mtk_ddp_comp *comp, unsigned int idx); + int (*layer_check)(struct mtk_ddp_comp *comp, + unsigned int idx, + struct mtk_plane_state *state); void (*layer_config)(struct mtk_ddp_comp *comp, unsigned int idx, struct mtk_plane_state *state); void (*gamma_set)(struct mtk_ddp_comp *comp, @@ -152,6 +155,15 @@ static inline void mtk_ddp_comp_layer_off(struct mtk_ddp_comp *comp, comp->funcs->layer_off(comp, idx); } +static inline int mtk_ddp_comp_layer_check(struct mtk_ddp_comp *comp, + unsigned int idx, + struct mtk_plane_state *state) +{ + if (comp->funcs && comp->funcs->layer_check) + return comp->funcs->layer_check(comp, idx, state); + return 0; +} + static inline void mtk_ddp_comp_layer_config(struct mtk_ddp_comp *comp, unsigned int idx, struct mtk_plane_state *state) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c index 584a9ecadce6..58b02fffe321 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c @@ -84,6 +84,7 @@ static int mtk_plane_atomic_check(struct drm_plane *plane, { struct drm_framebuffer *fb = state->fb; struct drm_crtc_state *crtc_state; + int ret; if (!fb) return 0; @@ -91,6 +92,11 @@ static int mtk_plane_atomic_check(struct drm_plane *plane, if (!state->crtc) return 0; + ret = mtk_drm_crtc_plane_check(state->crtc, plane, + to_mtk_plane_state(state)); + if (ret) + return ret; + crtc_state = drm_atomic_get_crtc_state(state->state, state->crtc); if (IS_ERR(crtc_state)) return PTR_ERR(crtc_state);