Commit 64f1603b authored by BALATON Zoltan's avatar BALATON Zoltan Committed by Peter Maydell
Browse files

sm501: Fixed code style and a few typos in comments



Signed-off-by: default avatarBALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: default avatarPeter Maydell <peter.maydell@linaro.org>
Tested-by: default avatarAurelien Jarno <aurelien@aurel32.net>
Message-id: 36288b703e7d56822c818567193ff28cdc47377e.1492787889.git.balaton@eik.bme.hu
Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parent d526e5d8
Loading
Loading
Loading
Loading
+568 −564
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@
/*
 * Status: 2010/05/07
 *   - Minimum implementation for Linux console : mmio regs and CRT layer.
 *   - 2D grapihcs acceleration partially supported : only fill rectangle.
 *   - 2D graphics acceleration partially supported : only fill rectangle.
 *
 * TODO:
 *   - Panel support
@@ -49,8 +49,8 @@
 *   - Performance tuning
 */

//#define DEBUG_SM501
//#define DEBUG_BITBLT
/*#define DEBUG_SM501*/
/*#define DEBUG_BITBLT*/

#ifdef DEBUG_SM501
#define SM501_DPRINTF(fmt, ...) printf(fmt, ## __VA_ARGS__)
@@ -805,7 +805,7 @@ static void sm501_system_config_write(void *opaque, hwaddr addr,
        break;
    case SM501_DRAM_CONTROL:
        s->local_mem_size_index = (value >> 13) & 0x7;
	/* rODO : check validity of size change */
        /* TODO : check validity of size change */
        s->dram_control |=  value & 0x7FFFFFC3;
        break;
    case SM501_IRQ_MASK:
@@ -853,8 +853,8 @@ static uint32_t sm501_palette_read(void *opaque, hwaddr addr)
    return *(uint32_t *)&s->dc_palette[addr];
}

static void sm501_palette_write(void *opaque,
				hwaddr addr, uint32_t value)
static void sm501_palette_write(void *opaque, hwaddr addr,
                                uint32_t value)
{
    SM501State *s = (SM501State *)opaque;
    SM501_DPRINTF("sm501 palette write addr=%x, val=%x\n",
@@ -1266,8 +1266,8 @@ static void sm501_draw_crt(SM501State * s)
    uint8_t  *src = s->local_mem;
    int src_bpp = 0;
    int dst_bpp = surface_bytes_per_pixel(surface);
    uint32_t * palette = (uint32_t *)&s->dc_palette[SM501_DC_CRT_PALETTE
						    - SM501_DC_PANEL_PALETTE];
    uint32_t *palette = (uint32_t *)&s->dc_palette[SM501_DC_CRT_PALETTE -
                                                   SM501_DC_PANEL_PALETTE];
    uint8_t hwc_palette[3 * 3];
    int ds_depth_index = get_depth_index(surface);
    draw_line_func *draw_line = NULL;
@@ -1344,17 +1344,20 @@ static void sm501_draw_crt(SM501State * s)
            /* draw graphics layer */
            draw_line(d, src, width, palette);

            /* draw haredware cursor */
            /* draw hardware cursor */
            if (update_hwc) {
                draw_hwc_line(s, 1, hwc_palette, y - get_hwc_y(s, 1), d, width);
            }

	    if (y_start < 0)
            if (y_start < 0) {
                y_start = y;
	    if (page0 < page_min)
            }
            if (page0 < page_min) {
                page_min = page0;
	    if (page1 > page_max)
            }
            if (page1 > page_max) {
                page_max = page1;
            }
        } else {
            if (y_start >= 0) {
                /* flush to display */
@@ -1368,8 +1371,9 @@ static void sm501_draw_crt(SM501State * s)
    }

    /* complete flush to display */
    if (y_start >= 0)
    if (y_start >= 0) {
        dpy_gfx_update(s->con, 0, y_start, width, y - y_start);
    }

    /* clear dirty flags */
    if (page_min != ~0l) {
@@ -1383,9 +1387,10 @@ static void sm501_update_display(void *opaque)
{
    SM501State *s = (SM501State *)opaque;

    if (s->dc_crt_control & SM501_DC_CRT_CONTROL_ENABLE)
    if (s->dc_crt_control & SM501_DC_CRT_CONTROL_ENABLE) {
        sm501_draw_crt(s);
    }
}

static const GraphicHwOps sm501_ops = {
    .gfx_update  = sm501_update_display,
@@ -1401,10 +1406,9 @@ void sm501_init(MemoryRegion *address_space_mem, uint32_t base,
    MemoryRegion *sm501_2d_engine = g_new(MemoryRegion, 1);

    /* allocate management data region */
    s = (SM501State *)g_malloc0(sizeof(SM501State));
    s = g_new0(SM501State, 1);
    s->base = base;
    s->local_mem_size_index
	= get_local_mem_size_index(local_mem_bytes);
    s->local_mem_size_index = get_local_mem_size_index(local_mem_bytes);
    SM501_DPRINTF("local mem size=%x. index=%d\n", get_local_mem_size(s),
                  s->local_mem_size_index);
    s->system_control = 0x00100000;
@@ -1421,8 +1425,8 @@ void sm501_init(MemoryRegion *address_space_mem, uint32_t base,
    memory_region_add_subregion(address_space_mem, base, &s->local_mem_region);

    /* map mmio */
    memory_region_init_io(sm501_system_config, NULL, &sm501_system_config_ops, s,
                          "sm501-system-config", 0x6c);
    memory_region_init_io(sm501_system_config, NULL, &sm501_system_config_ops,
                          s, "sm501-system-config", 0x6c);
    memory_region_add_subregion(address_space_mem, base + MMIO_BASE_OFFSET,
                                sm501_system_config);
    memory_region_init_io(sm501_disp_ctrl, NULL, &sm501_disp_ctrl_ops, s,
+26 −26
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ static void glue(draw_line8_, PIXEL_NAME)(
        r = (pal[v] >> 16) & 0xff;
        g = (pal[v] >>  8) & 0xff;
        b = (pal[v] >>  0) & 0xff;
	((PIXEL_TYPE *) d)[0] = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
        *(PIXEL_TYPE *)d = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
        s++;
        d += BPP;
    } while (--width != 0);
@@ -68,7 +68,7 @@ static void glue(draw_line16_, PIXEL_NAME)(
        r = ((rgb565 >> 11) & 0x1f) << 3;
        g = ((rgb565 >>  5) & 0x3f) << 2;
        b = ((rgb565 >>  0) & 0x1f) << 3;
	((PIXEL_TYPE *) d)[0] = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
        *(PIXEL_TYPE *)d = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
        s += 2;
        d += BPP;
    } while (--width != 0);
@@ -90,7 +90,7 @@ static void glue(draw_line32_, PIXEL_NAME)(
        g = s[1];
        r = s[2];
#endif
	((PIXEL_TYPE *) d)[0] = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
        *(PIXEL_TYPE *)d = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
        s += 4;
        d += BPP;
    } while (--width != 0);
@@ -132,7 +132,7 @@ static void glue(draw_hwc_line_, PIXEL_NAME)(SM501State * s, int crt,
            uint8_t r = palette[v * 3 + 0];
            uint8_t g = palette[v * 3 + 1];
            uint8_t b = palette[v * 3 + 2];
            ((PIXEL_TYPE *) d)[0] = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
            *(PIXEL_TYPE *)d = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
        }
        d += BPP;
    }