Commit 0d793797 authored by BALATON Zoltan's avatar BALATON Zoltan Committed by Blue Swirl
Browse files

vmware_vga: Coding style cleanup



Fix coding style as suggested by checkpatch.pl

Signed-off-by: default avatarBALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: default avatarBlue Swirl <blauwirbel@gmail.com>
parent ef84755e
Loading
Loading
Loading
Loading
+150 −124
Original line number Diff line number Diff line
@@ -299,28 +299,27 @@ static inline void vmsvga_update_rect(struct vmsvga_state_s *s,

    if (x + w > s->width) {
        fprintf(stderr, "%s: update width too large x: %d, w: %d\n",
                        __FUNCTION__, x, w);
                __func__, x, w);
        x = MIN(x, s->width);
        w = s->width - x;
    }

    if (y + h > s->height) {
        fprintf(stderr, "%s: update height too large y: %d, h: %d\n",
                        __FUNCTION__, y, h);
                __func__, y, h);
        y = MIN(y, s->height);
        h = s->height - y;
    }

    line = h;
    bypl = s->bypp * s->width;
    width = s->bypp * w;
    start = s->bypp * x + bypl * y;
    src = s->vga.vram_ptr + start;
    dst = ds_get_data(s->vga.ds) + start;

    for (; line > 0; line --, src += bypl, dst += bypl)
    for (line = h; line > 0; line--, src += bypl, dst += bypl) {
        memcpy(dst, src, width);

    }
    dpy_gfx_update(s->vga.ds, x, y, w, h);
}

