Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp755038ybt; Wed, 8 Jul 2020 10:50:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfkw+daqRQoHf0VaxPQDt9ZkRsFd11SCf+9ahWmxtlRSV1fD4aDVSiTGdNkha1WhOll0bZ X-Received: by 2002:a50:fb95:: with SMTP id e21mr9206172edq.245.1594230608240; Wed, 08 Jul 2020 10:50:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594230608; cv=none; d=google.com; s=arc-20160816; b=uWqYcJrrQ+iUPJrH8yac0ic7eTNsJim9cg8Ut6iRjbam/3bETc6VKYN9anwW/3i8Hi GXT7RfYkus7joyDQ85HILH8UdEbyIWyr4Etf50vQMOKJltFrsvfxQDcZ0GvIA0QjZruA gQ7vPzS+IFUUlCm1wCCbLnK78JgPchCDr1TU5r6qGL5wEgXRDFP+rpeVZmrt3fHvYk0/ akQ9uemU5B711UqKyXiXrjAddw3q13TwjnnkULN2MPJGSeNueV19hsmT+HKw8+R0Imlu 33yzCgD8Mmw4+G0wlgnuLZjS6zE7V0K52a0oGK11lvbVSZGBXipNbB4i837BekjmDyLl AcWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=36UbLzBQ7RjLWxEtt4ofelHXw0uE2Ft29VdIx7RKra8=; b=Hh19tt6GkjKv0Vf6cQ5Afkax9CAaSaJc7cZo69HTcWEX5ArziCykx1RydIx4xeBBX4 u9SlQrGaVxBLPZxgDn+X/yUBGUjXFxH7b96P6DenPH88rAc5JSZIdjTgKnkF0sMmUbcv ns+sgPsU6eB1thS5dRjNkbU+2wXdcqz+gvGZgPj2m9mPtHleaYOh4vc7vnDmepj5lBVV NCYoQQaN5bHQySCTX8QJ0bFNQF8EOdXohJEcxJ2duUEcJUAxaLB5BnT8/eQSFU8QjV81 xyrT7D2AMNS/W3Sm+ml1ucA5GrK0o89CwEu4qGcchBMVavh/zIy799RtrKjbwqExi09m d0gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=esDnVTnX; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=e8cnrg0H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d1si474468edr.113.2020.07.08.10.49.45; Wed, 08 Jul 2020 10:50:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=esDnVTnX; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=e8cnrg0H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726831AbgGHRnK (ORCPT + 99 others); Wed, 8 Jul 2020 13:43:10 -0400 Received: from wnew4-smtp.messagingengine.com ([64.147.123.18]:52765 "EHLO wnew4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726794AbgGHRnE (ORCPT ); Wed, 8 Jul 2020 13:43:04 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id 768D02F3; Wed, 8 Jul 2020 13:43:03 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 08 Jul 2020 13:43:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=36UbLzBQ7RjLW xEtt4ofelHXw0uE2Ft29VdIx7RKra8=; b=esDnVTnX3pCTTitKf9lUf+/ntlvjt gJHLDqkBO4L3GCOJOywA9NMelo4oeUd+1Z7nB/QIHSgsxlkVbIOqVEOchfvOn7cw ohi0LMrteaPsdZw4bVs0qOadFPbnyVF9nv4zsvM98ON/HF2A1A+x6S45zyL2NVIP alJrjp4vPtbzcuYDAlWb5Kcb0Yh6HcbmhwW5SlTLBA1UD9WRlbLfoFKN9g1CBPuv WkAGZT4DsueNzKOhvKsEIoMMtUNc29o+j1UfkmzUwbyTmTlVN3IFGdYXuiUtWbVz VaWlS9KCd8idcfpf/oh1yETP2oD5OBznI/e5jDeSyMopTS00YDMRNC3Nw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=36UbLzBQ7RjLWxEtt4ofelHXw0uE2Ft29VdIx7RKra8=; b=e8cnrg0H x/BIORGpVMUN+by7N6FjQW+3fWYa+h5a1v4Z3BA/d1FGOCVd/ef+Oa2Q8lEZyuOs cYrLg3QGPDk74UQ4aTazLZeC0DdYCAL0dGidUYZgR9qJ7ADqWEGBPsLu8ia550vA OclCEvHv8sBWy8Ug3Q3m0bJR8hm+ORzwvYsnBhxhtXIOSQW/x9uojB6V7uDvhahP YhGOwv3i/RyYlZyzrYBjbFv7+ICnWCW/lbjAFf6WMyOrkpJVdY8jtFLv5sFJLhV1 p04wlpFAfKJ0C+NcuTaCGPA6vQzC0jvMf9UNRoWH9mlHwyiu5/Qp7NTnw4FGmurh JRpk9ySX4Enh7A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudejgdduudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecukfhppeeltddrkeelrdeikedrjeeinecuvehluhhsthgvrhfuihiivgepudelne curfgrrhgrmhepmhgrihhlfhhrohhmpehmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA id AB0A8328005E; Wed, 8 Jul 2020 13:43:02 -0400 (EDT) From: Maxime Ripard To: Nicolas Saenz Julienne , Eric Anholt Cc: dri-devel@lists.freedesktop.org, linux-rpi-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Dave Stevenson , Tim Gover , Phil Elwell , Maxime Ripard Subject: [PATCH v4 22/78] drm/vc4: crtc: Move HVS init and close to a function Date: Wed, 8 Jul 2020 19:41:30 +0200 Message-Id: <840cb5324364e431b15d4105c85cebf8d12257f0.1594230107.git-series.maxime@cerno.tech> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to make further refactoring easier, let's move the HVS channel setup / teardown to their own function. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_hvs.c | 104 +++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 46 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_hvs.c b/drivers/gpu/drm/vc4/vc4_hvs.c index 50f9a9674a7e..78bb1c0b0b76 100644 --- a/drivers/gpu/drm/vc4/vc4_hvs.c +++ b/drivers/gpu/drm/vc4/vc4_hvs.c @@ -196,6 +196,62 @@ static void vc4_hvs_update_gamma_lut(struct drm_crtc *crtc) vc4_hvs_lut_load(crtc); } +static int vc4_hvs_init_channel(struct vc4_dev *vc4, struct drm_crtc *crtc, + struct drm_display_mode *mode, bool oneshot) +{ + struct vc4_crtc_state *vc4_crtc_state = to_vc4_crtc_state(crtc->state); + unsigned int chan = vc4_crtc_state->assigned_channel; + u32 dispctrl; + + /* Turn on the scaler, which will wait for vstart to start + * compositing. + * When feeding the transposer, we should operate in oneshot + * mode. + */ + dispctrl = SCALER_DISPCTRLX_ENABLE; + + if (!vc4->hvs->hvs5) + dispctrl |= VC4_SET_FIELD(mode->hdisplay, + SCALER_DISPCTRLX_WIDTH) | + VC4_SET_FIELD(mode->vdisplay, + SCALER_DISPCTRLX_HEIGHT) | + (oneshot ? SCALER_DISPCTRLX_ONESHOT : 0); + else + dispctrl |= VC4_SET_FIELD(mode->hdisplay, + SCALER5_DISPCTRLX_WIDTH) | + VC4_SET_FIELD(mode->vdisplay, + SCALER5_DISPCTRLX_HEIGHT) | + (oneshot ? SCALER5_DISPCTRLX_ONESHOT : 0); + + HVS_WRITE(SCALER_DISPCTRLX(chan), dispctrl); + + return 0; +} + +static void vc4_hvs_stop_channel(struct drm_device *dev, unsigned int chan) +{ + struct vc4_dev *vc4 = to_vc4_dev(dev); + + if (HVS_READ(SCALER_DISPCTRLX(chan)) & SCALER_DISPCTRLX_ENABLE) + return; + + HVS_WRITE(SCALER_DISPCTRLX(chan), + HVS_READ(SCALER_DISPCTRLX(chan)) | SCALER_DISPCTRLX_RESET); + HVS_WRITE(SCALER_DISPCTRLX(chan), + HVS_READ(SCALER_DISPCTRLX(chan)) & ~SCALER_DISPCTRLX_ENABLE); + + /* Once we leave, the scaler should be disabled and its fifo empty. */ + WARN_ON_ONCE(HVS_READ(SCALER_DISPCTRLX(chan)) & SCALER_DISPCTRLX_RESET); + + WARN_ON_ONCE(VC4_GET_FIELD(HVS_READ(SCALER_DISPSTATX(chan)), + SCALER_DISPSTATX_MODE) != + SCALER_DISPSTATX_MODE_DISABLED); + + WARN_ON_ONCE((HVS_READ(SCALER_DISPSTATX(chan)) & + (SCALER_DISPSTATX_FULL | SCALER_DISPSTATX_EMPTY)) != + SCALER_DISPSTATX_EMPTY); +} + int vc4_hvs_atomic_check(struct drm_crtc *crtc, struct drm_crtc_state *state) { @@ -268,63 +324,19 @@ void vc4_hvs_atomic_enable(struct drm_crtc *crtc, struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(crtc->state); struct drm_display_mode *mode = &crtc->state->adjusted_mode; bool oneshot = vc4_state->feed_txp; - u32 dispctrl; vc4_hvs_update_dlist(crtc); - - /* Turn on the scaler, which will wait for vstart to start - * compositing. - * When feeding the transposer, we should operate in oneshot - * mode. - */ - dispctrl = SCALER_DISPCTRLX_ENABLE; - - if (!vc4->hvs->hvs5) - dispctrl |= VC4_SET_FIELD(mode->hdisplay, - SCALER_DISPCTRLX_WIDTH) | - VC4_SET_FIELD(mode->vdisplay, - SCALER_DISPCTRLX_HEIGHT) | - (oneshot ? SCALER_DISPCTRLX_ONESHOT : 0); - else - dispctrl |= VC4_SET_FIELD(mode->hdisplay, - SCALER5_DISPCTRLX_WIDTH) | - VC4_SET_FIELD(mode->vdisplay, - SCALER5_DISPCTRLX_HEIGHT) | - (oneshot ? SCALER5_DISPCTRLX_ONESHOT : 0); - - HVS_WRITE(SCALER_DISPCTRLX(vc4_state->assigned_channel), dispctrl); + vc4_hvs_init_channel(vc4, crtc, mode, oneshot); } void vc4_hvs_atomic_disable(struct drm_crtc *crtc, struct drm_crtc_state *old_state) { struct drm_device *dev = crtc->dev; - struct vc4_dev *vc4 = to_vc4_dev(dev); struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(old_state); unsigned int chan = vc4_state->assigned_channel; - if (HVS_READ(SCALER_DISPCTRLX(chan)) & - SCALER_DISPCTRLX_ENABLE) { - HVS_WRITE(SCALER_DISPCTRLX(chan), - SCALER_DISPCTRLX_RESET); - - /* While the docs say that reset is self-clearing, it - * seems it doesn't actually. - */ - HVS_WRITE(SCALER_DISPCTRLX(chan), 0); - } - - /* Once we leave, the scaler should be disabled and its fifo empty. */ - - WARN_ON_ONCE(HVS_READ(SCALER_DISPCTRLX(chan)) & SCALER_DISPCTRLX_RESET); - - WARN_ON_ONCE(VC4_GET_FIELD(HVS_READ(SCALER_DISPSTATX(chan)), - SCALER_DISPSTATX_MODE) != - SCALER_DISPSTATX_MODE_DISABLED); - - WARN_ON_ONCE((HVS_READ(SCALER_DISPSTATX(chan)) & - (SCALER_DISPSTATX_FULL | SCALER_DISPSTATX_EMPTY)) != - SCALER_DISPSTATX_EMPTY); + vc4_hvs_stop_channel(dev, chan); } void vc4_hvs_atomic_flush(struct drm_crtc *crtc, -- git-series 0.9.1