Start by moving the get_color() and set_color() functions into the library.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/include/libopenbios/video.h | 16 +++++++ openbios-devel/include/packages/video.h | 1 - openbios-devel/libopenbios/build.xml | 1 + openbios-devel/libopenbios/console_common.c | 1 + openbios-devel/libopenbios/video_common.c | 64 +++++++++++++++++++++++++++ openbios-devel/packages/video.c | 55 +---------------------- 6 files changed, 83 insertions(+), 55 deletions(-) create mode 100644 openbios-devel/include/libopenbios/video.h create mode 100644 openbios-devel/libopenbios/video_common.c
diff --git a/openbios-devel/include/libopenbios/video.h b/openbios-devel/include/libopenbios/video.h new file mode 100644 index 0000000..dbc1747 --- /dev/null +++ b/openbios-devel/include/libopenbios/video.h @@ -0,0 +1,16 @@ + +unsigned long get_color(int col_ind); +void set_color(int ind, unsigned long color); +void video_mask_blit(void); + +typedef struct osi_fb_info { + unsigned long mphys; + unsigned long mvirt; + int rb, w, h, depth; +} osi_fb_info_t; + +struct { + int has_video; + osi_fb_info_t fb; + unsigned long *pal; /* 256 elements */ +} video; diff --git a/openbios-devel/include/packages/video.h b/openbios-devel/include/packages/video.h index 1e013b6..39ae8df 100644 --- a/openbios-devel/include/packages/video.h +++ b/openbios-devel/include/packages/video.h @@ -4,7 +4,6 @@ /* packages/video.c */ int video_get_res(int *w, int *h); void draw_pixel(int x, int y, int colind); -void set_color(int ind, unsigned long color); void video_scroll(int height); void init_video(unsigned long fb, int width, int height, int depth, int rb);
diff --git a/openbios-devel/libopenbios/build.xml b/openbios-devel/libopenbios/build.xml index 8c1fe3f..cd15baf 100644 --- a/openbios-devel/libopenbios/build.xml +++ b/openbios-devel/libopenbios/build.xml @@ -20,6 +20,7 @@ <object source="linuxbios_info.c" condition="LINUXBIOS"/> <object source="ofmem_common.c" condition="OFMEM"/> <object source="xcoff_load.c" condition="LOADER_XCOFF"/> + <object source="video_common.c"/> </library>
<dictionary name="openbios" target="forth"> diff --git a/openbios-devel/libopenbios/console_common.c b/openbios-devel/libopenbios/console_common.c index 22ec230..1631769 100644 --- a/openbios-devel/libopenbios/console_common.c +++ b/openbios-devel/libopenbios/console_common.c @@ -16,6 +16,7 @@ #include "libopenbios/bindings.h" #include "libopenbios/fontdata.h" #include "libopenbios/console.h" +#include "libopenbios/video.h" #include "packages/video.h"
#define FONT_ADJ_HEIGHT (FONT_HEIGHT + 2) diff --git a/openbios-devel/libopenbios/video_common.c b/openbios-devel/libopenbios/video_common.c new file mode 100644 index 0000000..0c61e3a --- /dev/null +++ b/openbios-devel/libopenbios/video_common.c @@ -0,0 +1,64 @@ +/* + * Creation Date: <2002/10/23 20:26:40 samuel> + * Time-stamp: <2004/01/07 19:39:15 samuel> + * + * <video_common.c> + * + * Shared video routines + * + * Copyright (C) 2002, 2003, 2004 Samuel Rydh (samuel@ibrium.se) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation + * + */ + +#include "config.h" +#include "libopenbios/bindings.h" +#include "libopenbios/video.h" +#include "packages/video.h" +#include "drivers/vga.h" + + +unsigned long +get_color( int col_ind ) +{ + unsigned long col; + if( !video.has_video || col_ind < 0 || col_ind > 255 ) + return 0; + if( video.fb.depth == 8 ) + return col_ind; + col = video.pal[col_ind]; + if( video.fb.depth == 24 || video.fb.depth == 32 ) + return col; + if( video.fb.depth == 15 ) + return ((col>>9) & 0x7c00) | ((col>>6) & 0x03e0) | ((col>>3) & 0x1f); + return 0; +} + +void +set_color( int ind, unsigned long color ) +{ + if( !video.has_video || ind < 0 || ind > 255 ) + return; + video.pal[ind] = color; + +#ifdef CONFIG_MOL + if( video.fb.depth == 8 ) + OSI_SetColor( ind, color ); +#elif defined(CONFIG_SPARC32) +#if defined(CONFIG_DEBUG_CONSOLE_VIDEO) + if( video.fb.depth == 8 ) { + dac[0] = ind << 24; + dac[1] = ((color >> 16) & 0xff) << 24; // Red + dac[1] = ((color >> 8) & 0xff) << 24; // Green + dac[1] = (color & 0xff) << 24; // Blue + } +#endif +#else + vga_set_color(ind, ((color >> 16) & 0xff), + ((color >> 8) & 0xff), + (color & 0xff)); +#endif +} diff --git a/openbios-devel/packages/video.c b/openbios-devel/packages/video.c index 3dbd3c5..bcc9dfc 100644 --- a/openbios-devel/packages/video.c +++ b/openbios-devel/packages/video.c @@ -20,21 +20,10 @@ #include "libopenbios/ofmem.h" #include "drivers/drivers.h" #include "packages/video.h" +#include "libopenbios/video.h" #include "libopenbios/console.h" #include "drivers/vga.h"
-typedef struct osi_fb_info { - unsigned long mphys; - unsigned long mvirt; - int rb, w, h, depth; -} osi_fb_info_t; - -static struct { - int has_video; - osi_fb_info_t fb; - unsigned long *pal; /* 256 elements */ -} video; -
int video_get_res( int *w, int *h ) @@ -103,22 +92,6 @@ startup_splash( void ) #endif }
-static unsigned long -get_color( int col_ind ) -{ - unsigned long col; - if( !video.has_video || col_ind < 0 || col_ind > 255 ) - return 0; - if( video.fb.depth == 8 ) - return col_ind; - col = video.pal[col_ind]; - if( video.fb.depth == 24 || video.fb.depth == 32 ) - return col; - if( video.fb.depth == 15 ) - return ((col>>9) & 0x7c00) | ((col>>6) & 0x03e0) | ((col>>3) & 0x1f); - return 0; -} - void draw_pixel( int x, int y, int colind ) { @@ -177,32 +150,6 @@ refresh_palette( void ) }
void -set_color( int ind, unsigned long color ) -{ - if( !video.has_video || ind < 0 || ind > 255 ) - return; - video.pal[ind] = color; - -#ifdef CONFIG_MOL - if( video.fb.depth == 8 ) - OSI_SetColor( ind, color ); -#elif defined(CONFIG_SPARC32) -#if defined(CONFIG_DEBUG_CONSOLE_VIDEO) - if( video.fb.depth == 8 ) { - dac[0] = ind << 24; - dac[1] = ((color >> 16) & 0xff) << 24; // Red - dac[1] = ((color >> 8) & 0xff) << 24; // Green - dac[1] = (color & 0xff) << 24; // Blue - } -#endif -#else - vga_set_color(ind, ((color >> 16) & 0xff), - ((color >> 8) & 0xff), - (color & 0xff)); -#endif -} - -void video_scroll( int height ) { int i, offs, size, *dest, *src;