@@ -335,6 +334,7 @@ static inline void vmsvga_update_rect_delayed(struct vmsvga_state_s *s,
                int x, int y, int w, int h)
{
    struct vmsvga_rect_s *rect = &s->redraw_fifo[s->redraw_fifo_last++];

    s->redraw_fifo_last &= REDRAW_FIFO_LEN - 1;
    rect->x = x;
    rect->y = y;
@@ -345,6 +345,7 @@ static inline void vmsvga_update_rect_delayed(struct vmsvga_state_s *s,
static inline void vmsvga_update_rect_flush(struct vmsvga_state_s *s)
{
    struct vmsvga_rect_s *rect;

    if (s->invalidated) {
        s->redraw_fifo_first = s->redraw_fifo_last;
        return;
@@ -473,7 +474,7 @@ static inline void vmsvga_cursor_define(struct vmsvga_state_s *s,
        break;
    default:
        fprintf(stderr, "%s: unhandled bpp %d, using fallback cursor\n",
                __FUNCTION__, c->bpp);
                __func__, c->bpp);
        cursor_put(qc);
        qc = cursor_builtin_left_ptr();
    }
@@ -488,20 +489,25 @@ static inline void vmsvga_cursor_define(struct vmsvga_state_s *s,
static inline int vmsvga_fifo_length(struct vmsvga_state_s *s)
{
    int num;
    if (!s->config || !s->enable)

    if (!s->config || !s->enable) {
        return 0;
    }
    num = CMD(next_cmd) - CMD(stop);
    if (num < 0)
    if (num < 0) {
        num += CMD(max) - CMD(min);
    }
    return num >> 2;
}

static inline uint32_t vmsvga_fifo_read_raw(struct vmsvga_state_s *s)
{
    uint32_t cmd = s->fifo[CMD(stop) >> 2];

    s->cmd->stop = cpu_to_le32(CMD(stop) + 4);
    if (CMD(stop) >= CMD(max))
    if (CMD(stop) >= CMD(max)) {
        s->cmd->stop = s->cmd->min;
    }
    return cmd;
}

@@ -527,8 +533,9 @@ static void vmsvga_fifo_run(struct vmsvga_state_s *s)
        case SVGA_CMD_UPDATE:
        case SVGA_CMD_UPDATE_VERBOSE:
            len -= 5;
            if (len < 0)
            if (len < 0) {
                goto rewind;
            }

            x = vmsvga_fifo_read(s);
            y = vmsvga_fifo_read(s);
@@ -539,8 +546,9 @@ static void vmsvga_fifo_run(struct vmsvga_state_s *s)

        case SVGA_CMD_RECT_FILL:
            len -= 6;
            if (len < 0)
            if (len < 0) {
                goto rewind;
            }

            colour = vmsvga_fifo_read(s);
            x = vmsvga_fifo_read(s);
@@ -557,8 +565,9 @@ static void vmsvga_fifo_run(struct vmsvga_state_s *s)

        case SVGA_CMD_RECT_COPY:
            len -= 7;
            if (len < 0)
            if (len < 0) {
                goto rewind;
            }

            x = vmsvga_fifo_read(s);
            y = vmsvga_fifo_read(s);
@@ -576,8 +585,9 @@ static void vmsvga_fifo_run(struct vmsvga_state_s *s)

        case SVGA_CMD_DEFINE_CURSOR:
            len -= 8;
            if (len < 0)
            if (len < 0) {
                goto rewind;
            }

            cursor.id = vmsvga_fifo_read(s);
            cursor.hot_x = vmsvga_fifo_read(s);
@@ -589,17 +599,21 @@ static void vmsvga_fifo_run(struct vmsvga_state_s *s)

            args = SVGA_BITMAP_SIZE(x, y) + SVGA_PIXMAP_SIZE(x, y, cursor.bpp);
            if (SVGA_BITMAP_SIZE(x, y) > sizeof cursor.mask ||
                SVGA_PIXMAP_SIZE(x, y, cursor.bpp) > sizeof cursor.image)
                SVGA_PIXMAP_SIZE(x, y, cursor.bpp) > sizeof cursor.image) {
                    goto badcmd;
            }

            len -= args;
            if (len < 0)
            if (len < 0) {
                goto rewind;
            }

            for (args = 0; args < SVGA_BITMAP_SIZE(x, y); args ++)
            for (args = 0; args < SVGA_BITMAP_SIZE(x, y); args++) {
                cursor.mask[args] = vmsvga_fifo_read_raw(s);
            for (args = 0; args < SVGA_PIXMAP_SIZE(x, y, cursor.bpp); args ++)
            }
            for (args = 0; args < SVGA_PIXMAP_SIZE(x, y, cursor.bpp); args++) {
                cursor.image[args] = vmsvga_fifo_read_raw(s);
            }
#ifdef HW_MOUSE_ACCEL
            vmsvga_cursor_define(s, &cursor);
            break;
@@ -614,9 +628,9 @@ static void vmsvga_fifo_run(struct vmsvga_state_s *s)
         */
        case SVGA_CMD_DEFINE_ALPHA_CURSOR:
            len -= 6;
            if (len < 0)
            if (len < 0) {
                goto rewind;

            }
            vmsvga_fifo_read(s);
            vmsvga_fifo_read(s);
            vmsvga_fifo_read(s);
@@ -632,9 +646,9 @@ static void vmsvga_fifo_run(struct vmsvga_state_s *s)
            goto badcmd;
        case SVGA_CMD_DRAW_GLYPH_CLIPPED:
            len -= 4;
            if (len < 0)
            if (len < 0) {
                goto rewind;

            }
            vmsvga_fifo_read(s);
            vmsvga_fifo_read(s);
            args = 7 + (vmsvga_fifo_read(s) >> 2);
@@ -658,12 +672,14 @@ static void vmsvga_fifo_run(struct vmsvga_state_s *s)
            args = 0;
        badcmd:
            len -= args;
            if (len < 0)
            if (len < 0) {
                goto rewind;
            while (args --)
            }
            while (args--) {
                vmsvga_fifo_read(s);
            }
            printf("%s: Unknown command 0x%02x in SVGA command FIFO\n",
                            __FUNCTION__, cmd);
                   __func__, cmd);
            break;

        rewind:
@@ -678,12 +694,14 @@ static void vmsvga_fifo_run(struct vmsvga_state_s *s)
static uint32_t vmsvga_index_read(void *opaque, uint32_t address)
{
    struct vmsvga_state_s *s = opaque;

    return s->index;
}

static void vmsvga_index_write(void *opaque, uint32_t address, uint32_t index)
{
    struct vmsvga_state_s *s = opaque;

    s->index = index;
}

@@ -691,6 +709,7 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address)
{
    uint32_t caps;
    struct vmsvga_state_s *s = opaque;

    switch (s->index) {
    case SVGA_REG_ID:
        return s->svgaid;
@@ -805,9 +824,10 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address)

    default:
        if (s->index >= SVGA_SCRATCH_BASE &&
                s->index < SVGA_SCRATCH_BASE + s->scratch_size)
            s->index < SVGA_SCRATCH_BASE + s->scratch_size) {
            return s->scratch[s->index - SVGA_SCRATCH_BASE];
        printf("%s: Bad register %02x\n", __FUNCTION__, s->index);
        }
        printf("%s: Bad register %02x\n", __func__, s->index);
    }

    return 0;
