[lib][display] update display_get_info to return success/failure

Update all the users to check for error.
This commit is contained in:
Travis Geiselbrecht
2015-10-08 15:54:40 -07:00
parent 9f72a0470e
commit c7ce0b9361
9 changed files with 39 additions and 21 deletions

View File

@@ -550,18 +550,21 @@ void virtio_gpu_gfx_flush(uint starty, uint endy)
event_signal(&the_gdev->flush_event, !arch_ints_disabled());
}
void display_get_info(struct display_info *info)
status_t display_get_info(struct display_info *info)
{
memset(info, 0, sizeof(*info));
if (the_gdev) {
info->framebuffer = the_gdev->fb;
info->format = GFX_FORMAT_RGB_x888;
info->width = the_gdev->pmode.r.width;
info->height = the_gdev->pmode.r.height;
info->stride = info->width;
info->flush = virtio_gpu_gfx_flush;
}
if (!the_gdev)
return ERR_NOT_FOUND;
info->framebuffer = the_gdev->fb;
info->format = GFX_FORMAT_RGB_x888;
info->width = the_gdev->pmode.r.width;
info->height = the_gdev->pmode.r.height;
info->stride = info->width;
info->flush = virtio_gpu_gfx_flush;
return NO_ERROR;
}

View File

@@ -42,7 +42,7 @@ struct display_info {
void (*flush)(uint starty, uint endy);
};
void display_get_info(struct display_info *info);
status_t display_get_info(struct display_info *info);
#endif

View File

@@ -31,6 +31,7 @@
// different graphics formats
typedef enum {
GFX_FORMAT_NONE,
GFX_FORMAT_RGB_565,
GFX_FORMAT_ARGB_8888,
GFX_FORMAT_RGB_x888,

View File

@@ -490,7 +490,8 @@ void gfx_surface_destroy(struct gfx_surface *surface)
void gfx_draw_pattern(void)
{
struct display_info info;
display_get_info(&info);
if (display_get_info(&info) < 0)
return;
gfx_surface *surface = gfx_create_surface_from_display(&info);
@@ -518,7 +519,8 @@ void gfx_draw_pattern(void)
void gfx_draw_pattern_white(void)
{
struct display_info info;
display_get_info(&info);
if (display_get_info(&info) < 0)
return;
gfx_surface *surface = gfx_create_surface_from_display(&info);
@@ -586,7 +588,10 @@ static int cmd_gfx(int argc, const cmd_args *argv)
}
struct display_info info;
display_get_info(&info);
if (display_get_info(&info) < 0) {
printf("no display to draw on!\n");
return -1;
}
gfx_surface *surface = gfx_create_surface_from_display(&info);

View File

@@ -163,7 +163,9 @@ void gfxconsole_start_on_display(void)
/* pop up the console */
struct display_info info;
display_get_info(&info);
if (display_get_info(&info) < 0)
return;
gfx_surface *s = gfx_create_surface_from_display(&info);
gfxconsole_start(s);
started = true;

View File

@@ -77,7 +77,8 @@ void text_draw(int x, int y, const char *string)
void text_update(void)
{
struct display_info info;
display_get_info(&info);
if (display_get_info(&info) < 0)
return;
/* get the display's surface */
gfx_surface *surface = gfx_create_surface_from_display(&info);

View File

@@ -53,10 +53,10 @@ void platform_init_display(void)
#endif
}
void display_get_info(struct display_info *info)
status_t display_get_info(struct display_info *info)
{
if (!has_display())
return;
return ERR_NOT_FOUND;
info->framebuffer = display_fb;
info->format = GFX_FORMAT_RGB_x888;
@@ -64,5 +64,7 @@ void display_get_info(struct display_info *info)
info->height = display_h;
info->stride = display_w;
info->flush = NULL;
return NO_ERROR;
}

View File

@@ -389,7 +389,7 @@ uint8_t BSP_LCD_Init(void)
}
/* LK display api here */
void display_get_info(struct display_info *info)
status_t display_get_info(struct display_info *info)
{
info->framebuffer = (void *)hLtdcEval.LayerCfg[ActiveLayer].FBStartAdress;
@@ -399,12 +399,14 @@ void display_get_info(struct display_info *info)
info->format = GFX_FORMAT_RGB_565;
} else {
panic("unhandled pixel format\n");
info->format = GFX_FORMAT_MAX;
return ERR_NOT_FOUND;
}
info->width = BSP_LCD_GetXSize();
info->height = BSP_LCD_GetYSize();
info->stride = BSP_LCD_GetXSize();
info->flush = NULL;
return NO_ERROR;
}

View File

@@ -395,7 +395,7 @@ uint8_t BSP_LCD_Init(uint32_t fb_address)
}
/* LK display (lib/gfx.h) calls this function */
void display_get_info(struct display_info *info)
status_t display_get_info(struct display_info *info)
{
info->framebuffer = (void *)ltdc_handle.LayerCfg[active_layer].FBStartAdress;
@@ -405,12 +405,14 @@ void display_get_info(struct display_info *info)
info->format = GFX_FORMAT_RGB_565;
} else {
panic("unhandled pixel format\n");
info->format = GFX_FORMAT_MAX;
return ERR_NOT_FOUND;
}
info->width = BSP_LCD_GetXSize();
info->height = BSP_LCD_GetYSize();
info->stride = BSP_LCD_GetXSize();
info->flush = NULL;
return NO_ERROR;
}