Subversion Repositories shark

Rev

Rev 1117 | Go to most recent revision | Details | Compare with Previous | 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
/*
1159 pj 39
 * CVS :        $Id: mplay.c,v 1.3 2003-05-01 19:44:07 pj Exp $
1085 pj 40
 *
41
 * File:        $File$
1159 pj 42
 * Revision:    $Revision: 1.3 $
43
 * Last update: $Date: 2003-05-01 19:44:07 $
1085 pj 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>
1117 pj 69
#include <time.h>
1085 pj 70
 
71
#include "gclock.h"
72
#include "gvideo.h"
73
#include "gload.h"
74
#include "gbuffer.h"
75
#include "gphoto.h"
76
#include "mutex.h"
77
#include "xread.h"
78
 
79
void ctrlc_exit(KEY_EVT *k)
80
{
81
  extern void dump_sem_table(void);
82
  extern void dump_nop_table(void);
83
#ifndef NOGRX
84
  grx_close();
85
#endif
86
  cprintf("CTRL-C pressed!\n");
87
  sys_end();
88
}
89
 
90
/*
91
 *
92
 *
93
 *
94
 */
95
 
96
int __register_sub_init_prologue(void)
97
{
98
  //  int id;
99
#ifndef NOTRACE
100
  TRC_init_phase1(NULL);
101
  trc_register_fixed_queue();
102
  id=trc_create_queue(TRC_FIXED_QUEUE,NULL);
103
  trc_trace_class(TRC_CLASS_USER);
104
  trc_assign_class_to_queue(TRC_CLASS_USER,id);
105
#endif 
106
  return 0;
107
}
108
 
109
int __register_sub_init(void)
110
{
111
#if defined(EDFSCHED)
112
  extern void BD_EDF_register_module(void);
113
  BD_EDF_register_module();
114
#elif defined(PSCANSCHED)
115
  extern void BD_PSCAN_register_module(void);
116
  BD_PSCAN_register_module();  
117
#endif
118
  return 0;
119
}
120
 
121
dev_t root_device=-1;
122
dev_t temp_device=-1;
123
 
124
int choose_root_callback(dev_t dev,u_int8_t fs)
125
{
126
  if (fs==FS_MSDOS) return dev;
127
  return -1;
128
}
129
 
130
int choose_temp_callback(__dev_t dev,__uint8_t fs)
131
{
132
  static int flag=0;
133
  if (fs==FS_MSDOS) {
134
    if (flag) return dev;
135
    flag=1;
136
  }
137
  return -1;
138
}
139
 
140
int __bdev_sub_init(void)
141
{
142
  BDEV_PARMS bdev=BASE_BDEV;
143
 
144
  bdev_def_showinfo(bdev,FALSE);
145
  bdev_init(&bdev);
146
 
147
  root_device=bdev_scan_devices(choose_root_callback);
148
  if (root_device<0) {
1159 pj 149
    sys_shutdown_message("can't find root device to mount on /!!!\n");
1085 pj 150
    sys_end();
151
    return -1;
152
  }
153
 
154
  /*
155
  temp_device=bdev_scan_devices(choose_temp_callback);
156
  if (temp_device<0) {
157
    cprintf("can't find a filesystem to mount on /TEMP!!!\n");
158
  }
159
  */
160
 
161
  return 0;
162
}
163
 
164
int __fs_sub_init(void)
165
{
166
  extern int libc_initialize(void);
167
  FILESYSTEM_PARMS fs=BASE_FILESYSTEM;
168
  //  struct mount_opts opts;
169
  //  int res;
170
 
171
  filesystem_def_rootdevice(fs,root_device);
172
  filesystem_def_fs(fs,FS_MSDOS);
173
  filesystem_def_showinfo(fs,FALSE);
174
  filesystem_init(&fs);
175
 
176
  /*
177
  if (temp_device>=0) {
178
    memset(&opts,0,sizeof(struct mount_opts));
179
    opts.flags=MOUNT_FLAG_RW;
180
    res=mount(temp_device,FS_MSDOS,"/TEMP",&opts);
181
    if (res!=0) {
182
      cprintf("can't mount XXX on /TEMP (errno: %i)\n",errno);
183
    } else
184
      cprintf("mounted /TEMP rw\n");    
185
  }
186
  */
187
 
188
  libc_initialize();
189
 
190
#ifndef NOTRACE
191
  TRC_init_phase2();
192
#endif
193
 
194
  return 0;
195
}
196
 
