source: titan/titan/i386port.h @ 15338

Last change on this file since 15338 was 15306, checked in by nit, 12 years ago

[titan] catch SIGPIPE

File size: 4.5 KB
Line 
1#ifndef I386PORT_H
2#define I386PORT_H
3
4void setfbvarsize(struct fb* newnode)
5{
6        if(newnode != NULL)
7                newnode->varfbsize = newnode->width * newnode->height * newnode->colbytes;
8}
9
10void enablemanualblit()
11{
12}
13
14//flag 0 = no animation
15//flag 1 = animation
16void blitfb2(struct fb* fbnode, int flag)
17{
18        int i = 0;
19
20        if(fbnode == NULL) return;
21
22#ifdef NOFB
23        if(status.rguidfd > -1)
24        {
25                unsigned char* buf = NULL;
26                buf = scale(fbnode->fb, fbnode->width, fbnode->height, 4, 320, 240, 0);
27                if(buf != NULL)
28                {
29                        socksend(&status.rguidfd, (unsigned char*)buf, 320 * 240 * 4, 5000 * 1000);
30                        free(buf); buf = NULL;
31                }
32        }
33        if(status.write_png == 1 && status.infobaraktiv == 0)
34        {
35                unsigned char* buf = NULL;
36                buf = scale(fbnode->fb, fbnode->width, fbnode->height, 4, 320, 240, 0);
37                if(buf != NULL)
38                {
39                        if(writeFBfile.ActBuf == NULL)
40                        {
41                                writeFBfile.buf1 = malloc(4 * 320 * 240);
42                                writeFBfile.ActBuf = writeFBfile.buf1;
43                                memcpy(writeFBfile.buf1, (unsigned char*)buf, 4 * 320 * 240);
44                                addtimer(&fb2png_thread, START, 10000, 1, NULL, NULL, NULL);
45                        }
46                        else if(writeFBfile.buf1 == writeFBfile.ActBuf)
47                        {
48                                if(writeFBfile.buf2 == NULL)
49                                        writeFBfile.buf2 = malloc(4 * 320 * 240);
50                                memcpy(writeFBfile.buf2, (unsigned char*)buf, 4 * 320 * 240);
51                        }
52                        else if(writeFBfile.buf2 == writeFBfile.ActBuf)
53                        {
54                                if(writeFBfile.buf1 == NULL)
55                                        writeFBfile.buf1 = malloc(4 * 320 * 240);
56                                memcpy(writeFBfile.buf1, (unsigned char*)buf, 4 * 320 * 240);
57                        }
58                        //fb2png((unsigned char*)buf, 320, 240, "/tmp/titanlcd.png");
59                        free(buf); buf = NULL;
60                }
61        }
62
63        if(fbnode != fb)
64        {
65                for(i = 0; i < fbnode->height; i++)
66                {
67                        memcpy(fb->fb + (i * fb->pitch), fbnode->fb + (i * fbnode->pitch), fbnode->width * fbnode->colbytes);
68                }
69        }
70        system("killall -9 xloadimage");
71
72        FILE *fd;
73        fd=fopen("titan.png", "w");
74        fwrite(fb->fb, fb->varfbsize, 1, fd);
75        fclose(fd);
76
77        system("fbgrab -f titan.png -w 1280 -h 720 -b 32 titan1.png > /dev/null");
78        system("xloadimage titan1.png > /dev/null &");
79#endif
80}
81
82void setfbtransparent(int value)
83{
84}
85
86int allocbpamem(size_t size, int *memfd, unsigned char **mem)
87{
88        return -1;
89}
90
91void freebpamem(int memfd, unsigned char* mem, size_t len)
92{
93}
94
95//mode 0: with fill (draw to skinfb)
96//mode 1: without fill (draw to skinfb)
97//mode 2: with fill (draw to fb)
98//mode 3: without fill (draw to fb)
99void blitrect(int posx, int posy, int width, int height, long color, int transparent, int mode)
100{
101        //debug(1000, "in");
102        int y, x;
103        unsigned long tmpcol;
104       
105        if(posx < 0) posx = 0;
106        if(posx > skinfb->width) posx = skinfb->width;
107        if(posy < 0) posy = 0;
108        if(posy > skinfb->height) posy = skinfb->height;
109        if(posx + width > skinfb->width) width = skinfb->width - posx;
110        if(posy + height > skinfb->height) height = skinfb->height - posy;
111
112        if(width <= 0 || height <= 0) return;
113
114        transparent = (transparent - 255) * -1;
115        tmpcol = color | ((transparent & 0xff) << 24);
116
117        if(mode == 0 || mode == 2)
118        {
119                for(y = 0; y < height; y++)
120                {
121                        for(x = 0; x < width; x++)
122                        {
123                                drawpixel(posx + x, posy + y, tmpcol);
124                        }
125                }
126        }
127        else if(mode == 1 || mode == 3)
128        {
129                //topline
130                for(x = 0; x < width; x++)
131                        drawpixel(posx + x, posy, tmpcol);
132                //bottomline
133                for(x = 0; x < width; x++)
134                        drawpixel(posx + x, posy + height - 1, tmpcol);
135                //leftline
136                for(y = 0; y < height; y++)
137                        drawpixel(posx, posy + y, tmpcol);
138                //rightline
139                for(y = 0; y < height; y++)
140                        drawpixel(posx + width - 1, posy + y, tmpcol);
141        }
142        //debug(1000, "out");
143}
144
145int readjpg(const char* filename, unsigned long* width, unsigned long* height, unsigned long* rowbytes, int* channels, unsigned char **mem, int *memfd)
146{
147        return -1;
148}
149
150//flag 0: blit from accelfb to skinfb
151//flag 1: blit from skinfb to accelfb
152void blitscale(int posx, int posy, int width, int height, int scalewidth, int scaleheight, int flag)
153{
154}
155
156void blitjpg(unsigned char* buf, int posx, int posy, int width, int height, int scalewidth, int scaleheight)
157{
158}
159
160void sighandler(int sig, struct sigcontext ctx)
161{
162
163        debug(1000, "in");
164        switch(sig)
165        {
166                case SIGPIPE:
167                {
168                        err("got signal sigpipe but ignore it");
169                        break;
170                }
171                case SIGUSR1:
172                {
173                        //todo all configs
174                        reloadconfig(status.configfile);
175                        reloadconfig(getconfig("ownconfig", NULL));
176                        break;
177                }
178                case SIGSEGV:
179                case SIGBUS:
180                case SIGABRT:
181                {
182                        //intel
183                        debugstack((void *)ctx.eip, NULL);
184                        err("got signal %d, fault address 0x%lx from 0x%lx", sig, ctx.cr2, ctx.eip);
185
186                        if(getconfigint("saverun", NULL) == 1 && status.longjumpbuf != NULL)
187                                siglongjmp(status.longjumpbuf, 1);
188                        else
189                                exit(100);
190                        break;
191                }
192        }
193        debug(1000, "out");
194}
195
196#endif
Note: See TracBrowser for help on using the repository browser.