34,9 → 34,11 |
*/ |
|
#include "kernel/kern.h" |
#include "stdlib.h" |
|
#include "drivers/shark_keyb26.h" |
#include "drivers/shark_videodev26.h" |
#include "drivers/shark_fb26.h" |
|
#define WIDTH 640 |
#define HEIGHT 480 |
58,6 → 60,8 |
|
} |
|
void elaborate_image(void *imageptr); |
|
TASK grab_task(void *arg) { |
|
struct video_picture vpic; |
64,6 → 68,7 |
struct video_buffer fbuf; |
struct video_window win; |
struct video_channel chan; |
int on; |
|
task_nopreempt(); |
|
71,26 → 76,27 |
|
VIDEODEV26_ioctl(0,VIDIOCGCHAN,(unsigned long)&chan); |
|
chan.channel = (int)(arg); |
|
chan.channel = (int)(arg); |
|
VIDEODEV26_ioctl(0,VIDIOCSCHAN,(unsigned long)&chan); |
|
VIDEODEV26_ioctl(0,VIDIOCGPICT,(unsigned long)&vpic); |
|
vpic.palette = VIDEO_PALETTE_RGB565; |
|
vpic.palette = VIDEO_PALETTE_GREY; |
vpic.depth = 8; |
|
VIDEODEV26_ioctl(0,VIDIOCSPICT,(unsigned long)&vpic); |
|
fbuf.base = malloc(640*480*2); |
|
fbuf.base = malloc(320*200); |
fbuf.height = 200; |
fbuf.width = 320; |
fbuf.height = 200; |
fbuf.bytesperline = 640*2; |
fbuf.depth = 16; |
fbuf.bytesperline = 320; |
fbuf.depth = 8; |
|
VIDEODEV26_ioctl(0,VIDIOCSFBUF,(unsigned long)&fbuf); |
|
|
VIDEODEV26_ioctl(0,VIDIOCGWIN,(unsigned long)&win); |
|
|
win.x = 0; |
win.y = 0; |
win.width = 320; |
97,56 → 103,48 |
win.height = 200; |
|
VIDEODEV26_ioctl(0,VIDIOCSWIN,(unsigned long)&win); |
|
|
task_preempt(); |
|
while(1) { |
|
task_nopreempt(); |
|
VIDEODEV26_ioctl(0,VIDIOCCAPTURE,NULL); |
|
VIDEODEV26_ioctl(0,VIDIOCSFBUF,(unsigned long)&fbuf); |
|
on = 1; |
VIDEODEV26_ioctl(0,VIDIOCCAPTURE,(unsigned long)&on); |
|
task_preempt(); |
|
task_endcycle(); |
|
elaborate_image(fbuf.base); |
|
task_endcycle(); |
|
} |
|
return NULL; |
|
} |
|
extern void *video_memory; |
|
void elaborate_image(void *imageptr) |
{ |
/* |
|
WORD x,y; |
BYTE *col; |
|
if (color == FG_MONO) { |
|
for(y = 0; y < FG_H; y++) |
for(x = 0; x < FG_W; x++) { |
|
col = (BYTE *)(imageptr + y*FG_W + x); |
*(WORD *)(video_buf + y*(WIDTH*2) + (x*2)) = (WORD)rgb16(*(BYTE *)(col),*(BYTE *)(col),*(BYTE *)(col)); |
col = (BYTE *)(imageptr + y * FG_W + x); |
*(WORD *)(video_memory + y*(WIDTH*2) + (x*2)) = (WORD)rgb16(*(BYTE *)(col),*(BYTE *)(col),*(BYTE *)(col)); |
|
} |
|
} |
|
if (color == FG_RGB24) { |
|
for(y = 0; y < FG_H; y++) |
for(x = 0; x < FG_W; x++) { |
|
col = (BYTE *)(imageptr + y*(FG_W*3) + (x*3)); |
*(WORD *)(video_buf + y*(WIDTH*2) + (x*2)) = (WORD)rgb16(*(BYTE *)(col),*(BYTE *)(col+1),*(BYTE *)(col+2)); |
|
} |
|
} |
*/ |
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)); |
|
} |
|
int main(int argc, char **argv) |
156,8 → 154,8 |
PID grab_task_pid; |
|
soft_task_default_model(st); |
soft_task_def_period(st,50000); |
soft_task_def_met(st,10000); |
soft_task_def_period(st,100000); |
soft_task_def_met(st,40000); |
soft_task_def_arg(st, (void *)(1)); |
soft_task_def_ctrl_jet(st); |
|