From: Samuel Holland <samuel@sholland.org>
To: "Heiko Stübner" <heiko@sntech.de>,
"Sandy Huang" <hjc@rock-chips.com>,
dri-devel@lists.freedesktop.org
Cc: linux-rockchip@lists.infradead.org,
"Alistair Francis" <alistair@alistair23.me>,
"Ondřej Jirman" <x@xff.cz>,
"Andreas Kemnade" <andreas@kemnade.info>,
"Daniel Vetter" <daniel@ffwll.ch>,
"David Airlie" <airlied@linux.ie>,
"Geert Uytterhoeven" <geert@linux-m68k.org>,
"Samuel Holland" <samuel@sholland.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Liang Chen" <cl@rock-chips.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Michael Riesch" <michael.riesch@wolfvision.net>,
"Nicolas Frattaroli" <frattaroli.nicolas@gmail.com>,
"Peter Geis" <pgwipeout@gmail.com>,
"Rob Herring" <robh+dt@kernel.org>,
"Sam Ravnborg" <sam@ravnborg.org>,
"Thierry Reding" <thierry.reding@gmail.com>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [RFC PATCH 09/16] drm/rockchip: ebc: Implement global refreshes
Date: Wed, 13 Apr 2022 17:19:09 -0500 [thread overview]
Message-ID: <20220413221916.50995-10-samuel@sholland.org> (raw)
In-Reply-To: <20220413221916.50995-1-samuel@sholland.org>
The global refresh mode is used to initialize and clear the screen.
It is the most efficient refresh mode. It uses two pixel buffers (old
and new) and a frame count. The frame count is set to the number of
phases in the waveform. The hardware then looks up the combination of
(old pixel value, new pixel value, frame number) in the LUT and sends
the resulting polarity value to the display.
Signed-off-by: Samuel Holland <samuel@sholland.org>
---
drivers/gpu/drm/rockchip/rockchip_ebc.c | 48 ++++++++++++++++++++++++-
1 file changed, 47 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_ebc.c b/drivers/gpu/drm/rockchip/rockchip_ebc.c
index ca3173b28d1c..cb6dc567e94c 100644
--- a/drivers/gpu/drm/rockchip/rockchip_ebc.c
+++ b/drivers/gpu/drm/rockchip/rockchip_ebc.c
@@ -127,6 +127,7 @@
#define EBC_NUM_LUT_REGS 0x1000
#define EBC_NUM_SUPPLIES 3
+#define EBC_REFRESH_TIMEOUT msecs_to_jiffies(3000)
#define EBC_SUSPEND_DELAY_MS 2000
struct rockchip_ebc {
@@ -269,8 +270,23 @@ static void rockchip_ebc_global_refresh(struct rockchip_ebc *ebc,
{
struct drm_device *drm = &ebc->drm;
u32 gray4_size = ctx->gray4_size;
+ struct device *dev = drm->dev;
- drm_dbg(drm, "global refresh\n");
+ dma_sync_single_for_device(dev, virt_to_phys(ctx->next),
+ gray4_size, DMA_TO_DEVICE);
+ dma_sync_single_for_device(dev, virt_to_phys(ctx->prev),
+ gray4_size, DMA_TO_DEVICE);
+
+ reinit_completion(&ebc->display_end);
+ regmap_write(ebc->regmap, EBC_CONFIG_DONE,
+ EBC_CONFIG_DONE_REG_CONFIG_DONE);
+ regmap_write(ebc->regmap, EBC_DSP_START,
+ ebc->dsp_start |
+ EBC_DSP_START_DSP_FRM_TOTAL(ebc->lut.num_phases - 1) |
+ EBC_DSP_START_DSP_FRM_START);
+ if (!wait_for_completion_timeout(&ebc->display_end,
+ EBC_REFRESH_TIMEOUT))
+ drm_err(drm, "Refresh timed out!\n");
memcpy(ctx->prev, ctx->next, gray4_size);
}
@@ -289,6 +305,7 @@ static void rockchip_ebc_refresh(struct rockchip_ebc *ebc,
enum drm_epd_waveform waveform)
{
struct drm_device *drm = &ebc->drm;
+ u32 dsp_ctrl = 0, epd_ctrl = 0;
struct device *dev = drm->dev;
int ret, temperature;
@@ -334,11 +351,40 @@ static void rockchip_ebc_refresh(struct rockchip_ebc *ebc,
ebc->lut.buf, EBC_NUM_LUT_REGS);
}
+ regmap_write(ebc->regmap, EBC_DSP_START,
+ ebc->dsp_start);
+
+ /*
+ * The hardware has a separate bit for each mode, with some priority
+ * scheme between them. For clarity, only set one bit at a time.
+ */
+ if (global_refresh) {
+ dsp_ctrl |= EBC_DSP_CTRL_DSP_LUT_MODE;
+ } else {
+ epd_ctrl |= EBC_EPD_CTRL_DSP_THREE_WIN_MODE;
+ }
+ regmap_update_bits(ebc->regmap, EBC_EPD_CTRL,
+ EBC_EPD_CTRL_DSP_THREE_WIN_MODE,
+ epd_ctrl);
+ regmap_update_bits(ebc->regmap, EBC_DSP_CTRL,
+ EBC_DSP_CTRL_DSP_LUT_MODE,
+ dsp_ctrl);
+
+ regmap_write(ebc->regmap, EBC_WIN_MST0,
+ virt_to_phys(ctx->next));
+ regmap_write(ebc->regmap, EBC_WIN_MST1,
+ virt_to_phys(ctx->prev));
+
if (global_refresh)
rockchip_ebc_global_refresh(ebc, ctx);
else
rockchip_ebc_partial_refresh(ebc, ctx);
+ /* Drive the output pins low once the refresh is complete. */
+ regmap_write(ebc->regmap, EBC_DSP_START,
+ ebc->dsp_start |
+ EBC_DSP_START_DSP_OUT_LOW);
+
pm_runtime_mark_last_busy(dev);
pm_runtime_put_autosuspend(dev);
}
--
2.35.1
next prev parent reply other threads:[~2022-04-13 22:20 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-13 22:19 [RFC PATCH 00/16] drm/rockchip: Rockchip EBC ("E-Book Controller") display driver Samuel Holland
2022-04-13 22:19 ` [RFC PATCH 01/16] drm: Add a helper library for EPD drivers Samuel Holland
2022-04-13 22:19 ` [RFC PATCH 02/16] dt-bindings: display: rockchip: Add EBC binding Samuel Holland
2022-04-14 8:15 ` Andreas Kemnade
2022-04-15 3:00 ` Samuel Holland
2022-04-15 11:45 ` Andreas Kemnade
2022-04-13 22:19 ` [RFC PATCH 03/16] drm/rockchip: Add EBC platform driver skeleton Samuel Holland
2022-04-13 22:19 ` [RFC PATCH 04/16] drm/rockchip: ebc: Add DRM " Samuel Holland
2022-04-13 22:19 ` [RFC PATCH 05/16] drm/rockchip: ebc: Add CRTC mode setting Samuel Holland
2022-04-13 22:19 ` [RFC PATCH 06/16] drm/rockchip: ebc: Add CRTC refresh thread Samuel Holland
2022-04-13 22:19 ` [RFC PATCH 07/16] drm/rockchip: ebc: Add CRTC buffer management Samuel Holland
2022-04-13 22:19 ` [RFC PATCH 08/16] drm/rockchip: ebc: Add LUT loading Samuel Holland
2022-04-13 22:19 ` Samuel Holland [this message]
2022-04-13 22:19 ` [RFC PATCH 10/16] drm/rockchip: ebc: Implement partial refreshes Samuel Holland
2022-04-13 22:19 ` [RFC PATCH 11/16] drm/rockchip: ebc: Enable diff mode for " Samuel Holland
2022-04-13 22:19 ` [RFC PATCH 12/16] drm/rockchip: ebc: Add support for direct mode Samuel Holland
2022-04-13 22:19 ` [RFC PATCH 13/16] drm/rockchip: ebc: Add a panel reflection option Samuel Holland
2022-04-13 22:19 ` [RFC PATCH 14/16] drm/panel-simple: Add eInk ED103TC2 Samuel Holland
2022-04-13 22:19 ` [RFC PATCH 15/16] arm64: dts: rockchip: rk356x: Add EBC node Samuel Holland
2022-04-13 22:19 ` [RFC PATCH 16/16] [DO NOT MERGE] arm64: dts: rockchip: pinenote: Enable EBC display pipeline Samuel Holland
2022-04-14 8:50 ` [RFC PATCH 00/16] drm/rockchip: Rockchip EBC ("E-Book Controller") display driver Maxime Ripard
2022-05-25 17:18 ` Daniel Vetter
2022-05-31 8:58 ` Maxime Ripard
2022-06-01 12:35 ` Daniel Vetter
2022-06-08 14:48 ` Maxime Ripard
2022-06-08 15:34 ` Daniel Vetter
2022-04-21 6:43 ` Andreas Kemnade
2022-04-21 7:10 ` Nicolas Frattaroli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220413221916.50995-10-samuel@sholland.org \
--to=samuel@sholland.org \
--cc=airlied@linux.ie \
--cc=alistair@alistair23.me \
--cc=andreas@kemnade.info \
--cc=cl@rock-chips.com \
--cc=daniel@ffwll.ch \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=frattaroli.nicolas@gmail.com \
--cc=geert@linux-m68k.org \
--cc=heiko@sntech.de \
--cc=hjc@rock-chips.com \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=michael.riesch@wolfvision.net \
--cc=mripard@kernel.org \
--cc=pgwipeout@gmail.com \
--cc=robh+dt@kernel.org \
--cc=sam@ravnborg.org \
--cc=thierry.reding@gmail.com \
--cc=tzimmermann@suse.de \
--cc=x@xff.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®