Subversion Repositories shark

Rev

Rev 1085 | Blame | Compare with Previous | 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: gvideo.c,v 1.1.1.1 2002-09-02 09:37:45 pj Exp $
 *
 * File:        $File$
 * Revision:    $Revision: 1.1.1.1 $
 * Last update: $Date: 2002-09-02 09:37:45 $
 */


//#include "config.h"

#include <kernel/func.h>
#include <kernel/model.h>
#include <kernel/const.h>

#include <drivers/glib.h>

#include <stdlib.h>

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

#include "config.h"
#include "global.h"

#define COLORFG rgb16(255,255,255)
#define COLORBG rgb16(0,0,0)

#define SP rgb16(0,128,0)
#define FG rgb16(255,255,255)
#define BG rgb16(0,0,0)

/* border size (pixels) */
#define BO 4


//#define NOGRX

/*
 *
 */



void draw_frame(int x, int y, int dx, int dy)
{
#ifndef NOGRX
  grx_box(x-1-BO,y-1-BO,x+dx+BO,y+dy+BO,SP);
  grx_rect(x-1-BO,y-1-BO,x+dx+BO,y+dy+BO,FG);
  grx_box(x,y,x+dx-1,y+dy-1,BG);
  grx_rect(x-1,y-1,x+dx,y+dy,FG);
#endif
}

static TASK play(void *arg)
{
  int x1,y1,x2,y2;
  int moreframes;
  struct framebuf_struct *fbuf;
 
  x1=1;
  y1=1;
  x2=x1+Coded_Picture_Width-1;
  y2=y1+Coded_Picture_Height-1;
 
  moreframes=1;
  task_nopreempt();

  while (moreframes) {
    fbuf = remove_frame();
#ifndef NOGRX
    //    grxlock();
//  grx_rect(10,10,10+5*fbuf->n,10+5*fbuf->n,FG);
    grx_putimage(x1, y1, x2, y2, fbuf->f);
    //    grxunlock();
#else
    cprintf("(%d %d)\n",fbuf->n, fbuf->f);
#endif
    give_back_framebuf(fbuf);
    task_endcycle();
  }
 
  return NULL;
}

void gvideo_init(void)
{
  SOFT_TASK_MODEL model;
  PID             pid;
  int             period,wcet;

#ifndef NOGRX
  grx_init();
  grx_setmode(grx_getmode(800, 600, 16));
#endif

  //  draw_frame(0, 0, CodedImageWidth,CodedImageHeight);

  srand(7);

  period=1000000/20;
  wcet=20000;
 
  soft_task_default_model(model);        
  soft_task_def_met(model,wcet);
  soft_task_def_wcet(model,wcet);
  soft_task_def_period(model,period);
  soft_task_def_periodic(model);
  soft_task_def_ctrl_jet(model);
 
  pid=task_create("Video",play,&model,NULL);
  if (pid!=-1) task_activate(pid);
}