Skip to contentSkip to conversation

drm/virtio: track virtual output state

PATCH In review Gerd Hoffmann 2 participants 3 messages Aug 13, 2018 – Sep 3, 2018

Subsystems (4)
lore
Share & tools
lore

Gerd Hoffmann

author maintainer
#0 lore raw

PATCH 1/1 drm/virtio: track virtual output state

Track whenever an virtual output (crtc) is enabled or disabled.

On atomic updates check for both framebuffer being present and crtc being enabled to figure whenever the output is active or not.

---
 drivers/gpu/drm/virtio/virtgpu_drv.h     | 1 +
 drivers/gpu/drm/virtio/virtgpu_display.c | 4 ++++
 drivers/gpu/drm/virtio/virtgpu_plane.c   | 2 +-
 3 files changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_drv.h +1 -0
index 65605e207b..d46f10e656 100644
@@ -114,6 +114,7 @@ struct virtio_gpu_output {
 	struct virtio_gpu_update_cursor cursor;
 	int cur_x;
 	int cur_y;
+	bool enabled;
 };
 #define drm_crtc_to_virtio_gpu_output(x) \
 	container_of(x, struct virtio_gpu_output, crtc)
drivers/gpu/drm/virtio/virtgpu_display.c +4 -0
index 25503b9335..9f1e0a669d 100644
@@ -109,6 +109,9 @@ static void virtio_gpu_crtc_mode_set_nofb(struct drm_crtc *crtc)
 static void virtio_gpu_crtc_atomic_enable(struct drm_crtc *crtc,
 					  struct drm_crtc_state *old_state)
 {
+	struct virtio_gpu_output *output = drm_crtc_to_virtio_gpu_output(crtc);
+
+	output->enabled = true;
 }
 
 static void virtio_gpu_crtc_atomic_disable(struct drm_crtc *crtc,
@@ -119,6 +122,7 @@ static void virtio_gpu_crtc_atomic_disable(struct drm_crtc *crtc,
 	struct virtio_gpu_output *output = drm_crtc_to_virtio_gpu_output(crtc);
 
 	virtio_gpu_cmd_set_scanout(vgdev, output->index, 0, 0, 0, 0, 0);
+	output->enabled = false;
 }
 
 static int virtio_gpu_crtc_atomic_check(struct drm_crtc *crtc,
drivers/gpu/drm/virtio/virtgpu_plane.c +1 -1
index dc5b5b2b7a..88f2fb8c61 100644
@@ -152,7 +152,7 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
 	if (WARN_ON(!output))
 		return;
 
-	if (plane->state->fb) {
+	if (plane->state->fb && output->enabled) {
 		vgfb = to_virtio_gpu_framebuffer(plane->state->fb);
 		bo = gem_to_virtio_gpu_obj(vgfb->base.obj[0]);
 		handle = bo->hw_res_handle;
Signature · 1 line
2.9.3
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Gerd Hoffmann

Track whenever an virtual output (crtc) is enabled or disabled.

On atomic updates check for both framebuffer being present and crtc being enabled to figure whenever the output is active or not.

Quoted 60 lines
---
 drivers/gpu/drm/virtio/virtgpu_drv.h     | 1 +
 drivers/gpu/drm/virtio/virtgpu_display.c | 4 ++++
 drivers/gpu/drm/virtio/virtgpu_plane.c   | 2 +-
 3 files changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_drv.h +1 -0
index 65605e207b..d46f10e656 100644
@@ -114,6 +114,7 @@ struct virtio_gpu_output {
        struct virtio_gpu_update_cursor cursor;
        int cur_x;
        int cur_y;
+       bool enabled;
 };
 #define drm_crtc_to_virtio_gpu_output(x) \
        container_of(x, struct virtio_gpu_output, crtc)
drivers/gpu/drm/virtio/virtgpu_display.c +4 -0
index 25503b9335..9f1e0a669d 100644
@@ -109,6 +109,9 @@ static void virtio_gpu_crtc_mode_set_nofb(struct drm_crtc *crtc)
 static void virtio_gpu_crtc_atomic_enable(struct drm_crtc *crtc,
                                          struct drm_crtc_state *old_state)
 {
+       struct virtio_gpu_output *output = drm_crtc_to_virtio_gpu_output(crtc);
+
+       output->enabled = true;
 }
 
 static void virtio_gpu_crtc_atomic_disable(struct drm_crtc *crtc,
@@ -119,6 +122,7 @@ static void virtio_gpu_crtc_atomic_disable(struct drm_crtc *crtc,
        struct virtio_gpu_output *output = drm_crtc_to_virtio_gpu_output(crtc);
 
        virtio_gpu_cmd_set_scanout(vgdev, output->index, 0, 0, 0, 0, 0);
+       output->enabled = false;
 }
 
 static int virtio_gpu_crtc_atomic_check(struct drm_crtc *crtc,
drivers/gpu/drm/virtio/virtgpu_plane.c +1 -2
index dc5b5b2b7a..88f2fb8c61 100644
@@ -152,7 +152,7 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
        if (WARN_ON(!output))
                return;
 
-       if (plane->state->fb) {
+       if (plane->state->fb && output->enabled) {
                vgfb = to_virtio_gpu_framebuffer(plane->state->fb);
                bo = gem_to_virtio_gpu_obj(vgfb->base.obj[0]);
                handle = bo->hw_res_handle;
--

2.9.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Gerd Hoffmann
Quoted 7 lines · Gerd Hoffmann

Track whenever an virtual output (crtc) is enabled or disabled.

On atomic updates check for both framebuffer being present and crtc being enabled to figure whenever the output is active or not.

Quoted 56 lines
---
 drivers/gpu/drm/virtio/virtgpu_drv.h     | 1 +
 drivers/gpu/drm/virtio/virtgpu_display.c | 4 ++++
 drivers/gpu/drm/virtio/virtgpu_plane.c   | 2 +-
 3 files changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_drv.h +1 -0
index 65605e207b..d46f10e656 100644
@@ -114,6 +114,7 @@ struct virtio_gpu_output {
        struct virtio_gpu_update_cursor cursor;
        int cur_x;
        int cur_y;
+       bool enabled;
 };
 #define drm_crtc_to_virtio_gpu_output(x) \
        container_of(x, struct virtio_gpu_output, crtc)
drivers/gpu/drm/virtio/virtgpu_display.c +4 -0
index 25503b9335..9f1e0a669d 100644
@@ -109,6 +109,9 @@ static void virtio_gpu_crtc_mode_set_nofb(struct drm_crtc *crtc)
 static void virtio_gpu_crtc_atomic_enable(struct drm_crtc *crtc,
                                          struct drm_crtc_state *old_state)
 {
+       struct virtio_gpu_output *output = drm_crtc_to_virtio_gpu_output(crtc);
+
+       output->enabled = true;
 }
 
 static void virtio_gpu_crtc_atomic_disable(struct drm_crtc *crtc,
@@ -119,6 +122,7 @@ static void virtio_gpu_crtc_atomic_disable(struct drm_crtc *crtc,
        struct virtio_gpu_output *output = drm_crtc_to_virtio_gpu_output(crtc);
 
        virtio_gpu_cmd_set_scanout(vgdev, output->index, 0, 0, 0, 0, 0);
+       output->enabled = false;
 }
 
 static int virtio_gpu_crtc_atomic_check(struct drm_crtc *crtc,
drivers/gpu/drm/virtio/virtgpu_plane.c +1 -2
index dc5b5b2b7a..88f2fb8c61 100644
@@ -152,7 +152,7 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
        if (WARN_ON(!output))
                return;
 
-       if (plane->state->fb) {
+       if (plane->state->fb && output->enabled) {
                vgfb = to_virtio_gpu_framebuffer(plane->state->fb);
                bo = gem_to_virtio_gpu_obj(vgfb->base.obj[0]);
                handle = bo->hw_res_handle;
--

2.9.3

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel