Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1189 → Rev 1423

/demos/trunk/bttvdemo/bttv.c
34,12 → 34,10
*/
 
#include "kernel/kern.h"
#include <drivers/fg.h>
#include <drivers/glib.h>
#include <drivers/keyb.h>
#include <unistd.h>
#include <stdlib.h>
 
#include "drivers/shark_keyb26.h"
#include "drivers/shark_videodev26.h"
 
#define WIDTH 640
#define HEIGHT 480
#define BYTES_PP 2
53,39 → 51,72
#define FG_W 320
#define FG_H 200
 
unsigned int color = FG_MONO;
void program_end(void *arg)
{
 
extern DWORD flbaddr;
sys_end();
}
 
static void screen()
{
TASK grab_task(void *arg) {
 
/* graphic card Initialization */
if (grx_init() < 1) {
sys_abort(1);
}
if (grx_open(640, 480, 16) < 0) {
cprintf("GRX Err\n");
sys_abort(1);
}
struct video_picture vpic;
struct video_buffer fbuf;
struct video_window win;
struct video_channel chan;
 
video_buf = (unsigned char *)flbaddr;
}
task_nopreempt();
 
void program_end(void *arg)
{
VIDEODEV26_open(0);
VIDEODEV26_ioctl(0,VIDIOCGCHAN,(unsigned long)&chan);
chan.channel = (int)(arg);
VIDEODEV26_ioctl(0,VIDIOCSCHAN,(unsigned long)&chan);
VIDEODEV26_ioctl(0,VIDIOCGPICT,(unsigned long)&vpic);
vpic.palette = VIDEO_PALETTE_RGB565;
VIDEODEV26_ioctl(0,VIDIOCSPICT,(unsigned long)&vpic);
fbuf.base = malloc(640*480*2);
fbuf.width = 320;
fbuf.height = 200;
fbuf.bytesperline = 640*2;
fbuf.depth = 16;
VIDEODEV26_ioctl(0,VIDIOCSFBUF,(unsigned long)&fbuf);
 
grx_close();
VIDEODEV26_ioctl(0,VIDIOCGWIN,(unsigned long)&win);
 
sys_end();
win.x = 0;
win.y = 0;
win.width = 320;
win.height = 200;
VIDEODEV26_ioctl(0,VIDIOCSWIN,(unsigned long)&win);
task_preempt();
while(1) {
task_nopreempt();
VIDEODEV26_ioctl(0,VIDIOCCAPTURE,NULL);
 
task_preempt();
 
task_endcycle();
 
}
 
}
 
void elaborate_image(void *imageptr)
{
 
/*
WORD x,y;
BYTE *col;
 
112,9 → 143,9
}
 
}
 
//printf_xy(0,0,WHITE,"Grabbed = %08lx",*(DWORD *)(imageptr + 50*FG_W + 50));
//printf_xy(0,1,WHITE,"Grabbed = %08lx",*(DWORD *)(imageptr + 51*FG_W + 50));
*/
printf_xy(0,0,WHITE,"Grabbed = %08lx",*(DWORD *)(imageptr + 50*FG_W + 50));
printf_xy(0,1,WHITE,"Grabbed = %08lx",*(DWORD *)(imageptr + 51*FG_W + 50));
}
 
121,33 → 152,27
int main(int argc, char **argv)
{
 
int channel = 0;
if (argc < 2) {
channel = 0;
} else {
channel = atoi(argv[1]);
}
sys_atrunlevel(program_end,NULL, RUNLEVEL_BEFORE_EXIT);
screen();
//video_buf = malloc(RGB565MEM);
SOFT_TASK_MODEL st;
PID grab_task_pid;
 
sleep(1);
soft_task_default_model(st);
soft_task_def_period(st,50000);
soft_task_def_met(st,10000);
soft_task_def_arg(st, (void *)(1));
soft_task_def_ctrl_jet(st);
FG_init(FG_PERIOD, FG_WCET, FG_W, FG_H, color, channel);
grab_task_pid = task_create("GrabTask",grab_task,&st,NULL);
if (grab_task_pid == NIL) {
cprintf("ERROR: Cannot create grab task\n");
sys_end();
}
 
FG_set_hook(elaborate_image);
task_activate(grab_task_pid);
 
FG_start_grabbing();
while(keyb_getch(BLOCK) != ESC);
 
FG_close();
sys_end();
 
sys_end();
return 0;
 
}
/demos/trunk/bttvdemo/initfile.c
1,104 → 1,68
/*
* Project: S.Ha.R.K.
* Project: S.Ha.R.K
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
* Coordinators: Giorgio Buttazzo <giorgio@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
* http://hartik.sssup.it
*/
 
/*
------------
CVS : $Id: initfile.c,v 1.1 2003-05-22 14:12:29 giacomo Exp $
 
File: $File$
Revision: $Revision: 1.1 $
Last update: $Date: 2003-05-22 14:12:29 $
------------
 
System initialization file
 
This file contains the 2 functions needed to initialize the system.
 
These functions register the following levels:
 
an EDF (Earliest Deadline First) level
a RR (Round Robin) level
a CBS (Costant Bandwidth Server) level
a Dummy level
 
It can accept these task models:
 
HARD_TASK_MODEL (wcet+mit) at level 0
SOFT_TASK_MODEL (met, period) at level 1
NRT_TASK_MODEL at level 2
 
This file is similar to the configuration of kernel/init/hartik3.c
 
TICK is set to 0 (one-shot timer is used)
*/
 
/*
* Copyright (C) 2000 Paolo Gai
*
* 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
*
*/
 
#include "kernel/kern.h"
#include "modules/edf.h"
#include "modules/cbs.h"
#include "modules/hardcbs.h"
#include "modules/rr.h"
#include "modules/dummy.h"
#include "modules/intdrive.h"
 
#include "modules/sem.h"
#include "modules/hartport.h"
#include "modules/cabs.h"
 
#include "drivers/keyb.h"
#include <drivers/shark_linuxc26.h>
#include <drivers/shark_pci26.h>
#include <drivers/shark_input26.h>
#include <drivers/shark_keyb26.h>
#include <drivers/shark_fb26.h>
#include <drivers/shark_i2c26.h>
#include <drivers/shark_bttv26.h>
#include <drivers/shark_videodev26.h>
 
#define FRAME_BUFFER_DEVICE 0
 
/*+ sysyem tick in us +*/
#define TICK 1000
#define TICK 0
 
/*+ RR tick in us +*/
#define RRTICK 10000
 
/*+ Interrup Server */
#define INTDRIVE_Q 1000
#define INTDRIVE_T 10000
#define INTDRIVE_FLAG 0
 
void call_shutdown_task(void *arg);
int device_drivers_init();
int device_drivers_close();
void set_shutdown_task();
TASK shutdown_task_body(void *arg);
 
PID shutdown_task_PID = -1;
 
TIME __kernel_register_levels__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
EDF_register_level(EDF_ENABLE_ALL);
CBS_register_level(CBS_ENABLE_ALL, 0);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
dummy_register_level();
INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG);
EDF_register_level(EDF_ENABLE_ALL);
HCBS_register_level(HCBS_ENABLE_ALL, 1);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
dummy_register_level();
 
