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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
1 #if defined(__linux__)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
2 #include <unistd.h>
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
3 #include <stdio.h>
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
4 #include <fcntl.h>
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
5 #include <linux/fb.h>
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
6 #include <linux/fs.h>
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
7 #include <sys/mman.h>
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
8 #include <sys/ioctl.h>
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
9 #include <stdlib.h>
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
10 #include <iostream>
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
11 using namespace std;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
12
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
13 #define DEVICE_NAME "/dev/fb0"
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
14 #define DIV_BYTE 8
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
15
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
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
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
19
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
20 int get_fbdev_addr(void)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
21 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
22 int fd_framebuffer ;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
23 struct fb_var_screeninfo vinfo;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
24 struct fb_fix_screeninfo finfo;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
25 long int screensize ;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
26 //long int location;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
27 char *fbptr ;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
28 char tmp[DIV_BYTE*10];
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
29
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
30 //int x , y ;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
31 int xres,yres,vbpp,line_len;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
32 //unsigned short tcolor ;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
33
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
34 /* ɤ߽Ѥ˥ե򳫤 */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
35 fd_framebuffer = open( DEVICE_NAME , O_RDWR);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
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
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
39 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
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
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
42 /* ꥹ꡼ */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
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
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
46 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
47
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
48 /* ư꡼ */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
49 if ( ioctl( fd_framebuffer , FBIOGET_VSCREENINFO , &vinfo ) ) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
50 send_current_error_msg("Variable information not gotton !");
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
51 exit(3);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
52 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
53 xres = vinfo.xres ;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
54 yres = vinfo.yres ;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
55 vbpp = vinfo.bits_per_pixel ;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
56 line_len = finfo.line_length ;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
57 sprintf( tmp , "%d(pixel)x%d(line), %dbpp(bits per pixel)",xres,yres,vbpp);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
58 send_current_information( tmp );
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
59
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
60 /* Хñ̤ǤΥ꡼Υ׻ */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
61 screensize = xres * yres * vbpp / DIV_BYTE ;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
62
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
63 /* ǥХ˥ޥåפ */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
64 fbptr = (char *)mmap(0,screensize,PROT_READ | PROT_WRITE,MAP_SHARED,fd_framebuffer,0);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
65 if ( (int)fbptr == -1 ) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
66 send_current_error_msg("Don't get framebuffer device to memory !");
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
67 exit(4);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
68 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
69 send_current_information("The framebuffer device was mapped !");
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
70
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
71 printf("fb: 0x%x \n", (unsigned int)fbptr);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
72 return (int)fbptr;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
73 //munmap(fbptr,screensize);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
74 //close(fd_framebuffer);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
75 //return 0;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
76 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
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
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
79 {
180
e3b7776b1420 いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents: 109
diff changeset
80 fprintf( stderr , "%s\n" , ptr );
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
81 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
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
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
84 {
180
e3b7776b1420 いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents: 109
diff changeset
85 fprintf( stdout , "%s\n" , ptr );
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
86 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
87 #else /* !defined(__linux__) */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
88 int get_fbdev_addr(void) {return 0;}
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
89 #endif /* defined(__linux__) */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
90
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
91 extern int get_fbdev_addr(void);