Commit c0967617 authored by Gerd Hoffmann's avatar Gerd Hoffmann

drm/virtio: use damage info for display updates.

v2: remove shift by src_{x,y}, drm_atomic_helper_damage_merged()
    handles that for us (Chia-I Wu).
Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
Reviewed-by: default avatarChia-I Wu <olvaffe@gmail.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20191212125346.8334-4-kraxel@redhat.com
parent 7082e7a4
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
*/ */
#include <drm/drm_atomic_helper.h> #include <drm/drm_atomic_helper.h>
#include <drm/drm_damage_helper.h>
#include <drm/drm_fourcc.h> #include <drm/drm_fourcc.h>
#include <drm/drm_plane_helper.h> #include <drm/drm_plane_helper.h>
...@@ -103,21 +104,25 @@ static int virtio_gpu_plane_atomic_check(struct drm_plane *plane, ...@@ -103,21 +104,25 @@ static int virtio_gpu_plane_atomic_check(struct drm_plane *plane,
} }
static void virtio_gpu_update_dumb_bo(struct virtio_gpu_device *vgdev, static void virtio_gpu_update_dumb_bo(struct virtio_gpu_device *vgdev,
struct virtio_gpu_object *bo, struct drm_plane_state *state,
struct drm_plane_state *state) struct drm_rect *rect)
{ {
struct virtio_gpu_object *bo =
gem_to_virtio_gpu_obj(state->fb->obj[0]);
struct virtio_gpu_object_array *objs; struct virtio_gpu_object_array *objs;
uint32_t w = rect->x2 - rect->x1;
uint32_t h = rect->y2 - rect->y1;
uint32_t x = rect->x1;
uint32_t y = rect->y1;
uint32_t off = x * state->fb->format->cpp[0] +
y * state->fb->pitches[0];
objs = virtio_gpu_array_alloc(1); objs = virtio_gpu_array_alloc(1);
if (!objs) if (!objs)
return; return;
virtio_gpu_array_add_obj(objs, &bo->base.base); virtio_gpu_array_add_obj(objs, &bo->base.base);
virtio_gpu_cmd_transfer_to_host_2d
(vgdev, 0, virtio_gpu_cmd_transfer_to_host_2d(vgdev, off, w, h, x, y,
state->src_w >> 16,
state->src_h >> 16,
state->src_x >> 16,
state->src_y >> 16,
objs, NULL); objs, NULL);
} }
...@@ -127,8 +132,8 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane, ...@@ -127,8 +132,8 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
struct drm_device *dev = plane->dev; struct drm_device *dev = plane->dev;
struct virtio_gpu_device *vgdev = dev->dev_private; struct virtio_gpu_device *vgdev = dev->dev_private;
struct virtio_gpu_output *output = NULL; struct virtio_gpu_output *output = NULL;
struct virtio_gpu_framebuffer *vgfb;
struct virtio_gpu_object *bo; struct virtio_gpu_object *bo;
struct drm_rect rect;
if (plane->state->crtc) if (plane->state->crtc)
output = drm_crtc_to_virtio_gpu_output(plane->state->crtc); output = drm_crtc_to_virtio_gpu_output(plane->state->crtc);
...@@ -146,12 +151,14 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane, ...@@ -146,12 +151,14 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
return; return;
} }
if (!drm_atomic_helper_damage_merged(old_state, plane->state, &rect))
return;
virtio_gpu_disable_notify(vgdev); virtio_gpu_disable_notify(vgdev);
vgfb = to_virtio_gpu_framebuffer(plane->state->fb); bo = gem_to_virtio_gpu_obj(plane->state->fb->obj[0]);
bo = gem_to_virtio_gpu_obj(vgfb->base.obj[0]);
if (bo->dumb) if (bo->dumb)
virtio_gpu_update_dumb_bo(vgdev, bo, plane->state); virtio_gpu_update_dumb_bo(vgdev, plane->state, &rect);
if (plane->state->fb != old_state->fb || if (plane->state->fb != old_state->fb ||
plane->state->src_w != old_state->src_w || plane->state->src_w != old_state->src_w ||
...@@ -175,10 +182,10 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane, ...@@ -175,10 +182,10 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
} }
virtio_gpu_cmd_resource_flush(vgdev, bo->hw_res_handle, virtio_gpu_cmd_resource_flush(vgdev, bo->hw_res_handle,
plane->state->src_x >> 16, rect.x1,
plane->state->src_y >> 16, rect.y1,
plane->state->src_w >> 16, rect.x2 - rect.x1,
plane->state->src_h >> 16); rect.y2 - rect.y1);
virtio_gpu_enable_notify(vgdev); virtio_gpu_enable_notify(vgdev);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment