From: Hans de Goede <hdegoede@redhat.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: devel@driverdev.osuosl.org, Hans de Goede <hdegoede@redhat.com>,
Michael Thayer <michael.thayer@oracle.com>,
dri-devel@lists.freedesktop.org
Subject: [PATCH resend 06/15] staging: vboxvideo: Atomic phase 1: Use drm_plane_helpers for primary plane
Date: Sat, 29 Sep 2018 14:18:16 +0200 [thread overview]
Message-ID: <20180929121825.25765-7-hdegoede@redhat.com> (raw)
In-Reply-To: <20180929121825.25765-1-hdegoede@redhat.com>
Use drm_plane_helpers for the primary plane and replace our custom
mode_set callback with drm_helper_crtc_mode_set.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/staging/vboxvideo/vbox_mode.c | 116 ++++++++++++++++++++------
1 file changed, 90 insertions(+), 26 deletions(-)
diff --git a/drivers/staging/vboxvideo/vbox_mode.c b/drivers/staging/vboxvideo/vbox_mode.c
index 75e112d33cf0..e560e36e7953 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -257,50 +257,48 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc *crtc,
mutex_unlock(&vbox->hw_mutex);
}
-static int vbox_crtc_mode_set(struct drm_crtc *crtc,
- struct drm_display_mode *mode,
- struct drm_display_mode *adjusted_mode,
- int x, int y, struct drm_framebuffer *old_fb)
+static void vbox_crtc_disable(struct drm_crtc *crtc)
{
- struct drm_framebuffer *new_fb = CRTC_FB(crtc);
- struct vbox_bo *bo = gem_to_vbox_bo(to_vbox_framebuffer(new_fb)->obj);
- int ret;
-
- ret = vbox_bo_pin(bo, TTM_PL_FLAG_VRAM);
- if (ret) {
- DRM_WARN("Error %d pinning new fb, out of video mem?\n", ret);
- return ret;
- }
-
- vbox_crtc_set_base_and_mode(crtc, new_fb, mode, x, y);
-
- if (old_fb) {
- bo = gem_to_vbox_bo(to_vbox_framebuffer(old_fb)->obj);
- vbox_bo_unpin(bo);
- }
+}
- return 0;
+static void vbox_crtc_prepare(struct drm_crtc *crtc)
+{
}
-static void vbox_crtc_disable(struct drm_crtc *crtc)
+static void vbox_crtc_commit(struct drm_crtc *crtc)
{
}
-static void vbox_crtc_prepare(struct drm_crtc *crtc)
+static void vbox_crtc_mode_set_nofb(struct drm_crtc *crtc)
{
+ /* We always set the mode when we set the fb/base */
}
-static void vbox_crtc_commit(struct drm_crtc *crtc)
+static void vbox_crtc_atomic_flush(struct drm_crtc *crtc,
+ struct drm_crtc_state *old_crtc_state)
{
+ struct drm_pending_vblank_event *event;
+ unsigned long flags;
+
+ if (crtc->state && crtc->state->event) {
+ event = crtc->state->event;
+ crtc->state->event = NULL;
+
+ spin_lock_irqsave(&crtc->dev->event_lock, flags);
+ drm_crtc_send_vblank_event(crtc, event);
+ spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
+ }
}
static const struct drm_crtc_helper_funcs vbox_crtc_helper_funcs = {
.dpms = vbox_crtc_dpms,
.mode_fixup = vbox_crtc_mode_fixup,
- .mode_set = vbox_crtc_mode_set,
+ .mode_set = drm_helper_crtc_mode_set,
+ .mode_set_nofb = vbox_crtc_mode_set_nofb,
.disable = vbox_crtc_disable,
.prepare = vbox_crtc_prepare,
.commit = vbox_crtc_commit,
+ .atomic_flush = vbox_crtc_atomic_flush,
};
static void vbox_crtc_reset(struct drm_crtc *crtc)
@@ -320,6 +318,63 @@ static const struct drm_crtc_funcs vbox_crtc_funcs = {
.destroy = vbox_crtc_destroy,
};
+static int vbox_primary_atomic_check(struct drm_plane *plane,
+ struct drm_plane_state *new_state)
+{
+ return 0;
+}
+
+static void vbox_primary_atomic_update(struct drm_plane *plane,
+ struct drm_plane_state *old_state)
+{
+ struct drm_crtc *crtc = plane->state->crtc;
+ struct drm_framebuffer *fb = plane->state->fb;
+
+ vbox_crtc_set_base_and_mode(crtc, fb, &crtc->state->mode,
+ plane->state->src_x >> 16,
+ plane->state->src_y >> 16);
+}
+
+void vbox_primary_atomic_disable(struct drm_plane *plane,
+ struct drm_plane_state *old_state)
+{
+ struct drm_crtc *crtc = old_state->crtc;
+
+ /* vbox_do_modeset checks plane->state->fb and will disable if NULL */
+ vbox_crtc_set_base_and_mode(crtc, old_state->fb, &crtc->state->mode,
+ old_state->src_x >> 16,
+ old_state->src_y >> 16);
+}
+
+static int vbox_primary_prepare_fb(struct drm_plane *plane,
+ struct drm_plane_state *new_state)
+{
+ struct vbox_bo *bo;
+ int ret;
+
+ if (!new_state->fb)
+ return 0;
+
+ bo = gem_to_vbox_bo(to_vbox_framebuffer(new_state->fb)->obj);
+ ret = vbox_bo_pin(bo, TTM_PL_FLAG_VRAM);
+ if (ret)
+ DRM_WARN("Error %d pinning new fb, out of video mem?\n", ret);
+
+ return ret;
+}
+
+static void vbox_primary_cleanup_fb(struct drm_plane *plane,
+ struct drm_plane_state *old_state)
+{
+ struct vbox_bo *bo;
+
+ if (!old_state->fb)
+ return;
+
+ bo = gem_to_vbox_bo(to_vbox_framebuffer(old_state->fb)->obj);
+ vbox_bo_unpin(bo);
+}
+
static int vbox_cursor_atomic_check(struct drm_plane *plane,
struct drm_plane_state *new_state)
{
@@ -479,8 +534,16 @@ static const uint32_t vbox_primary_plane_formats[] = {
DRM_FORMAT_ARGB8888,
};
+static const struct drm_plane_helper_funcs vbox_primary_helper_funcs = {
+ .atomic_check = vbox_primary_atomic_check,
+ .atomic_update = vbox_primary_atomic_update,
+ .atomic_disable = vbox_primary_atomic_disable,
+ .prepare_fb = vbox_primary_prepare_fb,
+ .cleanup_fb = vbox_primary_cleanup_fb,
+};
+
static const struct drm_plane_funcs vbox_primary_plane_funcs = {
- .update_plane = drm_primary_helper_update,
+ .update_plane = drm_plane_helper_update,
.disable_plane = drm_primary_helper_disable,
.destroy = drm_primary_helper_destroy,
};
@@ -499,6 +562,7 @@ static struct drm_plane *vbox_create_plane(struct vbox_private *vbox,
if (type == DRM_PLANE_TYPE_PRIMARY) {
funcs = &vbox_primary_plane_funcs;
formats = vbox_primary_plane_formats;
+ helper_funcs = &vbox_primary_helper_funcs;
num_formats = ARRAY_SIZE(vbox_primary_plane_formats);
} else if (type == DRM_PLANE_TYPE_CURSOR) {
funcs = &vbox_cursor_plane_funcs;
--
2.19.0
next prev parent reply other threads:[~2018-09-29 12:18 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-29 12:18 [PATCH resend 00/15] staging: vboxvideo: Convert to atomic modesetting API Hans de Goede
2018-09-29 12:18 ` [PATCH resend 01/15] staging: vboxvideo: Cleanup vbox_set_up_input_mapping() Hans de Goede
2018-09-29 12:18 ` [PATCH resend 02/15] staging: vboxvideo: Remove empty encoder_helper_funcs Hans de Goede
2018-09-29 12:18 ` [PATCH resend 03/15] staging: vboxvideo: Temporarily remove page_flip support Hans de Goede
2018-09-29 12:18 ` [PATCH resend 04/15] staging: vboxvideo: Cache mode width, height and crtc panning in vbox_crtc Hans de Goede
2018-09-29 12:18 ` [PATCH resend 05/15] staging: vboxvideo: Atomic phase 1: convert cursor to universal plane Hans de Goede
2018-09-29 12:18 ` Hans de Goede [this message]
2018-09-29 12:18 ` [PATCH resend 07/15] staging: vboxvideo: Atomic phase 2: Wire up state object handlers Hans de Goede
2018-09-29 12:18 ` [PATCH resend 08/15] staging: vboxvideo: Atomic phase 2: Stop using plane->fb and crtc->* Hans de Goede
2018-09-29 12:18 ` [PATCH resend 09/15] staging: vboxvideo: Atomic phase 3: Switch last bits over to atomic Hans de Goede
2018-09-29 12:18 ` [PATCH resend 10/15] staging: vboxvideo: Restore page-flip support Hans de Goede
2018-09-29 12:18 ` [PATCH resend 11/15] staging: vboxvideo: Fix DPMS support after atomic conversion Hans de Goede
2018-09-29 12:18 ` [PATCH resend 12/15] staging: vboxvideo: Replace crtc_helper enable/disable functions Hans de Goede
2018-09-29 12:18 ` [PATCH resend 13/15] staging: vboxvideo: Call drm_atomic_helper_check_plane_state from atomic_check Hans de Goede
2018-09-29 12:18 ` [PATCH resend 14/15] staging: vboxvideo: Drop unnecessary drm_connector_helper_funcs callbacks Hans de Goede
2018-09-29 12:18 ` [PATCH resend 15/15] staging: vboxvideo: Use more drm_fb_helper functions Hans de Goede
2018-10-01 7:25 ` [PATCH resend 00/15] staging: vboxvideo: Convert to atomic modesetting API Dan Carpenter
2018-10-01 9:20 ` Hans de Goede
2018-10-05 16:01 ` Daniel Vetter
2018-10-06 8:12 ` Hans de Goede
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=20180929121825.25765-7-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=devel@driverdev.osuosl.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=michael.thayer@oracle.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