@@ -816,10 +836,12 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address)
static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value)
{
    struct vmsvga_state_s *s = opaque;

    switch (s->index) {
    case SVGA_REG_ID:
        if (value == SVGA_ID_2 || value == SVGA_ID_1 || value == SVGA_ID_0)
        if (value == SVGA_ID_2 || value == SVGA_ID_1 || value == SVGA_ID_0) {
            s->svgaid = value;
        }
        break;

    case SVGA_REG_ENABLE:
@@ -850,7 +872,7 @@ static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value)
    case SVGA_REG_DEPTH:
    case SVGA_REG_BITS_PER_PIXEL:
        if (value != s->depth) {
            printf("%s: Bad colour depth: %i bits\n", __FUNCTION__, value);
            printf("%s: Bad colour depth: %i bits\n", __func__, value);
            s->config = 0;
        }
        break;
@@ -859,16 +881,19 @@ static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value)
        if (value) {
            s->fifo = (uint32_t *) s->fifo_ptr;
            /* Check range and alignment.  */
            if ((CMD(min) | CMD(max) |
                        CMD(next_cmd) | CMD(stop)) & 3)
            if ((CMD(min) | CMD(max) | CMD(next_cmd) | CMD(stop)) & 3) {
                break;
            if (CMD(min) < (uint8_t *) s->cmd->fifo - (uint8_t *) s->fifo)
            }
            if (CMD(min) < (uint8_t *) s->cmd->fifo - (uint8_t *) s->fifo) {
                break;
            if (CMD(max) > SVGA_FIFO_SIZE)
            }
            if (CMD(max) > SVGA_FIFO_SIZE) {
                break;
            if (CMD(max) < CMD(min) + 10 * 1024)
            }
            if (CMD(max) < CMD(min) + 10 * 1024) {
                break;
            }
        }
        s->config = !!value;
        break;

@@ -881,9 +906,10 @@ static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value)
        s->guest = value;
#ifdef VERBOSE
        if (value >= GUEST_OS_BASE && value < GUEST_OS_BASE +
                ARRAY_SIZE(vmsvga_guest_id))
            printf("%s: guest runs %s.\n", __FUNCTION__,
            ARRAY_SIZE(vmsvga_guest_id)) {
            printf("%s: guest runs %s.\n", __func__,
                   vmsvga_guest_id[value - GUEST_OS_BASE]);
        }
#endif
        break;

@@ -921,20 +947,19 @@ static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value)
            s->scratch[s->index - SVGA_SCRATCH_BASE] = value;
            break;
        }
        printf("%s: Bad register %02x\n", __FUNCTION__, s->index);
        printf("%s: Bad register %02x\n", __func__, s->index);
    }
}

static uint32_t vmsvga_bios_read(void *opaque, uint32_t address)
{
    printf("%s: what are we supposed to return?\n", __FUNCTION__);
    printf("%s: what are we supposed to return?\n", __func__);
    return 0xcafe;
}

static void vmsvga_bios_write(void *opaque, uint32_t address, uint32_t data)
{
    printf("%s: what are we supposed to do with (%08x)?\n",
                    __FUNCTION__, data);
    printf("%s: what are we supposed to do with (%08x)?\n", __func__, data);
}

static inline void vmsvga_size(struct vmsvga_state_s *s)
@@ -1024,18 +1049,19 @@ static void vmsvga_text_update(void *opaque, console_ch_t *chardata)
{
    struct vmsvga_state_s *s = opaque;

    if (s->vga.text_update)
    if (s->vga.text_update) {
        s->vga.text_update(&s->vga, chardata);
    }
}

static int vmsvga_post_load(void *opaque, int version_id)
{
    struct vmsvga_state_s *s = opaque;

    s->invalidated = 1;
    if (s->config)
    if (s->config) {
        s->fifo = (uint32_t *) s->fifo_ptr;

    }
    return 0;
}