From: Daniel Vetter <daniel@ffwll.ch>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 34/36] drm/tegra: Track active planes in CRTC state
Date: Tue, 20 Jan 2015 12:18:45 +0100 [thread overview]
Message-ID: <20150120111845.GA10113@phenom.ffwll.local> (raw)
In-Reply-To: <1421750935-4023-35-git-send-email-thierry.reding@gmail.com>
On Tue, Jan 20, 2015 at 11:48:53AM +0100, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> Wrap struct drm_crtc_state in a driver-specific structure and add the
> planes field which keeps track of which planes are updated or disabled
> during a modeset. This allows atomic updates of the the display engine
> at ->atomic_flush() time.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
commit 6ddd388ab222b66b596342becc76d5031c0e2fc8
Author: Rob Clark <robdclark@gmail.com>
Date: Fri Nov 21 15:28:31 2014 -0500
drm/atomic: track bitmask of planes attached to crtc
added this to the core since it seems to be generally useful. Does tegra
need more?
-Daniel
> ---
> drivers/gpu/drm/tegra/dc.c | 72 ++++++++++++++++++++++++++++------------------
> 1 file changed, 44 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
> index 52ae563cb531..835de4398c8f 100644
> --- a/drivers/gpu/drm/tegra/dc.c
> +++ b/drivers/gpu/drm/tegra/dc.c
> @@ -54,6 +54,8 @@ struct tegra_dc_state {
> struct clk *clk;
> unsigned long pclk;
> unsigned int div;
> +
> + u32 planes;
> };
>
> static inline struct tegra_dc_state *to_dc_state(struct drm_crtc_state *state)
> @@ -64,20 +66,6 @@ static inline struct tegra_dc_state *to_dc_state(struct drm_crtc_state *state)
> return NULL;
> }
>
> -static void tegra_dc_window_commit(struct tegra_dc *dc, unsigned int index)
> -{
> - u32 value = WIN_A_ACT_REQ << index;
> -
> - tegra_dc_writel(dc, value << 8, DC_CMD_STATE_CONTROL);
> - tegra_dc_writel(dc, value, DC_CMD_STATE_CONTROL);
> -}
> -
> -static void tegra_dc_cursor_commit(struct tegra_dc *dc)
> -{
> - tegra_dc_writel(dc, CURSOR_ACT_REQ << 8, DC_CMD_STATE_CONTROL);
> - tegra_dc_writel(dc, CURSOR_ACT_REQ, DC_CMD_STATE_CONTROL);
> -}
> -
> /*
> * Reads the active copy of a register. This takes the dc->lock spinlock to
> * prevent races with the VBLANK processing which also needs access to the
> @@ -395,8 +383,6 @@ static void tegra_dc_setup_window(struct tegra_dc *dc, unsigned int index,
> break;
> }
>
> - tegra_dc_window_commit(dc, index);
> -
> spin_unlock_irqrestore(&dc->lock, flags);
> }
>
> @@ -439,9 +425,28 @@ static void tegra_plane_cleanup_fb(struct drm_plane *plane,
> {
> }
>
> +static int tegra_plane_state_add(struct tegra_plane *plane,
> + struct drm_plane_state *state)
> +{
> + struct drm_crtc_state *crtc_state;
> + struct tegra_dc_state *tegra;
> +
> + /* Propagate errors from allocation or locking failures. */
> + crtc_state = drm_atomic_plane_get_crtc_state(state);
> + if (IS_ERR(crtc_state))
> + return PTR_ERR(crtc_state);
> +
> + tegra = to_dc_state(crtc_state);
> +
> + tegra->planes |= WIN_A_ACT_REQ << plane->index;
> +
> + return 0;
> +}
> +
> static int tegra_plane_atomic_check(struct drm_plane *plane,
> struct drm_plane_state *state)
> {
> + struct tegra_plane *tegra = to_tegra_plane(plane);
> struct tegra_dc *dc = to_tegra_dc(state->crtc);
> struct tegra_bo_tiling tiling;
> int err;
> @@ -472,6 +477,10 @@ static int tegra_plane_atomic_check(struct drm_plane *plane,
> }
> }
>
> + err = tegra_plane_state_add(tegra, state);
> + if (err < 0)
> + return err;
> +
> return 0;
> }
>
> @@ -538,8 +547,6 @@ static void tegra_plane_atomic_disable(struct drm_plane *plane,
> value &= ~WIN_ENABLE;
> tegra_dc_writel(dc, value, DC_WIN_WIN_OPTIONS);
>
> - tegra_dc_window_commit(dc, p->index);
> -
> spin_unlock_irqrestore(&dc->lock, flags);
> }
>
> @@ -599,6 +606,9 @@ static const u32 tegra_cursor_plane_formats[] = {
> static int tegra_cursor_atomic_check(struct drm_plane *plane,
> struct drm_plane_state *state)
> {
> + struct tegra_plane *tegra = to_tegra_plane(plane);
> + int err;
> +
> /* no need for further checks if the plane is being disabled */
> if (!state->crtc)
> return 0;
> @@ -616,6 +626,10 @@ static int tegra_cursor_atomic_check(struct drm_plane *plane,
> state->crtc_w != 128 && state->crtc_w != 256)
> return -EINVAL;
>
> + err = tegra_plane_state_add(tegra, state);
> + if (err < 0)
> + return err;
> +
> return 0;
> }
>
> @@ -680,9 +694,6 @@ static void tegra_cursor_atomic_update(struct drm_plane *plane,
> value = (state->crtc_y & 0x3fff) << 16 | (state->crtc_x & 0x3fff);
> tegra_dc_writel(dc, value, DC_DISP_CURSOR_POSITION);
>
> - /* apply changes */
> - tegra_dc_cursor_commit(dc);
> - tegra_dc_commit(dc);
> }
>
> static void tegra_cursor_atomic_disable(struct drm_plane *plane,
> @@ -700,9 +711,6 @@ static void tegra_cursor_atomic_disable(struct drm_plane *plane,
> value = tegra_dc_readl(dc, DC_DISP_DISP_WIN_OPTIONS);
> value &= ~CURSOR_ENABLE;
> tegra_dc_writel(dc, value, DC_DISP_DISP_WIN_OPTIONS);
> -
> - tegra_dc_cursor_commit(dc);
> - tegra_dc_commit(dc);
> }
>
> static const struct drm_plane_funcs tegra_cursor_plane_funcs = {
> @@ -734,6 +742,13 @@ static struct drm_plane *tegra_dc_cursor_plane_create(struct drm_device *drm,
> if (!plane)
> return ERR_PTR(-ENOMEM);
>
> + /*
> + * We'll treat the cursor as an overlay plane with index 6 here so
> + * that the update and activation request bits in DC_CMD_STATE_CONTROL
> + * match up.
> + */
> + plane->index = 6;
> +
> num_formats = ARRAY_SIZE(tegra_cursor_plane_formats);
> formats = tegra_cursor_plane_formats;
>
> @@ -1029,7 +1044,6 @@ static void tegra_crtc_disable(struct drm_crtc *crtc)
> }
>
> drm_crtc_vblank_off(crtc);
> - tegra_dc_commit(dc);
> }
>
> static bool tegra_crtc_mode_fixup(struct drm_crtc *crtc,
> @@ -1207,10 +1221,7 @@ static void tegra_crtc_prepare(struct drm_crtc *crtc)
>
> static void tegra_crtc_commit(struct drm_crtc *crtc)
> {
> - struct tegra_dc *dc = to_tegra_dc(crtc);
> -
> drm_crtc_vblank_on(crtc);
> - tegra_dc_commit(dc);
> }
>
> static int tegra_crtc_atomic_check(struct drm_crtc *crtc,
> @@ -1235,6 +1246,11 @@ static void tegra_crtc_atomic_begin(struct drm_crtc *crtc)
>
> static void tegra_crtc_atomic_flush(struct drm_crtc *crtc)
> {
> + struct tegra_dc_state *state = to_dc_state(crtc->state);
> + struct tegra_dc *dc = to_tegra_dc(crtc);
> +
> + tegra_dc_writel(dc, state->planes << 8, DC_CMD_STATE_CONTROL);
> + tegra_dc_writel(dc, state->planes, DC_CMD_STATE_CONTROL);
> }
>
> static const struct drm_crtc_helper_funcs tegra_crtc_helper_funcs = {
> --
> 2.1.3
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2015-01-20 11:18 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-20 10:48 [PATCH 00/36] drm/tegra: Atomic mode-setting conversion Thierry Reding
2015-01-20 10:48 ` [PATCH 01/36] clk: Introduce clk_try_parent() Thierry Reding
2015-01-20 18:02 ` Mike Turquette
2015-01-20 18:16 ` Rob Clark
2015-01-21 15:12 ` Thierry Reding
[not found] ` <1421750935-4023-2-git-send-email-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-01-20 19:21 ` Stephen Boyd
2015-01-21 15:05 ` Thierry Reding
2015-01-21 16:13 ` [PATCH v2] clk: Introduce clk_has_parent() Thierry Reding
[not found] ` <1421856780-32103-1-git-send-email-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-01-22 0:16 ` Stephen Boyd
[not found] ` <54C04145.1010906-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2015-01-22 7:37 ` Thierry Reding
2015-01-22 20:25 ` Stephen Boyd
2015-01-23 9:34 ` Thierry Reding
2015-01-25 1:02 ` Mike Turquette
2015-01-20 10:48 ` [PATCH 02/36] drm/plane: Make ->atomic_update() mandatory Thierry Reding
2015-01-20 11:10 ` Daniel Vetter
[not found] ` <1421750935-4023-3-git-send-email-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-01-20 13:51 ` Rob Clark
2015-01-23 9:18 ` Thierry Reding
2015-01-23 9:26 ` [PATCH v2] " Thierry Reding
2015-01-20 10:48 ` [PATCH 03/36] drm/plane: Add optional ->atomic_disable() callback Thierry Reding
2015-01-20 11:13 ` Daniel Vetter
2015-01-22 18:57 ` Gustavo Padovan
2015-01-23 9:28 ` [PATCH v4] " Thierry Reding
2015-01-20 10:48 ` [PATCH 04/36] drm/atomic: Add ->atomic_check() to encoder helpers Thierry Reding
2015-01-20 11:07 ` Daniel Vetter
2015-01-20 10:48 ` [PATCH 05/36] drm/atomic: Add drm_atomic_plane_get_crtc_state() Thierry Reding
2015-01-20 11:10 ` Daniel Vetter
[not found] ` <20150120111011.GX10113-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2015-01-23 9:32 ` Thierry Reding
2015-01-20 10:48 ` [PATCH 06/36] drm/tegra: Use tegra_commit_dc() in output drivers Thierry Reding
2015-01-20 10:48 ` [PATCH 07/36] drm/tegra: Stop CRTC at CRTC disable time Thierry Reding
2015-01-20 10:48 ` [PATCH 08/36] drm/tegra: dc: Wait for idle when disabled Thierry Reding
2015-01-20 10:48 ` [PATCH 09/36] drm/tegra: Move tegra_drm_mode_funcs to the core Thierry Reding
2015-01-20 10:48 ` [PATCH 10/36] drm/tegra: dc: No longer disable planes at CRTC disable Thierry Reding
2015-01-20 10:48 ` [PATCH 11/36] drm/tegra: Convert output midlayer to helpers Thierry Reding
2015-01-20 10:48 ` [PATCH 12/36] drm/tegra: output: Make ->setup_clock() optional Thierry Reding
2015-01-20 10:48 ` [PATCH 13/36] drm/tegra: Add tegra_dc_setup_clock() helper Thierry Reding
2015-01-20 10:48 ` [PATCH 14/36] drm/tegra: rgb: Demidlayer Thierry Reding
2015-01-20 10:48 ` [PATCH 15/36] drm/tegra: hdmi: Demidlayer Thierry Reding
2015-01-20 10:48 ` [PATCH 16/36] drm/tegra: dsi: Demidlayer Thierry Reding
2015-01-20 10:48 ` [PATCH 17/36] drm/tegra: sor: Demidlayer Thierry Reding
2015-01-20 10:48 ` [PATCH 18/36] drm/tegra: debugfs cleanup cannot fail Thierry Reding
2015-01-20 10:48 ` [PATCH 19/36] drm/tegra: Remove remnants of the output midlayer Thierry Reding
2015-01-20 10:48 ` [PATCH 20/36] drm/tegra: Output cleanup functions cannot fail Thierry Reding
2015-01-20 10:48 ` [PATCH 21/36] drm/tegra: dc: Do not needlessly deassert reset Thierry Reding
2015-01-20 10:48 ` [PATCH 22/36] drm/tegra: Atomic conversion, phase 1 Thierry Reding
2015-01-20 10:48 ` [PATCH 23/36] drm/tegra: Atomic conversion, phase 2 Thierry Reding
2015-01-20 10:48 ` [PATCH 24/36] drm/tegra: Atomic conversion, phase 3, step 1 Thierry Reding
2015-01-20 10:48 ` [PATCH 25/36] drm/tegra: dc: Store clock setup in atomic state Thierry Reding
2015-01-20 10:48 ` [PATCH 26/36] drm/tegra: rgb: Implement ->atomic_check() Thierry Reding
2015-01-20 10:48 ` [PATCH 27/36] drm/tegra: dsi: " Thierry Reding
2015-01-20 10:48 ` [PATCH 28/36] drm/tegra: hdmi: " Thierry Reding
2015-01-20 10:48 ` [PATCH 29/36] drm/tegra: sor: " Thierry Reding
2015-01-20 10:48 ` [PATCH 30/36] drm/tegra: dc: Use atomic clock state in modeset Thierry Reding
2015-01-20 10:48 ` [PATCH 31/36] drm/tegra: Atomic conversion, phase 3, step 2 Thierry Reding
2015-01-20 10:48 ` [PATCH 32/36] drm/tegra: Atomic conversion, phase 3, step 3 Thierry Reding
2015-01-20 10:48 ` [PATCH 33/36] drm/tegra: Remove unused ->mode_fixup() callbacks Thierry Reding
2015-01-20 10:48 ` [PATCH 34/36] drm/tegra: Track active planes in CRTC state Thierry Reding
2015-01-20 11:18 ` Daniel Vetter [this message]
2015-01-20 11:43 ` Thierry Reding
[not found] ` <1421750935-4023-35-git-send-email-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-01-23 9:31 ` [PATCH v2] " Thierry Reding
2015-01-20 10:48 ` [PATCH 35/36] drm/tegra: Track tiling and format in plane state Thierry Reding
2015-01-20 10:48 ` [PATCH 36/36] drm/tegra: dc: Unify enabling the display controller Thierry Reding
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=20150120111845.GA10113@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=thierry.reding@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).