Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1085 | pj | 1 | /* |
2 | * Project: S.Ha.R.K. |
||
3 | * |
||
4 | * Coordinators: |
||
5 | * Giorgio Buttazzo <giorgio@sssup.it> |
||
6 | * Paolo Gai <pj@gandalf.sssup.it> |
||
7 | * |
||
8 | * Authors : |
||
9 | * Paolo Gai <pj@gandalf.sssup.it> |
||
10 | * (see the web pages for full authors list) |
||
11 | * |
||
12 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
13 | * |
||
14 | * http://www.sssup.it |
||
15 | * http://retis.sssup.it |
||
16 | * http://shark.sssup.it |
||
17 | */ |
||
18 | |||
19 | /* |
||
20 | * Copyright (C) 1999 Luca Abeni and Massimiliano Giorgi |
||
21 | * |
||
22 | * This program is free software; you can redistribute it and/or modify |
||
23 | * it under the terms of the GNU General Public License as published by |
||
24 | * the Free Software Foundation; either version 2 of the License, or |
||
25 | * (at your option) any later version. |
||
26 | * |
||
27 | * This program is distributed in the hope that it will be useful, |
||
28 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
29 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
30 | * GNU General Public License for more details. |
||
31 | * |
||
32 | * You should have received a copy of the GNU General Public License |
||
33 | * along with this program; if not, write to the Free Software |
||
34 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
35 | * |
||
36 | */ |
||
37 | |||
38 | /* |
||
39 | * CVS : $Id: mplay.c,v 1.1.1.1 2002-09-02 09:37:41 pj Exp $ |
||
40 | * |
||
41 | * File: $File$ |
||
42 | * Revision: $Revision: 1.1.1.1 $ |
||
43 | * Last update: $Date: 2002-09-02 09:37:41 $ |
||
44 | */ |
||
45 | |||
46 | #include "config.h" |
||
47 | |||
48 | //#include <ll/sys/types.h> |
||
49 | |||
50 | #include <kernel/func.h> |
||
51 | #include <kernel/const.h> |
||
52 | |||
53 | #include <trace/trace.h> |
||
54 | #include <trace/queues.h> |
||
55 | |||
56 | #include <drivers/glib.h> |
||
57 | #include <drivers/gd.h> |
||
58 | #include <drivers/keyb.h> |
||
59 | |||
60 | #include <fs/bdevinit.h> |
||
61 | #include <fs/fsinit.h> |
||
62 | #include <fs/bdev.h> |
||
63 | |||
64 | #include <sys/types.h> |
||
65 | #include <sys/mount.h> |
||
66 | |||
67 | #include <stdlib.h> |
||
68 | #include <stdio.h> |
||
69 | |||
70 | #include "gclock.h" |
||
71 | #include "gvideo.h" |
||
72 | #include "gload.h" |
||
73 | #include "gbuffer.h" |
||
74 | #include "gphoto.h" |
||
75 | #include "mutex.h" |
||
76 | #include "xread.h" |
||
77 | |||
78 | void ctrlc_exit(KEY_EVT *k) |
||
79 | { |
||
80 | extern void dump_sem_table(void); |
||
81 | extern void dump_nop_table(void); |
||
82 | #ifndef NOGRX |
||
83 | grx_close(); |
||
84 | #endif |
||
85 | cprintf("CTRL-C pressed!\n"); |
||
86 | sys_end(); |
||
87 | } |
||
88 | |||
89 | /* |
||
90 | * |
||
91 | * |
||
92 | * |
||
93 | */ |
||
94 | |||
95 | int __register_sub_init_prologue(void) |
||
96 | { |
||
97 | // int id; |
||
98 | #ifndef NOTRACE |
||
99 | TRC_init_phase1(NULL); |
||
100 | trc_register_fixed_queue(); |
||
101 | id=trc_create_queue(TRC_FIXED_QUEUE,NULL); |
||
102 | trc_trace_class(TRC_CLASS_USER); |
||
103 | trc_assign_class_to_queue(TRC_CLASS_USER,id); |
||
104 | #endif |
||
105 | return 0; |
||
106 | } |
||
107 | |||
108 | int __register_sub_init(void) |
||
109 | { |
||
110 | #if defined(EDFSCHED) |
||
111 | extern void BD_EDF_register_module(void); |
||
112 | BD_EDF_register_module(); |
||
113 | #elif defined(PSCANSCHED) |
||
114 | extern void BD_PSCAN_register_module(void); |
||
115 | BD_PSCAN_register_module(); |
||
116 | #endif |
||
117 | return 0; |
||
118 | } |
||
119 | |||
120 | dev_t root_device=-1; |
||
121 | dev_t temp_device=-1; |
||
122 | |||
123 | int choose_root_callback(dev_t dev,u_int8_t fs) |
||
124 | { |
||
125 | if (fs==FS_MSDOS) return dev; |
||
126 | return -1; |
||
127 | } |
||
128 | |||
129 | int choose_temp_callback(__dev_t dev,__uint8_t fs) |
||
130 | { |
||
131 | static int flag=0; |
||
132 | if (fs==FS_MSDOS) { |
||
133 | if (flag) return dev; |
||
134 | flag=1; |
||
135 | } |
||
136 | return -1; |
||
137 | } |
||
138 | |||
139 | int __bdev_sub_init(void) |
||
140 | { |
||
141 | BDEV_PARMS bdev=BASE_BDEV; |
||
142 | |||
143 | bdev_def_showinfo(bdev,FALSE); |
||
144 | bdev_init(&bdev); |
||
145 | |||
146 | root_device=bdev_scan_devices(choose_root_callback); |
||
147 | if (root_device<0) { |
||
148 | cprintf("can't find root device to mount on /!!!\n"); |
||
149 | sys_end(); |
||
150 | return -1; |
||
151 | } |
||
152 | |||
153 | /* |
||
154 | temp_device=bdev_scan_devices(choose_temp_callback); |
||
155 | if (temp_device<0) { |
||
156 | cprintf("can't find a filesystem to mount on /TEMP!!!\n"); |
||
157 | } |
||
158 | */ |
||
159 | |||
160 | return 0; |
||
161 | } |
||
162 | |||
163 | int __fs_sub_init(void) |
||
164 | { |
||
165 | extern int libc_initialize(void); |
||
166 | FILESYSTEM_PARMS fs=BASE_FILESYSTEM; |
||
167 | // struct mount_opts opts; |
||
168 | // int res; |
||
169 | |||
170 | filesystem_def_rootdevice(fs,root_device); |
||
171 | filesystem_def_fs(fs,FS_MSDOS); |
||
172 | filesystem_def_showinfo(fs,FALSE); |
||
173 | filesystem_init(&fs); |
||
174 | |||
175 | /* |
||
176 | if (temp_device>=0) { |
||
177 | memset(&opts,0,sizeof(struct mount_opts)); |
||
178 | opts.flags=MOUNT_FLAG_RW; |
||
179 | res=mount(temp_device,FS_MSDOS,"/TEMP",&opts); |
||
180 | if (res!=0) { |
||
181 | cprintf("can't mount XXX on /TEMP (errno: %i)\n",errno); |
||
182 | } else |
||
183 | cprintf("mounted /TEMP rw\n"); |
||
184 | } |
||
185 | */ |
||
186 | |||
187 | libc_initialize(); |
||
188 | |||
189 | #ifndef NOTRACE |
||
190 | TRC_init_phase2(); |
||
191 | #endif |
||
192 | |||
193 | return 0; |
||
194 | } |
||
195 | |||
196 | /* |
||
197 | * |
||
198 | * |
||
199 | * |
||
200 | */ |
||
201 | |||
202 | struct { |
||
203 | char *filename; |
||
204 | int bitrate; |
||
205 | int framerate; |
||
206 | } mpegs[16]={ |
||
207 | /* 0 */ |
||
208 | {"/temp/m/2jaeger.mpg", 573225, 3000}, /* 3.27 bad*/ |
||
209 | {"/temp/m/alien.mpg", 289000, 2500}, /* 10.12 I */ |
||
210 | {"/temp/m/b0.mpg", 1725251, 3000}, /* 3.33 IBBPBBPBBPBB */ |
||
211 | {"/temp/m/canyon.mpg", 237194, 3000}, /* 58.60 IBBPBB */ |
||
212 | /* 4 */ |
||
213 | {"/temp/m/earth-ci.mpg", 974900, 2500}, /* 28.80 IBBPBB */ |
||
214 | {"/temp/m/flower.mpg", 1147101, 2997}, /* 5.01 bad */ |
||
215 | {"/temp/m/frisco.mpg", 397262, 3000}, /* 1.70 bad */ |
||
216 | {"/temp/m/hulahoop.mpg", 684126, 3000}, /* 1.33 bad */ |
||
217 | /* 8 */ |
||
218 | {"/temp/m/iicm.mpg", 527308, 3000}, /* 26.70 bad */ |
||
219 | {"/temp/m/micky.mpg", 711240, 3000}, /* 0.66 bad */ |
||
220 | {"/temp/m/mobile.mpg", 114622, 2997}, /* 5.01 bad */ |
||
221 | {"/temp/m/redsnigh.mpg", 597776, 2500}, /* 48.40 IBBBBBBBBBPBBBBBBBBB*/ |
||
222 | /* 12 */ |
||
223 | {"/temp/m/son.mpg", 1134335, 2500}, /* 6.92 IBBPBBPBBPBB */ |
||
224 | {"/temp/m/stoelend.mpg", 2248942, 3000}, /* 0.53 IBBPBB */ |
||
225 | {"/temp/m/sukhoi.mpg", 481521, 3000}, /* 25.47 I */ |
||
226 | {"/temp/m/us.mpg", 681599, 3000} /* 24.37 IBBPBB */ |
||
227 | }; |
||
228 | |||
229 | #define DEFINDEX 3 |
||
230 | |||
231 | char *getfilename(int index) |
||
232 | { |
||
233 | return mpegs[index%16].filename; |
||
234 | } |
||
235 | |||
236 | int getbitrate(int index) |
||
237 | { |
||
238 | return mpegs[index%16].bitrate; |
||
239 | } |
||
240 | |||
241 | int getframerate(int index) |
||
242 | { |
||
243 | return mpegs[index%16].framerate; |
||
244 | } |
||
245 | |||
246 | /* |
||
247 | * |
||
248 | * |
||
249 | * |
||
250 | */ |
||
251 | |||
252 | #ifdef FULLCOLOR |
||
253 | |||
254 | #define TEXTCOLOR rgb16(0,255,0) |
||
255 | #define TEXTCOLOR2 rgb16(255,255,255) |
||
256 | #define TEXTBG rgb16(0,0,0) |
||
257 | |||
258 | #else |
||
259 | |||
260 | #define TEXTCOLOR 255 |
||
261 | #define TEXTCOLOR2 255 |
||
262 | #define TEXTBG 0 |
||
263 | |||
264 | #endif |
||
265 | |||
266 | #define SCREENX 800 |
||
267 | #define SCREENY 600 |
||
268 | |||
269 | #define MAINSLEEP 20000 |
||
270 | |||
271 | g_sem_t grxsem; |
||
272 | |||
273 | int main(int argc, char *argv[]) |
||
274 | { |
||
275 | struct gvideoinfo info; |
||
276 | KEY_EVT k; |
||
277 | int index; |
||
278 | int mode; |
||
279 | int esc; |
||
280 | int pid,grp; |
||
281 | // int i; |
||
282 | int sx=20; |
||
283 | PID ph1,ph2,ph3; |
||
284 | |||
285 | g_sem_init(&grxsem,1); |
||
286 | |||
287 | /* |
||
288 | if (argc<2) { |
||
289 | cprintf("Usage: %s mpegfileordinal\n",argv[0]); |
||
290 | sys_abort(301); |
||
291 | } |
||
292 | */ |
||
293 | |||
294 | /* init the "file reader tasks" module */ |
||
295 | x_init(); |
||
296 | |||
297 | /* Init the graph... */ |
||
298 | #ifndef NOGRX |
||
299 | if (grx_init()==-1) { |
||
300 | cprintf("No init!!!\n"); |
||
301 | sys_abort(255); |
||
302 | } |
||
303 | #ifdef FULLCOLOR |
||
304 | mode=grx_getmode(SCREENX,SCREENY,16); |
||
305 | #else |
||
306 | mode=grx_getmode(SCREENX,SCREENY,8); |
||
307 | #endif |
||
308 | if (mode==-1) { |
||
309 | cprintf("Mode not present!!!\n"); |
||
310 | sys_abort(255); |
||
311 | } |
||
312 | #endif |
||
313 | |||
314 | cprintf("[hit enter to continue]\n"); |
||
315 | esc=FALSE; |
||
316 | while (!esc) { |
||
317 | keyb_getcode(&k,BLOCK); |
||
318 | if (k.ascii==13) esc=TRUE; |
||
319 | } |
||
320 | |||
321 | #ifndef NOGRX |
||
322 | if (grx_setmode(mode) == -1) { |
||
323 | cprintf("No SetMode!!!\n"); |
||
324 | sys_abort(255); |
||
325 | } |
||
326 | #endif |
||
327 | |||
328 | #ifndef NOGRX |
||
329 | grx_text("HARTIK 4.0 (Lego)",12*2,22,TEXTCOLOR,TEXTBG); |
||
330 | grx_text("[Filesystem demo]",12*2,22+10,TEXTCOLOR,TEXTBG); |
||
331 | |||
332 | grx_text("Video : 8bit/pixel",250,450,TEXTCOLOR2,TEXTBG); |
||
333 | grx_text("Double buffer: YES",250,450+10,TEXTCOLOR2,TEXTBG); |
||
334 | grx_text("Algorithm : FCFS",250,450+20,TEXTCOLOR2,TEXTBG); |
||
335 | #endif |
||
336 | |||
337 | pid=gclock_init(32+64+64,540); |
||
338 | task_activate(pid); |
||
339 | |||
340 | //for (i=0;i<argc-1;i++) { |
||
341 | |||
342 | //index=atoi(argv[i+1]); |
||
343 | index=4; |
||
344 | |||
345 | info.x=sx+30; |
||
346 | info.y=80; |
||
347 | info.pathname=getfilename(index); |
||
348 | info.bitrate=getbitrate(index); |
||
349 | info.framerate=getframerate(index); |
||
350 | info.band=25; |
||
351 | |||
352 | grp=gvideo_init("Video: earth.mpg", &info); |
||
353 | //if (grp>0) group_activate(grp); |
||
354 | |||
355 | sx+=info.w+15; |
||
356 | //} |
||
357 | |||
358 | pid=gload_init(1); |
||
359 | task_activate(pid); |
||
360 | |||
361 | ph1=gphoto_show("Photo: galaxy","/temp/b/ph2a.bmp",500,25); |
||
362 | ph2=gphoto_show("Photo: canyon","/temp/b/ph3a.bmp",500,225); |
||
363 | ph3=gphoto_show("Photo: nicole","/temp/b/ph7a.bmp",500,425); |
||
364 | |||
365 | if (grp>0) group_activate(grp); |
||
366 | |||
367 | esc=0; |
||
368 | while (!esc) { |
||
369 | if (keyb_getcode(&k,NON_BLOCK)) { |
||
370 | if(k.ascii==13) esc=1; |
||
371 | else if (k.ascii=='a') task_activate(ph1); |
||
372 | else if (k.ascii=='s') task_activate(ph2); |
||
373 | else if (k.ascii=='d') task_activate(ph3); |
||
374 | } |
||
375 | task_delay(MAINSLEEP); |
||
376 | } |
||
377 | |||
378 | #ifndef NOGRX |
||
379 | grx_close(); |
||
380 | #endif |
||
381 | |||
382 | sys_end(); |
||
383 | return 0; |
||
384 | } |