197
/*
198
 *
199
 *
200
 *
201
 */
202
 
203
struct {
204
  char *filename;
205
  int  bitrate;
206
  int  framerate;
207
} mpegs[16]={
208
  /* 0 */
209
  {"/temp/m/2jaeger.mpg",   573225, 3000}, /*  3.27 bad*/
210
  {"/temp/m/alien.mpg",     289000, 2500}, /* 10.12 I */
211
  {"/temp/m/b0.mpg",       1725251, 3000}, /*  3.33 IBBPBBPBBPBB */
212
  {"/temp/m/canyon.mpg",    237194, 3000}, /* 58.60 IBBPBB */
213
  /* 4 */
214
  {"/temp/m/earth-ci.mpg",  974900, 2500}, /* 28.80 IBBPBB */
215
  {"/temp/m/flower.mpg",   1147101, 2997}, /*  5.01 bad */
216
  {"/temp/m/frisco.mpg",    397262, 3000}, /*  1.70 bad */
217
  {"/temp/m/hulahoop.mpg",  684126, 3000}, /*  1.33 bad */
218
  /* 8 */
219
  {"/temp/m/iicm.mpg",      527308, 3000}, /* 26.70 bad */
220
  {"/temp/m/micky.mpg",     711240, 3000}, /*  0.66 bad */
221
  {"/temp/m/mobile.mpg",    114622, 2997}, /*  5.01 bad */
222
  {"/temp/m/redsnigh.mpg",  597776, 2500}, /* 48.40 IBBBBBBBBBPBBBBBBBBB*/
223
  /* 12 */
224
  {"/temp/m/son.mpg",      1134335, 2500}, /*  6.92 IBBPBBPBBPBB */
225
  {"/temp/m/stoelend.mpg", 2248942, 3000}, /*  0.53 IBBPBB */
226
  {"/temp/m/sukhoi.mpg",    481521, 3000}, /* 25.47 I */
227
  {"/temp/m/us.mpg",        681599, 3000}  /* 24.37 IBBPBB */
228
};
229
 
230
#define DEFINDEX 3
231
 
232
char *getfilename(int index)
233
{
234
  return mpegs[index%16].filename;
235
}
236
 
237
int getbitrate(int index)
238
{
239
  return mpegs[index%16].bitrate;
240
}
241
 
242
int getframerate(int index)
243
{
244
  return mpegs[index%16].framerate;
245
}
246
 
247
/*
248
 *
249
 *
250
 *
251
 */
252
 
253
#ifdef FULLCOLOR
254
 
255
#define TEXTCOLOR  rgb16(0,255,0)
256
#define TEXTCOLOR2 rgb16(255,255,255)
257
#define TEXTBG     rgb16(0,0,0)
258
 
259
#else
260
 
261
#define TEXTCOLOR  255
262
#define TEXTCOLOR2 255
263
#define TEXTBG       0
264
 
265
#endif
266
 
267
#define SCREENX 800
268
#define SCREENY 600
269
 
270
#define MAINSLEEP 20000
271
 
272
g_sem_t grxsem;
273
 
