Rev 267 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/* Fast Frame Grabber for SHARK
*
* Giacomo Guidi
* <giacomo@gandalf.sssup.it>
*
*/
#include <drivers/fg.h>
#include <linuxcomp.h>
#include <drivers/bttv.h>
#include <drivers/bttvp.h>
extern void bttv_start(struct bttv *btv);
extern int bttv_ioctl(struct bttv *btv, unsigned int cmg, void *arg);
extern void bttv_close(struct bttv *btv);
extern unsigned int gbufsize;
static struct bttv btv;
static struct video_mmap vmm;
static void * fbuf_pointer;
static void (*elaborate_frame_hook)(void * ptrframe);
void dummy_elaborate_frame(void * ptrframe)
{
}
void FG_refresh(void)
{
int err;
while(1) {
if (vmm.frame == 0) {
vmm.frame = 1;
// fbuf_pointer = (void *)(btv.fbuffer);
/* *(BYTE *)fbuf_pointer = 255;
* *(BYTE *)(fbuf_pointer+1) = 0;
*/
} else {
vmm.frame = 0;
//fbuf_pointer = btv.fbuffer+gbufsize;
/* *(BYTE *)fbuf_pointer = 0;
* *(BYTE *)(fbuf_pointer+1) = 255;
*/
}
err = bttv_ioctl(&btv, VIDIOCMCAPTURE, &vmm);
if (err) //kern_printf("(BTTV_IOCTL Error: %d)",err);
elaborate_frame_hook(fbuf_pointer);
}
}
int FG_init(unsigned int period, unsigned int wcet, unsigned int width,
unsigned int height, unsigned int color, unsigned int channel) {
int err;
struct video_window vw;
struct video_picture p;
struct video_channel ch;
bttv_start(&btv);
err = bttv_ioctl(&btv, VIDIOCGWIN, &vw);
if (err) {
//kern_printf("(BTTV_IOCTL VIDIOCGWIN Error: %d)",err);
}
vw.x = 0;
vw.y = 0;
vw.width = width;
vw.height = height;
err = bttv_ioctl(&btv, VIDIOCSWIN, &vw);
if (err) {
//kern_printf("(BTTV_IOCTL VIDIOCSWIN Error: %d)",err);
//sys_end();
}
err = bttv_ioctl(&btv, VIDIOCGPICT, &p);
if (err) {
//kern_printf("(BTTV_IOCTL VIDIOCGPICT Error: %d)",err);
//sys_end();
}
if (color == FG_RGB24) {
p.palette = VIDEO_PALETTE_RGB24;
p.depth = 24;
}
if (color == FG_MONO) {
p.palette = VIDEO_PALETTE_GREY;
p.depth = 8;
}
if (color == FG_YUYV) {
p.palette = VIDEO_PALETTE_YUYV;
p.depth = 16;
}
err = bttv_ioctl(&btv, VIDIOCSPICT, &p);
if (err) {
//kern_printf("(BTTV_IOCTL VIDIOCSPICT Error: %d)",err);
//sys_end();
}
ch.channel = channel;
err = bttv_ioctl(&btv, VIDIOCGCHAN, &ch);
if (err) {
//kern_printf("(BTTV_IOCTL VIDIOCGCHAN Error: %d)",err);
//sys_end();
}
ch.norm = VIDEO_MODE_PAL;
ch.type = VIDEO_TYPE_CAMERA;
err = bttv_ioctl(&btv, VIDIOCSCHAN, &ch);
if (err) {
//kern_printf("(BTTV_IOCTL VIDIOCSCHAN Error: %d)",err);
//sys_end();
}
vmm.frame = 0;
vmm.height = vw.height;
vmm.width = vw.width;
vmm.format = p.palette;
err = bttv_ioctl(&btv, VIDIOCMCAPTURE, &vmm);
if (err) {
//kern_printf("(BTTV_IOCTL VIDIOCMCAPTURE Error: %d)",err);
//sys_end();
}
elaborate_frame_hook = dummy_elaborate_frame;
return 0;
}
void FG_start_grabbing(void)
{
}
void FG_close(void)
{
bttv_close(&btv);
}
void * FG_getbuffer(void)
{
return fbuf_pointer;
}
void FG_set_hook(void * funptr)
{
elaborate_frame_hook = (void *)funptr;
}