dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
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 08/15] staging: vboxvideo: Atomic phase 2: Stop using plane->fb and crtc->*
Date: Sat, 29 Sep 2018 14:18:18 +0200	[thread overview]
Message-ID: <20180929121825.25765-9-hdegoede@redhat.com> (raw)
In-Reply-To: <20180929121825.25765-1-hdegoede@redhat.com>

Once we are fully atomic plane->fb will always be NULL and we also
should not access things like crtc->enabled and crt->[hw]mode.

Now that we've wired up the state object handlers, we always have a
plane_state and crtc_state so change the code referencing plane->fb and
crtc->* to use the data from the plane_state and crt_state instead.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/staging/vboxvideo/vbox_drv.h  |  1 -
 drivers/staging/vboxvideo/vbox_main.c | 16 +++++++++++-----
 drivers/staging/vboxvideo/vbox_mode.c | 15 +++++++--------
 3 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_drv.h b/drivers/staging/vboxvideo/vbox_drv.h
index 7fc668ff4465..fccb3851d6a3 100644
--- a/drivers/staging/vboxvideo/vbox_drv.h
+++ b/drivers/staging/vboxvideo/vbox_drv.h
@@ -199,7 +199,6 @@ int vbox_mode_init(struct vbox_private *vbox);
 void vbox_mode_fini(struct vbox_private *vbox);
 
 #define DRM_MODE_FB_CMD drm_mode_fb_cmd2
-#define CRTC_FB(crtc) ((crtc)->primary->fb)
 
 void vbox_enable_accel(struct vbox_private *vbox);
 void vbox_disable_accel(struct vbox_private *vbox);
diff --git a/drivers/staging/vboxvideo/vbox_main.c b/drivers/staging/vboxvideo/vbox_main.c
index 95100c5976e4..3b82d483ab51 100644
--- a/drivers/staging/vboxvideo/vbox_main.c
+++ b/drivers/staging/vboxvideo/vbox_main.c
@@ -102,24 +102,30 @@ void vbox_framebuffer_dirty_rectangles(struct drm_framebuffer *fb,
 				       unsigned int num_rects)
 {
 	struct vbox_private *vbox = fb->dev->dev_private;
+	struct drm_display_mode *mode;
 	struct drm_crtc *crtc;
+	int crtc_x, crtc_y;
 	unsigned int i;
 
 	mutex_lock(&vbox->hw_mutex);
 	list_for_each_entry(crtc, &fb->dev->mode_config.crtc_list, head) {
-		if (CRTC_FB(crtc) != fb)
+		if (crtc->primary->state->fb != fb)
 			continue;
 
+		mode = &crtc->state->mode;
+		crtc_x = crtc->primary->state->src_x >> 16;
+		crtc_y = crtc->primary->state->src_y >> 16;
+
 		vbox_enable_accel(vbox);
 
 		for (i = 0; i < num_rects; ++i) {
 			struct vbva_cmd_hdr cmd_hdr;
 			unsigned int crtc_id = to_vbox_crtc(crtc)->crtc_id;
 
-			if ((rects[i].x1 > crtc->x + crtc->hwmode.hdisplay) ||
-			    (rects[i].y1 > crtc->y + crtc->hwmode.vdisplay) ||
-			    (rects[i].x2 < crtc->x) ||
-			    (rects[i].y2 < crtc->y))
+			if ((rects[i].x1 > crtc_x + mode->hdisplay) ||
+			    (rects[i].y1 > crtc_y + mode->vdisplay) ||
+			    (rects[i].x2 < crtc_x) ||
+			    (rects[i].y2 < crtc_y))
 				continue;
 
 			cmd_hdr.x = (s16)rects[i].x1;
diff --git a/drivers/staging/vboxvideo/vbox_mode.c b/drivers/staging/vboxvideo/vbox_mode.c
index cb897b672752..54e6aac784f7 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -46,6 +46,7 @@
  */
 static void vbox_do_modeset(struct drm_crtc *crtc)
 {
+	struct drm_framebuffer *fb = crtc->primary->state->fb;
 	struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
 	struct vbox_private *vbox;
 	int width, height, bpp, pitch;
@@ -55,8 +56,8 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
 	vbox = crtc->dev->dev_private;
 	width = vbox_crtc->width ? vbox_crtc->width : 640;
 	height = vbox_crtc->height ? vbox_crtc->height : 480;
-	bpp = crtc->enabled ? CRTC_FB(crtc)->format->cpp[0] * 8 : 32;
-	pitch = crtc->enabled ? CRTC_FB(crtc)->pitches[0] : width * bpp / 8;
+	bpp = fb ? fb->format->cpp[0] * 8 : 32;
+	pitch = fb ? fb->pitches[0] : width * bpp / 8;
 	x_offset = vbox->single_framebuffer ? vbox_crtc->x : vbox_crtc->x_hint;
 	y_offset = vbox->single_framebuffer ? vbox_crtc->y : vbox_crtc->y_hint;
 
@@ -66,14 +67,13 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
 	 * VirtualBox, certain parts of the code still assume that the first
 	 * screen is programmed this way, so try to fake it.
 	 */
-	if (vbox_crtc->crtc_id == 0 && crtc->enabled &&
+	if (vbox_crtc->crtc_id == 0 && fb &&
 	    vbox_crtc->fb_offset / pitch < 0xffff - crtc->y &&
 	    vbox_crtc->fb_offset % (bpp / 8) == 0) {
 		vbox_write_ioport(VBE_DISPI_INDEX_XRES, width);
 		vbox_write_ioport(VBE_DISPI_INDEX_YRES, height);
 		vbox_write_ioport(VBE_DISPI_INDEX_VIRT_WIDTH, pitch * 8 / bpp);
-		vbox_write_ioport(VBE_DISPI_INDEX_BPP,
-				  CRTC_FB(crtc)->format->cpp[0] * 8);
+		vbox_write_ioport(VBE_DISPI_INDEX_BPP, bpp);
 		vbox_write_ioport(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_ENABLED);
 		vbox_write_ioport(
 			VBE_DISPI_INDEX_X_OFFSET,
@@ -83,8 +83,7 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
 	}
 
 	flags = VBVA_SCREEN_F_ACTIVE;
-	flags |= (crtc->enabled && !vbox_crtc->blanked) ?
-		 0 : VBVA_SCREEN_F_BLANK;
+	flags |= (fb && !vbox_crtc->blanked) ? 0 : VBVA_SCREEN_F_BLANK;
 	flags |= vbox_crtc->disconnected ? VBVA_SCREEN_F_DISABLED : 0;
 	hgsmi_process_display_info(vbox->guest_pool, vbox_crtc->crtc_id,
 				   x_offset, y_offset,
@@ -176,7 +175,7 @@ static bool vbox_set_up_input_mapping(struct vbox_private *vbox)
 	 * Same fall-back if this is the fbdev frame-buffer.
 	 */
 	list_for_each_entry(crtci, &vbox->ddev.mode_config.crtc_list, head) {
-		fb = CRTC_FB(crtci);
+		fb = crtci->primary->state->fb;
 		if (!fb)
 			continue;
 
-- 
2.19.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  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 ` [PATCH resend 06/15] staging: vboxvideo: Atomic phase 1: Use drm_plane_helpers for primary plane Hans de Goede
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 ` Hans de Goede [this message]
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-9-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