vga: use common endian swap macros
The constant-expression bswap is provided by const_le32(), and GET_PLANE() can also be implemented using cpu_to_le32(). Remove the custom macros in vga.c. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
977542ded7
commit
937de9a981
@ -90,58 +90,27 @@ const uint8_t gr_mask[16] = {
|
|||||||
0x00, /* 0x0f */
|
0x00, /* 0x0f */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define cbswap_32(__x) \
|
#define GET_PLANE(data, p) ((cpu_to_le32(data) >> ((p) * 8)) & 0xff)
|
||||||
((uint32_t)( \
|
|
||||||
(((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \
|
|
||||||
(((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \
|
|
||||||
(((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \
|
|
||||||
(((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) ))
|
|
||||||
|
|
||||||
#if HOST_BIG_ENDIAN
|
|
||||||
#define PAT(x) cbswap_32(x)
|
|
||||||
#else
|
|
||||||
#define PAT(x) (x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HOST_BIG_ENDIAN
|
|
||||||
#define BIG 1
|
|
||||||
#else
|
|
||||||
#define BIG 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HOST_BIG_ENDIAN
|
|
||||||
#define GET_PLANE(data, p) (((data) >> (24 - (p) * 8)) & 0xff)
|
|
||||||
#else
|
|
||||||
#define GET_PLANE(data, p) (((data) >> ((p) * 8)) & 0xff)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const uint32_t mask16[16] = {
|
static const uint32_t mask16[16] = {
|
||||||
PAT(0x00000000),
|
const_le32(0x00000000),
|
||||||
PAT(0x000000ff),
|
const_le32(0x000000ff),
|
||||||
PAT(0x0000ff00),
|
const_le32(0x0000ff00),
|
||||||
PAT(0x0000ffff),
|
const_le32(0x0000ffff),
|
||||||
PAT(0x00ff0000),
|
const_le32(0x00ff0000),
|
||||||
PAT(0x00ff00ff),
|
const_le32(0x00ff00ff),
|
||||||
PAT(0x00ffff00),
|
const_le32(0x00ffff00),
|
||||||
PAT(0x00ffffff),
|
const_le32(0x00ffffff),
|
||||||
PAT(0xff000000),
|
const_le32(0xff000000),
|
||||||
PAT(0xff0000ff),
|
const_le32(0xff0000ff),
|
||||||
PAT(0xff00ff00),
|
const_le32(0xff00ff00),
|
||||||
PAT(0xff00ffff),
|
const_le32(0xff00ffff),
|
||||||
PAT(0xffff0000),
|
const_le32(0xffff0000),
|
||||||
PAT(0xffff00ff),
|
const_le32(0xffff00ff),
|
||||||
PAT(0xffffff00),
|
const_le32(0xffffff00),
|
||||||
PAT(0xffffffff),
|
const_le32(0xffffffff),
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef PAT
|
|
||||||
|
|
||||||
#if HOST_BIG_ENDIAN
|
|
||||||
#define PAT(x) (x)
|
|
||||||
#else
|
|
||||||
#define PAT(x) cbswap_32(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static uint32_t expand4[256];
|
static uint32_t expand4[256];
|
||||||
static uint16_t expand2[256];
|
static uint16_t expand2[256];
|
||||||
static uint8_t expand4to8[16];
|
static uint8_t expand4to8[16];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user