SEM_register_module();
SEM_register_module();
 
CABS_register_module();
 
return TICK;
return TICK;
}
 
TASK __init__(void *arg)
105,16 → 69,107
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
KEYB_PARMS kparms = BASE_KEYB;
 
HARTPORT_init();
 
keyb_def_ctrlC(kparms, NULL);
keyb_def_map(kparms,itaMap);
KEYB_init(&kparms);
set_shutdown_task();
 
device_drivers_init();
 
sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN);
 
__call_main__(mb);
 
return (void *)0;
}
 
void set_shutdown_task() {
 
NRT_TASK_MODEL nrt;
 
nrt_task_default_model(nrt);
nrt_task_def_system(nrt);
 
shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL);
if (shutdown_task_PID == NIL) {
sys_shutdown_message("Error: Cannot create shutdown task\n");
sys_end();
}
 
}
 
int device_drivers_init() {
 
int res;
KEYB_PARMS kparms = BASE_KEYB;
LINUXC26_register_module();
 
PCI26_init();
 
I2C26_init();
 
INPUT26_init();
 
keyb_def_ctrlC(kparms, NULL);
 
KEYB26_init(&kparms);
 
BTTV26_init();
 
/*
FB26_init();
res = FB26_open(FRAME_BUFFER_DEVICE);
if (res) {
cprintf("Error: Cannot open graphical mode\n");
KEYB26_close();
INPUT26_close();
sys_end();
}
FB26_use_grx(FRAME_BUFFER_DEVICE);
FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16");
*/
return 0;
 
}
 
int device_drivers_close() {
/*
FB26_close(FRAME_BUFFER_DEVICE);
*/
KEYB26_close();
INPUT26_close();
return 0;
}
 
#define SHUTDOWN_TIMEOUT_SEC 3
 
void call_shutdown_task(void *arg)
{
struct timespec t;
 
sys_gettime(&t);
t.tv_sec += SHUTDOWN_TIMEOUT_SEC;
 
/* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */
kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0);
 
task_activate(shutdown_task_PID);
}
 
TASK shutdown_task_body(void *arg) {
 
device_drivers_close();
 
sys_shutdown_message("-- S.Ha.R.K. Closed --\n");
 
sys_abort_shutdown(0);
 
return NULL;
 
}
/demos/trunk/bttvdemo/makefile
12,5 → 12,5
include $(BASE)/config/example.mk
 
bttv:
make -f $(SUBMAKE) APP=bttv INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__ __BTTV__"
make -f $(SUBMAKE) APP=bttv INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__LINUXC26__ __PCI__ __INPUT__ __FB__ __I2C__ __BTTV__"