Blame |
Last modification |
View Log
| RSS feed
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Paolo Gai <pj@gandalf.sssup.it>
* (see the web pages for full authors list)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://shark.sssup.it
*/
/*
* Copyright (C) 1999 Luca Abeni and Massimiliano Giorgi
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/*
* CVS : $Id: mplay.c,v 1.1.1.1 2004-05-24 18:03:44 giacomo Exp $
*
* File: $File$
* Revision: $Revision: 1.1.1.1 $
* Last update: $Date: 2004-05-24 18:03:44 $
*/
#include "config.h"
//#include <ll/sys/types.h>
#include <kernel/func.h>
#include <kernel/const.h>
#include <trace/trace.h>
#include <trace/queues.h>
#include <drivers/glib.h>
#include <drivers/gd.h>
#include <drivers/keyb.h>
#include <fs/bdevinit.h>
#include <fs/fsinit.h>
#include <fs/bdev.h>
#include <sys/types.h>
#include <sys/mount.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "gclock.h"
#include "gvideo.h"
#include "gload.h"
#include "gbuffer.h"
#include "gphoto.h"
#include "mutex.h"
#include "xread.h"
void ctrlc_exit(KEY_EVT *k)
{
extern void dump_sem_table(void);
extern void dump_nop_table(void);
#ifndef NOGRX
grx_close();
#endif
cprintf("CTRL-C pressed!\n");
sys_end();
}
/*
*
*
*
*/
int __register_sub_init_prologue(void)
{
// int id;
#ifndef NOTRACE
TRC_init_phase1(NULL);
trc_register_fixed_queue();
id=trc_create_queue(TRC_FIXED_QUEUE,NULL);
trc_trace_class(TRC_CLASS_USER);
trc_assign_class_to_queue(TRC_CLASS_USER,id);
#endif
return 0;
}
int __register_sub_init(void)
{
#if defined(EDFSCHED)
extern void BD_EDF_register_module(void);
BD_EDF_register_module();
#elif defined(PSCANSCHED)
extern void BD_PSCAN_register_module(void);
BD_PSCAN_register_module();
#endif
return 0;
}
dev_t root_device=-1;
dev_t temp_device=-1;
int choose_root_callback(dev_t dev,u_int8_t fs)
{
if (fs==FS_MSDOS) return dev;
return -1;
}
int choose_temp_callback(__dev_t dev,__uint8_t fs)
{
static int flag=0;
if (fs==FS_MSDOS) {
if (flag) return dev;
flag=1;
}
return -1;
}
int __bdev_sub_init(void)
{
BDEV_PARMS bdev=BASE_BDEV;
bdev_def_showinfo(bdev,FALSE);
bdev_init(&bdev);
root_device=bdev_scan_devices(choose_root_callback);
if (root_device<0) {
sys_shutdown_message("can't find root device to mount on /!!!\n");
sys_end();
return -1;
}
/*
temp_device=bdev_scan_devices(choose_temp_callback);
if (temp_device<0) {
cprintf("can't find a filesystem to mount on /TEMP!!!\n");
}
*/
return 0;
}
int __fs_sub_init(void)
{
extern int libc_initialize(void);
FILESYSTEM_PARMS fs=BASE_FILESYSTEM;
// struct mount_opts opts;
// int res;
filesystem_def_rootdevice(fs,root_device);
filesystem_def_fs(fs,FS_MSDOS);
filesystem_def_showinfo(fs,FALSE);
filesystem_init(&fs);
/*
if (temp_device>=0) {
memset(&opts,0,sizeof(struct mount_opts));
opts.flags=MOUNT_FLAG_RW;
res=mount(temp_device,FS_MSDOS,"/TEMP",&opts);
if (res!=0) {
cprintf("can't mount XXX on /TEMP (errno: %i)\n",errno);
} else
cprintf("mounted /TEMP rw\n");
}
*/
libc_initialize();
#ifndef NOTRACE
TRC_init_phase2();
#endif
return 0;
}
/*
*
*
*
*/
struct {
char *filename;
int bitrate;
int framerate;
} mpegs[16]={
/* 0 */
{"/temp/m/2jaeger.mpg", 573225, 3000}, /* 3.27 bad*/
{"/temp/m/alien.mpg", 289000, 2500}, /* 10.12 I */
{"/temp/m/b0.mpg", 1725251, 3000}, /* 3.33 IBBPBBPBBPBB */
{"/temp/m/canyon.mpg", 237194, 3000}, /* 58.60 IBBPBB */
/* 4 */
{"/temp/m/earth-ci.mpg", 974900, 2500}, /* 28.80 IBBPBB */
{"/temp/m/flower.mpg", 1147101, 2997}, /* 5.01 bad */
{"/temp/m/frisco.mpg", 397262, 3000}, /* 1.70 bad */
{"/temp/m/hulahoop.mpg", 684126, 3000}, /* 1.33 bad */
/* 8 */
{"/temp/m/iicm.mpg", 527308, 3000}, /* 26.70 bad */
{"/temp/m/micky.mpg", 711240, 3000}, /* 0.66 bad */
{"/temp/m/mobile.mpg", 114622, 2997}, /* 5.01 bad */
{"/temp/m/redsnigh.mpg", 597776, 2500}, /* 48.40 IBBBBBBBBBPBBBBBBBBB*/
/* 12 */
{"/temp/m/son.mpg", 1134335, 2500}, /* 6.92 IBBPBBPBBPBB */
{"/temp/m/stoelend.mpg", 2248942, 3000}, /* 0.53 IBBPBB */
{"/temp/m/sukhoi.mpg", 481521, 3000}, /* 25.47 I */
{"/temp/m/us.mpg", 681599, 3000} /* 24.37 IBBPBB */
};
#define DEFINDEX 3
char *getfilename(int index)
{
return mpegs[index%16].filename;
}
int getbitrate(int index)
{
return mpegs[index%16].bitrate;
}
int getframerate(int index)
{
return mpegs[index%16].framerate;
}
/*
*
*
*
*/
#ifdef FULLCOLOR
#define TEXTCOLOR rgb16(0,255,0)
#define TEXTCOLOR2 rgb16(255,255,255)
#define TEXTBG rgb16(0,0,0)
#else
#define TEXTCOLOR 255
#define TEXTCOLOR2 255
#define TEXTBG 0
#endif
#define SCREENX 800
#define SCREENY 600
#define MAINSLEEP 20000
g_sem_t grxsem;
int main(int argc, char *argv[])
{
struct gvideoinfo info;
KEY_EVT k;
int index;
int mode;
int esc;
int pid,grp;
// int i;
int sx=20;
PID ph1,ph2,ph3;
g_sem_init(&grxsem,1);
/*
if (argc<2) {
cprintf("Usage: %s mpegfileordinal\n",argv[0]);
sys_abort(301);
}
*/
/* init the "file reader tasks" module */
x_init();
/* Init the graph... */
#ifndef NOGRX
if (grx_init()==-1) {
cprintf("No init!!!\n");
sys_abort(255);
}
#ifdef FULLCOLOR
mode=grx_getmode(SCREENX,SCREENY,16);
#else
mode=grx_getmode(SCREENX,SCREENY,8);
#endif
if (mode==-1) {
cprintf("Mode not present!!!\n");
sys_abort(255);
}
#endif
cprintf("[hit enter to continue]\n");
esc=FALSE;
while (!esc) {
keyb_getcode(&k,BLOCK);
if (k.ascii==13) esc=TRUE;
}
#ifndef NOGRX
if (grx_setmode(mode) == -1) {
cprintf("No SetMode!!!\n");
sys_abort(255);
}
#endif
#ifndef NOGRX
grx_text("HARTIK 4.0 (Lego)",12*2,22,TEXTCOLOR,TEXTBG);
grx_text("[Filesystem demo]",12*2,22+10,TEXTCOLOR,TEXTBG);
grx_text("Video : 8bit/pixel",250,450,TEXTCOLOR2,TEXTBG);
grx_text("Double buffer: YES",250,450+10,TEXTCOLOR2,TEXTBG);
grx_text("Algorithm : FCFS",250,450+20,TEXTCOLOR2,TEXTBG);
#endif
pid=gclock_init(32+64+64,540);
task_activate(pid);
//for (i=0;i<argc-1;i++) {
//index=atoi(argv[i+1]);
index=4;
info.x=sx+30;
info.y=80;
info.pathname=getfilename(index);
info.bitrate=getbitrate(index);
info.framerate=getframerate(index);
info.band=25;
grp=gvideo_init("Video: earth.mpg", &info);
//if (grp>0) group_activate(grp);
sx+=info.w+15;
//}
pid=gload_init(1);
task_activate(pid);
ph1=gphoto_show("Photo: galaxy","/temp/b/ph2a.bmp",500,25);
ph2=gphoto_show("Photo: canyon","/temp/b/ph3a.bmp",500,225);
ph3=gphoto_show("Photo: nicole","/temp/b/ph7a.bmp",500,425);
if (grp>0) group_activate(grp);
esc=0;
{
struct timespec delay;
delay.tv_sec = MAINSLEEP/1000000;
delay.tv_nsec = (MAINSLEEP%1000000)*1000;
while (!esc) {
if (keyb_getcode(&k,NON_BLOCK)) {
if(k.ascii==13) esc=1;
else if (k.ascii=='a') task_activate(ph1);
else if (k.ascii=='s') task_activate(ph2);
else if (k.ascii=='d') task_activate(ph3);
}
nanosleep(&delay, NULL);
}
}
#ifndef NOGRX
grx_close();
#endif
sys_end();
return 0;
}