add text output
This commit is contained in:
8
Makefile
8
Makefile
@@ -7,11 +7,11 @@ PROGS=db readback upd perf rect test offset pan ovl
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
.c.o: common.h
|
||||
.c.o: common.h font.h
|
||||
|
||||
test: test.o common.o
|
||||
upd: upd.o common.o
|
||||
ovl: ovl.o common.o
|
||||
test: test.o common.o font_8x8.c
|
||||
upd: upd.o common.o font_8x8.c
|
||||
ovl: ovl.o common.o font_8x8.c
|
||||
|
||||
clean:
|
||||
rm -f $(PROGS) *.o
|
||||
|
||||
71
common.c
71
common.c
@@ -15,6 +15,7 @@
|
||||
#include <linux/omapfb.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "font.h"
|
||||
|
||||
void fb_open(int fb_num, struct fb_info *fb_info)
|
||||
{
|
||||
@@ -67,3 +68,73 @@ void fb_sync_gfx(int fd)
|
||||
IOCTL0(fd, OMAPFB_SYNC_GFX);
|
||||
}
|
||||
|
||||
static void fb_clear_area(struct fb_info *fb_info, int x, int y, int w, int h)
|
||||
{
|
||||
int i = 0;
|
||||
int loc;
|
||||
char *fbuffer = (char *)fb_info->ptr;
|
||||
struct fb_var_screeninfo *var = &fb_info->var;
|
||||
struct fb_fix_screeninfo *fix = &fb_info->fix;
|
||||
|
||||
for(i = 0; i < h; i++)
|
||||
{
|
||||
loc = (x + var->xoffset) * (var->bits_per_pixel / 8)
|
||||
+ (y + i + var->yoffset) * fix->line_length;
|
||||
memset(fbuffer + loc, 0, w * var->bits_per_pixel / 8);
|
||||
}
|
||||
}
|
||||
|
||||
static void fb_put_char(struct fb_info *fb_info, int x, int y, char c,
|
||||
unsigned color)
|
||||
{
|
||||
int i, j, bits, loc;
|
||||
char *fbuffer = (char *)fb_info->ptr;
|
||||
struct fb_var_screeninfo *var = &fb_info->var;
|
||||
struct fb_fix_screeninfo *fix = &fb_info->fix;
|
||||
|
||||
for(i = 0; i < font_vga_8x8.height; i++) {
|
||||
bits = font_vga_8x8.data[font_vga_8x8.height * c + i];
|
||||
for(j = 0; j < 8; j++) {
|
||||
loc = (x + j + var->xoffset) * (var->bits_per_pixel / 8)
|
||||
+ (y + i + var->yoffset) * fix->line_length;
|
||||
if(loc >= 0 && loc < fix->smem_len && ((bits >> (7 - j)) & 1)) {
|
||||
switch(var->bits_per_pixel) {
|
||||
case 8:
|
||||
default:
|
||||
if(color==0)
|
||||
fbuffer[loc] = 0;
|
||||
else
|
||||
fbuffer[loc] = 1;
|
||||
break;
|
||||
case 16:
|
||||
*((unsigned short *)(fbuffer + loc)) = color;
|
||||
break;
|
||||
case 24:
|
||||
case 32:
|
||||
*((unsigned int *)(fbuffer + loc)) = color;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int fb_put_string(struct fb_info *fb_info, int x, int y, char *s, int maxlen,
|
||||
int color, int clear, int clearlen)
|
||||
{
|
||||
int i;
|
||||
int w = 0;
|
||||
|
||||
if(clear)
|
||||
fb_clear_area(fb_info, x, y, clearlen * font_vga_8x8.width,
|
||||
font_vga_8x8.height);
|
||||
|
||||
for(i=0;i<strlen(s) && i < maxlen;i++) {
|
||||
fb_put_char(fb_info, (x + font_vga_8x8.width * i), y, s[i],
|
||||
color);
|
||||
w += font_vga_8x8.width;
|
||||
}
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
|
||||
2
common.h
2
common.h
@@ -37,5 +37,7 @@ struct fb_info
|
||||
void fb_open(int fb_num, struct fb_info *fb_info);
|
||||
void fb_update_window(int fd, short x, short y, short w, short h);
|
||||
void fb_sync_gfx(int fd);
|
||||
int fb_put_string(struct fb_info *fb_info, int x, int y, char *s, int maxlen,
|
||||
int color, int clear, int clearlen);
|
||||
|
||||
#endif
|
||||
|
||||
37
font.h
Normal file
37
font.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* font.h -- `Soft' font definitions
|
||||
*
|
||||
* Created 1995 by Geert Uytterhoeven
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU General Public
|
||||
* License. See the file COPYING in the main directory of this archive
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#ifndef _VIDEO_FONT_H
|
||||
#define _VIDEO_FONT_H
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
struct fbcon_font_desc {
|
||||
int idx;
|
||||
char *name;
|
||||
int width, height;
|
||||
char *data;
|
||||
int pref;
|
||||
};
|
||||
|
||||
#define VGA8x8_IDX 0
|
||||
#define VGA8x16_IDX 1
|
||||
#define PEARL8x8_IDX 2
|
||||
#define VGA6x11_IDX 3
|
||||
#define SUN8x16_IDX 4
|
||||
#define SUN12x22_IDX 5
|
||||
#define ACORN8x8_IDX 6
|
||||
|
||||
extern struct fbcon_font_desc font_vga_8x8;
|
||||
|
||||
/* Max. length for the name of a predefined font */
|
||||
#define MAX_FONT_NAME 32
|
||||
|
||||
#endif /* _VIDEO_FONT_H */
|
||||
2583
font_8x8.c
Normal file
2583
font_8x8.c
Normal file
File diff suppressed because it is too large
Load Diff
4
test.c
4
test.c
@@ -109,6 +109,10 @@ static void fill_screen(struct fb_info *fb_info)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fb_put_string(fb_info, w / 3 * 2, 30, "RED", 3, 0xffffff, 1, 3);
|
||||
fb_put_string(fb_info, w / 3, 30, "GREEN", 5, 0xffffff, 1, 5);
|
||||
fb_put_string(fb_info, 20, 30, "BLUE", 4, 0xffffff, 1, 4);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
||||
Reference in New Issue
Block a user