From patchwork Sat Feb 24 15:05:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ond=C5=99ej_Jirman?= X-Patchwork-Id: 205898 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1188472dyb; Sat, 24 Feb 2024 07:07:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVLNLK5VD/i9NxWMWqn7icVkssggJFz4B78NpYmTgBSLCNz33frs1UOOXubcWqEwit7B4gbZ19H06ipgcw0k8QpQBIU0w== X-Google-Smtp-Source: AGHT+IFtSlXoT5TOl1ZYLKorbUPy9hEkjqRML2kp5WNCRLYmAK5Opb0he80z6B8LNKT+1lvoVQG+ X-Received: by 2002:a05:6512:2523:b0:512:d8ad:b454 with SMTP id be35-20020a056512252300b00512d8adb454mr1936544lfb.61.1708787221206; Sat, 24 Feb 2024 07:07:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708787221; cv=pass; d=google.com; s=arc-20160816; b=ZpzcEonL6ZlhpgZsxxftR3/JqnBEsVb5hwugj6Fn1aUXNSzCMmu2/28nnz5ogZBywq 7iSsyMRMEb4MGhBXCqEF4veKNWGPPApp3JeZc14iQDcSergyQyJbVXNIegYjuOg0cJyX QRnw6vjV9dx5CFla0Y95wAelKAwxvycb1fyLKcFcthnYb0Et95nBKqvH97F3vgDqpQo0 aON46B3OOsiLTNLV2IivIYT8/KsEehqsb86S7modAWvOAtsApfrLpEAn2K1cY25PN9U9 A/nV+P3tcgdg6h/TsqHuEyO2QZ7u10y2RWGyaV4Az/Q/bCUb4KS3TQDy2DgHJTT+cM2b ViUg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=QHiWltwfR51SwnXgIiAJgZzamGyvrDNCxmN1YcDPD6g=; fh=unULrk3HLskrF1j1J92Hyho+sCeXl6rNrRZMNuoyCm0=; b=qs0vJcgl1T8ntcfWR5Hv/fPj3IsFR3czu6Dcc781UfJA31z5UwU2E2XlpmonUTyMsC I1zbZndHNr8pqoejO5RTDRp725gxs1TwZ+wJa2dBuPWbsjsudqoqzY1grB9+KRCcH95M MXKfloGSEB/do7DruC5L1ZyFlpmuf+Gh0lDoEjchQwFu2jBoI1y3hOsDZV8hlyFVYD/W Ss/bdHnszbuvEJu3oTnn1QybTGKN6K0os4SGtAjQwLMRxY2OHeaDkK/SeZ0la7uS4GOY lt8RjgT2qsQ45MFwipwcCC9S3NDs/dFjHfAvMrzhr5t9mAhEGlJf/Zuof0HbhhoeO/6x Yngw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b="B/aFOneB"; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-79715-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79715-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id h11-20020a170906584b00b00a3e76484898si534249ejs.380.2024.02.24.07.07.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 07:07:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79715-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b="B/aFOneB"; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-79715-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79715-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A4A641F20FFB for ; Sat, 24 Feb 2024 15:07:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 39FDF2AF04; Sat, 24 Feb 2024 15:06:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="B/aFOneB" Received: from vps.xff.cz (vps.xff.cz [195.181.215.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 014D03398B for ; Sat, 24 Feb 2024 15:06:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.181.215.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708787174; cv=none; b=UWH7HBIPqyGrlu+VzvxVse3eZDjeBmtvcGrLPJn/R4Ltp/gCjvjxAzFay89FxNVMhTXdwIzJUmxOhMIKYZ2LWL0Un83e9sYQ8cJEfuMLj4QWWujS3sqPlSVOryWgrwSR3ePCMbXtnvN+Tx7dEmPPiNMybkNGnQgoLTZzMVd5l7c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708787174; c=relaxed/simple; bh=/QYk0uoyxgbSwG8OlM5p+weXCE1mQsTEizZZUWPWwDc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H7t19/UgA+8ufDXONacMTiJxgxJ5/Is98bsrrQDQc3neTp2FIcUUNj2Y0Gya9elTvXDu9CLky4SzITj42iFdc4xM+EtULoHCdcuCMNp1uUmRY8eZ1Yj70+xZdWW3bQlHfG6jgMvo4FScgJccKFtVpCPSoaEDmf7fNKU4TD+c6sw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz; spf=pass smtp.mailfrom=xff.cz; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b=B/aFOneB; arc=none smtp.client-ip=195.181.215.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xff.cz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xff.cz; s=mail; t=1708787168; bh=/QYk0uoyxgbSwG8OlM5p+weXCE1mQsTEizZZUWPWwDc=; h=From:To:Cc:Subject:Date:References:From; b=B/aFOneBxAvEXj6gOQa9hO8em8GSJUikzbXvqP2QYMspbS3b0ms4RsOIOIUumgohf A4uJ4tu5Qs+wCuoUMfCPripW/Xw6kiADtA9iuSlfP0Llejz0Jcn+KUPezwtm0/PBmr 3uYpO9JAHxIVBmZ4ew4GBv55GsKHNoQLJvjJvSqE= From: =?utf-8?q?Ond=C5=99ej_Jirman?= To: linux-kernel@vger.kernel.org, Maxime Ripard , Chen-Yu Tsai , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Jernej Skrabec , Samuel Holland Cc: Ondrej Jirman , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH v2 1/3] drm/sun4i: Unify sun8i_*_layer structs Date: Sat, 24 Feb 2024 16:05:58 +0100 Message-ID: <20240224150604.3855534-2-megi@xff.cz> In-Reply-To: <20240224150604.3855534-1-megi@xff.cz> References: <20240224150604.3855534-1-megi@xff.cz> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791793269435847806 X-GMAIL-MSGID: 1791793269435847806 From: Ondrej Jirman These structs are identical, use a single struct to represent private data for the DRM plane. This is a preparation for configuring layer routing from the CRTC (mixer) instead of current approach of setting up routing from individual layer's atomic_update callback. Signed-off-by: Ondrej Jirman Reviewed-by: Maxime Ripard Reviewed-by: Jernej Skrabec --- drivers/gpu/drm/sun4i/sun8i_mixer.c | 4 ++-- drivers/gpu/drm/sun4i/sun8i_mixer.h | 14 ++++++++++++++ drivers/gpu/drm/sun4i/sun8i_ui_layer.c | 14 +++++++------- drivers/gpu/drm/sun4i/sun8i_ui_layer.h | 20 ++++---------------- drivers/gpu/drm/sun4i/sun8i_vi_layer.c | 14 +++++++------- drivers/gpu/drm/sun4i/sun8i_vi_layer.h | 20 ++++---------------- 6 files changed, 38 insertions(+), 48 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c b/drivers/gpu/drm/sun4i/sun8i_mixer.c index 01382860aaee..1e681314e379 100644 --- a/drivers/gpu/drm/sun4i/sun8i_mixer.c +++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c @@ -271,7 +271,7 @@ static struct drm_plane **sun8i_layers_init(struct drm_device *drm, return ERR_PTR(-ENOMEM); for (i = 0; i < mixer->cfg->vi_num; i++) { - struct sun8i_vi_layer *layer; + struct sun8i_layer *layer; layer = sun8i_vi_layer_init_one(drm, mixer, i); if (IS_ERR(layer)) { @@ -284,7 +284,7 @@ static struct drm_plane **sun8i_layers_init(struct drm_device *drm, } for (i = 0; i < mixer->cfg->ui_num; i++) { - struct sun8i_ui_layer *layer; + struct sun8i_layer *layer; layer = sun8i_ui_layer_init_one(drm, mixer, i); if (IS_ERR(layer)) { diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.h b/drivers/gpu/drm/sun4i/sun8i_mixer.h index 85c94884fb9a..5a610ee30301 100644 --- a/drivers/gpu/drm/sun4i/sun8i_mixer.h +++ b/drivers/gpu/drm/sun4i/sun8i_mixer.h @@ -9,6 +9,7 @@ #include #include #include +#include #include "sunxi_engine.h" @@ -185,6 +186,19 @@ struct sun8i_mixer { struct clk *mod_clk; }; +struct sun8i_layer { + struct drm_plane plane; + struct sun8i_mixer *mixer; + int channel; + int overlay; +}; + +static inline struct sun8i_layer * +plane_to_sun8i_layer(struct drm_plane *plane) +{ + return container_of(plane, struct sun8i_layer, plane); +} + static inline struct sun8i_mixer * engine_to_sun8i_mixer(struct sunxi_engine *engine) { diff --git a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c index ca75ca0835a6..248fbb606ede 100644 --- a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c +++ b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c @@ -232,7 +232,7 @@ static int sun8i_ui_layer_atomic_check(struct drm_plane *plane, { struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane); - struct sun8i_ui_layer *layer = plane_to_sun8i_ui_layer(plane); + struct sun8i_layer *layer = plane_to_sun8i_layer(plane); struct drm_crtc *crtc = new_plane_state->crtc; struct drm_crtc_state *crtc_state; int min_scale, max_scale; @@ -264,7 +264,7 @@ static void sun8i_ui_layer_atomic_disable(struct drm_plane *plane, { struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, plane); - struct sun8i_ui_layer *layer = plane_to_sun8i_ui_layer(plane); + struct sun8i_layer *layer = plane_to_sun8i_layer(plane); unsigned int old_zpos = old_state->normalized_zpos; struct sun8i_mixer *mixer = layer->mixer; @@ -279,7 +279,7 @@ static void sun8i_ui_layer_atomic_update(struct drm_plane *plane, plane); struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, plane); - struct sun8i_ui_layer *layer = plane_to_sun8i_ui_layer(plane); + struct sun8i_layer *layer = plane_to_sun8i_layer(plane); unsigned int zpos = new_state->normalized_zpos; unsigned int old_zpos = old_state->normalized_zpos; struct sun8i_mixer *mixer = layer->mixer; @@ -345,13 +345,13 @@ static const uint64_t sun8i_layer_modifiers[] = { DRM_FORMAT_MOD_INVALID }; -struct sun8i_ui_layer *sun8i_ui_layer_init_one(struct drm_device *drm, - struct sun8i_mixer *mixer, - int index) +struct sun8i_layer *sun8i_ui_layer_init_one(struct drm_device *drm, + struct sun8i_mixer *mixer, + int index) { enum drm_plane_type type = DRM_PLANE_TYPE_OVERLAY; int channel = mixer->cfg->vi_num + index; - struct sun8i_ui_layer *layer; + struct sun8i_layer *layer; unsigned int plane_cnt; int ret; diff --git a/drivers/gpu/drm/sun4i/sun8i_ui_layer.h b/drivers/gpu/drm/sun4i/sun8i_ui_layer.h index e3e32ee1178d..83892f6ff211 100644 --- a/drivers/gpu/drm/sun4i/sun8i_ui_layer.h +++ b/drivers/gpu/drm/sun4i/sun8i_ui_layer.h @@ -47,21 +47,9 @@ #define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_ALPHA_MODE_COMBINED ((2) << 1) struct sun8i_mixer; +struct sun8i_layer; -struct sun8i_ui_layer { - struct drm_plane plane; - struct sun8i_mixer *mixer; - int channel; - int overlay; -}; - -static inline struct sun8i_ui_layer * -plane_to_sun8i_ui_layer(struct drm_plane *plane) -{ - return container_of(plane, struct sun8i_ui_layer, plane); -} - -struct sun8i_ui_layer *sun8i_ui_layer_init_one(struct drm_device *drm, - struct sun8i_mixer *mixer, - int index); +struct sun8i_layer *sun8i_ui_layer_init_one(struct drm_device *drm, + struct sun8i_mixer *mixer, + int index); #endif /* _SUN8I_UI_LAYER_H_ */ diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c index f9c0a56d3a14..0c0f1ac80517 100644 --- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c +++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c @@ -366,7 +366,7 @@ static int sun8i_vi_layer_atomic_check(struct drm_plane *plane, { struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane); - struct sun8i_vi_layer *layer = plane_to_sun8i_vi_layer(plane); + struct sun8i_layer *layer = plane_to_sun8i_layer(plane); struct drm_crtc *crtc = new_plane_state->crtc; struct drm_crtc_state *crtc_state; int min_scale, max_scale; @@ -398,7 +398,7 @@ static void sun8i_vi_layer_atomic_disable(struct drm_plane *plane, { struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, plane); - struct sun8i_vi_layer *layer = plane_to_sun8i_vi_layer(plane); + struct sun8i_layer *layer = plane_to_sun8i_vi_layer(plane); unsigned int old_zpos = old_state->normalized_zpos; struct sun8i_mixer *mixer = layer->mixer; @@ -413,7 +413,7 @@ static void sun8i_vi_layer_atomic_update(struct drm_plane *plane, plane); struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, plane); - struct sun8i_vi_layer *layer = plane_to_sun8i_vi_layer(plane); + struct sun8i_layer *layer = plane_to_sun8i_layer(plane); unsigned int zpos = new_state->normalized_zpos; unsigned int old_zpos = old_state->normalized_zpos; struct sun8i_mixer *mixer = layer->mixer; @@ -539,14 +539,14 @@ static const uint64_t sun8i_layer_modifiers[] = { DRM_FORMAT_MOD_INVALID }; -struct sun8i_vi_layer *sun8i_vi_layer_init_one(struct drm_device *drm, - struct sun8i_mixer *mixer, - int index) +struct sun8i_layer *sun8i_vi_layer_init_one(struct drm_device *drm, + struct sun8i_mixer *mixer, + int index) { enum drm_plane_type type = DRM_PLANE_TYPE_OVERLAY; u32 supported_encodings, supported_ranges; unsigned int plane_cnt, format_count; - struct sun8i_vi_layer *layer; + struct sun8i_layer *layer; const u32 *formats; int ret; diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.h b/drivers/gpu/drm/sun4i/sun8i_vi_layer.h index 48c399e1c86d..655440cdc78f 100644 --- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.h +++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.h @@ -52,21 +52,9 @@ #define SUN8I_MIXER_CHAN_VI_DS_M(x) ((x) << 0) struct sun8i_mixer; +struct sun8i_layer; -struct sun8i_vi_layer { - struct drm_plane plane; - struct sun8i_mixer *mixer; - int channel; - int overlay; -}; - -static inline struct sun8i_vi_layer * -plane_to_sun8i_vi_layer(struct drm_plane *plane) -{ - return container_of(plane, struct sun8i_vi_layer, plane); -} - -struct sun8i_vi_layer *sun8i_vi_layer_init_one(struct drm_device *drm, - struct sun8i_mixer *mixer, - int index); +struct sun8i_layer *sun8i_vi_layer_init_one(struct drm_device *drm, + struct sun8i_mixer *mixer, + int index); #endif /* _SUN8I_VI_LAYER_H_ */ From patchwork Sat Feb 24 15:05:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ond=C5=99ej_Jirman?= X-Patchwork-Id: 205897 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1188333dyb; Sat, 24 Feb 2024 07:06:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVlZYkPD4WgfcJiYDazN4bqvEQpEaDnL67hMnStV09Q8LfLAYi1UVQNHbN7HgNFQyIsGLbbJOVdQRtH55pbV+PBzEBanQ== X-Google-Smtp-Source: AGHT+IFyHdsHG/nvvX3FDL/yPPzlKftRrpSVrXq+MH597PK3CVUAi98OzvrtdFILk6U7/w4L8fJ/ X-Received: by 2002:a05:6512:3b1f:b0:512:d554:f1df with SMTP id f31-20020a0565123b1f00b00512d554f1dfmr1918910lfv.65.1708787206775; Sat, 24 Feb 2024 07:06:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708787206; cv=pass; d=google.com; s=arc-20160816; b=LgK2c/OaHZc3Bjjlex55eEiGlKOnjJvGEuVdoqKRKtyBByBRsXGgdrK7wkmXTtGnAA zNLr3MNmOM5bLcGyDJk/kEkxPNAyvTRnBe/yMzjP4oGAUK2AsKuvKZ4sS9SQlRxJ8Egm xlcs53lJcGR4aBbZVgmZgqZTQgFEPn3bv3nWm4V2SsEZMKt+iNlrgToZrNL0wFQZ5UbO urhjUo7sos/TebH+JKh+NXNOgeRglHCqAPoomEjkK+Lx96uV6jVmRoK5n4xzGmlqWKC3 vn3BqT4rhaNy9H52dYZF20bsQmIej5FjEBV0jCWvymKVe/ZlfD+L9nBGgZHuDCDIxcXB rgcw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=aeQU/PjTofjwTEnyZK2SBNE19krUEtUecFZbN5X80Hs=; fh=unULrk3HLskrF1j1J92Hyho+sCeXl6rNrRZMNuoyCm0=; b=oDv+rWAwSTGb+tUoRd8A00oO05QgqdXS5o0ezfp8Y12Er1LooFh5OKE4ll3grxvHFg vczYbrasm8acXII1L9TPeMGnPwJ1yaqAEDNB7CmOL3M8i7L7CEuqFH+gvWw/OMfDGxIk Y6A1SzzFt7Mvs1UbDq3lGAfLmFVp0mEUi31RZdaRk8CuE9+U7pc2ooDS79i7o2IfdppW Ixor6hV0EDxCH5O11lVqtY1NrkbU5xEvbKxGq/tfCZ9SkJtMMQULMPAKjF9EBEKuBikH GLoRoztjzatZc3xgCWk7ssu2M0tkXioXPBBrfu3Fp0kcGL4D7tqTe5CaYCAVU4kobOot XArQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=tMfWRFgo; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-79712-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79712-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id qk36-20020a1709077fa400b00a430f79d6e1si25674ejc.164.2024.02.24.07.06.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 07:06:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79712-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=tMfWRFgo; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-79712-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79712-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3348A1F215CE for ; Sat, 24 Feb 2024 15:06:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4C26482C6; Sat, 24 Feb 2024 15:06:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="tMfWRFgo" Received: from vps.xff.cz (vps.xff.cz [195.181.215.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09A8B45976 for ; Sat, 24 Feb 2024 15:06:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.181.215.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708787173; cv=none; b=Wj80449blcTgwhmwi94whCDO8tddliuTTjg6kSsSC28W8LaCNq1+QzEXVEwevuCf+7OC6OfGMgw/XLFIfDPP6IO7MV8HB7LnrAMNc9KPhlnMVQLkG6Qw66u0vrdTYK+YN0sxwi5j03fOpG580EmthZjZS5hUtschyNpm6wQGAZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708787173; c=relaxed/simple; bh=1o4GXfvP6xMrbbr1RM8jSgzNi7t4j6YOvmuIy2AM9jE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Uvmd9P8bYDiGjI8JFbWYhx6Vk66P0WfB3glzm66nlzLjIxt6ERWHV3GS7egjwJCgoBqqRgFBQ71Zj1w/EQxwyIcxV8XMcpN1JMvzEsp2RWCznVmYN/fuC6GeO8cd2O5VLRWn0VagfUPrK7cPSHU00ukpsrYrfairo+EDL+6zKgI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz; spf=pass smtp.mailfrom=xff.cz; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b=tMfWRFgo; arc=none smtp.client-ip=195.181.215.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xff.cz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xff.cz; s=mail; t=1708787168; bh=1o4GXfvP6xMrbbr1RM8jSgzNi7t4j6YOvmuIy2AM9jE=; h=From:To:Cc:Subject:Date:References:From; b=tMfWRFgoNIuDUYqRsD974N3vcVI89e9R6Zbs7lKepJ7JniADdhZWgOdW7bf6wGDAb TyWdUyTZeQdx4pc6jTxX9ajGxkA2iLRZhlitAZFGDFBG6CdakEl/6NbTU42NVwLeGF t2kkJYHk6wim1WxIR4ud/+05vkpYhKudg4PpvgD0= From: =?utf-8?q?Ond=C5=99ej_Jirman?= To: linux-kernel@vger.kernel.org, Maxime Ripard , Chen-Yu Tsai , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Jernej Skrabec , Samuel Holland Cc: Ondrej Jirman , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH v2 2/3] drm/sun4i: Add more parameters to sunxi_engine commit callback Date: Sat, 24 Feb 2024 16:05:59 +0100 Message-ID: <20240224150604.3855534-3-megi@xff.cz> In-Reply-To: <20240224150604.3855534-1-megi@xff.cz> References: <20240224150604.3855534-1-megi@xff.cz> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791793254262955820 X-GMAIL-MSGID: 1791793254262955820 From: Ondrej Jirman These will be needed later on when we move layer configuration to crtc update. Signed-off-by: Ondrej Jirman Reviewed-by: Maxime Ripard Reviewed-by: Jernej Skrabec --- drivers/gpu/drm/sun4i/sun4i_backend.c | 4 +++- drivers/gpu/drm/sun4i/sun4i_crtc.c | 2 +- drivers/gpu/drm/sun4i/sun8i_mixer.c | 5 ++++- drivers/gpu/drm/sun4i/sunxi_engine.h | 13 ++++++++++--- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c index 335fd0edb904..e89eb96d3131 100644 --- a/drivers/gpu/drm/sun4i/sun4i_backend.c +++ b/drivers/gpu/drm/sun4i/sun4i_backend.c @@ -69,7 +69,9 @@ static void sun4i_backend_disable_color_correction(struct sunxi_engine *engine) SUN4I_BACKEND_OCCTL_ENABLE, 0); } -static void sun4i_backend_commit(struct sunxi_engine *engine) +static void sun4i_backend_commit(struct sunxi_engine *engine, + struct drm_crtc *crtc, + struct drm_atomic_state *state) { DRM_DEBUG_DRIVER("Committing changes\n"); diff --git a/drivers/gpu/drm/sun4i/sun4i_crtc.c b/drivers/gpu/drm/sun4i/sun4i_crtc.c index c06d7cd45388..18e74047b0f5 100644 --- a/drivers/gpu/drm/sun4i/sun4i_crtc.c +++ b/drivers/gpu/drm/sun4i/sun4i_crtc.c @@ -91,7 +91,7 @@ static void sun4i_crtc_atomic_flush(struct drm_crtc *crtc, DRM_DEBUG_DRIVER("Committing plane changes\n"); - sunxi_engine_commit(scrtc->engine); + sunxi_engine_commit(scrtc->engine, crtc, state); if (event) { crtc->state->event = NULL; diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c b/drivers/gpu/drm/sun4i/sun8i_mixer.c index 1e681314e379..bdeb9b80e038 100644 --- a/drivers/gpu/drm/sun4i/sun8i_mixer.c +++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -249,7 +250,9 @@ int sun8i_mixer_drm_format_to_hw(u32 format, u32 *hw_format) return -EINVAL; } -static void sun8i_mixer_commit(struct sunxi_engine *engine) +static void sun8i_mixer_commit(struct sunxi_engine *engine, + struct drm_crtc *crtc, + struct drm_atomic_state *state) { DRM_DEBUG_DRIVER("Committing changes\n"); diff --git a/drivers/gpu/drm/sun4i/sunxi_engine.h b/drivers/gpu/drm/sun4i/sunxi_engine.h index ec8cf9b2bda4..ec0c4932f15c 100644 --- a/drivers/gpu/drm/sun4i/sunxi_engine.h +++ b/drivers/gpu/drm/sun4i/sunxi_engine.h @@ -7,6 +7,7 @@ #define _SUNXI_ENGINE_H_ struct drm_plane; +struct drm_crtc; struct drm_device; struct drm_crtc_state; struct drm_display_mode; @@ -59,7 +60,9 @@ struct sunxi_engine_ops { * * This function is optional. */ - void (*commit)(struct sunxi_engine *engine); + void (*commit)(struct sunxi_engine *engine, + struct drm_crtc *crtc, + struct drm_atomic_state *state); /** * @layers_init: @@ -144,12 +147,16 @@ struct sunxi_engine { /** * sunxi_engine_commit() - commit all changes of the engine * @engine: pointer to the engine + * @crtc: pointer to crtc the engine is associated with + * @state: atomic state */ static inline void -sunxi_engine_commit(struct sunxi_engine *engine) +sunxi_engine_commit(struct sunxi_engine *engine, + struct drm_crtc *crtc, + struct drm_atomic_state *state) { if (engine->ops && engine->ops->commit) - engine->ops->commit(engine); + engine->ops->commit(engine, crtc, state); } /** From patchwork Sat Feb 24 15:06:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ond=C5=99ej_Jirman?= X-Patchwork-Id: 205899 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1188473dyb; Sat, 24 Feb 2024 07:07:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCULcjm2KMIddC89lSUOlTjMEh+VCuGWtUnqNs2whONz4WOlblXWWL44Zf1ls6NMAABAJXdHRHqAP3rAmZlKBPamdHyuYg== X-Google-Smtp-Source: AGHT+IHWTMDHjovjQnoBhe1hyncEPYDPit9EznOPJOcZbvBPplLRjoDYYa6HauRdW+oft9eD/4f4 X-Received: by 2002:a17:902:ea05:b0:1dc:6073:a3a4 with SMTP id s5-20020a170902ea0500b001dc6073a3a4mr3185040plg.3.1708787221203; Sat, 24 Feb 2024 07:07:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708787221; cv=pass; d=google.com; s=arc-20160816; b=QP9002Y/xu1AQB24tt9bq7YLYqtg6CXS27EzHbXxz4zsQEgJc+Te0e/UD48mKjWF2i doHWvOTO9Jxs2oYbKycKQih3nlpisoimcGBQ7dSHzwtkRcEb2+8QHcsSi7LNEXMYnn5x h7GutAyW5JYNQcVqhGkcSTx1Bw4MGsOdsrr057AvsW12EZo1aUJi/Qc4ar2nXASG33Yc tFWJyd6h7rCTqXPzbJhowhFmHxN97tVQjOwqc0yV5uc3wrr1zGaKiK4r/XBgA1ShMC+d yFTsZQRRXwgCnmb6/VNFzqqJ1Bviaqj3ic3g/QfAYAJunJMzTBEand5TAOsAE/hS9QMs RH1Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=O7Lh2w9UjqCZrrmR31kiUqUqDadqH6pyvDosDGviY6I=; fh=unULrk3HLskrF1j1J92Hyho+sCeXl6rNrRZMNuoyCm0=; b=YcDS4r5f1qupktmTTeTJRKJAZAlIxTpASItDW8vbjKDE3rbhZrjcwBtjQ6A+SuOQhO uBJtcRGxFyj1+CtBlVqmbg3OpVe24Zmw6AvJ4udeBPawTp+dprz/YcZYvPkcs3M3Bu42 vh0WU2nbYiJWx2G/6SajDBvX2wN3msjlRhYv/gEmv3zUVhuCXXIGZv95K5zCVN2q6C21 BX8EB3tG5Jnyv8SdqjtVl2lnLOmFkh14zUV3lsdUy5pONZnY67Eq78UE7L4MEnBjeTed TOb05ES4KhyKQcQwuNYRmzDMdPxqjes4rtpGIbUMqHUxJ4mDffE7dY2xIArQVXifNTfG iUDw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=FH2xtBV9; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-79713-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79713-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id z16-20020a170902ccd000b001dc0039037csi920726ple.281.2024.02.24.07.07.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 07:07:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79713-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=FH2xtBV9; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-79713-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79713-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 07D10282693 for ; Sat, 24 Feb 2024 15:07:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 765E8495CC; Sat, 24 Feb 2024 15:06:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="FH2xtBV9" Received: from vps.xff.cz (vps.xff.cz [195.181.215.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 439C845BF1 for ; Sat, 24 Feb 2024 15:06:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.181.215.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708787174; cv=none; b=AgS211C13SZkAnBHM+CpmJsvUN5CAO8Yzz7f4gA6pMktO6uiQEIn+PmIrR/HtJ6REA9KYSRxAzVhNZZ1rnyimno/LxrEwyDY/fcUKfqLtKDf11DHH0H5A5GNt6WR33WmaNw8s0BF3Cgu8lxG0S9ifiAgLrxbypcnUc4eFAWqfWQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708787174; c=relaxed/simple; bh=Q9SrX86zQBhe2kUdguButB8vQWP6AxlFFgogUXGLSXg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hucIP4MFOJ7xVyIIcwzlopbp0RPUsQCeL3DX6gS7dtj75rHF6TN2NXNVpOfRUAwQq3YsTxJVELehfqPmEQjK8ctepbSdP8GaotoXVikQoae1D9QUfDwrkVNHN9dSGaPXbl3ISd3Qw49Ay3QgCjKAwcl4WF9pkiGAu7lI4YXk790= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz; spf=pass smtp.mailfrom=xff.cz; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b=FH2xtBV9; arc=none smtp.client-ip=195.181.215.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xff.cz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xff.cz; s=mail; t=1708787168; bh=Q9SrX86zQBhe2kUdguButB8vQWP6AxlFFgogUXGLSXg=; h=From:To:Cc:Subject:Date:References:From; b=FH2xtBV96s+MQ/h8BDgC0Qt5cWu1LxwDvCiUwEQ9BJP6dsQZxf1n9g6vHmOa9+agR cvRrm6HaOGJhtukSydgJLcnz+30E8g/FuuDRe0MCJBZhMxsqzeHXjftxR7Exyl84Hc 1yIQ2xFSS9U0Xh061kZxFcqJ0gsqHLewKtdkcHws= From: =?utf-8?q?Ond=C5=99ej_Jirman?= To: linux-kernel@vger.kernel.org, Maxime Ripard , Chen-Yu Tsai , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Jernej Skrabec , Samuel Holland Cc: Ondrej Jirman , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH v2 3/3] drm/sun4i: Fix layer zpos change/atomic modesetting Date: Sat, 24 Feb 2024 16:06:00 +0100 Message-ID: <20240224150604.3855534-4-megi@xff.cz> In-Reply-To: <20240224150604.3855534-1-megi@xff.cz> References: <20240224150604.3855534-1-megi@xff.cz> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791793269214196200 X-GMAIL-MSGID: 1791793269214196200 From: Ondrej Jirman Identical configurations of planes can lead to different (and wrong) layer -> pipe routing at HW level, depending on the order of atomic plane changes. For example: - Layer 1 is configured to zpos 0 and thus uses pipe 0. No other layer is enabled. This is a typical situation at boot. - When a compositor takes over and layer 3 is enabled, sun8i_ui_layer_enable() will get called with old_zpos=0 zpos=1, which will lead to incorrect disabling of pipe 0 and enabling of pipe 1. What happens is that sun8i_ui_layer_enable() function may disable blender pipes even if it is no longer assigned to its layer. To correct this, move the routing setup out of individual plane's atomic_update into crtc's atomic_update, where it can be calculated and updated all at once. Remove the atomic_disable callback because it is no longer needed. Signed-off-by: Ondrej Jirman Reviewed-by: Jernej Skrabec --- drivers/gpu/drm/sun4i/sun8i_mixer.c | 61 +++++++++++++++++++++ drivers/gpu/drm/sun4i/sun8i_mixer.h | 6 +++ drivers/gpu/drm/sun4i/sun8i_ui_layer.c | 73 +------------------------ drivers/gpu/drm/sun4i/sun8i_vi_layer.c | 74 +------------------------- 4 files changed, 71 insertions(+), 143 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c b/drivers/gpu/drm/sun4i/sun8i_mixer.c index bdeb9b80e038..bd0fe2c6624e 100644 --- a/drivers/gpu/drm/sun4i/sun8i_mixer.c +++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c @@ -250,12 +250,73 @@ int sun8i_mixer_drm_format_to_hw(u32 format, u32 *hw_format) return -EINVAL; } +static void sun8i_layer_enable(struct sun8i_layer *layer, bool enable) +{ + u32 ch_base = sun8i_channel_base(layer->mixer, layer->channel); + u32 val, reg, mask; + + if (layer->type == SUN8I_LAYER_TYPE_UI) { + val = enable ? SUN8I_MIXER_CHAN_UI_LAYER_ATTR_EN : 0; + mask = SUN8I_MIXER_CHAN_UI_LAYER_ATTR_EN; + reg = SUN8I_MIXER_CHAN_UI_LAYER_ATTR(ch_base, layer->overlay); + } else { + val = enable ? SUN8I_MIXER_CHAN_VI_LAYER_ATTR_EN : 0; + mask = SUN8I_MIXER_CHAN_VI_LAYER_ATTR_EN; + reg = SUN8I_MIXER_CHAN_VI_LAYER_ATTR(ch_base, layer->overlay); + } + + regmap_update_bits(layer->mixer->engine.regs, reg, mask, val); +} + static void sun8i_mixer_commit(struct sunxi_engine *engine, struct drm_crtc *crtc, struct drm_atomic_state *state) { + struct sun8i_mixer *mixer = engine_to_sun8i_mixer(engine); + u32 bld_base = sun8i_blender_base(mixer); + struct drm_plane_state *plane_state; + struct drm_plane *plane; + u32 route = 0, pipe_en = 0; + DRM_DEBUG_DRIVER("Committing changes\n"); + drm_for_each_plane(plane, state->dev) { + struct sun8i_layer *layer = plane_to_sun8i_layer(plane); + bool enable; + int zpos; + + if (!(plane->possible_crtcs & drm_crtc_mask(crtc)) || layer->mixer != mixer) + continue; + + plane_state = drm_atomic_get_new_plane_state(state, plane); + if (!plane_state) + plane_state = plane->state; + + enable = plane_state->crtc && plane_state->visible; + zpos = plane_state->normalized_zpos; + + DRM_DEBUG_DRIVER(" plane %d: chan=%d ovl=%d en=%d zpos=%d\n", + plane->base.id, layer->channel, layer->overlay, + enable, zpos); + + /* + * We always update the layer enable bit, because it can clear + * spontaneously for unknown reasons. + */ + sun8i_layer_enable(layer, enable); + + if (!enable) + continue; + + /* Route layer to pipe based on zpos */ + route |= layer->channel << SUN8I_MIXER_BLEND_ROUTE_PIPE_SHIFT(zpos); + pipe_en |= SUN8I_MIXER_BLEND_PIPE_CTL_EN(zpos); + } + + regmap_write(mixer->engine.regs, SUN8I_MIXER_BLEND_ROUTE(bld_base), route); + regmap_write(mixer->engine.regs, SUN8I_MIXER_BLEND_PIPE_CTL(bld_base), + pipe_en | SUN8I_MIXER_BLEND_PIPE_CTL_FC_EN(0)); + regmap_write(engine->regs, SUN8I_MIXER_GLOBAL_DBUFF, SUN8I_MIXER_GLOBAL_DBUFF_ENABLE); } diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.h b/drivers/gpu/drm/sun4i/sun8i_mixer.h index 5a610ee30301..d7898c9c9cc0 100644 --- a/drivers/gpu/drm/sun4i/sun8i_mixer.h +++ b/drivers/gpu/drm/sun4i/sun8i_mixer.h @@ -186,9 +186,15 @@ struct sun8i_mixer { struct clk *mod_clk; }; +enum { + SUN8I_LAYER_TYPE_UI, + SUN8I_LAYER_TYPE_VI, +}; + struct sun8i_layer { struct drm_plane plane; struct sun8i_mixer *mixer; + int type; int channel; int overlay; }; diff --git a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c index 248fbb606ede..b90e5edef4e8 100644 --- a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c +++ b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c @@ -24,55 +24,6 @@ #include "sun8i_ui_layer.h" #include "sun8i_ui_scaler.h" -static void sun8i_ui_layer_enable(struct sun8i_mixer *mixer, int channel, - int overlay, bool enable, unsigned int zpos, - unsigned int old_zpos) -{ - u32 val, bld_base, ch_base; - - bld_base = sun8i_blender_base(mixer); - ch_base = sun8i_channel_base(mixer, channel); - - DRM_DEBUG_DRIVER("%sabling channel %d overlay %d\n", - enable ? "En" : "Dis", channel, overlay); - - if (enable) - val = SUN8I_MIXER_CHAN_UI_LAYER_ATTR_EN; - else - val = 0; - - regmap_update_bits(mixer->engine.regs, - SUN8I_MIXER_CHAN_UI_LAYER_ATTR(ch_base, overlay), - SUN8I_MIXER_CHAN_UI_LAYER_ATTR_EN, val); - - if (!enable || zpos != old_zpos) { - regmap_update_bits(mixer->engine.regs, - SUN8I_MIXER_BLEND_PIPE_CTL(bld_base), - SUN8I_MIXER_BLEND_PIPE_CTL_EN(old_zpos), - 0); - - regmap_update_bits(mixer->engine.regs, - SUN8I_MIXER_BLEND_ROUTE(bld_base), - SUN8I_MIXER_BLEND_ROUTE_PIPE_MSK(old_zpos), - 0); - } - - if (enable) { - val = SUN8I_MIXER_BLEND_PIPE_CTL_EN(zpos); - - regmap_update_bits(mixer->engine.regs, - SUN8I_MIXER_BLEND_PIPE_CTL(bld_base), - val, val); - - val = channel << SUN8I_MIXER_BLEND_ROUTE_PIPE_SHIFT(zpos); - - regmap_update_bits(mixer->engine.regs, - SUN8I_MIXER_BLEND_ROUTE(bld_base), - SUN8I_MIXER_BLEND_ROUTE_PIPE_MSK(zpos), - val); - } -} - static void sun8i_ui_layer_update_alpha(struct sun8i_mixer *mixer, int channel, int overlay, struct drm_plane *plane) { @@ -259,36 +210,18 @@ static int sun8i_ui_layer_atomic_check(struct drm_plane *plane, true, true); } -static void sun8i_ui_layer_atomic_disable(struct drm_plane *plane, - struct drm_atomic_state *state) -{ - struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, - plane); - struct sun8i_layer *layer = plane_to_sun8i_layer(plane); - unsigned int old_zpos = old_state->normalized_zpos; - struct sun8i_mixer *mixer = layer->mixer; - - sun8i_ui_layer_enable(mixer, layer->channel, layer->overlay, false, 0, - old_zpos); -} static void sun8i_ui_layer_atomic_update(struct drm_plane *plane, struct drm_atomic_state *state) { - struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, - plane); struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, plane); struct sun8i_layer *layer = plane_to_sun8i_layer(plane); unsigned int zpos = new_state->normalized_zpos; - unsigned int old_zpos = old_state->normalized_zpos; struct sun8i_mixer *mixer = layer->mixer; - if (!new_state->visible) { - sun8i_ui_layer_enable(mixer, layer->channel, - layer->overlay, false, 0, old_zpos); + if (!new_state->crtc || !new_state->visible) return; - } sun8i_ui_layer_update_coord(mixer, layer->channel, layer->overlay, plane, zpos); @@ -298,13 +231,10 @@ static void sun8i_ui_layer_atomic_update(struct drm_plane *plane, layer->overlay, plane); sun8i_ui_layer_update_buffer(mixer, layer->channel, layer->overlay, plane); - sun8i_ui_layer_enable(mixer, layer->channel, layer->overlay, - true, zpos, old_zpos); } static const struct drm_plane_helper_funcs sun8i_ui_layer_helper_funcs = { .atomic_check = sun8i_ui_layer_atomic_check, - .atomic_disable = sun8i_ui_layer_atomic_disable, .atomic_update = sun8i_ui_layer_atomic_update, }; @@ -390,6 +320,7 @@ struct sun8i_layer *sun8i_ui_layer_init_one(struct drm_device *drm, drm_plane_helper_add(&layer->plane, &sun8i_ui_layer_helper_funcs); layer->mixer = mixer; + layer->type = SUN8I_LAYER_TYPE_UI; layer->channel = channel; layer->overlay = 0; diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c index 0c0f1ac80517..9c09d9c08496 100644 --- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c +++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c @@ -18,55 +18,6 @@ #include "sun8i_vi_layer.h" #include "sun8i_vi_scaler.h" -static void sun8i_vi_layer_enable(struct sun8i_mixer *mixer, int channel, - int overlay, bool enable, unsigned int zpos, - unsigned int old_zpos) -{ - u32 val, bld_base, ch_base; - - bld_base = sun8i_blender_base(mixer); - ch_base = sun8i_channel_base(mixer, channel); - - DRM_DEBUG_DRIVER("%sabling VI channel %d overlay %d\n", - enable ? "En" : "Dis", channel, overlay); - - if (enable) - val = SUN8I_MIXER_CHAN_VI_LAYER_ATTR_EN; - else - val = 0; - - regmap_update_bits(mixer->engine.regs, - SUN8I_MIXER_CHAN_VI_LAYER_ATTR(ch_base, overlay), - SUN8I_MIXER_CHAN_VI_LAYER_ATTR_EN, val); - - if (!enable || zpos != old_zpos) { - regmap_update_bits(mixer->engine.regs, - SUN8I_MIXER_BLEND_PIPE_CTL(bld_base), - SUN8I_MIXER_BLEND_PIPE_CTL_EN(old_zpos), - 0); - - regmap_update_bits(mixer->engine.regs, - SUN8I_MIXER_BLEND_ROUTE(bld_base), - SUN8I_MIXER_BLEND_ROUTE_PIPE_MSK(old_zpos), - 0); - } - - if (enable) { - val = SUN8I_MIXER_BLEND_PIPE_CTL_EN(zpos); - - regmap_update_bits(mixer->engine.regs, - SUN8I_MIXER_BLEND_PIPE_CTL(bld_base), - val, val); - - val = channel << SUN8I_MIXER_BLEND_ROUTE_PIPE_SHIFT(zpos); - - regmap_update_bits(mixer->engine.regs, - SUN8I_MIXER_BLEND_ROUTE(bld_base), - SUN8I_MIXER_BLEND_ROUTE_PIPE_MSK(zpos), - val); - } -} - static void sun8i_vi_layer_update_alpha(struct sun8i_mixer *mixer, int channel, int overlay, struct drm_plane *plane) { @@ -393,36 +344,17 @@ static int sun8i_vi_layer_atomic_check(struct drm_plane *plane, true, true); } -static void sun8i_vi_layer_atomic_disable(struct drm_plane *plane, - struct drm_atomic_state *state) -{ - struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, - plane); - struct sun8i_layer *layer = plane_to_sun8i_vi_layer(plane); - unsigned int old_zpos = old_state->normalized_zpos; - struct sun8i_mixer *mixer = layer->mixer; - - sun8i_vi_layer_enable(mixer, layer->channel, layer->overlay, false, 0, - old_zpos); -} - static void sun8i_vi_layer_atomic_update(struct drm_plane *plane, struct drm_atomic_state *state) { - struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, - plane); struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, plane); struct sun8i_layer *layer = plane_to_sun8i_layer(plane); unsigned int zpos = new_state->normalized_zpos; - unsigned int old_zpos = old_state->normalized_zpos; struct sun8i_mixer *mixer = layer->mixer; - if (!new_state->visible) { - sun8i_vi_layer_enable(mixer, layer->channel, - layer->overlay, false, 0, old_zpos); + if (!new_state->crtc || !new_state->visible) return; - } sun8i_vi_layer_update_coord(mixer, layer->channel, layer->overlay, plane, zpos); @@ -432,13 +364,10 @@ static void sun8i_vi_layer_atomic_update(struct drm_plane *plane, layer->overlay, plane); sun8i_vi_layer_update_buffer(mixer, layer->channel, layer->overlay, plane); - sun8i_vi_layer_enable(mixer, layer->channel, layer->overlay, - true, zpos, old_zpos); } static const struct drm_plane_helper_funcs sun8i_vi_layer_helper_funcs = { .atomic_check = sun8i_vi_layer_atomic_check, - .atomic_disable = sun8i_vi_layer_atomic_disable, .atomic_update = sun8i_vi_layer_atomic_update, }; @@ -613,6 +542,7 @@ struct sun8i_layer *sun8i_vi_layer_init_one(struct drm_device *drm, drm_plane_helper_add(&layer->plane, &sun8i_vi_layer_helper_funcs); layer->mixer = mixer; + layer->type = SUN8I_LAYER_TYPE_VI; layer->channel = index; layer->overlay = 0;