4 * Copyright Red Hat, Inc. 2013-2014
7 * Dave Airlie <airlied@redhat.com>
8 * Gerd Hoffmann <kraxel@redhat.com>
10 * This work is licensed under the terms of the GNU GPL, version 2 or later.
11 * See the COPYING file in the top-level directory.
14 #ifndef HW_VIRTIO_GPU_BSWAP_H
15 #define HW_VIRTIO_GPU_BSWAP_H
17 #include "qemu/bswap.h"
18 #include "standard-headers/linux/virtio_gpu.h"
21 virtio_gpu_ctrl_hdr_bswap(struct virtio_gpu_ctrl_hdr
*hdr
)
23 le32_to_cpus(&hdr
->type
);
24 le32_to_cpus(&hdr
->flags
);
25 le64_to_cpus(&hdr
->fence_id
);
26 le32_to_cpus(&hdr
->ctx_id
);
30 virtio_gpu_bswap_32(void *ptr
, size_t size
)
35 struct virtio_gpu_ctrl_hdr
*hdr
= (struct virtio_gpu_ctrl_hdr
*) ptr
;
37 virtio_gpu_ctrl_hdr_bswap(hdr
);
39 i
= sizeof(struct virtio_gpu_ctrl_hdr
);
41 le32_to_cpus((uint32_t *)(ptr
+ i
));
42 i
= i
+ sizeof(uint32_t);
49 virtio_gpu_t2d_bswap(struct virtio_gpu_transfer_to_host_2d
*t2d
)
51 virtio_gpu_ctrl_hdr_bswap(&t2d
->hdr
);
52 le32_to_cpus(&t2d
->r
.x
);
53 le32_to_cpus(&t2d
->r
.y
);
54 le32_to_cpus(&t2d
->r
.width
);
55 le32_to_cpus(&t2d
->r
.height
);
56 le64_to_cpus(&t2d
->offset
);
57 le32_to_cpus(&t2d
->resource_id
);
58 le32_to_cpus(&t2d
->padding
);
62 virtio_gpu_create_blob_bswap(struct virtio_gpu_resource_create_blob
*cblob
)
64 virtio_gpu_ctrl_hdr_bswap(&cblob
->hdr
);
65 le32_to_cpus(&cblob
->resource_id
);
66 le32_to_cpus(&cblob
->blob_flags
);
67 le64_to_cpus(&cblob
->size
);
71 virtio_gpu_scanout_blob_bswap(struct virtio_gpu_set_scanout_blob
*ssb
)
73 virtio_gpu_bswap_32(ssb
, sizeof(*ssb
) - sizeof(ssb
->offsets
[3]));
74 le32_to_cpus(&ssb
->offsets
[3]);