1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

Add a font width argument to vi_load_font_t, vi_save_font_t and vi_putm_t

and do some preparations for handling 12x22 fonts (currently lots of code
implies and/or hardcodes a font width of 8 pixels). This will be required
on sparc64 which uses a default font size of 12x22 in order to add font
loading and saving support as well as to use a syscons(4)-supplied mouse
pointer image.
This API breakage is committed now so it can be MFC'ed in time for 6.0
and later on upcoming framebuffer drivers destined for use on sparc64
and which are expected to rely on using font loading internally and on
a syscons(4)-supplied mouse pointer image can be easily MFC'ed to
RELENG_6 rather than requiring a backport.

Tested on:	i386, sparc64, make universe
MFC after:	1 week
This commit is contained in:
Marius Strobl 2005-09-28 14:54:07 +00:00
parent ce8bf81ff2
commit b7c96c0d0b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=150686
15 changed files with 81 additions and 74 deletions

View File

@ -443,16 +443,16 @@ creator_set_mode(video_adapter_t *adp, int mode)
}
static int
creator_save_font(video_adapter_t *adp, int page, int size, u_char *data,
int c, int count)
creator_save_font(video_adapter_t *adp, int page, int size, int width,
u_char *data, int c, int count)
{
return (ENODEV);
}
static int
creator_load_font(video_adapter_t *adp, int page, int size, u_char *data,
int c, int count)
creator_load_font(video_adapter_t *adp, int page, int size, int width,
u_char *data, int c, int count)
{
return (ENODEV);
@ -738,7 +738,7 @@ creator_puts(video_adapter_t *adp, vm_offset_t off, u_int16_t *s, int len)
static int
creator_putm(video_adapter_t *adp, int x, int y, u_int8_t *pixel_image,
u_int32_t pixel_mask, int size)
u_int32_t pixel_mask, int size, int width)
{
struct creator_softc *sc;

View File

@ -107,9 +107,9 @@ typedef int vi_init_t(int unit, video_adapter_t *adp, int flags);
typedef int vi_get_info_t(video_adapter_t *adp, int mode, video_info_t *info);
typedef int vi_query_mode_t(video_adapter_t *adp, video_info_t *info);
typedef int vi_set_mode_t(video_adapter_t *adp, int mode);
typedef int vi_save_font_t(video_adapter_t *adp, int page, int size,
typedef int vi_save_font_t(video_adapter_t *adp, int page, int size, int width,
u_char *data, int c, int count);
typedef int vi_load_font_t(video_adapter_t *adp, int page, int size,
typedef int vi_load_font_t(video_adapter_t *adp, int page, int size, int width,
u_char *data, int c, int count);
typedef int vi_show_font_t(video_adapter_t *adp, int page);
typedef int vi_save_palette_t(video_adapter_t *adp, u_char *palette);
@ -148,8 +148,8 @@ typedef int vi_putc_t(video_adapter_t *adp, vm_offset_t off, u_int8_t c,
u_int8_t a);
typedef int vi_puts_t(video_adapter_t *adp, vm_offset_t off, u_int16_t *s,
int len);
typedef int vi_putm_t(video_adapter_t *adp, int x, int y,
u_int8_t *pixel_image, u_int32_t pixel_mask, int size);
typedef int vi_putm_t(video_adapter_t *adp, int x, int y, u_int8_t *pixel_image,
u_int32_t pixel_mask, int size, int width);
typedef struct video_switch {
vi_probe_t *probe;

View File

@ -161,7 +161,7 @@ gfb_init(int unit, video_adapter_t *adp, int flags)
/* Prepare the default font... */
(*vidsw[adp->va_index]->load_font)(adp, 0, bold8x16.height,
bold8x16.data, 0, 256);
bold8x16.width, bold8x16.data, 0, 256);
adp->va_info.vi_cwidth = gfbc->fonts[0].width;
adp->va_info.vi_cheight = gfbc->fonts[0].height;
@ -213,8 +213,8 @@ gfb_set_mode(video_adapter_t *adp, int mode)
}
int
gfb_save_font(video_adapter_t *adp, int page, int fontsize, u_char *data,
int ch, int count)
gfb_save_font(video_adapter_t *adp, int page, int fontsize, int fontwidth,
u_char *data, int ch, int count)
{
struct gfb_softc *sc;
int error;
@ -225,7 +225,7 @@ gfb_save_font(video_adapter_t *adp, int page, int fontsize, u_char *data,
/* Check the font information... */
if((sc->gfbc->fonts[page].height != fontsize) ||
(sc->gfbc->fonts[page].width != 8))
(sc->gfbc->fonts[page].width != fontwidth))
error = EINVAL;
else
@ -242,8 +242,8 @@ gfb_save_font(video_adapter_t *adp, int page, int fontsize, u_char *data,
}
int
gfb_load_font(video_adapter_t *adp, int page, int fontsize, u_char *data,
int ch, int count)
gfb_load_font(video_adapter_t *adp, int page, int fontsize, int fontwidth,
u_char *data, int ch, int count)
{
struct gfb_softc *sc;
int error;
@ -259,7 +259,7 @@ gfb_load_font(video_adapter_t *adp, int page, int fontsize, u_char *data,
/* Save the font information... */
sc->gfbc->fonts[page].height = fontsize;
sc->gfbc->fonts[page].width = 8;
sc->gfbc->fonts[page].width = fontwidth;
return(error);
}
@ -912,7 +912,7 @@ gfb_puts(video_adapter_t *adp, vm_offset_t off, u_int16_t *s, int len)
int
gfb_putm(video_adapter_t *adp, int x, int y, u_int8_t *pixel_image,
u_int32_t pixel_mask, int size)
u_int32_t pixel_mask, int size, int width)
{
vm_offset_t poff;
int i, pixel_size;

View File

@ -702,16 +702,16 @@ machfb_set_mode(video_adapter_t *adp, int mode)
}
static int
machfb_save_font(video_adapter_t *adp, int page, int size, u_char *data,
int c, int count)
machfb_save_font(video_adapter_t *adp, int page, int size, int width,
u_char *data, int c, int count)
{
return (ENODEV);
}
static int
machfb_load_font(video_adapter_t *adp, int page, int size, u_char *data,
int c, int count)
machfb_load_font(video_adapter_t *adp, int page, int size, int width,
u_char *data, int c, int count)
{
return (ENODEV);
@ -1124,7 +1124,7 @@ machfb_puts(video_adapter_t *adp, vm_offset_t off, uint16_t *s, int len)
static int
machfb_putm(video_adapter_t *adp, int x, int y, uint8_t *pixel_image,
uint32_t pixel_mask, int size)
uint32_t pixel_mask, int size, int width)
{
struct machfb_softc *sc;
int error;

View File

@ -305,17 +305,19 @@ s3lfb_set_mode(video_adapter_t *adp, int mode)
}
static int
s3lfb_save_font(video_adapter_t *adp, int page, int fontsize, u_char *data,
int ch, int count)
s3lfb_save_font(video_adapter_t *adp, int page, int fontsize, int fontwidth,
u_char *data, int ch, int count)
{
return (*prevvidsw->save_font)(adp, page, fontsize, data, ch, count);
return (*prevvidsw->save_font)(adp, page, fontsize, fontwidth, data,
ch, count);
}
static int
s3lfb_load_font(video_adapter_t *adp, int page, int fontsize, u_char *data,
int ch, int count)
s3lfb_load_font(video_adapter_t *adp, int page, int fontsize, int fontwidth,
u_char *data, int ch, int count)
{
return (*prevvidsw->load_font)(adp, page, fontsize, data, ch, count);
return (*prevvidsw->load_font)(adp, page, fontsize, fontwidth, data,
ch, count);
}
static int

View File

@ -1308,7 +1308,7 @@ tga_puts(video_adapter_t *adp, vm_offset_t off, u_int16_t *s, int len)
int
tga_putm(video_adapter_t *adp, int x, int y, u_int8_t *pixel_image,
gfb_reg_t pixel_mask, int size)
gfb_reg_t pixel_mask, int size, int width)
{
gfb_reg_t gpxr;
gfb_reg_t gmor;

View File

@ -1787,8 +1787,8 @@ set_normal_mode(video_adapter_t *adp, u_char *buf)
* EGA/VGA
*/
static int
vga_save_font(video_adapter_t *adp, int page, int fontsize, u_char *data,
int ch, int count)
vga_save_font(video_adapter_t *adp, int page, int fontsize, int fontwidth,
u_char *data, int ch, int count)
{
#ifndef VGA_NO_FONT_LOADING
u_char buf[PARAM_BUFSIZE];
@ -1814,7 +1814,7 @@ vga_save_font(video_adapter_t *adp, int page, int fontsize, u_char *data,
fontsize = 14;
}
if (page < 0 || page >= 8)
if (page < 0 || page >= 8 || fontwidth != 8)
return EINVAL;
segment = FONT_BUF + 0x4000*page;
if (page > 3)
@ -1867,8 +1867,8 @@ vga_save_font(video_adapter_t *adp, int page, int fontsize, u_char *data,
* EGA/VGA
*/
static int
vga_load_font(video_adapter_t *adp, int page, int fontsize, u_char *data,
int ch, int count)
vga_load_font(video_adapter_t *adp, int page, int fontsize, int fontwidth,
u_char *data, int ch, int count)
{
#ifndef VGA_NO_FONT_LOADING
u_char buf[PARAM_BUFSIZE];
@ -1894,7 +1894,7 @@ vga_load_font(video_adapter_t *adp, int page, int fontsize, u_char *data,
fontsize = 14;
}
if (page < 0 || page >= 8)
if (page < 0 || page >= 8 || fontwidth != 8)
return EINVAL;
segment = FONT_BUF + 0x4000*page;
if (page > 3)

View File

@ -323,7 +323,7 @@ gfb_mouse(scr_stat *scp, int x, int y, int on)
/* Display the mouse pointer image... */
(*vidsw[scp->sc->adapter]->putm)(scp->sc->adp, x, y,
mouse_pointer, 0xffffffff, 16);
mouse_pointer, 0xffffffff, 16, 8);
} else {
/*

View File

@ -883,6 +883,7 @@ sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag,
#ifndef SC_NO_FONT_LOADING
if (ISTEXTSC(cur_scp) && (cur_scp->font != NULL))
sc_load_font(cur_scp, 0, cur_scp->font_size,
cur_scp->font_width,
cur_scp->font + cur_scp->font_size
* cur_scp->sc->mouse_char,
cur_scp->sc->mouse_char, 4);

View File

@ -312,7 +312,7 @@ draw_txtcharcursor(scr_stat *scp, int at, u_short c, u_short a, int flip)
font[i] ^= 0xff;
}
/* XXX */
(*vidsw[sc->adapter]->load_font)(sc->adp, 0, h, font,
(*vidsw[sc->adapter]->load_font)(sc->adp, 0, h, 8, font,
sc->cursor_char, 1);
sc_vtb_putc(&scp->scr, at, sc->cursor_char, a);
} else
@ -438,7 +438,7 @@ draw_txtmouse(scr_stat *scp, int x, int y)
while (!(inb(crtc_addr + 6) & 0x08)) /* idle */ ;
#endif
c = scp->sc->mouse_char;
(*vidsw[scp->sc->adapter]->load_font)(scp->sc->adp, 0, 32, font_buf,
(*vidsw[scp->sc->adapter]->load_font)(scp->sc->adp, 0, 32, 8, font_buf,
c, 4);
sc_vtb_putc(&scp->scr, pos, c, sc_vtb_geta(&scp->scr, pos));

View File

@ -694,11 +694,11 @@ sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct thread *
* Don't load fonts for now... XXX
*/
if (scp->sc->fonts_loaded & FONT_8)
sc_load_font(scp, 0, 8, scp->sc->font_8, 0, 256);
sc_load_font(scp, 0, 8, 8, scp->sc->font_8, 0, 256);
if (scp->sc->fonts_loaded & FONT_14)
sc_load_font(scp, 0, 14, scp->sc->font_14, 0, 256);
sc_load_font(scp, 0, 14, 8, scp->sc->font_14, 0, 256);
if (scp->sc->fonts_loaded & FONT_16)
sc_load_font(scp, 0, 16, scp->sc->font_16, 0, 256);
sc_load_font(scp, 0, 16, 8, scp->sc->font_16, 0, 256);
}
#endif /* SC_NO_FONT_LOADING */
#endif

View File

@ -1285,7 +1285,7 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
* Don't load if the current font size is not 8x8.
*/
if (ISTEXTSC(sc->cur_scp) && (sc->cur_scp->font_size < 14))
sc_load_font(sc->cur_scp, 0, 8, sc->font_8, 0, 256);
sc_load_font(sc->cur_scp, 0, 8, 8, sc->font_8, 0, 256);
return 0;
case GIO_FONT8x8: /* get 8x8 dot font */
@ -1311,7 +1311,7 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
if (ISTEXTSC(sc->cur_scp)
&& (sc->cur_scp->font_size >= 14)
&& (sc->cur_scp->font_size < 16))
sc_load_font(sc->cur_scp, 0, 14, sc->font_14, 0, 256);
sc_load_font(sc->cur_scp, 0, 14, 8, sc->font_14, 0, 256);
return 0;
case GIO_FONT8x14: /* get 8x14 dot font */
@ -1335,7 +1335,7 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
* Don't load if the current font size is not 8x16.
*/
if (ISTEXTSC(sc->cur_scp) && (sc->cur_scp->font_size >= 16))
sc_load_font(sc->cur_scp, 0, 16, sc->font_16, 0, 256);
sc_load_font(sc->cur_scp, 0, 16, 8, sc->font_16, 0, 256);
return 0;
case GIO_FONT8x16: /* get 8x16 dot font */
@ -2752,21 +2752,21 @@ scinit(int unit, int flags)
bcopy(dflt_font_16, sc->font_16, sizeof(dflt_font_16));
sc->fonts_loaded = FONT_16 | FONT_14 | FONT_8;
if (scp->font_size < 14) {
sc_load_font(scp, 0, 8, sc->font_8, 0, 256);
sc_load_font(scp, 0, 8, 8, sc->font_8, 0, 256);
} else if (scp->font_size >= 16) {
sc_load_font(scp, 0, 16, sc->font_16, 0, 256);
sc_load_font(scp, 0, 16, 8, sc->font_16, 0, 256);
} else {
sc_load_font(scp, 0, 14, sc->font_14, 0, 256);
sc_load_font(scp, 0, 14, 8, sc->font_14, 0, 256);
}
#else /* !SC_DFLT_FONT */
if (scp->font_size < 14) {
sc_save_font(scp, 0, 8, sc->font_8, 0, 256);
sc_save_font(scp, 0, 8, 8, sc->font_8, 0, 256);
sc->fonts_loaded = FONT_8;
} else if (scp->font_size >= 16) {
sc_save_font(scp, 0, 16, sc->font_16, 0, 256);
sc_save_font(scp, 0, 16, 8, sc->font_16, 0, 256);
sc->fonts_loaded = FONT_16;
} else {
sc_save_font(scp, 0, 14, sc->font_14, 0, 256);
sc_save_font(scp, 0, 14, 8, sc->font_14, 0, 256);
sc->fonts_loaded = FONT_14;
}
#endif /* SC_DFLT_FONT */
@ -3444,13 +3444,13 @@ set_mode(scr_stat *scp)
if (!(scp->status & PIXEL_MODE) && ISFONTAVAIL(scp->sc->adp->va_flags)) {
if (scp->font_size < 14) {
if (scp->sc->fonts_loaded & FONT_8)
sc_load_font(scp, 0, 8, scp->sc->font_8, 0, 256);
sc_load_font(scp, 0, 8, 8, scp->sc->font_8, 0, 256);
} else if (scp->font_size >= 16) {
if (scp->sc->fonts_loaded & FONT_16)
sc_load_font(scp, 0, 16, scp->sc->font_16, 0, 256);
sc_load_font(scp, 0, 16, 8, scp->sc->font_16, 0, 256);
} else {
if (scp->sc->fonts_loaded & FONT_14)
sc_load_font(scp, 0, 14, scp->sc->font_14, 0, 256);
sc_load_font(scp, 0, 14, 8, scp->sc->font_14, 0, 256);
}
/*
* FONT KLUDGE:
@ -3481,26 +3481,28 @@ sc_set_border(scr_stat *scp, int color)
#ifndef SC_NO_FONT_LOADING
void
sc_load_font(scr_stat *scp, int page, int size, u_char *buf,
sc_load_font(scr_stat *scp, int page, int size, int width, u_char *buf,
int base, int count)
{
sc_softc_t *sc;
sc = scp->sc;
sc->font_loading_in_progress = TRUE;
(*vidsw[sc->adapter]->load_font)(sc->adp, page, size, buf, base, count);
(*vidsw[sc->adapter]->load_font)(sc->adp, page, size, width, buf, base,
count);
sc->font_loading_in_progress = FALSE;
}
void
sc_save_font(scr_stat *scp, int page, int size, u_char *buf,
sc_save_font(scr_stat *scp, int page, int size, int width, u_char *buf,
int base, int count)
{
sc_softc_t *sc;
sc = scp->sc;
sc->font_loading_in_progress = TRUE;
(*vidsw[sc->adapter]->save_font)(sc->adp, page, size, buf, base, count);
(*vidsw[sc->adapter]->save_font)(sc->adp, page, size, width, buf, base,
count);
sc->font_loading_in_progress = FALSE;
}

View File

@ -252,9 +252,11 @@ typedef struct sc_softc {
#define FONT_8 2
#define FONT_14 4
#define FONT_16 8
#define FONT_22 8
u_char *font_8;
u_char *font_14;
u_char *font_16;
u_char *font_22;
#endif
u_char cursor_char;
@ -542,10 +544,10 @@ int sc_attach_unit(int unit, int flags);
int set_mode(scr_stat *scp);
void sc_set_border(scr_stat *scp, int color);
void sc_load_font(scr_stat *scp, int page, int size, u_char *font,
int base, int count);
void sc_save_font(scr_stat *scp, int page, int size, u_char *font,
int base, int count);
void sc_load_font(scr_stat *scp, int page, int size, int width,
u_char *font, int base, int count);
void sc_save_font(scr_stat *scp, int page, int size, int width,
u_char *font, int base, int count);
void sc_show_font(scr_stat *scp, int page);
void sc_touch_scrn_saver(void);

View File

@ -1130,17 +1130,19 @@ vesa_set_mode(video_adapter_t *adp, int mode)
}
static int
vesa_save_font(video_adapter_t *adp, int page, int fontsize, u_char *data,
int ch, int count)
vesa_save_font(video_adapter_t *adp, int page, int fontsize, int fontwidth,
u_char *data, int ch, int count)
{
return (*prevvidsw->save_font)(adp, page, fontsize, data, ch, count);
return (*prevvidsw->save_font)(adp, page, fontsize, fontwidth, data,
ch, count);
}
static int
vesa_load_font(video_adapter_t *adp, int page, int fontsize, u_char *data,
int ch, int count)
vesa_load_font(video_adapter_t *adp, int page, int fontsize, int fontwidth,
u_char *data, int ch, int count)
{
return (*prevvidsw->load_font)(adp, page, fontsize, data, ch, count);
return (*prevvidsw->load_font)(adp, page, fontsize, fontwidth, data,
ch, count);
}
static int

View File

@ -22,8 +22,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#include <sys/cdefs.h>
@ -404,16 +402,16 @@ ofwfb_set_mode(video_adapter_t *adp, int mode)
}
static int
ofwfb_save_font(video_adapter_t *adp, int page, int size, u_char *data,
int c, int count)
ofwfb_save_font(video_adapter_t *adp, int page, int size, int width,
u_char *data, int c, int count)
{
TODO;
return (0);
}
static int
ofwfb_load_font(video_adapter_t *adp, int page, int size, u_char *data,
int c, int count)
ofwfb_load_font(video_adapter_t *adp, int page, int size, int width,
u_char *data, int c, int count)
{
struct ofwfb_softc *sc;
@ -812,7 +810,7 @@ ofwfb_puts(video_adapter_t *adp, vm_offset_t off, u_int16_t *s, int len)
static int
ofwfb_putm(video_adapter_t *adp, int x, int y, uint8_t *pixel_image,
uint32_t pixel_mask, int size)
uint32_t pixel_mask, int size, int width)
{
struct ofwfb_softc *sc;