274
int main(int argc, char *argv[])
275
{
276
  struct gvideoinfo info;
277
  KEY_EVT k;
278
  int index;
279
  int mode;
280
  int esc;
281
  int pid,grp;
282
  //  int i;
283
  int sx=20;
284
  PID ph1,ph2,ph3;
285
 
286
  g_sem_init(&grxsem,1);
287
 
288
  /*
289
  if (argc<2) {
290
    cprintf("Usage: %s mpegfileordinal\n",argv[0]);
291
    sys_abort(301);
292
  }
293
  */
294
 
295
  /* init the "file reader tasks" module */
296
  x_init();
297
 
298
  /* Init the graph... */
299
#ifndef NOGRX  
300
  if (grx_init()==-1) {
301
    cprintf("No init!!!\n");
302
    sys_abort(255);
303
  }
304
#ifdef FULLCOLOR
305
  mode=grx_getmode(SCREENX,SCREENY,16);
306
#else
307
  mode=grx_getmode(SCREENX,SCREENY,8);
308
#endif
309
  if (mode==-1) {
310
    cprintf("Mode not present!!!\n");
311
    sys_abort(255);
312
  }
313
#endif
314
 
315
  cprintf("[hit enter to continue]\n");
316
  esc=FALSE;
317
  while (!esc) {
318
    keyb_getcode(&k,BLOCK);
319
    if (k.ascii==13) esc=TRUE;
320
  }
321
 
322
#ifndef NOGRX  
323
  if (grx_setmode(mode) == -1) {
324
    cprintf("No SetMode!!!\n");
325
    sys_abort(255);
326
  }
327
#endif
328
 
329
#ifndef NOGRX  
330
  grx_text("HARTIK 4.0 (Lego)",12*2,22,TEXTCOLOR,TEXTBG);
331
  grx_text("[Filesystem demo]",12*2,22+10,TEXTCOLOR,TEXTBG);
332
 
333
  grx_text("Video        : 8bit/pixel",250,450,TEXTCOLOR2,TEXTBG);
334
  grx_text("Double buffer: YES",250,450+10,TEXTCOLOR2,TEXTBG);
335
  grx_text("Algorithm    : FCFS",250,450+20,TEXTCOLOR2,TEXTBG);
336
#endif
337
 
338
  pid=gclock_init(32+64+64,540);
339
  task_activate(pid);
340
 
341
  //for (i=0;i<argc-1;i++) {
342
 
343
    //index=atoi(argv[i+1]);
344
    index=4;
345
 
346
    info.x=sx+30;
347
    info.y=80;
348
    info.pathname=getfilename(index);
349
    info.bitrate=getbitrate(index);
350
    info.framerate=getframerate(index);
351
    info.band=25;
352
 
353
    grp=gvideo_init("Video: earth.mpg", &info);
354
    //if (grp>0) group_activate(grp);
355
 
356
    sx+=info.w+15;
357
  //}
358
 
359
  pid=gload_init(1);
360
  task_activate(pid);
361
 
362
  ph1=gphoto_show("Photo: galaxy","/temp/b/ph2a.bmp",500,25);
363
  ph2=gphoto_show("Photo: canyon","/temp/b/ph3a.bmp",500,225);
364
  ph3=gphoto_show("Photo: nicole","/temp/b/ph7a.bmp",500,425);
365
 
366
  if (grp>0) group_activate(grp);
367
 
368
  esc=0;
1117 pj 369
 
370
  {
371
    struct timespec delay;
372
 
373
    delay.tv_sec = MAINSLEEP/1000000;
374
    delay.tv_nsec = (MAINSLEEP%1000000)*1000;
375
 
376
    while (!esc) {
377
      if (keyb_getcode(&k,NON_BLOCK)) {
378
        if(k.ascii==13) esc=1;
379
        else if (k.ascii=='a') task_activate(ph1);
380
        else if (k.ascii=='s') task_activate(ph2);      
381
        else if (k.ascii=='d') task_activate(ph3);
382
      }
383
      nanosleep(&delay, NULL);
1085 pj 384
    }
385
  }
386
 
387
#ifndef NOGRX  
388
  grx_close();
389
#endif
390
 
391
  sys_end();
392
  return 0;
393
}