|
From: James S. <jsi...@tr...> - 2002-05-02 22:09:11
|
Here you go. Something to test it with. I like so see if anyone else is
also having this problem.
/*
* 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.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
extern char *optarg;
extern int optind, opterr, optopt;
#include <errno.h>
int errno;
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <setjmp.h>
#include <sys/mman.h>
#include <asm/page.h>
#include <asm/byteorder.h>
#include <asm/bitops.h>
#include <linux/fb.h>
static unsigned char fontdata_8x16[4096] = {
/* 65 0x41 'A' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x10, /* 00010000 */
0x38, /* 00111000 */
0x6c, /* 01101100 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xfe, /* 11111110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
};
int
main(int argc, char **argv)
{
unsigned long mask, eorx;
int ppw, i, j, k, l;
unsigned long fgx, bgx, fgcolor = 0xFFFFFFFF, bgcolor = 0;
unsigned long *dst, *src = NULL;
struct fb_var_screeninfo fb_var;
struct fb_fix_screeninfo fb_fix;
int fb_mem_offset = 0, fbd, r;
char fbdevice[256];
int height, width;
unsigned long *dst1, *dst2, *src1;
int fbnum = 0;
int linesize;
long tmp;
fprintf(stderr, "Opening /dev/fb%d\n", fbnum);
sprintf(fbdevice, "/dev/fb%d", fbnum);
fbd = open(fbdevice, O_RDWR);
if (fbd < 0)
{
fprintf(stderr, "Couldn't open /dev/fb%d; errno: %d (%s)\n", fbnum, errno, strerror(errno));
exit(1);
}
r = ioctl(fbd, FBIOGET_VSCREENINFO, &fb_var);
if (r < 0)
{
fprintf(stderr, "IOCTL FBIOGET_VSCREENINFO error: %d errno: %d (%s)\n", r, errno, strerror(errno));
exit(1);
}
r = ioctl(fbd, FBIOGET_FSCREENINFO, &fb_fix);
if (r < 0)
{
fprintf(stderr, "IOCTL FBIOGET_FSCREENINFO error: %d errno: %d (%s)\n", r, errno, strerror(errno));
exit(1);
}
tmp = -1 >> (32 - fb_var.bits_per_pixel);
linesize = fb_fix.line_length;
fprintf(stderr, "Screen depth is %d\n", fb_var.bits_per_pixel);
/* map all FB memory */
fb_mem_offset = (unsigned long)(fb_fix.smem_start) & (~PAGE_MASK);
dst1 = mmap(NULL,fb_fix.smem_len+fb_mem_offset,PROT_WRITE,MAP_SHARED,fbd,0);
if (!dst1) {
fprintf(stderr, "MMap of /dev/fb%d failed\n", fbnum);
exit(1);
}
dst2 = mmap(fb_fix.mmio_start, fb_fix.mmio_len, PROT_WRITE,MAP_SHARED, fbd, 0);
if (!dst2) {
fprintf(stderr, "MMap of MMIO of /dev/fb%d failed\n", fbnum);
exit(1);
}
return(0);
}
|