Commit c7a6ac4f authored by Gurchetan Singh's avatar Gurchetan Singh Committed by Gerd Hoffmann

drm/virtio: implement blob resources: hypercall interface

This implements the blob hypercall interface.
Signed-off-by: default avatarGurchetan Singh <gurchetansingh@chromium.org>
Acked-by: default avatarTomeu Vizoso <tomeu.vizoso@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20200924003214.662-13-gurchetansingh@chromium.orgSigned-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
parent 16845c5d
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <drm/drm_drv.h> #include <drm/drm_drv.h>
#include <drm/drm_encoder.h> #include <drm/drm_encoder.h>
#include <drm/drm_fb_helper.h> #include <drm/drm_fb_helper.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_gem.h> #include <drm/drm_gem.h>
#include <drm/drm_gem_shmem_helper.h> #include <drm/drm_gem_shmem_helper.h>
#include <drm/drm_ioctl.h> #include <drm/drm_ioctl.h>
...@@ -384,6 +385,20 @@ int virtio_gpu_cmd_map(struct virtio_gpu_device *vgdev, ...@@ -384,6 +385,20 @@ int virtio_gpu_cmd_map(struct virtio_gpu_device *vgdev,
void virtio_gpu_cmd_unmap(struct virtio_gpu_device *vgdev, void virtio_gpu_cmd_unmap(struct virtio_gpu_device *vgdev,
struct virtio_gpu_object *bo); struct virtio_gpu_object *bo);
void
virtio_gpu_cmd_resource_create_blob(struct virtio_gpu_device *vgdev,
struct virtio_gpu_object *bo,
struct virtio_gpu_object_params *params,
struct virtio_gpu_mem_entry *ents,
uint32_t nents);
void
virtio_gpu_cmd_set_scanout_blob(struct virtio_gpu_device *vgdev,
uint32_t scanout_id,
struct virtio_gpu_object *bo,
struct drm_framebuffer *fb,
uint32_t width, uint32_t height,
uint32_t x, uint32_t y);
/* virtgpu_display.c */ /* virtgpu_display.c */
int virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev); int virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev);
void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev); void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev);
......
...@@ -1237,3 +1237,68 @@ void virtio_gpu_cmd_unmap(struct virtio_gpu_device *vgdev, ...@@ -1237,3 +1237,68 @@ void virtio_gpu_cmd_unmap(struct virtio_gpu_device *vgdev,
virtio_gpu_queue_ctrl_buffer(vgdev, vbuf); virtio_gpu_queue_ctrl_buffer(vgdev, vbuf);
} }
void
virtio_gpu_cmd_resource_create_blob(struct virtio_gpu_device *vgdev,
struct virtio_gpu_object *bo,
struct virtio_gpu_object_params *params,
struct virtio_gpu_mem_entry *ents,
uint32_t nents)
{
struct virtio_gpu_resource_create_blob *cmd_p;
struct virtio_gpu_vbuffer *vbuf;
cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p));
memset(cmd_p, 0, sizeof(*cmd_p));
cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB);
cmd_p->hdr.ctx_id = cpu_to_le32(params->ctx_id);
cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle);
cmd_p->blob_mem = cpu_to_le32(params->blob_mem);
cmd_p->blob_flags = cpu_to_le32(params->blob_flags);
cmd_p->blob_id = cpu_to_le64(params->blob_id);
cmd_p->size = cpu_to_le64(params->size);
cmd_p->nr_entries = cpu_to_le32(nents);
vbuf->data_buf = ents;
vbuf->data_size = sizeof(*ents) * nents;
virtio_gpu_queue_ctrl_buffer(vgdev, vbuf);
bo->created = true;
}
void virtio_gpu_cmd_set_scanout_blob(struct virtio_gpu_device *vgdev,
uint32_t scanout_id,
struct virtio_gpu_object *bo,
struct drm_framebuffer *fb,
uint32_t width, uint32_t height,
uint32_t x, uint32_t y)
{
uint32_t i;
struct virtio_gpu_set_scanout_blob *cmd_p;
struct virtio_gpu_vbuffer *vbuf;
uint32_t format = virtio_gpu_translate_format(fb->format->format);
cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p));
memset(cmd_p, 0, sizeof(*cmd_p));
cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_SET_SCANOUT_BLOB);
cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle);
cmd_p->scanout_id = cpu_to_le32(scanout_id);
cmd_p->format = cpu_to_le32(format);
cmd_p->width = cpu_to_le32(fb->width);
cmd_p->height = cpu_to_le32(fb->height);
for (i = 0; i < 4; i++) {
cmd_p->strides[i] = cpu_to_le32(fb->pitches[i]);
cmd_p->offsets[i] = cpu_to_le32(fb->offsets[i]);
}
cmd_p->r.width = cpu_to_le32(width);
cmd_p->r.height = cpu_to_le32(height);
cmd_p->r.x = cpu_to_le32(x);
cmd_p->r.y = cpu_to_le32(y);
virtio_gpu_queue_ctrl_buffer(vgdev, vbuf);
}
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