sm501: Fixed code style and a few typos in comments

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
Message-id: 36288b703e7d56822c818567193ff28cdc47377e.1492787889.git.balaton@eik.bme.hu
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
BALATON Zoltan 2017-04-21 17:18:09 +02:00 committed by Peter Maydell
parent d526e5d874
commit 64f1603b07
2 changed files with 575 additions and 571 deletions

View File

@ -38,7 +38,7 @@
/* /*
* Status: 2010/05/07 * Status: 2010/05/07
* - Minimum implementation for Linux console : mmio regs and CRT layer. * - 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: * TODO:
* - Panel support * - Panel support
@ -49,8 +49,8 @@
* - Performance tuning * - Performance tuning
*/ */
//#define DEBUG_SM501 /*#define DEBUG_SM501*/
//#define DEBUG_BITBLT /*#define DEBUG_BITBLT*/
#ifdef DEBUG_SM501 #ifdef DEBUG_SM501
#define SM501_DPRINTF(fmt, ...) printf(fmt, ## __VA_ARGS__) #define SM501_DPRINTF(fmt, ...) printf(fmt, ## __VA_ARGS__)
@ -805,7 +805,7 @@ static void sm501_system_config_write(void *opaque, hwaddr addr,
break; break;
case SM501_DRAM_CONTROL: case SM501_DRAM_CONTROL:
s->local_mem_size_index = (value >> 13) & 0x7; 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; s->dram_control |= value & 0x7FFFFFC3;
break; break;
case SM501_IRQ_MASK: 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]; return *(uint32_t *)&s->dc_palette[addr];
} }
static void sm501_palette_write(void *opaque, static void sm501_palette_write(void *opaque, hwaddr addr,
hwaddr addr, uint32_t value) uint32_t value)
{ {
SM501State *s = (SM501State *)opaque; SM501State *s = (SM501State *)opaque;
SM501_DPRINTF("sm501 palette write addr=%x, val=%x\n", 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; uint8_t *src = s->local_mem;
int src_bpp = 0; int src_bpp = 0;
int dst_bpp = surface_bytes_per_pixel(surface); int dst_bpp = surface_bytes_per_pixel(surface);
uint32_t * palette = (uint32_t *)&s->dc_palette[SM501_DC_CRT_PALETTE uint32_t *palette = (uint32_t *)&s->dc_palette[SM501_DC_CRT_PALETTE -
- SM501_DC_PANEL_PALETTE]; SM501_DC_PANEL_PALETTE];
uint8_t hwc_palette[3 * 3]; uint8_t hwc_palette[3 * 3];
int ds_depth_index = get_depth_index(surface); int ds_depth_index = get_depth_index(surface);
draw_line_func *draw_line = NULL; draw_line_func *draw_line = NULL;
@ -1344,17 +1344,20 @@ static void sm501_draw_crt(SM501State * s)
/* draw graphics layer */ /* draw graphics layer */
draw_line(d, src, width, palette); draw_line(d, src, width, palette);
/* draw haredware cursor */ /* draw hardware cursor */
if (update_hwc) { if (update_hwc) {
draw_hwc_line(s, 1, hwc_palette, y - get_hwc_y(s, 1), d, width); 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; y_start = y;
if (page0 < page_min) }
if (page0 < page_min) {
page_min = page0; page_min = page0;
if (page1 > page_max) }
if (page1 > page_max) {
page_max = page1; page_max = page1;
}
} else { } else {
if (y_start >= 0) { if (y_start >= 0) {
/* flush to display */ /* flush to display */
@ -1368,8 +1371,9 @@ static void sm501_draw_crt(SM501State * s)
} }
/* complete flush to display */ /* complete flush to display */
if (y_start >= 0) if (y_start >= 0) {
dpy_gfx_update(s->con, 0, y_start, width, y - y_start); dpy_gfx_update(s->con, 0, y_start, width, y - y_start);
}
/* clear dirty flags */ /* clear dirty flags */
if (page_min != ~0l) { if (page_min != ~0l) {
@ -1383,9 +1387,10 @@ static void sm501_update_display(void *opaque)
{ {
SM501State *s = (SM501State *)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); sm501_draw_crt(s);
} }
}
static const GraphicHwOps sm501_ops = { static const GraphicHwOps sm501_ops = {
.gfx_update = sm501_update_display, .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); MemoryRegion *sm501_2d_engine = g_new(MemoryRegion, 1);
/* allocate management data region */ /* allocate management data region */
s = (SM501State *)g_malloc0(sizeof(SM501State)); s = g_new0(SM501State, 1);
s->base = base; s->base = base;
s->local_mem_size_index s->local_mem_size_index = get_local_mem_size_index(local_mem_bytes);
= get_local_mem_size_index(local_mem_bytes);
SM501_DPRINTF("local mem size=%x. index=%d\n", get_local_mem_size(s), SM501_DPRINTF("local mem size=%x. index=%d\n", get_local_mem_size(s),
s->local_mem_size_index); s->local_mem_size_index);
s->system_control = 0x00100000; 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); memory_region_add_subregion(address_space_mem, base, &s->local_mem_region);
/* map mmio */ /* map mmio */
memory_region_init_io(sm501_system_config, NULL, &sm501_system_config_ops, s, memory_region_init_io(sm501_system_config, NULL, &sm501_system_config_ops,
"sm501-system-config", 0x6c); s, "sm501-system-config", 0x6c);
memory_region_add_subregion(address_space_mem, base + MMIO_BASE_OFFSET, memory_region_add_subregion(address_space_mem, base + MMIO_BASE_OFFSET,
sm501_system_config); sm501_system_config);
memory_region_init_io(sm501_disp_ctrl, NULL, &sm501_disp_ctrl_ops, s, memory_region_init_io(sm501_disp_ctrl, NULL, &sm501_disp_ctrl_ops, s,

View File

@ -51,7 +51,7 @@ static void glue(draw_line8_, PIXEL_NAME)(
r = (pal[v] >> 16) & 0xff; r = (pal[v] >> 16) & 0xff;
g = (pal[v] >> 8) & 0xff; g = (pal[v] >> 8) & 0xff;
b = (pal[v] >> 0) & 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++; s++;
d += BPP; d += BPP;
} while (--width != 0); } while (--width != 0);
@ -68,7 +68,7 @@ static void glue(draw_line16_, PIXEL_NAME)(
r = ((rgb565 >> 11) & 0x1f) << 3; r = ((rgb565 >> 11) & 0x1f) << 3;
g = ((rgb565 >> 5) & 0x3f) << 2; g = ((rgb565 >> 5) & 0x3f) << 2;
b = ((rgb565 >> 0) & 0x1f) << 3; 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; s += 2;
d += BPP; d += BPP;
} while (--width != 0); } while (--width != 0);
@ -90,7 +90,7 @@ static void glue(draw_line32_, PIXEL_NAME)(
g = s[1]; g = s[1];
r = s[2]; r = s[2];
#endif #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; s += 4;
d += BPP; d += BPP;
} while (--width != 0); } 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 r = palette[v * 3 + 0];
uint8_t g = palette[v * 3 + 1]; uint8_t g = palette[v * 3 + 1];
uint8_t b = palette[v * 3 + 2]; 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; d += BPP;
} }