Mercurial > hg > Game > Cerium
annotate TaskManager/Test/test_render/fb.h @ 269:abf96b4caee5 draft
merge
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 04 Jun 2009 00:01:11 +0900 |
parents | de235e3ef9d3 |
children | 768452fab95e |
rev | line source |
---|---|
109 | 1 #if defined(__linux__) |
2 #include <unistd.h> | |
3 #include <stdio.h> | |
4 #include <fcntl.h> | |
5 #include <linux/fb.h> | |
6 #include <linux/fs.h> | |
7 #include <sys/mman.h> | |
8 #include <sys/ioctl.h> | |
9 #include <stdlib.h> | |
10 #include <iostream> | |
11 using namespace std; | |
12 | |
13 #define DEVICE_NAME "/dev/fb0" | |
14 #define DIV_BYTE 8 | |
15 | |
16 /* function prototype */ | |
180
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
17 void send_current_error_msg(const char *ptr); |
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
18 void send_current_information(const char *ptr); |
109 | 19 |
20 int get_fbdev_addr(void) | |
21 { | |
22 int fd_framebuffer ; | |
23 struct fb_var_screeninfo vinfo; | |
24 struct fb_fix_screeninfo finfo; | |
25 long int screensize ; | |
26 //long int location; | |
27 char *fbptr ; | |
28 char tmp[DIV_BYTE*10]; | |
29 | |
30 //int x , y ; | |
31 int xres,yres,vbpp,line_len; | |
32 //unsigned short tcolor ; | |
33 | |
34 /* ɤ߽Ѥ˥ե */ | |
35 fd_framebuffer = open( DEVICE_NAME , O_RDWR); | |
36 if ( !fd_framebuffer ) { | |
180
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
37 send_current_error_msg("Framebuffer device open error !"); |
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
38 exit(1); |
109 | 39 } |
40 send_current_information("The framebuffer device was opened !"); | |
180
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
41 |
109 | 42 /* ꥹ */ |
43 if ( ioctl( fd_framebuffer , FBIOGET_FSCREENINFO , &finfo ) ) { | |
180
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
44 send_current_error_msg("Fixed information not gotton !"); |
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
45 exit(2); |
109 | 46 } |
47 | |
48 /* ư */ | |
49 if ( ioctl( fd_framebuffer , FBIOGET_VSCREENINFO , &vinfo ) ) { | |
50 send_current_error_msg("Variable information not gotton !"); | |
51 exit(3); | |
52 } | |
53 xres = vinfo.xres ; | |
54 yres = vinfo.yres ; | |
55 vbpp = vinfo.bits_per_pixel ; | |
56 line_len = finfo.line_length ; | |
57 sprintf( tmp , "%d(pixel)x%d(line), %dbpp(bits per pixel)",xres,yres,vbpp); | |
58 send_current_information( tmp ); | |
59 | |
60 /* Хñ̤ǤΥΥ */ | |
61 screensize = xres * yres * vbpp / DIV_BYTE ; | |
62 | |
63 /* ǥХ˥ޥåפ */ | |
64 fbptr = (char *)mmap(0,screensize,PROT_READ | PROT_WRITE,MAP_SHARED,fd_framebuffer,0); | |
65 if ( (int)fbptr == -1 ) { | |
66 send_current_error_msg("Don't get framebuffer device to memory !"); | |
67 exit(4); | |
68 } | |
69 send_current_information("The framebuffer device was mapped !"); | |
70 | |
71 printf("fb: 0x%x \n", (unsigned int)fbptr); | |
72 return (int)fbptr; | |
73 //munmap(fbptr,screensize); | |
74 //close(fd_framebuffer); | |
75 //return 0; | |
76 } | |
77 | |
180
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
78 void send_current_error_msg(const char *ptr) |
109 | 79 { |
180
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
80 fprintf( stderr , "%s\n" , ptr ); |
109 | 81 } |
82 | |
180
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
83 void send_current_information(const char *ptr) |
109 | 84 { |
180
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
85 fprintf( stdout , "%s\n" , ptr ); |
109 | 86 } |
87 #else /* !defined(__linux__) */ | |
88 int get_fbdev_addr(void) {return 0;} | |
89 #endif /* defined(__linux__) */ | |
90 | |
91 extern int get_fbdev_addr(void); |