Commit f9659329 authored by Gerd Hoffmann's avatar Gerd Hoffmann

drm/virtio: params struct for virtio_gpu_cmd_create_resource()

Add format, width and height fields to the virtio_gpu_object_params
struct.  With that in place we can use the parameter struct for
virtio_gpu_cmd_create_resource() calls too.
Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
Acked-by: default avatarNoralf Trønnes <noralf@tronnes.org>
Link: http://patchwork.freedesktop.org/patch/msgid/20190318113332.10900-4-kraxel@redhat.com
parent 4441235f
...@@ -51,6 +51,9 @@ ...@@ -51,6 +51,9 @@
#define DRIVER_PATCHLEVEL 0 #define DRIVER_PATCHLEVEL 0
struct virtio_gpu_object_params { struct virtio_gpu_object_params {
uint32_t format;
uint32_t width;
uint32_t height;
unsigned long size; unsigned long size;
}; };
...@@ -247,9 +250,7 @@ int virtio_gpu_alloc_vbufs(struct virtio_gpu_device *vgdev); ...@@ -247,9 +250,7 @@ int virtio_gpu_alloc_vbufs(struct virtio_gpu_device *vgdev);
void virtio_gpu_free_vbufs(struct virtio_gpu_device *vgdev); void virtio_gpu_free_vbufs(struct virtio_gpu_device *vgdev);
void virtio_gpu_cmd_create_resource(struct virtio_gpu_device *vgdev, void virtio_gpu_cmd_create_resource(struct virtio_gpu_device *vgdev,
struct virtio_gpu_object *bo, struct virtio_gpu_object *bo,
uint32_t format, struct virtio_gpu_object_params *params);
uint32_t width,
uint32_t height);
void virtio_gpu_cmd_unref_resource(struct virtio_gpu_device *vgdev, void virtio_gpu_cmd_unref_resource(struct virtio_gpu_device *vgdev,
uint32_t resource_id); uint32_t resource_id);
void virtio_gpu_cmd_transfer_to_host_2d(struct virtio_gpu_device *vgdev, void virtio_gpu_cmd_transfer_to_host_2d(struct virtio_gpu_device *vgdev,
......
...@@ -88,7 +88,6 @@ int virtio_gpu_mode_dumb_create(struct drm_file *file_priv, ...@@ -88,7 +88,6 @@ int virtio_gpu_mode_dumb_create(struct drm_file *file_priv,
struct virtio_gpu_object_params params = { 0 }; struct virtio_gpu_object_params params = { 0 };
int ret; int ret;
uint32_t pitch; uint32_t pitch;
uint32_t format;
if (args->bpp != 32) if (args->bpp != 32)
return -EINVAL; return -EINVAL;
...@@ -97,16 +96,17 @@ int virtio_gpu_mode_dumb_create(struct drm_file *file_priv, ...@@ -97,16 +96,17 @@ int virtio_gpu_mode_dumb_create(struct drm_file *file_priv,
args->size = pitch * args->height; args->size = pitch * args->height;
args->size = ALIGN(args->size, PAGE_SIZE); args->size = ALIGN(args->size, PAGE_SIZE);
params.format = virtio_gpu_translate_format(DRM_FORMAT_HOST_XRGB8888);
params.width = args->width;
params.height = args->height;
params.size = args->size; params.size = args->size;
ret = virtio_gpu_gem_create(file_priv, dev, &params, &gobj, ret = virtio_gpu_gem_create(file_priv, dev, &params, &gobj,
&args->handle); &args->handle);
if (ret) if (ret)
goto fail; goto fail;
format = virtio_gpu_translate_format(DRM_FORMAT_HOST_XRGB8888);
obj = gem_to_virtio_gpu_obj(gobj); obj = gem_to_virtio_gpu_obj(gobj);
virtio_gpu_cmd_create_resource(vgdev, obj, format, virtio_gpu_cmd_create_resource(vgdev, obj, &params);
args->width, args->height);
/* attach the object to the resource */ /* attach the object to the resource */
ret = virtio_gpu_object_attach(vgdev, obj, NULL); ret = virtio_gpu_object_attach(vgdev, obj, NULL);
......
...@@ -302,6 +302,9 @@ static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data, ...@@ -302,6 +302,9 @@ static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data,
INIT_LIST_HEAD(&validate_list); INIT_LIST_HEAD(&validate_list);
memset(&mainbuf, 0, sizeof(struct ttm_validate_buffer)); memset(&mainbuf, 0, sizeof(struct ttm_validate_buffer));
params.format = rc->format;
params.width = rc->width;
params.height = rc->height;
params.size = rc->size; params.size = rc->size;
/* allocate a single page size object */ /* allocate a single page size object */
...@@ -314,8 +317,7 @@ static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data, ...@@ -314,8 +317,7 @@ static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data,
obj = &qobj->gem_base; obj = &qobj->gem_base;
if (!vgdev->has_virgl_3d) { if (!vgdev->has_virgl_3d) {
virtio_gpu_cmd_create_resource(vgdev, qobj, rc->format, virtio_gpu_cmd_create_resource(vgdev, qobj, &params);
rc->width, rc->height);
ret = virtio_gpu_object_attach(vgdev, qobj, NULL); ret = virtio_gpu_object_attach(vgdev, qobj, NULL);
} else { } else {
......
...@@ -376,9 +376,7 @@ static int virtio_gpu_queue_cursor(struct virtio_gpu_device *vgdev, ...@@ -376,9 +376,7 @@ static int virtio_gpu_queue_cursor(struct virtio_gpu_device *vgdev,
/* create a basic resource */ /* create a basic resource */
void virtio_gpu_cmd_create_resource(struct virtio_gpu_device *vgdev, void virtio_gpu_cmd_create_resource(struct virtio_gpu_device *vgdev,
struct virtio_gpu_object *bo, struct virtio_gpu_object *bo,
uint32_t format, struct virtio_gpu_object_params *params)
uint32_t width,
uint32_t height)
{ {
struct virtio_gpu_resource_create_2d *cmd_p; struct virtio_gpu_resource_create_2d *cmd_p;
struct virtio_gpu_vbuffer *vbuf; struct virtio_gpu_vbuffer *vbuf;
...@@ -388,9 +386,9 @@ void virtio_gpu_cmd_create_resource(struct virtio_gpu_device *vgdev, ...@@ -388,9 +386,9 @@ void virtio_gpu_cmd_create_resource(struct virtio_gpu_device *vgdev,
cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_RESOURCE_CREATE_2D); cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_RESOURCE_CREATE_2D);
cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle); cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle);
cmd_p->format = cpu_to_le32(format); cmd_p->format = cpu_to_le32(params->format);
cmd_p->width = cpu_to_le32(width); cmd_p->width = cpu_to_le32(params->width);
cmd_p->height = cpu_to_le32(height); cmd_p->height = cpu_to_le32(params->height);
virtio_gpu_queue_ctrl_buffer(vgdev, vbuf); virtio_gpu_queue_ctrl_buffer(vgdev, vbuf);
bo->created = true; bo->created = true;
......
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