From: Thomas Zimmermann <tzimmermann@suse.de>
To: kraxel@redhat.com, airlied@redhat.com, daniel@ffwll.ch,
sam@ravnborg.org, javierm@redhat.com,
dri-devel@lists.freedesktop.org
Cc: Thomas Zimmermann <tzimmermann@suse.de>,
virtualization@lists.linux-foundation.org
Subject: [PATCH 15/17] drm/cirrus: Introduce struct cirrus_primary_plane_state
Date: Wed, 15 Feb 2023 17:15:15 +0100 [thread overview]
Message-ID: <20230215161517.5113-16-tzimmermann@suse.de> (raw)
In-Reply-To: <20230215161517.5113-1-tzimmermann@suse.de>
The cirrus driver maintains plane state, format and pitch, in it's
device structure. Introduce a plane state for the primary plane to
store the values.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/tiny/cirrus.c | 59 ++++++++++++++++++++++++++++++++++-
1 file changed, 58 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/tiny/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
index 8a1ae94d9106..ec6b918dce7b 100644
--- a/drivers/gpu/drm/tiny/cirrus.c
+++ b/drivers/gpu/drm/tiny/cirrus.c
@@ -74,6 +74,16 @@ struct cirrus_device {
#define to_cirrus(_dev) container_of(_dev, struct cirrus_device, dev)
+struct cirrus_primary_plane_state {
+ struct drm_shadow_plane_state base;
+};
+
+static inline struct cirrus_primary_plane_state *
+to_cirrus_primary_plane_state(struct drm_plane_state *plane_state)
+{
+ return container_of(plane_state, struct cirrus_primary_plane_state, base.base);
+};
+
/* ------------------------------------------------------------------ */
/*
* The meat of this driver. The core passes us a mode and we have to program
@@ -406,11 +416,58 @@ static const struct drm_plane_helper_funcs cirrus_primary_plane_helper_funcs = {
.atomic_update = cirrus_primary_plane_helper_atomic_update,
};
+static struct drm_plane_state *
+cirrus_primary_plane_atomic_duplicate_state(struct drm_plane *plane)
+{
+ struct drm_plane_state *plane_state = plane->state;
+ struct cirrus_primary_plane_state *new_primary_plane_state;
+ struct drm_shadow_plane_state *new_shadow_plane_state;
+
+ if (!plane_state)
+ return NULL;
+
+ new_primary_plane_state = kzalloc(sizeof(*new_primary_plane_state), GFP_KERNEL);
+ if (!new_primary_plane_state)
+ return NULL;
+ new_shadow_plane_state = &new_primary_plane_state->base;
+
+ __drm_gem_duplicate_shadow_plane_state(plane, new_shadow_plane_state);
+
+ return &new_shadow_plane_state->base;
+}
+
+static void cirrus_primary_plane_atomic_destroy_state(struct drm_plane *plane,
+ struct drm_plane_state *plane_state)
+{
+ struct cirrus_primary_plane_state *primary_plane_state =
+ to_cirrus_primary_plane_state(plane_state);
+
+ __drm_gem_destroy_shadow_plane_state(&primary_plane_state->base);
+ kfree(primary_plane_state);
+}
+
+static void cirrus_reset_primary_plane(struct drm_plane *plane)
+{
+ struct cirrus_primary_plane_state *primary_plane_state;
+
+ if (plane->state) {
+ cirrus_primary_plane_atomic_destroy_state(plane, plane->state);
+ plane->state = NULL; /* must be set to NULL here */
+ }
+
+ primary_plane_state = kzalloc(sizeof(*primary_plane_state), GFP_KERNEL);
+ if (!primary_plane_state)
+ return;
+ __drm_gem_reset_shadow_plane(plane, &primary_plane_state->base);
+}
+
static const struct drm_plane_funcs cirrus_primary_plane_funcs = {
.update_plane = drm_atomic_helper_update_plane,
.disable_plane = drm_atomic_helper_disable_plane,
.destroy = drm_plane_cleanup,
- DRM_GEM_SHADOW_PLANE_FUNCS,
+ .reset = cirrus_reset_primary_plane,
+ .atomic_duplicate_state = cirrus_primary_plane_atomic_duplicate_state,
+ .atomic_destroy_state = cirrus_primary_plane_atomic_destroy_state,
};
static int cirrus_crtc_helper_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *state)
--
2.39.1
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next prev parent reply other threads:[~2023-02-15 16:15 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-15 16:15 [PATCH 00/17] cirrus: Modernize the cirrus driver Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 01/17] drm/cirrus: Compute blit destination offset in single location Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 02/17] drm/cirrus: Replace cpp value with format Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 03/17] drm/cirrus: Use drm_fb_blit() to update scanout buffer Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 04/17] drm/cirrus: Move drm_dev_{enter, exit}() into DRM helpers Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 05/17] drm/cirrus: Split cirrus_mode_set() into smaller functions Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 06/17] drm/cirrus: Integrate connector into pipeline code Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 07/17] drm/cirrus: Move primary-plane format arrays Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 08/17] drm/cirrus: Convert to regular atomic helpers Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 09/17] drm/cirrus: Enable damage clipping on primary plane Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 10/17] drm/cirrus: Inline cirrus_fb_blit_rect() Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 11/17] drm/cirrus: Remove format test from cirrus_fb_create() Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 12/17] drm/cirrus: Remove size " Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 13/17] drm/cirrus: Test mode against video-memory size in device-wide mode_valid Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 14/17] drm/cirrus: Inline cirrus_check_size() into primary-plane atomic_check Thomas Zimmermann
2023-02-15 16:15 ` Thomas Zimmermann [this message]
2023-02-15 16:15 ` [PATCH 16/17] drm/cirrus: Store HW format/pitch in primary-plane state Thomas Zimmermann
2023-02-15 16:15 ` [PATCH 17/17] drm/cirrus: Use VGA macro constants to unblank Thomas Zimmermann
2023-02-16 11:33 ` Gerd Hoffmann
2023-02-16 12:03 ` Thomas Zimmermann
2023-02-16 12:33 ` Gerd Hoffmann
2023-02-16 12:52 ` Ville Syrjälä
2023-02-16 13:19 ` Gerd Hoffmann
2023-02-16 13:21 ` Thomas Zimmermann
2023-02-16 17:20 ` Ville Syrjälä
2023-02-17 8:23 ` Thomas Zimmermann
2023-02-20 14:22 ` Thomas Zimmermann
2023-02-20 15:39 ` Gerd Hoffmann
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=20230215161517.5113-16-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@redhat.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=javierm@redhat.com \
--cc=kraxel@redhat.com \
--cc=sam@ravnborg.org \
--cc=virtualization@lists.linux-foundation.org \
/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).