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
);
27 le32_to_cpus(&hdr
->padding
);
31 virtio_gpu_bswap_32(void *ptr
, size_t size
)
33 #ifdef HOST_WORDS_BIGENDIAN
36 struct virtio_gpu_ctrl_hdr
*hdr
= (struct virtio_gpu_ctrl_hdr
*) ptr
;
38 virtio_gpu_ctrl_hdr_bswap(hdr
);
40 i
= sizeof(struct virtio_gpu_ctrl_hdr
);
42 le32_to_cpus((uint32_t *)(ptr
+ i
));
43 i
= i
+ sizeof(uint32_t);
50 virtio_gpu_t2d_bswap(struct virtio_gpu_transfer_to_host_2d
*t2d
)
52 virtio_gpu_ctrl_hdr_bswap(&t2d
->hdr
);
53 le32_to_cpus(&t2d
->r
.x
);
54 le32_to_cpus(&t2d
->r
.y
);
55 le32_to_cpus(&t2d
->r
.width
);
56 le32_to_cpus(&t2d
->r
.height
);
57 le64_to_cpus(&t2d
->offset
);
58 le32_to_cpus(&t2d
->resource_id
);
59 le32_to_cpus(&t2d
->padding
);